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

can't pass st_file_attributes back #11

Closed
robert-boulanger opened this issue Jan 30, 2019 · 4 comments
Closed

can't pass st_file_attributes back #11

robert-boulanger opened this issue Jan 30, 2019 · 4 comments

Comments

@robert-boulanger
Copy link

As seen in winfsp/winfsp#114 it seems support for windows file attributes should be present.
The question is how to implement them in a proper way in fuse.py,or what changes are needed to make there.
Unfortunatly setting st_mode to S_IFREG | 0o555 for example is not enough. This would cause the file is readonly but lot of software seems to rely on the windows attributes to work proper.
Any hint how to modify fuse.py would be great.

@billziss-gh
Copy link
Owner

@robert-boulanger I have not thought this through, but it is likely that you can get it done by modifying c_stat to add st_flags and passing the FSP_FUSE_CAP_STAT_EX (1 << 23) in self.conn_want.

If you make this work please consider sharing.

@robert-boulanger
Copy link
Author

@billziss-gh That worked fine, so changing self.conn_want to

((1 << 21) if kwargs.pop("readdir_plus", False) else 0) | \
((1 << 23) if kwargs.pop("win_file_attributes", False) else 0)

and adding
('st_flags',c_uint32)
to the c_stat structure did the trick.

But for anyone reading this, it is worth to mention that using the FILE_ATTRIBUTES declared in pythons stat module and returned by os.lstat(some_file).st_file_attributes will not work. You have to use

FSP_FUSE_UF_HIDDEN = 0x00008000
FSP_FUSE_UF_READONLY = 0x00001000
FSP_FUSE_UF_SYSTEM = 0x00000080
FSP_FUSE_UF_ARCHIVE = 0x00000800

as found in inc/fuse/fuse_common.h

Took some time to find this out ;)

@billziss-gh
Copy link
Owner

@robert-boulanger yes, I forgot to mention the FSP_FUSE_UF_* constants. They are necessary for compatibility with FUSE for macOS, which already had chflags and friends.

@billziss-gh
Copy link
Owner

BTW, if this works well you can also submit it as a PR.

YoilyL pushed a commit to YoilyL/refuse that referenced this issue Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants