Currently, the getconf build fails on platforms (e.g. Android) without
confstr(3)
From c1a616fd5ff18a202ad934bbb23ba4d444458685 Mon Sep 17 00:00:00 2001
From: Grisha Levit <[email protected]>
Date: Thu, 13 Apr 2023 04:32:04 -0400
Subject: [PATCH] support getconf builtin build without confstr
---
examples/loadables/getconf.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/examples/loadables/getconf.c b/examples/loadables/getconf.c
index 0dc213be..cd89b82f 100644
--- a/examples/loadables/getconf.c
+++ b/examples/loadables/getconf.c
@@ -47,7 +47,15 @@ struct conf
{
const char *name;
const long call_name; /* or value for CONSTANT */
- const enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, UNDEFINED } call;
+ const enum {
+ SYSCONF,
+#if HAVE_CONFSTR
+ CONFSTR,
+#endif
+ PATHCONF,
+ CONSTANT,
+ UNDEFINED
+ } call;
};
static const struct conf vars[] =
@@ -489,8 +497,10 @@ static const struct conf vars[] =
{ "POSIX2_UPE", _SC_2_UPE, SYSCONF },
{ "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
+#ifdef _CS_PATH
{ "PATH", _CS_PATH, CONFSTR },
{ "CS_PATH", _CS_PATH, CONFSTR },
+#endif
/* LFS */
#ifdef _CS_LFS_CFLAGS
@@ -1072,6 +1082,7 @@ getconf_print (const struct conf *c, const char *vpath, int all)
printf ("%ld\n", value);
return (EXECUTION_SUCCESS);
+#if HAVE_CONFSTR
case CONFSTR:
errno = 0;
clen = confstr (cn, (char *) NULL, 0);
@@ -1092,6 +1103,7 @@ getconf_print (const struct conf *c, const char *vpath, int all)
printf ("%.*s\n", (int) clen, cvalue);
free (cvalue);
return (EXECUTION_SUCCESS);
+#endif
case CONSTANT:
return (getconf_internal (c, all));
--
2.40.0