From owner-freebsd-arch@FreeBSD.ORG Fri Nov 24 17:40:23 2006 Return-Path: X-Original-To: freebsd-arch@FreeBSD.ORG Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 984D916A403 for ; Fri, 24 Nov 2006 17:40:23 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C2D243D5D for ; Fri, 24 Nov 2006 17:39:38 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (rytytm@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id kAOHeDni072174 for ; Fri, 24 Nov 2006 18:40:18 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id kAOHeDHB072173; Fri, 24 Nov 2006 18:40:13 +0100 (CET) (envelope-from olli) Date: Fri, 24 Nov 2006 18:40:13 +0100 (CET) Message-Id: <200611241740.kAOHeDHB072173@lurza.secnetix.de> From: Oliver Fromme To: freebsd-arch@FreeBSD.ORG X-Newsgroups: list.freebsd-arch User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Fri, 24 Nov 2006 18:40:19 +0100 (CET) Cc: Subject: New option for ls(1), du(1), df(1) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Nov 2006 17:40:23 -0000 Hi, I'm not sure if posting to this list is the correct way to proceed, but the title says "Architecture and design discussions", and I'm having a design issue, so here it goes ... The tools ls(1), du(1) and df(1) all have a "-h" option which means so-called "human-readable" output. However, personally I think the output isn't very human-readable either way. You often get a mixture of numbers with various combinations of "K", "M", "G", and it's difficult to recognize the dimensions quickly and compare them to each other. Just an example: Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1a 989M 61M 849M 7% / /dev/ad0s1d 9.7G 31M 8.9G 0% /var /dev/ad0s1e 9.7G 1.5G 7.4G 17% /usr /dev/ad0s1f 122G 1.3G 111G 1% /home /dev/md0 290M 20K 267M 0% /tmp I've hacked a new option into those tools which uses thousands separators for displaying the numbers. With that option, the output looks like this (in US locale): Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 1,012,974 62,418 869,520 7% / /dev/ad0s1d 10,154,158 31,474 9,310,352 0% /var /dev/ad0s1e 10,154,158 1,545,718 7,796,108 17% /usr /dev/ad0s1f 128,009,212 1,358,600 116,409,876 1% /home /dev/md0 297,326 20 273,520 0% /tmp With a German locale (my personal default), periods are used instead of commas. The patches for ls(1), du(1) and df(1) are available from this URL: http://www.secnetix.de/~olli/FreeBSD/ls-patch/ They apply cleanly to RELENG_6 and RELENG_5. Except for df(1) they also apply to HEAD (the df(1) patch requires a small modification because of the recent addition of the "kflag" variable in HEAD). Those patches are not ready yet (that's why i haven't send-pr'ed them). They're not checked against style(9), and the option that I used for the new feature is "-," which is probably against style(9), even though it is easy to remember. For the same reason I haven't updated the usage strings and the manpages yet (but I'll do that when there is consensus). I have a few questions ... 1. Which option letter should be used (if not "-,")? Currently, the following are unused in ls(1): -DEJKMNOQVXYejvyz They are also unused in du(1) and df(1), so one of those would be fine. 2. There's a bit of common code in my patches to the three utilities. Should that code be moved to libutil? That's also where humanize_number(3) already lives. It is also worth noting that probably many more tools might benefit from that feature. "netstat -i" and "ipfw show" come to mind immediately. Any comments are welcome. Best regards Oliver PS: I'm reading the list, so there's no need to put me on CC when replying. -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. One Unix to rule them all, One Resolver to find them, One IP to bring them all and in the zone to bind them.