* [PATCH]: Shell script for printing XFS quota project id for files.
@ 2012-11-12 18:33 Arkadiusz Miśkiewicz
2012-11-12 18:40 ` [PATCH v2]: " Arkadiusz Miśkiewicz
0 siblings, 1 reply; 3+ messages in thread
From: Arkadiusz Miśkiewicz @ 2012-11-12 18:33 UTC (permalink / raw)
To: xfs
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@maven.pl>
---
man/man8/xfs_lsprojid.8 | 9 +++++++++
quota/Makefile | 4 +++-
quota/xfs_lsprojid.sh | 9 +++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 man/man8/xfs_lsprojid.8
create mode 100644 quota/xfs_lsprojid.sh
diff --git a/man/man8/xfs_lsprojid.8 b/man/man8/xfs_lsprojid.8
new file mode 100644
index 0000000..3ea7ce9
--- /dev/null
+++ b/man/man8/xfs_lsprojid.8
@@ -0,0 +1,9 @@
+.TH xfs_lsprojid 8
+.SH NAME
+xfs_lsprojid \- print XFS project id for files
+.SH SYNOPSIS
+.B xfs_lsprojid
+.IR filename " ..."
+.SH DESCRIPTION
+.B xfs_lsprojid
+displays quota project id for specified files.
diff --git a/quota/Makefile b/quota/Makefile
index 9c6411e..d813005 100644
--- a/quota/Makefile
+++ b/quota/Makefile
@@ -12,7 +12,8 @@ CFILES = init.c util.c \
CFILES += $(PKG_PLATFORM).c
PCFILES = darwin.c freebsd.c irix.c linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") \
+ xfs_lsprojid.sh
LLDLIBS = $(LIBXCMD)
LTDEPENDENCIES = $(LIBXCMD)
@@ -35,6 +36,7 @@ include $(BUILDRULES)
install: default
$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
+ $(INSTALL) -m 755 xfs_lsprojid.sh $(PKG_SBIN_DIR)/xfs_lsprojid
install-dev:
-include .dep
diff --git a/quota/xfs_lsprojid.sh b/quota/xfs_lsprojid.sh
new file mode 100644
index 0000000..4404de5
--- /dev/null
+++ b/quota/xfs_lsprojid.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# Copyright (c) 2011 Arkadiusz Miśkiewicz.
+#
+
+xfs_io -p "$0" -c "stat" $@ | awk '
+/^fd\.path =/ { projid=""; path=$3; gsub(/^\"/, "", path); gsub(/\"$/, "", path); }
+/^fsxattr\.projid =/ { projid=$3; print path ": " projid; }
+'
--
1.8.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2]: Shell script for printing XFS quota project id for files.
2012-11-12 18:33 [PATCH]: Shell script for printing XFS quota project id for files Arkadiusz Miśkiewicz
@ 2012-11-12 18:40 ` Arkadiusz Miśkiewicz
2012-11-12 22:14 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Arkadiusz Miśkiewicz @ 2012-11-12 18:40 UTC (permalink / raw)
To: xfs
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@maven.pl>
---
This time correct version of the patch.
man/man8/xfs_lsprojid.8 | 9 +++++++++
quota/Makefile | 4 +++-
quota/xfs_lsprojid.sh | 11 +++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 man/man8/xfs_lsprojid.8
create mode 100644 quota/xfs_lsprojid.sh
diff --git a/man/man8/xfs_lsprojid.8 b/man/man8/xfs_lsprojid.8
new file mode 100644
index 0000000..3ea7ce9
--- /dev/null
+++ b/man/man8/xfs_lsprojid.8
@@ -0,0 +1,9 @@
+.TH xfs_lsprojid 8
+.SH NAME
+xfs_lsprojid \- print XFS project id for files
+.SH SYNOPSIS
+.B xfs_lsprojid
+.IR filename " ..."
+.SH DESCRIPTION
+.B xfs_lsprojid
+displays quota project id for specified files.
diff --git a/quota/Makefile b/quota/Makefile
index 9c6411e..d813005 100644
--- a/quota/Makefile
+++ b/quota/Makefile
@@ -12,7 +12,8 @@ CFILES = init.c util.c \
CFILES += $(PKG_PLATFORM).c
PCFILES = darwin.c freebsd.c irix.c linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") \
+ xfs_lsprojid.sh
LLDLIBS = $(LIBXCMD)
LTDEPENDENCIES = $(LIBXCMD)
@@ -35,6 +36,7 @@ include $(BUILDRULES)
install: default
$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
+ $(INSTALL) -m 755 xfs_lsprojid.sh $(PKG_SBIN_DIR)/xfs_lsprojid
install-dev:
-include .dep
diff --git a/quota/xfs_lsprojid.sh b/quota/xfs_lsprojid.sh
new file mode 100644
index 0000000..0dbf95c
--- /dev/null
+++ b/quota/xfs_lsprojid.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Arkadiusz Miśkiewicz.
+#
+
+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
--
1.8.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2]: Shell script for printing XFS quota project id for files.
2012-11-12 18:40 ` [PATCH v2]: " Arkadiusz Miśkiewicz
@ 2012-11-12 22:14 ` Dave Chinner
0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2012-11-12 22:14 UTC (permalink / raw)
To: Arkadiusz Miśkiewicz; +Cc: xfs
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@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@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-12 22:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 18:33 [PATCH]: Shell script for printing XFS quota project id for files Arkadiusz Miśkiewicz
2012-11-12 18:40 ` [PATCH v2]: " Arkadiusz Miśkiewicz
2012-11-12 22:14 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox