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

extend LinkatFlags to allow passing AT_EMPTY_PATH #1895

Closed
wants to merge 2 commits into from

Conversation

xaverdh
Copy link

@xaverdh xaverdh commented Nov 30, 2022

pr for #1884

@xaverdh
Copy link
Author

xaverdh commented Nov 30, 2022

Ok this does not work as is obviously because SymlinkFollow is not a member of LinkatFlags anymore.. is there a way to have them both in the same namespace?

src/unistd.rs Outdated
@@ -1272,7 +1273,7 @@ pub fn linkat<P: ?Sized + NixPath>(
oldcstr.as_ptr(),
at_rawfd(newdirfd),
newcstr.as_ptr(),
atflag.bits() as libc::c_int
flags.bits() as libc::c_int
Copy link
Member

Choose a reason for hiding this comment

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

This type cast is unnecessary as flags.bits() already returns libc::c_int

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, I have left some comments.

BTW, this change needs a CHANGELOG, please see CONTRIBUTING.md on how to do it.

pub enum LinkatFlags {
SymlinkFollow,
NoSymlinkFollow,
libc_bitflags! {
Copy link
Member

Choose a reason for hiding this comment

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

This type itself should be #[cfg(not(target_os = "redox"))] as the file system on redox does not support symlink

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I am not sure if we should define a new type or just use the AtFlags type.

It is safer to define a new type so that we can prevent users from passing invalid arguments, but this will add our maintainence burgen. We are already using AtFlags type for other functions like fstatat, cc @asomers, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Link Add EmptyPath for FchownatFlags as these 2 PRs are similar

pub struct LinkatFlags: c_int {
#[cfg(not(target_os = "redox"))]
AT_SYMLINK_FOLLOW;
#[cfg(any(target_os = "android", target_os = "linux"))]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(linux_android)]

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.

None yet

2 participants