From de2192ea754883ea6ae643f63c44c2cbeb20f981 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Mon, 20 Apr 2009 12:33:43 -0700 Subject: libglusterfsclient: Add VMP-based link Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 39 ++++++++++++++++++++++++++++- libglusterfsclient/src/libglusterfsclient.h | 6 +++++ 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'libglusterfsclient/src') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 676fd8a64..aab93181f 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -4399,7 +4399,7 @@ out: } int -glusterfs_link (glusterfs_handle_t handle, const char *oldpath, +glusterfs_glh_link (glusterfs_handle_t handle, const char *oldpath, const char *newpath) { libglusterfs_client_ctx_t *ctx = handle; @@ -4458,6 +4458,43 @@ out: return op_ret; } +int +glusterfs_link (const char *oldpath, const char *newpath) +{ + struct vmp_entry *oldentry = NULL; + struct vmp_entry *newentry = NULL; + char *oldvpath = NULL; + char *newvpath = NULL; + int op_ret = -1; + + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, oldpath, out); + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, newpath, out); + + oldentry = libgf_vmp_search_entry ((char *)oldpath); + if (!oldentry) { + errno = ENODEV; + goto out; + } + + newentry = libgf_vmp_search_entry ((char *)newpath); + if (!newentry) { + errno = ENODEV; + goto out; + } + + /* Cannot hard link across glusterfs mounts. */ + if (newentry != oldentry) { + errno = EXDEV; + goto out; + } + + newvpath = libgf_vmp_virtual_path (newentry, newpath); + oldvpath = libgf_vmp_virtual_path (oldentry, oldpath); + op_ret = glusterfs_glh_link (newentry->handle, oldvpath, newvpath); +out: + return op_ret; +} + int32_t libgf_client_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct statvfs *buf) diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h index 377459c4d..97ab3bc34 100755 --- a/libglusterfsclient/src/libglusterfsclient.h +++ b/libglusterfsclient/src/libglusterfsclient.h @@ -277,6 +277,12 @@ glusterfs_glh_opendir (glusterfs_handle_t handle, const char *path); glusterfs_dir_t glusterfs_opendir (const char *path); +int +glusterfs_glh_link (glusterfs_handle_t handle, const char *oldpath, + const char *newpath); + +int +glusterfs_link (const char *oldpath, const char *newpath); /* FIXME: review the need for these apis */ /* added for log related initialization in booster fork implementation */ void -- cgit