show amount of disk space used by files with zero hardlinks
unlinked files generally occur one of two ways:
- unnamed temporaries
- a file has been deleted, but its file descriptor is still held open.
I recently encountered a situation where tmpfs got filled up by a logfile, and then removing the logfile did not actually free up any space, because the program was still holding the fd of the logfile.
These files are not seen by programs like du, however, df is able to see the total amount of space used on a drive, including unlinked files, so simple subtraction could be used to see how much of the disk is taken up by unlinked files.
is this the same as: https://github.com/bootandy/dust/issues/444 ?
Similar, but I'm proposing a much simpler solution: just ask the fs for the total used space (like how df does), then subtracting the size of named files from that, and displaying that number if it is significant.
Can you tell me how I can create that situation - I need to be able to create it before I can process it. - Some method of creating and removing files/symlinks ? (I have ext4 and tmpfs).
symlinks have nothing to do with this.
you can either use O_TMPFILE, or you can create a file, open it, then delete it while holding the file descriptor. in both cases the file will only stay alive while the fd lives, which means having a process stay running while you're testing.