[ARVADOS] updated: d165639ac5760713b872242dd1c2eb54c34a0ffd
git at public.curoverse.com
git at public.curoverse.com
Tue Feb 18 16:07:43 EST 2014
Summary of changes:
sdk/python/arvados/keep.py | 20 ++++++++-------
sdk/python/bin/arv-mount2 | 58 +++++++++++++++++++++++++++----------------
2 files changed, 47 insertions(+), 31 deletions(-)
via d165639ac5760713b872242dd1c2eb54c34a0ffd (commit)
from 61e04bd283799308728e9c0bf085db799bd9cbc2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit d165639ac5760713b872242dd1c2eb54c34a0ffd
Author: peter <peter at peter.shell.qr1hi.arvadosapi.com>
Date: Tue Feb 18 21:07:37 2014 +0000
Fuse driver works for mounting collections and reading files. Tested with jlake collection, spot checked m5dsum values of several files which matched the md5sum catalog in the jlake collection.
diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index 5f9a6d9..fe62eb7 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -146,15 +146,17 @@ class KeepClient(object):
def shuffled_service_roots(self, hash):
if self.service_roots == None:
self.lock.acquire()
- keep_disks = api().keep_disks().list().execute()['items']
- roots = (("http%s://%s:%d/" %
- ('s' if f['service_ssl_flag'] else '',
- f['service_host'],
- f['service_port']))
- for f in keep_disks)
- self.service_roots = sorted(set(roots))
- logging.debug(str(self.service_roots))
- self.lock.release()
+ try:
+ keep_disks = api().keep_disks().list().execute()['items']
+ roots = (("http%s://%s:%d/" %
+ ('s' if f['service_ssl_flag'] else '',
+ f['service_host'],
+ f['service_port']))
+ for f in keep_disks)
+ self.service_roots = sorted(set(roots))
+ logging.debug(str(self.service_roots))
+ finally:
+ self.lock.release()
seed = hash
pool = self.service_roots[:]
pseq = []
diff --git a/sdk/python/bin/arv-mount2 b/sdk/python/bin/arv-mount2
index 74683af..c349bdb 100755
--- a/sdk/python/bin/arv-mount2
+++ b/sdk/python/bin/arv-mount2
@@ -51,13 +51,18 @@ class FileHandle(object):
class Operations(llfuse.Operations):
- def __init__(self, collection):
+ def __init__(self, collection, uid, gid):
super(Operations, self).__init__()
#self.api = arvados.api('v1')
# dict of inodes to collection entry
self._inodes = {}
+ self.uid = uid
+ self.gid = gid
+
+ #print "root_parent", root_parent, "llfuse.ROOT_INODE", llfuse.ROOT_INODE
+
i = llfuse.ROOT_INODE
self.root = Directory(i, i)
self._inodes[i] = self.root
@@ -94,19 +99,21 @@ class Operations(llfuse.Operations):
entry.st_mode = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
if isinstance(e, Directory):
- entry.st_mode |= stat.S_IFDIR
+ entry.st_mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IFDIR
else:
entry.st_mode |= stat.S_IFREG
entry.st_nlink = 1
- entry.st_uid = 0
- entry.st_gid = 0
+ entry.st_uid = self.uid
+ entry.st_gid = self.gid
entry.st_rdev = 0
entry.st_size = e.size()
- entry.st_blksize = 512
- entry.st_blocks = 1
+ entry.st_blksize = 1024
+ entry.st_blocks = e.size()/1024
+ if e.size()/1024 != 0:
+ entry.st_blocks += 1
entry.st_atime = 0
entry.st_mtime = 0
entry.st_ctime = 0
@@ -147,19 +154,21 @@ class Operations(llfuse.Operations):
return fh
def read(self, fh, off, size):
+ #print "read", fh, off, size
if fh in self._filehandles:
handle = self._filehandles[fh]
else:
raise llfuse.FUSEError(errno.EBADF)
- with llfuse.lock_released:
- try:
+ try:
+ with llfuse.lock_released:
return handle.entry.reader.readfrom(off, size)
- except:
- raise llfuse.FUSEError(errno.EIO)
+ except:
+ raise llfuse.FUSEError(errno.EIO)
def release(self, fh):
- del self._filehandles[fh]
+ if fh in self._filehandles:
+ del self._filehandles[fh]
def opendir(self, inode):
#print "opendir: inode", inode
@@ -174,7 +183,11 @@ class Operations(llfuse.Operations):
fh = self._filehandles_counter
self._filehandles_counter += 1
- self._filehandles[fh] = FileHandle(fh, [('.', p), ('..', self._inodes[p.parent])] + list(p.entries.items()))
+ if p.parent in self._inodes:
+ parent = self._inodes[p.parent]
+ else:
+ parent = None
+ self._filehandles[fh] = FileHandle(fh, [('.', p), ('..', parent)] + list(p.entries.items()))
return fh
def readdir(self, fh, off):
@@ -199,22 +212,23 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Mount Keep data under the local filesystem.')
- parser.add_argument('mountpoint', type=str,
- help="""Mount point.""")
-
- parser.add_argument('--collection', type=str, action='append',
- help="""Collection locator""")
+ parser.add_argument('mountpoint', type=str, help="""Mount point.""")
+ parser.add_argument('--collection', type=str, required=True, help="""Collection locator""")
+ parser.add_argument('--debug', action='store_true', help="""Debug mode""")
args = parser.parse_args()
# for testing only!
- manifest = open('/home/peter/work/arvados/sdk/python/testdata/jlake_manifest').read()
-
- operations = Operations(arvados.CollectionReader(manifest))
+ #manifest = open('/home/peter/arvados/sdk/python/testdata/jlake_manifest').read()
+ #operations = Operations(arvados.CollectionReader(manifest), os.getuid(), os.getgid())
- #operations = Operations(arvados.CollectionReader(arvados.Keep.get(args.collection)))
+ operations = Operations(arvados.CollectionReader(arvados.Keep.get(args.collection)), os.getuid(), os.getgid())
- llfuse.init(operations, args.mountpoint, [ b'fsname=keepfuse', 'debug' ])
+ opts = []
+ if args.debug:
+ opts += ['debug']
+
+ llfuse.init(operations, args.mountpoint, opts)
try:
llfuse.main()
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list