> The guilty party here is the file TESTME. I trust you will agree that an
> 8016-byte file should use more than one block on a 1024 byte-blocksize
> filesystem (which I have)...
> No, I won't agree to that, and (more importantly) neither does the filesystem.
> You've got holes in your file, and the filesystem doesn't bother to allocate
> blocks to holes.
I received a lot of feedback on this issue, including some in private e-mail, and
all of it explaining ext2's support for sparse files. This helps me, but doesn't
solve my -real- problem. I shall elaborate:
I am trying to write my own version of quotacheck (for the sheer hell of it), and
am trying to do so in such a way that I don't depend on the internal structure of
/quota.user etc. To this end I do the following:
-create a blank quota file
-search the filesystem, compiling a list of which user owns which file (yes, I am
aware of hard/soft links) and how many blocks that file owns. This is done using
lstat(), and I do adjust the "raw" block count to get the number of filesystem
-use this info to set the quota using quotactl()
-disable quotas again, thus prompting the kernel to write its data to disc.
There are other considerations such as group quotas and various "what if ...?"
scenarios, but the approach outlined above is the one with the problem. The
problem appears thus:
-Disable quotas and delete any /quota.* files.
-Create a "null" quota file containing a zero entry for root. (I hope to move
away from this, but for now...)
-Scan the disc, but don't assign any quotas
The program reports that root is using 18253 blocks for 3189 inodes.
-Repeat the above procedure, but this time DO assign quotas
Output from the quota system: root is using 18261 blocks for 3189 inodes.
- Repeat the procedure, NOT assigning quotas
Output from the filesystem search: root is using 18256 blocks for 3189 inodes.
bash$ ls -als /quota.*
4 -rw------- 1 root root 16032 Feb 16 22:25 /quota.user
Conclusion? root's block-quota is 5 blocks astray. I have no idea where these
missing blocks are. However, I do know that the kernel allocated them all while
writing out the quota-file. And the approach the kernel uses to write the
quota-file is to set the file-position to the correct offset and then call the
file's write-operation; i.e. the quota-file is truly a sparse file. I did occur
to me to wonder whether some of the "phantom" blocks are somehow being added into
the block-quota, though.
Any insights would be welcome,