summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-11-22 17:42:50 -0500
committerIan Moffett <ian@osmora.org>2025-11-22 17:42:50 -0500
commita3ca97d24953f7d72dc26d0627d03b673335acee (patch)
treec3eabc08148aa8f8f86f9d3ceb3d5172e579321c /sys
parentbcc09c2031f35ec4c6e03e02818071e782db6ed1 (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>
Diffstat (limited to 'sys')
-rw-r--r--sys/inc/kern/namei.h2
-rw-r--r--sys/kern/kern_namei.c12
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;
}