Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/ffs Add test cases for the bug fixed in sys/ufs/ufs...



details:   https://anonhg.NetBSD.org/src/rev/9479453eb9d1
branches:  trunk
changeset: 781790:9479453eb9d1
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Sep 30 21:26:57 2012 +0000

description:
Add test cases for the bug fixed in sys/ufs/ufs/ufs_quota2.c 1.35:
when a on-disk block/inode allocation triggers allocating a new
quota entry, the new quota entry is not in the quota2 header block,
and the allocation will later be denied, the changes to the quota block would
not be flushed to disk, leading to list corruption (detected by fsck).

diffstat:

 tests/fs/ffs/h_quota2_tests.c |  16 +++++++++++-
 tests/fs/ffs/t_miscquota.sh   |  51 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 3 deletions(-)

diffs (99 lines):

diff -r 28ae5371fd51 -r 9479453eb9d1 tests/fs/ffs/h_quota2_tests.c
--- a/tests/fs/ffs/h_quota2_tests.c     Sun Sep 30 21:15:08 2012 +0000
+++ b/tests/fs/ffs/h_quota2_tests.c     Sun Sep 30 21:26:57 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_quota2_tests.c,v 1.3 2011/06/11 18:03:17 christos Exp $      */
+/*     $NetBSD: h_quota2_tests.c,v 1.4 2012/09/30 21:26:57 bouyer Exp $        */
 
 /*
  * rump server for advanced quota tests
@@ -34,7 +34,19 @@
        static char buf[512];
        int fd;
        int error;
-       rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID);
+       unsigned int i;
+       int chowner = 1;
+       for (i =0; testopts && i < strlen(testopts); i++) {
+               switch(testopts[i]) {
+               case 'C':
+                       chowner = 0;
+                       break;
+               default:
+                       errx(1, "test4: unknown option %c", testopts[i]);
+               }
+       }
+       if (chowner)
+               rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID);
        rump_sys_chmod(".", 0777);
        if (rump_sys_setegid(TEST_NONROOT_ID) != 0) {
                error = errno;
diff -r 28ae5371fd51 -r 9479453eb9d1 tests/fs/ffs/t_miscquota.sh
--- a/tests/fs/ffs/t_miscquota.sh       Sun Sep 30 21:15:08 2012 +0000
+++ b/tests/fs/ffs/t_miscquota.sh       Sun Sep 30 21:26:57 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_miscquota.sh,v 1.6 2012/02/13 17:55:12 dholland Exp $ 
+# $NetBSD: t_miscquota.sh,v 1.7 2012/09/30 21:26:58 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -53,6 +53,13 @@
     -oRL le 1 user
 
 
+test_case_root defaut_deny_user quota_defaut_deny \
+    "new quota entry denied by default entry" 5 -b le 1 user
+
+test_case_root defaut_deny_user_big quota_defaut_deny \
+    "new quota entry denied by default entry, with list on more than one block" 5000 -b le 1 user
+
+
 quota_walk_list()
 {
        create_ffs_server $*
@@ -162,3 +169,45 @@
        #shutdown and check filesystem
        rump_quota_shutdown
 }
+
+quota_defaut_deny()
+{
+       local nusers=$1; shift
+       create_ffs_server $*
+       local q=$4
+       local expect
+
+       case ${q} in
+       user)
+               expect=u
+               fail=g
+               ;;
+       group)
+               expect=g
+               fail=u
+               ;;
+       *)
+               atf_fail "wrong quota type"
+               ;;
+       esac
+
+       # create $nusers users, so we are sure the free list has entries
+       # from block 1. Start from 10, as non-root id is 1.
+       # set default to deny all
+       ( echo "@format netbsd-quota-dump v1"
+         echo "# idtype id objtype   hard soft usage expire grace"
+         echo "$q default block   0 0 0 0 0"
+         echo "$q default file   0 0 0 0 0"
+         local i=10;
+         while [ $i -lt $(($nusers + 10)) ]; do
+               echo "$q $i block   0 0 0 0 0"
+               echo "$q $i file   0 0 0 0 0"
+               i=$((i + 1))
+         done
+       ) | atf_check -s exit:0 \
+                  env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quotarestore -d /mnt
+       atf_check -s exit:0 rump.halt
+       #now start the server which does the limits tests
+       $(atf_get_srcdir)/h_quota2_tests -oC -b 0 ${IMG} ${RUMP_SERVER}
+       rump_quota_shutdown
+}



Home | Main Index | Thread Index | Old Index