From owner-freebsd-bugs@FreeBSD.ORG Tue Aug 31 15:10:04 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFEF510656AD for ; Tue, 31 Aug 2010 15:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A3AFC8FC1E for ; Tue, 31 Aug 2010 15:10:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o7VFA4K1026760 for ; Tue, 31 Aug 2010 15:10:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o7VFA4FJ026757; Tue, 31 Aug 2010 15:10:04 GMT (envelope-from gnats) Resent-Date: Tue, 31 Aug 2010 15:10:04 GMT Resent-Message-Id: <201008311510.o7VFA4FJ026757@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, pluknet Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A513010656BD for ; Tue, 31 Aug 2010 15:06:39 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 899548FC21 for ; Tue, 31 Aug 2010 15:06:39 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o7VF6dZv079126 for ; Tue, 31 Aug 2010 15:06:39 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o7VF6dHI079125; Tue, 31 Aug 2010 15:06:39 GMT (envelope-from nobody) Message-Id: <201008311506.o7VF6dHI079125@www.freebsd.org> Date: Tue, 31 Aug 2010 15:06:39 GMT From: pluknet To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/150151: [patch] fix quota(1) output [regression] X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2010 15:10:05 -0000 >Number: 150151 >Category: bin >Synopsis: [patch] fix quota(1) output [regression] >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 31 15:10:04 UTC 2010 >Closed-Date: >Last-Modified: >Originator: pluknet >Release: 9-CURRENT as of August '10 >Organization: >Environment: FreeBSD 9.0-CURRENT #47: Mon Aug 30 15:58:57 UTC 2010 root@host:/usr/obj/usr/src/sys/CUST amd64 >Description: After quota64 project merge, quota(1) starts to 1) incorrectly format numbers in -h mode; 2) print incorrect numbers in ordinary (non -h) mode. The causing changes is in: 1) field expansion resulting in passing too large buffer size to humanize_number(3); 2) some reason resulting in incorrect use of {dbtob() and multiplying} for calculating 1024-k sized blocks from disk blocks. >How-To-Repeat: # quota -rg nobody Raw group quota information for id 65534 on /mnt block hard limit: 0 block soft limit: 400000 current block count: 8 i-node hard limit: 0 i-node soft limit: 0 current i-node count: 1 block grace time: 1283866029 Tue Sep 7 13:27:09 2010 i-node grace time: 1283861167 Tue Sep 7 12:06:07 2010 Incorrect output: # quota -gh nobody Disk quotas for group nobody (gid 65534): Filesystem usage quota limit grace files quota limit grace /mnt 4096B 200000K 0B 1 0 0 # quota -g nobody Disk quotas for group nobody (gid 65534): Filesystem usage quota limit grace files quota limit grace /mnt 4194304 209715200000 0 1 0 0 >Fix: The possible and least intrusive change in attach. It mostly reverts a some part of quota64 project. Output after patching: # quota -gh nobody Disk quotas for group nobody (gid 65534): Filesystem usage quota limit grace files quota limit grace /mnt 4.0K 195M 0B 1 0 0 # quota -g nobody Disk quotas for group nobody (gid 65534): Filesystem usage quota limit grace files quota limit grace /mnt 4 200000 0 1 0 0 Patch attached with submission follows: Index: quota.c =================================================================== --- quota.c (revision 211279) +++ quota.c (working copy) @@ -266,7 +266,7 @@ static void prthumanval(int len, u_int64_t bytes) { - char buf[len + 1]; + char buf[5]; humanize_number(buf, sizeof(buf), bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); @@ -356,10 +356,13 @@ prthumanval(7, dbtob(qup->dqblk.dqb_bhardlimit)); } else { printf(" %7ju%c %7ju %7ju", - dbtob(1024) * (uintmax_t)qup->dqblk.dqb_curblocks, + (uintmax_t)dbtob(qup->dqblk.dqb_curblocks) + / 1024, (msgb == NULL) ? ' ' : '*', - dbtob(1024) * (uintmax_t)qup->dqblk.dqb_bsoftlimit, - dbtob(1024) * (uintmax_t)qup->dqblk.dqb_bhardlimit); + (uintmax_t)dbtob(qup->dqblk.dqb_bsoftlimit) + / 1024, + (uintmax_t)dbtob(qup->dqblk.dqb_bhardlimit) + / 1024); } if (msgb != NULL) bgrace = timeprt(qup->dqblk.dqb_btime); >Release-Note: >Audit-Trail: >Unformatted: