-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.sh
executable file
·66 lines (49 loc) · 1.16 KB
/
demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash -x
#
# Demo script for chunkfs to be run from inside UML.
#
function getSelfDirectory()
{
self="${1%/*}"
if [ ! ${self:0:1} = "/" ]; then
self="$PWD/$self"
fi
echo "$self/"
}
SELF="$(getSelfDirectory $0)"
# This is where the chunkfs user binaries are located.
BINPATH="$SELF"
MNT=/mnt
# Name of the file backing the loop device
ORIG=/loop/saved_disk
FILE=/loop/test_disk
cp ${ORIG} ${FILE}
# Unmount chunkfs and chunk file systems before stomping
umount ${MNT}
umount /dev/loop1
umount /dev/loop2
umount /dev/loop3
losetup -d /dev/loop0
losetup -d /dev/loop1
losetup -d /dev/loop2
losetup -d /dev/loop3
losetup /dev/loop0 ${FILE}
losetup -o 45056 /dev/loop1 ${FILE}
losetup -o 10530816 /dev/loop2 ${FILE}
losetup -o 21016576 /dev/loop3 ${FILE}
# Stomp head inode
OFFSET=$(((4096 * 4) + 0x0e00))
dd if=/dev/zero of=/dev/loop1 seek=${OFFSET} bs=1 count=128
# Repair individual chunks
fsck -f /dev/loop1
fsck -f /dev/loop2
fsck -f /dev/loop3
# Cross-chunk repair
${BINPATH}/cross.sh
for i in 1 2 3; do
mount -t ext2 -o user_xattr /dev/loop${i} /chunk${i}
done
${BINPATH}/mount_chunkfs /dev/loop0 ${MNT}
ls /mnt/big
ls /chunk2/1/29
exit 0