Skip to content

Commit

Permalink
Add unlinkat and AT_REMOVEDIR
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlamb committed Jul 12, 2019
1 parent 856c842 commit c34f87c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#1084](https://github.com/nix-rust/nix/pull/1084))
- Add `posix_fadvise`.
([#1089](https://github.com/nix-rust/nix/pull/1089))
- Add `rename`, `renameat`, and `AT_FDCWD`.
- Add `rename`, `renameat`, `unlinkat`, `AT_FDCWD`, and `AT_REMOVEDIR`.
([#1097](https://github.com/nix-rust/nix/pull/1097))

### Changed
Expand Down
1 change: 1 addition & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub const AT_FDCWD: RawFd = libc::AT_FDCWD as RawFd;

libc_bitflags!{
pub struct AtFlags: c_int {
AT_REMOVEDIR;
AT_SYMLINK_NOFOLLOW;
#[cfg(any(target_os = "android", target_os = "linux"))]
AT_NO_AUTOMOUNT;
Expand Down
9 changes: 9 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,15 @@ pub fn unlink<P: ?Sized + NixPath>(path: &P) -> Result<()> {
Errno::result(res).map(drop)
}

pub fn unlinkat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P, flags: AtFlags) -> Result<()> {
let res = path.with_nix_path(|cstr| {
unsafe {
libc::unlinkat(dirfd, cstr.as_ptr(), flags.bits() as libc::c_int)
}
})?;
Errno::result(res).map(drop)
}

#[inline]
pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> {
let res = path.with_nix_path(|cstr| {
Expand Down

0 comments on commit c34f87c

Please sign in to comment.