ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/pack/freebsd/misc/e2fsprogs-libuuid/files/patch-lib-uuid-gen_uuid.c
Revision: 92
Committed: 2009-07-28T06:52:54-07:00 (15 years, 10 months ago) by douglas
Content type: text/x-c
File size: 915 byte(s)
Log Message:
Preliminary patch: it works, but I don't think it's upstream kosher.

File Contents

# Content
1 --- ./lib/uuid/gen_uuid.c.orig 2009-06-30 20:41:09.000000000 -0700
2 +++ ./lib/uuid/gen_uuid.c 2009-07-28 06:46:12.380950940 -0700
3 @@ -89,6 +89,8 @@
4 #ifdef HAVE_SYS_RESOURCE_H
5 #include <sys/resource.h>
6 #endif
7 +#include <net/if_dl.h>
8 +#include <ifaddrs.h>
9
10 #include "uuidP.h"
11 #include "uuidd.h"
12 @@ -295,6 +297,28 @@
13 }
14 }
15 close(sd);
16 +#else
17 + struct ifaddrs *ifaddrsp, *ifaddrp;
18 + unsigned char *a;
19 +
20 + if (getifaddrs(&ifaddrsp) < 0)
21 + return -1;
22 + for (ifaddrp = ifaddrsp; ifaddrp != NULL; ifaddrp = ifaddrp->ifa_next)
23 + {
24 + if (ifaddrp->ifa_addr == NULL)
25 + continue;
26 + if (ifaddrp->ifa_addr->sa_family != AF_LINK)
27 + continue;
28 + a = LLADDR((struct sockaddr_dl *)ifaddrp->ifa_addr);
29 + if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
30 + continue;
31 + if (node_id) {
32 + memcpy(node_id, a, 6);
33 + freeifaddrs(ifaddrsp);
34 + return 1;
35 + }
36 + }
37 + freeifaddrs(ifaddrsp);
38 #endif
39 return 0;
40 }