From ad25d7a0ac4bf748b849ba7eec7b85fd37e6fe07 Mon Sep 17 00:00:00 2001 From: jpandre Date: Wed, 18 Nov 2009 16:37:15 +0000 Subject: [PATCH] Applied patches for Mac OS X (Erik Larsson) --- libntfs-3g/security.c | 3 +++ src/ntfs-3g.c | 31 ++++++++++++++----------------- src/secaudit.c | 27 ++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index aed9ff1b..8c4e69be 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -44,6 +44,9 @@ #ifdef HAVE_SETXATTR #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #include #include diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 2ec127aa..4a55135f 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -409,12 +409,6 @@ static void set_fuse_error(int *err) } #if defined(__APPLE__) || defined(__DARWIN__) -static void *ntfs_macfuse_init(struct fuse_conn_info *conn) -{ - FUSE_ENABLE_XTIMES(conn); - return NULL; -} - static int ntfs_macfuse_getxtimes(const char *org_path, struct timespec *bkuptime, struct timespec *crtime) { @@ -495,29 +489,34 @@ int ntfs_macfuse_setchgtime(const char *path, const struct timespec *tv) if (ntfs_fuse_is_named_data_stream(path)) return -EINVAL; /* n/a for named data streams. */ - ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); + ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); if (!ni) return -errno; if (tv) { - ni->last_mft_change_time = tv->tv_sec; + ni->last_mft_change_time = tv->tv_sec; ntfs_fuse_update_times(ni, 0); } if (ntfs_inode_close(ni)) - set_fuse_error(&res); + set_fuse_error(&res); return res; } -#else /* defined(__APPLE__) || defined(__DARWIN__) */ -#ifdef FUSE_CAP_DONT_MASK +#endif /* defined(__APPLE__) || defined(__DARWIN__) */ + +#if defined(FUSE_CAP_DONT_MASK) || (defined(__APPLE__) || defined(__DARWIN__)) static void *ntfs_init(struct fuse_conn_info *conn) { +#if defined(__APPLE__) || defined(__DARWIN__) + FUSE_ENABLE_XTIMES(conn); +#endif +#ifdef FUSE_CAP_DONT_MASK /* request umask not to be enforced by fuse */ conn->want |= FUSE_CAP_DONT_MASK; +#endif /* defined FUSE_CAP_DONT_MASK */ return NULL; } -#endif -#endif /* defined(__APPLE__) || defined(__DARWIN__) */ +#endif /* defined(FUSE_CAP_DONT_MASK) || (defined(__APPLE__) || defined(__DARWIN__)) */ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) { @@ -3182,17 +3181,15 @@ static struct fuse_operations ntfs_3g_ops = { .listxattr = ntfs_fuse_listxattr, #endif /* HAVE_SETXATTR */ #if defined(__APPLE__) || defined(__DARWIN__) - .init = ntfs_macfuse_init, /* MacFUSE extensions. */ .getxtimes = ntfs_macfuse_getxtimes, .setcrtime = ntfs_macfuse_setcrtime, .setbkuptime = ntfs_macfuse_setbkuptime, .setchgtime = ntfs_macfuse_setchgtime, -#else /* defined(__APPLE__) || defined(__DARWIN__) */ -#ifdef FUSE_CAP_DONT_MASK +#endif /* defined(__APPLE__) || defined(__DARWIN__) */ +#if defined(FUSE_CAP_DONT_MASK) || (defined(__APPLE__) || defined(__DARWIN__)) .init = ntfs_init #endif -#endif /* defined(__APPLE__) || defined(__DARWIN__) */ }; static int ntfs_fuse_init(void) diff --git a/src/secaudit.c b/src/secaudit.c index 026b3ec7..a6f62589 100644 --- a/src/secaudit.c +++ b/src/secaudit.c @@ -149,6 +149,9 @@ * * Nov 2009, version 1.3.9 * - allowed security descriptors up to 64K + * + * Nov 2009, version 1.3.10 + * - applied patches for MacOSX from Erik Larsson */ /* @@ -172,7 +175,7 @@ * General parameters which may have to be adapted to needs */ -#define AUDT_VERSION "1.3.9" +#define AUDT_VERSION "1.3.10" #define GET_FILE_SECURITY "ntfs_get_file_security" #define SET_FILE_SECURITY "ntfs_set_file_security" @@ -234,7 +237,12 @@ */ #include +#ifdef HAVE_ENDIAN_H #include +#endif +#ifdef HAVE_MACHINE_ENDIAN_H +#include +#endif #include #include #endif /* STSC */ @@ -259,7 +267,11 @@ #endif /* HAVE_CONFIG_H */ #ifdef HAVE_SETXATTR +#if defined(__APPLE__) || defined(__DARWIN__) +#include +#else #include +#endif #else #warning "The extended attribute package is not available" #endif /* HAVE_SETXATTR */ @@ -5002,6 +5014,15 @@ BOOL singleshow(const char *path) return (err); } +static ssize_t ntfs_getxattr(const char *path, const char *name, void *value, size_t size) +{ +#if defined(__APPLE__) || defined(__DARWIN__) + return getxattr(path, name, value, size, 0, 0); +#else + return getxattr(path, name, value, size); +#endif +} + /* * Display all the parameters associated to a mounted file */ @@ -5030,14 +5051,14 @@ void showmounted(const char *fullname) printname(stdout,fullname); printf("\n"); - attrsz = getxattr(fullname,"system.ntfs_acl",attr,MAXATTRSZ); + attrsz = ntfs_getxattr(fullname,"system.ntfs_acl",attr,MAXATTRSZ); if (attrsz > 0) { if (opt_v) { hexdump(attr,attrsz,8); printf("Computed hash : 0x%08lx\n", (unsigned long)hash((le32*)attr,attrsz)); } - if (getxattr(fullname,"system.ntfs_attrib",&attrib,4) != 4) { + if (ntfs_getxattr(fullname,"system.ntfs_attrib",&attrib,4) != 4) { printf("** Could not get file attrib\n"); errors++; } else