3 from arvados.fuse import *
8 if __name__ == '__main__':
9 # Handle command line parameters
10 parser = argparse.ArgumentParser(
11 description='''Mount Keep data under the local filesystem. By default, if neither
12 --collection or --tags is specified, this mounts as a virtual directory
13 under which all Keep collections are available as subdirectories named
14 with the Keep locator; however directories will not be visible to 'ls'
15 until a program tries to access them.''',
17 Note: When using the --exec feature, you must either specify the
18 mountpoint before --exec, or mark the end of your --exec arguments
21 parser.add_argument('mountpoint', type=str, help="""Mount point.""")
22 parser.add_argument('--collection', type=str, help="""Mount only the specified collection at the mount point.""")
23 parser.add_argument('--tags', action='store_true', help="""Mount as a virtual directory consisting of subdirectories representing tagged
24 collections on the server.""")
25 parser.add_argument('--debug', action='store_true', help="""Debug mode""")
26 parser.add_argument('--exec', type=str, nargs=argparse.REMAINDER,
27 dest="exec_args", metavar=('command', 'args', '...', '--'),
28 help="""Mount, run a command, then unmount and exit""")
30 args = parser.parse_args()
32 # Create the request handler
33 operations = Operations(os.getuid(), os.getgid())
36 api = arvados.api('v1')
37 e = operations.inodes.add_entry(TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api))
38 elif args.collection != None:
39 # Set up the request handler with the collection at the root
40 e = operations.inodes.add_entry(CollectionDirectory(llfuse.ROOT_INODE, operations.inodes, args.collection))
42 # Set up the request handler with the 'magic directory' at the root
43 operations.inodes.add_entry(MagicDirectory(llfuse.ROOT_INODE, operations.inodes))
45 # FUSE options, see mount.fuse(8)
48 # Enable FUSE debugging (logs each FUSE request)
52 # Initialize the fuse connection
53 llfuse.init(operations, args.mountpoint, opts)
56 t = threading.Thread(None, lambda: llfuse.main())
59 # wait until the driver is finished initializing
60 operations.initlock.wait()
64 rc = subprocess.call(args.exec_args, shell=False)
66 sys.stderr.write('arv-mount: %s -- exec %s\n' % (str(e), args.exec_args))
68 except Exception as e:
69 sys.stderr.write('arv-mount: %s\n' % str(e))
71 subprocess.call(["fusermount", "-u", "-z", args.mountpoint])