projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
92811df
)
uuid plugin: make it work on OpenBSD
author
Ruben Kerkhof
<ruben@rubenkerkhof.com>
Fri, 25 Dec 2015 10:46:04 +0000
(11:46 +0100)
committer
Ruben Kerkhof
<ruben@rubenkerkhof.com>
Thu, 4 Aug 2016 09:22:40 +0000
(11:22 +0200)
src/uuid.c
patch
|
blob
|
history
diff --git
a/src/uuid.c
b/src/uuid.c
index
a607d61
..
8976626
100644
(file)
--- a/
src/uuid.c
+++ b/
src/uuid.c
@@
-124,6
+124,21
@@
uuid_get_from_sysctlbyname(const char *name)
return NULL;
return (strdup (uuid));
}
return NULL;
return (strdup (uuid));
}
+#elif defined(__OpenBSD__)
+static char *
+uuid_get_from_sysctl(void)
+{
+ char uuid[UUID_PRINTABLE_NORMAL_LENGTH + 1];
+ size_t len = sizeof (uuid);
+ int mib[2];
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_UUID;
+
+ if (sysctl(mib, 2, uuid, &len, NULL, 0) == -1)
+ return NULL;
+ return (strdup (uuid));
+}
#endif
#if HAVE_LIBHAL_H
#endif
#if HAVE_LIBHAL_H
@@
-218,6
+233,9
@@
uuid_get_local(void)
#elif defined(__NetBSD__)
if ((uuid = uuid_get_from_sysctlbyname("machdep.dmi.system-uuid")) != NULL)
return (uuid);
#elif defined(__NetBSD__)
if ((uuid = uuid_get_from_sysctlbyname("machdep.dmi.system-uuid")) != NULL)
return (uuid);
+#elif defined(__OpenBSD__)
+ if ((uuid = uuid_get_from_sysctl()) != NULL)
+ return (uuid);
#elif defined(__linux__)
if ((uuid = uuid_get_from_file("/sys/class/dmi/id/product_uuid")) != NULL)
return (uuid);
#elif defined(__linux__)
if ((uuid = uuid_get_from_file("/sys/class/dmi/id/product_uuid")) != NULL)
return (uuid);