File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "bytes"
45 "encoding/json"
56 "fmt"
67 "log"
@@ -362,7 +363,9 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server {
362363 tlog .Info .Printf (tlog .ColorYellow + "THE OPTION \" -forcedecode\" IS ACTIVE. GOCRYPTFS WILL RETURN CORRUPT DATA!" +
363364 tlog .ColorReset )
364365 }
365- if args .nonempty {
366+ // fusermount from libfuse 3.x removed the "nonempty" option and exits
367+ // with an error if it sees it. Only add it to the options on libfuse 2.x.
368+ if args .nonempty && haveFusermount2 () {
366369 mOpts .Options = append (mOpts .Options , "nonempty" )
367370 }
368371 // Set values shown in "df -T" and friends
@@ -436,6 +439,25 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server {
436439 return srv
437440}
438441
442+ // haveFusermount2 finds out if the "fusermount" binary is from libfuse 2.x.
443+ func haveFusermount2 () bool {
444+ cmd := exec .Command ("/bin/fusermount" , "-V" )
445+ var out bytes.Buffer
446+ cmd .Stdout = & out
447+ err := cmd .Run ()
448+ if err != nil {
449+ tlog .Warn .Printf ("warning: haveFusermount2: %v" , err )
450+ return false
451+ }
452+ // libfuse 2: fusermount version: 2.9.9
453+ // libfuse 3: fusermount3 version: 3.9.0
454+ v := out .String ()
455+ if strings .HasPrefix (v , "fusermount version" ) {
456+ return true
457+ }
458+ return false
459+ }
460+
439461func handleSigint (srv * fuse.Server , mountpoint string ) {
440462 ch := make (chan os.Signal , 1 )
441463 signal .Notify (ch , os .Interrupt )
You can’t perform that action at this time.
0 commit comments