summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-04-16 23:57:13 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-17 13:44:05 +0530
commit169976dfafeb714f3c94b9a2f635f36759334b9c (patch)
treede434d2f87ade05072fcfcf4ce5171f5790c17d1 /libglusterfsclient
parentc9017ae0de2531342125eaf2a6aca3b9a251b16e (diff)
libglusterfsclient: Add utime API
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c47
1 files changed, 47 insertions, 0 deletions
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 <sys/vfs.h>
+#include <utime.h>
#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 = {
};