1#!/bin/sh 2 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13# the GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19 20# 21# FILE(s) : linktest.sh README 22# DESCRIPTION : Regression test for max links per file 23# USE : linktest.sh <number of symlinks> <number of hardlinks> 24# AUTHOR : Ngie Cooper (yaneurabeya@gmail.com) 25# HISTORY : 26# A rewrite of testcases/kernel/fs/linktest.pl 27 28export TCID=linker01 29export TST_TOTAL=2 30export TST_COUNT=1 31. test.sh 32 33if [ $# -ne 2 ]; then 34 tst_resm TBROK "usage: $0 {softlink count} {hardlink count}" 35 exit 1 36fi 37 38tst_tmpdir 39 40mkdir hlink.$$ slink.$$ && touch hlink.$$/hfile slink.$$/sfile 41 42do_link() { 43 pfix=$1 44 ln_opts=$2 45 limit=$3 46 prefix_msg=$4 47 48 lerrors=0 49 50 i=0 51 52 cd "${pfix}link.$$" 53 while [ $i -lt $limit ]; do 54 if ! ln ${ln_opts} "$PWD/${pfix}file" ${pfix}file${i}; then 55 : $(( lerrors += 1 )) 56 fi 57 : $(( i+= 1 )) 58 done 59 cd .. 60 61 if [ $lerrors -eq 0 ]; then 62 RTYPE=TPASS 63 else 64 RTYPE=TFAIL 65 fi 66 67 tst_resm $RTYPE "$prefix_msg Link Errors: $lerrors" 68 69 : $(( TST_COUNT += 1 )) 70 71} 72 73do_link s "-s" ${1} "Symbolic" 74do_link h "" ${2} "Hard" 75 76rm -Rf hlink.$$ slink.$$ 77 78tst_rmdir 79tst_exit 80