chiark / gitweb /
[PATCH] fix up the wait_for_sysfs_test script a bit.
[elogind.git] / test / wait_for_sysfs_test.sh
1 #! /bin/bash
2 #
3
4 # Check for missing binaries (stale symlinks should not happen)
5 UDEV_BIN=../wait_for_sysfs
6 test -x $UDEV_BIN || exit 5
7
8 # Directory where sysfs is mounted
9 SYSFS_DIR=/sys
10
11 run_udev () {
12         # handle block devices and their partitions
13         for i in ${SYSFS_DIR}/block/*; do
14                 # add each drive
15                 export DEVPATH=${i#${SYSFS_DIR}}
16                 $UDEV_BIN block
17
18                 # add each partition, on each device
19                 for j in $i/*; do
20                         if [ -f $j/dev ]; then
21                                 export DEVPATH=${j#${SYSFS_DIR}}
22                                 $UDEV_BIN block
23                         fi
24                 done
25         done
26         # all other device classes
27         for i in ${SYSFS_DIR}/class/*; do
28                 # try adding empty classes, just to test stuff...
29                 export DEVPATH=${i#${SYSFS_DIR}}
30                 CLASS=`echo ${i#${SYSFS_DIR}} | cut --delimiter='/' --fields=3-`
31                 $UDEV_BIN $CLASS
32
33                 for j in `ls $i/`; do
34                         x=$i/$j
35                         export DEVPATH=${x#${SYSFS_DIR}}
36                         CLASS=`echo ${i#${SYSFS_DIR}} | \
37                                 cut --delimiter='/' --fields=3-`
38                         $UDEV_BIN $CLASS
39                 done
40         done
41 }
42
43 export ACTION=add
44 run_udev