An example mdev.conf
Rob Landley
rob at landley.net
Thu Nov 5 21:11:26 UTC 2009
On Thursday 05 November 2009 11:19:31 Natanael Copa wrote:
> On Thu, 2009-11-05 at 01:52 -0600, Rob Landley wrote:
> > So solar at gentoo has maintained his own mdev.conf for a while:
> >
> > ftp://tinderbox.x86.dev.gentoo.org/misc/mdev.conf
> >
> > And Cross Linux From Scratch picked up a variant of it:
> >
> > http://cross-lfs.org/view/clfs-embedded/x86/bootscripts/mdev.html
> >
> > It would be nice if busybox had an example mdev.conf in the examples
> > directory, and these seem to be the main ones being used in the field.
>
> Have a look at this one too:
> http://git.alpinelinux.org/cgit/aports/tree/main/busybox-initscripts/mdev.c
>onf
Yay, more to pile on!
Possibly we want 2 examples mdev.conf files. One really tiny one that just
changes the permissions on /dev/null and /dev/zero and such so a non-root
process can at least _run_, and a second "kitchen sink" version containing
everything we know about.
>#
># This is a sample mdev.conf.
>#
>
># Devices:
># Syntax: %s %d:%d %s
># devices user:group mode
>
># null does already exist; therefore ownership has to be changed with
> command null root:root 0666 @chmod 666 $MDEV
>zero root:root 0666
Should mdev grow a more graceful way to do that? (This is a design question,
and if I start making design decisions for mdev I'm going to go back in and
RIP OUT the stupid "individually re-malloc and free every single line of the
file over and over for every device mdev -s handles and then do it again when
responding to hotplug events" code, and put back the faster/smaller/simpler
mmap version back in. If you want to genericize the mmap version, fine. But
unnecessarily doing 8 gazillion small malloc/frees is painful even when you're
not trying to support nommu...)
Anyway, I'm wild guessing that "mdev -s" should stomp existing permissions (at
least when we actually have a mdev.conf line for it instead of just a default
value), but hotplug shouldn't?
>zero root:root 0666
0:0 is smaller than root:root, and won't change.
Also, failure to look up a numeric uid/gid in /etc/passwd shouldn't really be
an error. We know how to handle it, and people who grab our default config file
won't necessarily grab a default passwd and group from us. (In this case,
what they probably really care about is that this device has a _unique_
owner/group, which they can attach to later if they care.)
>grsec root:root 0660
This is the default value, there's no reason to specify it that I'm aware of.
># console does already exist; therefore ownership has to be changed with
> command console root:tty 0600 @chmod 600 $MDEV && mkdir -p vc && ln -sf
> ../$MDEV vc/0 fd0 root:floppy 0660
Same as the earlier comment about changing mdev behavior to set permissions
automatically, plus I believe there's a symlink syntax already you should be
able to use for this?
I admit to being somewhat out of the loop with the symlink syntax. Solar
designed that, and I forget quite how it works.
By the way, what actually needs the vc/0 crud, anyway? Didn't devfs names die
with devfs? (And /dev/console _isn't_ a virtual console, it could be a serial
device.)
>kmem root:root 0640
>mem root:root 0640
>port root:root 0640
>ptmx root:tty 0666
>
># ram.*
>ram([0-9]*) root:disk 0660 >rd/%1
>loop([0-9]+) root:disk 0660 >loop/%1
>sd[a-z].* root:disk 0660 */lib/mdev/usbdisk_link
>hd[a-z][0-9]* root:disk 0660 */lib/mdev/ide_links
>md[0-9] root:disk 0660
Ooh, there _is_ a regex syntax for parentheticals. (I am so out of the loop.
And I need to update mdev.txt it seems.)
And while I'm at it, the symlink syntax solar and LFS are using doesn't match
what mdev.txt documents. I wonder if they're patching mdev?
>tty root:tty 0666
>tty[0-9] root:root 0600
>tty[0-9][0-9] root:tty 0660
Presumably tty[0-9]* would handle all of those cases?
Why is the middle of the three different than the first and last?
>ttyS[0-9]* root:uucp 0660
>pty.* root:tty 0660
>vcs[0-9]* root:tty 0660
>vcsa[0-9]* root:tty 0660
>
>
>ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem
>ttySHSF[0-9] root:dialout 0660 @ln -sf $MDEV modem
>slamr root:dialout 0660 @ln -sf $MDEV slamr0
>slusb root:dialout 0660 @ln -sf $MDEV slusb0
>fuse root:root 0666
>
># dri device
>card[0-9] root:video 0660 =dri/
>
># alsa sound devices and audio stuff
>pcm.* root:audio 0660 =snd/
>control.* root:audio 0660 =snd/
>midi.* root:audio 0660 =snd/
>seq root:audio 0660 =snd/
>timer root:audio 0660 =snd/
Isn't there some kind of curly bracket syntax we can feed to these regexes to
group essentially identical lines like this? (This is actually a regex
question, not an mdev question.)
Who created the "snd" directory, anyway? (Your init scripts before calling
mdev?)
>adsp root:audio 0660 >sound/
>audio root:audio 0660 >sound/
>dsp root:audio 0660 >sound/
>mixer root:audio 0660 >sound/
>sequencer.* root:audio 0660 >sound/
>
># misc stuff
>agpgart root:root 0660 >misc/
>psaux root:root 0660 >misc/
>rtc root:root 0664 >misc/
>
># input stuff
>event[0-9]+ root:root 0640 =input/
>mice root:root 0640 =input/
>mouse[0-9] root:root 0640 =input/
>ts[0-9] root:root 0600 =input/
>
># v4l stuff
>vbi[0-9] root:video 0660 >v4l/
>video[0-9] root:video 0660 >v4l/
>
># dvb stuff
>dvb.* root:video 0660 */lib/mdev/dvbdev
>
># load drivers for usb devices
>usbdev[0-9].[0-9] root:root 0660 */lib/mdev/usbdev
>usbdev[0-9].[0-9]_.* root:root 0660
>
># net devices
>tun[0-9]* root:root 0600 =net/
>tap[0-9]* root:root 0600 =net/
>
># zaptel devices
>zap(.*) root:dialout 0660 =zap/%1
>dahdi!(.*) root:dialout 0660 =dahdi/%1
>
># raid controllers
>cciss!(.*) root:disk 0660 =cciss/%1
>ida!(.*) root:disk 0660 =ida/%1
>rd!(.*) root:disk 0660 =rd/%1
Quite a long config file.
>sr[0-9] root:cdrom 0660 @ln -sf $MDEV cdrom
Um, why don't the = and > options work here?
(And when we _unplug_ devices, do those symlinks get properly removed? Or the
moved device nodes?)
> -nc
Rob
--
Latency is more important than throughput. It's that simple. - Linus Torvalds
More information about the busybox
mailing list