On 2/25/21 6:56 PM, John Reiser wrote: >> Tools such as ls or stat report the size of a directory. Of course it is not the content size. >> stat -c %s /home/sergio/.config >> 6550 >> >> What does 6550 mean in btrfs context? > > Regardless of filesystem type, the size of a directory is the sum of the sizes > of the struct linux_dirent (or linux_dirent64) for the filenames of the contained files. > See the manual page "man 2 getdents". That's not correct; dirents are in-memory structures, unrelated to what the [fl]stat(2) interface used by ls returns for a directory. The size returned by stat(2) (aka ls) of a directory inode is filesystem implementation dependent, and AFAIK has no well-defined meaning. stat(2) refers to st_size only for files and symlinks, not for directories. Same w/ POSIX: off_t st_size For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. So, as one example on ext4 - directories never shrink. # mkdir dir # ls -ld dir drwxr-xr-x. 2 root root 4096 Feb 26 00:48 dir # touch dir/123456789 # ls -ld dir drwxr-xr-x. 2 root root 4096 Feb 26 01:00 dir # for I in `seq 1 2000`; do touch dir/longfilename$I; done # ls -ld dir drwxr-xr-x. 2 root root 69632 Feb 26 00:49 dir # rm -f dir/* # ls -ld dir drwxr-xr-x. 2 root root 69632 Feb 26 00:49 dir 69632 byte directory with no files in it, wheeee. xfs is different: # mkdir dir # ls -ld dir drwxr-xr-x. 2 root root 6 Feb 26 00:58 dir # touch dir/123456789 # ls -ld dir drwxr-xr-x. 2 root root 23 Feb 26 00:59 dir # for I in `seq 1 2000`; do touch dir/longfilename$I; done # ls -ld dir drwxr-xr-x. 2 root root 65536 Feb 26 00:59 dir # rm -f dir/* # ls -ld dir drwxr-xr-x. 2 root root 6 Feb 26 00:59 dir btrfs is still different: # mkdir dir # ls -ld dir drwxr-xr-x. 1 root root 0 Feb 26 01:05 dir # touch dir/123456789 # ls -ld dir drwxr-xr-x. 1 root root 18 Feb 26 01:06 dir # for I in `seq 1 2000`; do touch dir/longfilename$I; done # ls -ld dir drwxr-xr-x. 1 root root 61804 Feb 26 01:06 dir # rm -f dir/* # ls -ld dir drwxr-xr-x. 1 root root 0 Feb 26 01:06 dir In short, "size" of a dir doesn't tell you much. -Eric _______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure