[Toybox] [PATCH 8/8] Add compat swapon(), swapoff() and sethostname() for Android.

Georgi Chorbadzhiyski gf at unixsol.org
Tue Apr 24 02:20:51 PDT 2012


---
 lib/portability.c |   14 ++++++++++++++
 lib/portability.h |   10 ++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/lib/portability.c b/lib/portability.c
index b1c448c..3e439fa 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -73,3 +73,17 @@ int clearenv(void) {
 	return 0;
 }
 #endif
+
+#if defined(__ANDROID__)
+int sethostname(const char *name, size_t len) {
+	return syscall(__NR_sethostname, name, len);
+}
+
+int swapoff(const char *path) {
+	return syscall(__NR_swapon, path);
+}
+
+int swapon(const char *path, int swapflags) {
+	return syscall(__NR_swapon, path, swapflags);
+}
+#endif
diff --git a/lib/portability.h b/lib/portability.h
index 9b8d294..7237090 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -32,6 +32,10 @@ char *strptime(const char *buf, const char *format, struct tm *tm);
 #define noreturn
 #endif
 
+#ifdef __ANDROID__
+#include <asm/unistd.h>
+#endif
+
 #ifndef __APPLE__
 #include <byteswap.h>
 #include <endian.h>
@@ -87,3 +91,9 @@ int clearenv(void);
 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
 ssize_t getline(char **lineptr, size_t *n, FILE *stream);
 #endif
+
+#if defined(__ANDROID__)
+int sethostname(const char *name, size_t len);
+int swapoff(const char *path);
+int swapon(const char *path, int swapflags);
+#endif
-- 
1.7.5.1


 1335259251.0


More information about the Toybox mailing list