blob: 5fd9a8d12930774cd2dd970064ba55e99c934a04 [file] [log] [blame]
Andrew Geissler87f5cff2022-09-30 13:13:31 -05001From 88f991b0ebb6fb8fcaad3d0eb8fb51a7439d053e Mon Sep 17 00:00:00 2001
2From: Fabian Groffen <grobian@gentoo.org>
3Date: Wed, 2 Feb 2022 09:27:13 +0800
4Subject: [PATCH 1/2] autofs-5.1.8 - add autofs_strerror_r() helper for musl
5
6If using musl libc the XSI-compliant variant strerror_r() which returns
7an integer instead of a pointer so add a helper function to handle this
8case.
9
10Signed-off-by: Fabian Groffen <grobian@gentoo.org>
11Signed-off-by: Ian Kent <raven@themaw.net>
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 include/automount.h | 5 +++++
15 lib/log.c | 10 ++++++++++
16 2 files changed, 15 insertions(+)
17
18diff --git a/include/automount.h b/include/automount.h
19index 8cd8b3a..f759e59 100644
20--- a/include/automount.h
21+++ b/include/automount.h
22@@ -51,6 +51,11 @@
23 # endif
24 #endif
25
26+#ifndef __GLIBC__
27+# define strerror_r(N,B,S) autofs_strerror_r(N,B,S)
28+char *autofs_strerror_r(int errnum, char *buf, size_t buflen); /* GNU */
29+#endif
30+
31 /* We MUST have the paths to mount(8) and umount(8) */
32 #ifndef HAVE_MOUNT
33 #error Failed to locate mount(8)!
34diff --git a/lib/log.c b/lib/log.c
35index 39b1e3b..b99fa39 100644
36--- a/lib/log.c
37+++ b/lib/log.c
38@@ -368,3 +368,13 @@ pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label) {
39
40 return ppid;
41 }
42+
43+#ifndef __GLIBC__
44+# undef strerror_r
45+char *autofs_strerror_r(int errnum, char *buf, size_t buflen) {
46+ int s = strerror_r(errnum, buf, buflen);
47+ if (s)
48+ return NULL;
49+ return buf;
50+}
51+#endif
52--
532.37.3
54