diff options
author | he <he@pkgsrc.org> | 2015-09-01 09:31:46 +0000 |
---|---|---|
committer | he <he@pkgsrc.org> | 2015-09-01 09:31:46 +0000 |
commit | 8d6edd579ad9087307af6764ffaae37e941a9c74 (patch) | |
tree | 7e14bed7e79e65643fbefbcaa2a1acfb8d758de5 /sysutils/collectd | |
parent | b1c9c7d6701ae43e313d465805dea5bb32e9f713 (diff) | |
download | pkgsrc-8d6edd579ad9087307af6764ffaae37e941a9c74.tar.gz |
Re-work the entropy patch to put the error section up front, and
the Linux code above the NetBSD code. No code change, except ensure
to forward-declare the common functions in all cases.
Diffstat (limited to 'sysutils/collectd')
-rw-r--r-- | sysutils/collectd/distinfo | 4 | ||||
-rw-r--r-- | sysutils/collectd/patches/patch-src_entropy.c | 88 |
2 files changed, 50 insertions, 42 deletions
diff --git a/sysutils/collectd/distinfo b/sysutils/collectd/distinfo index 6d8d96da4b8..f80db474ab6 100644 --- a/sysutils/collectd/distinfo +++ b/sysutils/collectd/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.19 2015/09/01 09:00:04 he Exp $ +$NetBSD: distinfo,v 1.20 2015/09/01 09:31:46 he Exp $ SHA1 (collectd-5.5.0.tar.gz) = d24e284c1eae20c5e75b846c8b2612ab65bd5565 RMD160 (collectd-5.5.0.tar.gz) = 2197758942a5fe56e4eabda3786f09d4138e943a @@ -15,7 +15,7 @@ SHA1 (patch-src_config.h.in) = be17db23b6ee7a90ba57e73f073ed5be11c369c5 SHA1 (patch-src_cpu.c) = 55b5cfc69bf0df279d1a12003eb6a8e681155e18 SHA1 (patch-src_df.c) = 7e75dfbc72ecad48eb0eb7427a19329daf6b9a60 SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5 -SHA1 (patch-src_entropy.c) = 7a522a6849d39bf4ed4704204a084790d27950ef +SHA1 (patch-src_entropy.c) = 46d5357d8407584943e9259325989e64a8710cc0 SHA1 (patch-src_irq.c) = 6b621474de35a5879105025d1a2848e4896b8479 SHA1 (patch-src_libcollectclient_network__buffer.c) = e07d403d299613fa0885a0e7285849eb85510253 SHA1 (patch-src_memory.c) = f48d50245176426e26af7fa1b1f4ff6fbf0b1d95 diff --git a/sysutils/collectd/patches/patch-src_entropy.c b/sysutils/collectd/patches/patch-src_entropy.c index 9039422231a..026ee0e61b7 100644 --- a/sysutils/collectd/patches/patch-src_entropy.c +++ b/sysutils/collectd/patches/patch-src_entropy.c @@ -1,15 +1,51 @@ -$NetBSD: patch-src_entropy.c,v 1.3 2015/08/18 07:47:46 he Exp $ +$NetBSD: patch-src_entropy.c,v 1.4 2015/09/01 09:31:46 he Exp $ Provide a NetBSD implementation for graphing available entropy. --- src/entropy.c.orig 2015-03-10 14:14:45.000000000 +0000 +++ src/entropy.c -@@ -29,27 +29,47 @@ +@@ -28,27 +28,16 @@ + #include "common.h" #include "plugin.h" - #if !KERNEL_LINUX +-#if !KERNEL_LINUX -# error "No applicable input method." -+# if KERNEL_NETBSD +-#endif +- +-#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" ++static void entropy_submit (double); ++static int entropy_read (void); + +-static void entropy_submit (double entropy) +-{ +- value_t values[1]; +- value_list_t vl = VALUE_LIST_INIT; ++#if !KERNEL_LINUX && !KERNEL_NETBSD ++# error "No applicable input method." ++#endif + +- values[0].gauge = entropy; ++#if KERNEL_LINUX + +- vl.values = values; +- vl.values_len = 1; +- sstrncpy (vl.host, hostname_g, sizeof (vl.host)); +- sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin)); +- sstrncpy (vl.type, "entropy", sizeof (vl.type)); +- +- plugin_dispatch_values (&vl); +-} ++#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" + + static int entropy_read (void) + { +@@ -74,6 +63,56 @@ static int entropy_read (void) + + return (0); + } ++#endif /* KERNEL_LINUX */ ++ ++#if KERNEL_NETBSD +/* Provide a NetBSD implementation, partial from rndctl.c */ + +#include <sys/types.h> @@ -18,57 +54,29 @@ Provide a NetBSD implementation for graphing available entropy. +#include <sys/rnd.h> +#if HAVE_SYS_RNDIO_H +# include <sys/rndio.h> - #endif ++#endif +#include <paths.h> - --#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" -+static void entropy_submit (double); -+static int entropy_read (void); - --static void entropy_submit (double entropy) ++ +static int +entropy_read (void) - { -- value_t values[1]; -- value_list_t vl = VALUE_LIST_INIT; ++{ + rndpoolstat_t rs; + int fd; - -- values[0].gauge = entropy; ++ + fd = open(_PATH_URANDOM, O_RDONLY, 0644); + if (fd < 0) + return -1; - -- vl.values = values; -- vl.values_len = 1; -- sstrncpy (vl.host, hostname_g, sizeof (vl.host)); -- sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin)); -- sstrncpy (vl.type, "entropy", sizeof (vl.type)); ++ + if (ioctl(fd, RNDGETPOOLSTAT, &rs) < 0) + return -1; - -- plugin_dispatch_values (&vl); ++ + entropy_submit (rs.curentropy); + + close(fd); + return 0; - } - -+# else /* KERNEL_NETBSD */ -+# error "No applicable input method." -+# endif -+#else /* Linux */ -+ -+#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" ++} + - static int entropy_read (void) - { - double entropy; -@@ -74,6 +94,23 @@ static int entropy_read (void) - - return (0); - } -+#endif /* not Linux */ ++#endif /* KERNEL_NETBSD */ + +static void entropy_submit (double entropy) +{ |