Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs It is not the task of tmpfs_open() to check for...



details:   https://anonhg.NetBSD.org/src/rev/78e642f5d8b3
branches:  trunk
changeset: 325417:78e642f5d8b3
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue Dec 24 09:23:33 2013 +0000

description:
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.

diffstat:

 sys/fs/tmpfs/tmpfs_vnops.c |  21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r 06dbb4865dba -r 78e642f5d8b3 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Tue Dec 24 01:42:32 2013 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Tue Dec 24 09:23:33 2013 +0000
@@ -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 @@
                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 @@
        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 &&



Home | Main Index | Thread Index | Old Index