4 # Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # Demonstrate livelock with "umount -f" seen both with UFS and MSDOS
33 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
38 dede $D 1m 1k || exit 1
43 sed '1,/^EOF/d' < $odir/$0 > umountf3.c
44 cc -o umountf3 -Wall umountf3.c
49 mount | grep "$mntpoint" | grep md${mdstart} > /dev/null && umount $mntpoint
50 mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart}
52 mdconfig -a -t vnode -f $D -u ${mdstart}
53 bsdlabel -w md${mdstart} auto
54 newfs md${mdstart}${part} > /dev/null 2>&1
55 mount /dev/md${mdstart}${part} $mntpoint
56 #newfs_msdos -F 32 -b 8192 /dev/md${mdstart}a
57 #mount -t msdosfs /dev/md${mdstart}a $mntpoint
58 export RUNDIR=$mntpoint/stressX
60 (cd /$mntpoint; /tmp/umountf3) &
63 echo "umount -f $mntpoint"
65 mdconfig -d -u $mdstart
66 rm -f $D /tmp/umountf3
75 #include <sys/param.h>
78 static unsigned long size = 1024 * 1024 * 2;
81 main(int argc, char **argv)
83 int buf[1024], index, to, n;
88 sprintf(file,"p%06d", getpid());
89 if ((fd = open(file, O_CREAT | O_RDWR, 0666)) == -1)
90 err(1, "creat(%s)", file);
95 while (index < size) {
96 if (index + to > size)
99 if (write(fd, buf, to) != to)
100 err(1, "write(%s), %s:%d", file, __FILE__, __LINE__);
103 if (lseek(fd, 0, 0) == -1)
106 while (index < size) {
107 if (index + to > size)
109 if ((n = read(fd, buf, to)) != to)
110 err(1, "rw read(%d, %d, %d). %s.%d", n, to, index, __FILE__, __LINE__);
113 if (lseek(fd, 0, 0) == -1)
118 err(1, "close(%s), %s:%d", file, __FILE__, __LINE__);
119 if (unlink(file) == -1)
120 err(1, "unlink(%s), %s:%d", file, __FILE__, __LINE__);