1#!/bin/sh 2 3# 4# Copyright (c) 2017 Dell EMC Isilon 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 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. 15# 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 26# SUCH DAMAGE. 27# 28 29[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 30 31# No problems seen. 32 33. ../default.cfg 34 35[ -d /usr/include ] || exit 0 36here=`pwd` 37cd /tmp 38sed '1,/^EOF/d' < $here/$0 > fts3.c 39mycc -o fts3 -Wall -Wextra fts3.c || exit 1 40rm -f fts3.c 41cd $here 42 43mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint 44mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart 45 46mdconfig -a -t swap -s 3g -u $mdstart || exit 1 47bsdlabel -w md$mdstart auto 48newfs $newfs_flags md${mdstart}$part > /dev/null 49mount /dev/md${mdstart}$part $mntpoint 50 51start=`date '+%s'` 52while [ $((`date '+%s'` - start)) -lt 120 ]; do 53 pids= 54 for i in `jot 20`; do 55 cp -r /usr/include $mntpoint/$i & 56 pids="$pids $!" 57 done 58 for p in $pids; do 59 wait $p 60 done 61 (cd $mntpoint && rm -rf *) 62done & 63 64pid=$! 65s=0 66while kill -0 $pid 2> /dev/null; do 67 /tmp/fts3 $mntpoint || { s=1; break; } 68done 69kill $pid > /dev/null 2>&1 70wait $pid 71 72for i in `jot 6`; do 73 umount $mntpoint && break || sleep 10 74done 75[ $i -eq 6 ] && s=2 76mdconfig -d -u $mdstart 77rm -f /tmp/fts3 78exit $s 79EOF 80#include <sys/param.h> 81 82#include <err.h> 83#include <errno.h> 84#include <fts.h> 85#include <libutil.h> 86#include <stdint.h> 87#include <stdio.h> 88#include <stdlib.h> 89#include <string.h> 90#include <unistd.h> 91 92int 93test(char *path) 94{ 95 96 FTS *fts; 97 FTSENT *p; 98 int ftsoptions; 99 char *args[2]; 100 101 ftsoptions = FTS_PHYSICAL; 102 args[0] = path; 103 args[1] = 0; 104 105 if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) 106 err(1, "fts_open"); 107 108 while ((p = fts_read(fts)) != NULL) 109 ; 110 111 if (errno != 0 && errno != ENOENT) 112 err(1, "fts_read"); 113 if (fts_close(fts) == -1) 114 err(1, "fts_close()"); 115 116 return (0); 117} 118 119int 120main(int argc, char **argv) 121{ 122 int i; 123 124 if (argc != 2) { 125 fprintf(stderr, "Usage: %s <path>\n", argv[0]); 126 exit(1); 127 } 128 alarm(120); 129 for (i = 0; i < 100; i++) 130 test(argv[1]); 131 132 return (0); 133} 134