File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,13 +79,28 @@ where
7979 std:: process:: id( )
8080 ) ) ;
8181
82+ // Prefer fusermount3 if available (FUSE3), otherwise fall back to fusermount (FUSE2).
8283 // polyfuse assumes an absolute path, see https://github.com/ubnt-intrepid/polyfuse/issues/83
83- let fusermount_path =
84- which:: which ( "fusermount" ) . context ( "looking up 'fusermount' in PATH" ) ?;
85- options. fusermount_path ( fusermount_path) ;
84+ let fusermount_path = which:: which ( "fusermount3" )
85+ . or_else ( |_| which:: which ( "fusermount" ) )
86+ . context ( "looking up 'fusermount3' or 'fusermount' in PATH" ) ?;
87+ // Clone because we need to both set the path and inspect the filename.
88+ options. fusermount_path ( fusermount_path. clone ( ) ) ;
89+
90+ // 'nonempty' is specific to libfuse2 and may be rejected by fusermount3.
91+ // Only add it when using the legacy 'fusermount' binary.
92+ let is_fuse2 = fusermount_path
93+ . file_name ( )
94+ . and_then ( |n| n. to_str ( ) )
95+ . map ( |n| n == "fusermount" )
96+ . unwrap_or ( false ) ;
97+ if is_fuse2 {
98+ options. mount_option ( "nonempty" ) ;
99+ }
86100
87101 let session = AsyncSession :: mount ( mountpoint, options) . await ?;
88102
103+
89104 // release here
90105 while let Some ( req) = session. next_request ( ) . await ? {
91106 let fs = self . clone ( ) ;
You can’t perform that action at this time.
0 commit comments