From 972c24f8b11d5a3e7e6fc341453d9733b2bb47b5 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Mon, 30 May 2016 17:42:15 +0530 Subject: 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 --- gluster/api.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'gluster/api.py') 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)) -- cgit