From edddd76165791d0412d23df2ff0af590a8a1f03d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 25 Sep 2016 10:52:55 -0700 Subject: [PATCH] collectd: patch deprecated usage of readdir_r() (#18956) --- pkgs/tools/system/collectd/default.nix | 5 ++ pkgs/tools/system/collectd/readdir-fix.patch | 55 ++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 pkgs/tools/system/collectd/readdir-fix.patch diff --git a/pkgs/tools/system/collectd/default.nix b/pkgs/tools/system/collectd/default.nix index 2aa5f9fb4c4e..fb2a66ecf37e 100644 --- a/pkgs/tools/system/collectd/default.nix +++ b/pkgs/tools/system/collectd/default.nix @@ -49,6 +49,11 @@ stdenv.mkDerivation rec { varnish yajl jdk libtool python udev net_snmp hiredis libmnl ]; + patches = [ + # Replace deprecated readdir_r() with readdir() to avoid a fatal warning. + ./readdir-fix.patch + ]; + # for some reason libsigrok isn't auto-detected configureFlags = stdenv.lib.optional (libsigrok != null) "--with-libsigrok" ++ diff --git a/pkgs/tools/system/collectd/readdir-fix.patch b/pkgs/tools/system/collectd/readdir-fix.patch new file mode 100644 index 000000000000..171dfc689a4d --- /dev/null +++ b/pkgs/tools/system/collectd/readdir-fix.patch @@ -0,0 +1,55 @@ +diff -Naur collectd-5.6.0/src/vserver.c collectd-5.6.0/src/vserver.c +--- collectd-5.6.0/src/vserver.c 2016-09-11 01:10:25.279038699 -0700 ++++ collectd-5.6.0/src/vserver.c 2016-09-25 07:44:40.771177458 -0700 +@@ -132,15 +132,8 @@ + + static int vserver_read (void) + { +-#if NAME_MAX < 1024 +-# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + 1024 + 1) +-#else +-# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + NAME_MAX + 1) +-#endif +- + DIR *proc; + struct dirent *dent; /* 42 */ +- char dirent_buffer[DIRENT_BUFFER_SIZE]; + + errno = 0; + proc = opendir (PROCDIR); +@@ -165,19 +158,23 @@ + + int status; + +- status = readdir_r (proc, (struct dirent *) dirent_buffer, &dent); +- if (status != 0) +- { +- char errbuf[4096]; +- ERROR ("vserver plugin: readdir_r failed: %s", +- sstrerror (errno, errbuf, sizeof (errbuf))); +- closedir (proc); +- return (-1); +- } +- else if (dent == NULL) ++ errno = 0; ++ dent = readdir (proc); ++ if (dent == NULL) + { +- /* end of directory */ +- break; ++ if (errno != 0) ++ { ++ char errbuf[4096]; ++ ERROR ("vserver plugin: readdir failed: %s", ++ sstrerror (errno, errbuf, sizeof (errbuf))); ++ closedir (proc); ++ return (-1); ++ } ++ else ++ { ++ /* end of directory */ ++ break; ++ } + } + + if (dent->d_name[0] == '.')