aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIsaac Dunham <ibid.ag@gmail.com>2014-11-19 16:38:46 -0600
committerIsaac Dunham <ibid.ag@gmail.com>2014-11-19 16:38:46 -0600
commit46ddf0e34b03f7711a9c80f7a70dc8cbf732f782 (patch)
tree4f69c03c7da6c6f3fd977182ebb93c89703d47a8 /lib
parent159a7f1621eecf6cf3c2824ffb762a19bf5f7667 (diff)
downloadtoybox-46ddf0e34b03f7711a9c80f7a70dc8cbf732f782.tar.gz
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Android is missing all of these; we need to probe for some so we have a config symbol to depend on. sethostname() is easily replaced. We got termios.h via pty.h; now it's not included in configure-step tools, so we need termios.h to generate globals.
Diffstat (limited to 'lib')
-rw-r--r--lib/portability.c10
-rw-r--r--lib/portability.h17
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/portability.c b/lib/portability.c
index d901a4b6..29608bc1 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -5,6 +5,9 @@
*/
#include "toys.h"
+#if defined(__ANDROID__)
+#include <asm/unistd.h>
+#endif
#if defined(__APPLE__) || defined(__ANDROID__)
ssize_t getdelim(char **linep, size_t *np, int delim, FILE *stream)
@@ -61,6 +64,13 @@ ssize_t getline(char **linep, size_t *np, FILE *stream)
}
#endif
+#if defined(__ANDROID__)
+int sethostname(const char *name, size_t len)
+{
+ return syscall(__NR_sethostname, name, len);
+}
+#endif
+
#if defined(__APPLE__)
extern char **environ;
diff --git a/lib/portability.h b/lib/portability.h
index b7a7c794..5383efaa 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -180,10 +180,25 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream);
#endif
// Linux headers not listed by POSIX or LSB
-#include <shadow.h>
#include <sys/mount.h>
#include <sys/swap.h>
+// Android is missing some headers and functions
+#if defined(__ANDROID__)
+int sethostname(const char *name, size_t len);
+#endif
+// "generated/config.h" is included first
+#if defined(CFG_TOYBOX_SHADOW) && CFG_TOYBOX_SHADOW
+#include <shadow.h>
+#endif
+#if defined(CFG_TOYBOX_UTMPX) && CFG_TOYBOX_UTMPX
+#include <utmpx.h>
+#endif
+#if defined(CFG_TOYBOX_PTY) && CFG_TOYBOX_PTY
+#include <pty.h>
+#endif
+
+
// Some systems don't define O_NOFOLLOW, and it varies by architecture, so...
#include <fcntl.h>
#ifndef O_NOFOLLOW