Files
kopia/cli/command_mount_fuse.go
Jarek Kowalski 9a6dea898b Linter upgrade to v1.30.0 (#526)
* fixed godot linter errors
* reformatted source with gofumpt
* disabled some linters
* fixed nolintlint warnings
* fixed gci warnings
* lint: fixed 'nestif' warnings
* lint: fixed 'exhaustive' warnings
* lint: fixed 'gocritic' warnings
* lint: fixed 'noctx' warnings
* lint: fixed 'wsl' warnings
* lint: fixed 'goerr113' warnings
* lint: fixed 'gosec' warnings
* lint: upgraded linter to 1.30.0
* lint: more 'exhaustive' warnings

Co-authored-by: Nick <nick@kasten.io>
2020-08-12 19:28:53 -07:00

55 lines
1.0 KiB
Go

// +build !windows
package cli
import (
"context"
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
"github.com/kopia/kopia/fs"
"github.com/kopia/kopia/internal/fusemount"
)
type root struct {
fusefs.Node
}
func (r *root) Root() (fusefs.Node, error) {
return r.Node, nil
}
var mountMode = mountCommand.Flag("mode", "Mount mode").Default("FUSE").Enum("WEBDAV", "FUSE")
func mountDirectoryFUSE(ctx context.Context, entry fs.Directory, mountPoint string) error {
rootNode := fusemount.NewDirectoryNode(entry)
fuseConnection, err := fuse.Mount(
mountPoint,
fuse.ReadOnly(),
fuse.FSName("kopia"),
fuse.Subtype("kopia"),
fuse.VolumeName("Kopia"),
)
if err != nil {
return err
}
defer fuseConnection.Close() //nolint:errcheck
onCtrlC(func() {
if unmounterr := fuse.Unmount(mountPoint); unmounterr != nil {
log(ctx).Warningf("unmount failed: %v", unmounterr)
}
})
err = fusefs.Serve(fuseConnection, &root{rootNode})
if err != nil {
return err
}
// wait for mount to stop.
<-fuseConnection.Ready
return fuseConnection.MountError
}