mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
udev-cache: refactor sysconf generation
The current system configuration needs to be generated both inside udev (to compare against the cached system configuration) and udev-cache (to regenerate the cached system configuration). Use a single function definition for this task, duplicated across both initscripts. This also allows administrators to modify it for machine-specific requirements. (From OE-Core rev: 34957afcfe663eed4f5ebec0891a84467e67a48d) Signed-off-by: Richard Tollerton <rich.tollerton@ni.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
c6e8f075a9
commit
0002d46e78
@@ -17,6 +17,16 @@ export TZ=/etc/localtime
|
|||||||
SYSCONF_CACHED="/etc/udev/cache.data"
|
SYSCONF_CACHED="/etc/udev/cache.data"
|
||||||
SYSCONF_TMP="/dev/shm/udev.cache"
|
SYSCONF_TMP="/dev/shm/udev.cache"
|
||||||
DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
|
DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
|
||||||
|
|
||||||
|
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
|
||||||
|
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
|
||||||
|
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
|
||||||
|
|
||||||
|
# Command to compute system configuration.
|
||||||
|
sysconf_cmd () {
|
||||||
|
cat -- $CMP_FILE_LIST
|
||||||
|
}
|
||||||
|
|
||||||
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
|
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
|
||||||
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
|
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
|
||||||
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
||||||
@@ -52,12 +62,9 @@ case "$1" in
|
|||||||
mkdir -m 1777 -p /var/volatile/tmp
|
mkdir -m 1777 -p /var/volatile/tmp
|
||||||
|
|
||||||
# Cache handling.
|
# Cache handling.
|
||||||
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
|
|
||||||
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
|
|
||||||
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
|
|
||||||
if [ "$DEVCACHE" != "" ]; then
|
if [ "$DEVCACHE" != "" ]; then
|
||||||
if [ -e $DEVCACHE ]; then
|
if [ -e $DEVCACHE ]; then
|
||||||
cat -- "$CMP_FILE_LIST" > "$SYSCONF_TMP"
|
sysconf_cmd > "$SYSCONF_TMP"
|
||||||
if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; then
|
if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; then
|
||||||
tar xmf $DEVCACHE -C / -m
|
tar xmf $DEVCACHE -C / -m
|
||||||
not_first_boot=1
|
not_first_boot=1
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
|
|||||||
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
|
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
|
||||||
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
|
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
|
||||||
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
|
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
|
||||||
|
|
||||||
|
# Command to compute system configuration.
|
||||||
|
sysconf_cmd () {
|
||||||
|
cat -- $CMP_FILE_LIST
|
||||||
|
}
|
||||||
|
|
||||||
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
|
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
|
||||||
|
|
||||||
if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
|
if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
|
||||||
@@ -34,7 +40,7 @@ fi
|
|||||||
if [ "$DEVCACHE" != "" -a -e "$DEVCACHE_REGEN" ]; then
|
if [ "$DEVCACHE" != "" -a -e "$DEVCACHE_REGEN" ]; then
|
||||||
echo "Populating dev cache"
|
echo "Populating dev cache"
|
||||||
udevadm control --stop-exec-queue
|
udevadm control --stop-exec-queue
|
||||||
cat -- $CMP_FILE_LIST > "$SYSCONF_TMP"
|
sysconf_cmd > "$SYSCONF_TMP"
|
||||||
find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
|
find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
|
||||||
| xargs tar cf "${DEVCACHE_TMP}" -T-
|
| xargs tar cf "${DEVCACHE_TMP}" -T-
|
||||||
gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"
|
gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"
|
||||||
|
|||||||
Reference in New Issue
Block a user