Skip to content
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

WIP Feature/macos compatibility #11

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cshatag.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
#define SHA256_BYTES 32
#define SHA256_NIBBLES 64

#ifdef __APPLE__
#define st_mtim st_mtimespec
#define fgetxattr(fd, name, buf, size) fgetxattr(fd, name, buf, size, 0, 0)
/*
* SMB or MacOS bug: when working on an SMB mounted filesystem on a Mac, it seems the call
* to `fsetxattr` does not update the xattr but removes it instead. So it takes two runs
* of `cshatag` to update the attribute.
* To work around this issue, we remove the xattr explicitely before setting it again.
*/
#define fsetxattr(fd, name, buf, size, flags) fremovexattr(fd, name, 0)|fsetxattr(fd, name, buf, size, 0, flags)
#undef ENODATA
#define ENODATA ENOATTR
#endif

/**
* Holds a file's metadata
*/
Expand Down