Path: blob/main/tools/test/stress2/misc/beneath3.sh
39536 views
#!/bin/sh12#3# SPDX-License-Identifier: BSD-2-Clause4#5# Copyright (c) 2019 Dell EMC Isilon6#7# Redistribution and use in source and binary forms, with or without8# modification, are permitted provided that the following conditions9# are met:10# 1. Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# 2. Redistributions in binary form must reproduce the above copyright13# notice, this list of conditions and the following disclaimer in the14# documentation and/or other materials provided with the distribution.15#16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26# SUCH DAMAGE.27#2829# vput: 0xfffff808d79c0278 is not locked but should be30# KDB: enter: lock violation31# Test scenario suggestions by kib@ and markj@3233# Fixed by r348052.3435. ../default.cfg36[ `id -u` -ne 0 ] && echo "Must be root!" && exit 13738dir=/tmp39odir=`pwd`40cd $dir41sed '1,/^EOF/d' < $odir/$0 > $dir/beneath3.c42mycc -o beneath3 -Wall -Wextra -O0 -g beneath3.c || exit 143rm -f beneath3.c44cd $odir4546set -e47mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint48[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart49mdconfig -a -t swap -s 1g -u $mdstart50newfs $newfs_flags md$mdstart > /dev/null51mount /dev/md$mdstart $mntpoint52set +e5354cd $mntpoint55(cd /usr; $dir/beneath3)56s=$?57[ -f beneath3.core -a $s -eq 0 ] &&58{ ls -l beneath3.core; mv beneath3.core $dir; s=1; }59cd $odir6061for i in `jot 6`; do62mount | grep -q "on $mntpoint " || break63umount $mntpoint && break || sleep 1064[ $i -eq 6 ] &&65{ echo FATAL; fstat -mf $mntpoint; exit 1; }66done67mdconfig -d -u $mdstart68rm -rf $dir/beneath369exit $s7071EOF72#include <sys/types.h>7374#include <err.h>75#include <errno.h>76#include <fcntl.h>7778int79main(void)80{81int fd;82char file[] = "/..";8384errno = 0;85fd = open(file, O_CREAT | O_RDONLY | O_RESOLVE_BENEATH);86if (fd != -1 || errno != ENOTCAPABLE)87err(1, "open(%s) returns %d", file, fd);8889return (0);90}919293