Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/tmpfs - tmpfs_remove: check 'appendable' flag for the...



details:   https://anonhg.NetBSD.org/src/rev/c2afe6333b4f
branches:  trunk
changeset: 790360:c2afe6333b4f
user:      rmind <rmind%NetBSD.org@localhost>
date:      Fri Oct 04 15:14:11 2013 +0000

description:
- tmpfs_remove: check 'appendable' flag for the parent directory as well.
  Patch from Pedro Martelletto.
- tmpfs_dir_detach: remove missleading check.
- tmpfs_link: remove unused variable.

diffstat:

 sys/fs/tmpfs/tmpfs_subr.c  |   9 +++------
 sys/fs/tmpfs/tmpfs_vnops.c |  22 +++++++++++++++-------
 2 files changed, 18 insertions(+), 13 deletions(-)

diffs (111 lines):

diff -r fa607a71b411 -r c2afe6333b4f sys/fs/tmpfs/tmpfs_subr.c
--- a/sys/fs/tmpfs/tmpfs_subr.c Fri Oct 04 15:13:51 2013 +0000
+++ b/sys/fs/tmpfs/tmpfs_subr.c Fri Oct 04 15:14:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $     */
+/*     $NetBSD: tmpfs_subr.c,v 1.80 2013/10/04 15:14:11 rmind Exp $    */
 
 /*
  * Copyright (c) 2005-2011 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.80 2013/10/04 15:14:11 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -514,10 +514,7 @@
 
                KASSERT(node->tn_links > 0);
                node->tn_links--;
-               if (vp) {
-                       VN_KNOTE(vp, node->tn_links ?
-                           NOTE_LINK : NOTE_DELETE);
-               }
+               VN_KNOTE(vp, node->tn_links ? NOTE_LINK : NOTE_DELETE);
 
                /* If directory - decrease the link count of parent. */
                if (node->tn_type == VDIR) {
diff -r fa607a71b411 -r c2afe6333b4f sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Fri Oct 04 15:13:51 2013 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Fri Oct 04 15:14:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.102 2013/10/01 23:10:25 rmind Exp $  */
+/*     $NetBSD: tmpfs_vnops.c,v 1.103 2013/10/04 15:14:11 rmind 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.102 2013/10/01 23:10:25 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.103 2013/10/04 15:14:11 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -668,7 +668,7 @@
                struct componentname *a_cnp;
        } */ *ap = v;
        vnode_t *dvp = ap->a_dvp, *vp = ap->a_vp;
-       tmpfs_node_t *node;
+       tmpfs_node_t *dnode, *node;
        tmpfs_dirent_t *de;
        int error;
 
@@ -679,18 +679,26 @@
                error = EPERM;
                goto out;
        }
+       dnode = VP_TO_TMPFS_DIR(dvp);
        node = VP_TO_TMPFS_NODE(vp);
 
-       /* Files marked as immutable or append-only cannot be deleted. */
+       /*
+        * Files marked as immutable or append-only cannot be deleted.
+        * Likewise, files residing on directories marked as append-only
+        * cannot be deleted.
+        */
        if (node->tn_flags & (IMMUTABLE | APPEND)) {
                error = EPERM;
                goto out;
        }
+       if (dnode->tn_flags & APPEND) {
+               error = EPERM;
+               goto out;
+       }
 
        /* Lookup the directory entry (check the cached hint first). */
        de = tmpfs_dir_cached(node);
        if (de == NULL) {
-               tmpfs_node_t *dnode = VP_TO_TMPFS_DIR(dvp);
                struct componentname *cnp = ap->a_cnp;
                de = tmpfs_dir_lookup(dnode, cnp);
        }
@@ -707,6 +715,7 @@
                tmpfs_dir_attach(dvp, de, TMPFS_NODE_WHITEOUT);
        else
                tmpfs_free_dirent(VFS_TO_TMPFS(vp->v_mount), de);
+
        if (node->tn_links > 0) {
                /* We removed a hard link. */
                node->tn_status |= TMPFS_NODE_CHANGED;
@@ -738,7 +747,7 @@
        vnode_t *dvp = ap->a_dvp;
        vnode_t *vp = ap->a_vp;
        struct componentname *cnp = ap->a_cnp;
-       tmpfs_node_t *dnode, *node;
+       tmpfs_node_t *node;
        tmpfs_dirent_t *de;
        int error;
 
@@ -747,7 +756,6 @@
        KASSERT(vp->v_type != VDIR);
        KASSERT(dvp->v_mount == vp->v_mount);
 
-       dnode = VP_TO_TMPFS_DIR(dvp);
        node = VP_TO_TMPFS_NODE(vp);
 
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);



Home | Main Index | Thread Index | Old Index