fs.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Marty 作者: NaPs 项目源码 文件源码
def getattr(self, inode, ctx=None):
        attrs = self.inodes.get(inode)
        if attrs is None:
            raise llfuse.FUSEError(errno.ENOENT)  # FIXME

        if attrs.get('type') == 'tree':
            mode_filetype = stat.S_IFDIR
        elif attrs.get('type') == 'blob':
            mode_filetype = stat.S_IFREG
        elif attrs.get('filetype') == 'link':
            mode_filetype = stat.S_IFLNK
        elif attrs.get('filetype') == 'fifo':
            mode_filetype = stat.S_IFIFO
        else:
            raise llfuse.FUSEError(errno.ENOENT)  # FIXME

        entry = llfuse.EntryAttributes()
        entry.st_mode = mode_filetype | attrs.get('mode', MartyFSHandler.DEFAULT_MODE)

        if attrs.get('type') == 'blob' and 'ref' in attrs:
            entry.st_size = self.storage.size(attrs['ref'])
        else:
            entry.st_size = 0

        stamp = int(1438467123.985654 * 1e9)
        entry.st_atime_ns = stamp
        entry.st_ctime_ns = stamp
        entry.st_mtime_ns = stamp
        entry.st_gid = 0
        entry.st_uid = 0
        entry.st_ino = inode

        return entry
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号