1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
13 "git.arvados.org/arvados.git/sdk/go/arvados"
14 "git.arvados.org/arvados.git/sdk/go/arvadosclient"
15 "git.arvados.org/arvados.git/sdk/go/keepclient"
16 "github.com/arvados/cgofuse/fuse"
22 // ready, if non-nil, will be closed when the mount is
23 // initialized. If ready is non-nil, it RunCommand() should
24 // not be called more than once, or when ready is already
27 // It is safe to call Unmount ounly after ready has been
29 Unmount func() (ok bool)
32 // RunCommand implements the subcommand "mount <path> [fuse options]".
34 // The "-d" fuse option (and perhaps other features) ignores the
35 // stderr argument and prints to os.Stderr instead.
36 func (c *cmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
37 logger := log.New(stderr, prog+" ", 0)
38 flags := flag.NewFlagSet(prog, flag.ContinueOnError)
39 ro := flags.Bool("ro", false, "read-only")
40 experimental := flags.Bool("experimental", false, "acknowledge this is an experimental command, and should not be used in production (required)")
41 err := flags.Parse(args)
47 logger.Printf("error: experimental command %q used without --experimental flag", prog)
51 client := arvados.NewClientFromEnv()
52 ac, err := arvadosclient.New(client)
57 kc, err := keepclient.MakeKeepClient(ac)
62 host := fuse.NewFileSystemHost(&keepFS{
70 c.Unmount = host.Unmount
71 ok := host.Mount("", flags.Args())