Beispiel #1
0
 def readdir(self, path, fh):
     
     print '#################'
     print '##### READ DIR  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     # FIXME Translation "." e ".."
     context = ""
     idObjDir = self.cache.lookup(options.root_bucket,path)
     lista = self.cache.getObjectList(options.root_bucket, idObjDir, uid, gid, context)
     propDir = self.cache.getProperties(options.root_bucket, idObjDir,OF.PROPERTY_OBJECT,uid,gid,context)
     dizio = dict()
     if len(lista) != 0:
         for elem in lista :
             elem = '/'+str(elem)
             if path != '/':
                 pathn = path+elem
                 idObj = self.cache.lookup(options.root_bucket,pathn)
             else:
                 idObj = self.cache.lookup(options.root_bucket,path)
             prop = self.cache.getProperties(options.root_bucket, idObj,OF.PROPERTY_OBJECT,uid,gid,context)
             dizio[elem] = dict(st_mode=(prop['mode']), st_nlink=prop['read_counter'],\
                                st_size=prop['size'], st_ctime=prop['creation_date'], \
                                st_mtime=prop['last_modify'], st_atime=time())
             dizio['/.']=dict(st_mode=(propDir['mode']), st_nlink=propDir['read_counter'],\
                      st_size=propDir['size'], st_ctime=propDir['creation_date'], \
                      st_mtime=propDir['last_modify'], st_atime=time())
     print '#############'
     print dizio
     print '###########'
     return ['..'] +[x[1:] for x in dizio if x != '/']
Beispiel #2
0
    def getattr(self, path, fh=None):
        print '#################'
        print '##### GET-ATT ###'
        print '#################'

        uid, gid, pid = fuse_get_context()
        context = ""
        
        ## IL PROBLEMA su MAC e il lookup non il raise, l'unica e fare come fa lui
        ## e quindi aver la lista e controllare li.. eliminando il lookup
        
        try :
            print 'PATH',path
            idObj = self.cache.lookup(options.root_bucket,path)
            if idObj == None or idObj == 'null':
                raise FuseOSError(ENOENT) 
            print 'FH', idObj
            '''prop = self.cache.getProperties(options.root_bucket, idObj, OF.PROPERTY_OBJECT, uid, gid, context)
            self.files[path] = dict(st_mode=(prop['mode']), st_nlink=prop['read_counter'],\
                st_size=prop['size'], st_ctime=prop['creation_date'], st_mtime=prop['last_modify'], st_atime=time())
            '''
            #prop = self.cache.getProperties(options.root_bucket, idObj, OF.PROPERTY_OBJECT, uid, gid, context)
        except :
            raise FuseOSError(ENOENT)    
        
        st = self.files[path]
        return st
Beispiel #3
0
 def read(self, path, size, offset, fh):    
     
     print '#################'
     print '##### READ  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     idObj = self.cache.lookup(options.root_bucket, path)
     stream = self.cache.load(options.root_bucket, idObj, uid, gid, context)
     return self.data[path][offset:offset + size]    
Beispiel #4
0
 def unlink(self, path):
     
     print '#################'
     print '##### unlink  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     idObj = self.cache.lookup(options.root_bucket,path)
     self.cache.remove(options.root_bucket,idObj, uid, gid, context) 
     self.cache.removeObject(options.root_bucket,idObj, uid, gid, context)        
     
     self.files.pop(path)
Beispiel #5
0
 def setxattr(self, path, name, value, options, position=0):
     
     print '#################'
     print '##### SETxattr  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     # Options ? / Positions ?
     idObj = self.cache.lookup(options.root_bucket,path)
     self.cache.setProperty(idObj, OF.PROPERTY_USER+name, value, uid, gid, context)
     
     attrs = self.files[path].setdefault('attrs', {})
     attrs[name] = value
Beispiel #6
0
 def rmdir(self, path):
     
     
     print '#################'
     print '##### RMDIR  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     idObj = self.cache.lookup(options.root_bucket,path)
     #self.cache.remove(options.root_bucket,idObj,uid,gid,context)
     self.cache.removeObject(options.root_bucket, idObj, uid, gid, context)
     self.files.pop(path)
     self.files['/']['st_nlink'] -= 1
Beispiel #7
0
 def open(self, path, flags):
     
     print '#################'
     print '##### OPEN  ###'
     print flags
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     idObj = self.cache.lookup(options.root_bucket, path)
     stream = self.cache.load(options.root_bucket, idObj, uid, gid, context)
     #self.cache.open(options.root_bucket, path, flags, uid, gid, context)
     self.fd += 1
     return self.fd
