@@ -10,6 +10,7 @@ F_MOD="-rw-r--r--"
10
10
S_MOD=" lrwxrwxrwx"
11
11
MAXFILESIZE=11173888 # SIMPLEFS_MAX_EXTENTS * SIMPLEFS_MAX_BLOCKS_PER_EXTENT * SIMPLEFS_BLOCK_SIZE
12
12
MAXFILES=40920 # max files per dir
13
+ MOUNT_TEST=100
13
14
14
15
test_op () {
15
16
local op=$1
61
62
filecnts=$( ls | wc -w)
62
63
test $filecnts -eq $MAXFILES || echo " Failed, it should be $MAXFILES files"
63
64
find . -name ' [0-9]*.txt' | xargs -n 2000 sudo rm
65
+ sync
66
+
67
+ # create 100 files with filenames inside
68
+ for (( i= 1 ; i<= $MOUNT_TEST ; i++ ))
69
+ do
70
+ echo file_$i | sudo tee file_$i .txt > /dev/null && echo " file_$i .txt created."
71
+ done
72
+ sync
73
+
74
+ # unmount and remount the filesystem
75
+ echo " Unmounting filesystem..."
76
+ popd > /dev/null || { echo " popd failed" ; exit 1; }
77
+ sudo umount test || { echo " umount failed" ; exit 1; }
78
+ sleep 1
79
+ echo " Remounting filesystem..."
80
+ sudo mount -t simplefs -o loop $IMAGE test || { echo " mount failed" ; exit 1; }
81
+ echo " Remount succeeds."
82
+ pushd test > /dev/null || { echo " pushd failed" ; exit 1; }
83
+
84
+ # check if files exist and content is correct after remounting
85
+ for (( i= 1 ; i<= $MOUNT_TEST ; i++ ))
86
+ do
87
+ if [[ -f " file_$i .txt" ]]; then
88
+ content=$( cat " file_$i .txt" | tr -d ' \000' )
89
+ if [[ " $content " == " file_$i " ]]; then
90
+ echo " Success: file_$i .txt content is correct."
91
+ else
92
+ echo " Failed: file_$i .txt content is incorrect."
93
+ exit 1
94
+ fi
95
+ else
96
+ echo " Failed: file_$i .txt does not exist."
97
+ exit 1
98
+ fi
99
+ done
100
+ find . -name ' file_[0-9]*.txt' | xargs sudo rm || { echo " Failed to delete files" ; exit 1; }
64
101
65
102
# hard link
66
103
test_op ' ln file hdlink'
@@ -96,4 +133,4 @@ check_exist $S_MOD 1 symlink
96
133
sleep 1
97
134
popd > /dev/null
98
135
sudo umount test
99
- sudo rmmod simplefs
136
+ sudo rmmod simplefs
0 commit comments