// Mount mounts a fuse fs.FS at a given location, and returns a Mount instance. // parent is a ContextGroup to bind the mount's ContextGroup to. func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allow_other bool) (Mount, error) { var conn *fuse.Conn var err error if allow_other { conn, err = fuse.Mount(mountpoint, fuse.AllowOther()) } else { conn, err = fuse.Mount(mountpoint) } if err != nil { return nil, err } m := &mount{ mpoint: mountpoint, fuseConn: conn, filesys: fsys, proc: goprocess.WithParent(p), // link it to parent. } m.proc.SetTeardown(m.unmount) // launch the mounting process. if err := m.mount(); err != nil { m.Unmount() // just in case. return nil, err } return m, nil }
func TestMountOptionAllowRootThenAllowOther(t *testing.T) { t.Parallel() mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{fstestutil.Dir{}}, fuse.AllowRoot(), fuse.AllowOther(), ) if err == nil { mnt.Close() } if g, e := err, fuse.ErrCannotCombineAllowOtherAndAllowRoot; g != e { t.Fatalf("wrong error: %v != %v", g, e) } }