Commit 19c2a8f8 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

fuse: move fusermount logic to new callFusermount() helper

This makes the function available to testing, which will
be used in the next commit.

Change-Id: I2df7aaf50748f209964da6f14764e81237d49027
parent 15a8bb02
...@@ -68,18 +68,12 @@ func mountDirect(mountPoint string, opts *MountOptions, ready chan<- error) (fd ...@@ -68,18 +68,12 @@ func mountDirect(mountPoint string, opts *MountOptions, ready chan<- error) (fd
return return
} }
// Create a FUSE FS on the specified mount point. The returned // callFusermount calls the `fusermount` suid helper with the right options so
// mount point is always absolute. // that it:
func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, err error) { // * opens `/dev/fuse`
if opts.DirectMount { // * mount()s this file descriptor to `mountPoint`
fd, err := mountDirect(mountPoint, opts, ready) // * passes this file descriptor back to use via a unix domain socket
if err == nil { func callFusermount(mountPoint string, opts *MountOptions) (fd int, err error) {
return fd, nil
} else if opts.Debug {
log.Printf("mount: failed to do direct mount: %s", err)
}
}
local, remote, err := unixgramSocketpair() local, remote, err := unixgramSocketpair()
if err != nil { if err != nil {
return return
...@@ -121,6 +115,27 @@ func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, e ...@@ -121,6 +115,27 @@ func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, e
return -1, err return -1, err
} }
return
}
// Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute.
func mount(mountPoint string, opts *MountOptions, ready chan<- error) (fd int, err error) {
if opts.DirectMount {
fd, err := mountDirect(mountPoint, opts, ready)
if err == nil {
return fd, nil
} else if opts.Debug {
log.Printf("mount: failed to do direct mount: %s", err)
}
}
// Usual case: mount via the `fusermount` suid helper
fd, err = callFusermount(mountPoint, opts)
if err != nil {
return
}
// golang sets CLOEXEC on file descriptors when they are // golang sets CLOEXEC on file descriptors when they are
// acquired through normal operations (e.g. open). // acquired through normal operations (e.g. open).
// Buf for fd, we have to set CLOEXEC manually // Buf for fd, we have to set CLOEXEC manually
......
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