du: add --inodes option
commit333dc83d52e014a0b532e316ea8cd93b048f1ac6
authorBernhard Voelker <mail@bernhard-voelker.de>
Sat, 27 Jul 2013 12:25:28 +0000 (27 14:25 +0200)
committerBernhard Voelker <mail@bernhard-voelker.de>
Sat, 27 Jul 2013 12:25:28 +0000 (27 14:25 +0200)
tree3bf519653280e660e7311e436b6e0e0fee8160a5
parent2bdb74ec1a453f6c6084d042e573de436ec205f3
du: add --inodes option

This new option can be used to find directories with a huge
amount of files.  The GNU find utility has the printf format
"%h" which prints the number of entries in a directory, but
this is non-cumulative and doesn't handle hard links.

* src/du.c (struct duinfo): Add new member for counting inodes.
(duinfo_init): Initialize inodes member with Zero.
(duinfo_set): Set inodes counter to 1.
(duinfo_add): Sum up the 2 given inodes counters.
(opt_inodes): Add new boolean flag to remember if the --inodes
option has been specified.
(INODES_OPTION): Add new enum value to be used ...
(long_options): ... here.
(usage): Add description of the new option.
(print_size): Pass inodes counter or size to print_only_size,
depending on the inodes mode.
(process_file): Adapt threshold handling: with --inodes, print or
elide the entries according to the struct member inodes.
(main): Add a case for accepting the new INODES_OPTION.
Print a warning diagnostic when --inodes is used together with the
option --apparent-size or -b.
Reset the output_block_size to 1 ... and thus ignoring the
options -m and -k.
* tests/du/inodes.sh: Add a new test.
* tests/local.mk (all_tests): Mention it.
* doc/coreutils.texi (du invocation): Document the new option.
* NEWS: Mention the new option.
NEWS
doc/coreutils.texi
src/du.c
tests/du/inodes.sh [new file with mode: 0755]
tests/local.mk