diff options
author | Jakob Unterwurzacher | 2019-12-28 20:44:12 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-12-28 23:51:45 +0100 |
commit | db43bfc4c03b37b8b91bef413f4a75e8d769dc15 (patch) | |
tree | f9cf255813f9d154e3a728169549a0cb1f4f07c4 /mount.go | |
parent | 1364b44ae356da31e24e5605fe73a307e9d6fb03 (diff) |
main: detect fusermount3 and don't add `nonempty`
fusermount3 (i.e. fusermount from libfuse 3.x) has dropped
the `nonempty` option.
Detect fusermount3 and don't add `nonempty` in this case.
Fixes https://github.com/rfjakob/gocryptfs/pull/440
Diffstat (limited to 'mount.go')
-rw-r--r-- | mount.go | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -1,6 +1,7 @@ package main import ( + "bytes" "encoding/json" "fmt" "log" @@ -362,7 +363,9 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server { tlog.Info.Printf(tlog.ColorYellow + "THE OPTION \"-forcedecode\" IS ACTIVE. GOCRYPTFS WILL RETURN CORRUPT DATA!" + tlog.ColorReset) } - if args.nonempty { + // fusermount from libfuse 3.x removed the "nonempty" option and exits + // with an error if it sees it. Only add it to the options on libfuse 2.x. + if args.nonempty && haveFusermount2() { mOpts.Options = append(mOpts.Options, "nonempty") } // Set values shown in "df -T" and friends @@ -436,6 +439,25 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server { return srv } +// haveFusermount2 finds out if the "fusermount" binary is from libfuse 2.x. +func haveFusermount2() bool { + cmd := exec.Command("/bin/fusermount", "-V") + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + tlog.Warn.Printf("warning: haveFusermount2: %v", err) + return false + } + // libfuse 2: fusermount version: 2.9.9 + // libfuse 3: fusermount3 version: 3.9.0 + v := out.String() + if strings.HasPrefix(v, "fusermount version") { + return true + } + return false +} + func handleSigint(srv *fuse.Server, mountpoint string) { ch := make(chan os.Signal, 1) signal.Notify(ch, os.Interrupt) |