From owner-freebsd-questions@FreeBSD.ORG Fri Oct 25 22:31:22 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 6709DB3E for ; Fri, 25 Oct 2013 22:31:22 +0000 (UTC) (envelope-from dnewman@networktest.com) Received: from mail5.networktest.com (mail5.networktest.com [204.109.60.142]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2CC692753 for ; Fri, 25 Oct 2013 22:31:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail5.networktest.com (Postfix) with ESMTP id BD4202FCCA0 for ; Fri, 25 Oct 2013 15:31:20 -0700 (PDT) Received: from mail5.networktest.com ([127.0.0.1]) by localhost (mail5.networktest.com [127.0.0.1]) (maiad, port 10024) with ESMTP id 17836-01 for ; Fri, 25 Oct 2013 15:31:20 -0700 (PDT) Received: from dhcp130.eng.networktest.com (ns.networktest.com [205.147.16.129]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: dnewman@networktest.com) by mail5.networktest.com (Postfix) with ESMTPSA id 6F6C82FCC96 for ; Fri, 25 Oct 2013 15:31:20 -0700 (PDT) Message-ID: <526AF138.9000200@networktest.com> Date: Fri, 25 Oct 2013 15:31:20 -0700 From: David Newman Organization: Network Test Inc. User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: viewing major and minor device numbers References: <526AC5E7.3080900@networktest.com> <20131025213456.13153587.freebsd@edvax.de> <526AD757.7010704@networktest.com> <025FA68F-57BF-4B6E-8898-5BD3EAF96372@lafn.org> In-Reply-To: <025FA68F-57BF-4B6E-8898-5BD3EAF96372@lafn.org> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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:31:22 -0000 On 10/25/13 3:24 PM, Doug Hardie wrote: > > 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 >>>> >>>> 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. >>>> >>>> The ls manpage says these numbers should be displayed in the size field. >>>> However, I'm seeing only one hex value, e.g.: >>>> >>>> $ ls -l /dev/null >>>> crw-rw-rw- 1 root wheel 0x13 Oct 25 12:22 /dev/null >>>> >>>> So I don't know what major and minor values to feed mknod. Or is there >>>> another way to do this? >>> >>> 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): >>> >>> % /bin/ls -laFG /dev/null >>> crw-rw-rw- 1 root wheel 0, 17 Oct 25 21:33 /dev/null >>> ^ ^^ >>> >>> This is the binary /bin/ls, no "shell builtin" or the like, >>> called from the C shell; OS is FreeBSD 8, x86. >> >> Even with /bin/ls, the system still returns the hex code: >> >> # /bin/ls -laFG /dev/null >> crw-rw-rw- 1 root wheel 0x13 Oct 25 13:22 /dev/null >> >> 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. >> > > 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]; > > 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)); > > (void)printf("%*s ", (u_int)width, buf); > } > > > > 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. Ahhh, got it. Many thanks. In this case I'm OK going with devfs, but thanks for clearing up why the output is different in 9.x. I suppose one could say this "breaks" mknod, or at least makes it much harder to use. But since the same thing is available from devfs, and it doesn't require messing with device numbers, I guess it's OK. Thanks again dn > > 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. > > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >