libgfs2: Patch to generate UUIDs for GFS2 volumes
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.
gfs2/libgfs2/ondisk.c +3 -0
@@ -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)
gfs2/libgfs2/structures.c +11 -1
@@ -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);