From 38e5e60484f827fe6e856e8f0e00d476f4044bcd Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 21 Feb 2010 08:41:15 -0800 Subject: [PATCH] kernel - TMPFS - Stabilization pass, fix assertion in nrmdir * Have tmpfs_nrmdir() test whether the vp is a directory and return the proper error before asserting that it is a directory. * Fixes assertion panic if you attempt to rmdir a file in tmpfs. --- sys/vfs/tmpfs/tmpfs_vnops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/vfs/tmpfs/tmpfs_vnops.c b/sys/vfs/tmpfs/tmpfs_vnops.c index ec4e553e56..76e4598d00 100644 --- a/sys/vfs/tmpfs/tmpfs_vnops.c +++ b/sys/vfs/tmpfs/tmpfs_vnops.c @@ -1062,12 +1062,17 @@ tmpfs_nrmdir(struct vop_nrmdir_args *v) struct vnode *dvp = v->a_dvp; struct namecache *ncp = v->a_nch->ncp; struct vnode *vp; - - int error; struct tmpfs_dirent *de; struct tmpfs_mount *tmp; struct tmpfs_node *dnode; struct tmpfs_node *node; + int error; + + /* + * Prevalidate so we don't hit an assertion later + */ + if (vp->v_type != VDIR) + return ENOTDIR; /* * We have to acquire the vp from v->a_nch because -- 2.41.0