-
Notifications
You must be signed in to change notification settings - Fork 23
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
Conversation
Use precompiler macros to transparently patch in MacOS support. The differences are: - the `sys/stat` modification time struct - the `fgetxattr` and `fsetxattr` function signatures - the "attribute not found" error
When an outdated tag is found on an SMB 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.
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.
LGTM
Can you check where the error comes from? (from fremovexattr or from fsetxattr?) |
The previous workaround was working, but it was causing an error to be displayed when adding a new tag, since the call to `fremovexattr` would fail with `ENOATTR`. Two calls to `fsetxattr` in a row also work around the bug, this time without displaying an error.
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.
LGTM
The error comes from the Maybe we could just ignore that error, but I don't know how to do that using a preprocessor macro since the macro also needs to be a single statement that returns the return value of the Of course, I could write a small function to do it, but I don't like the idea of having to pepper I found out that two calls to |
@yemartin I'm thinking about rewriting the whole thing in Go, using the https://github.com/pkg/xattr library, which works out of the box on Linux, MacOS and FreeBSD. The goal is to support passing multiple files per invocation, which should speed up processing of lots of small files considerably, and also to have command-line flags. I was thinking about you ticket #9 about not updating the tag when corruption is found. I think both behavoirs can make sense, so I would add a |
I wondered if you could test a Go rewrite on MacOS? |
@rfjakob Great idea, always better to use existing packages rather than reinventing the wheel. And of course I would be more than happy to test a Go rewrite. Do you have a repo for it already? |
I do. You can
to get the new version. |
Building@rfjakob Maybe this is basic stuff, but I am new to Go and the package did not build out of the box, with a
Anyway, RunningOn my local Mac filesystem, everything seems to be working fine:
About the MacOS + SMB bugUsing my oneliner test from #8 (comment) the output on my local filesystem is:
Unfortunately, the bug is still present when connecting to my SMB_3.02 NAS share:
So with MacOS + SMB, trying to update a tag still results in clearing it instead. To research this further, I changed the min/max version of SMB on my NAS for force a given protocol, and here are my results:
So, the root cause of this bug is probably totally outside of cshatag, but it is still something that we may have to work around. |
One more test: Performance5 runs of
So pretty much the same. Interesting how Go uses 100% CPU vs. 97% for C, but is also (maybe as a result) a tiny bit faster. |
I just pushed a commit that adds the "remove xattr before setting" workaround. Can you |
Sorry about the delay @rfjakob: I have had some issues with my NAS and could not do any testing last week. Things should be back in order now, I will give it a try tonight. |
Two good news:
On the Mac, inside an SMB-shared folder:
The output of my little one-liner (see #8 (comment)) is:
UPDATED: Fixed the oneliner output |
I just realized I must have pasted the wrong output. The end result regarding the workaround is the same |
I understand that this is fixed, closing in favor of #12 |
Do not merge yet:
The current workaround for the MacOS + SMB bug works, but it causes an error to be displayed:
My C is really rusty... Can you suggest a better way to implement it?