summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadek Podgorny <radek@podgorny.cz>2014-02-22 16:59:09 +0100
committerRadek Podgorny <radek@podgorny.cz>2014-02-22 16:59:09 +0100
commitc0bb0b06ef49225efc656e62065f8eff7938f3ff (patch)
tree90603669eac78c8cfcf72b9ad62bb9d5693f402b
parentdfe6f53fc507aabb409c0fcb69b79fd6f777f6b6 (diff)
downloadunionfs-fuse-c0bb0b06ef49225efc656e62065f8eff7938f3ff.tar.gz
add likai liu's patch for apple support
-rw-r--r--CREDITS1
-rw-r--r--src/unionfs.c45
-rw-r--r--src/usyslog.c8
3 files changed, 50 insertions, 4 deletions
diff --git a/CREDITS b/CREDITS
index a79cec7..9e9e0f9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -20,6 +20,7 @@ Julian Andres Klode <jak@debian.org>
Mike Kazantsev <mk.fraggod@gmail.com>
B Howe <bhowe@wetafx.co.nz>
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Likai Liu <liulk@likai.org>
Hashtable routines taken from:
Christopher Clark <christopher.clark@cl.cam.ac.uk>
diff --git a/src/unionfs.c b/src/unionfs.c
index 90cbccd..a487d8c 100644
--- a/src/unionfs.c
+++ b/src/unionfs.c
@@ -19,7 +19,13 @@
#endif
#include <fuse.h>
-#include <fuse/fuse_common.h>
+
+#if __APPLE__
+ #include <fuse_common.h>
+#else
+ #include <fuse/fuse_common.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -32,6 +38,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <inttypes.h>
+
#ifdef linux
#include <sys/vfs.h>
#else
@@ -76,7 +83,6 @@ static struct fuse_opt unionfs_opts[] = {
FUSE_OPT_END
};
-
static int unionfs_chmod(const char *path, mode_t mode) {
DBG("%s\n", path);
@@ -193,7 +199,7 @@ static int unionfs_getattr(const char *path, struct stat *stbuf) {
DBG("%s\n", path);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) {
- memset(stbuf, 0, sizeof(stbuf));
+ memset(stbuf, 0, sizeof(*stbuf));
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
stbuf->st_size = STATS_SIZE;
@@ -666,7 +672,15 @@ static int unionfs_utimens(const char *path, const struct timespec ts[2]) {
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[i].path, path)) RETURN(-ENAMETOOLONG);
+#if __APPLE__
+ struct timeval tv[2] = {
+ {ts[0].tv_sec, ts[0].tv_nsec / 1000},
+ {ts[1].tv_sec, ts[1].tv_nsec / 1000},
+ };
+ int res = utimes(p, tv);
+#else
int res = utimensat(0, p, ts, AT_SYMLINK_NOFOLLOW);
+#endif
if (res == -1) RETURN(-errno);
@@ -687,7 +701,12 @@ static int unionfs_write(const char *path, const char *buf, size_t size, off_t o
}
#ifdef HAVE_XATTR
+
+#if __APPLE__
+static int unionfs_getxattr(const char *path, const char *name, char *value, size_t size, uint32_t position) {
+#else
static int unionfs_getxattr(const char *path, const char *name, char *value, size_t size) {
+#endif
DBG("%s\n", path);
int i = find_rorw_branch(path);
@@ -696,7 +715,11 @@ static int unionfs_getxattr(const char *path, const char *name, char *value, siz
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[i].path, path)) RETURN(-ENAMETOOLONG);
+#if __APPLE__
+ int res = getxattr(p, name, value, size, position, XATTR_NOFOLLOW);
+#else
int res = lgetxattr(p, name, value, size);
+#endif
if (res == -1) RETURN(-errno);
@@ -712,7 +735,11 @@ static int unionfs_listxattr(const char *path, char *list, size_t size) {
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[i].path, path)) RETURN(-ENAMETOOLONG);
+#if __APPLE__
+ int res = listxattr(p, list, size, XATTR_NOFOLLOW);
+#else
int res = llistxattr(p, list, size);
+#endif
if (res == -1) RETURN(-errno);
@@ -728,14 +755,22 @@ static int unionfs_removexattr(const char *path, const char *name) {
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[i].path, path)) RETURN(-ENAMETOOLONG);
+#if __APPLE__
+ int res = removexattr(p, name, XATTR_NOFOLLOW);
+#else
int res = lremovexattr(p, name);
+#endif
if (res == -1) RETURN(-errno);
RETURN(res);
}
+#if __APPLE__
+static int unionfs_setxattr(const char *path, const char *name, const char *value, size_t size, int flags, uint32_t position) {
+#else
static int unionfs_setxattr(const char *path, const char *name, const char *value, size_t size, int flags) {
+#endif
DBG("%s\n", path);
int i = find_rw_branch_cow(path);
@@ -744,7 +779,11 @@ static int unionfs_setxattr(const char *path, const char *name, const char *valu
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[i].path, path)) RETURN(-ENAMETOOLONG);
+#if __APPLE__
+ int res = setxattr(p, name, value, size, position, flags | XATTR_NOFOLLOW);
+#else
int res = lsetxattr(p, name, value, size, flags);
+#endif
if (res == -1) RETURN(-errno);
diff --git a/src/usyslog.c b/src/usyslog.c
index 75becac..611e74d 100644
--- a/src/usyslog.c
+++ b/src/usyslog.c
@@ -20,7 +20,13 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-#include <malloc.h>
+
+#if __APPLE__
+ #include <malloc/malloc.h>
+#else
+ #include <malloc.h>
+#endif
+
#include <pthread.h>
#include <stdarg.h>