From 454ec8915dff0002be280915f722107bdc4f7cd0 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Sun, 7 Jul 2013 00:33:03 -0700 Subject: [PATCH] Handle 64-bit offsets correctly on Android --- fsck/Android.mk | 4 ++-- fsck/main.c | 2 +- fuse/Android.mk | 4 ++-- fuse/main.c | 2 +- libexfat/Android.mk | 2 +- libexfat/exfat.h | 5 +++++ libexfat/io.c | 6 ++++++ libexfat/platform.h | 4 ++-- mkfs/Android.mk | 4 ++-- mkfs/cbm.c | 2 +- mkfs/fat.c | 1 + mkfs/main.c | 2 +- mkfs/mkexfat.c | 2 +- mkfs/rootdir.c | 2 +- mkfs/vbr.c | 2 +- 15 files changed, 28 insertions(+), 16 deletions(-) diff --git a/fsck/Android.mk b/fsck/Android.mk index 145384a..eab2d97 100644 --- a/fsck/Android.mk +++ b/fsck/Android.mk @@ -9,8 +9,8 @@ LOCAL_SRC_FILES = main.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ external/exfat/libexfat \ external/fuse/include -LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl -LOCAL_STATIC_LIBRARIES += libfuse +LOCAL_SHARED_LIBRARIES += libz libc libdl +LOCAL_STATIC_LIBRARIES += libexfat libfuse include $(BUILD_EXECUTABLE) diff --git a/fsck/main.c b/fsck/main.c index f6ba4fd..104b8af 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -18,9 +18,9 @@ along with this program. If not, see . */ +#include #include #include -#include #include #include #include diff --git a/fuse/Android.mk b/fuse/Android.mk index cf7688f..ff35c78 100644 --- a/fuse/Android.mk +++ b/fuse/Android.mk @@ -9,7 +9,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH) \ external/exfat/libexfat \ external/fuse/include \ external/fuse/android -LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl -LOCAL_STATIC_LIBRARIES += libfuse +LOCAL_SHARED_LIBRARIES += libz libc libdl +LOCAL_STATIC_LIBRARIES += libexfat libfuse include $(BUILD_EXECUTABLE) diff --git a/fuse/main.c b/fuse/main.c index 6d91fb5..191ae93 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -19,13 +19,13 @@ */ #define FUSE_USE_VERSION 26 +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/libexfat/Android.mk b/libexfat/Android.mk index 39a7faa..44b8b4b 100644 --- a/libexfat/Android.mk +++ b/libexfat/Android.mk @@ -9,4 +9,4 @@ LOCAL_SRC_FILES = cluster.c io.c log.c lookup.c mount.c node.c time.c utf.c util LOCAL_C_INCLUDES += $(LOCAL_PATH) \ LOCAL_SHARED_LIBRARIES += libc -include $(BUILD_SHARED_LIBRARY) +include $(BUILD_STATIC_LIBRARY) diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 9a9d596..f8480b5 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -22,6 +22,11 @@ #ifndef EXFAT_H_INCLUDED #define EXFAT_H_INCLUDED +#if defined(__ANDROID__) +#define _OFF_T_DEFINED_ +typedef long long off_t; +#endif + #include #include #include diff --git a/libexfat/io.c b/libexfat/io.c index fea3562..9bd1233 100644 --- a/libexfat/io.c +++ b/libexfat/io.c @@ -251,6 +251,8 @@ off_t exfat_seek(struct exfat_dev* dev, off_t offset, int whence) #ifdef USE_UBLIO /* XXX SEEK_CUR will be handled incorrectly */ return dev->pos = lseek(dev->fd, offset, whence); +#elif defined(__ANDROID__) + return lseek64(dev->fd, offset, whence); #else return lseek(dev->fd, offset, whence); #endif @@ -285,6 +287,8 @@ void exfat_pread(struct exfat_dev* dev, void* buffer, size_t size, { #ifdef USE_UBLIO if (ublio_pread(dev->ufh, buffer, size, offset) != size) +#elif defined(__ANDROID__) + if (pread64(dev->fd, buffer, size, offset) != size) #else if (pread(dev->fd, buffer, size, offset) != size) #endif @@ -297,6 +301,8 @@ void exfat_pwrite(struct exfat_dev* dev, const void* buffer, size_t size, { #ifdef USE_UBLIO if (ublio_pwrite(dev->ufh, buffer, size, offset) != size) +#elif defined(__ANDROID__) + if (pwrite64(dev->fd, buffer, size, offset) != size) #else if (pwrite(dev->fd, buffer, size, offset) != size) #endif diff --git a/libexfat/platform.h b/libexfat/platform.h index 1537283..f3429ae 100644 --- a/libexfat/platform.h +++ b/libexfat/platform.h @@ -22,7 +22,7 @@ #ifndef PLATFORM_H_INCLUDED #define PLATFORM_H_INCLUDED -#if defined(__GLIBC__) +#if defined(__GLIBC__) || defined (__ANDROID__) #include #include @@ -38,7 +38,7 @@ #define __LITTLE_ENDIAN LITTLE_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN -#elif defined(__ANDROID__) || defined(__FreeBSD__) || defined(__DragonFlyBSD__) || defined(__NetBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFlyBSD__) || defined(__NetBSD__) #include #define bswap_16(x) bswap16(x) diff --git a/mkfs/Android.mk b/mkfs/Android.mk index 4ca91bc..dfaae73 100644 --- a/mkfs/Android.mk +++ b/mkfs/Android.mk @@ -9,7 +9,7 @@ LOCAL_SRC_FILES = cbm.c fat.c main.c mkexfat.c rootdir.c uct.c uctc.c vbr.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ external/exfat/libexfat \ external/fuse/include -LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl -LOCAL_STATIC_LIBRARIES += libfuse +LOCAL_SHARED_LIBRARIES += libz libc libdl +LOCAL_STATIC_LIBRARIES += libexfat libfuse include $(BUILD_EXECUTABLE) diff --git a/mkfs/cbm.c b/mkfs/cbm.c index c631d8a..8abdad0 100644 --- a/mkfs/cbm.c +++ b/mkfs/cbm.c @@ -18,11 +18,11 @@ along with this program. If not, see . */ -#include #include "cbm.h" #include "fat.h" #include "uct.h" #include "rootdir.h" +#include static off_t cbm_alignment(void) { diff --git a/mkfs/fat.c b/mkfs/fat.c index 9df890a..2cfed58 100644 --- a/mkfs/fat.c +++ b/mkfs/fat.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ +#include #include #include "fat.h" #include "cbm.h" diff --git a/mkfs/main.c b/mkfs/main.c index 28b3ec1..8a419f1 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #include "mkexfat.h" #include "vbr.h" #include "fat.h" diff --git a/mkfs/mkexfat.c b/mkfs/mkexfat.c index 7e300df..dd7d404 100644 --- a/mkfs/mkexfat.c +++ b/mkfs/mkexfat.c @@ -18,12 +18,12 @@ along with this program. If not, see . */ +#include "mkexfat.h" #include #include #include #include #include -#include "mkexfat.h" static int check_size(off_t volume_size) { diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index 22add95..6370565 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -18,11 +18,11 @@ along with this program. If not, see . */ -#include #include "rootdir.h" #include "uct.h" #include "cbm.h" #include "uctc.h" +#include static off_t rootdir_alignment(void) { diff --git a/mkfs/vbr.c b/mkfs/vbr.c index ce7a3bf..42c70f4 100644 --- a/mkfs/vbr.c +++ b/mkfs/vbr.c @@ -18,12 +18,12 @@ along with this program. If not, see . */ -#include #include "vbr.h" #include "fat.h" #include "cbm.h" #include "uct.h" #include "rootdir.h" +#include static off_t vbr_alignment(void) { -- 2.11.0