diff options
author | kib <kib@FreeBSD.org> | 2008-03-31 12:01:21 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2008-03-31 12:01:21 +0000 |
commit | eff8c6d35eb85c880ee73166dbff3ba639b6569c (patch) | |
tree | f8cc8d866703361e98f57783e3292705ce2d5dbc /sys/kern | |
parent | fb67926ebba3585578dba016e05aabe5090ea064 (diff) | |
download | FreeBSD-src-eff8c6d35eb85c880ee73166dbff3ba639b6569c.zip FreeBSD-src-eff8c6d35eb85c880ee73166dbff3ba639b6569c.tar.gz |
Add the support for the AT_FDCWD and fd-relative name lookups to the
namei(9).
Based on the submission by rdivacky,
sponsored by Google Summer of Code 2007
Reviewed by: rwatson, rdivacky
Tested by: pho
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_jail.c | 1 | ||||
-rw-r--r-- | sys/kern/vfs_acl.c | 1 | ||||
-rw-r--r-- | sys/kern/vfs_extattr.c | 1 | ||||
-rw-r--r-- | sys/kern/vfs_lookup.c | 26 | ||||
-rw-r--r-- | sys/kern/vfs_mount.c | 1 |
5 files changed, 27 insertions, 3 deletions
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 62fae6f..fe34616 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -22,6 +22,7 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/taskqueue.h> +#include <sys/fcntl.h> #include <sys/jail.h> #include <sys/lock.h> #include <sys/mutex.h> diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index fd681f9..760b0e7 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/sysproto.h> +#include <sys/fcntl.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/mount.h> diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 28f3741..cd2b9cc 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <sys/mutex.h> #include <sys/sysproto.h> +#include <sys/fcntl.h> #include <sys/namei.h> #include <sys/filedesc.h> #include <sys/limits.h> diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index c04916b..dc34249 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/fcntl.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/namei.h> @@ -192,10 +193,29 @@ namei(struct nameidata *ndp) ndp->ni_rootdir = fdp->fd_rdir; ndp->ni_topdir = fdp->fd_jdir; - dp = fdp->fd_cdir; + if (cnp->cn_pnbuf[0] != '/' && ndp->ni_dirfd != AT_FDCWD) { + error = fgetvp(td, ndp->ni_dirfd, &dp); + FILEDESC_SUNLOCK(fdp); + if (error == 0 && dp->v_type != VDIR) { + vfslocked = VFS_LOCK_GIANT(dp->v_mount); + vrele(dp); + VFS_UNLOCK_GIANT(vfslocked); + error = ENOTDIR; + } + if (error) { + uma_zfree(namei_zone, cnp->cn_pnbuf); +#ifdef DIAGNOSTIC + cnp->cn_pnbuf = NULL; + cnp->cn_nameptr = NULL; +#endif + return (error); + } + } else { + dp = fdp->fd_cdir; + VREF(dp); + FILEDESC_SUNLOCK(fdp); + } vfslocked = VFS_LOCK_GIANT(dp->v_mount); - VREF(dp); - FILEDESC_SUNLOCK(fdp); for (;;) { /* * Check if root directory should replace current directory. diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 3961022..5061f2a 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/conf.h> #include <sys/clock.h> +#include <sys/fcntl.h> #include <sys/jail.h> #include <sys/kernel.h> #include <sys/libkern.h> |