From 3f17cd48ad2c75cb7622e2ac21d61bd483158919 Mon Sep 17 00:00:00 2001 From: hellogdc Date: Fri, 5 May 2023 17:25:33 +0800 Subject: [PATCH] issues-463 example/hello can trying direct mount when fusermount not installed --- example/hello/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/example/hello/main.go b/example/hello/main.go index 4fe3e3a0e..4fdb8bfa2 100644 --- a/example/hello/main.go +++ b/example/hello/main.go @@ -10,12 +10,17 @@ import ( "context" "flag" "log" + "os/exec" "syscall" "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" ) +const ( + fusermountBin = "fusermount" +) + type HelloRoot struct { fs.Inode } @@ -46,6 +51,10 @@ func main() { log.Fatal("Usage:\n hello MOUNTPOINT") } opts := &fs.Options{} + if _, err := exec.LookPath(fusermountBin); err != nil { + log.Printf("%s not installed; trying direct mount", fusermountBin) + opts.DirectMount = true + } opts.Debug = *debug server, err := fs.Mount(flag.Arg(0), &HelloRoot{}, opts) if err != nil {