Skip to content

Commit 5939b21

Browse files
committed
first commit
0 parents  commit 5939b21

8 files changed

Lines changed: 292 additions & 0 deletions

File tree

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SYSCONFDIR ?= /etc
2+
LIBDIR ?= /lib
3+
MDEV ?= $(LIBDIR)/mdev
4+
INITD ?= $(SYSCONFDIR)/init.d
5+
6+
all:
7+
8+
install:
9+
install -d $(DESTDIR)$(MDEV)
10+
install -m 0644 mdev/* $(DESTDIR)$(MDEV)
11+
12+
install -d $(DESTDIR)$(INITD)
13+
install -m 0755 init.d/* $(DESTDIR)$(INITD)
14+
15+
install -m 0644 mdev.conf $(SYSCONFDIR)
16+
17+
.PHONY: install

init.d/mdev

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/sbin/openrc-run
2+
3+
depend() {
4+
provide dev
5+
need sysfs dev-mount
6+
before checkfs fsck
7+
keyword -vserver -lxc
8+
}
9+
10+
start() {
11+
# check if udev is specified on cmd line
12+
if get_bootparam "udev"; then
13+
ewarn "Skipping mdev as udev requested in kernel cmdline"
14+
return 0
15+
fi
16+
17+
ebegin "Starting busybox mdev"
18+
mkdir -p /dev
19+
20+
# use mdev for hotplug
21+
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
22+
23+
# mdev -s will not create /dev/usb[1-9] devices with recent kernels
24+
# so we trigger hotplug events for usb for now
25+
for i in $(find /sys/devices -name 'usb[0-9]*'); do
26+
[ -e $i/uevent ] && echo add > $i/uevent
27+
done
28+
29+
# create devices
30+
mdev -s
31+
eend $?
32+
}
33+
34+
stop() {
35+
ebegin "Stopping busybox mdev"
36+
echo "" > /proc/sys/kernel/hotplug
37+
eend
38+
}
39+

mdev.conf

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#
2+
# This is a sample mdev.conf.
3+
#
4+
5+
# Devices:
6+
# Syntax: %s %d:%d %s
7+
# devices user:group mode
8+
9+
$MODALIAS=.* root:root 0660 @modprobe -q -b "$MODALIAS"
10+
11+
# null does already exist; therefore ownership has to be changed with command
12+
null root:root 0666 @chmod 666 $MDEV
13+
zero root:root 0666
14+
grsec root:root 0660
15+
full root:root 0666
16+
17+
random root:root 0666
18+
urandom root:root 0444
19+
hwrandom root:root 0660
20+
21+
console root:tty 0600
22+
23+
# load frambuffer console when first frambuffer is found
24+
fb0 root:video 0660 @modprobe -q -b fbcon
25+
vchiq root:video 0660
26+
27+
fd0 root:floppy 0660
28+
kmem root:root 0640
29+
mem root:root 0640
30+
port root:root 0640
31+
ptmx root:tty 0666
32+
33+
# Kernel-based Virtual Machine.
34+
kvm root:kvm 660
35+
36+
# ram.*
37+
ram([0-9]*) root:disk 0660 >rd/%1
38+
loop([0-9]+) root:disk 0660 >loop/%1
39+
sd[a-z].* root:disk 0660 */lib/mdev/usbdisk_link
40+
hd[a-z][0-9]* root:disk 0660 */lib/mdev/ide_links
41+
md[0-9] root:disk 0660
42+
43+
tty root:tty 0666
44+
tty[0-9] root:root 0600
45+
tty[0-9][0-9] root:tty 0660
46+
ttyS[0-9]* root:uucp 0660
47+
pty.* root:tty 0660
48+
vcs[0-9]* root:tty 0660
49+
vcsa[0-9]* root:tty 0660
50+
51+
# rpi bluetooth
52+
#ttyAMA0 root:tty 660 @hciattach /dev/$MDEV bcm43xx 115200 noflow -
53+
54+
ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem
55+
ttySHSF[0-9] root:dialout 0660 @ln -sf $MDEV modem
56+
slamr root:dialout 0660 @ln -sf $MDEV slamr0
57+
slusb root:dialout 0660 @ln -sf $MDEV slusb0
58+
fuse root:root 0666
59+
60+
# dri device
61+
dri/.* root:video 0660
62+
card[0-9] root:video 0660 =dri/
63+
64+
# alsa sound devices and audio stuff
65+
pcm.* root:audio 0660 =snd/
66+
control.* root:audio 0660 =snd/
67+
midi.* root:audio 0660 =snd/
68+
seq root:audio 0660 =snd/
69+
timer root:audio 0660 =snd/
70+
71+
adsp root:audio 0660 >sound/
72+
audio root:audio 0660 >sound/
73+
dsp root:audio 0660 >sound/
74+
mixer root:audio 0660 >sound/
75+
sequencer.* root:audio 0660 >sound/
76+
77+
SUBSYSTEM=sound;.* root:audio 0660
78+
79+
# misc stuff
80+
agpgart root:root 0660 >misc/
81+
psaux root:root 0660 >misc/
82+
rtc root:root 0664 >misc/
83+
84+
# input stuff
85+
event[0-9]+ root:input 0640 =input/
86+
mice root:input 0640 =input/
87+
mouse[0-9] root:input 0640 =input/
88+
js[0-9] root:input 0640 =input/
89+
ts[0-9] root:input 0600 =input/
90+
91+
# v4l stuff
92+
vbi[0-9] root:video 0660 >v4l/
93+
video[0-9]+ root:video 0660 >v4l/
94+
95+
# dvb stuff
96+
dvb.* root:video 0660 */lib/mdev/dvbdev
97+
98+
# load drivers for usb devices
99+
usb[0-9]+ root:root 0660 */lib/mdev/usbdev
100+
101+
# net devices
102+
net/tun[0-9]* root:netdev 0660
103+
net/tap[0-9]* root:netdev 0660
104+
105+
# zaptel devices
106+
zap(.*) root:dialout 0660 =zap/%1
107+
dahdi!(.*) root:dialout 0660 =dahdi/%1
108+
dahdi/(.*) root:dialout 0660 =dahdi/%1
109+
110+
# raid controllers
111+
cciss!(.*) root:disk 0660 =cciss/%1
112+
cciss/(.*) root:disk 0660 =cciss/%1
113+
ida!(.*) root:disk 0660 =ida/%1
114+
ida/(.*) root:disk 0660 =ida/%1
115+
rd!(.*) root:disk 0660 =rd/%1
116+
rd/(.*) root:disk 0660 =rd/%1
117+
118+
sr0 root:cdrom 0660 @ln -sf $MDEV cdrom
119+
120+
# xen stuff
121+
xvd[a-z] root:root 0660 */lib/mdev/xvd_links
122+
123+
# fallback for any!device -> any/device
124+
(.*)!(.*) root:root 0660 =%1/%2

