and '%' directives. The supported directives include most supported by
\fBfind\fP(1) and the following extensions:
.RS
+.IP %{fid}
+file FID
.IP %{projid}
numerical project ID
+.IP %{mirror-count}
+FLR mirror count
+.IP %{stripe-count}
+stripe count of last instantiated component
.IP %{xattr:NAME}
contents of NAME xattr as a string
.RE
// parent-fid
// parent-fids
// pools
- /* TODO
- * if (strcmp(ext, "fid") == 0)
- * LF3_EMIT_S('a', "(fid)");
- * else
- */
- if (strcmp(ext, "projid") == 0)
- LF3_EMIT_N('d', "(%s)", ext);
- /* TODO
- * else if (strcmp(ext, "projid") == 0 ||
- * strcmp(ext, "stripe-count") == 0 ||
- * strcmp(ext, "mirror-count") == 0)
- * LF3_EMIT_N('d', "(%s)", ext);
- */
+ if (strcmp(ext, "fid") == 0)
+ LF3_EMIT_S('a', "(file-fid)");
+ 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);
else if (strstartswith(ext, "xattr:"))
LF3_EMIT_S('a', "(or (xattr-ref-string %Q) %Q)", ext + strlen("xattr:"), "");
else
}
run_test 115 "lipe_find3 -path and -ipath with UTF-8"
+test_116() {
+ local file=$MOUNT/$tfile
+ declare -a fid
+ local x
+
+ init_lipe_find3_env
+
+ for x in 1 2 3; do
+ $LFS mirror create --mirror-count=$x "$file-$x" ||
+ error "cannot create mirror for $file-$x"
+ fid[${x}]=$($LFS path2fid "$file-"${x})
+ done
+ sync
+
+ for x in 1 2 3; do
+ expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \
+ -mirror-count $x -printf '%{mirror-count} %{fid}'
+ done
+
+ expect_empty lipe_find3_facet mds1 -mirror-count 4 \
+ -printf '%{mirror-count}'
+
+ rm $file*
+
+ for x in 1 2 3; do
+ $LFS setstripe -i 0 -c $x "$file-1-$x" ||
+ error "cannot setstripe $x for file $file-1-$x"
+ fid[${x}]=$($LFS path2fid "$file-1-$x")
+ echo XXX > "$file-1-$x"
+ done
+ sync
+
+ for x in 1 2 3; do
+ expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \
+ -stripe-count $x -printf '%{stripe-count} %{fid}'
+ done
+
+ expect_empty lipe_find3_facet mds1 -stripe-count 4 -printf '%{fid}'
+
+ rm $file*
+
+ for x in 1001 1002 1003; do
+ touch "$file-2-$x"
+ $LFS project -p $x $file-2-$x ||
+ error "cannot set project $x for file $file-2-$x"
+ fid[${x}]=$($LFS path2fid "$file-2-$x")
+ done
+ sync
+
+ for x in 1001 1002 1003; do
+ expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \
+ -projid $x -printf '%{projid} %{fid}'
+ done
+
+ expect_empty lipe_find3_facet mds1 -projid 1 -printf '%{projid} %{fid}'
+
+ rm $file*
+
+ for x in 1 2 3; do
+ touch "$file-3-$x"
+ setfattr -n user.$x -v $x "$file-3-$x"
+ fid[${x}]=$($LFS path2fid "$file-3-$x")
+ done
+ sync
+
+ for x in 1 2 3; do
+ local format='%{xattr:user.'"$x"'} %{fid}'
+ expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \
+ -xattr user.$x -printf "${format}"
+ done
+
+ init_lipe_find3_env
+}
+run_test 116 "lipe_find3 verify printf formats"
+
test_130() {
local file=$MOUNT/$tfile
local xtime