[PATCH v2]: Shell script for printing XFS quota project id for files.
Dave Chinner
david at fromorbit.com
Mon Nov 12 16:14:24 CST 2012
On Mon, Nov 12, 2012 at 07:40:28PM +0100, Arkadiusz Miśkiewicz wrote:
> Simple script that prints project id for files:
>
> $ sh quota/xfs_lsprojid.sh quota/[fl]*
> quota/freebsd.c: 232
> quota/free.c: 0
> quota/free.o: 222
> quota/linux.c: 21344
> quota/linux.o: 0
>
> Signed-off-by: Arkadiusz Miśkiewicz <arekm at maven.pl>
> ---
.....
> @@ -0,0 +1,11 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2012 Arkadiusz Miśkiewicz.
Best to use only 7-bit ascii in code.
> +#
> +
> +for file in "$@"; do
> + xfs_io -p "$0" -r -c "stat" "$file" | awk '
> + /^fd\.path =/ { projid=""; gsub(/^fd\.path = \"/, ""); gsub(/\"$/, ""); path=$0 }
> + /^fsxattr\.projid =/ { projid=$3; print path ": " projid; }
> + '
> +done
Can you write it in a way that looks a little less like line
noise? This is much easier to understand:
xfs_io -p "$0" -r -c "stat" "$file" | awk '
/^fd\.path =/ {
projid="";
gsub(/^fd\.path = \"/, "");
gsub(/\"$/, "");
path=$0
}
/^fsxattr\.projid =/ {
projid=$3;
print path ": " projid;
}'
It also needs a usage message when no files are given, and probably
a version output (-V option) as well.
Cheers,
Dave.
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list