commit dd34066c2162e2347d044660e4049cbb8c141c9c
parent d190c9c3d4ecd8a3bef658b975a6596a8cf1acbc
Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 28 Apr 2012 20:34:51 +0200
A bit more precise in README.md.
Diffstat:
8 files changed, 470 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -18,6 +18,14 @@ For getting nldev and mdev to work use the following instructions.
% cd /bin
% ln -s busybox mdev
+Now copy over all the required files.
+
+ % cd $nldevdir
+ % mkdir -p /lib/mdev
+ % mkdir -p /etc
+ % cp mdev/etc/mdev.conf /etc
+ % cp mdev/lib/* /lib/mdev
+
In you init scripts you will need to trigger:
% run_nldev &
@@ -31,3 +39,13 @@ in the kernel, don't assume interfaces to be there after startup.
Always add some step to check for the devices to be there or do
them per service.
+## udev replacement
+
+Many application directly depend on libudev and so need the
+overengineered backends of udev to work. Most of this (like X11)
+can be avoided by having symlinks to static devices and leaving
+all the automatism in one place instead of many.
+
+Scripts that call the udev tools directly will need to be patched,
+like laptop-mode-utils.
+
diff --git a/mdev/etc/mdev.conf b/mdev/etc/mdev.conf
@@ -0,0 +1,206 @@
+#
+# mdev.conf
+#
+
+$MODALIAS=.* root:root 660 @/bin/busybox modprobe "$MODALIAS"
+
+# tty
+# TODO: add char/X:X
+console root:tty 600 @chmod 600 $MDEV
+pty.* root:tty 660
+ptmx root:tty 666
+tty root:tty 666
+tty[0-9]* root:tty 620
+vcs root:tty 660
+vcs[0-9]* root:tty 660
+vcsa root:tty 660
+vcsa[0-9]* root:tty 660
+
+# serial
+ttyS[0-9]* root:uucp 660
+ppox[0-9]* root:uucp 660
+ircomm[0-9]* root:uucp 660
+noz[0-9]* root:uucp 660
+rfcomm[0-9]* root:uucp 660
+mwave root:uucp 660
+hvc.* root:uucp 660
+hvsi.* root:uucp 660
+
+ttyUSB[0-9]* root:uucp 660
+ttyACM[0-9]* root:uucp 660
+
+ttyLTM[0-9]* root:uucp 660
+ttySHSF[0-9]* root:uucp 660
+slamr root:uucp 660
+slusb root:uucp 660
+
+# virtio serial
+vport.* root:root 660
+
+# mem
+null root:root 666 @chmod 666 $MDEV
+zero root:root 666
+full root:root 666
+random root:root 666
+urandom root:root 666
+hwrandom root:root 444
+hw_random root:root 444 =hwrng
+grsec root:root 660
+mem root:kmem 640
+kmem root:kmem 640
+port root:kmem 640
+nvram root:kmem 640
+
+# input
+mouse.* root:root 640 =input/
+mice root:root 640 =input/
+event.* root:root 640 */lib/mdev/inputdev
+ts[0-9]* root:root 640 =input/
+uinput root:root 640$ =input/
+js[0-9]* root:root 644 =input/
+
+# v4l
+vttuner.* root:video 660 >v4l/
+video.* root:video 660 >v4l/
+vtx.* root:video 660 >v4l/
+vbi.* root:video 660 >v4l/
+winradio.* root:video 660 >v4l/
+v4l.* root:video 660 >v4l/
+
+# graphics
+agpgart root:video 660
+pmu root:video 660
+nvidia.* root:video 660
+nvidiactl.* root:video 660
+fb[0-9]* root:video 660
+
+# dri
+card[0-9]* root:video 660 =dri/
+controlD[0-9]* root:video 660 =dri/
+
+# dvb
+dvb.* root:video 660 */lib/mdev/dvbdev
+
+# usb
+([0-9]+)-([0-9]+).* root:usb 665 */lib/mdev/usb
+
+# printer
+parport[0-9]* root:lp 660
+parport_pc root:lp 660
+lp[0-9]* root:lp 660
+irlpt[0-9]* root:lp 660
+
+# block devices
+ram[0-9]* root:disk 660
+loop[0-9]* root:disk 660
+sd[!a-z].* root:disk 660 */lib/mdev/sddev
+hd[a-z].* root:disk 660 */lib/mdev/hddev
+control root:root 000 =mapper/
+md.* root:disk 660
+mtd.* root:disk 660
+ndb.* root:disk 660
+gnbd.* root:disk 660
+btibm.* root:disk 660
+dm-.* root:disk 660
+vd.* root:disk 660
+sg.* root:disk 660
+
+# floppy
+fd[0-9] root:floppy 660
+
+# optical
+sr[0-9]* root:optical 660 @ln -sf $MDEV optical
+pktcdvd[0-9]* root:optical 660 =pktcdvd/
+pktcdvd root:optical 660 =pktcdvd/control
+
+# tape
+ht[0-9]* root:tape 660
+nht[0-9]* root:tape 660
+pt[0-9]* root:tape 660
+npt[0-9]* root:tape 660
+pht[0-9]* root:tape 660
+st*[0-9]* root:tape 660
+nst*[0-9]* root:tape 660
+
+# block-related
+scsi.*/.* root:disk 660 !
+bdi.*/.* root:disk 660 !
+
+sch[0-9]* root:disk 660
+pg[0-9]* root:disk 660
+
+qft[0-9]* root:disk 660
+nqft[0-9]* root:disk 660
+zqft[0-9]* root:disk 660
+nzqft[0-9]* root:disk 660
+rawqft[0-9]* root:disk 660
+nrawqft[0-9]* root:disk 660
+
+rawctl root:disk 660 =raw/
+raw[0-9]* root:disk 660 =raw/
+aoe.* root:disk 660 =etherd/
+bsg/.* root:disk 660 =bsg/
+
+# audio
+pcmC.* root:audio 660 =snd/
+controlC.* root:audio 660 =snd/
+midiC.* root:audio 660 =snd/
+seq root:audio 660 =snd/
+timer root:audio 660 =snd/
+hwC.* root:audio 660 =snd/
+
+hpet root:audio 660
+
+adsp root:audio 660 >sound/
+audio root:audio 660 >sound/
+dsp root:audio 660 >sound/
+mixer root:audio 660 >sound/
+sequencer.* root:audio 660 >sound/
+
+# network
+-net/.* root:root 600 @nameif
+tun root:root 666 =net/
+tun[0-9]* root:root 600 =net/
+tap[0-9]* root:root 600 =net/
+rfkill root:rfkill 64
+
+# cpu
+cpu([0-9]+) root:root 444 =cpu/%1/cpuid
+msr([0-9]+) root:root 600 =cpu/%1/msr
+microcode root:root 600 =cpu/microcode
+
+# fuse
+fuse root:root 666 @/bin/mount -t fusectl fusectl /sys/fs/fuse/connections
+
+# raid controllers
+cciss.* root:disk 660
+ida.* root:disk 660
+rd.* root:disk 660
+
+# misc
+ppp root:root 000
+kvm root:kvm 660
+rtc root:root 664
+rtc[0-9]* root:root 664 @ln -sf $MDEV rtc
+mmtimer root:root 644
+rflash[0-9]* root:root 400
+rrom[0-9]* root:root 400
+
+auer[0-9]* root:root 660 =usb/
+sxctl root:root 660 =specialix_sxctl
+rioctl root:root 660 =specialix_rioctl
+iowarrior[0-9]* root:root 660 =usb/
+hiddev[0-9]* root:root 660 =usb/
+legousbtower[0-9]* root:root 660 =usb/
+dabusb[0-9]* root:root 660 =usb/
+usbdpfp[0-9]* root:root 660 =usb/
+cpad[0-9]* root:root 660 =usb/
+
+# arch
+sgi_.* root:root 666
+iseries/ibmsis.* root:disk 660
+iseries/nvt.* root:disk 660
+iseries/vt.* root:disk 660
+iseries/vtty.* root:uucp 660
+z90crypt root:root 666
+
diff --git a/mdev/lib/dvbdev b/mdev/lib/dvbdev
@@ -0,0 +1,21 @@
+#!/bin/busybox ash
+
+# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0
+ADAPTER=${MDEV%.*}
+N=${ADAPTER#dvb}
+# MDEV=dvb0.demux1 -> DEVB_DEV=demux1
+DVB_DEV=${MDEV#*.}
+
+case "$ACTION" in
+ add|"")
+ mkdir -p dvb/adapter${N}
+ mv ${MDEV} dvb/adapter${N}/${DVB_DEV}
+ ;;
+ remove)
+ rm -f dvb/adapter${N}/${DVB_DEV}
+ rmdir dvb/adapter${N} 2>/dev/null
+ rmdir dvb/ 2>/dev/null
+esac
+
+exit 0
+
diff --git a/mdev/lib/hddev b/mdev/lib/hddev
@@ -0,0 +1 @@
+sddev+
\ No newline at end of file
diff --git a/mdev/lib/inputdev b/mdev/lib/inputdev
@@ -0,0 +1,50 @@
+#!/bin/busybox ash
+
+[ -n "$MDEV" ] || exit 0
+[ -n "$DEVNAME" ] || exit 0
+[ "$SUBSYSTEM" = "input" ] || exit 0
+
+BPATH="input"
+SPATH="/sys${DEVPATH}"
+
+NAME=""
+if [ -e ${SPATH} ];
+then
+ NAME=$(cat ${SPATH}/../name)
+fi
+
+cd $BPATH
+case "$ACTION" in
+ add|"")
+ if [ ! -e "$MDEV" ];
+ then
+ mv ../$MDEV .
+ fi
+
+ case "$NAME" in
+ "TPPS/2 IBM TrackPoint")
+ ln -s $MDEV mouse
+ ;;
+ "AT Translated Set 2 keyboard")
+ ln -s $MDEV kbd
+ ;;
+ esac
+ ;;
+ remove)
+ if [ -e "$MDEV" ];
+ then
+ rm -f $MDEV
+ fi
+
+ case "$NAME" in
+ "TPPS/2 IBM TrackPoint")
+ rm -f mouse
+ ;;
+ "AT Translated Set 2 keyboard")
+ rm -f kbd
+ ;;
+ esac
+ ;;
+esac
+
+exit 0
diff --git a/mdev/lib/sddev b/mdev/lib/sddev
@@ -0,0 +1,97 @@
+#!/bin/busybox ash
+
+# $MDEV
+# $ACTION
+
+blkidstr=$(blkid $(pwd)/${MDEV})
+UUID=$(echo -n "$blkidstr" \
+ | grep UUID \
+ | sed -e 's,.*UUID="\([^"]*\)".*,\1,')
+LABEL=$(echo -n "$blkidstr" \
+ | grep LABEL \
+ | sed -e 's,.*LABEL="\([^"]*\)".*,\1,')
+BLOCK=$(cat /sys${DEVPATH}/dev)
+
+case "$ACTION" in
+ add|"")
+ if [ -n "${UUID}" ];
+ then
+ mkdir -p disk/by-uuid
+ cd disk/by-uuid
+ [ -e "${UUID}" ] && rm -f ${UUID}
+ ln -s ../../${MDEV} ${UUID}
+ cd ../..
+ fi
+
+ if [ -n "${LABEL}" ];
+ then
+ mkdir -p disk/by-label
+ cd disk/by-uuid
+ [ -e "${LABEL}" ] && rm -f ${LABEL}
+ ln -s ../../${MDEV} ${LABEL}
+ cd ../..
+ fi
+
+ if [ -n "${BLOCK}" ];
+ then
+ mkdir -p block
+ cd block
+ [ -e "${BLOCK}" ] && rm -f ${BLOCK}
+ ln -s ../${MDEV} ${BLOCK}
+ cd ..
+ fi
+ ;;
+ remove)
+ [ -n "${UUID}" ] && [ -e disk/by-uuid/${UUID} ] \
+ && rm -f disk/by-uuid/${UUID}
+ [ -n "${LABEL}" ] && [ -e disk/by-uuid/${LABEL} ] \
+ && rm -f disk/by-uuid/${LABEL}
+ [ -n "${BLOCK}" ] && [ -e block/${BLOCK} ] \
+ && rm -f block/${BLOCK}
+
+ if [ -e disk/by-uuid ];
+ then
+ cd disk/by-uuid
+ SLS=$(ls -l \
+ | awk "/..\/..\/${MDEV}/ {print \$9 }")
+ for FILE in ${SLS};
+ do
+ rm -f ${FILE}
+ done
+ cd ../..
+
+ rmdir disk/by-uuid 2>/dev/null
+ fi
+ if [ -e disk/by-label ];
+ then
+ cd disk/by-label
+ SLS=$(ls -l \
+ | awk "/..\/..\/${MDEV}/ {print \$9 }")
+ for FILE in ${SLS};
+ do
+ rm -f ${FILE}
+ done
+ cd ../..
+
+ rmdir disk/by-label 2>/dev/null
+ fi
+ rmdir disk/ 2>/dev/null
+
+ if [ -e block ];
+ then
+ cd block
+ SLS=$(ls -l \
+ | awk "/..\/${MDEV}/ {print \$9 }")
+ for FILE in ${SLS};
+ do
+ rm -f ${FILE}
+ done
+ cd ..
+
+ rmdir block 2>/dev/null
+ fi
+ ;;
+esac
+
+exit 0
+
diff --git a/mdev/lib/ttydev b/mdev/lib/ttydev
@@ -0,0 +1,51 @@
+#!/bin/busybox ash
+
+#
+# This will work, but it is a useless overhead for every tty
+# that might be created. Only use it, if there is really some
+# dirty compatibility with udev that won't resolve otherwise!
+# You have been warned!
+#
+
+# $MDEV
+# $ACTION
+
+if [ "${MDEV}" = "console" ] || [ "${MDEV}" = "null" ];
+then
+ chmod 600 ${MDEV}
+fi
+
+CHAR=$(cat /sys/${DEVPATH}/dev)
+
+case "$ACTION" in
+ add|"")
+ if [ -n "${CHAR}" ];
+ then
+ mkdir -p char
+ cd char
+ [ -e "${CHAR}" ] && rm -f ${CHAR}
+ ln -s ../${MDEV} ${CHAR}
+ cd ..
+ fi
+ ;;
+ remove)
+ [ -e char/${CHAR} ] && rm -f char/${CHAR}
+
+ if [ -e char ];
+ then
+ cd char
+ SLS=$(ls -l \
+ | awk "/..\/${MDEV}/ {print \$9 }")
+ for FILE in ${SLS};
+ do
+ rm -f ${FILE}
+ done
+ cd ..
+
+ rmdir char 2>/dev/null
+ fi
+ ;;
+esac
+
+exit 0
+
diff --git a/mdev/lib/usb b/mdev/lib/usb
@@ -0,0 +1,25 @@
+#!/bin/busybox ash
+
+[ -n "$MDEV" ] || exit 0
+[ -n "$DEVNAME" ] || exit 0
+[ "$SUBSYSTEM" = "usb" ] || exit 0
+
+BUSPATH=$(dirname "$DEVNAME")
+DEVICENAME=$(basename "$DEVNAME")
+
+case "$ACTION" in
+ add|"")
+ if [ ! -d "$BUSPATH" ]; then
+ mkdir -p "$BUSPATH"
+ fi
+ mv "$MDEV" "$BUSPATH/$DEVICENAME"
+ ;;
+ remove)
+ if rm -f "$BUSPATH/$DEVICENAME" 2>/dev/null
+ then
+ rmdir -p "$BUSNAME" 2>/dev/null
+ fi
+ ;;
+esac
+
+exit 0