def setxattr(self, path, key, value, flags=0):
"""
Set extended attribute of the path.
:param path: Path to file or directory.
:param key: The key of extended attribute.
:param value: The valiue of extended attribute.
:param flags: Possible values are 0 (default), 1 and 2
0: xattr will be created if it does not exist, or the
value will be replaced if the xattr exists.
1: Perform a pure create, which fails if the named
attribute already exists.
2: Perform a pure replace operation, which fails if the
named attribute does not already exist.
"""
ret = api.glfs_setxattr(self.fs, path, key, value, len(value), flags)
if ret < 0:
err = ctypes.get_errno()
raise OSError(err, os.strerror(err))
评论列表
文章目录