7 ms·
Examples: The filesize reported by stat() may or may not have an relation to actual disk space consumed. Counting all files and adding up the stat() filesize,
by zaarn 8y ago
Examples:
The filesize reported by stat() may or may not have an relation to actual disk space consumed. Counting all files and adding up the stat() filesize, accounting for hardlinks, symlinks and all other normal unix weirdness including Sparse files, you could still find yourself a few bytes up to gigabytes off.
In dropbox' case the two suspected culprits are f_fsid and xattr, both of which have different behaviour on different FS'.
f_fsid is assumed/documented stable and it is. For varying definitions of "stable", where some filesystems mean "stable for each mount" or "stable for this device" or "stable for filesystem forever".
xattrs have varying limits on how much data you can put in and how many xattrs you can have and how they are handled for hardlinks (Linux says 255 byte for the name and 64KiB for the data, XFS and Reiser have that limit, ext4 and btrfs limit the entire xattr to 4KiB).
- fao_ 8y agoxattr is arguably worse for NTFS. While there is no limit to NTFS extended attributes, they are represented transparently as a separate file on the filesystem. Unlike where on linux all tools will suffice to copy xattrs because they are part of the file, on Windows, a copy tool needs to be aware of xattrs or they will be lost. Relying on f_fsid as an actual filesystem id is batshit stupid. It is only "guaranteed" (And, bear in mind, POSIX doesn't specify anything in relation to f_fsid, so I have no idea what authority is guaranteeing this claim) that f_fsid+inode creates a uniquely identifying pair. Aside from that, a filesystem could fill it with literally anything to assure that. As the linux documentation says: "Nobody knows what f_fsid is supposed to contain" See, the Linux documentation on statvfs: The general idea is that f_fsid contains some random stuff such that the pair (f_fsid,ino) uniquely determines a file. Some operating systems use (a variation on) the device number, or the device number combined with the filesystem type. Several operating systems restrict giving out the f_fsid field to the superuser only (and zero it for unprivileged users), because this field is used in the filehandle of the filesystem when NFS-exported, and giving it out is a security concern.