1From 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---
14Upstream-Status: Pending
15
16 include/automount.h |  5 +++++
17 lib/log.c           | 10 ++++++++++
18 2 files changed, 15 insertions(+)
19
20diff --git a/include/automount.h b/include/automount.h
21index 8cd8b3a..f759e59 100644
22--- a/include/automount.h
23+++ b/include/automount.h
24@@ -51,6 +51,11 @@
25 # endif
26 #endif
27
28+#ifndef __GLIBC__
29+# define strerror_r(N,B,S) autofs_strerror_r(N,B,S)
30+char *autofs_strerror_r(int errnum, char *buf, size_t buflen);  /* GNU */
31+#endif
32+
33 /* We MUST have the paths to mount(8) and umount(8) */
34 #ifndef HAVE_MOUNT
35 #error Failed to locate mount(8)!
36diff --git a/lib/log.c b/lib/log.c
37index 39b1e3b..b99fa39 100644
38--- a/lib/log.c
39+++ b/lib/log.c
40@@ -368,3 +368,13 @@ pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label) {
41
42 	return ppid;
43 }
44+
45+#ifndef __GLIBC__
46+# undef strerror_r
47+char *autofs_strerror_r(int errnum, char *buf, size_t buflen) {
48+	int s = strerror_r(errnum, buf, buflen);
49+	if (s)
50+		return NULL;
51+	return buf;
52+}
53+#endif
54--
552.37.3
56
57