summaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorPS <p@0x53.net>2026-02-01 12:10:12 +0100
committerPS <p@0x53.net>2026-02-01 12:10:12 +0100
commit049d80ae0e2b5f6370411207ed27fe423f5ff451 (patch)
tree4cdb7da70fff54ef52bd1d0a496d112b9ab19b2c /src/bin
downloadmdevd-conf-049d80ae0e2b5f6370411207ed27fe423f5ff451.tar.gz
mdevd-conf-049d80ae0e2b5f6370411207ed27fe423f5ff451.tar.bz2
mdevd-conf-049d80ae0e2b5f6370411207ed27fe423f5ff451.zip
version 0.1.0.0
Diffstat (limited to 'src/bin')
-rwxr-xr-xsrc/bin/mddc-add-block-sym80
-rwxr-xr-xsrc/bin/mddc-del-block-sym14
2 files changed, 94 insertions, 0 deletions
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}