From b12fde2b06c4701970201aaebc7f45a8b964812c Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 5 May 2009 15:57:27 +0530 Subject: libglusterfsclient: Add VMP-based rename Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 42 +++++++++++++++++++++++++++-- libglusterfsclient/src/libglusterfsclient.h | 7 +++++ 2 files changed, 47 insertions(+), 2 deletions(-) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 46208a8ee..9a8ead505 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 defbec878..d4f0c6c6a 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 -- cgit