54 lines
1.4 KiB
Text
54 lines
1.4 KiB
Text
$NetBSD: patch-ab,v 1.4 2012/09/05 13:03:04 jperkin Exp $
|
|
|
|
fcntl is portable, flock is not.
|
|
|
|
Solaris does not have ifr.ifr_hwaddr.
|
|
|
|
--- shlibs/uuid/src/gen_uuid.c.orig Mon May 2 09:10:08 2011
|
|
+++ shlibs/uuid/src/gen_uuid.c Wed Sep 5 12:23:54 2012
|
|
@@ -265,7 +265,7 @@
|
|
for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
|
|
ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
|
|
strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
|
|
-#ifdef SIOCGIFHWADDR
|
|
+#if defined(SIOCGIFHWADDR) && !defined(__sun)
|
|
if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
|
|
continue;
|
|
a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
|
|
@@ -314,11 +314,16 @@
|
|
THREAD_LOCAL int state_fd = -2;
|
|
THREAD_LOCAL FILE *state_f;
|
|
THREAD_LOCAL uint16_t clock_seq;
|
|
+ struct flock lock;
|
|
struct timeval tv;
|
|
uint64_t clock_reg;
|
|
mode_t save_umask;
|
|
int len;
|
|
|
|
+ lock.l_whence = SEEK_SET;
|
|
+ lock.l_start = 0;
|
|
+ lock.l_len = 0;
|
|
+
|
|
if (state_fd == -2) {
|
|
save_umask = umask(0);
|
|
state_fd = open("/var/lib/libuuid/clock.txt",
|
|
@@ -334,7 +339,8 @@
|
|
}
|
|
if (state_fd >= 0) {
|
|
rewind(state_f);
|
|
- while (flock(state_fd, LOCK_EX) < 0) {
|
|
+ lock.l_type = F_WRLCK;
|
|
+ while (fcntl(state_fd, F_SETLKW, &lock) < 0) {
|
|
if (errno == EINTR)
|
|
continue;
|
|
fclose(state_f);
|
|
@@ -405,7 +411,8 @@
|
|
fflush(state_f);
|
|
}
|
|
rewind(state_f);
|
|
- flock(state_fd, LOCK_UN);
|
|
+ lock.l_type = F_UNLCK;
|
|
+ fcntl(state_fd, F_SETLK, &lock);
|
|
}
|
|
|
|
*clock_high = clock_reg >> 32;
|