initscripts: improve the way it handles volatile storage
cover initscripts: improve the way it handles volatile storage
From: Chen Qi <[email protected]>
The following changes since commit e421e95de0ce430cc2c6db9b0712a66ab96288a1:
gnome-desktop: Now we depend on gnome-common-native, use the correct sysroot (2012-11-02 16:18:32 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/initscripts
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/initscripts
Chen Qi (1):
initscripts: improve the way initscripts handle volatile storage
.../initscripts/initscripts-1.0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.0/volatiles | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/1 initscripts: improve the way initscripts handle volatile storage
From: Chen Qi <[email protected]>
Change the way how populate_volatile.sh handles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.
This patch makes populate_volatile.sh do things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.
Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in bootmisc.sh should also be done by populate_volatile.sh.
[YOCTO #3404]
--- .../initscripts/initscripts-1.0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.0/volatiles | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -7
@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +13 -15
@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" - - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build - - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\"; + fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile. + eval $EXEC & } check_requirements() {
@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." - [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." - link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." + link_file "${TSOURCE}" "${TNAME}" & continue }
meta/recipes-core/initscripts/initscripts-1.0/volatiles +1 -0
@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp none
meta/recipes-core/initscripts/initscripts_1.0.bb +1 -1
@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic system startup initialization scrip SECTION = "base" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" -PR = "r137" +PR = "r138" INHIBIT_DEFAULT_DEPS = "1"
Signature · 1 line
1.7.9.5
Re: [PATCH 1/1] initscripts: improve the way initscripts handle volatile storage
Quoted 63 lines · On 11/12/2012 03:33 AM, [email protected] wrote:
From: Chen Qi <[email protected]>
Change the way how
populate_volatile.shhandles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.This patch makes
populate_volatile.shdo things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in
bootmisc.shshould also be done bypopulate_volatile.sh.[YOCTO #3404]
Signed-off-by Chen Qi <[email protected]>--- .../initscripts/initscripts-1.0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.0/volatiles | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0
-7@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-8@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" - - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build - - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC &
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh mk_dir() { · line 58
Quoted 10 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +9
-1- } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\"; + fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.
I wonder if we should be testing /etc for writablity here first? We need to make sure we respect the possibility that the root filesystem with read-only.
Sau!
Quoted 54 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +4
-6+ eval $EXEC & } check_requirements() {@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." - [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." - link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." + link_file "${TSOURCE}" "${TNAME}" & continue }meta/recipes-core/initscripts/initscripts-1.0/volatiles +1
-0@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp nonemeta/recipes-core/initscripts/initscripts_1.0.bb +1
-1@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic system startup initialization scrip SECTION = "base" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" -PR = "r137" +PR = "r138" INHIBIT_DEFAULT_DEPS = "1"
Re: [PATCH 1/1] initscripts: improve the way initscripts handle volatile storage
Quoted 79 lines · Saul Wold
Quoted 77 lines · On 11/12/2012 03:33 AM, [email protected] wrote:
From: Chen Qi <[email protected]>
Change the way how
populate_volatile.shhandles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.This patch makes
populate_volatile.shdo things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in
bootmisc.shshould also be done bypopulate_volatile.sh.[YOCTO #3404]
Signed-off-by Chen Qi <[email protected]>--- .../initscripts/initscripts-1.**0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-**volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.**0/volatiles | 1 + meta/recipes-core/initscripts/**initscripts_1.0.bb<http://initscripts_1.0.bb> | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)meta/recipes-core/**initscripts/initscripts-1.0/**bootmisc.sh +0
-7@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-1--- a/meta/recipes-core/**initscripts/initscripts-1.0/**
populate-volatile.sh
+++ b/meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.shmeta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-1@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty02>&1"
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-2- - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>
/etc/volatile.cache.buildmeta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +6
-6- - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\";
Quoted 8 lines
Quoted 5 lines
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +3
-0+ fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>
/etc/volatile.I wonder if we should be testing /etc for writablity here first? We need to make sure we respect the possibility that the root filesystem with read-only.
I'd say we ought to test for it and print an error if the cache is enabled and etc is not writable.
Quoted 68 lines
+ eval $EXEC &
Quoted 58 lines
} check_requirements() {meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-1@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\\(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-3- [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-2- link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-0+ link_file "${TSOURCE}" "${TNAME}" & continue }meta/recipes-core/**initscripts/initscripts-1.0/**volatiles +1
-0@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp none(quoted diff) +0
-0**initscripts/initscripts_1.0.bb
index d25838b..251dd06 100644meta/recipes-core/**initscripts/initscripts_1.0.bb +0
-0@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic systemstartup initialization scrip
SECTION = "base"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM= "file://COPYING;md5=**751419260aa954499f7abaabaa882b
**be"meta/recipes-core/**initscripts/initscripts_1.0.bb
Quoted 4 lines
meta/recipes-core/**initscripts/initscripts_1.0.bb +1
-1-PR = "r137" +PR = "r138" INHIBIT_DEFAULT_DEPS = "1"______________________________**_________________
Openembedded-core mailing list Openembedded-core@lists.**openembedded.org<[email protected]>
http://lists.linuxtogo.org/**cgi-bin/mailman/listinfo/**openembedded-core<http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core>
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
Re: [PATCH 1/1] initscripts: improve the way initscripts handle volatile storage
In reply to Saul WoldQuoted 138 lines · Saul Wold
Quoted 76 lines · On 11/12/2012 03:33 AM, [email protected] wrote:
From: Chen Qi <[email protected]>
Change the way how
populate_volatile.shhandles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.This patch makes
populate_volatile.shdo things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in
bootmisc.shshould also be done bypopulate_volatile.sh.[YOCTO #3404]
Signed-off-by Chen Qi <[email protected]>--- .../initscripts/initscripts-1.0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.0/volatiles | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0
-7@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-1@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty02>&1"
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-2- - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>
/etc/volatile.cache.buildmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +9
-6- - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\"; + fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>Quoted 1 line
/etc/volatile.I wonder if we should be testing /etc for writablity here first? We need to make sure we respect the possibility that the root filesystem with read-only.
Sau!
Quoted 56 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +2
-1+ eval $EXEC & } check_requirements() {@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\\(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-3- [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1
-2- link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1
-0+ link_file "${TSOURCE}" "${TNAME}" & continue }meta/recipes-core/initscripts/initscripts-1.0/volatiles +1
-0@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp nonemeta/recipes-core/initscripts/initscripts_1.0.bb +0
-0@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic systemstartup initialization scrip
SECTION = "base"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM=
"file://COPYING;md5=751419260aa954499f7abaabaa882bbe"meta/recipes-core/initscripts/initscripts_1.0.bb +1
-1-PR = "r137" +PR = "r138"
Quoted 4 lines
Quoted 3 lines
INHIBIT_DEFAULT_DEPS= "1"
Hi Saul:
Good point! I did miss that.
However, after a second thinking, I think we probably don't need to change it. Here's my reasons.
1. No matter rootfs is read-only or writable, this script would work correctly. This is because it will first check whether '/etc/volatile.cache' exists before using it. (Of course, this is based on the assumption that users don't change /etc/volatile.cache manually.)
2. There are some other initscripts that assume rootfs to be writable, for example, udev-cache, bootmisc.sh, avahi-daemon, rmnologin.sh, save-rtc.sh. They have 'mkdir', 'cp' or 'mv' operation on /etc without checking whether rootfs is read-only.
Cheers,
Chen Qi
Re: [PATCH 1/1] initscripts: improve the way initscripts handle volatile storage
In reply to Saul WoldQuoted 138 lines · Saul Wold
Quoted 76 lines · On 11/12/2012 03:33 AM, [email protected] wrote:
From: Chen Qi <[email protected]>
Change the way how
populate_volatile.shhandles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.This patch makes
populate_volatile.shdo things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in
bootmisc.shshould also be done bypopulate_volatile.sh.[YOCTO #3404]
Signed-off-by Chen Qi <[email protected]>--- .../initscripts/initscripts-1.0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.0/volatiles | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0
-7@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-1@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty02>&1"
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-2- - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>
/etc/volatile.cache.buildmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +9
-6- - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\"; + fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>Quoted 1 line
/etc/volatile.I wonder if we should be testing /etc for writablity here first? We need to make sure we respect the possibility that the root filesystem with read-only.
Sau!
Quoted 56 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +2
-1+ eval $EXEC & } check_requirements() {@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\\(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0
-3- [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1
-2- link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1
-0+ link_file "${TSOURCE}" "${TNAME}" & continue }meta/recipes-core/initscripts/initscripts-1.0/volatiles +1
-0@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp nonemeta/recipes-core/initscripts/initscripts_1.0.bb +0
-0@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic systemstartup initialization scrip
SECTION = "base"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM=
"file://COPYING;md5=751419260aa954499f7abaabaa882bbe"meta/recipes-core/initscripts/initscripts_1.0.bb +1
-1-PR = "r137" +PR = "r138"
Quoted 4 lines
Quoted 3 lines
INHIBIT_DEFAULT_DEPS= "1"
Hi Saul:
After looking at bug#3406 and bug#3407, I realize that it is much more complex than I thought to make this script work on a read-only rootfs. After all, if the rootfs is read-only, we cannot delete things like /tmp, /var/run and so on.
Besides, as I mentioned in the last email, there are some other initscripts that assume rootfs to be writable. So as far as I can see, support for read-only rootfs would not be trivial.
Cheers,
Chen Qi
Re: [PATCH 1/1] initscripts: improve the way initscripts handle volatile storage
Quoted 157 lines · ChenQi
Quoted 149 lines · Saul Wold
Quoted 80 lines · On 11/12/2012 03:33 AM, [email protected] wrote:
From: Chen Qi <[email protected]>
Change the way how
populate_volatile.shhandles link-type config items. Previously, if a link-type config item is encountered, the script does not handle it correctly. If the target exists as a link, the config item is skipped no matter where the target actually points. If the target exists as a file or a directory, it does nothing. This behavious is sometimes confusing; for example, if /run has been created by other recipes, it will not be updated to a symlink as the config file states.This patch makes
populate_volatile.shdo things as the config file tells it. As for link-type config items, it creates them properly with an effort to avoid data loss.Besides, it's not appropriate to divide volatile storage handling into two files. Operations for /tmp directory in
bootmisc.shshould also be done bypopulate_volatile.sh.[YOCTO #3404]
Signed-off-by Chen Qi <[email protected]>--- .../initscripts/initscripts-1.**0/bootmisc.sh | 7 ----- .../initscripts-1.0/populate-**volatile.sh | 28 +++++++++----------- .../initscripts/initscripts-1.**0/volatiles | 1 + meta/recipes-core/initscripts/**initscripts_1.0.bb<http://initscripts_1.0.bb> | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-)meta/recipes-core/**initscripts/initscripts-1.0/**bootmisc.sh +0
-7@@ -54,13 +54,6 @@ fi # # This is as good a place as any for a sanity check -# /tmp should be a symlink to /var/tmp to cut down on the number -# of mounted ramdisks. -if test ! -L /tmp && test -d /var/tmp -then - rm -rf /tmp - ln -sf /var/tmp /tmp -fi # Set the system clock from hardware clock # If the timestamp is more recent than the current time,meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-1--- a/meta/recipes-core/**initscripts/initscripts-1.0/**
populate-volatile.sh
+++ b/meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.shmeta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-1@@ -47,15 +47,16 @@ mk_dir() { } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty02>&1"
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-2- - test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>
/etc/volatile.cache.buildmeta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +9
-6- - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + EXEC=" + if [ -L \"$2\" ]; then + rm -f \"$2\"; + elif [ -d \"$2\" ]; then + cp -rf \"$2/*\" \"$1\"; + rm -rf \"$2\"; + fi; + ln -sf \"$1\" \"$2\" " + test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >>Quoted 2 lines
/etc/volatile.I wonder if we should be testing /etc for writablity here first? We need to make sure we respect the possibility that the root filesystem with read-only.
Sau!
+ eval $EXEC &
Quoted 58 lines
} check_requirements() {meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-1@@ -119,20 +120,17 @@ apply_cfgfile() { return 1 } - cat ${CFGFILE} | grep -v "^#" | \ + cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \ while read LINE; do eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\\(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +0
-3- [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-2- link_file "${TSOURCE}" "${TNAME}" & - } + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}-pointing to -${TSOURCE}-."
meta/recipes-core/**initscripts/initscripts-1.0/**populate-volatile.sh +1
-0+ link_file "${TSOURCE}" "${TNAME}" & continue }meta/recipes-core/**initscripts/initscripts-1.0/**volatiles +1
-0@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock l root root 0755 /var/log /var/volatile/log l root root 0755 /var/run /var/volatile/run l root root 1777 /var/tmp /var/volatile/tmp +l root root 1777 /tmp /var/tmp d root root 0755 /var/lock/subsys none f root root 0664 /var/log/wtmp none f root root 0664 /var/run/utmp none(quoted diff) +0
-0**initscripts/initscripts_1.0.bb
index d25838b..251dd06 100644meta/recipes-core/**initscripts/initscripts_1.0.bb +0
-0@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic systemstartup initialization scrip
SECTION = "base"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM= "file://COPYING;md5=**
751419260aa954499f7abaabaa882b**be"meta/recipes-core/**initscripts/initscripts_1.0.bb +1
-1-PR = "r137" +PR = "r138"Quoted 5 lines
Quoted 4 lines
INHIBIT_DEFAULT_DEPS= "1"Hi Saul:
Quoted 9 lines
After looking at bug#3406 and bug#3407, I realize that it is much more complex than I thought to make this script work on a read-only rootfs. After all, if the rootfs is read-only, we cannot delete things like /tmp,
/var/runand so on.Besides, as I mentioned in the last email, there are some other initscripts that assume rootfs to be writable. So as far as I can see, support for read-only rootfs would not be trivial.
I think it ought to ERROR in case it is not writable; and then work on a fix for it. In fact it doesn't work now so it ought to "document" it during boot and then a fix for it can be done.
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br