Return-Path: Received: from relay.sgi.com (relay2.corp.sgi.com [137.38.102.29]) by oss.sgi.com (Postfix) with ESMTP id AD2B37CA0 for ; Wed, 6 Apr 2016 23:12:19 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay2.corp.sgi.com (Postfix) with ESMTP id 7E71B304039 for ; Wed, 6 Apr 2016 21:12:16 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id 6mLItogzBa72pMkM (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 06 Apr 2016 21:12:15 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 581677F6C1 for ; Thu, 7 Apr 2016 04:12:14 +0000 (UTC) From: Zorro Lang Subject: [PATCH v2] xfs_quota: print quota id number if the name can't be found Date: Thu, 7 Apr 2016 12:12:11 +0800 Message-Id: <1460002331-18278-1-git-send-email-zlang@redhat.com> List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: xfs@oss.sgi.com Cc: sandeen@redhat.com, Zorro Lang When use GETNEXTQUOTA ioctl to report project quota, it always report an unexpected quota: (null) 0 0 0 00 [--------] The ID 0 store the default quota, even if no one set default quota, it still have quota accounting, but not enforced. So GETNEXTQUOTA can find and report this undefined quota. >From this problem, I thought if others' quota name miss, (null) will be printed too. e.g. # xfs_quota -xc "limit -u bsoft=300m bhard=400m test" $mnt # xfs_quota -xc "report -u" $mnt User ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------] test 0 307200 409600 00 [--------] # userdel -r test # xfs_quota -xc "report -u" $mnt User ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------] (null) 0 307200 409600 00 [--------] So this problem same with above id 0's problem. For deal with this, this patch will print id number if the name can't be found. But if use old GETQUOTA ioctl, it won't print project id 0 quota information(if it's not defined). That's different with GETNEXTQUOTA. For keep consistent, this patch also print project id 0 when use old GETQUOTA. Signed-off-by: Zorro Lang --- Hi, This V2 patch has below change: 1. Add some comments 2. Change the xfs_quota man page 3. For alignment, change "#%-10u" to "#%-9u" when print ID or name mixed. For reduce the impact on xfstests, I didn't change the original "#%-10u" when use "report -n": if (flags & NO_LOOKUP_FLAG) { fprintf(fp, "#%-10u", d.d_id); And didn't change "%-10s" when print quota name: fprintf(fp, "%-10s", name); Thanks, Zorro man/man8/xfs_quota.8 | 7 +++++-- quota/report.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/man/man8/xfs_quota.8 b/man/man8/xfs_quota.8 index 951252b..dc01804 100644 --- a/man/man8/xfs_quota.8 +++ b/man/man8/xfs_quota.8 @@ -357,9 +357,12 @@ option outputs the report to .I file instead of stdout. The .B \-a -option reports on all filesystems. The +option reports on all filesystems. As default, outputs the name of +the user/group/project. But if no name is defined, outputs the +numberic ID. The .B \-n -option outputs the numeric ID instead of the name. The +option outputs the numeric ID instead of the name, even the name is +defined. The .B \-L and .B \-U diff --git a/quota/report.c b/quota/report.c index 48a3f29..cc422d1 100644 --- a/quota/report.c +++ b/quota/report.c @@ -389,7 +389,11 @@ report_mount( name = p->pr_name; } } - fprintf(fp, "%-10s", name); + /* If no name is found, print the id #num instead of (null) */ + if (name != NULL) + fprintf(fp, "%-10s", name); + else + fprintf(fp, "#%-9u", d.d_id); } if (form & XFS_BLOCK_QUOTA) { @@ -571,6 +575,16 @@ report_project_mount( id = oid + 1; } } else { + if (!getprprid(0)) { + /* + * Print default project quota, even if projid 0 + * isn't defined + */ + report_mount(fp, 0, NULL, NULL, form, XFS_PROJ_QUOTA, + mount, flags); + flags |= NO_HEADER_FLAG; + } + setprent(); while ((p = getprent()) != NULL) { if (report_mount(fp, p->pr_prid, p->pr_name, NULL, -- 2.5.5 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs