From c6552462d3e24bb06d3794690fb7a8baea44e0b1 Mon Sep 17 00:00:00 2001 From: carlosb1 Date: Fri, 29 Sep 2023 23:35:52 +0200 Subject: [PATCH 1/4] Changed signature for openat function Signed-off-by: carlosb1 --- src/dir.rs | 2 +- src/fcntl.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dir.rs b/src/dir.rs index 96a5843bc6..bdec58bd1b 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -44,7 +44,7 @@ impl Dir { /// Opens the given path as with `fcntl::openat`. pub fn openat( - dirfd: RawFd, + dirfd: Option, path: &P, oflag: OFlag, mode: sys::stat::Mode, diff --git a/src/fcntl.rs b/src/fcntl.rs index 9bfecda5ac..60b0bfde1a 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -220,13 +220,13 @@ pub fn open( #[allow(clippy::useless_conversion)] #[cfg(not(target_os = "redox"))] pub fn openat( - dirfd: RawFd, + dirfd: Option, path: &P, oflag: OFlag, mode: Mode, ) -> Result { let fd = path.with_nix_path(|cstr| unsafe { - libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) + libc::openat(at_rawfd(dirfd), cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) })?; Errno::result(fd) } From 05275a40fef75d287bab3bdec52db739c6b9b6ee Mon Sep 17 00:00:00 2001 From: carlosb1 Date: Fri, 29 Sep 2023 23:41:44 +0200 Subject: [PATCH 2/4] Fixed tests for openat to apply Options Signed-off-by: carlosb1 --- test/test_fcntl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index 5fef04ba9b..f2efcf9aec 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -42,7 +42,7 @@ fn test_openat() { open(tmp.path().parent().unwrap(), OFlag::empty(), Mode::empty()) .unwrap(); let fd = openat( - dirfd, + Some(dirfd), tmp.path().file_name().unwrap(), OFlag::O_RDONLY, Mode::empty(), From 58f0cc10a052001ff28224573c366742a29963aa Mon Sep 17 00:00:00 2001 From: carlosb1 Date: Sun, 1 Oct 2023 00:01:41 +0200 Subject: [PATCH 3/4] Updated changelog Signed-off-by: carlosb1 --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a171afd68..5e0ee986cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). +## [Unreleased] - 2023-09-30 + +### Changed + +- Changed `openat()` and `Dir::openat()` now take optional `dirfd`s + ([#1850](https://github.com/nix-rust/nix/pull/2139)) + + ## [0.27.1] - 2023-08-28 ### Fixed @@ -99,7 +107,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [0.26.3] - 2023-08-27 ### Fixed -- Fix: send `ETH_P_ALL` in htons format +- Fix: send `ETH_P_ALL` in htons format ([#1925](https://github.com/nix-rust/nix/pull/1925)) - Fix: `recvmsg` now sets the length of the received `sockaddr_un` field correctly on Linux platforms. ([#2041](https://github.com/nix-rust/nix/pull/2041)) @@ -187,7 +195,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ([#1824](https://github.com/nix-rust/nix/pull/1824)) - Workaround XNU bug causing netmasks returned by `getifaddrs` to misbehave. ([#1788](https://github.com/nix-rust/nix/pull/1788)) - + ### Removed - Removed deprecated error constants and conversions. From 37b168a669b2117ba71ee154d547f7c1393ee308 Mon Sep 17 00:00:00 2001 From: carlosb1 Date: Sun, 1 Oct 2023 00:03:53 +0200 Subject: [PATCH 4/4] Fixed num PR Signed-off-by: carlosb1 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e0ee986cb..e9f101d87b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Changed -- Changed `openat()` and `Dir::openat()` now take optional `dirfd`s - ([#1850](https://github.com/nix-rust/nix/pull/2139)) +- Changed `openat()` and `Dir::openat()`, now take optional `dirfd`s + ([#2139](https://github.com/nix-rust/nix/pull/2139)) ## [0.27.1] - 2023-08-28