summaryrefslogtreecommitdiff
path: root/system/mdevd
diff options
context:
space:
mode:
Diffstat (limited to 'system/mdevd')
-rw-r--r--system/mdevd/APKBUILD50
-rw-r--r--system/mdevd/mdev.conf77
-rw-r--r--system/mdevd/mdevd.initd39
-rw-r--r--system/mdevd/mdevd.run3
4 files changed, 169 insertions, 0 deletions
diff --git a/system/mdevd/APKBUILD b/system/mdevd/APKBUILD
new file mode 100644
index 000000000..b4ef7fa4e
--- /dev/null
+++ b/system/mdevd/APKBUILD
@@ -0,0 +1,50 @@
+# Contributor: Laurent Bercot <ska-adelie@skarnet.org>
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=mdevd
+pkgver=0.1.7.0
+pkgrel=0
+pkgdesc="A small uevent manager daemon"
+url="https://skarnet.org/software/mdevd/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+_skalibs_version=2.14.4
+makedepends="skalibs-dev>=$_skalibs_version"
+subpackages="$pkgname-doc $pkgname-openrc"
+source="https://skarnet.org/software/$pkgname/$pkgname-$pkgver.tar.gz mdev.conf mdevd.run mdevd.initd"
+
+build() {
+ ./configure \
+ --enable-allstatic \
+ --with-pkgconfig \
+ --enable-pkgconfig \
+ --enable-static-libc
+ make
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+ mkdir -p -m 0755 "$pkgdir/etc/init.d" "$pkgdir/usr/share/doc"
+ cp -f "$srcdir/mdev.conf" "$pkgdir/etc/"
+ chmod 0644 "$pkgdir/etc/mdev.conf"
+ cp -f "$srcdir/mdevd.initd" "$pkgdir/etc/init.d/mdevd"
+ chmod 0755 "$pkgdir/etc/init.d/mdevd"
+ cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
+}
+
+openrc() {
+ rldir="$subpkgdir"/etc/runlevels/sysinit
+ svcdir="$subpkgdir/etc/s6-linux-init/current/run-image/service/mdevd"
+ default_openrc
+ mkdir -p "$rldir" "$svcdir"
+ cp -f "$srcdir/mdevd.run" "$svcdir/run"
+ chmod 0755 "$svcdir/run"
+ echo 3 > "$svcdir/notification-fd"
+ touch "$svcdir/down"
+ ln -s ../../init.d/mdevd "$rldir/mdevd"
+}
+
+sha512sums="b50750afbba81c5168348acc2b38ba28abe0ac19bf4ea49c04f68eec1269a079642bccbed0acb1ef5da4848aea20c5f71c2711945eb2218ab79d570ffecdce57 mdevd-0.1.7.0.tar.gz
+f966d66366eac3b9b9eeb9b8523ea0924ada2b858c85ca0c0151d0fb374dfbf56c49ec2210d2d5ca19aa4d9f24371c85d777050eb8bf9f57821ec65704f18717 mdev.conf
+427a5903fa2126060955dcce8144d59255a679c4973f2dbc3145a4d646e879fc241ebcaa53289498719d343c746fc376c41defa87932dcbe91192b2d6f4ed1c4 mdevd.run
+afda8cb4fbf3125367b67df713b51a1de4fea9e444580bcf7e0056a236f7a1b72b64f1b3feabe9aff308d46ff04b2f2711e64fada305eea4290080017c8a72fe mdevd.initd"
diff --git a/system/mdevd/mdev.conf b/system/mdevd/mdev.conf
new file mode 100644
index 000000000..8f5a262a5
--- /dev/null
+++ b/system/mdevd/mdev.conf
@@ -0,0 +1,77 @@
+# Thanks to Piotr Karbowski for mdev-like-a-boss.
+# TODO: audit the helpers and adapt them to Adélie
+
+$MODALIAS=.* 0:0 0600 @modprobe -b "$MODALIAS"
+
+console 0:0 0600
+null 0:0 0666
+urandom 0:0 0666
+random 0:0 0444
+kmem 0:0 0000
+zero 0:0 0444
+full 0:0 0222
+ptmx 0:0 0666
+pty.* 0:0 0600
+fuse 0:0 0666
+
+mem root:kmem 0640
+ptmx root:tty 0666
+
+# Typical devices
+tty root:tty 0666
+tty[0-9]* root:tty 0660
+vcs* root:tty 0660
+ttyS[0-9]* root:dialout 0660
+
+# block devices
+ram([0-9]*) root:disk 0660
+loop([0-9]+) root:disk 0660
+fd[0-9]* root:floppy 0660
+sd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+vd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+hd[a-z].* root:disk 0660 # */opt/mdev/helpers/storage-device
+md[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+dm-[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+bcache[0-9]* root:disk 0660 # */opt/mdev/helpers/storage-device
+mmcblk[0-9].* root:disk 0660 # */opt/mdev/helpers/storage-device
+sr[0-9]* root:cdrom 0660 # +ln -sf $MDEV cdrom
+
+# Run settle-nics every time new NIC appear.
+# If you don't want to auto-populate /etc/mactab with NICs, run 'settle-nics' without '--write-mactab' param.
+# -SUBSYSTEM=net;DEVPATH=.*/net/.*;.* root:root 600 @/opt/mdev/helpers/settle-nics --write-mactab
+
+net/tun[0-9]* root:kvm 0660
+net/tap[0-9]* root:root 0600
+
+# alsa sound devices and audio stuff
+SUBSYSTEM=sound;.* root:audio 0660 # @/opt/mdev/helpers/sound-control
+
+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/
+
+
+# raid controllers
+cciss!(.*) root:disk 0660 =cciss/%1
+ida!(.*) root:disk 0660 =ida/%1
+rd!(.*) root:disk 0660 =rd/%1
+
+agpgart root:root 0660 # >misc/
+psaux root:root 0660 # >misc/
+rtc[0-9]* root:root 0600 # +ln -sf $MDEV rtc
+
+# input stuff
+SUBSYSTEM=input;.* root:input 0660
+
+# v4l stuff
+vbi[0-9] root:video 660 >v4l/
+video[0-9] root:video 660 >v4l/
+
+# dvb stuff
+dvb.* root:video 660
+
+# drm etc
+card[0-9] root:video 0660 =dri/
+dri/.* root:video 0660
diff --git a/system/mdevd/mdevd.initd b/system/mdevd/mdevd.initd
new file mode 100644
index 000000000..1b55a3a84
--- /dev/null
+++ b/system/mdevd/mdevd.initd
@@ -0,0 +1,39 @@
+#!/sbin/openrc-run
+# Copyright 2019-2025 Adélie Linux
+
+description="mdevd manages device permissions and symbolic links in /dev"
+extra_started_commands="reload"
+description_reload="Reload the mdevd configuration file"
+
+depend()
+{
+ use modloop
+ need sysfs dev-mount
+ before checkfs fsck
+ keyword -lxc -systemd-nspawn -vserver
+ provide dev
+}
+
+stop()
+{
+ ebegin "Stopping mdevd"
+ s6-svc -D /run/service/mdevd
+ eend $?
+}
+
+start()
+{
+ ebegin "Starting mdevd"
+ s6-svc -UwU /run/service/mdevd
+ eend $?
+ ebegin "Coldplugging devices"
+ mdevd-coldplug -O4
+ eend $?
+}
+
+reload()
+{
+ ebegin "Reloading mdevd config file"
+ s6-svc -h /run/service/mdevd
+ eend $?
+}
diff --git a/system/mdevd/mdevd.run b/system/mdevd/mdevd.run
new file mode 100644
index 000000000..f4468fcf2
--- /dev/null
+++ b/system/mdevd/mdevd.run
@@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+
+mdevd -D3 -O4