Beispiel #8
0
    def chmod(self, path, mode):
        
        print '#################'
        print '##### CH MOD  ###'
        print '#################'

        uid, gid, pid = fuse_get_context()
        idObj = self.cache.lookup(options.root_bucket,path) 
        context = ""     
        prop = self.cache.getProperties(options.root_bucket, idObj, OF.PROPERTY_OBJECT, uid, gid, context)
        prop.mode = mode
        self.cache.setAttributes(options.root_bucket, idObj, OF.PROPERTY_OBJECT, prop, uid, gid, context)
        
        self.files[path]['st_mode'] &= 0770000
        self.files[path]['st_mode'] |= prop.mode
        return 0
Beispiel #9
0
 def rename(self, old, new):
     
     print '#################'
     print '##### RENAME  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     idObj_old = self.cache.lookup(options.root_bucket,old)
     prop_old = self.cache.getProperties(options.root_bucket, idObj_old, OF.PROPERTY_OBJECT, uid, gid, context)
     #self.cache.removeObject(options.root_bucket, idObj_old, uid, gid, context)
     #self.cache.remove(options.root_bucket,idObj,uid,gid,context)
     
     prop_old['object_name'] = new
     self.cache.removeObject(options.root_bucket, idObj_old, uid, gid, context)
     self.cache.setAttributesFromNew(options.root_bucket, idObj_old, prop_old, uid, gid, context)
     self.files[new] = self.files.pop(old)
Beispiel #10
0
    def removexattr(self, path, name):
        
        print '#################'
        print '##### REMOVE XATTr ###'
        print '#################'

        uid, gid, pid = fuse_get_context()
        context = ""
        
        idObj = self.cache.lookup(options.root_bucket,path)
        attrs = self.files[path].get('attrs', {})
        try:
            del attrs[name]
            self.cache.delProperty(idObj, OF.PROPERTY_USER+name, uid, gid, context)
        except KeyError:
            pass        # Should return ENOATTR
Beispiel #11
0
 def chown(self, path, uid, gid):
     
     print '#################'
     print '##### CH OWN  ###'
     print '#################'
     #uid and gid correct? are the new or old one ?
     old_uid, old_gid, pid = fuse_get_context()
     idObj = self.cache.lookup(options.root_bucket,path) 
     context = ""     
     prop = self.cache.getProperties(options.root_bucket, idObj, OF.PROPERTY_OBJECT, old_uid, old_gid, context)
     if gid & uid:
         prop.mode = uid+gid+prop.mode[-1]
     elif uid:
         prop.mode = uid+prop.mode[1:]
     self.cache.setAttributes(options.root_bucket, idObj, OF.PROPERTY_OBJECT, prop, uid, gid, context)
     
     self.files[path]['st_uid'] = uid
     self.files[path]['st_gid'] = gid
Beispiel #12
0
 def mkdir(self, path, mode):
     
     print '#################'
     print '##### MKDIR  ###'
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     
     st_mode = (S_IFDIR | mode)
     self.cache.createObject(options.root_bucket,path, OF.TYPE_DIR, uid, gid, st_mode, context)
     
     idObj = self.cache.lookup(options.root_bucket, path)
     prop = self.cache.getProperties(options.root_bucket, idObj,OF.PROPERTY_OBJECT,uid,gid,context)
     self.files[path] = dict(st_mode=(S_IFDIR | mode), st_nlink=prop['read_counter'],\
             st_size=prop['size'], st_ctime=prop['creation_date'], st_mtime=prop['last_modify'], st_atime=time())
     self.files['/']['st_nlink'] += 1
     
     print sys.exc_info()
Beispiel #13
0
 def create(self, path, mode):
     
     print '#################'
     print '##### CREATE  ###'
     print path
     print '#################'
     uid, gid, pid = fuse_get_context()
     context = ""
     st_mode=(S_IFREG | mode)
     self.cache.createObject(options.root_bucket,path, OF.TYPE_FILE, uid, gid, st_mode, context)
     
     print '#################'
     print OF.TYPE_FILE
     print '#################'
     
     self.files[path] = dict(st_mode=(S_IFREG | mode), st_nlink=1,
        st_size=0, st_ctime=time(), st_mtime=time(), st_atime=time())
     self.fd += 1
     #FIXME idObj need a number 
     return self.fd 
Beispiel #14
0
 def write(self, path, data_handler, offset, fh):
     print '#################'
     print '##### WRITE  ###'
     print '#################'
     uid, gid, context = fuse_get_context()
     xattr = self.listxattr(path)
     object_acl = S3ACP.ACL_FULL_CONTROL
     acp = ACP()
     grant = Grant() 
     grant.uid = uid  
     grant.permission = ACPHelper.s3AclToPerm(object_acl)
     grantList = [grant]
     acp.setByGrants(grantList)
     storage_class="STANDARD"
     content_type=None
     self.cache.write(options.root_bucket, path, uid, gid, context, storage_class, object_acl ,content_type, xattr,  data_handler)
     
     self.data[path] = self.data[path][:offset] + data_handler
     self.files[path]['st_size'] = len(self.data[path])
     return len(data_handler)