Commit 39953190 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Han-Wen Nienhuys

nodefs += Mount

Add nodefs.Mount - utility to mount root over mountpoint with given
options. We already had nodefs.MountRoot, but that was taking only
nodefs.Options and there was no way to pass fuse.MountOptions in. The
new utility accepts both fuse.MountOptions and nodefs.Options, each
covering their level.

This should be generally useful(*), as well as it will be used in a next
patch in TestFopenKeepCache where fuse.MountOptions.PreciseDataCacheControl
will need to be used.

(*) see e.g. https://lab.nexedi.com/kirr/wendelin.core/blob/8f497094/wcfs/misc.go#L258
as example that users unroll their Mount versions to be able to pass in
fuse.MountOptions.
parent 48c07fc7
...@@ -8,18 +8,22 @@ import ( ...@@ -8,18 +8,22 @@ import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
) )
// MountRoot mounts a filesystem with the given root node on the given directory. // Mount mounts a filesystem with the given root node on the given directory.
// Convenience wrapper around fuse.NewServer // Convenience wrapper around fuse.NewServer
func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error) { func Mount(mountpoint string, root Node, mountOptions *fuse.MountOptions, nodefsOptions *Options) (*fuse.Server, *FileSystemConnector, error) {
conn := NewFileSystemConnector(root, opts) conn := NewFileSystemConnector(root, nodefsOptions)
s, err := fuse.NewServer(conn.RawFS(), mountpoint, mountOptions)
mountOpts := fuse.MountOptions{}
if opts != nil && opts.Debug {
mountOpts.Debug = opts.Debug
}
s, err := fuse.NewServer(conn.RawFS(), mountpoint, &mountOpts)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
return s, conn, nil return s, conn, nil
} }
// MountRoot is like Mount but uses default fuse mount options.
func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error) {
mountOpts := &fuse.MountOptions{}
if opts != nil && opts.Debug {
mountOpts.Debug = opts.Debug
}
return Mount(mountpoint, root, mountOpts, opts)
}
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