From da5a33d206431f885a4dc029d79f693a27ef293a Mon Sep 17 00:00:00 2001 From: hchiramm Date: Wed, 9 Apr 2014 18:48:28 +0530 Subject: Add statvfs support This support will help other consumers to get the statvfs details. Change-Id: Iee4e84a515ff80f24add812ad6fcf84c992bf356 Signed-off-by: hchiramm --- glusterfs/gfapi.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) mode change 100644 => 100755 glusterfs/gfapi.py (limited to 'glusterfs/gfapi.py') diff --git a/glusterfs/gfapi.py b/glusterfs/gfapi.py old mode 100644 new mode 100755 index 80418a1..974aac5 --- 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' -- cgit