diff options
-rwxr-xr-x | libglusterfsclient/src/libglusterfsclient.c | 32 | ||||
-rwxr-xr-x | libglusterfsclient/src/libglusterfsclient.h | 7 |
2 files changed, 33 insertions, 6 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 449f38d1706..643add84e1b 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -3451,12 +3451,35 @@ out: } int -glusterfs_stat (glusterfs_handle_t handle, const char *path, struct stat *buf) +glusterfs_glh_stat (glusterfs_handle_t handle, const char *path, + struct stat *buf) { return __glusterfs_stat (handle, path, buf, LIBGF_DO_STAT); } int +glusterfs_stat (const char *path, struct stat *buf) +{ + struct vmp_entry *entry = NULL; + int op_ret = -1; + char *vpath = NULL; + + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out); + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out); + + entry = libgf_vmp_search_entry ((char *)path); + if (!entry) { + errno = ENODEV; + goto out; + } + + vpath = libgf_vmp_virtual_path (entry, path); + op_ret = glusterfs_glh_stat (entry->handle, vpath, buf); +out: + return op_ret; +} + +int glusterfs_lstat (glusterfs_handle_t handle, const char *path, struct stat *buf) { return __glusterfs_stat (handle, path, buf, LIBGF_DO_LSTAT); @@ -5214,11 +5237,12 @@ glusterfs_realpath (glusterfs_handle_t handle, const char *path, *dest = '\0'; /* posix_stat is implemented using lstat */ - ret = glusterfs_stat (handle, rpath, &stbuf); + ret = glusterfs_glh_stat (handle, rpath, &stbuf); if (ret == -1) { gf_log ("libglusterfsclient", GF_LOG_ERROR, - "glusterfs_stat returned -1 for path" - " (%s):(%s)", rpath, strerror (errno)); + "glusterfs_glh_stat returned -1 for" + " path (%s):(%s)", rpath, + strerror (errno)); goto err; } diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h index d46156e28db..ec707ad92fc 100755 --- a/libglusterfsclient/src/libglusterfsclient.h +++ b/libglusterfsclient/src/libglusterfsclient.h @@ -124,8 +124,11 @@ int glusterfs_close (glusterfs_file_t fd); int -glusterfs_stat (glusterfs_handle_t handle, const char *path, - struct stat *stbuf); +glusterfs_glh_stat (glusterfs_handle_t handle, const char *path, + struct stat *stbuf); + +int +glusterfs_stat (const char *path, struct stat *buf); int glusterfs_fstat (glusterfs_file_t fd, struct stat *stbuf); |