diff options
| -rw-r--r-- | meta/recipes-core/udev/udev/init | 54 | ||||
| -rw-r--r-- | meta/recipes-core/udev/udev/udev-cache | 6 |
2 files changed, 38 insertions, 22 deletions
diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init index 426e4dbb19..d90d4468e4 100644 --- a/meta/recipes-core/udev/udev/init +++ b/meta/recipes-core/udev/udev/init | |||
| @@ -18,15 +18,17 @@ export TZ=/etc/localtime | |||
| 18 | [ -x @UDEVD@ ] || exit 1 | 18 | [ -x @UDEVD@ ] || exit 1 |
| 19 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache | 19 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache |
| 20 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf | 20 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf |
| 21 | [ -f /etc/default/rcS ] && . /etc/default/rcS | ||
| 21 | 22 | ||
| 22 | readfile () { | 23 | readfiles () { |
| 23 | filename=$1 | ||
| 24 | READDATA="" | 24 | READDATA="" |
| 25 | if [ -r $filename ]; then | 25 | for filename in $@; do |
| 26 | while read line; do | 26 | if [ -r $filename ]; then |
| 27 | READDATA="$READDATA$line" | 27 | while read line; do |
| 28 | done < $filename | 28 | READDATA="$READDATA$line" |
| 29 | fi | 29 | done < $filename |
| 30 | fi | ||
| 31 | done | ||
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | case "$1" in | 34 | case "$1" in |
| @@ -52,29 +54,37 @@ case "$1" in | |||
| 52 | mount -a -t tmpfs 2>/dev/null | 54 | mount -a -t tmpfs 2>/dev/null |
| 53 | mkdir -p /var/volatile/tmp | 55 | mkdir -p /var/volatile/tmp |
| 54 | 56 | ||
| 55 | # cache handling | 57 | # Cache handling. |
| 58 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. | ||
| 59 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags" | ||
| 56 | if [ "$DEVCACHE" != "" ]; then | 60 | if [ "$DEVCACHE" != "" ]; then |
| 57 | readfile /proc/version | ||
| 58 | VERSION="$READDATA" | ||
| 59 | readfile /proc/cmdline | ||
| 60 | CMDLINE="$READDATA" | ||
| 61 | readfile /proc/devices | ||
| 62 | DEVICES="$READDATA" | ||
| 63 | readfile /proc/atags | ||
| 64 | ATAGS="$READDATA" | ||
| 65 | |||
| 66 | if [ -e $DEVCACHE ]; then | 61 | if [ -e $DEVCACHE ]; then |
| 67 | readfile /etc/udev/cache.data | 62 | readfiles $CMP_FILE_LIST |
| 68 | if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then | 63 | NEWDATA="$READDATA" |
| 64 | readfiles /etc/udev/cache.data | ||
| 65 | OLDDATA="$READDATA" | ||
| 66 | if [ "$OLDDATA" = "$NEWDATA" ]; then | ||
| 69 | (cd /; tar xf $DEVCACHE > /dev/null 2>&1) | 67 | (cd /; tar xf $DEVCACHE > /dev/null 2>&1) |
| 70 | not_first_boot=1 | 68 | not_first_boot=1 |
| 71 | [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" | 69 | [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" |
| 72 | [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache | 70 | [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache |
| 73 | else | 71 | else |
| 74 | echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache | 72 | # Output detailed reason why the cached /dev is not used |
| 73 | if [ "$VERBOSE" != "no" ]; then | ||
| 74 | echo "udev: udev cache not used" | ||
| 75 | echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued" | ||
| 76 | echo "udev: olddata: $OLDDATA" | ||
| 77 | echo "udev: newdata: $NEWDATA" | ||
| 78 | fi | ||
| 79 | echo "$NEWDATA" > /dev/shm/udev.cache | ||
| 75 | fi | 80 | fi |
| 76 | else | 81 | else |
| 77 | echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache | 82 | if [ "$ROOTFS_READ_ONLY" != "yes" ]; then |
| 83 | # If rootfs is not read-only, it's possible that a new udev cache would be generated; | ||
| 84 | # otherwise, we do not bother to read files. | ||
| 85 | readfiles $CMP_FILE_LIST | ||
| 86 | echo "$READDATA" > /dev/shm/udev.cache | ||
| 87 | fi | ||
| 78 | fi | 88 | fi |
| 79 | fi | 89 | fi |
| 80 | 90 | ||
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache index 8a84fa9dc8..db5a513e14 100644 --- a/meta/recipes-core/udev/udev/udev-cache +++ b/meta/recipes-core/udev/udev/udev-cache | |||
| @@ -15,8 +15,14 @@ export TZ=/etc/localtime | |||
| 15 | [ -x @UDEVD@ ] || exit 1 | 15 | [ -x @UDEVD@ ] || exit 1 |
| 16 | [ -d /sys/class ] || exit 1 | 16 | [ -d /sys/class ] || exit 1 |
| 17 | 17 | ||
| 18 | [ -f /etc/default/rcS ] && . /etc/default/rcS | ||
| 18 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache | 19 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache |
| 19 | 20 | ||
| 21 | if [ "$ROOTFS_READ_ONLY" = "yes" ]; then | ||
| 22 | [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache" | ||
| 23 | exit 0 | ||
| 24 | fi | ||
| 25 | |||
| 20 | if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then | 26 | if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then |
| 21 | echo "Populating dev cache" | 27 | echo "Populating dev cache" |
| 22 | (cd /; tar cf "$DEVCACHE" dev) | 28 | (cd /; tar cf "$DEVCACHE" dev) |
