Include sys/rndio.h if it's available to be able to compile the entropy plugin on newer NetBSD releases (>= 7.99.9, by the looks of it). No PKGREVISION bump since this is a configure+build fix.diff -r1.10 -r1.11 pkgsrc/sysutils/collectd/distinfo
(he)
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | $NetBSD: distinfo,v 1.10 2015/08/11 14:15:00 he Exp $ | 1 | $NetBSD: distinfo,v 1.11 2015/08/14 12:59:04 he Exp $ | |
2 | 2 | |||
3 | SHA1 (collectd-5.5.0.tar.gz) = d24e284c1eae20c5e75b846c8b2612ab65bd5565 | 3 | SHA1 (collectd-5.5.0.tar.gz) = d24e284c1eae20c5e75b846c8b2612ab65bd5565 | |
4 | RMD160 (collectd-5.5.0.tar.gz) = 2197758942a5fe56e4eabda3786f09d4138e943a | 4 | RMD160 (collectd-5.5.0.tar.gz) = 2197758942a5fe56e4eabda3786f09d4138e943a | |
5 | Size (collectd-5.5.0.tar.gz) = 2244454 bytes | 5 | Size (collectd-5.5.0.tar.gz) = 2244454 bytes | |
6 | SHA1 (patch-Makefile.in) = 197307399312fa26c71ca168b92bbe41d31d556d | 6 | SHA1 (patch-Makefile.in) = 197307399312fa26c71ca168b92bbe41d31d556d | |
7 | SHA1 (patch-configure) = d39d93002cd7b453122364824784c6b8c177724a | 7 | SHA1 (patch-configure) = ca8949de66bd19c4d398223d182e9fbecdcf861a | |
8 | SHA1 (patch-configure.ac) = 5a9224941ccf0091108346d01714641da79f3f49 | 8 | SHA1 (patch-configure.ac) = 48c0eedbd3de5e09a5593670017aff661744c7bc | |
9 | SHA1 (patch-src_Makefile.in) = f94d046ee323fdb9251ad49cf383b3a61df5dcaa | 9 | SHA1 (patch-src_Makefile.in) = f94d046ee323fdb9251ad49cf383b3a61df5dcaa | |
10 | SHA1 (patch-src_collectd-tg.c) = f9f41dfb0b1b55a62202128a165d5c9943faf5bc | 10 | SHA1 (patch-src_collectd-tg.c) = f9f41dfb0b1b55a62202128a165d5c9943faf5bc | |
11 | SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f | 11 | SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f | |
12 | SHA1 (patch-src_config.h.in) = 08765b041f4764873b4055140d85c4478faeba49 | 12 | SHA1 (patch-src_config.h.in) = 911a0441e15e0a85bb4819f1b49eaddbdd5c9d1c | |
13 | SHA1 (patch-src_df.c) = 19cca888b183a90759b359702e4d65c8afa6e58d | 13 | SHA1 (patch-src_df.c) = 19cca888b183a90759b359702e4d65c8afa6e58d | |
14 | SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5 | 14 | SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5 | |
15 | SHA1 (patch-src_entropy.c) = 51551cb758115e5fd7f099e787cfa7758a5f1ea9 | 15 | SHA1 (patch-src_entropy.c) = d9bfa1bd4d045f2218105eaadf2dda90b7fc4646 | |
16 | SHA1 (patch-src_libcollectclient_network__buffer.c) = e07d403d299613fa0885a0e7285849eb85510253 | 16 | SHA1 (patch-src_libcollectclient_network__buffer.c) = e07d403d299613fa0885a0e7285849eb85510253 | |
17 | SHA1 (patch-src_memory.c) = 7bbf24481e2ad6bb8b11a5e6bddd8145e1b2a6ef | 17 | SHA1 (patch-src_memory.c) = 7bbf24481e2ad6bb8b11a5e6bddd8145e1b2a6ef | |
18 | SHA1 (patch-src_swap.c) = e7602eb83eed6b90752b8293b9666b94bdd42493 | 18 | SHA1 (patch-src_swap.c) = e7602eb83eed6b90752b8293b9666b94bdd42493 | |
19 | SHA1 (patch-src_tcpconns.c) = 712af1b821d62217283df884dd283d5b1218ab7c | 19 | SHA1 (patch-src_tcpconns.c) = 712af1b821d62217283df884dd283d5b1218ab7c | |
20 | SHA1 (patch-src_utils__dns.c) = c3782dc9127f42da30e3142b853aa2cb2259af94 | 20 | SHA1 (patch-src_utils__dns.c) = c3782dc9127f42da30e3142b853aa2cb2259af94 | |
21 | SHA1 (patch-version-gen.sh) = 07d830019e22ac651514b75acf299b1f50c4632d | 21 | SHA1 (patch-version-gen.sh) = 07d830019e22ac651514b75acf299b1f50c4632d |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | $NetBSD: patch-configure,v 1.3 2015/08/11 13:19:21 he Exp $ | 1 | $NetBSD: patch-configure,v 1.4 2015/08/14 12:59:04 he Exp $ | |
2 | 2 | |||
3 | Regen from configure.ac. | 3 | Regen from configure.ac. | |
4 | 4 | |||
5 | --- configure.orig 2015-05-27 07:51:50.000000000 +0000 | 5 | --- configure.orig 2015-05-27 07:51:50.000000000 +0000 | |
6 | +++ configure | 6 | +++ configure | |
7 | @@ -13908,7 +13908,7 @@ else | 7 | @@ -13908,7 +13908,7 @@ else | |
8 | We can't simply define LARGE_OFF_T to be 9223372036854775807, | 8 | We can't simply define LARGE_OFF_T to be 9223372036854775807, | |
9 | since some C++ compilers masquerading as C compilers | 9 | since some C++ compilers masquerading as C compilers | |
10 | incorrectly reject 9223372036854775807. */ | 10 | incorrectly reject 9223372036854775807. */ | |
11 | -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) | 11 | -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) | |
12 | +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) | 12 | +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) | |
13 | int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 | 13 | int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 | |
14 | && LARGE_OFF_T % 2147483647 == 1) | 14 | && LARGE_OFF_T % 2147483647 == 1) | |
@@ -52,27 +52,57 @@ Regen from configure.ac. | @@ -52,27 +52,57 @@ Regen from configure.ac. | |||
52 | @@ -15319,6 +15319,12 @@ $as_echo "#define KERNEL_OPENBSD 1" >>co | 52 | @@ -15319,6 +15319,12 @@ $as_echo "#define KERNEL_OPENBSD 1" >>co | |
53 | 53 | |||
54 | ac_system="OpenBSD" | 54 | ac_system="OpenBSD" | |
55 | ;; | 55 | ;; | |
56 | + *netbsd*) | 56 | + *netbsd*) | |
57 | + | 57 | + | |
58 | +$as_echo "#define KERNEL_NETBSD 1" >>confdefs.h | 58 | +$as_echo "#define KERNEL_NETBSD 1" >>confdefs.h | |
59 | + | 59 | + | |
60 | + ac_system="NetBSD" | 60 | + ac_system="NetBSD" | |
61 | + ;; | 61 | + ;; | |
62 | *aix*) | 62 | *aix*) | |
63 | 63 | |||
64 | $as_echo "#define KERNEL_AIX 1" >>confdefs.h | 64 | $as_echo "#define KERNEL_AIX 1" >>confdefs.h | |
65 | @@ -19171,6 +19177,54 @@ else | 65 | @@ -15876,6 +15882,29 @@ fi | |
66 | done | |||
67 | ||||
68 | ||||
69 | +# For entropy plugin on newer NetBSD | |||
70 | +for ac_header in sys/rndio.h | |||
71 | +do : | |||
72 | + ac_fn_c_check_header_compile "$LINENO" "sys/rndio.h" "ac_cv_header_sys_rndio_h" "#if HAVE_SYS_TYPES_H | |||
73 | +# include <sys/types.h> | |||
74 | +#endif | |||
75 | +#if HAVE_SYS_IOCTL_H | |||
76 | +# include <sys/ioctl.h> | |||
77 | +#endif | |||
78 | +#if HAVE_SYS_PARAM_H | |||
79 | +# include <sys/param.h> | |||
80 | +#endif | |||
81 | + | |||
82 | +" | |||
83 | +if test "x$ac_cv_header_sys_rndio_h" = xyes; then : | |||
84 | + cat >>confdefs.h <<_ACEOF | |||
85 | +#define HAVE_SYS_RNDIO_H 1 | |||
86 | +_ACEOF | |||
87 | + | |||
88 | +fi | |||
89 | + | |||
90 | +done | |||
91 | + | |||
92 | # For ping library | |||
93 | for ac_header in netinet/in_systm.h | |||
94 | do : | |||
95 | @@ -19171,6 +19200,54 @@ else | |||
66 | fi | 96 | fi | |
67 | 97 | |||
68 | 98 | |||
69 | +ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_pid" "ac_cv_member_struct_kinfo_proc2_p_pid" " | 99 | +ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_pid" "ac_cv_member_struct_kinfo_proc2_p_pid" " | |
70 | +#include <sys/param.h> | 100 | +#include <sys/param.h> | |
71 | +#include <sys/sysctl.h> | 101 | +#include <sys/sysctl.h> | |
72 | +#include <kvm.h> | 102 | +#include <kvm.h> | |
73 | + | 103 | + | |
74 | +" | 104 | +" | |
75 | +if test "x$ac_cv_member_struct_kinfo_proc2_p_pid" = xyes; then : | 105 | +if test "x$ac_cv_member_struct_kinfo_proc2_p_pid" = xyes; then : | |
76 | + | 106 | + | |
77 | +cat >>confdefs.h <<_ACEOF | 107 | +cat >>confdefs.h <<_ACEOF | |
78 | +#define HAVE_STRUCT_KINFO_PROC2_P_PID 1 | 108 | +#define HAVE_STRUCT_KINFO_PROC2_P_PID 1 | |
@@ -107,38 +137,38 @@ Regen from configure.ac. | @@ -107,38 +137,38 @@ Regen from configure.ac. | |||
107 | + | 137 | + | |
108 | + have_struct_kinfo_proc_netbsd="yes" | 138 | + have_struct_kinfo_proc_netbsd="yes" | |
109 | + | 139 | + | |
110 | +else | 140 | +else | |
111 | + | 141 | + | |
112 | + have_struct_kinfo_proc_netbsd="no" | 142 | + have_struct_kinfo_proc_netbsd="no" | |
113 | + | 143 | + | |
114 | +fi | 144 | +fi | |
115 | + | 145 | + | |
116 | + | 146 | + | |
117 | ac_fn_c_check_member "$LINENO" "struct udphdr" "uh_dport" "ac_cv_member_struct_udphdr_uh_dport" "#define _BSD_SOURCE | 147 | ac_fn_c_check_member "$LINENO" "struct udphdr" "uh_dport" "ac_cv_member_struct_udphdr_uh_dport" "#define _BSD_SOURCE | |
118 | #define _DEFAULT_SOURCE | 148 | #define _DEFAULT_SOURCE | |
119 | #if HAVE_STDINT_H | 149 | #if HAVE_STDINT_H | |
120 | @@ -27648,6 +27702,12 @@ then | 150 | @@ -27648,6 +27725,12 @@ then | |
121 | plugin_tcpconns="yes" | 151 | plugin_tcpconns="yes" | |
122 | fi | 152 | fi | |
123 | 153 | |||
124 | +if test "x$ac_system" = "xNetBSD" | 154 | +if test "x$ac_system" = "xNetBSD" | |
125 | +then | 155 | +then | |
126 | + plugin_entropy="yes" | 156 | + plugin_entropy="yes" | |
127 | + plugin_disk="yes" | 157 | + plugin_disk="yes" | |
128 | +fi | 158 | +fi | |
129 | + | 159 | + | |
130 | # Mac OS X devices | 160 | # Mac OS X devices | |
131 | if test "x$with_libiokit" = "xyes" | 161 | if test "x$with_libiokit" = "xyes" | |
132 | then | 162 | then | |
133 | @@ -27890,6 +27950,11 @@ then | 163 | @@ -27890,6 +27973,11 @@ then | |
134 | plugin_swap="yes" | 164 | plugin_swap="yes" | |
135 | fi | 165 | fi | |
136 | 166 | |||
137 | +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes" | 167 | +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes" | |
138 | +then | 168 | +then | |
139 | + plugin_swap="yes" | 169 | + plugin_swap="yes" | |
140 | +fi | 170 | +fi | |
141 | + | 171 | + | |
142 | if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes" | 172 | if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes" | |
143 | then | 173 | then | |
144 | plugin_tcpconns="yes" | 174 | plugin_tcpconns="yes" |
@@ -1,66 +1,85 @@ | @@ -1,66 +1,85 @@ | |||
1 | $NetBSD: patch-configure.ac,v 1.1 2015/08/11 13:19:21 he Exp $ | 1 | $NetBSD: patch-configure.ac,v 1.2 2015/08/14 12:59:04 he Exp $ | |
2 | 2 | |||
3 | Add KERNEL_NETBSD, add entry and disk plugins for NetBSD, | 3 | Add KERNEL_NETBSD, add entry and disk plugins for NetBSD, | |
4 | and also do swap for "have_swapctl_three_args" (as for NetBSD). | 4 | and also do swap for "have_swapctl_three_args" (as for NetBSD). | |
5 | Also, the start of process support, but that's not yet finished. | 5 | Also, the start of process support, but that's not yet finished. | |
6 | 6 | |||
7 | --- configure.ac.orig 2015-05-27 07:51:35.000000000 +0000 | 7 | --- configure.ac.orig 2015-05-27 07:51:35.000000000 +0000 | |
8 | +++ configure.ac | 8 | +++ configure.ac | |
9 | @@ -77,6 +77,10 @@ case $host_os in | 9 | @@ -77,6 +77,10 @@ case $host_os in | |
10 | AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel]) | 10 | AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel]) | |
11 | ac_system="OpenBSD" | 11 | ac_system="OpenBSD" | |
12 | ;; | 12 | ;; | |
13 | + *netbsd*) | 13 | + *netbsd*) | |
14 | + AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel]) | 14 | + AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel]) | |
15 | + ac_system="NetBSD" | 15 | + ac_system="NetBSD" | |
16 | + ;; | 16 | + ;; | |
17 | *aix*) | 17 | *aix*) | |
18 | AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel]) | 18 | AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel]) | |
19 | ac_system="AIX" | 19 | ac_system="AIX" | |
20 | @@ -1363,6 +1367,21 @@ AC_CHECK_MEMBERS([struct kinfo_proc.p_pi | 20 | @@ -151,6 +155,18 @@ AC_HEADER_STDBOOL | |
21 | ||||
22 | AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h) | |||
23 | ||||
24 | +# For entropy plugin on newer NetBSD | |||
25 | +AC_CHECK_HEADERS(sys/rndio.h, [], [], | |||
26 | +[#if HAVE_SYS_TYPES_H | |||
27 | +# include <sys/types.h> | |||
28 | +#endif | |||
29 | +#if HAVE_SYS_IOCTL_H | |||
30 | +# include <sys/ioctl.h> | |||
31 | +#endif | |||
32 | +#if HAVE_SYS_PARAM_H | |||
33 | +# include <sys/param.h> | |||
34 | +#endif | |||
35 | +]) | |||
36 | # For ping library | |||
37 | AC_CHECK_HEADERS(netinet/in_systm.h, [], [], | |||
38 | [#if HAVE_STDINT_H | |||
39 | @@ -1363,6 +1379,21 @@ AC_CHECK_MEMBERS([struct kinfo_proc.p_pi | |||
21 | #include <kvm.h> | 40 | #include <kvm.h> | |
22 | ]) | 41 | ]) | |
23 | 42 | |||
24 | +AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss], | 43 | +AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss], | |
25 | + [ | 44 | + [ | |
26 | + AC_DEFINE(HAVE_STRUCT_KINFO_PROC_NETBSD, 1, | 45 | + AC_DEFINE(HAVE_STRUCT_KINFO_PROC_NETBSD, 1, | |
27 | + [Define if struct kinfo_proc2 exists in the NetBSD variant.]) | 46 | + [Define if struct kinfo_proc2 exists in the NetBSD variant.]) | |
28 | + have_struct_kinfo_proc_netbsd="yes" | 47 | + have_struct_kinfo_proc_netbsd="yes" | |
29 | + ], | 48 | + ], | |
30 | + [ | 49 | + [ | |
31 | + have_struct_kinfo_proc_netbsd="no" | 50 | + have_struct_kinfo_proc_netbsd="no" | |
32 | + ], | 51 | + ], | |
33 | + [ | 52 | + [ | |
34 | +#include <sys/param.h> | 53 | +#include <sys/param.h> | |
35 | +#include <sys/sysctl.h> | 54 | +#include <sys/sysctl.h> | |
36 | +#include <kvm.h> | 55 | +#include <kvm.h> | |
37 | + ]) | 56 | + ]) | |
38 | + | 57 | + | |
39 | AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [], | 58 | AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [], | |
40 | [#define _BSD_SOURCE | 59 | [#define _BSD_SOURCE | |
41 | #define _DEFAULT_SOURCE | 60 | #define _DEFAULT_SOURCE | |
42 | @@ -5244,6 +5263,12 @@ then | 61 | @@ -5244,6 +5275,12 @@ then | |
43 | plugin_tcpconns="yes" | 62 | plugin_tcpconns="yes" | |
44 | fi | 63 | fi | |
45 | 64 | |||
46 | +if test "x$ac_system" = "xNetBSD" | 65 | +if test "x$ac_system" = "xNetBSD" | |
47 | +then | 66 | +then | |
48 | + plugin_entropy="yes" | 67 | + plugin_entropy="yes" | |
49 | + plugin_disk="yes" | 68 | + plugin_disk="yes" | |
50 | +fi | 69 | +fi | |
51 | + | 70 | + | |
52 | # Mac OS X devices | 71 | # Mac OS X devices | |
53 | if test "x$with_libiokit" = "xyes" | 72 | if test "x$with_libiokit" = "xyes" | |
54 | then | 73 | then | |
55 | @@ -5482,6 +5507,11 @@ then | 74 | @@ -5482,6 +5519,11 @@ then | |
56 | plugin_swap="yes" | 75 | plugin_swap="yes" | |
57 | fi | 76 | fi | |
58 | 77 | |||
59 | +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes" | 78 | +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes" | |
60 | +then | 79 | +then | |
61 | + plugin_swap="yes" | 80 | + plugin_swap="yes" | |
62 | +fi | 81 | +fi | |
63 | + | 82 | + | |
64 | if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes" | 83 | if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes" | |
65 | then | 84 | then | |
66 | plugin_tcpconns="yes" | 85 | plugin_tcpconns="yes" |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | $NetBSD: patch-src_config.h.in,v 1.1 2015/08/11 13:19:21 he Exp $ | 1 | $NetBSD: patch-src_config.h.in,v 1.2 2015/08/14 12:59:04 he Exp $ | |
2 | 2 | |||
3 | Optionally define a few vars for NetBSD. | 3 | Optionally define a few vars for NetBSD. | |
4 | 4 | |||
5 | --- src/config.h.in.orig 2015-05-27 07:53:03.000000000 +0000 | 5 | --- src/config.h.in.orig 2015-05-27 07:53:03.000000000 +0000 | |
6 | +++ src/config.h.in | 6 | +++ src/config.h.in | |
7 | @@ -1246,6 +1246,12 @@ | 7 | @@ -1246,6 +1246,12 @@ | |
8 | /* Define to 1 if `imr_ifindex' is a member of `struct ip_mreqn'. */ | 8 | /* Define to 1 if `imr_ifindex' is a member of `struct ip_mreqn'. */ | |
9 | #undef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX | 9 | #undef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX | |
10 | 10 | |||
11 | +/* Define to 1 if `p_pid' is a member of `struct kinfo_proc2'. */ | 11 | +/* Define to 1 if `p_pid' is a member of `struct kinfo_proc2'. */ | |
12 | +#undef HAVE_STRUCT_KINFO_PROC2_P_PID | 12 | +#undef HAVE_STRUCT_KINFO_PROC2_P_PID | |
13 | + | 13 | + | |
14 | +/* Define to 1 if `p_uru_maxrss' is a member of `struct kinfo_proc2'. */ | 14 | +/* Define to 1 if `p_uru_maxrss' is a member of `struct kinfo_proc2'. */ | |
@@ -17,23 +17,33 @@ Optionally define a few vars for NetBSD. | @@ -17,23 +17,33 @@ Optionally define a few vars for NetBSD. | |||
17 | /* Define if struct kinfo_proc exists in the FreeBSD variant. */ | 17 | /* Define if struct kinfo_proc exists in the FreeBSD variant. */ | |
18 | #undef HAVE_STRUCT_KINFO_PROC_FREEBSD | 18 | #undef HAVE_STRUCT_KINFO_PROC_FREEBSD | |
19 | 19 | |||
20 | @@ -1258,6 +1264,9 @@ | 20 | @@ -1258,6 +1264,9 @@ | |
21 | /* Define to 1 if `ki_rusage' is a member of `struct kinfo_proc'. */ | 21 | /* Define to 1 if `ki_rusage' is a member of `struct kinfo_proc'. */ | |
22 | #undef HAVE_STRUCT_KINFO_PROC_KI_RUSAGE | 22 | #undef HAVE_STRUCT_KINFO_PROC_KI_RUSAGE | |
23 | 23 | |||
24 | +/* Define if struct kinfo_proc2 exists in the NetBSD variant. */ | 24 | +/* Define if struct kinfo_proc2 exists in the NetBSD variant. */ | |
25 | +#undef HAVE_STRUCT_KINFO_PROC_NETBSD | 25 | +#undef HAVE_STRUCT_KINFO_PROC_NETBSD | |
26 | + | 26 | + | |
27 | /* Define if struct kinfo_proc exists in the OpenBSD variant. */ | 27 | /* Define if struct kinfo_proc exists in the OpenBSD variant. */ | |
28 | #undef HAVE_STRUCT_KINFO_PROC_OPENBSD | 28 | #undef HAVE_STRUCT_KINFO_PROC_OPENBSD | |
29 | 29 | |||
30 | @@ -1507,6 +1516,9 @@ | 30 | @@ -1375,6 +1384,9 @@ | |
31 | /* Define to 1 if you have the <sys/resource.h> header file. */ | |||
32 | #undef HAVE_SYS_RESOURCE_H | |||
33 | ||||
34 | +/* Define to 1 if you have the <sys/rndio.h> header file. */ | |||
35 | +#undef HAVE_SYS_RNDIO_H | |||
36 | + | |||
37 | /* Define to 1 if you have the <sys/select.h> header file. */ | |||
38 | #undef HAVE_SYS_SELECT_H | |||
39 | ||||
40 | @@ -1507,6 +1519,9 @@ | |||
31 | /* True if program is to be compiled for a Linux kernel */ | 41 | /* True if program is to be compiled for a Linux kernel */ | |
32 | #undef KERNEL_LINUX | 42 | #undef KERNEL_LINUX | |
33 | 43 | |||
34 | +/* True if program is to be compiled for a NetBSD kernel */ | 44 | +/* True if program is to be compiled for a NetBSD kernel */ | |
35 | +#undef KERNEL_NETBSD | 45 | +#undef KERNEL_NETBSD | |
36 | + | 46 | + | |
37 | /* True if program is to be compiled for an OpenBSD kernel */ | 47 | /* True if program is to be compiled for an OpenBSD kernel */ | |
38 | #undef KERNEL_OPENBSD | 48 | #undef KERNEL_OPENBSD | |
39 | 49 |
@@ -1,38 +1,40 @@ | @@ -1,38 +1,40 @@ | |||
1 | $NetBSD: patch-src_entropy.c,v 1.1 2015/08/11 13:19:21 he Exp $ | 1 | $NetBSD: patch-src_entropy.c,v 1.2 2015/08/14 12:59:04 he Exp $ | |
2 | 2 | |||
3 | Provide a NetBSD implementation for graphing available entropy. | 3 | Provide a NetBSD implementation for graphing available entropy. | |
4 | 4 | |||
5 | --- src/entropy.c.orig 2015-03-10 14:14:45.000000000 +0000 | 5 | --- src/entropy.c.orig 2015-03-10 14:14:45.000000000 +0000 | |
6 | +++ src/entropy.c | 6 | +++ src/entropy.c | |
7 | @@ -29,27 +29,43 @@ | 7 | @@ -29,27 +29,46 @@ | |
8 | #include "plugin.h" | 8 | #include "plugin.h" | |
9 | 9 | |||
10 | #if !KERNEL_LINUX | 10 | #if !KERNEL_LINUX | |
11 | -# error "No applicable input method." | 11 | -# error "No applicable input method." | |
12 | -#endif | |||
13 | +# if defined(__NetBSD__) | 12 | +# if defined(__NetBSD__) | |
14 | +/* Provide a NetBSD implementation, partial from rndctl.c */ | 13 | +/* Provide a NetBSD implementation, partial from rndctl.c */ | |
15 | 14 | + | ||
16 | -#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" | |||
17 | +#include <sys/types.h> | 15 | +#include <sys/types.h> | |
18 | +#include <sys/ioctl.h> | 16 | +#include <sys/ioctl.h> | |
19 | +#include <sys/param.h> | 17 | +#include <sys/param.h> | |
20 | +#include <sys/rnd.h> | 18 | +#include <sys/rnd.h> | |
19 | +#if HAVE_SYS_RNDIO_H | |||
20 | +# include <sys/rndio.h> | |||
21 | #endif | |||
21 | 22 | |||
22 | -static void entropy_submit (double entropy) | 23 | -#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" | |
23 | +static void entropy_submit (double); | 24 | +static void entropy_submit (double); | |
24 | +static int entropy_read (void); | 25 | +static int entropy_read (void); | |
25 | + | 26 | ||
27 | -static void entropy_submit (double entropy) | |||
26 | +static int | 28 | +static int | |
27 | +entropy_read (void) | 29 | +entropy_read (void) | |
28 | { | 30 | { | |
29 | - value_t values[1]; | 31 | - value_t values[1]; | |
30 | - value_list_t vl = VALUE_LIST_INIT; | 32 | - value_list_t vl = VALUE_LIST_INIT; | |
31 | + rndpoolstat_t rs; | 33 | + rndpoolstat_t rs; | |
32 | + int fd; | 34 | + int fd; | |
33 | 35 | |||
34 | - values[0].gauge = entropy; | 36 | - values[0].gauge = entropy; | |
35 | + fd = open("/dev/urandom", O_RDONLY, 0644); | 37 | + fd = open("/dev/urandom", O_RDONLY, 0644); | |
36 | + if (fd < 0) | 38 | + if (fd < 0) | |
37 | + return -1; | 39 | + return -1; | |
38 | 40 | |||
@@ -51,27 +53,27 @@ Provide a NetBSD implementation for grap | @@ -51,27 +53,27 @@ Provide a NetBSD implementation for grap | |||
51 | + return 0; | 53 | + return 0; | |
52 | } | 54 | } | |
53 | 55 | |||
54 | +# else /* not NetBSD */ | 56 | +# else /* not NetBSD */ | |
55 | +# error "No applicable input method." | 57 | +# error "No applicable input method." | |
56 | +# endif | 58 | +# endif | |
57 | +#else /* Linux */ | 59 | +#else /* Linux */ | |
58 | + | 60 | + | |
59 | +#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" | 61 | +#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail" | |
60 | + | 62 | + | |
61 | static int entropy_read (void) | 63 | static int entropy_read (void) | |
62 | { | 64 | { | |
63 | double entropy; | 65 | double entropy; | |
64 | @@ -74,6 +90,23 @@ static int entropy_read (void) | 66 | @@ -74,6 +93,23 @@ static int entropy_read (void) | |
65 | 67 | |||
66 | return (0); | 68 | return (0); | |
67 | } | 69 | } | |
68 | +#endif /* not Linux */ | 70 | +#endif /* not Linux */ | |
69 | + | 71 | + | |
70 | +static void entropy_submit (double entropy) | 72 | +static void entropy_submit (double entropy) | |
71 | +{ | 73 | +{ | |
72 | + value_t values[1]; | 74 | + value_t values[1]; | |
73 | + value_list_t vl = VALUE_LIST_INIT; | 75 | + value_list_t vl = VALUE_LIST_INIT; | |
74 | + | 76 | + | |
75 | + values[0].gauge = entropy; | 77 | + values[0].gauge = entropy; | |
76 | + | 78 | + | |
77 | + vl.values = values; | 79 | + vl.values = values; |