On linux, what does it mean when a directory has size 0 instead of 4096?

Posted by kdt on Server Fault See other posts from Server Fault or by kdt
Published on 2011-02-07T11:14:49Z Indexed on 2011/02/08 23:27 UTC
Read the original article Hit count: 254

Filed under:
|
|
|

Here's a strange thing I haven't seen before -- a directory whose size is reported by ls as 0 instead of 4096, and I can't create any files within it.

# ls -ld lib home
drwxr-xr-x.  2 root root    0 Feb  7 03:10 home  <-- it has zero size
dr-xr-xr-x. 11 root root 4096 Feb  4 09:28 lib
# touch home/foo
touch: cannot touch `home/foo': No such file or directory  <-- and I can't create files in it
# rm home
rm: cannot remove `home': Is a directory   <-- look, it really is a dir

So what does it mean for a directory to have size 0 instead of 4096?

Filesystem is ext4 on fedora core 14.

The output of mount is:

/dev/mapper/vg_dev-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/vda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

Output of du -s /home:

0   /home

Output of stat /home:

  File: `/home'
  Size: 0           Blocks: 0          IO Block: 1024   directory
Device: 15h/21d Inode: 34913       Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-02-07 03:45:46.188995765 -0800
Modify: 2011-02-07 03:11:59.980995019 -0800
Change: 2011-02-06 07:58:45.874995002 -0800

© Server Fault or respective owner

Related posts about linux

Related posts about directory