X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fmkfs_lustre.c;h=25de036595f69b444fa3e14afb3df15605db59d2;hp=3bfe70dd644d8dfbb67e6bb1b8f168ad5c454d99;hb=14765d2816bafa2a08879ece0e33bf8c97f84948;hpb=90b07fe52702f58eb9b60dbc6bce88d9c7cbd3cb diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 3bfe70d..25de036 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -50,6 +50,7 @@ #include #include #include +#include #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);