]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/xfs_mkfile.sh
configure: don't check for readdir
[thirdparty/xfsprogs-dev.git] / io / xfs_mkfile.sh
1 #!/bin/sh -f
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
4 #
5
6 OPTS=""
7 NOBYTES=false
8 PREALLOC=false
9 VERBOSE=false
10 VERSION=false
11 XFS_IO=`dirname $0`"/xfs_io -p xfs_mkfile"
12 USAGE="Usage: xfs_mkfile [-npvV] size file..."
13
14 while getopts "npvV" c
15 do
16 case $c in
17 n) NOBYTES=true;;
18 p) PREALLOC=true;;
19 v) VERBOSE=true;;
20 V) VERSION=true;;
21 \?) echo $USAGE 1>&2
22 exit 2
23 ;;
24 esac
25 done
26 $VERSION && $XFS_IO -V
27
28 shift `expr $OPTIND - 1`
29 [ "$1" != "" ] || exit 0
30 SIZE="$1"
31 ERRORS=0
32 shift
33
34 while [ "$1" != "" ]
35 do
36 if $VERBOSE ; then
37 $PREALLOC && echo "$1 $SIZE bytes pre-allocated"
38 $PREALLOC || echo "$1 $SIZE bytes"
39 fi
40 if $NOBYTES ; then
41 $XFS_IO -ft -c "truncate $SIZE" -- "$1"
42 elif $PREALLOC ; then
43 $XFS_IO -ftd -c "resvsp 0 $SIZE" \
44 -c "pwrite -q -S0 -b256k 0 $SIZE" \
45 -c "truncate $SIZE" -- "$1"
46 else
47 $XFS_IO -ftd -c "pwrite -q -S0 -b256k 0 $SIZE" \
48 -c "truncate $SIZE" -- "$1"
49 fi
50 [ $? -eq 0 ] || ERRORS=`expr $ERRORS + 1`
51 shift
52 done
53 exit $ERRORS