-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac updates #384
base: master
Are you sure you want to change the base?
Mac updates #384
Changes from 8 commits
d9ae6df
1aea1d4
39b7772
d1aec14
6cfd4d5
59ece5f
3b0d371
bca8404
b0fb518
a00dc9b
6a67a92
3b2fa95
25fe57f
d0fa9ef
cf567f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
ISC License | ||
|
||
Copyright (c) 2017, Antonio SJ Musumeci <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#if __APPLE__ | ||
# include "fs_base_futimesat_osx.icpp" | ||
#else | ||
# include "fs_base_futimesat_generic.icpp" | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
ISC License | ||
|
||
Copyright (c) 2017, Antonio SJ Musumeci <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef __FS_BASE_FUTIMESAT_HPP__ | ||
#define __FS_BASE_FUTIMESAT_HPP__ | ||
|
||
namespace fs | ||
{ | ||
int | ||
futimesat(const int dirfd, | ||
const char *pathname, | ||
const struct timeval times[2]); | ||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
ISC License | ||
|
||
Copyright (c) 2017, Antonio SJ Musumeci <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <fcntl.h> | ||
#include <sys/time.h> | ||
|
||
namespace fs | ||
{ | ||
int | ||
futimesat(const int dirfd, | ||
const char *pathname, | ||
const struct timeval times[2]) | ||
{ | ||
return ::futimesat(dirfd,pathname,times); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
ISC License | ||
|
||
Copyright (c) 2017, Antonio SJ Musumeci <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <err.h> | ||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/errno.h> | ||
#include <sys/param.h> | ||
#include <sys/stat.h> | ||
#include <sys/time.h> | ||
#include <unistd.h> | ||
|
||
static | ||
int | ||
getpath(const int dirfd, | ||
const char *path, | ||
char *fullpath) | ||
{ | ||
int rv; | ||
struct stat st; | ||
|
||
rv = ::fstat(dirfd,&st); | ||
if(rv == -1) | ||
return -1; | ||
|
||
if(!S_ISDIR(st.st_mode)) | ||
return (errno=ENOTDIR,-1); | ||
|
||
rv = ::fcntl(dirfd,F_GETPATH,fullpath); | ||
if(rv == -1) | ||
return -1; | ||
|
||
rv = ::strlcat(fullpath,"/",MAXPATHLEN); | ||
if(rv > MAXPATHLEN) | ||
return (errno=ENAMETOOLONG,-1); | ||
|
||
rv = ::strlcat(fullpath,path,MAXPATHLEN); | ||
if(rv > MAXPATHLEN) | ||
return (errno=ENAMETOOLONG,-1); | ||
|
||
return 0; | ||
} | ||
|
||
namespace fs | ||
{ | ||
int | ||
futimesat(const int dirfd, | ||
const char *path, | ||
const struct timeval times[2]) | ||
{ | ||
int rv; | ||
char fullpath[MAXPATHLEN]; | ||
|
||
if((dirfd == AT_FDCWD) || | ||
((path != NULL) && (path[0] == '/'))) | ||
return ::utimes(path,times); | ||
|
||
if(dirfd < 0) | ||
return (errno=EBADF,-1); | ||
|
||
rv = getpath(dirfd,path,fullpath); | ||
if(rv == -1) | ||
return -1; | ||
|
||
return ::utimes(fullpath,times); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,13 +33,16 @@ namespace fs | |
const char *name, | ||
const void *value, | ||
const size_t size, | ||
const int flags) | ||
const int flags, | ||
const u_int32_t position) | ||
{ | ||
#ifndef WITHOUT_XATTR | ||
return ::lsetxattr(path.c_str(),name,value,size,flags); | ||
#else | ||
#if WITHOUT_XATTR | ||
return (errno=ENOTSUP,-1); | ||
#endif | ||
#elif __APPLE__ | ||
return ::setxattr(path.c_str(),name,value,size,position,flags & XATTR_NOFOLLOW); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't There's a few other similar places where bitwise AND is used where it probably should be a OR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. Should be ORed. |
||
#else | ||
return ::lsetxattr(path.c_str(),name,value,size,flags); | ||
#endif | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm watching Travis. If I commit something which breaks I'll fix it.