Skip to content

Starting with fuse 3.0 the nonempty option has been removed. #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func parseCliOpts() (args argContainer) {
"Only works if user_allow_other is set in /etc/fuse.conf.")
flagSet.BoolVar(&args.reverse, "reverse", false, "Reverse mode")
flagSet.BoolVar(&args.aessiv, "aessiv", false, "AES-SIV encryption")
flagSet.BoolVar(&args.nonempty, "nonempty", false, "Allow mounting over non-empty directories")
flagSet.BoolVar(&args.nonempty, "nonempty", false, "Allow mounting over non-empty directories (deprecated for fuse >=3.0)")
flagSet.BoolVar(&args.raw64, "raw64", true, "Use unpadded base64 for file names")
flagSet.BoolVar(&args.noprealloc, "noprealloc", false, "Disable preallocation before writing")
flagSet.BoolVar(&args.speed, "speed", false, "Run crypto speed test")
Expand Down
51 changes: 50 additions & 1 deletion mount.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"encoding/json"
"fmt"
"log"
Expand All @@ -12,6 +13,8 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"strconv"
"runtime"
"runtime/debug"
"strings"
Expand Down Expand Up @@ -61,7 +64,14 @@ func doMount(args *argContainer) {
args.mountpoint, args.cipherdir)
os.Exit(exitcodes.MountPoint)
}
major, _, err := ProgramVersion("fusermount")
if err != nil {
os.Exit(exitcodes.Usage)
}
if args.nonempty {
if major > 2 {
tlog.Warn.Printf("The option \"nonempty\" was deprecated with fusermount version >= 3.0")
}
err = isDir(args.mountpoint)
} else {
err = isEmptyDir(args.mountpoint)
Expand All @@ -70,7 +80,12 @@ func doMount(args *argContainer) {
tlog.Info.Printf("Mountpoint %q does not exist, but should be created by OSXFuse",
args.mountpoint)
err = nil
goto End
}
if major > 2 {
err = isDir(args.mountpoint)
}
End:
}
if err != nil {
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
Expand Down Expand Up @@ -363,7 +378,12 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server {
tlog.ColorReset)
}
if args.nonempty {
mOpts.Options = append(mOpts.Options, "nonempty")
major, _, _ := ProgramVersion("fusermount")
if major > 2 {
tlog.Warn.Printf("The option \"nonempty\" was deprecated with fusermount version >= 3.0")
} else {
mOpts.Options = append(mOpts.Options, "nonempty")
}
}
// Set values shown in "df -T" and friends
// First column, "Filesystem"
Expand Down Expand Up @@ -461,3 +481,32 @@ func unmount(srv *fuse.Server, mountpoint string) {
}
}
}

// This code was copied from
// https://github.com/hanwen/go-fuse/blob/d4b28605b58e1da41383c1f1874f897f44591d24/unionfs/unionfs_test.go#L897
func ProgramVersion(bin string) (major, minor int64, err error) {
cmd := exec.Command(bin, "--version")
buf := &bytes.Buffer{}
cmd.Stdout = buf
if err := cmd.Run(); err != nil {
return 0, 0, err
}
lines := strings.Split(buf.String(), "\n")
if len(lines) < 1 {
return 0, 0, fmt.Errorf("no output")
}
matches := regexp.MustCompile(".* ([0-9]+)\\.([0-9]+)").FindStringSubmatch(lines[0])

if matches == nil {
return 0, 0, fmt.Errorf("no match for %q", lines[0])
}
major, err = strconv.ParseInt(matches[1], 10, 64)
if err != nil {
return 0, 0, err
}
minor, err = strconv.ParseInt(matches[2], 10, 64)
if err != nil {
return 0, 0, err
}
return major, minor, nil
}