11 echo "Usage: $1 <scratch dir> [seed]"
12 echo "(If no seed is given, it will be randomly generated.)"
16 if [ -z "$scratch_dir" ]; then
17 print_usage
"$0" 'No scratch dir given' >&2
21 if [ ! -d "$scratch_dir" ]; then
22 print_usage
"$0" "$scratch_dir is not a directory" >&2
27 if [ -z "$seed" ]; then
39 echo 'Error: This directory seems to be in use already' >&2
43 for ((i
= 0; i
< $mount_count; i
++)); do
44 printf "Setting up fs %i/%i...\r" "$((i + 1))" "$mount_count"
47 truncate
-s 512M fs
$i.img
49 devs
[i
]=$
(sudo losetup
-f --show fs
$i.img
)
53 top_level_mounts
=$
((RANDOM
% mount_count
+ 1))
56 echo 'root' > share
/some-file
58 for ((i
= 0; i
< $top_level_mounts; i
++)); do
59 printf "Mounting fs %i/%i...\r" "$((i + 1))" "$mount_count"
62 touch share
/mnt
$i/not-mounted
63 sudo mount
"${devs[i]}" share
/mnt
$i
64 sudo chown
"$(id -u):$(id -g)" share
/mnt
$i
66 pushd share
/mnt
$i >/dev
/null
68 nesting
=$
((RANDOM
% 4))
69 for ((j
= 0; j
< $nesting; j
++)); do
85 for ((; i
< $mount_count; i
++)); do
86 printf "Mounting fs %i/%i...\r" "$((i + 1))" "$mount_count"
88 mp_i
=$
((i
% top_level_mounts
))
90 pushd share
/mnt
$mp_i >/dev
/null
94 if cd sub
2>/dev
/null
; then
96 elif [ -n "$sub_mp" ] && cd "$sub_mp" 2>/dev
/null
; then
103 touch mnt
$i/not-mounted
104 sudo mount
"${devs[i]}" mnt
$i
105 sudo chown
"$(id -u):$(id -g)" mnt
$i
109 nesting
=$
((RANDOM
% 4))
110 for ((j
= 0; j
< $nesting; j
++)); do
111 cat > some-file
<<EOF
119 cat > some-file
<<EOF