# SPDX-License-Identifier: BSD-2-Clause1#2# Copyright (c) 2024 ConnectWise3# All rights reserved.4#5# Redistribution and use in source and binary forms, with or without6# modification, are permitted provided that the following conditions7# are met:8# 1. Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# 2. Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR15# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES16# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.17# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,18# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT19# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,20# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY21# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF23# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2425. $(atf_get_srcdir)/../../cam/ctl/ctl.subr2627# Regression test for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=28340228#29# Almost any fuse file system would work, but this tests uses fusefs-ext230# because it's simple and its download is very small.31atf_test_case remove_lun_with_atime cleanup32remove_lun_with_atime_head()33{34atf_set "descr" "Remove a fuse-backed CTL LUN when atime is enabled"35atf_set "require.user" "root"36atf_set "require.progs" "fuse-ext2 mkfs.ext2"37}38remove_lun_with_atime_body()39{40MOUNTPOINT=$PWD/mnt41atf_check mkdir $MOUNTPOINT42atf_check truncate -s 1g ext2.img43atf_check mkfs.ext2 -q ext2.img44# Note: both default_permissions and atime must be enabled45atf_check fuse-ext2 -o default_permissions,allow_other,rw+ ext2.img \46$MOUNTPOINT4748atf_check truncate -s 1m $MOUNTPOINT/file49create_block -o file=$MOUNTPOINT/file5051# Force fusefs to open the file, and dirty its atime52atf_check dd if=/dev/$dev of=/dev/null count=1 status=none5354# Finally, remove the LUN. Hopefully it won't panic.55atf_check -o ignore ctladm remove -b block -l $LUN5657rm lun-create.txt # So we don't try to remove the LUN twice58}59remove_lun_with_atime_cleanup()60{61cleanup62umount $PWD/mnt63}6465atf_init_test_cases()66{67atf_add_test_case remove_lun_with_atime68}697071