--- tagutils/tagutils.c	2010-12-13 01:41:52.000000000 -0500
+++ tagutils/tagutils.c	2010-12-13 17:28:29.000000000 -0500
@@ -36,6 +36,7 @@
 #include <vorbis/codec.h>
 #include <FLAC/metadata.h>
+#include <libgen.h>
 
-#include "../config.h"
+#include "config.h"
 #ifdef HAVE_ICONV_H
 #include <iconv.h>
--- image_utils.c	2011-05-03 18:07:47.000000000 -0400
+++ image_utils.c	2011-08-24 01:11:13.000000000 -0400
@@ -34,5 +34,5 @@
 #include <setjmp.h>
 #include <jpeglib.h>
-#include <endian.h>
+#include <sys/endian.h>
 
 #include "upnpreplyparse.h"
--- upnpdescgen.c	2011-05-03 18:07:47.000000000 -0400
+++ upnpdescgen.c	2011-08-24 01:32:48.000000000 -0400
@@ -585,5 +585,5 @@
                    const struct XMLElt * p)
 {
-	u_int16_t i, j, k;
+	uint16_t i, j, k;
 	int top;
 	const char * eltname, *s;
--- upnpglobalvars.c	2011-05-26 19:10:54.000000000 -0400
+++ upnpglobalvars.c	2011-08-24 01:33:57.000000000 -0400
@@ -49,5 +49,5 @@
 #include <sys/types.h>
 #include <netinet/in.h>
-#include <linux/limits.h>
+#include <limits.h>
 
 #include "config.h"
--- tagutils/misc.c	2010-11-11 18:48:14.000000000 -0500
+++ tagutils/misc.c	2011-08-24 01:36:58.000000000 -0400
@@ -22,5 +22,5 @@
 #include <stdio.h>
 #include <string.h>
-#include <endian.h>
+#include <sys/endian.h>
 
 #include "misc.h"
--- uuid.c	2011-05-26 19:04:33.000000000 -0400
+++ uuid.c	2011-08-24 01:56:11.000000000 -0400
@@ -31,4 +31,5 @@
 #include <sys/syscall.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
@@ -47,13 +48,4 @@
 static int clock_seq_initialized;
 
-unsigned long long
-monotonic_us(void)
-{
-	struct timespec ts;
-
-	syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts);
-	return ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000;
-}
-
-int
+static int
 read_bootid_node(unsigned char *buf, size_t size)
@@ -82,26 +74,13 @@
 read_random_bytes(unsigned char *buf, size_t size)
 {
-	int i;
-	pid_t pid;
+	long r;
+	srandomdev();
 
-	i = open("/dev/urandom", O_RDONLY);
-	if(i >= 0)
-	{
-		read(i, buf, size);
-		close(i);
-	}
-	/* Paranoia. /dev/urandom may be missing.
-	 * rand() is guaranteed to generate at least [0, 2^15) range,
-	 * but lowest bits in some libc are not so "random".  */
-	srand(monotonic_us());
-	pid = getpid();
-	while(1)
-	{
-		for(i = 0; i < size; i++)
-			buf[i] ^= rand() >> 5;
-		if(pid == 0)
-			break;
-		srand(pid);
-		pid = 0;
+	while ((ssize_t)size > 0) {
+		r = random();
+		memcpy(buf, &r,
+		    size > sizeof(r) ? sizeof(r) : size);
+		buf += sizeof(r);
+		size -= sizeof(r);
 	}
 }
@@ -163,5 +142,5 @@
 	 * Gregorian reform to the Christian calendar).
 	 */
-	syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
+	clock_gettime(CLOCK_REALTIME, &ts);
 	time_all = ((u_int64_t)ts.tv_sec) * (NSEC_PER_SEC / 100);
 	time_all += ts.tv_nsec / 100;
--- tagutils/tagutils-asf.h	2010-11-11 18:48:14.000000000 -0500
+++ tagutils/tagutils-asf.h	2011-08-24 01:57:26.000000000 -0400
@@ -24,5 +24,5 @@
 #define __PACKED__  __attribute__((packed))
 
-#include <endian.h>
+#include <sys/endian.h>
 
 typedef struct _GUID {
--- utils.c	2011-07-18 14:13:25.000000000 -0400
+++ utils.c	2011-09-21 00:58:47.000000000 -0400
@@ -207,11 +207,15 @@
 		}
 
-		if (mkdir(path, mode) < 0) {
+		if (!(path[0] == '/' && s == path + 1) /* skip "/" */
+		    && mkdir(path, mode) < 0) {
+			int	e = errno;
 			/* If we failed for any other reason than the directory
 			 * already exists, output a diagnostic and return -1.*/
 			if (errno != EEXIST || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
-				DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
 				if (c)
 					*s = c;
+				DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot "
+				    "create directory '%.*s' (to create %s): "
+				    "%s\n", s - path, path, path, strerror(e));
 				return -1;
 			}
