Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Make namei() work with no root dir yet.
details: https://anonhg.NetBSD.org/src/rev/f287062ab87c
branches: trunk
changeset: 461937:f287062ab87c
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Jul 18 09:39:40 2019 +0000
description:
Make namei() work with no root dir yet.
>From David Holland with minor tweaks from me.
Should fix PR kern/54378 (panic with TLB miss when attempting to reboot)
diffstat:
sys/kern/vfs_lookup.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diffs (72 lines):
diff -r ae8df9b46548 -r f287062ab87c sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c Thu Jul 18 09:07:59 2019 +0000
+++ b/sys/kern/vfs_lookup.c Thu Jul 18 09:39:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lookup.c,v 1.211 2019/07/06 14:27:38 maxv Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.211 2019/07/06 14:27:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_magiclinks.h"
@@ -515,7 +515,8 @@
KASSERT(state->cnp == &state->ndp->ni_cnd);
if (state->root_referenced) {
- vrele(state->ndp->ni_rootdir);
+ if (state->ndp->ni_rootdir != NULL)
+ vrele(state->ndp->ni_rootdir);
if (state->ndp->ni_erootdir != NULL)
vrele(state->ndp->ni_erootdir);
}
@@ -538,7 +539,8 @@
struct vnode *rootdir, *erootdir, *curdir, *startdir;
if (state->root_referenced) {
- vrele(state->ndp->ni_rootdir);
+ if (state->ndp->ni_rootdir != NULL)
+ vrele(state->ndp->ni_rootdir);
if (state->ndp->ni_erootdir != NULL)
vrele(state->ndp->ni_erootdir);
state->root_referenced = 0;
@@ -595,8 +597,10 @@
* Must hold references to rootdir and erootdir while we're running.
* A multithreaded process may chroot during namei.
*/
- vref(startdir);
- vref(state->ndp->ni_rootdir);
+ if (startdir != NULL)
+ vref(startdir);
+ if (state->ndp->ni_rootdir != NULL)
+ vref(state->ndp->ni_rootdir);
if (state->ndp->ni_erootdir != NULL)
vref(state->ndp->ni_erootdir);
state->root_referenced = 1;
@@ -616,6 +620,9 @@
KASSERT(state->ndp->ni_atdir != NULL);
/* always use the real root, and never set an emulation root */
+ if (rootvnode == NULL) {
+ return NULL;
+ }
state->ndp->ni_rootdir = rootvnode;
state->ndp->ni_erootdir = NULL;
@@ -693,6 +700,10 @@
namei_ktrace(state);
}
+ if (startdir == NULL) {
+ return ENOENT;
+ }
+
/* NDAT may feed us with a non directory namei_getstartdir */
if (startdir->v_type != VDIR) {
vrele(startdir);
Home |
Main Index |
Thread Index |
Old Index