summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Schildknecht <adriens@google.com>2016-11-23 10:21:42 -0800
committerTheodore Ts'o <tytso@mit.edu>2017-05-23 22:47:23 -0400
commitf47f3195857867f18a781df317c833a3e97300c4 (patch)
tree891f6f03298f1e73dda46c5d2115c9c2c92f4918
parent43f927f7aa259c1deca0ec5855b1e5d23cb7f9e0 (diff)
downloade2fsprogs-f47f3195857867f18a781df317c833a3e97300c4.tar.gz
AOSP: android: libext2fs and com_err for windows
Test: m libext2fs-host && m libext2_com_err-host Change-Id: I92b6717b617a4f7f16182bf12af58cb22f20fa8f From AOSP commit: 1538eb4c580d53657f82e4e0170ca5ad5b67455c Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--configure.ac3
-rw-r--r--include/nonunix/linux/types.h13
-rw-r--r--lib/et/Android.mk2
-rw-r--r--lib/et/error_message.c6
-rw-r--r--lib/ext2fs/Android.mk18
-rw-r--r--lib/ext2fs/blkmap64_rb.c4
-rw-r--r--lib/ext2fs/flushb.c2
-rw-r--r--lib/ext2fs/jfs_compat.h4
-rw-r--r--lib/ext2fs/test_io.c2
-rw-r--r--lib/ext2fs/unix_io.c4
-rw-r--r--util/android_config.h72
11 files changed, 83 insertions, 47 deletions
diff --git a/configure.ac b/configure.ac
index 9da7b868..4c994da6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -920,6 +920,7 @@ AC_CHECK_HEADERS(m4_flatten([
linux/fd.h
linux/major.h
linux/loop.h
+ linux/types.h
net/if_dl.h
netinet/in.h
sys/acl.h
@@ -1094,8 +1095,10 @@ AC_CHECK_FUNCS(m4_flatten([
fallocate
fallocate64
fchown
+ fcntl
fdatasync
fstat64
+ fsync
ftruncate64
futimes
getcwd
diff --git a/include/nonunix/linux/types.h b/include/nonunix/linux/types.h
index 8e5bc90a..eb870113 100644
--- a/include/nonunix/linux/types.h
+++ b/include/nonunix/linux/types.h
@@ -1,10 +1,11 @@
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H
-#ifndef _MSC_VER
-#error _MSC_VER not defined
-#endif
+//#ifndef _MSC_VER
+//#error _MSC_VER not defined
+//#endif
+#include <sys/types.h>
typedef unsigned __int8 __u8;
typedef signed __int8 __s8;
@@ -22,7 +23,11 @@ typedef signed __int64 __s64;
typedef unsigned __int64 __u64;
-typedef __u32 ino_t;
+//typedef __u32 ino_t;
+typedef __u32 dev_t;
+typedef __u32 uid_t;
+typedef __u32 gid_t;
+#include <stdint.h>
#endif /* LINUX_TYPES_H */
diff --git a/lib/et/Android.mk b/lib/et/Android.mk
index f1b5105b..c14e2900 100644
--- a/lib/et/Android.mk
+++ b/lib/et/Android.mk
@@ -42,6 +42,7 @@ LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
LOCAL_CFLAGS := $(libext2_com_err_cflags)
LOCAL_MODULE := libext2_com_err-host
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_HOST_OS := darwin linux windows
include $(BUILD_HOST_SHARED_LIBRARY)
@@ -52,5 +53,6 @@ LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
LOCAL_CFLAGS := $(libext2_com_err_cflags)
LOCAL_MODULE := libext2_com_err-host
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_HOST_OS := darwin linux windows
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/et/error_message.c b/lib/et/error_message.c
index fe79122c..5dd8aa65 100644
--- a/lib/et/error_message.c
+++ b/lib/et/error_message.c
@@ -35,7 +35,9 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if HAVE_FCNTL
#include <fcntl.h>
+#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -196,8 +198,10 @@ oops:
*/
static char *safe_getenv(const char *arg)
{
+#if !defined(_WIN32)
if ((getuid() != geteuid()) || (getgid() != getegid()))
return NULL;
+#endif
#if HAVE_PRCTL
if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
return NULL;
@@ -249,11 +253,13 @@ static void init_debug(void)
debug_f = fopen("/dev/tty", "a");
if (debug_f) {
fd = fileno(debug_f);
+#if defined(HAVE_FCNTL)
if (fd >= 0) {
flags = fcntl(fd, F_GETFD);
if (flags >= 0)
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
}
+#endif
} else
debug_mask = DEBUG_INIT;
diff --git a/lib/ext2fs/Android.mk b/lib/ext2fs/Android.mk
index e248ffea..047b8670 100644
--- a/lib/ext2fs/Android.mk
+++ b/lib/ext2fs/Android.mk
@@ -86,17 +86,13 @@ libext2fs_src_files += test_io.c
libext2fs_shared_libraries := \
libext2_com_err \
- libext2_uuid \
- libext2_blkid \
- libext2_e2p
+ libext2_uuid
libext2fs_system_shared_libraries := libc
libext2fs_static_libraries := \
libext2_com_err \
- libext2_uuid_static \
- libext2_blkid \
- libext2_e2p
+ libext2_uuid_static
libext2fs_system_static_libraries := libc
@@ -132,25 +128,31 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libext2fs_src_files)
-LOCAL_SHARED_LIBRARIES := $(addsuffix -host, $(libext2fs_shared_libraries))
+LOCAL_WHOLE_STATIC_LIBRARIES := libext2_com_err-host
LOCAL_STATIC_LIBRARIES := libsparse_host libz
LOCAL_C_INCLUDES := $(libext2fs_c_includes)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(libext2fs_c_includes)
LOCAL_CFLAGS := $(libext2fs_cflags)
LOCAL_MODULE := libext2fs-host
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_HOST_OS := darwin linux windows
+LOCAL_CFLAGS_windows := -isystem external/e2fsprogs/include/nonunix -Wno-format
+LOCAL_LDLIBS_windows := -lws2_32
include $(BUILD_HOST_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libext2fs_src_files)
-LOCAL_STATIC_LIBRARIES := $(addsuffix -host, $(libext2fs_shared_libraries))
+LOCAL_WHOLE_STATIC_LIBRARIES := libext2_com_err-host
LOCAL_STATIC_LIBRARIES := libsparse_host libz
LOCAL_C_INCLUDES := $(libext2fs_c_includes)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(libext2fs_c_includes)
LOCAL_CFLAGS := $(libext2fs_cflags) $(libext2fs_cflags_linux)
LOCAL_MODULE := libext2fs-host
LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_HOST_OS := darwin linux windows
+LOCAL_CFLAGS_windows := -isystem external/e2fsprogs/include/nonunix -Wno-format
+LOCAL_LDLIBS_windows := -lws2_32
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index 7e7e29d4..8d5ddd3f 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -9,6 +9,7 @@
* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
@@ -22,6 +23,9 @@
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+#if HAVE_LINUX_TYPES_H
+#include <linux/types.h>
+#endif
#include "ext2_fs.h"
#include "ext2fsP.h"
diff --git a/lib/ext2fs/flushb.c b/lib/ext2fs/flushb.c
index 98821fc7..fe1d3e7d 100644
--- a/lib/ext2fs/flushb.c
+++ b/lib/ext2fs/flushb.c
@@ -58,8 +58,10 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
* still is a race condition for those kernels, but this
* reduces it greatly.)
*/
+#if defined(HAVE_FSYNC)
if (fsync (fd) == -1)
return errno;
+#endif
if (flushb) {
diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h
index 75a05966..91373674 100644
--- a/lib/ext2fs/jfs_compat.h
+++ b/lib/ext2fs/jfs_compat.h
@@ -7,7 +7,11 @@
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#else
#include <arpa/inet.h>
+#endif
#define printk printf
#define KERN_ERR ""
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index f7c50d1b..ee828be7 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -146,8 +146,10 @@ static void test_abort(io_channel channel, unsigned long block)
static char *safe_getenv(const char *arg)
{
+#if !defined(_WIN32)
if ((getuid() != geteuid()) || (getgid() != getegid()))
return NULL;
+#endif
#if HAVE_PRCTL
if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
return NULL;
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index f4e6148c..dc2a2e9f 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -718,6 +718,7 @@ static errcode_t unixfd_open(const char *str_fd, int flags,
int fd_flags;
fd = atoi(str_fd);
+#if defined(HAVE_FCNTL)
fd_flags = fcntl(fd, F_GETFD);
if (fd_flags == -1)
return -EBADF;
@@ -731,6 +732,7 @@ static errcode_t unixfd_open(const char *str_fd, int flags,
if (fd_flags & O_DIRECT)
flags |= IO_FLAG_DIRECT_IO;
#endif
+#endif /* HAVE_FCNTL */
return unix_open_channel(str_fd, fd, flags, channel, unixfd_io_manager);
}
@@ -1030,8 +1032,10 @@ static errcode_t unix_flush(io_channel channel)
#ifndef NO_IO_CACHE
retval = flush_cached_blocks(channel, data, 0);
#endif
+#ifdef HAVE_FSYNC
if (!retval && fsync(data->dev) != 0)
return errno;
+#endif
return retval;
}
diff --git a/util/android_config.h b/util/android_config.h
index bcf81229..9b09ce6b 100644
--- a/util/android_config.h
+++ b/util/android_config.h
@@ -9,33 +9,11 @@
#define DISABLE_BACKTRACE 1
#define HAVE_DIRENT_H 1
#define HAVE_ERRNO_H 1
-#define HAVE_EXT2_IOCTLS 1
-#define HAVE_FALLOCATE 1
#define HAVE_GETOPT_H 1
-#define HAVE_GETPAGESIZE 1
#define HAVE_GETPWUID_R 1
#define HAVE_INTPTR_T 1
#define HAVE_INTTYPES_H 1
-#ifdef __linux__
-#define HAVE_LINUX_FD_H 1
-#define HAVE_LSEEK64 1
-#define HAVE_LSEEK64_PROTOTYPE 1
-#endif
#define HAVE_MMAP 1
-#ifdef __linux__
-#define HAVE_MNTENT_H 1
-#endif
-#define HAVE_NETINET_IN_H 1
-#define HAVE_NET_IF_H 1
-#define HAVE_POSIX_MEMALIGN 1
-#define HAVE_PREAD 1
-#ifdef __linux__
-#define HAVE_PREAD64 1
-#endif
-#define HAVE_PWRITE 1
-#ifdef __linux__
-#define HAVE_PWRITE64 1
-#endif
#define HAVE_SETJMP_H 1
#ifdef __linux__
#define HAVE_SETMNTENT 1
@@ -48,19 +26,43 @@
#define HAVE_STRNLEN 1
#define HAVE_STRPTIME 1
#define HAVE_SYSCONF 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_MMAN_H 1
-#define HAVE_SYS_MOUNT_H 1
-#define HAVE_SYS_PARAM_H 1
-#ifdef __linux__
-#define HAVE_SYS_PRCTL_H 1
-#endif
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_WAIT_H 1
#define HAVE_TYPE_SSIZE_T 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1
+
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+
+#if defined(_WIN32)
+# define HAVE_LINUX_TYPES_H 1
+# define HAVE_WINSOCK_H 1
+#endif
+#if defined(__APPLE__) || defined(__linux__)
+# define HAVE_FCNTL 1
+# define HAVE_FSYNC 1
+# define HAVE_GETPAGESIZE 1
+# define HAVE_NET_IF_H 1
+# define HAVE_NETINET_IN_H 1
+# define HAVE_PREAD 1
+# define HAVE_PWRITE 1
+# define HAVE_POSIX_MEMALIGN 1
+# define HAVE_SYS_IOCTL_H 1
+# define HAVE_SYS_MMAN_H 1
+# define HAVE_SYS_MOUNT_H 1
+# define HAVE_SYS_PARAM_H 1
+# define HAVE_SYS_RESOURCE_H 1
+# define HAVE_SYS_SELECT_H 1
+# define HAVE_SYS_WAIT_H 1
+#endif
+#if defined(__linux__)
+# define HAVE_EXT2_IOCTLS 1
+# define HAVE_FALLOCATE 1
+# define HAVE_LINUX_FD_H 1
+# define HAVE_LINUX_TYPES_H 1
+# define HAVE_LSEEK64 1
+# define HAVE_LSEEK64_PROTOTYPE 1
+# define HAVE_PREAD64 1
+# define HAVE_PWRITE64 1
+# define HAVE_SYS_PRCTL_H 1
+#endif