summaryrefslogtreecommitdiffstats
path: root/glusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'glusterfs')
-rwxr-xr-xglusterfs/api.py9
-rwxr-xr-xglusterfs/gfapi.py27
2 files changed, 36 insertions, 0 deletions
diff --git a/glusterfs/api.py b/glusterfs/api.py
index 6bc19ea..1ecc34a 100755
--- a/glusterfs/api.py
+++ b/glusterfs/api.py
@@ -126,6 +126,15 @@ glfs_stat = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p,
glfs_fstat = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(
Stat))(('glfs_fstat', client))
+glfs_chmod = ctypes.CFUNCTYPE(ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_char_p,
+ ctypes.c_ushort)(('glfs_chmod', client))
+
+glfs_fchmod = ctypes.CFUNCTYPE(ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_ushort)(('glfs_fchmod', client))
+
glfs_chown = ctypes.CFUNCTYPE(ctypes.c_int,
ctypes.c_void_p,
ctypes.c_char_p,
diff --git a/glusterfs/gfapi.py b/glusterfs/gfapi.py
index fc6bb27..2d51a96 100755
--- a/glusterfs/gfapi.py
+++ b/glusterfs/gfapi.py
@@ -65,6 +65,19 @@ class File(object):
raise OSError(err, os.strerror(err))
return ret
+ def fchmod(self, mode):
+ """
+ Change this file's mode
+
+ :param mode: new mode
+ :returns: 0 if success, raises OSError if it fails
+ """
+ ret = api.glfs_fchmod(self.fd, mode)
+ if ret < 0:
+ err = ctypes.get_errno()
+ raise OSError(err, os.strerror(err))
+ return ret
+
def fchown(self, uid, gid):
"""
Change this file's owner and group id
@@ -196,6 +209,20 @@ class Volume(object):
def mount(self):
return api.glfs_init(self.fs)
+ def chmod(self, path, mode):
+ """
+ Change mode of path
+
+ :param path: the item to be modified
+ :mode: new mode
+ :returns: 0 if success, raises OSError if it fails
+ """
+ ret = api.glfs_chmod(self.fs, path, mode)
+ if ret < 0:
+ err = ctypes.get_errno()
+ raise OSError(err, os.strerror(err))
+ return ret
+
def chown(self, path, uid, gid):
"""
Change owner and group id of path