Whamcloud - gitweb
AOSP: android: libext2fs and com_err for windows
authorAdrien Schildknecht <adriens@google.com>
Wed, 23 Nov 2016 18:21:42 +0000 (10:21 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 24 May 2017 02:47:23 +0000 (22:47 -0400)
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>
configure.ac
include/nonunix/linux/types.h
lib/et/Android.mk
lib/et/error_message.c
lib/ext2fs/Android.mk
lib/ext2fs/blkmap64_rb.c
lib/ext2fs/flushb.c
lib/ext2fs/jfs_compat.h
lib/ext2fs/test_io.c
lib/ext2fs/unix_io.c
util/android_config.h

index 9da7b86..4c994da 100644 (file)
@@ -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
index 8e5bc90..eb87011 100644 (file)
@@ -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 */
index f1b5105..c14e290 100644 (file)
@@ -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)
index fe79122..5dd8aa6 100644 (file)
@@ -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;
 
index e248ffe..047b867 100644 (file)
@@ -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)
index 7e7e29d..8d5ddd3 100644 (file)
@@ -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"
index 98821fc..fe1d3e7 100644 (file)
@@ -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) {
 
index 75a0596..9137367 100644 (file)
@@ -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 ""
index f7c50d1..ee828be 100644 (file)
@@ -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;
index f4e6148..dc2a2e9 100644 (file)
@@ -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;
 }
 
index bcf8122..9b09ce6 100644 (file)
@@ -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
 #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