-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunit.sh
More file actions
114 lines (99 loc) · 2.69 KB
/
runit.sh
File metadata and controls
114 lines (99 loc) · 2.69 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
echo "==========Let's Start!=========="
mkdir /tmp/mnt
truncate -s 64M img
./mkfs.a1fs -i 100 img
./a1fs img /tmp/mnt
echo "After mounting, the current state of the filesystem should look like the following"
echo ""
echo ""
ls -al /tmp/mnt
echo ""
echo "-------------Makes one directory--------------"
mkdir /tmp/mnt/dir
ls -al /tmp/mnt
echo "Remove it"
rmdir /tmp/mnt/dir
ls -al /tmp/mnt
echo ""
echo "-------------Make two directories that are direct children of root-------------"
mkdir /tmp/mnt/dir1
mkdir /tmp/mnt/dir2
ls -al /tmp/mnt
echo "Try to rename dir1 to dir2"
mv /tmp/mnt/dir1 /tmp/mnt/dir2
ls -al /tmp/mnt
echo "There should be a dir1 under dir2 now"
ls -al /tmp/mnt/dir2
echo "Clear disk"
rmdir /tmp/mnt/dir2/dir1
rmdir /tmp/mnt/dir2
echo ""
echo "-------------Make a bunch of nested directories-------------"
mkdir /tmp/mnt/a
mkdir /tmp/mnt/a/b
mkdir /tmp/mnt/a/b/c
mkdir /tmp/mnt/d
ls -al /tmp/mnt
echo "Try to rename c to d"
mv /tmp/mnt/a/b /tmp/mnt/d
echo "There should be 'b' under 'd' and 'c' under 'b'"
ls -al /tmp/mnt/d
ls -al /tmp/mnt/d/b
echo "'a' should be left alone"
ls /tmp/mnt/a
echo "Clear disk"
rmdir /tmp/mnt/a
rmdir /tmp/mnt/d/b/c
rmdir /tmp/mnt/d/b
rmdir /tmp/mnt/d
echo ""
echo "-------------Make one directory-------------"
mkdir /tmp/mnt/a
ls -al /tmp/mnt
echo "Try to rename 'a' to 'b' where 'b' does not exist"
mv /tmp/mnt/a /tmp/mnt/b
ls -al /tmp/mnt
echo "There should only be a 'b' now"
ls -al /tmp/mnt
echo "Clear disk"
rmdir /tmp/mnt/b
echo ""
echo "-------------Creates an empty file-------------"
touch /tmp/mnt/file1
echo "Checks the information about dir to make sure file1 is successfully created"
ls -al /tmp/mnt
echo ""
echo "-------------Write something to file1-------------"
echo "I love the CSC369!" > /tmp/mnt/file1
echo "The byte number of file1 should not be zero now"
ls -al /tmp/mnt
echo ""
echo "-------------Show the message in file1-------------"
cat /tmp/mnt/file1
echo ""
echo "-------------Show the bit-wise map of file1-------------"
xxd /tmp/mnt/file1
echo ""
echo "-------------Try to append file1 with other message-------------"
echo "!963CSC evol I" >> /tmp/mnt/file1
xxd /tmp/mnt/file1
echo ""
echo "-------------Unlinks file1-------------"
ls -al /tmp/mnt
unlink /tmp/mnt/file1
ls -al /tmp/mnt
echo ""
echo "-------------Create a new file and truncate it to the 4096B-------------"
touch /tmp/mnt/test
truncate -s 4096 /tmp/mnt/test
ls -al /tmp/mnt
echo ""
echo "-------------Use truncate to shrink the file to 100 bytes-------------"
truncate -s 100 /tmp/mnt/test
ls -al /tmp/mnt
echo ""
echo "-------------Unmount the file system and mount it back-------------"
fusermount -u /tmp/mnt
./a1fs img /tmp/mnt
ls -al /tmp/mnt
echo "===========The End==========="