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 {
109109 }
110110 }
111111
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+
112119 fn stat ( & self ) -> io:: Result < libc:: stat64 > {
113120 match self {
114121 InodeHandle :: File ( f) => stat_fd ( f, None ) ,
@@ -146,6 +153,10 @@ impl InodeData {
146153 fn get_file ( & self ) -> io:: Result < InodeFile < ' _ > > {
147154 self . handle . get_file ( )
148155 }
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+ }
149160}
150161
151162/// Data structures to manage accessed inodes.
Original file line number Diff line number Diff line change @@ -30,14 +30,12 @@ use crate::transport::FsCacheReqHandler;
3030
3131impl < S : BitmapSlice + Send + Sync > PassthroughFs < S > {
3232 fn open_inode ( & self , inode : Inode , flags : i32 ) -> io:: Result < File > {
33- let new_flags = self . get_writeback_open_flags ( flags) ;
3433 let data = self . inode_map . get ( inode) ?;
3534 if !is_safe_inode ( data. mode ) {
3635 Err ( ebadf ( ) )
3736 } 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 )
4139 }
4240 }
4341
@@ -418,11 +416,11 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
418416 // Safe because this doesn't modify any memory and we check the return value.
419417 unsafe { libc:: mkdirat ( file. as_raw_fd ( ) , name. as_ptr ( ) , mode & !umask) }
420418 } ;
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 ( ) ) ;
425421 }
422+
423+ self . do_lookup ( parent, name)
426424 }
427425
428426 fn rmdir ( & self , _ctx : & Context , parent : Inode , name : & CStr ) -> io:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments