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(
78
78
pub ( crate ) fn openat2 (
79
79
dirfd : BorrowedFd < ' _ > ,
80
80
path : & CStr ,
81
- flags : OFlags ,
81
+ mut flags : OFlags ,
82
82
mode : Mode ,
83
83
resolve : ResolveFlags ,
84
84
) -> 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
+ }
87
90
88
91
unsafe {
89
92
ret_owned_fd ( syscall_readonly ! (
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ fn test_openat2() {
75
75
)
76
76
. unwrap_err ( ) ;
77
77
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
+
78
88
// Test `NO_MAGICLINKS`.
79
89
let test = openat2_more (
80
90
& dir,
You can’t perform that action at this time.
0 commit comments