LU-10378 utils: add formatted printf to lfs find
Introduce new --printf option with lfs find utility along with support for
the backslash escapes and format directives given below that allow users to
obtain metadata in formatted style.
List of backslash escapes supported by --printf option:
-------------------------------------
Description | Escape
-------------------------------------
Newline character | \n
Tab character | \t
Literal backslash | \\
List of format directives used with --printf option:
----------------------------------------------------------
Description | Directive
----------------------------------------------------------
Literal % character | %%
Access time (in ctime format) | %a
Access time (in secs since epoch) | %A@
File size (in 512B blocks) | %b
Last change time (in ctime format) | %c
Last change time (in secs since epoch) | %C@
Numeric group ID of file/dir owner | %G
File size (in 1K blocks) | %k
File mode (octal) | %m
Path name of file | %p
File size (in bytes) | %s
Modification time (in ctime format) | %t
Modification time (in secs since epoch) | %T@
Numeric user ID of file/dir owner | %U
Birth time (in ctime format) | %w
Birth time (in secs since epoch) | %W@
File type | %y
Stripe count | %Lc
Lustre FID | %LF
Directory hash type | %Lh
Starting OST (file) or MDT (dir) index | %Li
List of all OST (file) or MDT (dir) indices | %Lo
OST pool name | %Lp
Numeric project id assigned to file/dir | %LP
Stripe size in bytes | %LS
---------------------------------------------------------
Note: Stripe size and OST pool name are not defined for
directories whereas Hash type is not defined for files.
%Li gives starting OST index for files and starting MDT index
for directories. For composite files %Lo provides list of all
OST indices for all components whereas %Lc, %LS, %Li and %Lp
provide details for last initialized component only.
A usage example for --printf option and its output for a composite
file with three components are shown below.
lfs find --printf '%a | %t | %c | %w | %W@ | %b | %s | %U | %G |
%A@ | %T@ | %C@ | %LP | %Lc | %LS | %Li | %Lo | %Lp | %pn'
/lustre/lustre/composite.txt
Tue Oct 26 16:06:18 2021 | Tue Oct 26 16:06:50 2021 | Tue Oct 26
16:06:50 2021 | Tue Oct 26 16:06:18 2021 |
1635278778 | 204800 |
104857600 | 0 | 0 |
1635278778 |
1635278810 |
1635278810 | 0 | 3 |
2097152 | 2 | [1][2,0][2,0,1] | pool1 |
/lustre/lustre/composite.txt
Change-Id: I370c0978900a4837b0ea3060e08dabb1fcb6e115
Signed-off-by: Anjus George <georgea@ornl.gov>
Signed-off-by: Rick Mohr <mohrrf@ornl.gov>
Reviewed-on: https://review.whamcloud.com/45136
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>