[Ocfs2-tools-commits] manish commits r787 - in trunk: . listuuid mkfs.ocfs2 mounted.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Apr 5 21:36:26 CDT 2005


Author: manish
Date: 2005-04-05 21:36:24 -0500 (Tue, 05 Apr 2005)
New Revision: 787

Modified:
   trunk/Config.make.in
   trunk/blkid.m4
   trunk/configure.in
   trunk/listuuid/Makefile
   trunk/listuuid/listuuid.c
   trunk/mkfs.ocfs2/Makefile
   trunk/mkfs.ocfs2/mkfs.c
   trunk/mkfs.ocfs2/mkfs.h
   trunk/mounted.ocfs2/Makefile
   trunk/mounted.ocfs2/mounted.c
Log:
Use libuuid for things


Modified: trunk/Config.make.in
===================================================================
--- trunk/Config.make.in	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/Config.make.in	2005-04-06 02:36:24 UTC (rev 787)
@@ -37,7 +37,9 @@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@ 
+
 COM_ERR_LIBS = @COM_ERR_LIBS@
+UUID_LIBS = @UUID_LIBS@
 
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@

Modified: trunk/blkid.m4
===================================================================
--- trunk/blkid.m4	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/blkid.m4	2005-04-06 02:36:24 UTC (rev 787)
@@ -7,9 +7,6 @@
   AC_SUBST(HAVE_BLKID)
 
   if test "x$HAVE_BLKID" != "xyes"; then
-    AC_CHECK_LIB(uuid, uuid_unparse, :,
-      [AC_MSG_ERROR([could not find uuid library])])
-
     AC_CHECK_SIZEOF(short)
     AC_CHECK_SIZEOF(int)
     AC_CHECK_SIZEOF(long)

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/configure.in	2005-04-06 02:36:24 UTC (rev 787)
@@ -65,10 +65,21 @@
 COM_ERR_LIBS=
 AC_CHECK_LIB(com_err, com_err, COM_ERR_LIBS=-lcom_err)
 if test "x$COM_ERR_LIBS" = "x"; then
-    AC_MSG_ERROR([Unable to find com_err library])
+  AC_MSG_ERROR([Unable to find com_err library])
 fi
+AC_CHECK_HEADER(et/com_err.h, :,
+  AC_MSG_ERROR([Unable to find com_err headers]))
 AC_SUBST(COM_ERR_LIBS)
 
+UUID_LIBS=
+AC_CHECK_LIB(uuid, uuid_unparse, UUID_LIBS=-luuid)
+if test "x$COM_ERR_LIBS" = "x"; then
+  AC_MSG_ERROR([Unable to find uuid library])
+fi
+AC_CHECK_HEADER(uuid/uuid.h, :,
+  AC_MSG_ERROR([Unable to find uuid headers]))
+AC_SUBST(UUID_LIBS)
+
 AC_C_BIGENDIAN()
 
 AC_MSG_CHECKING(for debug executables)

Modified: trunk/listuuid/Makefile
===================================================================
--- trunk/listuuid/Makefile	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/listuuid/Makefile	2005-04-06 02:36:24 UTC (rev 787)
@@ -40,6 +40,6 @@
 	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
 
 listuuid: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
