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('--collection', type=str, help="""Mount only the specified collection at the mount point.""")
24 parser.add_argument('--tags', action='store_true', help="""Mount as a virtual directory consisting of subdirectories representing tagged
25 collections on the server.""")
26 parser.add_argument('--groups', action='store_true', help="""Mount as a virtual directory consisting of subdirectories representing groups on the server.""")
27 parser.add_argument('--debug', action='store_true', help="""Debug mode""")
28 parser.add_argument('--foreground', action='store_true', help="""Run in foreground (default is to daemonize unless --exec specified)""", default=False)
29 parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER,
30 dest="exec_args", metavar=('command', 'args', '...', '--'),
31 help="""Mount, run a command, then unmount and exit""")
33 args = parser.parse_args()
35 # Create the request handler
36 operations = Operations(os.getuid(), os.getgid())
39 api = arvados.api('v1')
40 e = operations.inodes.add_entry(GroupsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
42 api = arvados.api('v1')
43 e = operations.inodes.add_entry(TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
44 elif args.collection != None:
45 # Set up the request handler with the collection at the root
46 e = operations.inodes.add_entry(CollectionDirectory(llfuse.ROOT_INODE, operations.inodes, args.collection))
48 # Set up the request handler with the 'magic directory' at the root
49 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
51 # FUSE options, see mount.fuse(8)
54 # Enable FUSE debugging (logs each FUSE request)
59 # Initialize the fuse connection
60 llfuse.init(operations, args.mountpoint, opts)
62 t = threading.Thread(None, lambda: llfuse.main())
65 # wait until the driver is finished initializing
66 operations.initlock.wait()
70 rc = subprocess.call(args.exec_args, shell=False)
72 sys.stderr.write('arv-mount: %s -- exec %s\n' % (str(e), args.exec_args))
74 except Exception as e:
75 sys.stderr.write('arv-mount: %s\n' % str(e))
77 subprocess.call(["fusermount", "-u", "-z", args.mountpoint])
82 # Initialize the fuse connection
83 llfuse.init(operations, args.mountpoint, opts)
86 with daemon.DaemonContext():
87 # Initialize the fuse connection
88 llfuse.init(operations, args.mountpoint, opts)