Blob Blame History Raw
commit 75a68102d55a1c361725ed01864c98fee6f77199
Author: Andrew Price <anprice@redhat.com>
Date:   Thu Feb 6 13:16:18 2014 +0000

    gfs2-utils: Ensure sb_uuid uses are guarded
    
    Guard uses of sb_uuid with #ifdef GFS2_HAS_UUID
    
    Tweak print_results() in mkfs.gfs2 to accept the gfs2_sb which we
    conditionally print the uuid from, instead of the gfs2_sbd.
    
    Resolves: rhbz#1063842
    
    Signed-off-by: Andrew Price <anprice@redhat.com>

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 36f6600..0708445 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -104,10 +104,12 @@ static int gfs2_sb_printval(struct gfs2_sb *lsb, const char *strfield)
 	checkprints(strfield, lsb, sb_locktable);
 	checkprint(strfield, lsb, __pad3.no_addr);
 	checkprint(strfield, lsb, __pad4.no_addr);
+#ifdef GFS2_HAS_UUID
 	if (strcmp(strfield, "sb_uuid") == 0) {
 		printf("%s\n", str_uuid(lsb->sb_uuid));
 		return 0;
 	}
+#endif
 
 	return -1;
 }
@@ -135,8 +137,9 @@ static int gfs2_sb_assigns(struct gfs2_sb *lsb, const char *strfield,
 {
 	checkassigns(strfield, lsb, sb_lockproto, val);
 	checkassigns(strfield, lsb, sb_locktable, val);
+#ifdef GFS2_HAS_UUID
 	checkassigns(strfield, lsb, sb_uuid, val);
-
+#endif
 	return -1;
 }
 
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 8bd396a..32da585 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -555,24 +555,25 @@ static void opts_check(struct mkfs_opts *opts)
 	}
 }
 
-static void print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
-                          struct mkfs_opts *opts, unsigned char uuid[16])
+static void print_results(struct gfs2_sb *sb, struct mkfs_dev *dev, struct mkfs_opts *opts,
+                          uint64_t rgrps, uint64_t fssize)
 {
 	printf("%-27s%s\n", _("Device:"), opts->device);
-	printf("%-27s%u\n", _("Block size:"), sdp->bsize);
-	printf("%-27s%.2f %s (%llu %s)\n", _("Device size:"),
+	printf("%-27s%u\n", _("Block size:"), sb->sb_bsize);
+	printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Device size:"),
 	       /* Translators: "GB" here means "gigabytes" */
-	       real_device_size / ((float)(1 << 30)), _("GB"),
-	       (unsigned long long)real_device_size / sdp->bsize, _("blocks"));
-	printf("%-27s%.2f %s (%llu %s)\n", _("Filesystem size:"),
-	       sdp->fssize / ((float)(1 << 30)) * sdp->bsize, _("GB"),
-	       (unsigned long long)sdp->fssize, _("blocks"));
-	printf("%-27s%u\n", _("Journals:"), sdp->md.journals);
-	printf("%-27s%llu\n", _("Resource groups:"), (unsigned long long)sdp->rgrps);
+	       (dev->size / ((float)(1 << 30))), _("GB"),
+	       (dev->size / sb->sb_bsize), _("blocks"));
+	printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Filesystem size:"),
+	       (fssize / ((float)(1 << 30)) * sb->sb_bsize), _("GB"), fssize, _("blocks"));
+	printf("%-27s%u\n", _("Journals:"), opts->journals);
+	printf("%-27s%"PRIu64"\n", _("Resource groups:"), rgrps);
 	printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
 	printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
+#ifdef GFS2_HAS_UUID
 	/* Translators: "UUID" = universally unique identifier. */
-	printf("%-27s%s\n", _("UUID:"), str_uuid(uuid));
+	printf("%-27s%s\n", _("UUID:"), str_uuid(sb->sb_uuid));
+#endif
 }
 
 static void warn_of_destruction(const char *path)
@@ -909,5 +910,5 @@ void main_mkfs(int argc, char *argv[])
 	}
 
 	if (!opts.quiet)
-		print_results(&sbd, dev.size, &opts, sb.sb_uuid);
+		print_results(&sb, &dev, &opts, sbd.rgrps, sbd.fssize);
 }
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index cc34990..cbd0026 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -124,8 +124,9 @@ static int is_gfs2(const struct tunegfs2 *tfs)
 int print_super(const struct tunegfs2 *tfs)
 {
 	printf(_("File system volume name: %s\n"), tfs->sb->sb_locktable);
-	if (is_gfs2(tfs))
-		printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#ifdef GFS2_HAS_UUID
+	printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#endif
 	printf( _("File system magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
 	printf(_("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
 	printf(_("Block shift: %d\n"), be32_to_cpu(tfs->sb->sb_bsize_shift));