summaryrefslogtreecommitdiffstats
path: root/glusterfs/gfapi.py
diff options
context:
space:
mode:
authorhchiramm <hchiramm@redhat.com>2014-04-09 18:48:28 +0530
committerhchiramm <hchiramm@redhat.com>2014-05-02 18:05:29 +0530
commitda5a33d206431f885a4dc029d79f693a27ef293a (patch)
treee4804568c053d3e08adcab54320a614f38a3c285 /glusterfs/gfapi.py
parentbd683d93cb8d967f761d53f7a6b4243eb8eaedea (diff)
Add statvfs support
This support will help other consumers to get the statvfs details. Change-Id: Iee4e84a515ff80f24add812ad6fcf84c992bf356 Signed-off-by: hchiramm <hchiramm@redhat.com>
Diffstat (limited to 'glusterfs/gfapi.py')
-rwxr-xr-x[-rw-r--r--]glusterfs/gfapi.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/glusterfs/gfapi.py b/glusterfs/gfapi.py
index 80418a1..974aac5 100644..100755
--- a/glusterfs/gfapi.py
+++ b/glusterfs/gfapi.py
@@ -60,6 +60,23 @@ class Stat (ctypes.Structure):
]
+class Statvfs (ctypes.Structure):
+ _fields_ = [
+ ("f_bsize", ctypes.c_ulong),
+ ("f_frsize", ctypes.c_ulong),
+ ("f_blocks", ctypes.c_ulong),
+ ("f_bfree", ctypes.c_ulong),
+ ("f_bavail", ctypes.c_ulong),
+ ("f_files", ctypes.c_ulong),
+ ("f_ffree", ctypes.c_ulong),
+ ("f_favail", ctypes.c_ulong),
+ ("f_fsid", ctypes.c_ulong),
+ ("f_flag", ctypes.c_ulong),
+ ("f_namemax", ctypes.c_ulong),
+ ("__f_spare", ctypes.c_int * 6),
+ ]
+
+
class Dirent (ctypes.Structure):
_fields_ = [
("d_ino", ctypes.c_ulong),
@@ -518,6 +535,18 @@ class Volume(object):
raise OSError(err, os.strerror(err))
return s
+ def statvfs(self, path):
+ """
+ To get status information about the file system that contains the file
+ named by the path argument.
+ """
+ s = Statvfs()
+ rc = api.glfs_statvfs(self.fs, path, ctypes.byref(s))
+ if rc < 0:
+ err = ctypes.get_errno()
+ raise OSError(err, os.strerror(err))
+ return s
+
def symlink(self, source, link_name):
"""
Create a symbolic link 'link_name' which points to 'source'