File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,13 @@ impl InodeHandle {
109
109
}
110
110
}
111
111
112
+ fn open_file ( & self , flags : libc:: c_int , proc_self_fd : & File ) -> io:: Result < File > {
113
+ match self {
114
+ InodeHandle :: File ( f) => reopen_fd_through_proc ( f, flags, proc_self_fd) ,
115
+ InodeHandle :: Handle ( h) => h. open ( flags) ,
116
+ }
117
+ }
118
+
112
119
fn stat ( & self ) -> io:: Result < libc:: stat64 > {
113
120
match self {
114
121
InodeHandle :: File ( f) => stat_fd ( f, None ) ,
@@ -146,6 +153,10 @@ impl InodeData {
146
153
fn get_file ( & self ) -> io:: Result < InodeFile < ' _ > > {
147
154
self . handle . get_file ( )
148
155
}
156
+
157
+ fn open_file ( & self , flags : libc:: c_int , proc_self_fd : & File ) -> io:: Result < File > {
158
+ self . handle . open_file ( flags, proc_self_fd)
159
+ }
149
160
}
150
161
151
162
/// Data structures to manage accessed inodes.
Original file line number Diff line number Diff line change @@ -30,14 +30,12 @@ use crate::transport::FsCacheReqHandler;
30
30
31
31
impl < S : BitmapSlice + Send + Sync > PassthroughFs < S > {
32
32
fn open_inode ( & self , inode : Inode , flags : i32 ) -> io:: Result < File > {
33
- let new_flags = self . get_writeback_open_flags ( flags) ;
34
33
let data = self . inode_map . get ( inode) ?;
35
34
if !is_safe_inode ( data. mode ) {
36
35
Err ( ebadf ( ) )
37
36
} else {
38
- // TODO: optimize
39
- let file = data. get_file ( ) ?;
40
- reopen_fd_through_proc ( & file, new_flags | libc:: O_CLOEXEC , & self . proc_self_fd )
37
+ let new_flags = self . get_writeback_open_flags ( flags) ;
38
+ data. open_file ( new_flags | libc:: O_CLOEXEC , & self . proc_self_fd )
41
39
}
42
40
}
43
41
@@ -418,11 +416,11 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
418
416
// Safe because this doesn't modify any memory and we check the return value.
419
417
unsafe { libc:: mkdirat ( file. as_raw_fd ( ) , name. as_ptr ( ) , mode & !umask) }
420
418
} ;
421
- if res == 0 {
422
- self . do_lookup ( parent, name)
423
- } else {
424
- Err ( io:: Error :: last_os_error ( ) )
419
+ if res < 0 {
420
+ return Err ( io:: Error :: last_os_error ( ) ) ;
425
421
}
422
+
423
+ self . do_lookup ( parent, name)
426
424
}
427
425
428
426
fn rmdir ( & self , _ctx : & Context , parent : Inode , name : & CStr ) -> io:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments