[BACK]Return to t_enable_quotas.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / sbin / fsck_ffs

Annotation of src/tests/sbin/fsck_ffs/t_enable_quotas.sh, Revision 1.2

1.2     ! bouyer      1: # $NetBSD$
        !             2: #
        !             3: #  Copyright (c) 2011 Manuel Bouyer
        !             4: #  All rights reserved.
        !             5: #
        !             6: #  Redistribution and use in source and binary forms, with or without
        !             7: #  modification, are permitted provided that the following conditions
        !             8: #  are met:
        !             9: #  1. Redistributions of source code must retain the above copyright
        !            10: #     notice, this list of conditions and the following disclaimer.
        !            11: #  2. Redistributions in binary form must reproduce the above copyright
        !            12: #     notice, this list of conditions and the following disclaimer in the
        !            13: #     documentation and/or other materials provided with the distribution.
        !            14: #
        !            15: #  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            16: #  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            17: #  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            18: #  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            19: #  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            20: #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            21: #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            22: #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            23: #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            24: #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            25: #  POSSIBILITY OF SUCH DAMAGE.
        !            26: #
        !            27:
        !            28: for e in le be; do
        !            29:   for v in 1 2; do
        !            30:     test_case disable_${e}_${v} disable_quotas "creation/removal of" ${e} ${v}
        !            31:     test_case corrupt_${e}_${v} corrupt_quotas "repair of corrupted" ${e} ${v}
        !            32:     test_case unallocated_${e}_${v} unallocated_quotas \
        !            33:                "recovery of unallocated" ${e} ${v}
        !            34:     test_case dir1_${e}_${v} dir1_quotas \
        !            35:                "successfull clear of wrong type of" ${e} ${v}
        !            36:     test_case notreg_${e}_${v} notreg_quotas \
        !            37:                "successfull clear of wrong type of" ${e} ${v}
        !            38:   done
        !            39: done
        !            40:
        !            41: disable_quotas()
        !            42: {
        !            43:        create_with_quotas $*
        !            44:
        !            45: # check that the quota inode creation didn't corrupt the filesystem
        !            46:        atf_check -s exit:0 -o "match:already clean" -o  "match:3 files" \
        !            47:                fsck_ffs -nf -F ${IMG}
        !            48: #now check fsck can properly clear the quota inode when quota flags are
        !            49: # cleared
        !            50:        atf_check -o ignore -e ignore tunefs -q nouser -q nogroup -F ${IMG}
        !            51:        atf_check -s exit:0 -o "match:SUPERBLOCK QUOTA FLAG CLEARED" \
        !            52:                fsck_ffs -fp -F ${IMG}
        !            53:        atf_check -s exit:0 -o "match:1 files, 1 used" fsck_ffs -nf -F ${IMG}
        !            54: }
        !            55:
        !            56: corrupt_quotas()
        !            57: {
        !            58:        create_with_quotas $*
        !            59:
        !            60:        local blkno=$(printf "inode 3\nblks\n" | /sbin/fsdb -nF -f ${IMG} | awk '$1 == "0:" {print $2}')
        !            61:        atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} bs=512 \
        !            62:                count=1 seek=${blkno} conv=notrunc
        !            63:        atf_check -s exit:0 \
        !            64:                -o "match:CORRUPTED USER QUOTA INODE 3 \(CLEARED\)" \
        !            65:                -o "match:NO USER QUOTA INODE \(CREATED\)" \
        !            66:                fsck_ffs -fp -F ${IMG}
        !            67:        atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
        !            68: }
        !            69:
        !            70: unallocated_quotas()
        !            71: {
        !            72:        create_with_quotas $*
        !            73:
        !            74:        atf_check -o ignore -e ignore clri ${IMG} 3
        !            75:        atf_check -s exit:0 \
        !            76:                -o "match:UNALLOCATED USER QUOTA INODE 3 \(CLEARED\)" \
        !            77:                -o "match:NO USER QUOTA INODE \(CREATED\)" \
        !            78:                fsck_ffs -fp -F ${IMG}
        !            79:        atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
        !            80: }
        !            81:
        !            82: dir1_quotas()
        !            83: {
        !            84:        create_with_quotas $*
        !            85:
        !            86:        atf_check -s exit:255 -o ignore -e ignore -x \
        !            87:                "printf 'inode 3\nchtype dir\nexit\n' | fsdb -F -f ${IMG}"
        !            88:        atf_check -s exit:0 \
        !            89:                -o "match:DIR I=3 CONNECTED. PARENT WAS I=0" \
        !            90:                -o "match:USER QUOTA INODE 3 IS A DIRECTORY" \
        !            91:                fsck_ffs -y -F ${IMG}
        !            92: }
        !            93:
        !            94: notreg_quotas()
        !            95: {
        !            96:        create_with_quotas $*
        !            97:
        !            98:        atf_check -s exit:255 -o ignore -e ignore -x \
        !            99:                "printf 'inode 3\nchtype fifo\nexit\n' | fsdb -F -f ${IMG}"
        !           100:        atf_check -s exit:0 \
        !           101:                -o "match:WRONG TYPE 4096 for USER QUOTA INODE 3 \(CLEARED\)" \
        !           102:                -o "match:NO USER QUOTA INODE \(CREATED\)" \
        !           103:                fsck_ffs -p -F ${IMG}
        !           104:        atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
        !           105: }

CVSweb <webmaster@jp.NetBSD.org>