From 9b3c87ec97474806c29a61337a3d4b83f0742c26 Mon Sep 17 00:00:00 2001 From: Nate Rosenblum Date: Thu, 25 Jun 2015 12:55:47 -0700 Subject: [PATCH] Specialize {set,get}xattr for OS X These system calls take an extra 'position' parameter on OS X. A non-zero position value is only valid for resource forks (the Darwin VFS layer will reject anything else with EINVAL); this patch simply adds and ignores the parameter on Apple platforms. Allows building against OSXFUSE. --- src/s3fs.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 5d5f8a2..ec02da4 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -201,8 +201,13 @@ static int s3fs_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off static int s3fs_access(const char* path, int mask); static void* s3fs_init(struct fuse_conn_info* conn); static void s3fs_destroy(void*); +#if defined(__APPLE__) +static int s3fs_setxattr(const char* path, const char* name, const char* value, size_t size, int flags, uint32_t position); +static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size, uint32_t position); +#else static int s3fs_setxattr(const char* path, const char* name, const char* value, size_t size, int flags); static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size); +#endif static int s3fs_listxattr(const char* path, char* list, size_t size); static int s3fs_removexattr(const char* path, const char* name); @@ -2884,7 +2889,11 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v return 0; } +#if defined(__APPLE__) +static int s3fs_setxattr(const char* path, const char* name, const char* value, size_t size, int flags, uint32_t position) +#else static int s3fs_setxattr(const char* path, const char* name, const char* value, size_t size, int flags) +#endif { FPRN("[path=%s][name=%s][value=%p][size=%zu][flags=%d]", path, name, value, size, flags); @@ -2893,6 +2902,13 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value, return 0; } +#if defined(__APPLE__) + if (position != 0) { + // No resource fork support + return -EINVAL; + } +#endif + int result; string strpath; string newpath; @@ -2963,7 +2979,11 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value, return 0; } +#if defined(__APPLE__) +static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size, uint32_t position) +#else static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size) +#endif { FPRN("[path=%s][name=%s][value=%p][size=%zu]", path, name, value, size); @@ -2971,6 +2991,13 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t return -EIO; } +#if (__APPLE__) + if (position != 0) { + // No resource fork support + return -EINVAL; + } +#endif + int result; headers_t meta; xattrs_t xattrs;