← Back to team overview

ecryptfs team mailing list archive

[Bug 390833] 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.

-- 
du reports newly created files on ecryptfs as empty
https://bugs.launchpad.net/bugs/390833
You received this bug notification because you are a member of eCryptfs,
which is subscribed to ecryptfs-utils in ubuntu.

Status in eCryptfs - Enterprise Cryptographic Filesystem: In Progress
Status in “ecryptfs-utils” package in Ubuntu: Triaged

Bug description:
I'm using an encrypted home directory on Ubuntu Jaunty. When I create a new file in my home directory or copy and existing file/folder, du shows its size as zero bytes:

das@serenity ~ > dd if=/dev/zero of=test bs=1024 count=1024
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.114302 s, 9.2 MB/s
das@serenity ~ > du test
0	test
das@serenity ~ > ll test
-rw-r--r-- 1 das das 1048576 2009-06-22 22:14 test

du keeps reporting a size of zero bytes until the encrypted directory is remounted. After that, the output seems to be correct.