Browse Source

Get macOS working again.

pull/384/head
Adam Knight 9 years ago
parent
commit
d9ae6df01c
  1. 10
      src/fs_base_utime.hpp
  2. 46
      src/fs_base_utime_generic.hpp
  3. 3
      src/fs_fallocate_osx.icpp
  4. 3
      src/fs_inode.hpp
  5. 8
      src/gidcache.cpp
  6. 2
      tools/cppfind

10
src/fs_base_utime.hpp

@ -35,8 +35,13 @@ namespace fs
{ {
struct timespec times[2]; struct timespec times[2];
#if __APPLE__
times[0] = st.st_atimespec;
times[1] = st.st_mtimespec;
#else
times[0] = st.st_atim; times[0] = st.st_atim;
times[1] = st.st_mtim; times[1] = st.st_mtim;
#endif
return fs::utime(AT_FDCWD,path,times,0); return fs::utime(AT_FDCWD,path,times,0);
} }
@ -49,8 +54,13 @@ namespace fs
{ {
struct timespec times[2]; struct timespec times[2];
#if __APPLE__
times[0] = st.st_atimespec;
times[1] = st.st_mtimespec;
#else
times[0] = st.st_atim; times[0] = st.st_atim;
times[1] = st.st_mtim; times[1] = st.st_mtim;
#endif
return fs::utime(fd,times); return fs::utime(fd,times);
} }

46
src/fs_base_utime_generic.hpp

@ -25,6 +25,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#if __APPLE__
#import <sys/param.h> /* MAXPATHLEN */
#endif
#ifndef UTIME_NOW #ifndef UTIME_NOW
# define UTIME_NOW ((1l << 30) - 1l) # define UTIME_NOW ((1l << 30) - 1l)
#endif #endif
@ -123,6 +127,7 @@ _set_utime_omit_to_current_value(const int dirfd,
{ {
int rv; int rv;
struct stat st; struct stat st;
timespec *atime, *mtime;
if(!_any_timespec_is_utime_omit(ts)) if(!_any_timespec_is_utime_omit(ts))
return 0; return 0;
@ -131,10 +136,18 @@ _set_utime_omit_to_current_value(const int dirfd,
if(rv == -1) if(rv == -1)
return -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) 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) if(ts[1].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim);
TIMESPEC_TO_TIMEVAL(&tv[1],mtime);
return 0; return 0;
} }
@ -148,6 +161,7 @@ _set_utime_omit_to_current_value(const int fd,
{ {
int rv; int rv;
struct stat st; struct stat st;
timespec *atime, *mtime;
if(!_any_timespec_is_utime_omit(ts)) if(!_any_timespec_is_utime_omit(ts))
return 0; return 0;
@ -156,10 +170,18 @@ _set_utime_omit_to_current_value(const int fd,
if(rv == -1) if(rv == -1)
return -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) 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) if(ts[1].tv_nsec == UTIME_OMIT)
TIMESPEC_TO_TIMEVAL(&tv[1],&st.st_mtim);
TIMESPEC_TO_TIMEVAL(&tv[1],mtime);
return 0; return 0;
} }
@ -269,8 +291,22 @@ namespace fs
if(rv == -1) if(rv == -1)
return -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); return ::futimesat(dirfd,path.c_str(),tvp);
#endif
}
if(_can_call_lutimes(dirfd,path,flags)) if(_can_call_lutimes(dirfd,path,flags))
return ::lutimes(path.c_str(),tvp); return ::lutimes(path.c_str(),tvp);

3
src/fs_fallocate_osx.icpp

@ -18,6 +18,7 @@
#include "errno.hpp" #include "errno.hpp"
#include "fs_fallocate.hpp" #include "fs_fallocate.hpp"
#include "fs_base_ftruncate.hpp"
namespace fs namespace fs
{ {
@ -52,6 +53,6 @@ namespace fs
if(mode) if(mode)
return (errno=EOPNOTSUPP,-1); return (errno=EOPNOTSUPP,-1);
return ::_fallocate_core(fd,offset,len);
return _fallocate_core(fd,offset,len);
} }
} }

3
src/fs_inode.hpp

@ -34,7 +34,8 @@ namespace fs
void void
recompute(struct stat &st) 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);
} }
} }
} }

8
src/gidcache.cpp

@ -109,7 +109,15 @@ gid_t_cache::cache(const uid_t uid,
rec->size = 0; rec->size = 0;
::getgrouplist(pwd.pw_name,gid,NULL,&rec->size); ::getgrouplist(pwd.pw_name,gid,NULL,&rec->size);
rec->size = std::min(MAXGIDS,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); rv = ::getgrouplist(pwd.pw_name,gid,rec->gids,&rec->size);
#endif
if(rv == -1) if(rv == -1)
{ {
rec->gids[0] = gid; rec->gids[0] = gid;

2
tools/cppfind

@ -2,6 +2,6 @@
FUSE_CFLAGS="$(pkg-config --cflags fuse) -DFUSE_USE_VERSION=29" FUSE_CFLAGS="$(pkg-config --cflags fuse) -DFUSE_USE_VERSION=29"
echo "#include <fuse.h>" | cpp ${FUSE_CFLAGS} | grep "${1}" > /dev/null
echo "#include <fuse.h>" | cc -E ${FUSE_CFLAGS} - | grep "${1}" > /dev/null
[ "$?" != "0" ]; echo $? [ "$?" != "0" ]; echo $?
Loading…
Cancel
Save