Whamcloud - gitweb
LU-16561: find: support width in -printf directive 95/57395/4
authorCourrier Guillaume <guillaume.courrier@cea.fr>
Fri, 6 Dec 2024 15:39:07 +0000 (16:39 +0100)
committerOleg Drokin <green@whamcloud.com>
Sun, 2 Feb 2025 06:27:48 +0000 (06:27 +0000)
commit6fe2fcb02c7fbbe00f7188e33bb65a38dc7ebcc3
treebd6d876441a1ce2d540cdd060d1c640fd83c04b9
parent6703c05df0e60c5af46f59c4ff19d17a7d0a88fb
LU-16561: find: support width in -printf directive

The width supported can be positive or negative. A negative width will align
elements on the left while positive values will align elements on the right.

We also support the 0 prefix. The man page of printf(3) indicates that the
prefix 0 should use '0' instead of spaces for padding. However, GNU-find does
not use 0 padding for all the types of values. Only '%d', '%m' and '%S' use 0
padding. This patch replicates this behavior. For instance:

$ find /mnt/lustre -printf "%13p: '%024i' '%05m'\n"
  /mnt/lustre: '      144115188193296385' '00755'
/mnt/lustre/f: '      144115205272502273' '00644'

Change-Id: I954788513cc6b43c413a3688d51c1bf1efd7d9db
Signed-off-by: Courrier Guillaume <guillaume.courrier@cea.fr>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57395
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c