Commit 1fe08a46 authored by James D. Nurmi's avatar James D. Nurmi

Search for fusermount on init rather than hard-coding. (keep defaults if one isn't found on path)

parent a75cd967
...@@ -4,11 +4,15 @@ package fuse ...@@ -4,11 +4,15 @@ package fuse
import ( import (
"fmt" "fmt"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings"
"syscall" "syscall"
"unsafe" "unsafe"
) )
var mount_bin string = "/bin/fusermount"
func Socketpair(network string) (l, r *os.File, err os.Error) { func Socketpair(network string) (l, r *os.File, err os.Error) {
var domain int var domain int
var typ int var typ int
...@@ -51,13 +55,13 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin ...@@ -51,13 +55,13 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint)) mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint))
} }
cmd := []string{"/bin/fusermount", mountPoint} cmd := []string{mount_bin, mountPoint}
if options != "" { if options != "" {
cmd = append(cmd, "-o") cmd = append(cmd, "-o")
cmd = append(cmd, options) cmd = append(cmd, options)
} }
proc, err := os.StartProcess("/bin/fusermount", proc, err := os.StartProcess(mount_bin,
cmd, cmd,
&os.ProcAttr{ &os.ProcAttr{
Env: []string{"_FUSE_COMMFD=3"}, Env: []string{"_FUSE_COMMFD=3"},
...@@ -82,8 +86,8 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin ...@@ -82,8 +86,8 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
func unmount(mountPoint string) (err os.Error) { func unmount(mountPoint string) (err os.Error) {
dir, _ := filepath.Split(mountPoint) dir, _ := filepath.Split(mountPoint)
proc, err := os.StartProcess("/bin/fusermount", proc, err := os.StartProcess(mount_bin,
[]string{"/bin/fusermount", "-u", mountPoint}, []string{mount_bin, "-u", mountPoint},
&os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}}) &os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}})
if err != nil { if err != nil {
return return
...@@ -128,3 +132,14 @@ func getConnection(local *os.File) (f *os.File, err os.Error) { ...@@ -128,3 +132,14 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
f = os.NewFile(int(fd), "<fuseConnection>") f = os.NewFile(int(fd), "<fuseConnection>")
return return
} }
func init() {
for _, v := range strings.Split(os.Getenv("PATH"), ":", -1) {
tpath := path.Join(v, "fusermount")
fi, err := os.Stat(tpath)
if err == nil && (fi.Mode&0111) != 0 {
mount_bin = tpath
break
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment