From 15305a6b380aae4df16fce9e3676b70f24eb4e64 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 12 Apr 2024 23:38:00 -0600 Subject: [PATCH] EX-9585 lipe: add lipe_find3 projid option Add an option to print the project ID for a file with the "-printf" argument, both as long option %{projid} as well as short option and "%LP" that is compatible with "lfs find". Sort all of the existing and new options alphabetically so that it is easier to see which ones are implemented in the future. Update the lipe-find3.1 man page and add a test case. Test-Parameters: trivial testlist=sanity-lipe-find3.sh Signed-off-by: Andreas Dilger Change-Id: I18d2d3cc161c8aa92eb27c33b06214b6f5ce7057 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54784 Reviewed-by: Vitaliy Kuznetsov Tested-by: jenkins Tested-by: Maloo --- lipe/man/lipe_find3.1 | 14 +++++++------- lipe/src/lipe_find3/lf3_parse_format.c | 23 +++++++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lipe/man/lipe_find3.1 b/lipe/man/lipe_find3.1 index 3446110..6ab7fc4 100644 --- a/lipe/man/lipe_find3.1 +++ b/lipe/man/lipe_find3.1 @@ -297,15 +297,15 @@ Print \fIformat\fP to the standard output, interpreting '\e' escapes and '%' directives. The supported directives include most supported by \fBfind\fP(1) and the following extensions: .RS -.IP %{fid}, %LF +.IP %{stripe-count},%Lc +stripe count of last instantiated component +.IP %{fid},%LF file FID -.IP %{projid} -numerical project ID -.IP %{mirror-count}, %LN +.IP %{mirror-count},%LN FLR mirror count -.IP %{stripe-count}, %Lc -stripe count of last instantiated component -.IP %{stripe-size}, %LS +.IP %{projid},%LP +numerical project ID +.IP %{stripe-size},%LS stripe size of last instantiated component .IP %{xattr:NAME} contents of NAME xattr as a string diff --git a/lipe/src/lipe_find3/lf3_parse_format.c b/lipe/src/lipe_find3/lf3_parse_format.c index 5d40f1e..b8725eb 100644 --- a/lipe/src/lipe_find3/lf3_parse_format.c +++ b/lipe/src/lipe_find3/lf3_parse_format.c @@ -245,17 +245,20 @@ width: case 'L': /* formats like lfs find */ c = fmt[n++]; switch (c) { - case 'S': - LF3_EMIT_N('d', "(lov-stripe-size)"); - break; case 'c': LF3_EMIT_N('d', "(lov-stripe-count)"); break; + case 'F': + LF3_EMIT_S('a', "(file-fid)"); + break; case 'N': LF3_EMIT_N('d', "(lov-mirror-count)"); break; - case 'F': - LF3_EMIT_S('a', "(file-fid)"); + case 'P': + LF3_EMIT_N('d', "(projid)"); + break; + case 'S': + LF3_EMIT_N('d', "(lov-stripe-size)"); break; } break; @@ -319,14 +322,14 @@ width: // pools if (strcmp(ext, "fid") == 0) LF3_EMIT_S('a', "(file-fid)"); - else if (strcmp(ext, "stripe-size") == 0) - LF3_EMIT_N('d', "(lov-stripe-size)", ext); - else if (strcmp(ext, "stripe-count") == 0) - LF3_EMIT_N('d', "(lov-stripe-count)", ext); else if (strcmp(ext, "mirror-count") == 0) LF3_EMIT_N('d', "(lov-mirror-count)", ext); else if (strcmp(ext, "projid") == 0) - LF3_EMIT_N('d', "(%s)", ext); + LF3_EMIT_N('d', "(projid)", ext); + else if (strcmp(ext, "stripe-count") == 0) + LF3_EMIT_N('d', "(lov-stripe-count)", ext); + else if (strcmp(ext, "stripe-size") == 0) + LF3_EMIT_N('d', "(lov-stripe-size)", ext); else if (strstartswith(ext, "xattr:")) LF3_EMIT_S('a', "(or (xattr-ref-string %Q) %Q)", ext + strlen("xattr:"), ""); else -- 1.8.3.1