ports/sysutils/e2fsprogs/files/patch-lib-uuid-gen_uuid.c
Martin Wilke f6bff99e09 - Update to 1.41.9
PR:		139531
Submitted by:	Matthias Andree <matthias.andree@gmx.de> (maintainer)
2009-11-05 20:40:38 +00:00

42 lines
1,000 B
C

This patch contributed by Douglas William Thrift to enable libuuid to
obtain the ethernet hardware address.
--- ./lib/uuid/gen_uuid.c.orig 2009-06-30 20:41:09.000000000 -0700
+++ ./lib/uuid/gen_uuid.c 2009-07-28 06:46:12.380950940 -0700
@@ -89,6 +89,7 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
+#include <ifaddrs.h>
#include "uuidP.h"
#include "uuidd.h"
@@ -295,6 +296,28 @@
}
}
close(sd);
+#else
+ struct ifaddrs *ifaddrsp, *ifaddrp;
+ unsigned char *a;
+
+ if (getifaddrs(&ifaddrsp) < 0)
+ return -1;
+ for (ifaddrp = ifaddrsp; ifaddrp != NULL; ifaddrp = ifaddrp->ifa_next)
+ {
+ if (ifaddrp->ifa_addr == NULL)
+ continue;
+ if (ifaddrp->ifa_addr->sa_family != AF_LINK)
+ continue;
+ a = LLADDR((struct sockaddr_dl *)ifaddrp->ifa_addr);
+ if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
+ continue;
+ if (node_id) {
+ memcpy(node_id, a, 6);
+ freeifaddrs(ifaddrsp);
+ return 1;
+ }
+ }
+ freeifaddrs(ifaddrsp);
#endif
return 0;
}