From 92d2a3f298a2d8661df37890202caa84b8f5331b Mon Sep 17 00:00:00 2001 From: viyatb-oai Date: Mon, 8 Jun 2026 17:03:34 -0700 Subject: [PATCH] refactor: simplify no-follow read helper Co-authored-by: Codex --- codex-rs/utils/path-utils/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/codex-rs/utils/path-utils/src/lib.rs b/codex-rs/utils/path-utils/src/lib.rs index 35fee11c23..159b3c8aff 100644 --- a/codex-rs/utils/path-utils/src/lib.rs +++ b/codex-rs/utils/path-utils/src/lib.rs @@ -149,11 +149,6 @@ pub fn write_atomically(write_path: &Path, contents: &str) -> io::Result<()> { /// Relative paths are resolved from the process's current directory. #[cfg(unix)] pub fn open_file_for_read_no_follow(path: &Path) -> io::Result { - open_file_no_follow(path, libc::O_RDONLY, /*mode*/ 0) -} - -#[cfg(unix)] -fn open_file_no_follow(path: &Path, flags: libc::c_int, mode: libc::mode_t) -> io::Result { let components = path .components() .filter_map(|component| match component { @@ -189,8 +184,8 @@ fn open_file_no_follow(path: &Path, flags: libc::c_int, mode: libc::mode_t) -> i openat( ¤t_dir, file_name, - flags | libc::O_CLOEXEC | libc::O_NOFOLLOW, - mode, + libc::O_RDONLY | libc::O_CLOEXEC | libc::O_NOFOLLOW, + /*mode*/ 0, ) }