From: Maximilian Dilger Date: Sun, 16 Jun 2024 01:55:46 +0000 (-0400) Subject: LU-15504 utils: lfs find -ls function X-Git-Tag: 2.15.65~16 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=1d8164fa16efb12d02b0855de61eb95d7ba246ab;p=fs%2Flustre-release.git LU-15504 utils: lfs find -ls function Added -ls function for lfs find. It is equivalent to using printf "%i/t%k/t%M/t%n/t%u/t%g/t%s/t%t/t%p/n" Signed-off-by: Maximilian Dilger Change-Id: If84687915a2f71be81ee8adc5c9402371d635956 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55443 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Anjus George --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7d57de4..8a2662b 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9189,6 +9189,19 @@ test_56eaa() { } run_test 56eaa "test lfs find -printf added functions" +test_56eab() { + touch $DIR/$tfile + local lfs_ls=($($LFS find $DIR -name $tfile -ls)) + local find_ls=($(find $DIR -name $tfile -ls)) + +# "-1" is last field, since dates are not printed exactly the same. + for ((i = -1; i < 7; i++)); do + [[ "${lfs_ls[i]}" == "${find_ls[i]}" ]] || + error "expected '${lfs_ls[i]}' but got '${find_ls[i]}'" + done +} +run_test 56eab "test lfs find -ls function" + test_56eb() { local dir=$DIR/$tdir local subdir_1=$dir/subdir_1 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index b1c6299..a172a94 100755 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3533,6 +3533,7 @@ enum { LFS_INHERIT_RR_OPT, LFS_FIND_PERM, LFS_PRINTF_OPT, + LFS_PRINTF_LS, LFS_NO_FOLLOW_OPT, LFS_HEX_IDX_OPT, LFS_STATS_OPT, @@ -5449,6 +5450,8 @@ static int lfs_find(int argc, char **argv) { .val = 'L', .name = "layout", .has_arg = required_argument }, { .val = LFS_LINKS_OPT, .name = "links", .has_arg = required_argument }, + { .val = LFS_PRINTF_LS, + .name = "ls", .has_arg = no_argument }, { .val = 'm', .name = "mdt", .has_arg = required_argument }, { .val = 'm', .name = "mdt-index", .has_arg = required_argument }, { .val = 'm', .name = "mdt_index", .has_arg = required_argument }, @@ -6144,6 +6147,10 @@ err_free: case LFS_PRINTF_OPT: param.fp_format_printf_str = strdup(optarg); break; + case LFS_PRINTF_LS: + param.fp_format_printf_str = + strdup("%i\t%k\t%M\t%n\t%u\t%g\t%s\t%t\t%p\n"); + break; case LFS_PROJID_OPT: rc = name2projid(¶m.fp_projid, optarg); if (rc) {