1# SPDX-License-Identifier: BSD-2-Clause 2# 3# Copyright (c) 2024 ConnectWise 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 DOCUMENTATION IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26. $(atf_get_srcdir)/../../cam/ctl/ctl.subr 27 28# Regression test for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283402 29# 30# Almost any fuse file system would work, but this tests uses fusefs-ext2 31# because it's simple and its download is very small. 32atf_test_case remove_lun_with_atime cleanup 33remove_lun_with_atime_head() 34{ 35 atf_set "descr" "Remove a fuse-backed CTL LUN when atime is enabled" 36 atf_set "require.user" "root" 37 atf_set "require.progs" "fuse-ext2 mkfs.ext2" 38} 39remove_lun_with_atime_body() 40{ 41 MOUNTPOINT=$PWD/mnt 42 atf_check mkdir $MOUNTPOINT 43 atf_check truncate -s 1g ext2.img 44 atf_check mkfs.ext2 -q ext2.img 45 # Note: both default_permissions and atime must be enabled 46 atf_check fuse-ext2 -o default_permissions,allow_other,rw+ ext2.img \ 47 $MOUNTPOINT 48 49 atf_check truncate -s 1m $MOUNTPOINT/file 50 create_block -o file=$MOUNTPOINT/file 51 52 # Force fusefs to open the file, and dirty its atime 53 atf_check dd if=/dev/$dev of=/dev/null count=1 status=none 54 55 # Finally, remove the LUN. Hopefully it won't panic. 56 atf_check -o ignore ctladm remove -b block -l $LUN 57 58 rm lun-create.txt # So we don't try to remove the LUN twice 59} 60remove_lun_with_atime_cleanup() 61{ 62 cleanup 63 umount $PWD/mnt 64} 65 66atf_init_test_cases() 67{ 68 atf_add_test_case remove_lun_with_atime 69} 70