This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - libgfs2: Add support for UUID generation to gfs2_mkfs


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85049a0824daa9abaa38f5dca377767907b53b39
Commit:        85049a0824daa9abaa38f5dca377767907b53b39
Parent:        d763f902abf33655e635fc3b8b1919fd31d4f66c
Author:        Steven Whitehouse <swhiteho@redhat.com>
AuthorDate:    Fri Oct 10 16:04:29 2008 +0100
Committer:     Steven Whitehouse <swhiteho@redhat.com>
CommitterDate: Fri Oct 10 16:12:12 2008 +0100

libgfs2: Add support for UUID generation to gfs2_mkfs

Uses /dev/urandom to create 16 byte UUIDs for GFS2 filesystems
at mkfs time. Backwards and forwards compatible with all
GFS2 filesystems. You'll need a set of kernel headers with
the new field defined in order for this feature to be
enabled. Bugzilla #242690

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 gfs2/libgfs2/ondisk.c     |    3 +++
 gfs2/libgfs2/structures.c |   12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)

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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]