示例#1
0
 def getattr(self, path, fh=None):
     if syscalls.exists(path):
         return syscalls.getattr(path)
     resp = one_time_message(self.bootstrap, method='find', path=path)
     if 'errno' in resp:
         raise FuseOSError(resp['errno'])
     resp = one_time_message(tuple(resp['addr']),
                             method='getattr',
                             path=path)
     return resp['ret']
示例#2
0
 def write(self, path, data, offset, fh):
     if syscalls.exists(path):
         return syscalls.write(path, data, offset)
     resp = one_time_message(self.bootstrap, method='find', path=path)
     if 'errno' in resp:
         raise FuseOSError(resp['errno'])
     resp = one_time_message(tuple(resp['addr']),
                             method='write',
                             path=path,
                             data=data.decode(),
                             offset=offset)
     return resp['ret']
示例#3
0
 def read(self, path, size, offset, fh):
     if syscalls.exists(path):
         return syscalls.read(path, size, offset)
     resp = one_time_message(self.bootstrap, method='find', path=path)
     if 'errno' in resp:
         raise FuseOSError(resp['errno'])
     resp = one_time_message(tuple(resp['addr']),
                             method='read',
                             path=path,
                             size=size,
                             offset=offset)
     return resp['ret'].encode()
示例#4
0
 def open(self, path, flags):
     if syscalls.exists(path):
         try:
             return syscalls.open(path, flags)
         except OSError as e:
             raise FuseOSError(e.errno)
     resp = one_time_message(self.bootstrap, method='find', path=path)
     if 'errno' in resp:
         raise FuseOSError(resp['errno'])
     resp = one_time_message(tuple(resp['addr']),
                             method='open',
                             path=path,
                             flags=flags)
     return resp['ret']
示例#5
0
文件: peer.py 项目: rrokkam/difuse
 def __init__(self, mountpoint, bootstrap, host_port):
     os.system("mkdir -p %s" % syscalls.LOCALSTORAGE_DIR)
     sock = listening_socket(host_port)
     response = one_time_message(bootstrap, method='join', port=host_port)
     filesystem = Filesystem(bootstrap)
     thread = Thread(target=listen, args=(sock, ))
     thread.daemon = True
     thread.start()
     atexit.register(shutdown, bootstrap)
     fuse = FUSE(filesystem, mountpoint, foreground=True)
示例#6
0
 def unlink(self, path):
     if syscalls.exists(path):
         resp = one_time_message(self.bootstrap, method='unlink', path=path)
         if 'errno' in resp:
             raise FuseOSError(resp['errno'])
         syscalls.unlink(path)
         return
     resp = one_time_message(self.bootstrap, method='find', path=path)
     if 'errno' in resp:
         raise FuseOSError(resp['errno'])
     one_time_message(tuple(resp['addr']), method='unlink', path=path)
     one_time_message(self.bootstrap, method='unlink', path=path)
示例#7
0
 def readdir(self, path, fh):
     resp = one_time_message(self.bootstrap, method='readdir')
     return resp['ret']
示例#8
0
 def create(self, path, mode):
     resp = one_time_message(self.bootstrap, method='create', path=path)
     if 'errno' in resp:
         return 0
     syscalls.create(path, mode)
     return 0
示例#9
0
文件: peer.py 项目: rrokkam/difuse
def shutdown(bootstrap):
    one_time_message(bootstrap, method='leave')
    os.system("rm -rf %s" % syscalls.LOCALSTORAGE_DIR)