@@ -10,6 +10,7 @@ F_MOD="-rw-r--r--"
1010S_MOD=" lrwxrwxrwx"
1111MAXFILESIZE=11173888 # SIMPLEFS_MAX_EXTENTS * SIMPLEFS_MAX_BLOCKS_PER_EXTENT * SIMPLEFS_BLOCK_SIZE
1212MAXFILES=40920 # max files per dir
13+ MOUNT_TEST=100
1314
1415test_op () {
1516 local op=$1
6162filecnts=$( ls | wc -w)
6263test $filecnts -eq $MAXFILES || echo " Failed, it should be $MAXFILES files"
6364find . -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; }
64101
65102# hard link
66103test_op ' ln file hdlink'
@@ -96,4 +133,4 @@ check_exist $S_MOD 1 symlink
96133sleep 1
97134popd > /dev/null
98135sudo umount test
99- sudo rmmod simplefs
136+ sudo rmmod simplefs
0 commit comments