diff --git a/src/fs_base_utime.hpp b/src/fs_base_utime.hpp index ae1b1afe..b57ae9f1 100644 --- a/src/fs_base_utime.hpp +++ b/src/fs_base_utime.hpp @@ -35,8 +35,13 @@ namespace fs { struct timespec times[2]; +#if __APPLE__ + times[0] = st.st_atimespec; + times[1] = st.st_mtimespec; +#else times[0] = st.st_atim; times[1] = st.st_mtim; +#endif return fs::utime(AT_FDCWD,path,times,0); } @@ -49,8 +54,13 @@ namespace fs { struct timespec times[2]; +#if __APPLE__ + times[0] = st.st_atimespec; + times[1] = st.st_mtimespec; +#else times[0] = st.st_atim; times[1] = st.st_mtim; +#endif return fs::utime(fd,times); } diff --git a/src/fs_base_utime_generic.hpp b/src/fs_base_utime_generic.hpp index eeea26ad..13e2d8bd 100644 --- a/src/fs_base_utime_generic.hpp +++ b/src/fs_base_utime_generic.hpp @@ -25,6 +25,10 @@ #include #include +#if __APPLE__ +#import /* MAXPATHLEN */ +#endif + #ifndef UTIME_NOW # define UTIME_NOW ((1l << 30) - 1l) #endif @@ -123,6 +127,7 @@ _set_utime_omit_to_current_value(const int dirfd, { int rv; struct stat st; + timespec *atime, *mtime; if(!_any_timespec_is_utime_omit(ts)) return 0; @@ -131,10 +136,18 @@ _set_utime_omit_to_current_value(const int dirfd, if(rv == -1) return -1; +#if __APPLE__ + atime = &st.st_atimespec; + mtime = &st.st_mtimespec; +#else + atime = &st.st_atim; + mtime = &st.st_mtim; +#endif + if(ts[0].tv_nsec == UTIME_OMIT) - TIMESPEC_TO_TIMEVAL(&tv[0],&st.st_atim); + TIMESPEC_TO_TIMEVAL(&tv[0],atime); if(ts[1].tv_nsec == UTIME_OMIT) - TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim); + TIMESPEC_TO_TIMEVAL(&tv[1],mtime); return 0; } @@ -148,6 +161,7 @@ _set_utime_omit_to_current_value(const int fd, { int rv; struct stat st; + timespec *atime, *mtime; if(!_any_timespec_is_utime_omit(ts)) return 0; @@ -156,10 +170,18 @@ _set_utime_omit_to_current_value(const int fd, if(rv == -1) return -1; +#if __APPLE__ + atime = &st.st_atimespec; + mtime = &st.st_mtimespec; +#else + atime = &st.st_atim; + mtime = &st.st_mtim; +#endif + if(ts[0].tv_nsec == UTIME_OMIT) - TIMESPEC_TO_TIMEVAL(&tv[0],&st.st_atim); + TIMESPEC_TO_TIMEVAL(&tv[0],atime); if(ts[1].tv_nsec == UTIME_OMIT) - TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim); + TIMESPEC_TO_TIMEVAL(&tv[1],mtime); return 0; } @@ -269,8 +291,22 @@ namespace fs if(rv == -1) return -1; - if((flags & AT_SYMLINK_NOFOLLOW) == 0) + if((flags & AT_SYMLINK_NOFOLLOW) == 0) { +#if __APPLE__ + + char fullpath[MAXPATHLEN]; + + if (fcntl(dirfd,F_GETPATH,fullpath) < 0) + return (errno=errno,-1); + + if (strlcat(fullpath, "/", MAXPATHLEN) > MAXPATHLEN || strlcat(fullpath, path.c_str(), MAXPATHLEN) > MAXPATHLEN) + return (errno=ENAMETOOLONG,-1); + + return ::utimes(fullpath,tvp); +#else return ::futimesat(dirfd,path.c_str(),tvp); +#endif + } if(_can_call_lutimes(dirfd,path,flags)) return ::lutimes(path.c_str(),tvp); diff --git a/src/fs_fallocate_osx.icpp b/src/fs_fallocate_osx.icpp index 70894142..6d57f471 100644 --- a/src/fs_fallocate_osx.icpp +++ b/src/fs_fallocate_osx.icpp @@ -18,6 +18,7 @@ #include "errno.hpp" #include "fs_fallocate.hpp" +#include "fs_base_ftruncate.hpp" namespace fs { @@ -52,6 +53,6 @@ namespace fs if(mode) return (errno=EOPNOTSUPP,-1); - return ::_fallocate_core(fd,offset,len); + return _fallocate_core(fd,offset,len); } } diff --git a/src/fs_inode.hpp b/src/fs_inode.hpp index b217305f..7e07a7e0 100644 --- a/src/fs_inode.hpp +++ b/src/fs_inode.hpp @@ -34,7 +34,8 @@ namespace fs void recompute(struct stat &st) { - st.st_ino |= (st.st_dev << 32); + uint64_t st_dev = st.st_dev; /* Mac OS has a 32-bit device ID */ + st.st_ino |= (st_dev << 32); } } } diff --git a/src/gidcache.cpp b/src/gidcache.cpp index 3bace59a..0d5afbfb 100644 --- a/src/gidcache.cpp +++ b/src/gidcache.cpp @@ -109,7 +109,15 @@ gid_t_cache::cache(const uid_t uid, rec->size = 0; ::getgrouplist(pwd.pw_name,gid,NULL,&rec->size); rec->size = std::min(MAXGIDS,rec->size); + + #if __APPLE__ + // OSX: getgrouplist(const char *name, int basegid, int *groups, int *ngroups) + rv = ::getgrouplist(pwd.pw_name,gid,(int*)rec->gids,&rec->size); +#else + // Linux: getgrouplist(const char *name, gid_t group, gid_t *groups int *ngroups) rv = ::getgrouplist(pwd.pw_name,gid,rec->gids,&rec->size); +#endif + if(rv == -1) { rec->gids[0] = gid; diff --git a/tools/cppfind b/tools/cppfind index bac073eb..fa9dbad4 100755 --- a/tools/cppfind +++ b/tools/cppfind @@ -2,6 +2,6 @@ FUSE_CFLAGS="$(pkg-config --cflags fuse) -DFUSE_USE_VERSION=29" -echo "#include " | cpp ${FUSE_CFLAGS} | grep "${1}" > /dev/null +echo "#include " | cc -E ${FUSE_CFLAGS} - | grep "${1}" > /dev/null [ "$?" != "0" ]; echo $?