@@ -12,15 +12,34 @@ die(){ printf 'mkfile: error: %s' "$1"; exit "${2-1}"; }
12
12
usage ()
13
13
{
14
14
echo " \
15
- Usage: mkfile [ -qnv ] [ -i INFILE ] [ -b BLOCKSIZE_MAX ] size[bkgtpe] FILES...
15
+ Usage: mkfile [ -qnvp ] [-m MODE] [ -i INFILE ] [ -b BS ] size[bkgtpe] FILES...
16
16
mkfile -?
17
17
18
- max_blocksize is 1048576 bytes by default.
18
+ blocksize is 1048576 bytes by default. By default, the remainder from size%bs
19
+ is added with an additional dd pass in copy mode.
19
20
20
21
The \` b' suffix denotes block numbers; for compatibility, the default blocksize
21
22
used for this calculation is 512."
22
23
}
23
24
25
+ usage_more (){
26
+ usage
27
+ echo " Options:
28
+ -q Turn off verbose output. This is the default.
29
+ -v Turn on verbose output (looks like '{fn} {n}bytes @ {mode} -> {exit}')
30
+ -b BS Sets blocksize for copy/pipe as well as for size calculation.
31
+ -i FILE Sets the input file for dd (\` copy' mode only).
32
+ -m MODE Sets the operation mode. Possible values are:
33
+ copy dd-from-infile. Creates a regular file, slow. Default.
34
+ seek dd-seek. Creates a sparse file (bad for swap), fast. See -n.
35
+ alloc fallocate. Creates a regular file, fast.
36
+ redir printf-pat-redir. Creates a regular file, slow.
37
+
38
+ -p PAT The byte pattern to use in pipe mode. Do not use NUL bytes.
39
+
40
+ " .
41
+ }
42
+
24
43
humanreadable ()
25
44
{
26
45
multiplier=1
@@ -42,16 +61,21 @@ humanreadable ()
42
61
bs=1048576 # bigger, better, faster!
43
62
hbs=512 # the bs used for humanreadable, in order to respect 'mkfile'.
44
63
quiet=0
64
+ method=copy # copy/seek/alloc
65
+ noremain=0
66
+ verbose=0
67
+ keepgoing=0
45
68
INFILE=/dev/zero
46
69
47
- while getopts ' i:b:qnavr?' opt
70
+ while getopts ' i:b:m: qnavr?' opt
48
71
do
49
72
case $opt in
50
73
b) bs=$OPTARG hbs=$bs ;;
51
- i) INFILE=$OPTARG ;;
52
- q) quiet=1 ;;
53
- n) trunc=1 ;; # dd seek-only
54
- a) alloc=1 ;; # use fallocate instead
74
+ i) INFILE=$OPTARG ;;
75
+ q) verbose=0 ;;
76
+ k) keepgoing=1 ;;
77
+ n) method=seek ;; # dd seek-only
78
+ m) method=optarg ;;
55
79
r) noremain=1 ;; # ignore (size % bs) difference
56
80
v) verbose=1 ;; # %s %llu bytes stdout; METHOD stderr; \n stdout.
57
81
\? ) usage_more; exit ;;
0 commit comments