It is not the task of tmpfs_open() to check for unlinked nodes.
Fix tmpfs_lookup() to always return ENOENT when looking up from an unlinked directory.
This commit is contained in:
parent
0824426c83
commit
905b6b7730
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tmpfs_vnops.c,v 1.109 2013/11/24 17:16:29 rmind Exp $ */
|
||||
/* $NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.109 2013/11/24 17:16:29 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/dirent.h>
|
||||
|
@ -176,6 +176,15 @@ tmpfs_lookup(void *v)
|
|||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Treat an unlinked directory as empty (no "." or "..")
|
||||
*/
|
||||
if (dnode->tn_links == 0) {
|
||||
KASSERT(dnode->tn_size == 0);
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cnp->cn_flags & ISDOTDOT) {
|
||||
tmpfs_node_t *pnode;
|
||||
|
||||
|
@ -352,14 +361,6 @@ tmpfs_open(void *v)
|
|||
KASSERT(VOP_ISLOCKED(vp));
|
||||
|
||||
node = VP_TO_TMPFS_NODE(vp);
|
||||
if (node->tn_links < 1) {
|
||||
/*
|
||||
* The file is still active, but all its names have been
|
||||
* removed (e.g. by a "rmdir $(pwd)"). It cannot be opened
|
||||
* any more, as it is about to be destroyed.
|
||||
*/
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
/* If the file is marked append-only, deny write requests. */
|
||||
if ((node->tn_flags & APPEND) != 0 &&
|
||||
|
|
Loading…
Reference in New Issue