mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
> But the test.block script doesn't catch any partitions on the block
> devices :)
Never happy!
[19:07:52]root@phantasy:~/src/udev/udev# ./test.block
[19:13:37]root@phantasy:~/src/udev/udev# ls /udev/hd*
ls: /udev/hd*: No such file or directory
[19:13:42]root@phantasy:~/src/udev/udev# ./test.block
[19:13:53]root@phantasy:~/src/udev/udev# ls /udev/hd*
/udev/hda /udev/hda2 /udev/hda4 /udev/hda6 /udev/hdd
/udev/hda1 /udev/hda3 /udev/hda5 /udev/hdc
test.block now recurses /sys/block, looking for partitions. Should add
all drives and all partitions.
23 lines
531 B
Bash
23 lines
531 B
Bash
#! /bin/sh
|
|
#
|
|
# test.block - run udev(8) on each block device in /sys/block
|
|
|
|
SYSFSDIR=/sys # change this for a nonstand sysfs mount point
|
|
BIN=./udev # location of your udev binary
|
|
export ACTION=add # 'add' or 'remove'
|
|
|
|
for i in ${SYSFSDIR}/block/*; do
|
|
# add each drive
|
|
export DEVPATH="/"`echo $i | cut --delimiter='/' --fields=3-`
|
|
$BIN block
|
|
|
|
# add each partition, on each device
|
|
for j in $i/*; do
|
|
if [ -f $j/dev ]; then
|
|
export DEVPATH="/"`echo $j | \
|
|
cut --delimiter='/' --fields=3-`
|
|
$BIN block
|
|
fi
|
|
done
|
|
done
|