Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=ec2b6270b29... Commit: ec2b6270b291a671b70a17a12389d8fecaabd61b Parent: 5d4dbd94f5244f45fb6ee01d27353a0a7a2fd6d9 Author: Andrew Price anprice@redhat.com AuthorDate: Tue Oct 7 21:23:29 2014 +0100 Committer: Andrew Price anprice@redhat.com CommitterDate: Tue Oct 7 21:23:29 2014 +0100
libgfs2: Remove path_name from struct gfs2_sbd
This is another gfs2_sbd field which needn't be kept in libgfs2. In the gfs2_jadd case, create a new structure in which to store command options, including the mount point path.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/libgfs2/libgfs2.h | 4 +-- gfs2/libgfs2/misc.c | 4 +- gfs2/mkfs/main_grow.c | 9 +++---- gfs2/mkfs/main_jadd.c | 53 ++++++++++++++++++++++++----------------------- 4 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 658fd4f..6509e9b 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -280,8 +280,6 @@ struct gfs2_sbd { unsigned int rgsize; /* Size of resource groups (in MB) */ unsigned int qcsize; /* Size of quota change files (in MB) */
- char *path_name; - /* Constants */
uint32_t sd_fsb2bb; @@ -679,7 +677,7 @@ extern int lgfs2_open_mnt_dev(const char *path, int flags, struct mntent **mnt); extern int lgfs2_open_mnt_dir(const char *path, int flags, struct mntent **mnt); extern int find_gfs2_meta(struct gfs2_sbd *sdp); extern int dir_exists(const char *dir); -extern int mount_gfs2_meta(struct gfs2_sbd *sdp); +extern int mount_gfs2_meta(struct gfs2_sbd *sdp, const char *path); extern void cleanup_metafs(struct gfs2_sbd *sdp); extern int is_fsname(char *name);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c index a66ca4f..6feccad 100644 --- a/gfs2/libgfs2/misc.c +++ b/gfs2/libgfs2/misc.c @@ -222,7 +222,7 @@ static void sighandler(int error) metafs_interrupted = 1; }
-int mount_gfs2_meta(struct gfs2_sbd *sdp) +int mount_gfs2_meta(struct gfs2_sbd *sdp, const char *path) { int ret; struct sigaction sa = { .sa_handler = &sighandler }; @@ -242,7 +242,7 @@ int mount_gfs2_meta(struct gfs2_sbd *sdp) sigaction(SIGCONT, &sa, NULL); sigaction(SIGUSR1, &sa, NULL); sigaction(SIGUSR2, &sa, NULL); - ret = mount(sdp->path_name, sdp->metafs_path, "gfs2meta", 0, NULL); + ret = mount(path, sdp->metafs_path, "gfs2meta", 0, NULL); if (ret) { rmdir(sdp->metafs_path); return -1; diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index 4c1225c..79ba56a 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -306,9 +306,9 @@ trunc: /** * print_info - Print out various bits of (interesting?) information */ -static void print_info(struct gfs2_sbd *sdp, char *device) +static void print_info(struct gfs2_sbd *sdp, char *device, char *mnt_path) { - log_notice("FS: %-25s%s\n", _("Mount point:"), sdp->path_name); + log_notice("FS: %-25s%s\n", _("Mount point:"), mnt_path); log_notice("FS: %-25s%s\n", _("Device:"), device); log_notice("FS: %-25s%llu (0x%llx)\n", _("Size:"), (unsigned long long)fssize, (unsigned long long)fssize); @@ -352,7 +352,6 @@ void main_grow(int argc, char *argv[]) fprintf(stderr, _("%s: not a mounted gfs2 file system\n"), argv[optind]); continue; } - sdp->path_name = mnt->mnt_dir;
if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo) < 0) { perror(mnt->mnt_fsname); @@ -373,7 +372,7 @@ void main_grow(int argc, char *argv[]) exit(EXIT_FAILURE); } fix_device_geometry(sdp); - if (mount_gfs2_meta(sdp)) { + if (mount_gfs2_meta(sdp, mnt->mnt_dir)) { perror(_("Failed to mount GFS2 meta file system")); exit(EXIT_FAILURE); } @@ -429,7 +428,7 @@ void main_grow(int argc, char *argv[]) error = -1; goto out; } - print_info(sdp, mnt->mnt_fsname); + print_info(sdp, mnt->mnt_fsname, mnt->mnt_dir); rgcount = initialize_new_portion(sdp, rgs); if (rgcount == 0 || metafs_interrupted) goto out; diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c index d468a6f..4968ec9 100644 --- a/gfs2/mkfs/main_jadd.c +++ b/gfs2/mkfs/main_jadd.c @@ -27,8 +27,11 @@ #define BUF_SIZE 4096 #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))
-static int quiet = 0; -static int debug = 0; +struct jadd_opts { + char *path; + unsigned quiet:1; + unsigned debug:1; +};
static void make_jdata(int fd, const char *value) @@ -116,7 +119,7 @@ static void print_usage(const char *prog_name) * */
-static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) +static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp, struct jadd_opts *opts) { int cont = TRUE; int optchar; @@ -129,7 +132,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) sdp->qcsize = atoi(optarg); break; case 'D': - debug = 1; + opts->debug = 1; lgfs2_set_debug(1); break; case 'h': @@ -143,7 +146,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) sdp->md.journals = atoi(optarg); break; case 'q': - quiet = 1; + opts->quiet = 1; break; case 'V': printf("gfs2_jadd %s (built %s %s)\n", VERSION, @@ -166,7 +169,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) }
if (optind < argc) { - sdp->path_name = argv[optind]; + opts->path = argv[optind]; optind++; } else die( _("no path specified (try -h for help)\n")); @@ -174,13 +177,13 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) if (optind < argc) die( _("Unrecognized argument: %s\n"), argv[optind]);
- if (debug) { + if (opts->debug) { printf( _("Command Line Arguments:\n")); printf(" qcsize = %u\n", sdp->qcsize); printf(" jsize = %u\n", sdp->jsize); printf(" journals = %u\n", sdp->md.journals); - printf(" quiet = %d\n", quiet); - printf(" path = %s\n", sdp->path_name); + printf(" quiet = %u\n", opts->quiet); + printf(" path = %s\n", opts->path); } }
@@ -200,14 +203,14 @@ static void verify_arguments(struct gfs2_sbd *sdp) * */
-static void print_results(struct gfs2_sbd *sdp) +static void print_results(struct gfs2_sbd *sdp, struct jadd_opts *opts) { - if (debug) + if (opts->debug) printf("\n"); - else if (quiet) + else if (opts->quiet) return;
- printf( _("Filesystem: %s\n"), sdp->path_name); + printf( _("Filesystem: %s\n"), opts->path); printf( _("Old Journals: %u\n"), sdp->orig_journals); printf( _("New Journals: %u\n"), sdp->md.journals);
@@ -364,12 +367,11 @@ add_qc(struct gfs2_sbd *sdp) } }
-static void -gather_info(struct gfs2_sbd *sdp) +static void gather_info(struct gfs2_sbd *sdp, struct jadd_opts *opts) { struct statfs statbuf; - if (statfs(sdp->path_name, &statbuf) < 0) { - perror(sdp->path_name); + if (statfs(opts->path, &statbuf) < 0) { + perror(opts->path); exit(EXIT_FAILURE); } sdp->bsize = statbuf.f_bsize; @@ -485,6 +487,7 @@ add_j(struct gfs2_sbd *sdp)
void main_jadd(int argc, char *argv[]) { + struct jadd_opts opts = {0}; struct gfs2_sbd sbd, *sdp = &sbd; struct mntent *mnt; unsigned int total; @@ -494,23 +497,21 @@ void main_jadd(int argc, char *argv[]) sdp->qcsize = GFS2_DEFAULT_QCSIZE; sdp->md.journals = 1;
- decode_arguments(argc, argv, sdp); + decode_arguments(argc, argv, sdp, &opts); verify_arguments(sdp);
- sbd.path_fd = lgfs2_open_mnt_dir(sbd.path_name, O_RDONLY|O_CLOEXEC, &mnt); + sbd.path_fd = lgfs2_open_mnt_dir(opts.path, O_RDONLY|O_CLOEXEC, &mnt); if (sbd.path_fd < 0) { - fprintf(stderr, _("Error looking up mount '%s': %s\n"), sbd.path_name, strerror(errno)); + fprintf(stderr, _("Error looking up mount '%s': %s\n"), opts.path, strerror(errno)); exit(EXIT_FAILURE); } if (mnt == NULL) { - fprintf(stderr, _("%s: not a mounted gfs2 file system\n"), sbd.path_name); + fprintf(stderr, _("%s: not a mounted gfs2 file system\n"), opts.path); exit(EXIT_FAILURE); } - sbd.path_name = mnt->mnt_dir; - - gather_info(sdp); + gather_info(sdp, &opts);
- if (mount_gfs2_meta(sdp)) { + if (mount_gfs2_meta(sdp, mnt->mnt_dir)) { perror("GFS2 metafs"); exit(EXIT_FAILURE); } @@ -538,5 +539,5 @@ void main_jadd(int argc, char *argv[]) close(sdp->path_fd); cleanup_metafs(sdp); sync(); - print_results(sdp); + print_results(sdp, &opts); }
cluster-commits@lists.fedorahosted.org