Comment 9 for bug 390833

Revision history for this message
Tyler Hicks (tyhicks) wrote : Re: du reports newly created files on ecryptfs as empty

Sorry I haven't been actively updating this bug report. Here's a brain dump:

--apparent-size uses the st_size field returned from a call to stat(). It is set in the kernel with a call to i_size_read() on the eCryptfs inode. As Tv pointed out, it works well.

By default, du uses the st_blocks (512 byte blocks) field of the stat struct to show file size. It does this because most filesystems are smart enough to account for things like holes in the files, so st_blocks * 512 may be considerably less than what you'll see in the st_size field.

What I think eCryptfs should be doing is what Mikko is alluding to by calling the lower filesystem's getattr() to get the *actual* st_blocks. What I'm undecided on is whether or not the size of the header region should be subtracted from the lower filesystem's st_blocks count. It is a small difference - the header region is only going to be 8 KB on most systems.

I'll begin writing up the patch and decide as I'm going. Feel free to weigh-in in the meantime.