Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5d4dbd94f52... Commit: 5d4dbd94f5244f45fb6ee01d27353a0a7a2fd6d9 Parent: c136b342699b1a690fac1e05afb1d94b77471a43 Author: Andrew Price anprice@redhat.com AuthorDate: Tue Oct 7 20:30:08 2014 +0100 Committer: Andrew Price anprice@redhat.com CommitterDate: Tue Oct 7 20:30:08 2014 +0100
libgfs2: Remove device_name from struct gfs2_sbd
Remove this field from struct gfs2_sbd because, * It arbitrarily limits the path length * It bloats the struct by PATH_MAX (commonly 4096) chars * It isn't used by libgfs2 itself
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/edit/hexedit.c | 6 ++---- gfs2/edit/savemeta.c | 3 ++- gfs2/fsck/initialize.c | 2 +- gfs2/libgfs2/libgfs2.h | 1 - gfs2/mkfs/main_grow.c | 10 ++++------ gfs2/mkfs/main_jadd.c | 1 - 6 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index b316065..dd4b625 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1000,7 +1000,7 @@ static void read_superblock(int fd) if (!sbd.bsize) sbd.bsize = GFS2_DEFAULT_BSIZE; if (lgfs2_get_dev_info(fd, &sbd.dinfo)) { - perror(sbd.device_name); + perror(device); exit(-1); } if(compute_constants(&sbd)) { @@ -1401,8 +1401,7 @@ uint64_t check_keywords(const char *kword) if (sbd.gfs1) fprintf(stderr, "This is GFS1; there's no master directory.\n"); else if (!sbd.sd_sb.sb_master_dir.no_addr) { - fprintf(stderr, "GFS2 master directory not found on %s\n", - sbd.device_name); + fprintf(stderr, "GFS2 master directory not found on %s\n", device); exit(-1); } else blk = sbd.sd_sb.sb_master_dir.no_addr; @@ -2541,7 +2540,6 @@ int main(int argc, char *argv[])
read_superblock(fd); max_block = lseek(fd, 0, SEEK_END) / sbd.bsize; - strcpy(sbd.device_name, device); if (sbd.gfs1) edit_row[GFS2_MODE]++; else diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 5147ee5..5d30d28 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -62,6 +62,7 @@ static uint64_t journal_blocks[MAX_JOURNALS_SAVED]; static uint64_t gfs1_journal_size = 0; /* in blocks */ static int journals_found = 0; int print_level = MSG_NOTICE; +extern char *device;
static int block_is_a_journal(void) { @@ -737,7 +738,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel) if (!sbd.gfs1) sbd.bsize = GFS2_DEFAULT_BSIZE; if (lgfs2_get_dev_info(sbd.device_fd, &sbd.dinfo)) { - perror(sbd.device_name); + perror(device); exit(-1); } fix_device_geometry(&sbd); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 4dedec2..4e52262 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1608,7 +1608,7 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen, }
if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo)) { - perror(sdp->device_name); + perror(opts.device); return FSCK_ERROR; }
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index f33b838..658fd4f 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -280,7 +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 device_name[PATH_MAX]; char *path_name;
/* Constants */ diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index c4f5055..4c1225c 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -305,12 +305,11 @@ trunc:
/** * print_info - Print out various bits of (interesting?) information - * */ -static void print_info(struct gfs2_sbd *sdp) +static void print_info(struct gfs2_sbd *sdp, char *device) { log_notice("FS: %-25s%s\n", _("Mount point:"), sdp->path_name); - log_notice("FS: %-25s%s\n", _("Device:"), sdp->device_name); + 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); log_notice("FS: %-25s%u (0x%x)\n", _("New resource group size:"), rgsize, rgsize); @@ -354,10 +353,9 @@ void main_grow(int argc, char *argv[]) continue; } sdp->path_name = mnt->mnt_dir; - strncpy(sdp->device_name, mnt->mnt_fsname, PATH_MAX - 1);
if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo) < 0) { - perror(sdp->device_name); + perror(mnt->mnt_fsname); exit(EXIT_FAILURE); } sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE; @@ -431,7 +429,7 @@ void main_grow(int argc, char *argv[]) error = -1; goto out; } - print_info(sdp); + print_info(sdp, mnt->mnt_fsname); 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 4338e8d..d468a6f 100644 --- a/gfs2/mkfs/main_jadd.c +++ b/gfs2/mkfs/main_jadd.c @@ -507,7 +507,6 @@ void main_jadd(int argc, char *argv[]) exit(EXIT_FAILURE); } sbd.path_name = mnt->mnt_dir; - strncpy(sbd.device_name, mnt->mnt_fsname, PATH_MAX - 1);
gather_info(sdp);
cluster-commits@lists.fedorahosted.org