summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-10-30 03:28:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-30 03:37:39 -0700
commite6fc0cbe716a18f02891d3911481fdcb121d8840 (patch)
tree34fa4bb4cc83d3e07891ef1cfe77ac21859a1482 /libglusterfsclient
parent5d9a4d81b3928e6af15aaeb7fab18fb451f7abcc (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 7cec4d486..7066390be 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;
}
@@ -1399,6 +1410,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);
@@ -1437,6 +1449,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';
@@ -1498,9 +1516,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
@@ -1524,7 +1542,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)) {
@@ -1610,6 +1628,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)
{
@@ -1692,6 +1781,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);
@@ -2123,7 +2219,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);
@@ -2131,18 +2227,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;
}
@@ -2574,7 +2667,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);
@@ -2582,19 +2675,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;
}
@@ -2604,7 +2694,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);
@@ -2612,19 +2702,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;
}
@@ -2907,7 +2994,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;
@@ -2915,13 +3002,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);
@@ -2930,8 +3016,6 @@ glusterfs_open (const char *path, int flags, ...)
} else
fh = glusterfs_glh_open (entry->handle, vpath, flags);
out:
- if (vpath)
- free (vpath);
return fh;
}
@@ -2947,24 +3031,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;
}
@@ -3178,25 +3259,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;
}
@@ -3207,25 +3285,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;
}
@@ -4734,23 +4809,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;
}
@@ -4765,23 +4836,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;
}
@@ -4989,22 +5057,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;
}
@@ -5104,22 +5169,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;
}
@@ -5212,22 +5274,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;
}
@@ -5307,22 +5366,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;
}
@@ -5338,22 +5394,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;
}
@@ -5430,23 +5483,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;
}
@@ -5828,8 +5878,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);
@@ -5837,13 +5887,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;
@@ -5855,14 +5905,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;
}
@@ -5986,24 +6030,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;
}
@@ -6061,24 +6102,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;
}
@@ -6216,13 +6254,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;
@@ -6233,15 +6271,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;
}
@@ -6303,23 +6335,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;
}
@@ -6384,24 +6413,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;
}
@@ -6513,23 +6539,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;
}
@@ -6592,23 +6615,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;
}
@@ -6698,23 +6718,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;
}
@@ -6838,7 +6855,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);
@@ -6846,17 +6863,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;
}
@@ -6964,24 +6978,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;
}
@@ -7184,14 +7195,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;
@@ -7201,7 +7212,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;
@@ -7212,8 +7222,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;
}
@@ -7263,23 +7271,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 fbc020699..9882a4092 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;