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

feat: AT_EMPTY_PATH for fchownat on Linux/Android/FreeBSD/Hurd #2267

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

SteveLauC
Copy link
Member

@SteveLauC SteveLauC commented Dec 16, 2023

What does this PR do

Picks up #1128

Closes #1128 Closes #1029

Enable the AT_EMPTY_PATH flag for fchownat() on Linux/Android/FreeBSD/Hurd

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

src/unistd.rs Outdated
NoFollowSymlink,
libc_bitflags! {
/// Flags for the `fchownat` function.
pub struct FchownatFlags: c_int {
Copy link
Member Author

Choose a reason for hiding this comment

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

For this type, 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 the AtFlags type for other functions like fstatat

Copy link
Member

Choose a reason for hiding this comment

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

If we're already using AtFlags for more than one function, I think we can use it here, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Get it

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

This is a rare case of an API change in Nix where we can help users migrate. What about defining some deprecated constants like this?

impl FchownatFlags {
     #[deprecated]
    pub const FollowSymlink = FchownatFlags::empty();
    #[deprecated]
    pub const NoFollowSymlink = FchownatFlags::AT_SYMLINK_NOFOLLOW;
}

src/unistd.rs Outdated
NoFollowSymlink,
libc_bitflags! {
/// Flags for the `fchownat` function.
pub struct FchownatFlags: 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.

If we're already using AtFlags for more than one function, I think we can use it here, too.

src/unistd.rs Outdated
///
/// If `dirfd` is `None`, the call operates on the current working
/// directory.
#[cfg(linux_android)]
Copy link
Member

Choose a reason for hiding this comment

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

It's also available on FreeBSD, beginning in 13.1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me do this in a separate PR

@SteveLauC
Copy link
Member Author

This is a rare case of an API change in Nix where we can help users migrate. What about defining some deprecated constants like this?

impl FchownatFlags {
     #[deprecated]
    pub const FollowSymlink = FchownatFlags::empty();
    #[deprecated]
    pub const NoFollowSymlink = FchownatFlags::AT_SYMLINK_NOFOLLOW;
}

Done


Well, fixing imports is so painful, I really hope Nix never do

use xxx

but directly use the items when needed.

@SteveLauC SteveLauC changed the title feat: AT_EMPTY_PATH for fchownat on Linux/Android feat: AT_EMPTY_PATH for fchownat on Linux/Android/FreeBSD/Hurd Jan 7, 2024
@SteveLauC SteveLauC added this pull request to the merge queue Jan 7, 2024
Merged via the queue into nix-rust:master with commit 833828e Jan 7, 2024
35 checks passed
@SteveLauC SteveLauC deleted the empty_path_fchownat branch January 7, 2024 04:01
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.

Missing Flag For nix::unistd::fchownat
2 participants