From d541fcea4a7962f499f20033f19f6a97aedfc122 Mon Sep 17 00:00:00 2001 From: Igor Ostapenko Date: Mon, 8 May 2023 22:05:43 +0300 Subject: [PATCH 1/2] vfs: fix description comment of vfs_lookup() Signed-off-by: Igor Ostapenko --- sys/kern/vfs_lookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index a75ea4ca16d65e..89839ce1de66b2 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -840,7 +840,7 @@ vfs_lookup_failifexists(struct nameidata *ndp) * Search a pathname. * This is a very central and rather complicated routine. * - * The pathname is pointed to by ni_ptr and is of length ni_pathlen. + * The pathname is pointed to by cn_nameptr and is of length ni_pathlen. * The starting directory is taken from ni_startdir. The pathname is * descended until done, or a symbolic link is encountered. The variable * ni_more is clear if the path is completed; it is set to one if a @@ -861,7 +861,7 @@ vfs_lookup_failifexists(struct nameidata *ndp) * Overall outline of lookup: * * dirloop: - * identify next component of name at ndp->ni_ptr + * identify next component of name at ndp->ni_cnd.cn_nameptr * handle degenerate case where name is null string * if .. and crossing mount points and on mounted filesys, find parent * call VOP_LOOKUP routine for next component name From f10cecf905a265a8388d5fb9c9794a4830da404c Mon Sep 17 00:00:00 2001 From: Igor Ostapenko Date: Wed, 21 Jun 2023 02:34:14 +0300 Subject: [PATCH 2/2] vfs: bring vfs_lookup() description comment up to date Signed-off-by: Igor Ostapenko --- sys/kern/vfs_lookup.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 89839ce1de66b2..35f4c7fb5ece06 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -842,27 +842,27 @@ vfs_lookup_failifexists(struct nameidata *ndp) * * The pathname is pointed to by cn_nameptr and is of length ni_pathlen. * The starting directory is taken from ni_startdir. The pathname is - * descended until done, or a symbolic link is encountered. The variable - * ni_more is clear if the path is completed; it is set to one if a + * descended until done, or a symbolic link is encountered. The cn_flags + * has ISLASTCN or'ed if the path is completed or ISSYMLINK or'ed if a * symbolic link needing interpretation is encountered. * - * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on + * The cn_nameiop is LOOKUP, CREATE, RENAME, or DELETE depending on * whether the name is to be looked up, created, renamed, or deleted. * When CREATE, RENAME, or DELETE is specified, information usable in * creating, renaming, or deleting a directory entry may be calculated. - * If flag has LOCKPARENT or'ed into it, the parent directory is returned - * locked. If flag has WANTPARENT or'ed into it, the parent directory is + * If cn_flags has LOCKPARENT or'ed into it, the parent directory is returned + * locked. If it has WANTPARENT or'ed into it, the parent directory is * returned unlocked. Otherwise the parent directory is not returned. If - * the target of the pathname exists and LOCKLEAF is or'ed into the flag + * the target of the pathname exists and LOCKLEAF is or'ed into the cn_flags * the target is returned locked, otherwise it is returned unlocked. - * When creating or renaming and LOCKPARENT is specified, the target may not - * be ".". When deleting and LOCKPARENT is specified, the target may be ".". * * Overall outline of lookup: * + * handle degenerate case where name is null string + * * dirloop: * identify next component of name at ndp->ni_cnd.cn_nameptr - * handle degenerate case where name is null string + * handle .. special cases related to capabilities, chroot, jail * if .. and crossing mount points and on mounted filesys, find parent * call VOP_LOOKUP routine for next component name * directory vnode returned in ni_dvp, unlocked unless LOCKPARENT set @@ -870,6 +870,7 @@ vfs_lookup_failifexists(struct nameidata *ndp) * if result vnode is mounted on and crossing mount points, * find mounted on vnode * if more components of name, do next level at dirloop + * if VOP_LOOKUP returns ERELOOKUP, repeat the same level at dirloop * return the answer in ni_vp, locked if LOCKLEAF set * if LOCKPARENT set, return locked parent in ni_dvp * if WANTPARENT set, return unlocked parent in ni_dvp