From owner-svn-src-head@FreeBSD.ORG Thu Jun 30 09:20:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35842106567A; Thu, 30 Jun 2011 09:20:27 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 25D348FC19; Thu, 30 Jun 2011 09:20:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5U9KRis035899; Thu, 30 Jun 2011 09:20:27 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5U9KRP6035897; Thu, 30 Jun 2011 09:20:27 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201106300920.p5U9KRP6035897@svn.freebsd.org> From: Sergey Kandaurov Date: Thu, 30 Jun 2011 09:20:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223690 - head/usr.bin/quota X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2011 09:20:27 -0000 Author: pluknet Date: Thu Jun 30 09:20:26 2011 New Revision: 223690 URL: http://svn.freebsd.org/changeset/base/223690 Log: Fix quota(1) output. - Fix calculation of 1024-byte sized blocks from disk blocks shown when -h option isn't specified. It was broken with quota64 integration. - In prthumanval(): limit the size of a buffer passed to humanize_number() to a width of 5 bytes but allow a shorter length if requested. That's what users expect. PR: bin/150151 Reviewed by: Kirk McKusick Modified: head/usr.bin/quota/quota.c Modified: head/usr.bin/quota/quota.c ============================================================================== --- head/usr.bin/quota/quota.c Thu Jun 30 05:28:10 2011 (r223689) +++ head/usr.bin/quota/quota.c Thu Jun 30 09:20:26 2011 (r223690) @@ -264,8 +264,11 @@ prthumanval(int len, u_int64_t bytes) { char buf[len + 1]; - humanize_number(buf, sizeof(buf), bytes, "", HN_AUTOSCALE, - HN_B | HN_NOSPACE | HN_DECIMAL); + /* + * Limit the width to 5 bytes as that is what users expect. + */ + humanize_number(buf, sizeof(buf) < 5 ? sizeof(buf) : 5, bytes, "", + HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); (void)printf(" %*s", len, buf); } @@ -352,10 +355,13 @@ showquotas(int type, u_long id, const ch 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);