[PATCH 1/2] xfs_quota: push id/name printing down into report_mount()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

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@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux