cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/4] gfs2-utils: Ensure sb_uuid uses are guarded
Date: Mon, 17 Feb 2014 14:47:58 +0000	[thread overview]
Message-ID: <1392648480-5085-2-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1392648480-5085-1-git-send-email-anprice@redhat.com>

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.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/hexedit.c   |  5 ++++-
 gfs2/mkfs/main_mkfs.c | 27 ++++++++++++++-------------
 gfs2/tune/super.c     |  5 +++--
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index ffbf075..1ed4755 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));
-- 
1.8.5.3



  reply	other threads:[~2014-02-17 14:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 14:47 [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Andrew Price
2014-02-17 14:47 ` Andrew Price [this message]
2014-02-17 14:47 ` [Cluster-devel] [PATCH 3/4] libgfs2: Add support for new leaf hint fields Andrew Price
2014-02-18 10:36   ` Steven Whitehouse
2014-02-18 11:02     ` Andrew Price
2014-02-17 14:48 ` [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Remove a dead structure Andrew Price
2014-02-17 15:12 ` [Cluster-devel] [PATCH 1/4] libgfs2: Superblock building and writing improvements Bob Peterson
2014-02-25  3:15 ` [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update Abhijith Das
2014-02-25 12:20   ` Andrew Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392648480-5085-2-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).