-
Notifications
You must be signed in to change notification settings - Fork 654
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
Conversation
Ok this does not work as is obviously because |
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 |
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.
This type cast is unnecessary as flags.bits()
already returns libc::c_int
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.
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! { |
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.
This type itself should be #[cfg(not(target_os = "redox"))]
as the file system on redox does not support symlink
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.
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?
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.
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"))] |
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.
#[cfg(any(target_os = "android", target_os = "linux"))] | |
#[cfg(linux_android)] |
pr for #1884