summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server-resolve.c
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-11-22 10:52:51 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-11-24 00:33:35 -0800
commit7f68e386132af9e02bf37a3b4d0653de000bdefe (patch)
tree89acf2c2d3df6694a194fe0c1ae98ac283ab7075 /xlators/protocol/server/src/server-resolve.c
parentf1205225417b3e0d5cf27f5ba85ccdfe0ef6b246 (diff)
resolver: handle corner cases of handling root inode better
- changes in deep resolution and simple resolution of pure paths to handle resolution of "/" - warn on pure path resolution Signed-off-by: Anand V. Avati <avati@amp.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/protocol/server/src/server-resolve.c')
-rw-r--r--xlators/protocol/server/src/server-resolve.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index ec1d6554b20..4f9d97394b5 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -83,8 +83,17 @@ prepare_components (call_frame_t *frame)
i = 1;
for (trav = resolved; *trav; trav++) {
if (*trav == '/') {
- components[i].basename = trav + 1;
*trav = 0;
+
+ if (!(*(trav + 1))) {
+ /* Skip trailing "/" in a path.
+ This is the check which prevents
+ inode_link'age of itable->root
+ */
+ break;
+ }
+
+ components[i].basename = trav + 1;
i++;
}
}
@@ -238,7 +247,7 @@ resolve_path_deep (call_frame_t *frame)
state = CALL_STATE (frame);
resolve = state->resolve_now;
- gf_log (BOUND_XL (frame)->name, GF_LOG_TRACE,
+ gf_log (BOUND_XL (frame)->name, GF_LOG_DEBUG,
"RESOLVE %s() seeking deep resolution of %s",
gf_fop_list[frame->root->op], resolve->path);
@@ -268,8 +277,8 @@ resolve_path_simple (call_frame_t *frame)
server_resolve_t *resolve = NULL;
struct resolve_comp *components = NULL;
int ret = -1;
- int par_idx = 0;
- int ino_idx = 0;
+ int par_idx = -1;
+ int ino_idx = -1;
int i = 0;
state = CALL_STATE (frame);
@@ -287,11 +296,22 @@ resolve_path_simple (call_frame_t *frame)
ino_idx = i;
}
+ if (ino_idx == -1) {
+ resolve->op_ret = -1;
+ resolve->op_errno = EINVAL;
+ goto out;
+ }
+
+ if (par_idx == -1)
+ /* "/" will not have a parent */
+ goto noparent;
+
if (!components[par_idx].inode) {
resolve->op_ret = -1;
resolve->op_errno = ENOENT;
goto out;
}
+noparent:
if (!components[ino_idx].inode &&
(resolve->type == RESOLVE_MUST || resolve->type == RESOLVE_EXACT)) {
@@ -540,6 +560,9 @@ server_resolve (call_frame_t *frame)
} else if (resolve->path) {
+ gf_log (frame->this->name, GF_LOG_WARNING,
+ "pure path resolution for %s (%s)",
+ resolve->path, gf_fop_list[frame->root->op]);
resolve_path_deep (frame);
} else {