summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2015-07-11 16:22:48 +0000
committermjg <mjg@FreeBSD.org>2015-07-11 16:22:48 +0000
commita85ed5531d84d12ab5ad8b50190028c228d7d861 (patch)
treef949fd85e6011817842d92d50f444ca5039ab9c7 /sys/kern/kern_descrip.c
parentc71e9ab8634afefe13ecbf6d9f4d812ed55d78fb (diff)
downloadFreeBSD-src-a85ed5531d84d12ab5ad8b50190028c228d7d861.zip
FreeBSD-src-a85ed5531d84d12ab5ad8b50190028c228d7d861.tar.gz
Create a dedicated function for ensuring that cdir and rdir are populated.
Previously several places were doing it on its own, partially incorrectly (e.g. without the filedesc locked) or even actively harmful by populating jdir or assigning rootvnode without vrefing it. Reviewed by: kib
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 7e54d18..4229cc9 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sbuf.h>
#include <sys/signalvar.h>
#include <sys/socketvar.h>
+#include <sys/kdb.h>
#include <sys/stat.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
@@ -308,6 +309,24 @@ fdfree(struct filedesc *fdp, int fd)
#endif
}
+void
+pwd_ensure_dirs(void)
+{
+ struct filedesc *fdp;
+
+ fdp = curproc->p_fd;
+ FILEDESC_XLOCK(fdp);
+ if (fdp->fd_cdir == NULL) {
+ fdp->fd_cdir = rootvnode;
+ VREF(rootvnode);
+ }
+ if (fdp->fd_rdir == NULL) {
+ fdp->fd_rdir = rootvnode;
+ VREF(rootvnode);
+ }
+ FILEDESC_XUNLOCK(fdp);
+}
+
/*
* System calls on descriptors.
*/
OpenPOWER on IntegriCloud