File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -78,12 +78,15 @@ pub(crate) fn openat(
7878pub ( crate ) fn openat2 (
7979 dirfd : BorrowedFd < ' _ > ,
8080 path : & CStr ,
81- flags : OFlags ,
81+ mut flags : OFlags ,
8282 mode : Mode ,
8383 resolve : ResolveFlags ,
8484) -> io:: Result < OwnedFd > {
85- // Always enable support for large files.
86- let flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
85+ // Enable support for large files, but not with `O_PATH` because
86+ // `openat2` doesn't like those flags together.
87+ if !flags. contains ( OFlags :: PATH ) {
88+ flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
89+ }
8790
8891 unsafe {
8992 ret_owned_fd ( syscall_readonly ! (
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ fn test_openat2() {
7575 )
7676 . unwrap_err ( ) ;
7777
78+ // Test with `O_PATH`.
79+ let _ = openat2_more (
80+ & dir,
81+ "test.txt" ,
82+ OFlags :: RDONLY | OFlags :: CLOEXEC | OFlags :: PATH ,
83+ Mode :: empty ( ) ,
84+ ResolveFlags :: empty ( ) ,
85+ )
86+ . unwrap ( ) ;
87+
7888 // Test `NO_MAGICLINKS`.
7989 let test = openat2_more (
8090 & dir,
You can’t perform that action at this time.
0 commit comments