From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: [PATCH 3/3] xfs_quota: use Q_XGETQUOTA2 for repquota
Date: Fri, 8 Jan 2016 12:57:55 -0600 [thread overview]
Message-ID: <569006B3.8000300@sandeen.net> (raw)
In-Reply-To: <56900640.1050200@redhat.com>
Rather than a loop over getpwnam() etc, use the Q_XGETQUOTA2
command to iterate through all active quotas.
If Q_XGETQUOTA2 fails, go back to the old way.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
quota/quota.h | 1 +
quota/report.c | 41 +++++++++++++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/quota/quota.h b/quota/quota.h
index 8b80029..dec8330 100644
--- a/quota/quota.h
+++ b/quota/quota.h
@@ -74,6 +74,7 @@ enum {
DEFAULTS_FLAG = 0x0100, /* use value as a default */
ABSOLUTE_FLAG = 0x0200, /* absolute time, not related to now */
NO_LOOKUP_FLAG = 0x0400, /* skip name lookups, just report ID */
+ GETQUOTA2_FLAG = 0x0800, /* use getquota2 quotactl */
};
/*
diff --git a/quota/report.c b/quota/report.c
index 746b04a..093155b 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -302,8 +302,14 @@ report_mount(
char c[8], h[8], s[8];
uint qflags;
int count;
+ int cmd;
- if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0) {
+ if (flags & GETQUOTA2_FLAG)
+ cmd = XFS_GETQUOTA2;
+ else
+ cmd = XFS_GETQUOTA;
+
+ if (xfsquotactl(cmd, dev, type, id, (void *)&d) < 0) {
if (errno != ENOENT && errno != ENOSYS && errno != ESRCH)
perror("XFS_GETQUOTA");
return 0;
@@ -425,7 +431,7 @@ report_user_mount(
uint flags)
{
struct passwd *u;
- uint id;
+ uint id = 0, oid;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
@@ -433,6 +439,15 @@ report_user_mount(
form, XFS_USER_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
+ } else if (report_mount(fp, id, NULL, &oid, form,
+ XFS_USER_QUOTA, mount, flags|GETQUOTA2_FLAG)) {
+ id = oid + 1;
+ flags |= GETQUOTA2_FLAG;
+ flags |= NO_HEADER_FLAG;
+ while (report_mount(fp, id, NULL, &oid, form, XFS_USER_QUOTA,
+ mount, flags)) {
+ id = oid + 1;
+ }
} else {
setpwent();
while ((u = getpwent()) != NULL) {
@@ -457,7 +472,7 @@ report_group_mount(
uint flags)
{
struct group *g;
- uint id;
+ uint id = 0, oid;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
@@ -465,6 +480,15 @@ report_group_mount(
form, XFS_GROUP_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
+ } else if (report_mount(fp, id, NULL, &oid, form,
+ XFS_GROUP_QUOTA, mount, flags|GETQUOTA2_FLAG)) {
+ id = oid + 1;
+ flags |= GETQUOTA2_FLAG;
+ flags |= NO_HEADER_FLAG;
+ while (report_mount(fp, id, NULL, &oid, form, XFS_GROUP_QUOTA,
+ mount, flags)) {
+ id = oid + 1;
+ }
} else {
setgrent();
while ((g = getgrent()) != NULL) {
@@ -488,7 +512,7 @@ report_project_mount(
uint flags)
{
fs_project_t *p;
- uint id;
+ uint id = 0, oid;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
@@ -496,6 +520,15 @@ report_project_mount(
form, XFS_PROJ_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
+ } else if (report_mount(fp, id, NULL, &oid, form,
+ XFS_PROJ_QUOTA, mount, flags|GETQUOTA2_FLAG)) {
+ id = oid + 1;
+ flags |= GETQUOTA2_FLAG;
+ flags |= NO_HEADER_FLAG;
+ while (report_mount(fp, id, NULL, &oid, form, XFS_PROJ_QUOTA,
+ mount, flags)) {
+ id = oid + 1;
+ }
} else {
setprent();
while ((p = getprent()) != NULL) {
--
1.7.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2016-01-08 18:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 18:56 [PATCH 0/3] xfsprogs: use Q_XGETQUOTA2 Eric Sandeen
2016-01-08 18:57 ` [PATCH 1/3] xfs_quota: define Q_XGETQUOTA2 Eric Sandeen
2016-01-08 18:57 ` [PATCH 2/3] xfs_quota: make report_mount() take an "output id" Eric Sandeen
2016-01-08 18:57 ` Eric Sandeen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=569006B3.8000300@sandeen.net \
--to=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox