xref: /aosp_15_r20/external/e2fsprogs/tests/t_quota_add/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1FSCK_OPT=-yf
2
3if [ "$QUOTA" != "y" ]; then
4	echo "$test_name: $test_description: skipped"
5	return 0
6fi
7
8$MKE2FS -q -F -o Linux -b 4096 -O quota -E quotatype=prjquota $TMPFILE 10000 > $test_name.log 2>&1
9status=$?
10if [ "$status" != 0 ] ; then
11	echo "mke2fs failed" > $test_name.failed
12	echo "$test_name: $test_description: failed"
13	return $status
14fi
15
16for type in usrquota grpquota; do
17	$TUNE2FS -Q $type $TMPFILE >> $test_name.log 2>&1
18	status=$?
19	if [ "$status" != 0 ] ; then
20		echo "tune2fs -O quota failed with $status" > $test_name.failed
21		echo "$test_name: $test_description: failed"
22		return $status
23	fi
24done
25
26UUSAGE=$($DEBUGFS 2>/dev/null -R "lq user" $TMPFILE | grep "^ *0 ")
27for type in group project; do
28	TUSAGE=$($DEBUGFS 2>/dev/null -R "lq $type" $TMPFILE | grep "^ *0 ")
29	if [ "$TUSAGE" != "$UUSAGE" ]; then
30		echo "user and $type quota entries are different" >$test_name.failed
31		echo "$test_name: $test_description: failed"
32		return 1
33	fi
34done
35
36$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
37status=$?
38if [ "$status" = 0 ] ; then
39	echo "$test_name: $test_description: ok"
40	touch $test_name.ok
41else
42	echo "e2fsck with quota enabled failed with $status" > $test_name.failed
43	echo "$test_name: $test_description: failed"
44	return $status
45fi
46rm -f $TMPFILE
47