summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-10-30 03:40:09 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-30 04:28:06 -0700
commitc618b7bc59ad46e8b9d1eed0383184336382aec7 (patch)
treedb78ecdec591d2257360d989bf52b67c06288fc4 /libglusterfsclient
parent7e77e4c026f48137b2320ad07e9834a7b0cddc45 (diff)
booster, libglusterfsclient: Support samba specific relative paths
Signed-off-by: Shehjar Tikoo <shehjart@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 158 (libglusterfsclient: Applications are restricted to using absolute paths) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=158
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c337
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h2
2 files changed, 173 insertions, 166 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index ea0b20e7770..252ebed80c5 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -58,6 +58,8 @@
#define LIBGF_SENDFILE_BLOCK_SIZE 4096
#define LIBGF_READDIR_BLOCK 4096
+#define libgf_path_absolute(path) ((path[0] == '/'))
+
static inline xlator_t *
libglusterfs_graph (xlator_t *graph);
int32_t libgf_client_readlink (libglusterfs_client_ctx_t *ctx, loc_t *loc,
@@ -84,20 +86,25 @@ pthread_mutex_t vmplock = PTHREAD_MUTEX_INITIALIZER;
* needs to be syncronised.
*/
pthread_mutex_t mountlock = PTHREAD_MUTEX_INITIALIZER;
+int relativepaths = 0;
char *
-libgf_vmp_virtual_path(struct vmp_entry *entry, const char *path)
+libgf_vmp_virtual_path (int entrylen, const char *path, char *vpath)
{
- char *vpath = NULL;
char *tmp = NULL;
- vpath = calloc (strlen (path) + 1, sizeof (char));
- tmp = ((char *)(path + (entry->vmplen-1)));
- if (tmp[0] != '/') {
+ tmp = ((char *)(path + (entrylen-1)));
+ if (strlen (tmp) > 0) {
+ if (tmp[0] != '/') {
+ vpath[0] = '/';
+ vpath[1] = '\0';
+ strcat (&vpath[1], tmp);
+ } else
+ strcpy (vpath, tmp);
+ } else {
vpath[0] = '/';
- strcat (&vpath[1], tmp);
- } else
- strcpy (vpath, tmp);
+ vpath[1] = '\0';
+ }
return vpath;
}
@@ -796,17 +803,21 @@ libgf_resolve_path_light (char *path)
char *mypath = NULL;
int len = 0;
int addslash = 0;
+ char *savemypath = NULL;
if (!path)
goto out;
- /* We dont as yet support relative paths anywhere in
- * the lib.
- */
- if (path[0] != '/')
+ if ((path[0] != '/') && (strncmp (path, "./", 2) != 0))
goto out;
mypath = strdup (path);
+ savemypath = mypath;
+ if (strncmp (mypath, "./", 2) == 0) {
+ savemypath = mypath;
+ mypath++;
+ }
+
len = strlen (mypath);
respath = calloc (strlen(mypath) + 1, sizeof (char));
if (respath == NULL) {
@@ -850,8 +861,8 @@ libgf_resolve_path_light (char *path)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "Path: %s, Resolved Path: %s",
path, respath);
out:
- if (mypath)
- free (mypath);
+ if (savemypath)
+ free (savemypath);
return respath;
}
@@ -1398,6 +1409,7 @@ libgf_init_vmpentry (char *vmp, glusterfs_handle_t *vmphandle)
}
entry->vmplen = vmplen;
+
entry->handle = vmphandle;
INIT_LIST_HEAD (&entry->list);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "New VMP entry: %s", vmp);
@@ -1436,6 +1448,12 @@ libgf_count_path_components (char *path)
if (!pathdup)
return -1;
+ /* Must account for atleast one component in a relative since it starts
+ * with a path component.
+ */
+ if (pathdup[0] != '/')
+ compos++;
+
len = strlen (pathdup);
if (pathdup[len - 1] == '/')
pathdup[len - 1] = '\0';
@@ -1497,9 +1515,9 @@ free_s1:
}
int
-libgf_vmp_entry_match (struct vmp_entry *entry, char *path)
+libgf_vmp_entry_match (char *entry, char *path)
{
- return libgf_strmatchcount (entry->vmp, path);
+ return libgf_strmatchcount (entry, path);
}
#define LIBGF_VMP_EXACT 1
@@ -1523,7 +1541,7 @@ _libgf_vmp_search_entry (char *path, int searchtype)
list_for_each_entry(entry, &vmplist.list, list) {
vmpcompcount = libgf_count_path_components (entry->vmp);
- matchcount = libgf_vmp_entry_match (entry, path);
+ matchcount = libgf_vmp_entry_match (entry->vmp, path);
gf_log (LIBGF_XL_NAME, GF_LOG_TRACE, "Candidate VMP: %s,"
" Matchcount: %d", entry->vmp, matchcount);
if ((matchcount > maxcount) && (matchcount == vmpcompcount)) {
@@ -1609,6 +1627,77 @@ out:
return entry;
}
+
+struct vmp_entry *
+libgf_vmp_first_entry ()
+{
+ struct vmp_entry *entry = NULL;
+
+ pthread_mutex_lock (&vmplock);
+ {
+ if (vmplist.entries == 0) {
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "Virtual Mount Point "
+ "list is empty.");
+ goto unlock_out;
+ }
+
+ list_for_each_entry (entry, &vmplist.list, list)
+ break;
+ }
+unlock_out:
+ pthread_mutex_unlock (&vmplock);
+
+ return entry;
+}
+
+
+struct vmp_entry *
+libgf_vmp_search_entry_vpath (char *path, char *vpath)
+{
+ struct vmp_entry *entry = NULL;
+ int vmplen = 0;
+
+ if ((!path) || (!vpath))
+ return NULL;
+
+ if (!libgf_path_absolute (path)) {
+ if (!relativepaths)
+ goto out;
+ else {
+ /* On relativepaths, we assume that all relativepaths
+ * go over the first VMP. It is dangerous but for now
+ * we're assuming relative path support is only needed
+ * for samba. This condition is safe for the assumptions
+ * made in samba about its cwd.
+ */
+ entry = libgf_vmp_first_entry ();
+ /* Relative paths can start with both . and .. */
+ if (strncmp (path, "..", 2) == 0)
+ vmplen = 3;
+ else if (strncmp (path, ".", 1) == 0)
+ vmplen = 1;
+
+ goto vpath_out;
+ }
+ }
+
+ entry = libgf_vmp_search_entry ((char *)path);
+ if (!entry)
+ goto out;
+
+ vmplen = entry->vmplen;
+
+vpath_out:
+ if (!entry)
+ return NULL;
+
+ libgf_vmp_virtual_path (vmplen, path, vpath);
+
+out:
+ return entry;
+}
+
+
int
libgf_vmp_map_ghandle (char *vmp, glusterfs_handle_t *vmphandle)
{
@@ -1691,6 +1780,13 @@ glusterfs_mount (char *vmp, glusterfs_init_params_t *ipars)
}
ret = libgf_vmp_map_ghandle (vmp_resolved, vmphandle);
+ /* Only switch on relativepaths if it is not on already.
+ * The check is there to ensure no one actually adds more than
+ * two VMPs in the conf file and expect relative paths to work.
+ */
+ if (ipars->relativepaths && !relativepaths)
+ relativepaths = 1;
+
if (ret == -1) {
gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "Failed to map new"
" handle: %s", vmp);
@@ -2118,7 +2214,7 @@ glusterfs_get (const char *path, void *buf, size_t size, struct stat *stbuf)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
@@ -2126,18 +2222,15 @@ glusterfs_get (const char *path, void *buf, size_t size, struct stat *stbuf)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, size %lu", path,
(long unsigned)size);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_get (entry->handle, vpath, buf, size, stbuf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -2568,7 +2661,7 @@ glusterfs_getxattr (const char *path, const char *name, void *value,
{
int op_ret = -1;
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out);
@@ -2576,19 +2669,16 @@ glusterfs_getxattr (const char *path, const char *name, void *value,
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, name %s, size %lu",
path, name, (long unsigned)size);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = __glusterfs_glh_getxattr (entry->handle, vpath, name, value,
size, LIBGF_DO_GETXATTR);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -2598,7 +2688,7 @@ glusterfs_lgetxattr (const char *path, const char *name, void *value,
{
int op_ret = -1;
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out);
@@ -2606,19 +2696,16 @@ glusterfs_lgetxattr (const char *path, const char *name, void *value,
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, name %s, size %lu",
path, name, (long unsigned)size);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = __glusterfs_glh_getxattr (entry->handle, vpath, name, value,
size, LIBGF_DO_LGETXATTR);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -2898,7 +2985,7 @@ glusterfs_file_t
glusterfs_open (const char *path, int flags, ...)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
glusterfs_file_t fh = NULL;
mode_t mode = 0;
va_list ap;
@@ -2906,13 +2993,12 @@ glusterfs_open (const char *path, int flags, ...)
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
if (flags & O_CREAT) {
va_start (ap, flags);
mode = va_arg (ap, mode_t);
@@ -2921,8 +3007,6 @@ glusterfs_open (const char *path, int flags, ...)
} else
fh = glusterfs_glh_open (entry->handle, vpath, flags);
out:
- if (vpath)
- free (vpath);
return fh;
}
@@ -2938,24 +3022,21 @@ glusterfs_file_t
glusterfs_creat (const char *path, mode_t mode)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
glusterfs_file_t fh = NULL;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
fh = glusterfs_glh_creat (entry->handle, vpath, mode);
out:
- if (vpath)
- free (vpath);
return fh;
}
@@ -3169,25 +3250,22 @@ glusterfs_setxattr (const char *path, const char *name, const void *value,
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, value, out);
gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "path %s, name %s", path, name);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = __glusterfs_glh_setxattr (entry->handle, vpath, name, value,
size, flags, LIBGF_DO_SETXATTR);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -3198,25 +3276,22 @@ glusterfs_lsetxattr (glusterfs_handle_t handle, const char *path,
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, name, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, value, out);
gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "path %s, name %s", path, name);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = __glusterfs_glh_setxattr (entry->handle, vpath, name, value,
size, flags, LIBGF_DO_LSETXATTR);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -4732,23 +4807,19 @@ glusterfs_stat (const char *path, struct stat *buf)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
-
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_stat (entry->handle, vpath, buf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -4763,23 +4834,20 @@ glusterfs_lstat (const char *path, struct stat *buf)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_lstat (entry->handle, vpath, buf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -4984,22 +5052,19 @@ glusterfs_mkdir (const char *path, mode_t mode)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_mkdir (entry->handle, vpath, mode);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -5097,22 +5162,19 @@ glusterfs_rmdir (const char *path)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_rmdir (entry->handle, vpath);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -5198,22 +5260,19 @@ glusterfs_chmod (const char *path, mode_t mode)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_chmod (entry->handle, vpath, mode);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -5326,22 +5385,19 @@ glusterfs_chown (const char *path, uid_t owner, gid_t group)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_chown (entry->handle, vpath, owner, group);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -5357,22 +5413,19 @@ glusterfs_lchown (const char *path, uid_t owner, gid_t group)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_lchown (entry->handle, vpath, owner, group);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -5449,23 +5502,20 @@ glusterfs_dir_t
glusterfs_opendir (const char *path)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
glusterfs_dir_t dir = NULL;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
dir = glusterfs_glh_opendir (entry->handle, vpath);
out:
- if (vpath)
- free (vpath);
return dir;
}
@@ -5870,8 +5920,8 @@ glusterfs_link (const char *oldpath, const char *newpath)
{
struct vmp_entry *oldentry = NULL;
struct vmp_entry *newentry = NULL;
- char *oldvpath = NULL;
- char *newvpath = NULL;
+ char oldvpath[PATH_MAX];
+ char newvpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, oldpath, out);
@@ -5879,13 +5929,13 @@ glusterfs_link (const char *oldpath, const char *newpath)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "old %s, new %s", oldpath,
newpath);
- oldentry = libgf_vmp_search_entry ((char *)oldpath);
+ oldentry = libgf_vmp_search_entry_vpath ((char *)oldpath, oldvpath);
if (!oldentry) {
errno = ENODEV;
goto out;
}
- newentry = libgf_vmp_search_entry ((char *)newpath);
+ newentry = libgf_vmp_search_entry_vpath ((char *)newpath, newvpath);
if (!newentry) {
errno = ENODEV;
goto out;
@@ -5897,14 +5947,8 @@ glusterfs_link (const char *oldpath, const char *newpath)
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:
- if (newvpath)
- free (newvpath);
- if (oldvpath)
- free (oldvpath);
return op_ret;
}
@@ -6028,24 +6072,21 @@ int
glusterfs_statfs (const char *path, struct statfs *buf)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_statfs (entry->handle, vpath, buf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6103,24 +6144,21 @@ int
glusterfs_statvfs (const char *path, struct statvfs *buf)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_statvfs (entry->handle, vpath, buf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6255,13 +6293,13 @@ glusterfs_rename (const char *oldpath, const char *newpath)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "Old %s, new %s", oldpath,
newpath);
- old = libgf_vmp_search_entry ((char *)oldpath);
+ old = libgf_vmp_search_entry_vpath ((char *)oldpath, oldvpath);
if (!old) {
errno = ENODEV;
goto out;
}
- new = libgf_vmp_search_entry ((char *)newpath);
+ new = libgf_vmp_search_entry_vpath ((char *)newpath, newvpath);
if (!new) {
errno = ENODEV;
goto out;
@@ -6272,15 +6310,9 @@ glusterfs_rename (const char *oldpath, const char *newpath)
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:
- if (oldvpath)
- free (oldvpath);
- if (newvpath)
- free (newvpath);
return op_ret;
}
@@ -6382,23 +6414,20 @@ int
glusterfs_utimes (const char *path, const struct timeval times[2])
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_utimes (entry->handle, vpath, times);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6458,24 +6487,21 @@ int
glusterfs_utime (const char *path, const struct utimbuf *buf)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_utime (entry->handle, vpath, buf);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6585,23 +6611,20 @@ int
glusterfs_mknod(const char *pathname, mode_t mode, dev_t dev)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, pathname, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", pathname);
- entry = libgf_vmp_search_entry ((char *)pathname);
+ entry = libgf_vmp_search_entry_vpath ((char *)pathname, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, pathname);
op_ret = glusterfs_glh_mknod (entry->handle, vpath, mode, dev);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6664,23 +6687,20 @@ int
glusterfs_mkfifo (const char *path, mode_t mode)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_mkfifo (entry->handle, vpath, mode);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6769,23 +6789,20 @@ int
glusterfs_unlink (const char *path)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_unlink (entry->handle, vpath);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -6907,7 +6924,7 @@ int
glusterfs_symlink (const char *oldpath, const char *newpath)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, oldpath, out);
@@ -6915,17 +6932,14 @@ glusterfs_symlink (const char *oldpath, const char *newpath)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "target: %s, link: %s", oldpath,
newpath);
- entry = libgf_vmp_search_entry ((char *)newpath);
+ entry = libgf_vmp_search_entry_vpath ((char *)newpath, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, newpath);
op_ret = glusterfs_glh_symlink (entry->handle, oldpath, vpath);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -7033,24 +7047,21 @@ ssize_t
glusterfs_readlink (const char *path, char *buf, size_t bufsize)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
int op_ret = -1;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, buf, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, path);
op_ret = glusterfs_glh_readlink (entry->handle, vpath, buf, bufsize);
out:
- if (vpath)
- free (vpath);
return op_ret;
}
@@ -7253,14 +7264,14 @@ char *
glusterfs_realpath (const char *path, char *resolved_path)
{
struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
char *res = NULL;
char *realp = NULL;
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, path, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", path);
- entry = libgf_vmp_search_entry ((char *)path);
+ entry = libgf_vmp_search_entry_vpath ((char *)path, vpath);
if (!entry) {
errno = ENODEV;
goto out;
@@ -7270,7 +7281,6 @@ glusterfs_realpath (const char *path, char *resolved_path)
if (!realp)
goto out;
- vpath = libgf_vmp_virtual_path (entry, path);
res = glusterfs_glh_realpath (entry->handle, vpath, resolved_path);
if (!res)
goto out;
@@ -7281,8 +7291,6 @@ glusterfs_realpath (const char *path, char *resolved_path)
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, resolved %s", path,
resolved_path);
out:
- if (vpath)
- free (vpath);
return realp;
}
@@ -7332,23 +7340,20 @@ glusterfs_remove(const char *pathname)
{
struct vmp_entry *entry = NULL;
int op_ret = -1;
- char *vpath = NULL;
+ char vpath[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, pathname, out);
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s", pathname);
- entry = libgf_vmp_search_entry ((char *)pathname);
+ entry = libgf_vmp_search_entry_vpath ((char *)pathname, vpath);
if (!entry) {
errno = ENODEV;
goto out;
}
- vpath = libgf_vmp_virtual_path (entry, pathname);
op_ret = glusterfs_glh_remove (entry->handle, vpath);
out:
- if (vpath)
- FREE (vpath);
return op_ret;
}
diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h
index fbc0206995d..9882a409216 100755
--- a/libglusterfsclient/src/libglusterfsclient.h
+++ b/libglusterfsclient/src/libglusterfsclient.h
@@ -111,6 +111,8 @@ typedef struct {
for the duration specified in this
member. In Seconds.
*/
+
+ int relativepaths;
} glusterfs_init_params_t;