Repository navigation
Expand file tree
/
Copy pathrunit.sh
More file actions
120 lines (103 loc) · 2.31 KB
/
Copy pathrunit.sh
File metadata and controls
120 lines (103 loc) · 2.31 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
115
116
117
118
119
120
#Create an image
truncate -s 64K test.img
echo "test.img created"
#Format the image
./mkfs.a1fs -i 16 test.img
echo "test.img is formatted with 16 inodes"
#Mount the image
mkdir mnt
chmod 777 mnt
./a1fs test.img mnt
echo -e "my_fs is the mounted ROOT directory\n"
#Performance
cd mnt
#mkdir
echo "---------- Test creating directory ----------"
echo "--- create directory /a1 ---"
mkdir a1
cd a1
echo "--- create directory /a1/a2 ---"
mkdir a2
cd ..
echo -e "\n"
#stat
echo "---------- Test stat ----------"
echo "--- status of ROOT ---"
stat .
echo "--- status of /a1 ---"
stat ./a1
echo "--- status of /a1/a2 ---"
stat ./a1/a2
echo -e "\n"
#creat files
echo "---------- Test Creating files ----------"
echo "--- create 1.txt ---"
touch 1.txt
echo "--- create 2.txt ---"
touch 2.txt
echo "--- create 3.txt ---"
touch 3.txt
echo -e "\n"
#write and read files
echo "---------- File manipulation: READ & WRITE ----------"
echo "--- write into 1.txt ---"
echo "This is the content in 1.txt" > 1.txt
cat 1.txt
echo "--- append to 1.txt ---"
echo "This is a huge assignment~" >> 1.txt
cat 1.txt
echo "--- write into 2.txt ---"
echo "This is the content in 2.txt" > 2.txt
cat 2.txt
echo "--- overwrite the content in 2.txt"
echo "Overwriting..." > 2.txt
cat 2.txt
echo -e "\n"
#ls
echo "---------- Read directory ----------"
ls -la
echo -e "\n"
#truncate
echo "---------- Test truncate ----------"
echo "--- truncate 1.txt to 100 bytes ---"
truncate -s 100 1.txt
stat 1.txt
cat 1.txt
echo "--- truncate 1.txt to 5 bytes ---"
truncate -s 5 1.txt
stat 1.txt
cat 1.txt
echo -e "\n"
#unlink
echo "---------- Test Deleting file ----------"
echo "--- unlink/remove 1.txt ---"
unlink 1.txt
ls -la
echo -e "\n"
#rmdir
echo "---------- Delete directory ----------"
echo "--- delete /a1/a2"
rm -rf ./a1/a2
echo "--- Here is /a1 ---"
ls -la ./a1
echo -e "\n"
#rename
echo "---------- Test Rename file/directories ----------"
mkdir hi
echo "--- Rename directory from hi to hello---"
mv hi hello
echo "---------- Test Rename file/directories ----------"
touch a.txt
echo "--- Rename file a.txt to b.txt---"
mv a.txt b.txt
#unmount
echo "---------- Unmounting file system ----------"
cd ..
fusermount -u mnt
echo "file system mnt unmounted"
echo -e "\n"
echo "---------- Mount mnt again to test persistency ----------"
#mount again
./a1fs test.img mnt
cd mnt
ls -la