77use std:: ffi:: OsStr ;
88use std:: io;
99use std:: path:: { Path , PathBuf } ;
10- use std:: sync:: { Arc , Mutex , OnceLock } ;
10+ use std:: sync:: { Arc , OnceLock } ;
1111use std:: time:: SystemTime ;
1212
1313use fuser:: { AccessFlags , BsdFileFlags , Errno , FileHandle , FopenFlags , INodeNo , LockOwner , OpenFlags , RenameFlags , TimeOrNow , WriteFlags } ;
14+ use parking_lot:: Mutex ;
1415use threadpool:: ThreadPool ;
1516
1617use crate :: directory_cache:: * ;
@@ -100,7 +101,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> FuseMT<T> {
100101
101102macro_rules! get_path {
102103 ( $s: expr, $ino: expr, $reply: expr) => {
103- if let Some ( path) = $s. inodes. lock( ) . unwrap ( ) . get_path( $ino) {
104+ if let Some ( path) = $s. inodes. lock( ) . get_path( $ino) {
104105 path
105106 } else {
106107 $reply. error( Errno :: EINVAL ) ;
@@ -136,7 +137,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
136137 let path = Arc :: new ( ( * parent_path) . clone ( ) . join ( name) ) ;
137138 match self . target . getattr ( req. info ( ) , & path, None ) {
138139 Ok ( ( ttl, attr) ) => {
139- let mut inodes = self . inodes . lock ( ) . unwrap ( ) ;
140+ let mut inodes = self . inodes . lock ( ) ;
140141 let ( ino, generation) = inodes. add_or_get ( path. clone ( ) ) ;
141142 inodes. lookup ( ino) ;
142143 reply. entry ( & ttl, & fuse_fileattr ( attr, ino) , generation) ;
@@ -151,7 +152,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
151152 ino : INodeNo ,
152153 nlookup : u64 ,
153154 ) {
154- let mut inodes = self . inodes . lock ( ) . unwrap ( ) ;
155+ let mut inodes = self . inodes . lock ( ) ;
155156 let path = inodes. get_path ( ino) . unwrap_or_else ( || {
156157 Arc :: new ( PathBuf :: from ( "[unknown]" ) )
157158 } ) ;
@@ -281,7 +282,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
281282 debug ! ( "mknod: {:?}/{:?}" , parent_path, name) ;
282283 match self . target . mknod ( req. info ( ) , & parent_path, name, mode, rdev) {
283284 Ok ( ( ttl, attr) ) => {
284- let ( ino, generation) = self . inodes . lock ( ) . unwrap ( )
285+ let ( ino, generation) = self . inodes . lock ( )
285286 . add ( Arc :: new ( parent_path. join ( name) ) ) ;
286287 reply. entry ( & ttl, & fuse_fileattr ( attr, ino) , generation)
287288 } ,
@@ -302,7 +303,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
302303 debug ! ( "mkdir: {:?}/{:?}" , parent_path, name) ;
303304 match self . target . mkdir ( req. info ( ) , & parent_path, name, mode) {
304305 Ok ( ( ttl, attr) ) => {
305- let ( ino, generation) = self . inodes . lock ( ) . unwrap ( )
306+ let ( ino, generation) = self . inodes . lock ( )
306307 . add ( Arc :: new ( parent_path. join ( name) ) ) ;
307308 reply. entry ( & ttl, & fuse_fileattr ( attr, ino) , generation)
308309 } ,
@@ -321,7 +322,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
321322 debug ! ( "unlink: {:?}/{:?}" , parent_path, name) ;
322323 match self . target . unlink ( req. info ( ) , & parent_path, name) {
323324 Ok ( ( ) ) => {
324- self . inodes . lock ( ) . unwrap ( ) . unlink ( & parent_path. join ( name) ) ;
325+ self . inodes . lock ( ) . unlink ( & parent_path. join ( name) ) ;
325326 reply. ok ( )
326327 } ,
327328 Err ( e) => reply. error ( Errno :: from_i32 ( e) ) ,
@@ -339,7 +340,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
339340 debug ! ( "rmdir: {:?}/{:?}" , parent_path, name) ;
340341 match self . target . rmdir ( req. info ( ) , & parent_path, name) {
341342 Ok ( ( ) ) => {
342- self . inodes . lock ( ) . unwrap ( ) . unlink ( & parent_path. join ( name) ) ;
343+ self . inodes . lock ( ) . unlink ( & parent_path. join ( name) ) ;
343344 reply. ok ( )
344345 } ,
345346 Err ( e) => reply. error ( Errno :: from_i32 ( e) ) ,
@@ -358,7 +359,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
358359 debug ! ( "symlink: {:?}/{:?} -> {:?}" , parent_path, name, link) ;
359360 match self . target . symlink ( req. info ( ) , & parent_path, name, link) {
360361 Ok ( ( ttl, attr) ) => {
361- let ( ino, generation) = self . inodes . lock ( ) . unwrap ( )
362+ let ( ino, generation) = self . inodes . lock ( )
362363 . add ( Arc :: new ( parent_path. join ( name) ) ) ;
363364 reply. entry ( & ttl, & fuse_fileattr ( attr, ino) , generation)
364365 } ,
@@ -381,7 +382,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
381382 debug ! ( "rename: {:?}/{:?} -> {:?}/{:?}" , parent_path, name, newparent_path, newname) ;
382383 match self . target . rename ( req. info ( ) , & parent_path, name, & newparent_path, newname) {
383384 Ok ( ( ) ) => {
384- self . inodes . lock ( ) . unwrap ( ) . rename ( & parent_path. join ( name) , Arc :: new ( newparent_path. join ( newname) ) ) ;
385+ self . inodes . lock ( ) . rename ( & parent_path. join ( name) , Arc :: new ( newparent_path. join ( newname) ) ) ;
385386 reply. ok ( )
386387 } ,
387388 Err ( e) => reply. error ( Errno :: from_i32 ( e) ) ,
@@ -403,7 +404,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
403404 Ok ( ( ttl, attr) ) => {
404405 // NOTE: this results in the new link having a different inode from the original.
405406 // This is needed because our inode table is a 1:1 map between paths and inodes.
406- let ( new_ino, generation) = self . inodes . lock ( ) . unwrap ( )
407+ let ( new_ino, generation) = self . inodes . lock ( )
407408 . add ( Arc :: new ( newparent_path. join ( newname) ) ) ;
408409 reply. entry ( & ttl, & fuse_fileattr ( attr, new_ino) , generation) ;
409410 } ,
@@ -559,7 +560,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
559560 debug ! ( "opendir: {:?}" , path) ;
560561 match self . target . opendir ( req. info ( ) , & path, flags. 0 as u32 ) {
561562 Ok ( ( fh, flags) ) => {
562- let dcache_key = self . directory_cache . lock ( ) . unwrap ( ) . new_entry ( fh) ;
563+ let dcache_key = self . directory_cache . lock ( ) . new_entry ( fh) ;
563564 reply. opened ( FileHandle ( dcache_key) , FopenFlags :: from_bits_retain ( flags) ) ;
564565 } ,
565566 Err ( e) => reply. error ( Errno :: from_i32 ( e) ) ,
@@ -577,7 +578,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
577578 let path = get_path ! ( self , ino, reply) ;
578579 debug ! ( "readdir: {:?} @ {}" , path, offset) ;
579580
580- let mut dcache = self . directory_cache . lock ( ) . unwrap ( ) ;
581+ let mut dcache = self . directory_cache . lock ( ) ;
581582 let entries: & [ DirectoryEntry ] = {
582583 let dcache_entry = dcache. get_mut ( fh. 0 ) ;
583584 if let Some ( ref entries) = dcache_entry. entries {
@@ -601,7 +602,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
601602 ino
602603 } else {
603604 let parent_path: & Path = path. parent ( ) . unwrap ( ) ;
604- match self . inodes . lock ( ) . unwrap ( ) . get_inode ( parent_path) {
605+ match self . inodes . lock ( ) . get_inode ( parent_path) {
605606 Some ( inode) => inode,
606607 None => {
607608 error ! ( "readdir: unable to get inode for parent of {:?}" , path) ;
@@ -652,7 +653,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
652653 ) {
653654 let path = get_path ! ( self , ino, reply) ;
654655 debug ! ( "releasedir: {:?}" , path) ;
655- let mut dcache = self . directory_cache . lock ( ) . unwrap ( ) ;
656+ let mut dcache = self . directory_cache . lock ( ) ;
656657 let real_fh = dcache. real_fh ( fh. 0 ) ;
657658 match self . target . releasedir ( req. info ( ) , & path, real_fh, flags. 0 as u32 ) {
658659 Ok ( ( ) ) => reply. ok ( ) ,
@@ -671,7 +672,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
671672 ) {
672673 let path = get_path ! ( self , ino, reply) ;
673674 debug ! ( "fsyncdir: {:?} (datasync: {:?})" , path, datasync) ;
674- let real_fh = self . directory_cache . lock ( ) . unwrap ( ) . real_fh ( fh. 0 ) ;
675+ let real_fh = self . directory_cache . lock ( ) . real_fh ( fh. 0 ) ;
675676 match self . target . fsyncdir ( req. info ( ) , & path, real_fh, datasync) {
676677 Ok ( ( ) ) => reply. ok ( ) ,
677678 Err ( e) => reply. error ( Errno :: from_i32 ( e) ) ,
@@ -816,7 +817,7 @@ impl<T: FilesystemMT + Sync + Send + 'static> fuser::Filesystem for FuseMT<T> {
816817 debug ! ( "create: {:?}/{:?} (mode={:#o}, flags={:#x})" , parent_path, name, mode, flags) ;
817818 match self . target . create ( req. info ( ) , & parent_path, name, mode, flags as u32 ) {
818819 Ok ( create) => {
819- let ( ino, generation) = self . inodes . lock ( ) . unwrap ( ) . add ( Arc :: new ( parent_path. join ( name) ) ) ;
820+ let ( ino, generation) = self . inodes . lock ( ) . add ( Arc :: new ( parent_path. join ( name) ) ) ;
820821 let attr = fuse_fileattr ( create. attr , ino) ;
821822 reply. created ( & create. ttl , & attr, generation, FileHandle ( create. fh ) , FopenFlags :: from_bits_retain ( create. flags ) ) ;
822823 } ,
0 commit comments