]> git.ipfire.org Git - thirdparty/coreutils.git/commit
stat: support more device number representations
authorPádraig Brady <P@draigBrady.com>
Sun, 20 Jun 2021 14:16:49 +0000 (15:16 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 21 Jun 2021 11:01:04 +0000 (12:01 +0100)
commit4a8278229e0ead89231b3d44d747fe3c10767596
tree38c594d5fbbf439371df3107e6991706a5a52541
parent4edad9e1210dfaa4c8630bad16d0b2e6090de790
stat: support more device number representations

In preparation for changing the default device number
representation (to decomposed decimal), provide more
formatting options for device numbers.

These new (FreeBSD compat) formatting options are added:

   %Hd  major device number in decimal (st_dev)
   %Ld  minor device number in decimal (st_dev)
   %Hr  major device type in decimal (st_rdev)
   %Lr  minor device type in decimal (st_rdev)
   %r   (composed) device type in decimal (st_rdev)
   %R   (composed) device type in hex (st_rdev)

* doc/coreutils.texi (stat invocation): Document new formats.
* src/stat.c (print_it): Handle the new %H and %L modifiers.
(print_statfs): Adjust to passing the format as two chars
rather than an int.  Using an int was introduced in commit db42ae78,
but using separate chars is cleaner and more extensible.
(print_stat): Likewise.  Handle any modifiers and the new 'r' format.
(usage): Document the new formats.
* tests/misc/stat-fmt.sh: Add a test case for new modifiers.
Addresses https://bugs.gnu.org/48960
NEWS
doc/coreutils.texi
src/stat.c
tests/misc/stat-fmt.sh