Module Name: src
Committed By: hannken
Date: Tue Dec 24 09:23:33 UTC 2013
Modified Files:
src/sys/fs/tmpfs: tmpfs_vnops.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/fs/tmpfs/tmpfs_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.109 src/sys/fs/tmpfs/tmpfs_vnops.c:1.110
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.109 Sun Nov 24 17:16:29 2013
+++ src/sys/fs/tmpfs/tmpfs_vnops.c Tue Dec 24 09:23:33 2013
@@ -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 &&