From 86d6e6cf7947691bfb3f3e9acafdbf44aa5e3821 Mon Sep 17 00:00:00 2001 From: pjd Date: Wed, 8 Sep 2010 20:56:18 +0000 Subject: - Log all the problems in devfs_fixup(). - Correct error paths. The system will be useless on devfs_fixup() failure, so why bother? Maybe for the same reason why a dead body is washed and dressed in a nice suit before it is put into a coffin? Maybe system's last will is to panic without any locks held? Reviewed by: kib --- sys/kern/vfs_mount.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index fe9f16c..3d3fcc8 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1549,9 +1549,9 @@ static void devfs_fixup(struct thread *td) { struct nameidata nd; - int error; struct vnode *vp, *dvp; struct mount *mp; + int error; /* Remove our devfs mount from the mountlist and purge the cache */ mtx_lock(&mountlist_mtx); @@ -1575,16 +1575,26 @@ devfs_fixup(struct thread *td) error = namei(&nd); if (error) { printf("Lookup of /dev for devfs, error: %d\n", error); + vput(dvp); + vfs_unbusy(mp); return; } NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; if (vp->v_type != VDIR) { + printf("/dev is not a directory\n"); + vput(dvp); vput(vp); + vfs_unbusy(mp); + return; } error = vinvalbuf(vp, V_SAVE, 0, 0); if (error) { + printf("vinvalbuf() of /dev failed, error: %d\n", error); + vput(dvp); vput(vp); + vfs_unbusy(mp); + return; } cache_purge(vp); mp->mnt_vnodecovered = vp; @@ -1597,7 +1607,9 @@ devfs_fixup(struct thread *td) vfs_unbusy(mp); /* Unlink the no longer needed /dev/dev -> / symlink */ - kern_unlink(td, "/dev/dev", UIO_SYSSPACE); + error = kern_unlink(td, "/dev/dev", UIO_SYSSPACE); + if (error) + printf("kern_unlink of /dev/dev failed, error: %d\n", error); } /* -- cgit v1.1