From 88f991b0ebb6fb8fcaad3d0eb8fb51a7439d053e Mon Sep 17 00:00:00 2001
From: Fabian Groffen <grobian@gentoo.org>
Date: Wed, 2 Feb 2022 09:27:13 +0800
Subject: [PATCH 1/2] autofs-5.1.8 - add autofs_strerror_r() helper for musl

If using musl libc the XSI-compliant variant strerror_r() which returns
an integer instead of a pointer so add a helper function to handle this
case.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending

 include/automount.h |  5 +++++
 lib/log.c           | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/automount.h b/include/automount.h
index 8cd8b3a..f759e59 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -51,6 +51,11 @@
 # endif
 #endif
 
+#ifndef __GLIBC__
+# define strerror_r(N,B,S) autofs_strerror_r(N,B,S)
+char *autofs_strerror_r(int errnum, char *buf, size_t buflen);  /* GNU */
+#endif
+
 /* We MUST have the paths to mount(8) and umount(8) */
 #ifndef HAVE_MOUNT
 #error Failed to locate mount(8)!
diff --git a/lib/log.c b/lib/log.c
index 39b1e3b..b99fa39 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -368,3 +368,13 @@ pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label) {
 
 	return ppid;
 }
+
+#ifndef __GLIBC__
+# undef strerror_r
+char *autofs_strerror_r(int errnum, char *buf, size_t buflen) {
+	int s = strerror_r(errnum, buf, buflen);
+	if (s)
+		return NULL;
+	return buf;
+}
+#endif
-- 
2.37.3

