test with qa0327.0 tree quota given user bill 150k space,it is correct that it is failed to write a 200k size file. however when the function ftruncate() is used to fill 200k size file,it returned true and the file was created. the source of test program is attached. not too sure it is a quota issue or glibc issue... [root@dolphins /root]# cat /etc/fstab LABEL=/ / ext2 defaults 1 1 LABEL=/bhuang /bhuang ext2 defaults,usrquota 1 2LABEL=/boot /boot ext2 defaults 1 2 /dev/fd0 /mnt/floppy auto noauto,owner 0 0 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/hda6 swap swap defaults 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 [root@dolphins /root]# mount /bhuang [root@dolphins /root]# tocuh /bhuang/quota.user bash: tocuh: command not found [root@dolphins /root]# touch /bhuang/quota.user [root@dolphins /root]# convertquota /bhuang [root@dolphins /root]# mount -o remount /bhuang [root@dolphins /root]# quotacheck -a [root@dolphins /root]# quotaon -a [root@dolphins /root]# edquota bill [root@dolphins /root]# repquota bill [root@dolphins /root]# edquota bill [root@dolphins /root]# [root@station23 bhuang]# cat edquota-bill Quotas for user bill: Filesystem Blocks Soft Hard Inodes Soft Hard /dev/hda7 200 100 150 1 0 0 ~ [bill@dolphins bill]$ ./a.out ide0(3,7): warning, user block quota exceeded. ide0(3,7): write failed, user block limit reached. write error!! ftruncate result = 0 [bill@dolphins bill]$ the result of test program: ot@dolphins /root]# ll /bhuang -rw------- 1 root root 200 37n 30 21:28 1 -rw------- 1 root root 7168 37n 30 21:34 aquota.user -rw------- 1 root root 2048 37n 30 21:30 aquota.user~ drwxr-xr-x 2 root root 16384 37n 30 19:17 lost+found -rw-r--r-- 1 root root 0 37n 30 21:30 quota.user -rw-r--r-- 1 bill bill 204800 37n 30 21:33 testfile [root@dolphins /root]#
Created attachment 14223 [details] test program:filetest.c
What ls -l sais is completely uninteresting here, try du -b instead. Quota is about used blocks on the disk, with holes you can have several gigabytes large file which occupies only a few kilobytes on the disk e.g.
result of du -b testfile: 151552 testfile The behaviour of quota is correct? and ftruncate() is also correct?
Yes, the behaviour is correct. The file occupies less than 150K on the disk.