提交 fe479a58 编写于 作者: A Al Viro

merge component type recognition

no need to do it in three places...
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 e41f7d4e
...@@ -1362,6 +1362,7 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1362,6 +1362,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
unsigned long hash; unsigned long hash;
struct qstr this; struct qstr this;
unsigned int c; unsigned int c;
int type;
nd->flags |= LOOKUP_CONTINUE; nd->flags |= LOOKUP_CONTINUE;
...@@ -1381,6 +1382,16 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1381,6 +1382,16 @@ static int link_path_walk(const char *name, struct nameidata *nd)
this.len = name - (const char *) this.name; this.len = name - (const char *) this.name;
this.hash = end_name_hash(hash); this.hash = end_name_hash(hash);
type = LAST_NORM;
if (this.name[0] == '.') switch (this.len) {
case 2:
if (this.name[1] == '.')
type = LAST_DOTDOT;
break;
case 1:
type = LAST_DOT;
}
/* remove trailing slashes? */ /* remove trailing slashes? */
if (!c) if (!c)
goto last_component; goto last_component;
...@@ -1393,21 +1404,17 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1393,21 +1404,17 @@ static int link_path_walk(const char *name, struct nameidata *nd)
* to be able to know about the current root directory and * to be able to know about the current root directory and
* parent relationships. * parent relationships.
*/ */
if (this.name[0] == '.') switch (this.len) { if (unlikely(type != LAST_NORM)) {
default: if (type == LAST_DOTDOT) {
break;
case 2:
if (this.name[1] != '.')
break;
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
if (follow_dotdot_rcu(nd)) if (follow_dotdot_rcu(nd))
return -ECHILD; return -ECHILD;
} else } else
follow_dotdot(nd); follow_dotdot(nd);
/* fallthrough */ }
case 1: continue;
continue;
} }
/* This does the actual lookups.. */ /* This does the actual lookups.. */
err = do_lookup(nd, &this, &next, &inode); err = do_lookup(nd, &this, &next, &inode);
if (err) if (err)
...@@ -1441,20 +1448,15 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1441,20 +1448,15 @@ static int link_path_walk(const char *name, struct nameidata *nd)
nd->flags &= lookup_flags | ~LOOKUP_CONTINUE; nd->flags &= lookup_flags | ~LOOKUP_CONTINUE;
if (lookup_flags & LOOKUP_PARENT) if (lookup_flags & LOOKUP_PARENT)
goto lookup_parent; goto lookup_parent;
if (this.name[0] == '.') switch (this.len) { if (unlikely(type != LAST_NORM)) {
default: if (type == LAST_DOTDOT) {
break;
case 2:
if (this.name[1] != '.')
break;
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
if (follow_dotdot_rcu(nd)) if (follow_dotdot_rcu(nd))
return -ECHILD; return -ECHILD;
} else } else
follow_dotdot(nd); follow_dotdot(nd);
/* fallthrough */ }
case 1: goto return_reval;
goto return_reval;
} }
err = do_lookup(nd, &this, &next, &inode); err = do_lookup(nd, &this, &next, &inode);
if (err) if (err)
...@@ -1480,14 +1482,8 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1480,14 +1482,8 @@ static int link_path_walk(const char *name, struct nameidata *nd)
goto return_base; goto return_base;
lookup_parent: lookup_parent:
nd->last = this; nd->last = this;
nd->last_type = LAST_NORM; nd->last_type = type;
if (this.name[0] != '.') if (type == LAST_NORM)
goto return_base;
if (this.len == 1)
nd->last_type = LAST_DOT;
else if (this.len == 2 && this.name[1] == '.')
nd->last_type = LAST_DOTDOT;
else
goto return_base; goto return_base;
return_reval: return_reval:
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册