gfapi.py 文件源码

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

项目:gkube 作者: guohongze 项目源码 文件源码
def fgetxattr(self, key, size=0):
        """
        Retrieve the value of the extended attribute identified by key
        for the file.

        :param key: Key of extended attribute
        :param size: If size is specified as zero, we first determine the
                     size of xattr and then allocate a buffer accordingly.
                     If size is non-zero, it is assumed the caller knows
                     the size of xattr.
        :returns: Value of extended attribute corresponding to key specified.
        """
        if size == 0:
            size = api.glfs_fgetxattr(self.fd, key, None, size)
            if size < 0:
                err = ctypes.get_errno()
                raise OSError(err, os.strerror(err))

        buf = ctypes.create_string_buffer(size)
        rc = api.glfs_fgetxattr(self.fd, key, buf, size)
        if rc < 0:
            err = ctypes.get_errno()
            raise OSError(err, os.strerror(err))
        return buf.value[:rc]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号