Index: util-linux-2.19.1/misc-utils/uuidd.c
===================================================================
--- util-linux-2.19.1.orig/misc-utils/uuidd.c
+++ util-linux-2.19.1/misc-utils/uuidd.c
@@ -346,7 +346,7 @@ static void server_loop(const char *sock
 			break;
 		case UUIDD_OP_TIME_UUID:
 			num = 1;
-			uuid__generate_time(uu, &num);
+			__uuid_generate_time(uu, &num);
 			if (debug) {
 				uuid_unparse(uu, str);
 				printf(_("Generated time UUID: %s\n"), str);
@@ -356,7 +356,7 @@ static void server_loop(const char *sock
 			break;
 		case UUIDD_OP_RANDOM_UUID:
 			num = 1;
-			uuid__generate_random(uu, &num);
+			__uuid_generate_random(uu, &num);
 			if (debug) {
 				uuid_unparse(uu, str);
 				printf(_("Generated random UUID: %s\n"), str);
@@ -365,7 +365,7 @@ static void server_loop(const char *sock
 			reply_len = sizeof(uu);
 			break;
 		case UUIDD_OP_BULK_TIME_UUID:
-			uuid__generate_time(uu, &num);
+			__uuid_generate_time(uu, &num);
 			if (debug) {
 				uuid_unparse(uu, str);
 				printf(_("Generated time UUID %s and %d "
@@ -383,7 +383,7 @@ static void server_loop(const char *sock
 				num = 1000;
 			if (num * UUID_LEN > (int) (sizeof(reply_buf)-sizeof(num)))
 				num = (sizeof(reply_buf)-sizeof(num)) / UUID_LEN;
-			uuid__generate_random((unsigned char *) reply_buf +
+			__uuid_generate_random((unsigned char *) reply_buf +
 					      sizeof(num), &num);
 			if (debug) {
 				printf(_("Generated %d UUIDs:\n"), num);
Index: util-linux-2.19.1/shlibs/uuid/man/Makefile.am
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/man/Makefile.am
+++ util-linux-2.19.1/shlibs/uuid/man/Makefile.am
@@ -3,7 +3,7 @@ include $(top_srcdir)/config/include-Mak
 dist_man_MANS = uuid.3 uuid_clear.3 uuid_compare.3 uuid_copy.3 uuid_generate.3 \
 		uuid_is_null.3 uuid_parse.3 uuid_time.3 uuid_unparse.3
 
-UUID_GENERATE_LINKS = uuid_generate_random.3 uuid_generate_time.3
+UUID_GENERATE_LINKS = uuid_generate_random.3 uuid_generate_time.3 uuid_generate_time_safe.3
 
 man_MANS = $(UUID_GENERATE_LINKS)
 CLEANFILES = $(man_MANS)
Index: util-linux-2.19.1/shlibs/uuid/man/uuid_generate.3
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/man/uuid_generate.3
+++ util-linux-2.19.1/shlibs/uuid/man/uuid_generate.3
@@ -31,7 +31,8 @@
 .\" Created  Wed Mar 10 17:42:12 1999, Andreas Dilger
 .TH UUID_GENERATE 3 "May 2009" "util-linux" "Libuuid API"
 .SH NAME
-uuid_generate, uuid_generate_random, uuid_generate_time \- create a new unique UUID value
+uuid_generate, uuid_generate_random, uuid_generate_time,
+uuid_generate_time_safe \- create a new unique UUID value
 .SH SYNOPSIS
 .nf
 .B #include <uuid/uuid.h>
@@ -39,6 +40,7 @@ uuid_generate, uuid_generate_random, uui
 .BI "void uuid_generate(uuid_t " out );
 .BI "void uuid_generate_random(uuid_t " out );
 .BI "void uuid_generate_time(uuid_t " out );
+.BI "int uuid_generate_time_safe(uuid_t " out );
 .fi
 .SH DESCRIPTION
 The
@@ -72,7 +74,24 @@ information about when and where the UUI
 privacy problems in some applications, so the
 .B uuid_generate
 function only uses this algorithm if a high-quality source of
-randomness is not available.
+randomness is not available.  To guarantee uniqueness of UUIDs generated
+by concurrently running processes, the uuid library uses global
+clock state counter (if the process has permissions to gain exclusive access
+to this file) and/or the
+.B uuidd
+daemon, if it is running already or can be be spawned by the process (if
+installed and the process has enough permissions to run it).  If neither of
+these two synchronization mechanisms can be used, it is theoretically possible
+that two concurrently running processes obtain the same UUID(s).  To tell
+whether the UUID has been generated in a safe manner, use
+.BR uuid_generate_time_safe .
+.sp
+The
+.B uuid_generate_time_safe
+is similar to
+.BR uuid_generate_time ,
+except that it returns a value which denotes whether any of the synchronization
+mechanisms (see above) has been used.
 .sp
 The UUID is 16 bytes (128 bits) long, which gives approximately 3.4x10^38
 unique values (there are approximately 10^80 elementary particles in
@@ -84,6 +103,8 @@ and in the future.
 .SH RETURN VALUE
 The newly created UUID is returned in the memory location pointed to by
 .IR out .
+.B uuid_generate_time_safe
+returns zero if the UUID has been generated in a safe manner, -1 otherwise.
 .SH "CONFORMING TO"
 OSF DCE 1.1
 .SH AUTHOR
@@ -95,6 +116,7 @@ ftp://ftp.kernel.org/pub/linux/utils/uti
 .SH "SEE ALSO"
 .BR uuid (3),
 .BR uuidgen (1),
+.BR uuidd (8),
 .BR uuid_clear (3),
 .BR uuid_compare (3),
 .BR uuid_copy (3),
Index: util-linux-2.19.1/shlibs/uuid/man/uuid_generate_time_safe.3
===================================================================
--- /dev/null
+++ util-linux-2.19.1/shlibs/uuid/man/uuid_generate_time_safe.3
@@ -0,0 +1 @@
+.so man3/uuid_generate.3
Index: util-linux-2.19.1/shlibs/uuid/man/uuid_time.3
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/man/uuid_time.3
+++ util-linux-2.19.1/shlibs/uuid/man/uuid_time.3
@@ -47,7 +47,9 @@ was created.  Note that the UUID creatio
 certain types of UUIDs.  This function can only reasonably expect to
 extract the creation time for UUIDs created with the
 .BR uuid_generate_time (3)
-function.  It may or may not work with UUIDs created by other mechanisms.
+and
+.BR uuid_generate_time_safe (3)
+functions.  It may or may not work with UUIDs created by other mechanisms.
 .SH "RETURN VALUES"
 The time at which the UUID was created, in seconds since January 1, 1970 GMT
 (the epoch), is returned (see
Index: util-linux-2.19.1/shlibs/uuid/src/gen_uuid.c
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/src/gen_uuid.c
+++ util-linux-2.19.1/shlibs/uuid/src/gen_uuid.c
@@ -306,6 +306,12 @@ static int get_node_id(unsigned char *no
 /* Assume that the gettimeofday() has microsecond granularity */
 #define MAX_ADJUSTMENT 10
 
+/*
+ * Get clock from global sequence clock counter.
+ *
+ * Return -1 if the clock counter could not be opened/locked (in this case
+ * pseudorandom value is returned in @ret_clock_seq), otherwise return 0.
+ */
 static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
 		     uint16_t *ret_clock_seq, int *num)
 {
@@ -318,6 +324,7 @@ static int get_clock(uint32_t *clock_hig
 	uint64_t			clock_reg;
 	mode_t				save_umask;
 	int				len;
+	int				ret = 0;
 
 	if (state_fd == -2) {
 		save_umask = umask(0);
@@ -329,8 +336,11 @@ static int get_clock(uint32_t *clock_hig
 			if (!state_f) {
 				close(state_fd);
 				state_fd = -1;
+				ret = -1;
 			}
 		}
+		else
+			ret = -1;
 	}
 	if (state_fd >= 0) {
 		rewind(state_f);
@@ -340,6 +350,7 @@ static int get_clock(uint32_t *clock_hig
 			fclose(state_f);
 			close(state_fd);
 			state_fd = -1;
+			ret = -1;
 			break;
 		}
 	}
@@ -411,7 +422,7 @@ try_again:
 	*clock_high = clock_reg >> 32;
 	*clock_low = clock_reg;
 	*ret_clock_seq = clock_seq;
-	return 0;
+	return ret;
 }
 
 #if defined(HAVE_UUIDD) && defined(HAVE_SYS_UN_H)
@@ -555,12 +566,13 @@ static int get_uuid_via_daemon(int op, u
 }
 #endif
 
-void uuid__generate_time(uuid_t out, int *num)
+int __uuid_generate_time(uuid_t out, int *num)
 {
 	static unsigned char node_id[6];
 	static int has_init = 0;
 	struct uuid uu;
 	uint32_t	clock_mid;
+	int ret;
 
 	if (!has_init) {
 		if (get_node_id(node_id) <= 0) {
@@ -574,16 +586,24 @@ void uuid__generate_time(uuid_t out, int
 		}
 		has_init = 1;
 	}
-	get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
+	ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num);
 	uu.clock_seq |= 0x8000;
 	uu.time_mid = (uint16_t) clock_mid;
 	uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000;
 	memcpy(uu.node, node_id, 6);
 	uuid_pack(&uu, out);
+	return ret;
 }
 
-void uuid_generate_time(uuid_t out)
-{
+/*
+ * Generate time-based UUID and store it to @out
+ *
+ * Tries to guarantee uniqueness of the generated UUIDs by obtaining them from the uuidd daemon,
+ * or, if uuidd is not usable, by using the global clock state counter (see get_clock()).
+ * If neither of these is possible (e.g. because of insufficient permissions), it generates
+ * the UUID anyway, but returns -1. Otherwise, returns 0.
+ */
+static int uuid_generate_time_generic(uuid_t out) {
 #ifdef HAVE_TLS
 	THREAD_LOCAL int		num = 0;
 	THREAD_LOCAL struct uuid	uu;
@@ -602,7 +622,7 @@ void uuid_generate_time(uuid_t out)
 			last_time = time(0);
 			uuid_unpack(out, &uu);
 			num--;
-			return;
+			return 0;
 		}
 		num = 0;
 	}
@@ -615,18 +635,34 @@ void uuid_generate_time(uuid_t out)
 		}
 		num--;
 		uuid_pack(&uu, out);
-		return;
+		return 0;
 	}
 #else
 	if (get_uuid_via_daemon(UUIDD_OP_TIME_UUID, out, 0) == 0)
-		return;
+		return 0;
 #endif
 
-	uuid__generate_time(out, 0);
+	return __uuid_generate_time(out, 0);
+}
+
+/*
+ * Generate time-based UUID and store it to @out.
+ *
+ * Discards return value from uuid_generate_time_generic()
+ */
+void uuid_generate_time(uuid_t out)
+{
+	(void)uuid_generate_time_generic(out);
+}
+
+
+int uuid_generate_time_safe(uuid_t out)
+{
+	return uuid_generate_time_generic(out);
 }
 
 
-void uuid__generate_random(uuid_t out, int *num)
+void __uuid_generate_random(uuid_t out, int *num)
 {
 	uuid_t	buf;
 	struct uuid uu;
@@ -654,7 +690,7 @@ void uuid_generate_random(uuid_t out)
 	int	num = 1;
 	/* No real reason to use the daemon for random uuid's -- yet */
 
-	uuid__generate_random(out, &num);
+	__uuid_generate_random(out, &num);
 }
 
 
Index: util-linux-2.19.1/shlibs/uuid/src/uuid.h
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/src/uuid.h
+++ util-linux-2.19.1/shlibs/uuid/src/uuid.h
@@ -79,6 +79,7 @@ void uuid_copy(uuid_t dst, const uuid_t
 void uuid_generate(uuid_t out);
 void uuid_generate_random(uuid_t out);
 void uuid_generate_time(uuid_t out);
+int uuid_generate_time_safe(uuid_t out);
 
 /* isnull.c */
 int uuid_is_null(const uuid_t uu);
Index: util-linux-2.19.1/shlibs/uuid/src/uuid.sym
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/src/uuid.sym
+++ util-linux-2.19.1/shlibs/uuid/src/uuid.sym
@@ -1,6 +1,6 @@
 /*
  * The symbol versioning ensures that a new application requiring symbol foo()
- * can't run with old libblkid.so not providing foo() - the global SONAME
+ * can't run with old libuuid.so not providing foo() - the global SONAME
  * version info can't enforce this since we never change the SONAME.
  *
  * The original libuuid from e2fsprogs (<=1.41.5) does not to use
@@ -22,12 +22,25 @@ global:
 	uuid_time;
 	uuid_type;
 	uuid_variant;
+};
+
+/*
+ * version(s) since util-linux 2.20
+ */
+UUID_2.20 {
+global:
+	uuid_generate_time_safe;
+} UUID_1.0;
+
 
-	/* uuid__* this is not part of the official API, this is
+/*
+ * __uuid_* this is not part of the official API, this is
 	 * uuidd (uuid daemon) specific stuff. Hell.
 	 */
-	uuid__generate_time;
-	uuid__generate_random;
+UUIDD_PRIVATE {
+global:
+	__uuid_generate_time;
+	__uuid_generate_random;
 local:
 	*;
 };
Index: util-linux-2.19.1/shlibs/uuid/src/uuidd.h
===================================================================
--- util-linux-2.19.1.orig/shlibs/uuid/src/uuidd.h
+++ util-linux-2.19.1/shlibs/uuid/src/uuidd.h
@@ -48,7 +48,7 @@
 #define UUIDD_OP_BULK_RANDOM_UUID	5
 #define UUIDD_MAX_OP			UUIDD_OP_BULK_RANDOM_UUID
 
-extern void uuid__generate_time(uuid_t out, int *num);
-extern void uuid__generate_random(uuid_t out, int *num);
+extern int __uuid_generate_time(uuid_t out, int *num);
+extern void __uuid_generate_random(uuid_t out, int *num);
 
 #endif /* _UUID_UUID_H */
