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

Type discrepancy for permissions #14

Open
sector-f opened this issue Jun 10, 2017 · 3 comments
Open

Type discrepancy for permissions #14

sector-f opened this issue Jun 10, 2017 · 3 comments

Comments

@sector-f
Copy link
Contributor

The chmod function passes the mode as a u32, but the perm field of FileAttr is a u16

@wfraser
Copy link
Owner

wfraser commented Jun 26, 2017

This is because FUSE passes the mode as a u32, which is because the mode_t in chmod(2) is actually a 32-bit integer on some platforms (Linux at least). Not all the bits have a well-defined meaning, which is why FileAttr only takes a u16, but I guess nothing stops you from doing chmod(path, 0x10000); on Linux.

@wfraser
Copy link
Owner

wfraser commented Jun 26, 2017

So I did some experiments, and found something interesting. On Linux, while you can pass any 32-bit value to chmod(), at some level it gets a mask applied and the maximum value fuse_mt sees is 0x8FFF. I'm not sure if this is the kernel or FUSE doing this.

So it might make sense to change the type after all.

@wfraser
Copy link
Owner

wfraser commented Jun 26, 2017

Looks like macOS does the same thing; even though it defines mode_t as unsigned short (16 bits), everything is masked to 0x8FFF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants