1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
13 // pprof is only imported to register its HTTP handlers
17 "git.arvados.org/arvados.git/lib/cmd"
18 "git.arvados.org/arvados.git/sdk/go/arvados"
19 "git.arvados.org/arvados.git/sdk/go/arvadosclient"
20 "git.arvados.org/arvados.git/sdk/go/keepclient"
21 "github.com/arvados/cgofuse/fuse"
24 var Command = &mountCommand{}
26 type mountCommand struct {
27 // ready, if non-nil, will be closed when the mount is
28 // initialized. If ready is non-nil, it RunCommand() should
29 // not be called more than once, or when ready is already
32 // It is safe to call Unmount only after ready has been
34 Unmount func() (ok bool)
37 // RunCommand implements the subcommand "mount <path> [fuse options]".
39 // The "-d" fuse option (and perhaps other features) ignores the
40 // stderr argument and prints to os.Stderr instead.
41 func (c *mountCommand) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
42 logger := log.New(stderr, prog+" ", 0)
43 flags := flag.NewFlagSet(prog, flag.ContinueOnError)
44 ro := flags.Bool("ro", false, "read-only")
45 experimental := flags.Bool("experimental", false, "acknowledge this is an experimental command, and should not be used in production (required)")
46 blockCache := flags.Int("block-cache", 4, "read cache size (number of 64MiB blocks)")
47 pprof := flags.String("pprof", "", "serve Go profile data at `[addr]:port`")
48 if ok, code := cmd.ParseFlags(flags, prog, args, "[FUSE mount options]", stderr); !ok {
52 logger.Printf("error: experimental command %q used without --experimental flag", prog)
57 log.Println(http.ListenAndServe(*pprof, nil))
61 client := arvados.NewClientFromEnv()
62 ac, err := arvadosclient.New(client)
67 kc, err := keepclient.MakeKeepClient(ac)
72 kc.BlockCache = &keepclient.BlockCache{MaxBlocks: *blockCache}
73 host := fuse.NewFileSystemHost(&keepFS{
81 c.Unmount = host.Unmount
82 ok := host.Mount("", flags.Args())