link_path_walk(): move assignments to nd->last/nd->last_type up

... and clean the main loop a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2013-01-24 18:04:22 -05:00
parent ad8ca3743c
commit 5f4a6a6950

View File

@ -1802,8 +1802,11 @@ static int link_path_walk(const char *name, struct nameidata *nd)
} }
} }
nd->last = this;
nd->last_type = type;
if (!name[len]) if (!name[len])
goto last_component; return 0;
/* /*
* If it wasn't NUL, we know it was '/'. Skip that * If it wasn't NUL, we know it was '/'. Skip that
* slash, and continue until no more slashes. * slash, and continue until no more slashes.
@ -1812,7 +1815,8 @@ static int link_path_walk(const char *name, struct nameidata *nd)
len++; len++;
} while (unlikely(name[len] == '/')); } while (unlikely(name[len] == '/'));
if (!name[len]) if (!name[len])
goto last_component; return 0;
name += len; name += len;
err = walk_component(nd, &next, &this, type, LOOKUP_FOLLOW); err = walk_component(nd, &next, &this, type, LOOKUP_FOLLOW);
@ -1824,16 +1828,10 @@ static int link_path_walk(const char *name, struct nameidata *nd)
if (err) if (err)
return err; return err;
} }
if (can_lookup(nd->inode)) if (!can_lookup(nd->inode)) {
continue; err = -ENOTDIR;
err = -ENOTDIR; break;
break; }
/* here ends the main loop */
last_component:
nd->last = this;
nd->last_type = type;
return 0;
} }
terminate_walk(nd); terminate_walk(nd);
return err; return err;