From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: [PATCH 1/2] xfs_quota: push id/name printing down into report_mount()
Date: Tue, 15 Dec 2015 20:39:39 -0600 [thread overview]
Message-ID: <5670CEEB.8080805@sandeen.net> (raw)
In-Reply-To: <5670CD2F.9020009@redhat.com>
Push the printing of the id number and/or name during quota
reporting down into report_mount(), rather than doing it in
the caller.
This lets the next patch do a lookup of any ID found with
a quota, when upper/lower ID bounds are specified. This patch,
however, changes no behavior. Both the ID and the name are
passed in, and which one gets printed depends on the
presence of the NO_LOOKUP_FLAG.
If "NULL" is passed in (as in the upper/lower ID search case),
then as before, only the ID is printed. Next patch changes this.
Drops a few lines of code as well.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/quota/report.c b/quota/report.c
index 3d84447..55e44c5 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -322,7 +322,11 @@ report_mount(
if (!(flags & NO_HEADER_FLAG))
report_header(fp, form, type, mount, flags);
- fprintf(fp, "%-10s", name);
+ if ((name == NULL) || (flags & NO_LOOKUP_FLAG))
+ fprintf(fp, "#%-10u", id);
+ else
+ fprintf(fp, "%-10s", name);
+
if (form & XFS_BLOCK_QUOTA) {
qflags = (flags & HUMAN_FLAG);
if (d.d_blk_hardlimit && d.d_bcount > d.d_blk_hardlimit)
@@ -400,24 +404,18 @@ report_user_mount(
uint flags)
{
struct passwd *u;
- char n[NMAX];
uint id;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
- snprintf(n, sizeof(n)-1, "#%u", id);
- if (report_mount(fp, id, n,
+ if (report_mount(fp, id, NULL,
form, XFS_USER_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
} else {
setpwent();
while ((u = getpwent()) != NULL) {
- if (flags & NO_LOOKUP_FLAG)
- snprintf(n, sizeof(n)-1, "#%u", u->pw_uid);
- else
- strncpy(n, u->pw_name, sizeof(n)-1);
- if (report_mount(fp, u->pw_uid, n,
+ if (report_mount(fp, u->pw_uid, u->pw_name,
form, XFS_USER_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
@@ -438,24 +436,18 @@ report_group_mount(
uint flags)
{
struct group *g;
- char n[NMAX];
uint id;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
- snprintf(n, sizeof(n)-1, "#%u", id);
- if (report_mount(fp, id, n,
+ if (report_mount(fp, id, NULL,
form, XFS_GROUP_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
} else {
setgrent();
while ((g = getgrent()) != NULL) {
- if (flags & NO_LOOKUP_FLAG)
- snprintf(n, sizeof(n)-1, "#%u", g->gr_gid);
- else
- strncpy(n, g->gr_name, sizeof(n)-1);
- if (report_mount(fp, g->gr_gid, n,
+ if (report_mount(fp, g->gr_gid, g->gr_name,
form, XFS_GROUP_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
@@ -475,25 +467,18 @@ report_project_mount(
uint flags)
{
fs_project_t *p;
- char n[NMAX];
uint id;
if (upper) { /* identifier range specified */
for (id = lower; id <= upper; id++) {
- snprintf(n, sizeof(n)-1, "#%u", id);
- if (report_mount(fp, id, n,
+ if (report_mount(fp, id, NULL,
form, XFS_PROJ_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
} else {
setprent();
while ((p = getprent()) != NULL) {
- if (flags & NO_LOOKUP_FLAG)
- snprintf(n, sizeof(n)-1, "#%u",
- (unsigned int)p->pr_prid);
- else
- strncpy(n, p->pr_name, sizeof(n)-1);
- if (report_mount(fp, p->pr_prid, n,
+ if (report_mount(fp, p->pr_prid, p->pr_name,
form, XFS_PROJ_QUOTA, mount, flags))
flags |= NO_HEADER_FLAG;
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-12-16 2:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-16 2:32 [PATCH 0/2] xfs_quota: enable id->name lookups with lower/upper bounds Eric Sandeen
2015-12-16 2:39 ` Eric Sandeen [this message]
2015-12-16 2:41 ` [PATCH 2/2] xfs_quota: allow name lookup when reporting from ID range Eric Sandeen
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=5670CEEB.8080805@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