3 from arvados_fuse import *
9 if __name__ == '__main__':
10 # Handle command line parameters
11 parser = argparse.ArgumentParser(
12 description='''Mount Keep data under the local filesystem. By default, if neither
13 --collection or --tags is specified, this mounts as a virtual directory
14 under which all Keep collections are available as subdirectories named
15 with the Keep locator; however directories will not be visible to 'ls'
16 until a program tries to access them.''',
18 Note: When using the --exec feature, you must either specify the
19 mountpoint before --exec, or mark the end of your --exec arguments
22 parser.add_argument('mountpoint', type=str, help="""Mount point.""")
23 parser.add_argument('--allow-other', action='store_true',
24 help="""Let other users read the mount""")
25 parser.add_argument('--collection', type=str, help="""Mount only the specified collection at the mount point.""")
26 parser.add_argument('--tags', action='store_true', help="""Mount as a virtual directory consisting of subdirectories representing tagged
27 collections on the server.""")
28 parser.add_argument('--groups', action='store_true', help="""Mount as a virtual directory consisting of subdirectories representing groups on the server.""")
29 parser.add_argument('--debug', action='store_true', help="""Debug mode""")
30 parser.add_argument('--foreground', action='store_true', help="""Run in foreground (default is to daemonize unless --exec specified)""", default=False)
31 parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER,
32 dest="exec_args", metavar=('command', 'args', '...', '--'),
33 help="""Mount, run a command, then unmount and exit""")
35 args = parser.parse_args()
37 # Create the request handler
38 operations = Operations(os.getuid(), os.getgid())
41 api = arvados.api('v1')
42 e = operations.inodes.add_entry(GroupsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
44 api = arvados.api('v1')
45 e = operations.inodes.add_entry(TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
46 elif args.collection != None:
47 # Set up the request handler with the collection at the root
48 e = operations.inodes.add_entry(CollectionDirectory(llfuse.ROOT_INODE, operations.inodes, args.collection))
50 # Set up the request handler with the 'magic directory' at the root
51 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
53 # FUSE options, see mount.fuse(8)
54 opts = [optname for optname in ['allow_other', 'debug']
55 if getattr(args, optname)]
58 # Initialize the fuse connection
59 llfuse.init(operations, args.mountpoint, opts)
61 t = threading.Thread(None, lambda: llfuse.main())
64 # wait until the driver is finished initializing
65 operations.initlock.wait()
69 rc = subprocess.call(args.exec_args, shell=False)
71 sys.stderr.write('arv-mount: %s -- exec %s\n' % (str(e), args.exec_args))
73 except Exception as e:
74 sys.stderr.write('arv-mount: %s\n' % str(e))
76 subprocess.call(["fusermount", "-u", "-z", args.mountpoint])
81 # Initialize the fuse connection
82 llfuse.init(operations, args.mountpoint, opts)
85 # Initialize the fuse connection
86 llfuse.init(operations, args.mountpoint, opts)
87 with daemon.DaemonContext():