viewing major and minor device numbers
David Newman
dnewman at networktest.com
Fri Oct 25 20:40:58 UTC 2013
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.
This URL:
http://fanf.livejournal.com/123376.html
gives instructions for how to create devices in chroot environments
using devfs:
# $T is the chroot directory
mount -t devfs devfs $T/dev
# the default ruleset is immutable, so create a new one
devfs -m $T/dev ruleset 1
# only a small selection of devices should be visible
devfs -m $T/dev rule add path random unhide
devfs -m $T/dev rule add path urandom unhide
# make it so
devfs -m $T/dev rule applyset
This worked for me, and the chroot'd devices have the same hex IDs as
those in /dev.
But I'm still curious why ls displays those hex values instead of major
and minor device numbers.
thanks
dn
More information about the freebsd-questions
mailing list