diff options
| author | Ian Moffett <ian@osmora.org> | 2025-11-22 17:42:50 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-11-22 17:42:50 -0500 |
| commit | a3ca97d24953f7d72dc26d0627d03b673335acee (patch) | |
| tree | c3eabc08148aa8f8f86f9d3ceb3d5172e579321c | |
| parent | bcc09c2031f35ec4c6e03e02818071e782db6ed1 (diff) | |
kern: vfs: Add NAMEI_PARENT flag to NAMEI
This flag allows one to get the vnode of the parent component rather
than the last
Signed-off-by: Ian Moffett <ian@osmora.org>
| -rw-r--r-- | sys/inc/kern/namei.h | 2 | ||||
| -rw-r--r-- | sys/kern/kern_namei.c | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sys/inc/kern/namei.h b/sys/inc/kern/namei.h index a9fba7f..5dbf5ad 100644 --- a/sys/inc/kern/namei.h +++ b/sys/inc/kern/namei.h @@ -33,6 +33,8 @@ #include <sys/types.h> #include <sys/param.h> +#define NAMEI_PARENT BIT(0) + /* * Represents arguments to be passed with namei() */ diff --git a/sys/kern/kern_namei.c b/sys/kern/kern_namei.c index cc11116..703cebb 100644 --- a/sys/kern/kern_namei.c +++ b/sys/kern/kern_namei.c @@ -38,6 +38,7 @@ namei(struct nameidata *ndp) struct vops *vops; struct mount *mpoint = NULL; struct vnode *vp = NULL; + struct vnode *parent = NULL; const char *p; int error; char namebuf[NAME_MAX]; @@ -88,8 +89,13 @@ namei(struct nameidata *ndp) continue; } + parent = vp; vops = &vp->vops; error = vnode_lookup(vp, namebuf, &vp); + if (error != 0 && ISSET(ndp->flags, NAMEI_PARENT)) { + break; + } + if (error != 0) { return error; } @@ -97,6 +103,10 @@ namei(struct nameidata *ndp) namebuf_idx = 0; } - *ndp->vp_res = vp; + if (ISSET(ndp->flags, NAMEI_PARENT)) { + *ndp->vp_res = parent; + } else { + *ndp->vp_res = vp; + } return 0; } |