mdev/dvbdev

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0
4+
ADAPTER=${MDEV%.*}
5+
N=${ADAPTER#dvb}
6+
# MDEV=dvb0.demux1 -> DEVB_DEV=demux1
7+
DVB_DEV=${MDEV#*.}
8+
9+
case "$ACTION" in
10+
add|"")
11+
mkdir -p dvb/adapter${N}
12+
mv ${MDEV} dvb/adapter${N}/${DVB_DEV}
13+
;;
14+
remove)
15+
rm -f dvb/adapter${N}/${DVB_DEV}
16+
rmdir dvb/adapter${N} 2>/dev/null
17+
rmdir dvb/ 2>/dev/null
18+
esac

mdev/ide_links

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
[ -f /proc/ide/$MDEV/media ] || exit
4+
5+
media=`cat /proc/ide/$MDEV/media`
6+
for i in $media $media[0-9]* ; do
7+
if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then
8+
LINK=$i
9+
break
10+
fi
11+
done
12+
13+
# link exist, remove if necessary and exit
14+
if [ "$LINK" ] ; then
15+
[ "$ACTION" = remove ] && rm $LINK
16+
exit
17+
fi
18+
19+
# create a link
20+
num=`ls $media[0-9]* 2>/dev/null | wc -l`
21+
ln -sf $MDEV "$media`echo $num`"
22+
[ -e "$media" ] || ln -sf $MDEV "$media"
23+

mdev/usbdev

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# mdev -s will not set SUBSYSTEM or DEVNAME so we trigger a hotplug event
4+
if [ "$SUBSYSTEM" != "usb" ] || [ "$DEVTYPE" != "usb_device" ]; then
5+
uev=/sys/bus/usb/devices/$MDEV/uevent
6+
[ -e "$uev" ] && echo "add" > "$uev"
7+
exit
8+
fi
9+
10+
[ -n "$DEVNAME" ] || exit
11+
12+
case "$ACTION" in
13+
add)
14+
mkdir -p "${DEVNAME%/*}"
15+
mv $MDEV $DEVNAME
16+
# autoload driver
17+
for i in /sys/$DEVPATH/*/modalias; do
18+
[ -e "$i" ] && echo $i
19+
done | xargs sort -u | xargs modprobe -a 2>/dev/null
20+
;;
21+
remove)
22+
rm $DEVNAME
23+
;;
24+
esac
25+

mdev/usbdisk_link

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars.
4+
5+
current=$(readlink usbdisk)
6+
7+
if [ "$current" = "$MDEV" ] && [ "$ACTION" = "remove" ]; then
8+
rm -f usbdisk usba1
9+
fi
10+
[ -n "$current" ] && exit
11+
12+
if [ -e /sys/block/$MDEV ]; then
13+
SYSDEV=$(readlink -f /sys/block/$MDEV/device)
14+
# if /sys device path contains '/usb[0-9]' then we assume its usb
15+
# also, if its an usb without partitions we require FAT
16+
if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then
17+
# do not create link if there is not FAT
18+
dd if=/dev/$MDEV bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0
19+
20+
ln -sf $MDEV usbdisk
21+
# keep this for compat. people have it in fstab
22+
ln -sf $MDEV usba1
23+
fi
24+
25+
elif [ -e /sys/block/*/$MDEV ] ; then
26+
PARENT=$(dirname /sys/block/*/$MDEV)
27+
SYSDEV=$(readlink -f $PARENT/device)
28+
if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then
29+
ln -sf $MDEV usbdisk
30+
# keep this for compat. people have it in fstab
31+
ln -sf $MDEV usba1
32+
fi
33+
fi
34+

mdev/xvd_links

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
[ -f /sys/block/$MDEV/capability ] || exit
4+
5+
caps="0x`cat /sys/block/$MDEV/capability`"
6+
7+
if [ $(($caps & 8)) -gt 0 ]; then
8+
case $ACTION in
9+
add|"") ln -sf $MDEV cdrom ;;
10+
remove) [ "`readlink cdrom 2>/dev/null`" = $MDEV ] && rm -f cdrom ;;
11+
esac
12+
fi

0 commit comments

Comments
 (0)