Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame^] | 1 | From 88f991b0ebb6fb8fcaad3d0eb8fb51a7439d053e Mon Sep 17 00:00:00 2001 |
| 2 | From: Fabian Groffen <grobian@gentoo.org> |
| 3 | Date: Wed, 2 Feb 2022 09:27:13 +0800 |
| 4 | Subject: [PATCH 1/2] autofs-5.1.8 - add autofs_strerror_r() helper for musl |
| 5 | |
| 6 | If using musl libc the XSI-compliant variant strerror_r() which returns |
| 7 | an integer instead of a pointer so add a helper function to handle this |
| 8 | case. |
| 9 | |
| 10 | Signed-off-by: Fabian Groffen <grobian@gentoo.org> |
| 11 | Signed-off-by: Ian Kent <raven@themaw.net> |
| 12 | Signed-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 | |
| 18 | diff --git a/include/automount.h b/include/automount.h |
| 19 | index 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)! |
| 34 | diff --git a/lib/log.c b/lib/log.c |
| 35 | index 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 | -- |
| 53 | 2.37.3 |
| 54 | |