From owner-freebsd-questions@FreeBSD.ORG Fri Oct 25 22:24:37 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DB859767 for ; Fri, 25 Oct 2013 22:24:37 +0000 (UTC) (envelope-from bc979@lafn.org) Received: from zoom.lafn.org (zoom.lafn.org [108.92.93.123]) by mx1.freebsd.org (Postfix) with ESMTP id 981FF26D9 for ; Fri, 25 Oct 2013 22:24:37 +0000 (UTC) Received: from [10.0.1.4] (static-71-177-216-148.lsanca.fios.verizon.net [71.177.216.148]) (authenticated bits=0) by zoom.lafn.org (8.14.3/8.14.2) with ESMTP id r9PMOZ7h051711 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 25 Oct 2013 15:24:36 -0700 (PDT) (envelope-from bc979@lafn.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: viewing major and minor device numbers From: Doug Hardie In-Reply-To: <526AD757.7010704@networktest.com> Date: Fri, 25 Oct 2013 15:24:35 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <025FA68F-57BF-4B6E-8898-5BD3EAF96372@lafn.org> References: <526AC5E7.3080900@networktest.com> <20131025213456.13153587.freebsd@edvax.de> <526AD757.7010704@networktest.com> To: David Newman X-Mailer: Apple Mail (2.1510) X-Virus-Scanned: clamav-milter 0.97 at zoom.lafn.org X-Virus-Status: Clean Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 22:24:37 -0000 On 25 October 2013, at 13:40, David Newman = wrote: > On 10/25/13 12:34 PM, Polytropon wrote: >> On Fri, 25 Oct 2013 12:26:31 -0700, David Newman wrote: >>> FreeBSD 9.2-RELEASE, amd64 >>>=20 >>> To create some character special devices in a chroot environment, = I've >>> previously used mknod, but now can't find the major and minor device >>> numbers. >>>=20 >>> The ls manpage says these numbers should be displayed in the size = field. >>> However, I'm seeing only one hex value, e.g.: >>>=20 >>> $ ls -l /dev/null >>> crw-rw-rw- 1 root wheel 0x13 Oct 25 12:22 /dev/null >>>=20 >>> So I don't know what major and minor values to feed mknod. Or is = there >>> another way to do this? >>=20 >> Do you have any "suspicious" ls alias or options preconfigured? >> That output looks a bit strange, it should be something like >> this (example from a host system, not from inside a jail): >>=20 >> % /bin/ls -laFG /dev/null=20 >> crw-rw-rw- 1 root wheel 0, 17 Oct 25 21:33 /dev/null >> ^ ^^ >>=20 >> This is the binary /bin/ls, no "shell builtin" or the like, >> called from the C shell; OS is FreeBSD 8, x86. >=20 > Even with /bin/ls, the system still returns the hex code: >=20 > # /bin/ls -laFG /dev/null > crw-rw-rw- 1 root wheel 0x13 Oct 25 13:22 /dev/null >=20 > Two machines, both running 9.2/amd64, both return these hex codes. One > machine runs on bare metal and the other is a VM I just built. Both > machines have no aliases for ls. >=20 The ls source module print.c has been changed in the printdev module to = print differently: Here is the module from 8.x (I don't recall which exact version this is) printdev(size_t width, dev_t dev) { char buf[DEVSTR_HEX_LEN + 1]; =20 if (minor(dev) > 255 || minor(dev) < 0) (void)snprintf(buf, sizeof(buf), "%3d, 0x%08x", major(dev), (u_int)minor(dev)); else (void)snprintf(buf, sizeof(buf), "%3d, %3d", major(dev), minor(dev)); =20 (void)printf("%*s ", (u_int)width, buf); } =20 Note that it splits the dev number into the two fields we are all used = to. Now here is the same code from 9.2 Release: printdev(size_t width, dev_t dev) { (void)printf("%#*jx ", (u_int)width, (uintmax_t)dev); } Note its a lot simpler because it does not bother to split out the major = and minor numbers. You might be able to replace just this module and rebuild ls. major and = minor are still in the libs. It looks like it should work, but I = haven't tried it.