def read(self, path, size, offset, fh): self.log.debug("Entering read. Locals: %r" % locals()) fs_path = map_to_fs(self.sess, path) self.log.info('Reading local file %r' % fs_path) fptr = open(fs_path) fptr.seek(offset, 0) data = fptr.read(size) fptr.close() return data
def read(self, path, size, offset, fh): self.log.debug("Entering read. Locals: %r" % locals()) fs_path = map_to_fs(self.sess, path) self.log.info('Reading local file %r' % fs_path) fptr = open(fs_path) fptr.seek(offset, 0) data = fptr.read(size) fptr.close() return data
def getattr(self, path, fh=None): self.log.debug("Entering getattr. Locals: %r" % locals()) if path.startswith('/.Trash'): raise FuseOSError(ENOENT) if path != "/": fs_path = map_to_fs(self.sess, path) else: fs_path = None self.log.debug( 'Mapped %r to %r' % (path, fs_path) ) try: if fs_path: self.log.debug("Node maps to filesystem => query system stat") if not exists(fs_path): raise FuseOSError(ENOENT) node = by_uri(self.sess, fs_path) if node: stat = os.lstat(fs_path) return dict((key, getattr(stat, key)) for key in ('st_atime', 'st_ctime', 'st_gid', 'st_mode', 'st_mtime', 'st_nlink', 'st_size', 'st_uid')) return dict( st_mode = (S_IFDIR | 0755), st_ctime = time(), st_mtime = time(), st_atime = time(), st_nlink = 2 ) else: return dict( st_mode = (S_IFDIR | 0755), st_ctime = time(), st_mtime = time(), st_atime = time(), st_nlink = 2 ) except Exception, ex: self.log.exception(ex)
def getattr(self, path, fh=None): self.log.debug("Entering getattr. Locals: %r" % locals()) if path.startswith('/.Trash'): raise FuseOSError(ENOENT) if path != "/": fs_path = map_to_fs(self.sess, path) else: fs_path = None self.log.debug('Mapped %r to %r' % (path, fs_path)) try: if fs_path: self.log.debug("Node maps to filesystem => query system stat") if not exists(fs_path): raise FuseOSError(ENOENT) node = by_uri(self.sess, fs_path) if node: stat = os.lstat(fs_path) return dict((key, getattr(stat, key)) for key in ('st_atime', 'st_ctime', 'st_gid', 'st_mode', 'st_mtime', 'st_nlink', 'st_size', 'st_uid')) return dict(st_mode=(S_IFDIR | 0755), st_ctime=time(), st_mtime=time(), st_atime=time(), st_nlink=2) else: return dict(st_mode=(S_IFDIR | 0755), st_ctime=time(), st_mtime=time(), st_atime=time(), st_nlink=2) except Exception, ex: self.log.exception(ex)