summaryrefslogtreecommitdiffstats
path: root/gluster/api.py
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2016-05-30 17:42:15 +0530
committerPrashanth Pai <ppai@redhat.com>2016-06-01 12:42:25 +0530
commit972c24f8b11d5a3e7e6fc341453d9733b2bb47b5 (patch)
treed38c5cdf723c1a029455147ddbb19cf126c3186e /gluster/api.py
parent123c2b7dc51d012f6d2924f680eeec748187a300 (diff)
Implement os.utime() like API and zerofill
This patch: * Implements Volume.utime() which is very similar to os.utime() present in Python. https://docs.python.org/2/library/os.html#os.utime * Implements File.zerofill() which exposes glfs_zerofill. * Fixes function prototype of fallocate and discard. Adds functional tests for the same. Change-Id: Icb8d3a571998c31d6bf9b139ca253af59f6fc3f4 Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'gluster/api.py')
-rwxr-xr-xgluster/api.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/gluster/api.py b/gluster/api.py
index 7163076..3fd9d91 100755
--- a/gluster/api.py
+++ b/gluster/api.py
@@ -115,6 +115,13 @@ class Dirent (ctypes.Structure):
]
+class Timespec (ctypes.Structure):
+ _fields_ = [
+ ('tv_sec', ctypes.c_long),
+ ('tv_nsec', ctypes.c_long)
+ ]
+
+
# Here is the reference card of libgfapi library exported
# apis with its different versions.
#
@@ -474,12 +481,22 @@ glfs_getcwd = gfapi_prototype('glfs_getcwd', ctypes.c_char_p,
ctypes.c_char_p,
ctypes.c_size_t)
+glfs_fallocate = gfapi_prototype('glfs_fallocate', ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_int,
+ ctypes.c_size_t)
+
+glfs_discard = gfapi_prototype('glfs_discard', ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_int,
+ ctypes.c_size_t)
-# TODO: # discard and fallocate fails with "AttributeError: /lib64/libgfapi.so.0: undefined symbol: glfs_discard", # noqa
-# for time being, using it from api.* # noqa
-# glfs_discard = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_size_t)(('glfs_discard', client)) # noqa
-# _glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t) # noqa
-# (('glfs_fallocate', client)) # noqa
+glfs_zerofill = gfapi_prototype('glfs_zerofill', ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_int,
+ ctypes.c_size_t)
-# glfs_discard = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_size_t)(('glfs_discard', client)) # noqa
-# glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t)(('glfs_fallocate', client)) # noqa
+glfs_utimens = gfapi_prototype('glfs_utimens', ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_char_p,
+ ctypes.POINTER(Timespec))