1#!/bin/sh 2 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6# Copyright (c) 2023 Peter Holm <pho@FreeBSD.org> 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27# SUCH DAMAGE. 28# 29 30# Test mounting of snapshots for different UFS types 31 32# Seen: mount of a -O1 snapshot failed 33# Fixed by: 34# f1549d7d5229 Write out corrected superblock when creating a UFS/FFS snapshot. 35 36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 37 38. ../default.cfg 39 40set -u 41s=0 42m2=$((mdstart + 1)) 43mp2=$mntpoint$m2 44[ -d $mp2 ] || mkdir -p $mp2 45mount | grep -q "on $mntpoint " && umount -f $mntpoint 46[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart 47[ -c /dev/md$m2 ] && mdconfig -d -u $m2 48mdconfig -a -t swap -s 2g -u $mdstart || exit 1 49for newfs_flags in "-O2" "-U" "-j" "-O1"; do 50 echo "newfs $newfs_flags md$mdstart" 51 newfs $newfs_flags md$mdstart > /dev/null 52 mount /dev/md$mdstart $mntpoint 53 touch $mntpoint/file 54 55 rm -f $mntpoint/.snap/stress2 56 mksnap_ffs $mntpoint $mntpoint/.snap/stress2 || { s=1; break; } 57 mdconfig -a -t vnode -f $mntpoint/.snap/stress2 -u $m2 -o readonly || 58 { s=2; break; } 59 mount -t ufs -o ro /dev/md$m2 $mp2 || { 60 echo "mount of a $newfs_flags snapshot failed" 61 dumpfs -s /dev/md$m2; s=3; break; } 62 [ -f $mp2/file ] || { s=4; ls -l $mp2; } 63 umount $mp2 64 mdconfig -d -u $m2 65 umount $mntpoint 66done 67mount | grep -q "on $mntpoint " && umount $mntpoint 68 69mdconfig -d -u $mdstart 70exit $s 71