Skip to content

Conversation

ofaaland
Copy link
Collaborator

@ofaaland ofaaland commented Aug 1, 2025

Add a --printf option to dfind, enabling the user to produce strings with an arbitrary format using values discovered during the find (e.g. filename, file size, blocks allocated). For example:

$ srun -N1 -n16 /g/g0/faaland1/projects/mfu-install/bin/^Cind --printf "%p blocks %b size %s"  /p/lflood/faaland1/swl/callan-toss4/
[2025-07-31T18:35:46] Walking /p/lflood/faaland1/swl/callan-toss4
[2025-07-31T18:35:56] Walked 486036 items in 10.004 secs (48582.588 items/sec) ...
[2025-07-31T18:36:02] Walked 765358 items in 15.729 secs (48658.632 items/sec) ...
[2025-07-31T18:36:02] Walked 765358 items in 15.731 seconds (48652.838 items/sec)
/p/lflood/faaland1/swl/callan-toss4/4.8-14rc0-pass1 blocks 260 size 133120
/p/lflood/faaland1/swl/callan-toss4/4.8-14rc0-pass1/sphot_998.stdout blocks 66 size 58056
/p/lflood/faaland1/swl/callan-toss4/4.8-14rc0-pass1/minimd_667.stderr blocks 66 size 1647
/p/lflood/faaland1/swl/callan-toss4/4.8-14rc0-pass1/pynamic_1042 blocks 52 size 26624

ofaaland added 2 commits July 31, 2025 18:53
When building an flist where stat() was called for each file, record
st_blocks as well as st_size, st_ino, st_mode, etc.

Signed-off-by: Olaf Faaland <[email protected]>
support:
    %b    count of 512B blocks
    %s    size in bytes
    %p    full path

Signed-off-by: Olaf Faaland <[email protected]>
@ofaaland ofaaland self-assigned this Aug 1, 2025
@defaziogiancarlo
Copy link
Collaborator

This looks good to me. Are you planning on adding additional fields from stat?

printf("\n");
printf("Supported format string specifiers:\n");
printf(" %b allocated space in 512-byte blocks\n");
printf(" %p path name of file\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use %%p and %%s

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@adilger
Copy link
Contributor

adilger commented Aug 2, 2025

I would suggest that the print formats match those of "lfs find", which are largely identical to "find", but add %L formats for Lustre-specific attributes like stripe count, pool, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants