X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fmkfs_lustre.c;h=b6a7f260c909ad3a92ebb5061453b47e8d8a91ce;hb=4f958e8d4ebe2b040d4ee01e9f205e15aecf8498;hp=8f852357896e6198c66b92588312a2595bd828f9;hpb=3c670d0a3e156a4b051b07a4d6ef7b001f8dcf69;p=fs%2Flustre-release.git diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 8f85235..b6a7f26 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -40,9 +40,9 @@ #include #ifdef __linux__ -/* kp30.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h which +/* libcfs.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h which * requires BITS_PER_LONG to be defined */ -#include +#include #include /* for BLKGETSIZE64 */ #include #endif @@ -50,6 +50,7 @@ #include #include #include +#include "mount_utils.h" #ifndef PATH_MAX #define PATH_MAX 4096 @@ -73,8 +74,8 @@ struct mkfs_opts { int mo_mgs_failnodes; }; -static char *progname; -static int verbose = 1; +char *progname; +int verbose = 1; static int print_only = 0; static int failover = 0; @@ -125,12 +126,6 @@ void usage(FILE *out) #define vprint if (verbose > 0) printf #define verrprint if (verbose >= 0) printf -static void fatal(void) -{ - verbose = 0; - fprintf(stderr, "\n%s FATAL: ", progname); -} - /*================ utility functions =====================*/ char *strscat(char *dst, char *src, int buflen) { @@ -185,47 +180,6 @@ int get_os_version() return version; } -int run_command(char *cmd, int cmdsz) -{ - char log[] = "/tmp/mkfs_logXXXXXX"; - int fd = -1, rc; - - if ((cmdsz - strlen(cmd)) < 6) { - fatal(); - fprintf(stderr, "Command buffer overflow: %.*s...\n", - cmdsz, cmd); - return ENOMEM; - } - - if (verbose > 1) { - printf("cmd: %s\n", cmd); - } else { - if ((fd = mkstemp(log)) >= 0) { - close(fd); - strcat(cmd, " >"); - strcat(cmd, log); - } - } - strcat(cmd, " 2>&1"); - - /* Can't use popen because we need the rv of the command */ - rc = system(cmd); - if (rc && (fd >= 0)) { - char buf[128]; - FILE *fp; - fp = fopen(log, "r"); - if (fp) { - while (fgets(buf, sizeof(buf), fp) != NULL) { - printf(" %s", buf); - } - fclose(fp); - } - } - if (fd >= 0) - remove(log); - return rc; -} - static int check_mtab_entry(char *spec) { FILE *fp; @@ -449,6 +403,7 @@ static int file_in_dev(char *file_name, char *dev_name) if (strstr(debugfs_cmd, "unsupported feature")) { disp_old_e2fsprogs_msg("an unknown", 0); } + pclose(fp); return -1; } pclose(fp); @@ -912,6 +867,10 @@ int read_local_files(struct mkfs_opts *mop) dev = mop->mo_device; + /* TODO: it's worth observing the get_mountdata() function that is + in mount_utils.c for getting the mountdata out of the + filesystem */ + /* Construct debugfs command line. */ snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s/mountdata' %s", MOUNT_DATA_FILE, tmpdir, dev);