[PATCH 6/7] killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS.
If sysconf returns an error, fall back to MAXSYMLINKS on platforms
that define it.
Fixes build on Hurd.
---
debian/changelog | 2 ++
src/killall5.c | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index ce16030..dd1861d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -60,6 +60,8 @@ sysvinit (2.88dsf-42) UNRELEASED; urgency=low
only recently.
* checkroot.sh: Only run rootcheck on Linux. Neither kFreeBSD nor Hurd
have /dev/root and the device ids used here are specific to Linux.
+ * killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS.
+ Fixes build on Hurd.
-- Roger Leigh <rleigh@debian.org> Sat, 04 May 2013 13:13:51 +0100
diff --git a/src/killall5.c b/src/killall5.c
index 5937d98..2c9bb4f 100644
--- a/src/killall5.c
+++ b/src/killall5.c
@@ -367,13 +367,26 @@ out:
}
/*
+ * Get the maximal number of symlinks to follow.
+ */
+static int maxsymlinks(void)
+{
+ int v = sysconf(_SC_SYMLOOP_MAX);
+#ifdef MAXSYMLINKS
+ if (v == -1)
+ return MAXSYMLINKS;
+#endif
+ return v;
+}
+
+/*
* Check path is located on a network based partition.
*/
int check4nfs(const char * path, char * real)
{
char buf[PATH_MAX+1];
const char *curr;
- int deep = MAXSYMLINKS;
+ int deep = maxsymlinks();
if (!nlist) return 0;
--
1.7.10.4
Reply to: