summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-05-05 15:57:27 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-05 17:02:00 +0530
commitb12fde2b06c4701970201aaebc7f45a8b964812c (patch)
tree4557c31e801cb2bc27f0e2b42e063ea3f323e978 /libglusterfsclient/src
parent6fdf8f4c7d5cced776c925052eb8a81c332a3573 (diff)
libglusterfsclient: Add VMP-based rename
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c42
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h7
2 files changed, 47 insertions, 2 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 46208a8ee35..9a8ead505d4 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -4759,8 +4759,8 @@ out:
}
int
-glusterfs_rename (glusterfs_handle_t handle, const char *oldpath,
- const char *newpath)
+glusterfs_glh_rename (glusterfs_handle_t handle, const char *oldpath,
+ const char *newpath)
{
int32_t op_ret = -1;
loc_t oldloc = {0, }, newloc = {0, };
@@ -4825,6 +4825,44 @@ out:
return op_ret;
}
+
+int
+glusterfs_rename (const char *oldpath, const char *newpath)
+{
+ int op_ret = -1;
+ struct vmp_entry *new = NULL;
+ struct vmp_entry *old = NULL;
+ char *oldvpath = NULL;
+ char *newvpath = NULL;
+
+ GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, oldpath, out);
+ GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, newpath, out);
+
+ old = libgf_vmp_search_entry ((char *)oldpath);
+ if (!old) {
+ errno = ENODEV;
+ goto out;
+ }
+
+ new = libgf_vmp_search_entry ((char *)newpath);
+ if (!new) {
+ errno = ENODEV;
+ goto out;
+ }
+
+ if (old != new) {
+ errno = EXDEV;
+ goto out;
+ }
+
+ oldvpath = libgf_vmp_virtual_path (old, oldpath);
+ newvpath = libgf_vmp_virtual_path (new, newpath);
+ op_ret = glusterfs_glh_rename (old->handle, oldvpath, newvpath);
+
+out:
+ return op_ret;
+}
+
int32_t
libgf_client_utimens_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h
index defbec8786d..d4f0c6c6ae7 100755
--- a/libglusterfsclient/src/libglusterfsclient.h
+++ b/libglusterfsclient/src/libglusterfsclient.h
@@ -351,6 +351,13 @@ glusterfs_glh_readlink (glusterfs_handle_t handle, const char *path, char *buf,
ssize_t
glusterfs_readlink (const char *path, char *buf, size_t bufsize);
+
+int
+glusterfs_glh_rename (glusterfs_handle_t handle, const char *oldpath,
+ const char *newpath);
+
+int
+glusterfs_rename (const char *oldpath, const char *newpath);
/* FIXME: review the need for these apis */
/* added for log related initialization in booster fork implementation */
void