Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/puffs/h_dtfs prevent rename of source directory und...



details:   https://anonhg.NetBSD.org/src/rev/7fa75905801a
branches:  trunk
changeset: 756362:7fa75905801a
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Jul 14 13:09:52 2010 +0000

description:
prevent rename of source directory under itself

diffstat:

 tests/fs/puffs/h_dtfs/dtfs.h       |   4 +++-
 tests/fs/puffs/h_dtfs/dtfs_subr.c  |  17 ++++++++++++++++-
 tests/fs/puffs/h_dtfs/dtfs_vnops.c |   9 ++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diffs (72 lines):

diff -r 65f759aa6220 -r 7fa75905801a tests/fs/puffs/h_dtfs/dtfs.h
--- a/tests/fs/puffs/h_dtfs/dtfs.h      Wed Jul 14 09:52:39 2010 +0000
+++ b/tests/fs/puffs/h_dtfs/dtfs.h      Wed Jul 14 13:09:52 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtfs.h,v 1.1 2010/07/06 14:16:44 pooka Exp $   */
+/*     $NetBSD: dtfs.h,v 1.2 2010/07/14 13:09:52 pooka Exp $   */
 
 /*
  * Copyright (c) 2006  Antti Kantee.  All Rights Reserved.
@@ -118,6 +118,8 @@
 void   dtfs_baseattrs(struct vattr *, enum vtype, ino_t);
 void   dtfs_updatetimes(struct puffs_node *, int, int, int);
 
+bool   dtfs_isunder(struct puffs_node *, struct puffs_node *);
+
 
 #define DTFS_CTOF(a) ((struct dtfs_file *)(((struct puffs_node *)a)->pn_data))
 #define DTFS_PTOF(a) ((struct dtfs_file *)(a->pn_data))
diff -r 65f759aa6220 -r 7fa75905801a tests/fs/puffs/h_dtfs/dtfs_subr.c
--- a/tests/fs/puffs/h_dtfs/dtfs_subr.c Wed Jul 14 09:52:39 2010 +0000
+++ b/tests/fs/puffs/h_dtfs/dtfs_subr.c Wed Jul 14 13:09:52 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtfs_subr.c,v 1.1 2010/07/06 14:16:44 pooka Exp $      */
+/*     $NetBSD: dtfs_subr.c,v 1.2 2010/07/14 13:09:52 pooka Exp $      */
 
 /*
  * Copyright (c) 2006  Antti Kantee.  All Rights Reserved.
@@ -338,3 +338,18 @@
        if (domtime)
                pn->pn_va.va_mtime = ts;
 }
+
+bool
+dtfs_isunder(struct puffs_node *pn, struct puffs_node *pn_parent)
+{
+       struct dtfs_file *df;
+
+       while (pn) {
+               if (pn == pn_parent)
+                       return true;
+               df = DTFS_CTOF(pn);
+               pn = df->df_dotdot;
+       }
+
+       return false;
+}
diff -r 65f759aa6220 -r 7fa75905801a tests/fs/puffs/h_dtfs/dtfs_vnops.c
--- a/tests/fs/puffs/h_dtfs/dtfs_vnops.c        Wed Jul 14 09:52:39 2010 +0000
+++ b/tests/fs/puffs/h_dtfs/dtfs_vnops.c        Wed Jul 14 13:09:52 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dtfs_vnops.c,v 1.1 2010/07/06 14:16:44 pooka Exp $     */
+/*     $NetBSD: dtfs_vnops.c,v 1.2 2010/07/14 13:09:52 pooka Exp $     */
 
 /*
  * Copyright (c) 2006  Antti Kantee.  All Rights Reserved.
@@ -305,9 +305,16 @@
 {
        struct dtfs_dirent *dfd_src;
        struct puffs_node *pn_sdir = opc;
+       struct puffs_node *pn_sfile = src;
        struct puffs_node *pn_tdir = targ_dir;
        struct puffs_node *pn_tfile = targ;
 
+       /* check that we don't do the old amigados trick */
+       if (pn_sfile->pn_va.va_type == VDIR) {
+               if (dtfs_isunder(pn_tdir, pn_sfile))
+                       return EINVAL;
+       }
+
        dfd_src = dtfs_dirgetbyname(DTFS_PTOF(pn_sdir),
            pcn_src->pcn_name, pcn_src->pcn_namelen);
 



Home | Main Index | Thread Index | Old Index