From 169976dfafeb714f3c94b9a2f635f36759334b9c Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 16 Apr 2009 23:57:13 -0700 Subject: libglusterfsclient: Add utime API Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'libglusterfsclient/src/libglusterfsclient.c') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 011c136e47a..ede3324d705 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -41,6 +41,7 @@ #include "compat.h" #include "compat-errno.h" #include +#include #define LIBGF_XL_NAME "libglusterfsclient" #define LIBGLUSTERFS_INODE_TABLE_LRU_LIMIT 1000 //14057 @@ -4290,6 +4291,52 @@ out: return op_ret; } +int +glusterfs_utime (glusterfs_handle_t handle, const char *path, + const struct utimbuf *buf) +{ + int32_t op_ret = -1; + loc_t loc = {0, }; + libglusterfs_client_ctx_t *ctx = handle; + struct timespec ts[2] = {{0,},{0,}}; + char *name = NULL; + + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, ctx, out); + GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO (LIBGF_XL_NAME, path, out); + + loc.path = strdup (path); + op_ret = libgf_client_path_lookup (&loc, ctx, 1); + if (op_ret == -1) { + gf_log ("libglusterfsclient", GF_LOG_ERROR, + "path lookup failed for (%s)", path); + goto out; + } + + name = strdup (path); + op_ret = libgf_client_loc_fill (&loc, ctx, 0, loc.parent->ino, + basename (name)); + if (op_ret == -1) { + gf_log ("libglusterfsclient", GF_LOG_ERROR, + "libgf_client_loc_fill returned -1," + " returning EINVAL"); + errno = EINVAL; + goto out; + } + + ts[0].tv_sec = buf->actime; + ts[0].tv_nsec = 0; + + ts[1].tv_sec = buf->modtime; + ts[1].tv_nsec = 0; + + op_ret = libgf_client_utimens (ctx, &loc, ts); +out: + if (name) + FREE (name); + libgf_client_loc_wipe (&loc); + return op_ret; +} + static struct xlator_fops libgf_client_fops = { }; -- cgit