From 054af4a2cbdb6fcccb3e7e16f4890cb05dcc8e7b Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Thu, 18 Dec 2014 04:32:52 +0000 Subject: fix segmentation faults of Ntfsfix Change-Id: I52a6aa829cf5d7d104d0cdeee5b7ef49078ef527 --- diff --git a/Android.mk b/Android.mk index e67abd7..1910532 100755 --- a/Android.mk +++ b/Android.mk @@ -1,7 +1,7 @@ ifneq ($(TARGET_SIMULATOR), true) LOCAL_PATH := $(call my-dir) -MY_CFLAG:= -O2 -g -W -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H +MY_CFLAG:= -O2 -g -W -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -DANDROID ################################################################### ## For stage1, we have to make libfuse ################################################################### diff --git a/include/ntfs-3g/logging.h b/include/ntfs-3g/logging.h index 82f39fe..61754ef 100755 --- a/include/ntfs-3g/logging.h +++ b/include/ntfs-3g/logging.h @@ -32,6 +32,9 @@ #endif #include "types.h" +#ifdef ANDROID +#include +#endif /* Function prototype for the logging handlers */ typedef int (ntfs_log_handler)(const char *function, const char *file, int line, @@ -86,10 +89,10 @@ int ntfs_log_redirect(const char *function, const char *file, int line, #define NTFS_LOG_FLAG_LINE (1 << 2) /* Show the line number of the message */ #define NTFS_LOG_FLAG_FUNCTION (1 << 3) /* Show the function name containing the message */ #define NTFS_LOG_FLAG_ONLYNAME (1 << 4) /* Only display the filename, not the pathname */ - /* Macros to simplify logging. One for each level defined above. * Note, ntfs_log_debug/trace have effect only if DEBUG is defined. */ +#ifndef ANDROID #define ntfs_log_critical(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_CRITICAL,NULL,FORMAT,##ARGS) #define ntfs_log_error(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_ERROR,NULL,FORMAT,##ARGS) #define ntfs_log_info(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_INFO,NULL,FORMAT,##ARGS) @@ -98,15 +101,32 @@ int ntfs_log_redirect(const char *function, const char *file, int line, #define ntfs_log_quiet(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_QUIET,NULL,FORMAT,##ARGS) #define ntfs_log_verbose(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_VERBOSE,NULL,FORMAT,##ARGS) #define ntfs_log_warning(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_WARNING,NULL,FORMAT,##ARGS) +#else +#define ntfs_log_critical(FORMAT, ARGS...) SLOGE(FORMAT,##ARGS) +#define ntfs_log_error(FORMAT, ARGS...) SLOGE(FORMAT,##ARGS) +#define ntfs_log_info(FORMAT, ARGS...) SLOGI(FORMAT,##ARGS) +#define ntfs_log_perror(FORMAT, ARGS...) SLOGE(FORMAT,##ARGS) +#define ntfs_log_progress(FORMAT, ARGS...) SLOGI(FORMAT,##ARGS) +#define ntfs_log_quiet(FORMAT, ARGS...) SLOGI(FORMAT,##ARGS) +#define ntfs_log_verbose(FORMAT, ARGS...) SLOGV(FORMAT,##ARGS) +#define ntfs_log_warning(FORMAT, ARGS...) SLOGW(FORMAT,##ARGS) +#endif /* By default debug and trace messages are compiled into the program, * but not displayed. */ #ifdef DEBUG +#ifdef ANDROID +#define ntfs_log_debug(FORMAT, ARGS...) SLOGD(FORMAT,##ARGS) +#define ntfs_log_trace(FORMAT, ARGS...) SLOGV(FORMAT,##ARGS) +#define ntfs_log_enter(FORMAT, ARGS...) SLOGV(FORMAT,##ARGS) +#define ntfs_log_leave(FORMAT, ARGS...) SLOGV(FORMAT,##ARGS) +#else #define ntfs_log_debug(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_DEBUG,NULL,FORMAT,##ARGS) #define ntfs_log_trace(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_TRACE,NULL,FORMAT,##ARGS) #define ntfs_log_enter(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_ENTER,NULL,FORMAT,##ARGS) #define ntfs_log_leave(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_LEAVE,NULL,FORMAT,##ARGS) +#endif #else #define ntfs_log_debug(FORMAT, ARGS...)do {} while (0) #define ntfs_log_trace(FORMAT, ARGS...)do {} while (0) diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index f8da9ce..506b540 100755 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -145,6 +145,10 @@ #define basename(name) name #endif +#ifdef ANDROID +#define LOG_TAG "mkntfs" +#endif + typedef enum { WRITE_STANDARD, WRITE_BITMAP, WRITE_LOGFILE } WRITE_TYPE; #ifdef NO_NTFS_DEVICE_DEFAULT_IO_OPS diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index eaf474c..2518eed 100755 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -86,6 +86,10 @@ You need to run ./configure without the --disable-default-device-io-ops \ switch if you want to be able to build the NTFS utilities." #endif +#ifdef ANDROID +#define LOG_TAG "Ntfsfix" +#endif + static const char *EXEC_NAME = "ntfsfix"; static const char OK[] = "OK\n"; static const char FAILED[] = "FAILED\n"; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index efd9891..31f3a48 100755 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -126,6 +126,10 @@ #define set_archive(ni) (ni)->flags |= FILE_ATTR_ARCHIVE +#ifdef ANDROID +#define LOG_TAG "Ntfs-3g" +#endif + typedef enum { FSTYPE_NONE, FSTYPE_UNKNOWN, -- cgit