-	$(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(LIBO2DLM_LIBS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(COM_ERR_LIBS) $(UUID_LIBS)
 
 include $(TOPDIR)/Postamble.make

Modified: trunk/listuuid/listuuid.c
===================================================================
--- trunk/listuuid/listuuid.c	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/listuuid/listuuid.c	2005-04-06 02:36:24 UTC (rev 787)
@@ -35,6 +35,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include <uuid/uuid.h>
+
 #define  OCFS2_FLAT_INCLUDES	1
 #include <ocfs2.h>
 #include <ocfs2_fs.h>
@@ -101,21 +103,17 @@
 	struct list_head *pos;
 	char uuid[40];
 	char devstr[10];
-	char *p;
-	int i;
 
-	printf("%-20s  %7s  %-5s  %-32s  %-s\n", "Device", "maj,min", "FS", "UUID", "Label");
+	printf("%-20s  %7s  %-5s  %-36s  %-s\n", "Device", "maj,min", "FS", "UUID", "Label");
 	list_for_each(pos, dev_list) {
 		dev = list_entry(pos, ocfs2_devices, list);
 		if (dev->fs_type == 0)
 			continue;
 
-		memset(uuid, 0, sizeof(uuid));
-		for (i = 0, p = uuid; i < 16; i++, p += 2)
-			sprintf(p, "%02X", dev->uuid[i]);
+		uuid_unparse(dev->uuid, uuid);
 
 		sprintf(devstr, "%3d,%-d", dev->maj_num, dev->min_num);
-		printf("%-20s  %-7s  %-5s  %-32s  %s\n", dev->dev_name, devstr, 
+		printf("%-20s  %-7s  %-5s  %-36s  %s\n", dev->dev_name, devstr, 
 		       (dev->fs_type == 2 ? "ocfs2" : "ocfs"), uuid, dev->label);
 	}
 

Modified: trunk/mkfs.ocfs2/Makefile
===================================================================
--- trunk/mkfs.ocfs2/Makefile	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/mkfs.ocfs2/Makefile	2005-04-06 02:36:24 UTC (rev 787)
@@ -41,6 +41,6 @@
 DIST_FILES = $(CFILES) $(HFILES) mkfs.ocfs2.8.in
 
 mkfs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
-	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) $(UUID_LIBS)
 
 include $(TOPDIR)/Postamble.make

Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/mkfs.ocfs2/mkfs.c	2005-04-06 02:36:24 UTC (rev 787)
@@ -1686,35 +1686,11 @@
 	return (i < 4) ? defaults[i] : 32;
 }
 
-/* XXX: Hm, maybe replace this with libuuid? */
 static void
 generate_uuid(State *s)
 {
-	int randfd = 0;
-	int readlen = 0;
-	int len = 0;
-
-	if ((randfd = open("/dev/urandom", O_RDONLY)) == -1) {
-		com_err(s->progname, 0,
-			"Error opening /dev/urandom: %s", strerror(errno));
-		exit(1);
-	}
-
 	s->uuid = do_malloc(s, OCFS2_VOL_UUID_LEN);
-
-	while (readlen < OCFS2_VOL_UUID_LEN) {
-		if ((len = read(randfd, s->uuid + readlen,
-				OCFS2_VOL_UUID_LEN - readlen)) == -1) {
-			com_err(s->progname, 0,
-				"Error reading from /dev/urandom: %s",
-				strerror(errno));
-			exit(1);
-		}
-
-		readlen += len;
-	}
-
-	close(randfd);
+	uuid_generate(s->uuid);
 }
 
 static void create_generation(State *s)

Modified: trunk/mkfs.ocfs2/mkfs.h
===================================================================
--- trunk/mkfs.ocfs2/mkfs.h	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/mkfs.ocfs2/mkfs.h	2005-04-06 02:36:24 UTC (rev 787)
@@ -41,6 +41,8 @@
 #include <inttypes.h>
 #include <ctype.h>
 
+#include <uuid/uuid.h>
+
 #include "ocfs2.h"
 #include "bitops.h"
 

Modified: trunk/mounted.ocfs2/Makefile
===================================================================
--- trunk/mounted.ocfs2/Makefile	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/mounted.ocfs2/Makefile	2005-04-06 02:36:24 UTC (rev 787)
@@ -36,6 +36,6 @@
 DIST_FILES = $(CFILES) mounted.ocfs2.8.in
 
 mounted.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
-	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS)  $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS)  $(LIBO2CB_LIBS) $(COM_ERR_LIBS) $(UUID_LIBS)
 
 include $(TOPDIR)/Postamble.make

Modified: trunk/mounted.ocfs2/mounted.c
===================================================================
--- trunk/mounted.ocfs2/mounted.c	2005-04-06 02:13:42 UTC (rev 786)
+++ trunk/mounted.ocfs2/mounted.c	2005-04-06 02:36:24 UTC (rev 787)
@@ -34,6 +34,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include <uuid/uuid.h>
+
 #include <ocfs2.h>
 #include <ocfs2_fs.h>
 #include <ocfs1_fs_compat.h>
@@ -133,20 +135,16 @@
 	ocfs2_devices *dev;
 	struct list_head *pos;
 	char uuid[40];
-	char *p;
-	int i;
 
-	printf("%-20s  %-5s  %-32s  %-s\n", "Device", "FS", "GUID", "Label");
+	printf("%-20s  %-5s  %-36s  %-s\n", "Device", "FS", "UUID", "Label");
 	list_for_each(pos, dev_list) {
 		dev = list_entry(pos, ocfs2_devices, list);
 		if (dev->fs_type == 0)
 			continue;
 
-		memset(uuid, 0, sizeof(uuid));		
-		for (i = 0, p = uuid; i < 16; i++, p += 2)
-			sprintf(p, "%02X", dev->uuid[i]);
+		uuid_unparse(dev->uuid, uuid);
 
-		printf("%-20s  %-5s  %-32s  %-s\n", dev->dev_name,
+		printf("%-20s  %-5s  %-36s  %-s\n", dev->dev_name,
 		       (dev->fs_type == 2 ? "ocfs2" : "ocfs"), uuid,
 		       dev->label);
 	}



More information about the Ocfs2-tools-commits mailing list