summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-03-30 07:20:35 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-03 19:24:48 +0530
commit475a5909f3f80a1fc91630ea22bec228bfdc676b (patch)
treeaae213530826f6de20f2d36ce4cec0444e1b7266 /libglusterfsclient
parent65bd768543c4de3d2ffd8d17efbd79e1e03666a4 (diff)
libglusterfsclient - fix bug in __do_path_resolve
- add argument lookup_basename to __do_path_resolve which indicates whether to lookup basename(path). This is necessary for apis like glusterfs_get, which dont want basename(path) to be looked up by libgf_client_lookup_path. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rw-r--r--libglusterfsclient/src/libglusterfsclient-dentry.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-dentry.c b/libglusterfsclient/src/libglusterfsclient-dentry.c
index cbaf587bf64..9c25e57dfbb 100644
--- a/libglusterfsclient/src/libglusterfsclient-dentry.c
+++ b/libglusterfsclient/src/libglusterfsclient-dentry.c
@@ -218,15 +218,17 @@ libgf_client_update_resolved (const char *path, char *resolved)
/* __do_path_resolve - resolve @loc->path into @loc->inode and @loc->parent. also
* update the dentry cache
*
- * @loc - loc to resolve.
- * @ctx - libglusterfsclient context
+ * @loc - loc to resolve.
+ * @ctx - libglusterfsclient context
+ * @lookup_basename - flag whether to lookup basename(loc->path)
*
* return - 0 on success
* -1 on failure
*
*/
static int32_t
-__do_path_resolve (loc_t *loc, libglusterfs_client_ctx_t *ctx)
+__do_path_resolve (loc_t *loc, libglusterfs_client_ctx_t *ctx,
+ char lookup_basename)
{
int32_t op_ret = -1;
char *resolved = NULL;
@@ -334,29 +336,31 @@ __do_path_resolve (loc_t *loc, libglusterfs_client_ctx_t *ctx)
pathname = NULL;
}
- pathname = strdup (loc->path);
- file = basename (pathname);
+ if (lookup_basename) {
+ pathname = strdup (loc->path);
+ file = basename (pathname);
- inode = inode_search (ctx->itable, parent->ino, file);
- if (!inode) {
- libgf_client_loc_fill (&new_loc, ctx, 0, parent->ino,
- file);
+ inode = inode_search (ctx->itable, parent->ino, file);
+ if (!inode) {
+ libgf_client_loc_fill (&new_loc, ctx, 0, parent->ino,
+ file);
- op_ret = libgf_client_lookup (ctx, &new_loc, NULL, NULL,
- 0);
- if (op_ret == -1) {
- /* parent is resolved, file referred by the
- path may not be present on the storage*/
- if (strcmp (loc->path, "/") != 0) {
- op_ret = 0;
- }
+ op_ret = libgf_client_lookup (ctx, &new_loc, NULL, NULL,
+ 0);
+ if (op_ret == -1) {
+ /* parent is resolved, file referred by the
+ path may not be present on the storage*/
+ if (strcmp (loc->path, "/") != 0) {
+ op_ret = 0;
+ }
+ libgf_client_loc_wipe (&new_loc);
+ goto out;
+ }
+
+ inode = inode_ref (new_loc.inode);
libgf_client_loc_wipe (&new_loc);
- goto out;
}
-
- inode = inode_ref (new_loc.inode);
- libgf_client_loc_wipe (&new_loc);
}
out:
@@ -443,7 +447,7 @@ libgf_client_path_lookup (loc_t *loc,
"exists without parent (%s)",
inode->ino, loc->path, directory);
}
- op_ret = __do_path_resolve (loc, ctx);
+ op_ret = __do_path_resolve (loc, ctx, lookup_basename);
}
out: