From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] libgfs2: Patch to generate UUIDs for GFS2 volumes
Date: Fri, 10 Oct 2008 11:46:37 +0100 [thread overview]
Message-ID: <1223635597.3493.13.camel@localhost.localdomain> (raw)
Hi,
This is the support for mkfs to generate UUIDs for GFS2 volumes. Its
bugzilla #242690 and is in support of the recent kernel patch. Its
also backwards comaptible and pretty small.
Steve.
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 40eb259..d80c9bb 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -117,6 +117,9 @@ void gfs2_sb_out(struct gfs2_sb *sb, char *buf)
CPOUT_08(sb, str, sb_lockproto, GFS2_LOCKNAME_LEN);
CPOUT_08(sb, str, sb_locktable, GFS2_LOCKNAME_LEN);
+#ifdef GFS2_HAS_UUID
+ memcpy(str->sb_uuid, sb->sb_uuid, 16);
+#endif
}
void gfs2_sb_print(struct gfs2_sb *sb)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index eb4c7bd..002edb6 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -58,7 +58,17 @@ build_sb(struct gfs2_sbd *sdp)
sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
strcpy(sb.sb_lockproto, sdp->lockproto);
strcpy(sb.sb_locktable, sdp->locktable);
-
+#ifdef GFS2_HAS_UUID
+ {
+ int fd = open("/dev/urandom", O_RDONLY);
+ int n;
+ if (fd >= 0)
+ n = read(fd, &sb.sb_uuid, 16);
+ if (fd < 0 || n != 16)
+ memset(&sb.sb_uuid, 0, 16);
+ close(fd);
+ }
+#endif
bh = bget(sdp, sdp->sb_addr);
gfs2_sb_out(&sb, bh->b_data);
brelse(bh, updated);
reply other threads:[~2008-10-10 10:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1223635597.3493.13.camel@localhost.localdomain \
--to=swhiteho@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