|
| 1 | +#! /bin/bash |
| 2 | +set -o errexit -o pipefail -o nounset |
| 3 | + |
| 4 | +target="${1}" |
| 5 | +root="${target}/__tree_with_hardlinks__" |
| 6 | +mkdir -pv "${root}" |
| 7 | + |
| 8 | +create_file() { |
| 9 | + mkdir -p "$(dirname "${root}/$1")" |
| 10 | + head -c "$2" /dev/zero >"${root}/$1" |
| 11 | +} |
| 12 | + |
| 13 | +create_hardlink() { |
| 14 | + mkdir -p "$(dirname "${root}/$2")" |
| 15 | + ln "${root}/$1" "${root}/$2" |
| 16 | +} |
| 17 | + |
| 18 | +# file 01: 128 bytes, 1 hardlink |
| 19 | +create_file a/file01 128 |
| 20 | +create_hardlink a/file01 b/link01 |
| 21 | + |
| 22 | +# file 02: 256 bytes, 3 hardlinks |
| 23 | +create_file a/b/file02 256 |
| 24 | +create_hardlink a/b/file02 c/link02a |
| 25 | +create_hardlink a/b/file02 c/d/link02b |
| 26 | +create_hardlink a/b/file02 e/link02c |
| 27 | + |
| 28 | +# file 03: 512 bytes, 5 hardlinks |
| 29 | +create_file b/c/file03 512 |
| 30 | +create_hardlink b/c/file03 f/link03a |
| 31 | +create_hardlink b/c/file03 f/g/link03b |
| 32 | +create_hardlink b/c/file03 f/g/h/link03c |
| 33 | +create_hardlink b/c/file03 i/link03d |
| 34 | +create_hardlink b/c/file03 j/k/link03e |
| 35 | + |
| 36 | +# file 04: 1024 bytes, 7 hardlinks |
| 37 | +create_file c/d/e/file04 1024 |
| 38 | +create_hardlink c/d/e/file04 l/link04a |
| 39 | +create_hardlink c/d/e/file04 l/m/link04b |
| 40 | +create_hardlink c/d/e/file04 l/m/n/link04c |
| 41 | +create_hardlink c/d/e/file04 o/link04d |
| 42 | +create_hardlink c/d/e/file04 o/p/link04e |
| 43 | +create_hardlink c/d/e/file04 q/link04f |
| 44 | +create_hardlink c/d/e/file04 r/s/link04g |
| 45 | + |
| 46 | +# file 05: 2048 bytes, 2 hardlinks |
| 47 | +create_file d/file05 2048 |
| 48 | +create_hardlink d/file05 s/t/link05a |
| 49 | +create_hardlink d/file05 u/link05b |
| 50 | + |
| 51 | +# file 06: 4096 bytes, 4 hardlinks |
| 52 | +create_file e/f/file06 4096 |
| 53 | +create_hardlink e/f/file06 v/link06a |
| 54 | +create_hardlink e/f/file06 v/w/link06b |
| 55 | +create_hardlink e/f/file06 x/link06c |
| 56 | +create_hardlink e/f/file06 x/y/z/link06d |
| 57 | + |
| 58 | +# file 07: 8192 bytes, 10 hardlinks |
| 59 | +create_file f/g/h/file07 8192 |
| 60 | +for i in $(seq 1 10); do |
| 61 | + create_hardlink f/g/h/file07 "aa/bb${i}/link07" |
| 62 | +done |
| 63 | + |
| 64 | +# file 08: 100 bytes, 15 hardlinks |
| 65 | +create_file g/file08 100 |
| 66 | +for i in $(seq 1 15); do |
| 67 | + create_hardlink g/file08 "cc/dd${i}/link08" |
| 68 | +done |
| 69 | + |
| 70 | +# file 09: 200 bytes, 20 hardlinks |
| 71 | +create_file h/i/file09 200 |
| 72 | +for i in $(seq 1 20); do |
| 73 | + create_hardlink h/i/file09 "ee/ff${i}/link09" |
| 74 | +done |
| 75 | + |
| 76 | +# file 10: 300 bytes, 30 hardlinks |
| 77 | +create_file i/j/k/file10 300 |
| 78 | +for i in $(seq 1 30); do |
| 79 | + create_hardlink i/j/k/file10 "gg/hh${i}/link10" |
| 80 | +done |
| 81 | + |
| 82 | +# file 11: 400 bytes, 1 hardlink |
| 83 | +create_file j/file11 400 |
| 84 | +create_hardlink j/file11 ii/link11 |
| 85 | + |
| 86 | +# file 12: 600 bytes, 2 hardlinks |
| 87 | +create_file k/l/file12 600 |
| 88 | +create_hardlink k/l/file12 jj/link12a |
| 89 | +create_hardlink k/l/file12 jj/kk/link12b |
| 90 | + |
| 91 | +# file 13: 700 bytes, 8 hardlinks |
| 92 | +create_file l/m/n/file13 700 |
| 93 | +for i in $(seq 1 8); do |
| 94 | + create_hardlink l/m/n/file13 "ll/mm${i}/link13" |
| 95 | +done |
| 96 | + |
| 97 | +# file 14: 900 bytes, 12 hardlinks |
| 98 | +create_file m/file14 900 |
| 99 | +for i in $(seq 1 12); do |
| 100 | + create_hardlink m/file14 "nn/oo${i}/link14" |
| 101 | +done |
| 102 | + |
| 103 | +# file 15: 1500 bytes, 25 hardlinks |
| 104 | +create_file n/o/file15 1500 |
| 105 | +for i in $(seq 1 25); do |
| 106 | + create_hardlink n/o/file15 "pp/qq${i}/link15" |
| 107 | +done |
| 108 | + |
| 109 | +# file 16: 3000 bytes, 40 hardlinks |
| 110 | +create_file o/p/q/file16 3000 |
| 111 | +for i in $(seq 1 40); do |
| 112 | + create_hardlink o/p/q/file16 "rr/ss${i}/link16" |
| 113 | +done |
| 114 | + |
| 115 | +# file 17: 5000 bytes, 50 hardlinks |
| 116 | +create_file p/file17 5000 |
| 117 | +for i in $(seq 1 50); do |
| 118 | + create_hardlink p/file17 "tt/uu${i}/link17" |
| 119 | +done |
| 120 | + |
| 121 | +# file 18: 750 bytes, 6 hardlinks |
| 122 | +create_file q/r/file18 750 |
| 123 | +create_hardlink q/r/file18 vv/link18a |
| 124 | +create_hardlink q/r/file18 vv/ww/link18b |
| 125 | +create_hardlink q/r/file18 vv/ww/xx/link18c |
| 126 | +create_hardlink q/r/file18 yy/link18d |
| 127 | +create_hardlink q/r/file18 yy/zz/link18e |
| 128 | +create_hardlink q/r/file18 aaa/link18f |
| 129 | + |
| 130 | +# file 19: 1234 bytes, 9 hardlinks |
| 131 | +create_file r/s/t/file19 1234 |
| 132 | +for i in $(seq 1 9); do |
| 133 | + create_hardlink r/s/t/file19 "bbb/ccc${i}/link19" |
| 134 | +done |
| 135 | + |
| 136 | +# file 20: 10240 bytes, 11 hardlinks |
| 137 | +create_file s/file20 10240 |
| 138 | +for i in $(seq 1 11); do |
| 139 | + create_hardlink s/file20 "ddd/eee${i}/link20" |
| 140 | +done |
0 commit comments