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

mkdirall: switch to os.FileMode argument #44

Merged
merged 2 commits into from
Jan 13, 2025
Merged

Conversation

cyphar
Copy link
Owner

@cyphar cyphar commented Jan 12, 2025

This is mostly a cosmetic change for most users, but libpathrs uses
os.FileMode as well and most Go users are more used to using
os.FileMode. The only thing that users need to watch out for is that
they need to switch from unix.S_ISVTX to os.ModeSticky if they are using
that bit (since os.FileMode and unix.S_* bits have a different layout).

This will also help with building on 32-bit architectures without
switching the argument type to uint32 explicitly.

Closes #34
Signed-off-by: Aleksa Sarai [email protected]

This is mostly a cosmetic change for most users, but libpathrs uses
os.FileMode as well and most Go users are more used to using
os.FileMode. The only thing that users need to watch out for is that
they need to switch from unix.S_ISVTX to os.ModeSticky if they are using
that bit (since os.FileMode and unix.S_* bits have a different layout).

This will also help with building on 32-bit architectures without
switching the argument type to uint32 explicitly.

Signed-off-by: Aleksa Sarai <[email protected]>
@cyphar cyphar force-pushed the mkdirall-os-filemode branch from 208d7f3 to 0c2fbe6 Compare January 12, 2025 01:26
@cyphar
Copy link
Owner Author

cyphar commented Jan 12, 2025

@kolyshkin WDYT? For runc all of the uses just directly pass 0o... calls so we shouldn't need to change anything...

@cyphar cyphar force-pushed the mkdirall-os-filemode branch from 17854d7 to 428c39e Compare January 12, 2025 03:24
@cyphar cyphar force-pushed the mkdirall-os-filemode branch from 428c39e to ea4e5b6 Compare January 12, 2025 03:25
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me either way is fine, as long as it is documented, but I guess most users

  • do not know that some of the os.Mode* bit values differ from their low-level unix.S_* counterparts;
  • do expect high-level os.Mode* values to be passed to Mkdir* functions.

So I think this change is indeed an improvement, LGTM.

@cyphar cyphar merged commit e410d4a into main Jan 13, 2025
40 checks passed
@cyphar
Copy link
Owner Author

cyphar commented Jan 13, 2025

Thanks for the review, I agree!

@cyphar cyphar deleted the mkdirall-os-filemode branch January 13, 2025 03:59
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

Successfully merging this pull request may close these issues.

2 participants