xfs
[Top] [All Lists]

[PATCH 2/3] xfs_quota: make report_mount() take an "output id"

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/3] xfs_quota: make report_mount() take an "output id"
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 8 Jan 2016 12:57:42 -0600
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <56900640.1050200@xxxxxxxxxx>
References: <56900640.1050200@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
Allow report_mount() to take a *oid pointer, an "output id"
which will be filled in if the quotactl returns an ID for
something other than that which was passed in.

Also, when printing results, print the id which was actually
returned, not the id which was passed in.

Should be a no-op change at this point; the next patch which
wires in Q_XGETQUOTA2 will make use of this.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 quota/report.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/quota/report.c b/quota/report.c
index c77b24f..746b04a 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -291,6 +291,7 @@ report_mount(
        FILE            *fp,
        __uint32_t      id,
        char            *name,
+       __uint32_t      *oid,
        uint            form,
        uint            type,
        fs_path_t       *mount,
@@ -308,6 +309,9 @@ report_mount(
                return 0;
        }
 
+       if (oid)
+               *oid = d.d_id;
+
        if (flags & TERSE_FLAG) {
                count = 0;
                if ((form & XFS_BLOCK_QUOTA) && d.d_bcount)
@@ -324,19 +328,19 @@ report_mount(
                report_header(fp, form, type, mount, flags);
 
        if (flags & NO_LOOKUP_FLAG) {
-               fprintf(fp, "#%-10u", id);
+               fprintf(fp, "#%-10u", d.d_id);
        } else {
                if (name == NULL) {
                        if (type == XFS_USER_QUOTA) {
-                               struct passwd   *u = getpwuid(id);
+                               struct passwd   *u = getpwuid(d.d_id);
                                if (u)
                                        name = u->pw_name;
                        } else if (type == XFS_GROUP_QUOTA) {
-                               struct group    *g = getgrgid(id);
+                               struct group    *g = getgrgid(d.d_id);
                                if (g)
                                        name = g->gr_name;
                        } else if (type == XFS_PROJ_QUOTA) {
-                               fs_project_t    *p = getprprid(id);
+                               fs_project_t    *p = getprprid(d.d_id);
                                if (p)
                                        name = p->pr_name;
                        }
@@ -425,14 +429,14 @@ report_user_mount(
 
        if (upper) {    /* identifier range specified */
                for (id = lower; id <= upper; id++) {
-                       if (report_mount(fp, id, NULL,
+                       if (report_mount(fp, id, NULL, NULL,
                                        form, XFS_USER_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
        } else {
                setpwent();
                while ((u = getpwent()) != NULL) {
-                       if (report_mount(fp, u->pw_uid, u->pw_name,
+                       if (report_mount(fp, u->pw_uid, u->pw_name, NULL,
                                        form, XFS_USER_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
@@ -457,14 +461,14 @@ report_group_mount(
 
        if (upper) {    /* identifier range specified */
                for (id = lower; id <= upper; id++) {
-                       if (report_mount(fp, id, NULL,
+                       if (report_mount(fp, id, NULL, NULL,
                                        form, XFS_GROUP_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
        } else {
                setgrent();
                while ((g = getgrent()) != NULL) {
-                       if (report_mount(fp, g->gr_gid, g->gr_name,
+                       if (report_mount(fp, g->gr_gid, g->gr_name, NULL,
                                        form, XFS_GROUP_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
@@ -488,14 +492,14 @@ report_project_mount(
 
        if (upper) {    /* identifier range specified */
                for (id = lower; id <= upper; id++) {
-                       if (report_mount(fp, id, NULL,
+                       if (report_mount(fp, id, NULL, NULL,
                                        form, XFS_PROJ_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
        } else {
                setprent();
                while ((p = getprent()) != NULL) {
-                       if (report_mount(fp, p->pr_prid, p->pr_name,
+                       if (report_mount(fp, p->pr_prid, p->pr_name, NULL,
                                        form, XFS_PROJ_QUOTA, mount, flags))
                                flags |= NO_HEADER_FLAG;
                }
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>