From 049d80ae0e2b5f6370411207ed27fe423f5ff451 Mon Sep 17 00:00:00 2001 From: PS
Date: Sun, 1 Feb 2026 12:10:12 +0100 Subject: version 0.1.0.0 --- src/bin/mddc-add-block-sym | 80 ++++++++++++++++++++++++++++++++++++++++++++++ src/bin/mddc-del-block-sym | 14 ++++++++ src/lib/etc/mdev.conf | 32 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100755 src/bin/mddc-add-block-sym create mode 100755 src/bin/mddc-del-block-sym create mode 100644 src/lib/etc/mdev.conf (limited to 'src') diff --git a/src/bin/mddc-add-block-sym b/src/bin/mddc-add-block-sym new file mode 100755 index 0000000..7ee1eca --- /dev/null +++ b/src/bin/mddc-add-block-sym @@ -0,0 +1,80 @@ +#!@shebangdir@/execlineb -P + +importas -Si MDEV + +if -x0 { eltest -d /sys/block/${MDEV} } + +#skip cryptsetup nodes +if -nx0 { eltest ${MDEV} =~ dm-[0-9] } + +background { mkdir -p /dev/disk/by-diskseq } +background { mkdir -p /dev/disk/by-partuuid } +background { mkdir -p /dev/disk/by-uuid } +background { mkdir -p /dev/disk/by-id } +#background { mkdir -p /dev/disk/by-path } + +backtick -Ei DISKSEQ { cat /sys/block/${MDEV}/diskseq } +background { ln -sf ../../${MDEV} /dev/disk/by-diskseq/${DISKSEQ} } + +pipeline { if { eltest -e /sys/block/${MDEV}/device/model } cat /sys/block/${MDEV}/device/model } +pipeline { sed -e s/\ *$// -e s/\ /_/g } +withstdinas -ED "" MODEL +pipeline { if { eltest -e /sys/block/${MDEV}/device/serial } cat /sys/block/${MDEV}/device/serial } +pipeline { sed -e s/\ *$// -e s/\ /_/g -e s/^/_/g } +withstdinas -ED "" SERIAL +background { if { eltest "${MODEL}${SERIAL}" } + ln -sf ../../${MDEV} /dev/disk/by-id/${MODEL}${SERIAL} +} + +execline-cd /sys/block/${MDEV} + +elglob -0d "" PARTS ${MDEV}* +if { eltest ${PARTS} } +define -sd "" SPARTS ${PARTS} +forx -pE PART { ${SPARTS} } + # by-partuuid + background { + pipeline { grep -- ^PARTUUID= ${PART}/uevent } + pipeline { sed -e s/PARTUUID=// } + withstdinas -E PARTUUID + ln -sf ../../${PART} /dev/disk/by-partuuid/${PARTUUID} + } + # by-diskseq, by-id + background { + backtick -Ei PARTN { cat ${PART}/partition } + background { ln -sf ../../${PART} /dev/disk/by-diskseq/${DISKSEQ}-part${PARTN} } + if { eltest "${MODEL}${SERIAL}" } + ln -sf ../../${PART} /dev/disk/by-id/${MODEL}${SERIAL}-part${PARTN} + } + # only if blkid exists + if { redirfd -w 1 /dev/null tryexec { blkid } exit 1 } + # by-uuid + background { + if { + pipeline { blkid /dev/${PART} } + pipeline { grep " UUID" } + pipeline { + sed + -e s/^.*\ UUID=\"// + -e s/\".*// + } + withstdinas -E UUID + if { eltest ${UUID} } + ln -sf ../../${PART} /dev/disk/by-uuid/${UUID} + } + } + # by-label + background { + if { + pipeline { blkid /dev/${PART} } + pipeline { grep " LABEL" } + pipeline { + sed + -e s/^.*\ LABEL=\"// + -e s/\".*// + } + withstdinas -E LABEL + if { eltest ${LABEL} } + ln -sf ../../${PART} /dev/disk/by-label/${LABEL} + } + } diff --git a/src/bin/mddc-del-block-sym b/src/bin/mddc-del-block-sym new file mode 100755 index 0000000..caa4ce9 --- /dev/null +++ b/src/bin/mddc-del-block-sym @@ -0,0 +1,14 @@ +#!@shebangdir@/execlineb -P + +importas -Si MDEV + +if -x0 { eltest -d /sys/block/${MDEV} } +if -x0 { eltest -d /dev/disk } + +pipeline { ls -1 /dev/disk } +forstdin -pE TYPE + pipeline { ls -1 /dev/disk/${TYPE} } + forstdin -pE SYM + backtick -E RPATH { realpath /dev/disk/${TYPE}/${SYM} } + if { eltest ${RPATH} =~ /dev/${MDEV}.* } + rm -f /dev/disk/${TYPE}/${SYM} diff --git a/src/lib/etc/mdev.conf b/src/lib/etc/mdev.conf new file mode 100644 index 0000000..cb71b25 --- /dev/null +++ b/src/lib/etc/mdev.conf @@ -0,0 +1,32 @@ +# mdevd-conf +# null, zero may already exist; therefore ownership has to be changed with command +null root:root 666 +importas -S MDEV chmod 666 $MDEV +zero root:root 666 +importas -S MDEV chmod 666 $MDEV +urandom root:root 666 +random root:root 666 +full root:root 666 +fuse root:root 666 + +# console may already exist; therefore ownership has to be changed with command +console root:tty 600 +importas -S MDEV chmod 600 $MDEV +tty root:tty 666 +ttyS.* root:dialout 660 +tty.* root:tty 620 +ptmx root:tty 666 + +snd/.* root:audio 660 + +uinput root:input 660 +input/.* root:input 660 +bus/usb/.*/.* root:usb 660 + +mem root:kmem 640 +kmem root:kmem 640 +port root:kmem 640 + +dri/card.* root:video 660 +dri/render.* root:render 666 + +kfd root:render 666 +-SUBSYSTEM=block;.* root:disk 660 +mddc-add-block-sym +SUBSYSTEM=block;.* root:disk 660 -mddc-del-block-sym -- cgit v1.2.3