Skip to contentSkip to conversation

read-only rootfs support

PATCH In review [email protected] 5 participants 31 messages Jan 24, 2013 – Jan 28, 2013

lore
Share & tools
lore
#0 lore raw

cover read-only rootfs support

From: Chen Qi <[email protected]>

The series of patches add support to read-only rootfs.

The main idea is to use symbolic links to create the illuion that some directories are writable in case of a read-only rootfs.

We use a similar stragety to update-rc.d.bbclass to manage all the recipes that need to tweak some specific directories to support a read-only rootfs. These recipes inherit volatiles.bbclass and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS properly.

The advantage of this strategy is that it deligates the task of supporting read-only rootfs to the recipes, resulting in a better management scheme.

This set of patches have been tested on minimal images with and without 'read-only-rootfs' image feature enabled. Everything is OK.

For sato images, everything is the same as before if 'read-only-rootfs' is not enabled. With 'read-only-rootfs' enabled, sato image could work if graphic interface is diabled. When all postinstall problems are resolved, sato image should work well.

The following changes since commit 37e025f6f9c410005e0f1dee0767e38eaec01cbd:

bitbake: hob: Hob should display warnings generated during parsing (2013-01-21 19:05:31 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/readonly-rootfs
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/readonly-rootfs

Chen Qi (12):
sysvinit: add ROOTFS_READ_ONLY variable to rcS-default image.bbclass: add a hook funtion to support readonly rootfs core-image.bbclass: support read-only rootfs package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS volatiles.bbclass: add recipe volatiles_sysvinit.bbclass: add recipe populate-volatile.sh: improve this script
initscripts: let populate-volatile.sh create the /tmp link
initscripts: inherit volatiles to support read-only rootfs
dropbear: inherit volatiles to support read-only rootfs
nfs-utils: inherit volatiles to support read-only rootfs
dbus: inherit volatiles to support read-only rootfs

 meta/classes/core-image.bbclass                    |    4 +
 meta/classes/image.bbclass                         |   18 ++
 meta/classes/package.bbclass                       |    4 +-
 meta/classes/volatiles.bbclass                     |   11 +
 meta/classes/volatiles_sysvinit.bbclass            |   49 ++++
 .../nfs-utils/nfs-utils_1.2.3.bb                   |    7 +-
 meta/recipes-core/dbus/dbus.inc                    |    7 +-
 meta/recipes-core/dropbear/dropbear.inc            |    7 +-
 .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +-
 .../initscripts-1.0/populate-volatile.sh           |  287 ++++++++++----------
 .../initscripts/initscripts-1.0/volatiles          |    1 +
 meta/recipes-core/initscripts/initscripts_1.0.bb   |    6 +-
 meta/recipes-core/sysvinit/sysvinit/rcS-default    |    4 +
 meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb     |    2 +-
 14 files changed, 255 insertions(+), 161 deletions(-)
 create mode 100644 meta/classes/volatiles.bbclass
 create mode 100644 meta/classes/volatiles_sysvinit.bbclass
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/12 sysvinit: add ROOTFS_READ_ONLY variable to rcS-default

From: Chen Qi <[email protected]>

This variable indicates whether the rootfs is intended to be read-only or not. Changing this value from 'no' to 'yes' on a currently running system with read-write rootfs and rebooting will give the user a working system with read-only rootfs.

However, it is not suggested to change its value. Normally, if a read-only rootfs is required, we should build an image with 'read-only-rootfs' image feature.

[YOCTO #3406]

---
 meta/recipes-core/sysvinit/sysvinit/rcS-default |    4 ++++
 meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb  |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
meta/recipes-core/sysvinit/sysvinit/rcS-default +4 -0
index 3c9dea9..709cdf6 100644
@@ -23,3 +23,7 @@ FSCKFIX=yes
 #TICKADJ=10000
 # Enable caching in populate-volatile.sh
 VOLATILE_ENABLE_CACHE=yes
+# Indicate whether the rootfs is intended to be read-only or not.
+# Setting ROOTFS_READ_ONLY to yes and rebooting will give you a read-only rootfs.
+# Normally you should not change this value.
+ROOTFS_READ_ONLY=no
meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb +1 -1
index de073b8..bf6a29b 100644
@@ -5,7 +5,7 @@ SECTION = "base"
 LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe \
                     file://COPYRIGHT;endline=15;md5=349c872e0066155e1818b786938876a4"
-PR = "r9"
+PR = "r10"
 
 RDEPENDS_${PN} = "${PN}-inittab"
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/12 image.bbclass: add a hook funtion to support readonly rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

read_only_rootfs_hook: this funtion is invoked only if 'read-only-rootfs' is in IMAGE_FEATURES. It tweaks some basic files and makes populate- volatile.sh script run at rootfs time.

For now, it has real effect only if the init system is sysvinit.

[YOCTO #3406]

---
 meta/classes/image.bbclass |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
meta/classes/image.bbclass +18 -0
index 0293d2e..91045fc 100644
@@ -201,6 +201,24 @@ run_intercept_scriptlets () {
 	fi
 }
 
+# A hook function to support read-only-rootfs IMAGE_FEATURES
+# Currently, it only supports sysvinit system.
+read_only_rootfs_hook () {
+	if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
+	        # Tweak the mount option in fstab
+		sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab
+	        # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
+		if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
+			sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
+		fi
+	        # Run populate-volatile.sh at rootfs time to set up basic files
+	        # and directories to support read-only rootfs.
+		if [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+		fi
+	fi
+}
+
 fakeroot do_rootfs () {
 	#set -x
 	# When use the rpm incremental image generation, don't remove the rootfs
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs

Quoted 20 lines · On 1/24/13 2:16 AM, [email protected] wrote:

From: Chen Qi <[email protected]>

read_only_rootfs_hook: this funtion is invoked only if 'read-only-rootfs' is in IMAGE_FEATURES. It tweaks some basic files and makes populate- volatile.sh script run at rootfs time.

For now, it has real effect only if the init system is sysvinit.

[YOCTO #3406]

---
  meta/classes/image.bbclass |   18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
meta/classes/image.bbclass +0 -0
index 0293d2e..91045fc 100644

meta/classes/image.bbclass run_intercept_scriptlets () { · line 209

Quoted 9 lines
meta/classes/image.bbclass +6 -0
@@ -201,6 +201,24 @@ run_intercept_scriptlets () {
  	fi
  }
 
+# A hook function to support read-only-rootfs IMAGE_FEATURES
+# Currently, it only supports sysvinit system.
+read_only_rootfs_hook () {
+	if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
+	        # Tweak the mount option in fstab
+		sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab

There is a slight bug in the above. Not all configurations will contain an /etc/fstab! So you need to check for the existence of the file before you try to sed it.

(Initramfs is where I hit a problem trying to test this.)

--Mark

Quoted 16 lines
meta/classes/image.bbclass +12 -0
+	        # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
+		if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
+			sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
+		fi
+	        # Run populate-volatile.sh at rootfs time to set up basic files
+	        # and directories to support read-only rootfs.
+		if [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+		fi
+	fi
+}
+
  fakeroot do_rootfs () {
  	#set -x
  	# When use the rpm incremental image generation, don't remove the rootfs
author
#4 lore raw

Re: [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs

Quoted 34 lines · Mark Hatle
Quoted 28 lines · On 1/24/13 2:16 AM, [email protected] wrote:

From: Chen Qi <[email protected]>

read_only_rootfs_hook: this funtion is invoked only if 'read-only-rootfs' is in IMAGE_FEATURES. It tweaks some basic files and makes populate- volatile.sh script run at rootfs time.

For now, it has real effect only if the init system is sysvinit.

[YOCTO #3406]

---
  meta/classes/image.bbclass |   18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
meta/classes/image.bbclass +4 -0
index 0293d2e..91045fc 100644
@@ -201,6 +201,24 @@ run_intercept_scriptlets () {
      fi
  }
 
+# A hook function to support read-only-rootfs IMAGE_FEATURES
+# Currently, it only supports sysvinit system.
+read_only_rootfs_hook () {
+    if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", 

"false", d)}; then

meta/classes/image.bbclass run_intercept_scriptlets () { · line 209

Quoted 2 lines
meta/classes/image.bbclass +2 -0
+            # Tweak the mount option in fstab
+        sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab

There is a slight bug in the above. Not all configurations will contain an /etc/fstab! So you need to check for the existence of the file before you try to sed it.

Quoted 4 lines

(Initramfs is where I hit a problem trying to test this.)

--Mark

Thank you for pointing it out. I'll fix it.

Thanks,
Chen Qi

Quoted 28 lines
Quoted 18 lines

+ # Change the value of ROOTFS_READ_ONLY in
/etc/default/rcS to yes

meta/classes/image.bbclass +2 -0
+        if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
+            sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' 

${IMAGE_ROOTFS}/etc/default/rcS

meta/classes/image.bbclass +2 -0
+        fi
+            # Run populate-volatile.sh at rootfs time to set up 

basic files

meta/classes/image.bbclass +7 -0
+            # and directories to support read-only rootfs.
+        if [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+            ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+        fi
+    fi
+}
+
  fakeroot do_rootfs () {
      #set -x
      # When use the rpm incremental image generation, don't remove 
Quoted 2 lines

the rootfs

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#5 lore raw

PATCH 3/12 core-image.bbclass: support read-only rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

The hook function is appended to ROOTFS_POSTPROCESS_COMMAND properly to support the 'read-only-rootfs' image feature.

[YOCTO #3406]

---
 meta/classes/core-image.bbclass |    4 ++++
 1 file changed, 4 insertions(+)
meta/classes/core-image.bbclass +4 -0
index e0f6dbb..0e6663d 100644
@@ -28,6 +28,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3
 # - dev-pkgs            - development packages (headers, etc.) for all installed packages in the rootfs
 # - dbg-pkgs            - debug symbol packages for all installed packages in the rootfs
 # - doc-pkgs            - documentation packages for all installed packages in the rootfs
+# - read-only-rootfs    - tweaks an image to support read-only rootfs
 #
 PACKAGE_GROUP_x11 = "packagegroup-core-x11"
 PACKAGE_GROUP_x11-base = "packagegroup-core-x11-base"
@@ -76,3 +77,6 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Zap the root password if debug-tweaks feature is not enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "", "zap_root_password ; ",d)}'
+
+# Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled
+ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 4/12 package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS

In reply to [email protected]

From: Chen Qi <[email protected]>

These two variables are used by recipes that inherit volatiles.bbclass. The usage of them is similar to INITSCRIPT_NAME and INITSCRIPT_PARAMS.

[YOCTO #3406]

---
 meta/classes/package.bbclass |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/package.bbclass +3 -1
index 8e07168..b4298ad 100644
@@ -1842,7 +1842,9 @@ python package_depchains() {
 
 # Since bitbake can't determine which variables are accessed during package
 # iteration, we need to list them here:
-PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR"
+PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES \
+RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm INITSCRIPT_NAME INITSCRIPT_PARAMS \
+DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR VOLATILE_DIR VOLATILE_LINK"
 
 def gen_packagevar(d):
     ret = []
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 5/12 volatiles.bbclass: add recipe

In reply to [email protected]

From: Chen Qi <[email protected]>

All recipes that need to tweak their directories need to inherit this class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.

[YOCTO #3406]

---
 meta/classes/volatiles.bbclass |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes/volatiles.bbclass
meta/classes/volatiles.bbclass new file +11 -0
new file mode 100644
index 0000000..f27e598
@@ -0,0 +1,11 @@
+# This bbclass is for read-only-rootfs support. All recipes that may tweak their
+# own directories in order to run correctly in a read-only rootfs enviroment
+# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
+
+# For each package, the net result is a read-only specific conf file generated
+# and packaged, which has the name of readonly-${VOLATILESPN}.
+
+# All these config files are then parsed by populate-volatile.sh to create proper
+# directories and links.
+
+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 20 lines · On Thu, Jan 24, 2013 at 04:16:45PM +0800, [email protected] wrote:

From: Chen Qi <[email protected]>

All recipes that need to tweak their directories need to inherit this class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.

[YOCTO #3406]

---
 meta/classes/volatiles.bbclass |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes/volatiles.bbclass
meta/classes/volatiles.bbclass new file +1 -0
new file mode 100644
index 0000000..f27e598
@@ -0,0 +1,11 @@
+# This bbclass is for read-only-rootfs support. All recipes that may tweak their

meta/classes/volatiles.bbclass line 11

Quoted 10 lines
meta/classes/volatiles.bbclass new file +10 -0
+# own directories in order to run correctly in a read-only rootfs enviroment
+# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
+
+# For each package, the net result is a read-only specific conf file generated
+# and packaged, which has the name of readonly-${VOLATILESPN}.
+
+# All these config files are then parsed by populate-volatile.sh to create proper
+# directories and links.
+
+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

Does "inherit " work?

I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC it will fail to parse.

Cheers,

Quoted 8 lines
Signature · 7 lines
1.7.9.5


_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#9 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 34 lines · Martin Jansa
Quoted 20 lines · On Thu, Jan 24, 2013 at 04:16:45PM +0800, [email protected] wrote:

From: Chen Qi <[email protected]>

All recipes that need to tweak their directories need to inherit this class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.

[YOCTO #3406]

---
 meta/classes/volatiles.bbclass |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes/volatiles.bbclass
meta/classes/volatiles.bbclass new file +1 -0
new file mode 100644
index 0000000..f27e598
@@ -0,0 +1,11 @@
+# This bbclass is for read-only-rootfs support. All recipes that may tweak their

meta/classes/volatiles.bbclass line 11

Quoted 10 lines
meta/classes/volatiles.bbclass new file +10 -0
+# own directories in order to run correctly in a read-only rootfs enviroment
+# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
+
+# For each package, the net result is a read-only specific conf file generated
+# and packaged, which has the name of readonly-${VOLATILESPN}.
+
+# All these config files are then parsed by populate-volatile.sh to create proper
+# directories and links.
+
+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

Does "inherit " work?

Quoted 2 lines

I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC it will fail to parse.

The above syntax does now work. A plain "inherit " won't but something with an expression in does get handled correctly. It did not used to work with older bitbake versions.

Cheers,

Richard

#10 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 10 lines · Richard Purdie
Quoted 6 lines
Quoted 1 line

+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

Does "inherit " work?

I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC it will fail to parse.

The above syntax does now work. A plain "inherit " won't but something with an expression in does get handled correctly. It did not used to work with older bitbake versions.

The syntax works but that expression won't. If sysvinit was backfilled (pending patch from Marcin) because the distribution didn't pick sysvinit or systemd explicitly, the backfill happens after this expression is parsed.

I'm testing a change where these tests happen against DISTRO_FEATURES_INITMAN instead now.

Ross

author
#11 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 15 lines · Ross
Quoted 8 lines · Richard Purdie
Quoted 5 lines
Quoted 1 line

+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

Does "inherit " work?

I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC it will fail to parse.

The above syntax does now work. A plain "inherit " won't but something with an expression in does get handled correctly. It did not used to work with older bitbake versions.

The syntax works but that expression won't. If sysvinit was backfilled (pending patch from Marcin) because the distribution didn't pick sysvinit or systemd explicitly, the backfill happens after this expression is parsed.

Quoted 6 lines

I'm testing a change where these tests happen against DISTRO_FEATURES_INITMAN instead now.

Ross

_

It seems that the backfill happens *before* this expression is parsed.

I tested it with DISTRO_FEATURES explicitly set in local.conf (basically the default value, except that it contains no init manager). It worked out well.

#
DISTRO ?= "poky"
DISTRO_FEATURES_LIBC_DEFAULT = "ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-charsets libc-crypt \
libc-crypt-ufc libc-db-aliases libc-envz libc-fcvt
libc-fmtmsg libc-fstab libc-ftraverse \
libc-getlogin libc-idn libc-inet-anl libc-libm
libc-libm-big libc-locales libc-locale-code \
libc-memusage libc-nis libc-nsswitch libc-rcmd
libc-rtld-debug libc-spawn libc-streams libc-sunrpc \
libc-utmp libc-utmpx libc-wordexp
libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc \
libc-posix-wchar-io"
DISTRO_FEATURES_LIBC = "${DISTRO_FEATURES_LIBC_DEFAULT}"
DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}"
DISTRO_FEATURES = "alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g x11 ${DISTRO_FEATURES_LIBC}"

I also added the following lines to volatiles.bbclass to examine the DISTRO_FEATURES when parsing the volatiles.bbclass.

+python __anonymous() {
+ bb.error("DISTRO_FEATURES: %s" % d.getVar('DISTRO_FEATURES', True))
+}
+
inherit
${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

And the DISTRO_FEATURES contains 'sysvinit'.

ERROR: DISTRO_FEATURES: alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g x11 ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-charsets libc-crypt libc-crypt-ufc libc-db-aliases libc-envz libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse libc-getlogin libc-idn libc-inet-anl libc-libm libc-libm-big libc-locales libc-locale-code libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug libc-spawn libc-streams libc-sunrpc libc-utmp libc-utmpx libc-wordexp libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc libc-posix-wchar-io pulseaudio sysvinit largefile opengl multiarch

Best Regards,
Chen Qi

Quoted 6 lines

______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#12 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 1 line · ChenQi

It seems that the backfill happens *before* this expression is parsed.

Yes, because of these two patches that I reviewed and submitted yesterday:

commit 4db8a3daafdedf39e081f4f6130f6cdcde03ed62

Author: Richard Purdie <[email protected]>
Date:   Thu Jan 24 17:52:56 2013 +0000

base: make feature backfilling happen earlier

commit c98363450fc4ccab82b34a37a95bd172cf6e115f

Author: Marcin Juszkiewicz <[email protected]>
Date:   Thu Jan 24 17:52:55 2013 +0000

bitbake.conf: unbreak all builds with custom DISTRO_FEATURES

Ross

author
#13 lore raw

Re: [PATCH 05/12] volatiles.bbclass: add recipe

Quoted 10 lines · Ross
Quoted 1 line · ChenQi

It seems that the backfill happens *before* this expression is parsed.

Yes, because of these two patches that I reviewed and submitted yesterday:

commit 4db8a3daafdedf39e081f4f6130f6cdcde03ed62

Author: Richard Purdie <[email protected]>
Date:   Thu Jan 24 17:52:56 2013 +0000

base: make feature backfilling happen earlier

Quoted 9 lines

commit c98363450fc4ccab82b34a37a95bd172cf6e115f

Author: Marcin Juszkiewicz <[email protected]>
Date:   Thu Jan 24 17:52:55 2013 +0000

bitbake.conf: unbreak all builds with custom DISTRO_FEATURES

Ross

Ah... Yes.

Thanks for making things clear for me :)

Best Regards,
Chen Qi

#14 lore raw

PATCH 6/12 volatiles_sysvinit.bbclass: add recipe

In reply to [email protected]

From: Chen Qi <[email protected]>

This bbclass is used to support read-only rootfs with sysvinit init manager.

[YOCTO #3406]

---
 meta/classes/volatiles_sysvinit.bbclass |   49 +++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 meta/classes/volatiles_sysvinit.bbclass
meta/classes/volatiles_sysvinit.bbclass new file +49 -0
new file mode 100644
index 0000000..df5bedc
@@ -0,0 +1,49 @@
+# This bbclass is used to support read-only rootfs with sysvinit init manager.
+
+VOLATILESPN ?= "${PN}"
+VOLATILES_PKGD_DIR = "${PKGD}${sysconfdir}/default/volatiles"
+CONF_FILE_NAME = "readonly-${VOLATILESPN}"
+
+CONF_FILE = "${VOLATILES_PKGD_DIR}/${CONF_FILE_NAME}"
+
+def volatiles_after_parse(d):
+    if d.getVar('VOLATILE_PKGS') == None:
+        if d.getVar('VOLATILE_DIR') == None:
+            raise bb.build.FuncFailed, "%s inherits volatiles but doesn't set VOLATILE_DIR" % d.getVar('FILE')
+        if d.getVar('VOLATILE_LINK') == None:
+            raise bb.build.FuncFailed, "%s inherits volatiles but doesn't set VOLATILE_LINK" % d.getVar('FILE')
+
+python __anonymous() {
+    volatiles_after_parse(d)
+}
+
+do_install_prepend () {
+    install -d ${D}${sysconfdir}/default/volatiles
+}
+
+python populate_packages_prepend () {
+    def volatiles_package(pkg):
+        bb.debug(1, 'generating volatile config files for %s' % pkg)
+        localdata = bb.data.createCopy(d)
+        overrides = localdata.getVar("OVERRIDES", True)
+        localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
+        bb.data.update_data(localdata)
+
+        # install read-only specific conf files
+        filepath = localdata.getVar('CONF_FILE', True)
+        dirpath = localdata.getVar('VOLATILE_DIR', True)
+        linkpath = localdata.getVar('VOLATILE_LINK', True)
+        f = open(filepath, 'a')
+        f.write("d root root 0755 %s none\n" % dirpath)
+        f.write("l root root 0755 %s %s\n" % (linkpath, dirpath))
+        f.close()
+
+    pkgs = d.getVar('VOLATILE_PKGS', True)
+    if pkgs == None:
+        pkgs = d.getVar('VOLATILESPN', True)
+        packages = (d.getVar('PACKAGES', True) or "").split()
+        if not pkgs in packages and packages != []:
+            pkgs = packages[0]
+    for pkg in pkgs.split():
+        volatiles_package(pkg)
+}
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH 7/12 populate-volatile.sh: improve this script

In reply to [email protected]

From: Chen Qi <[email protected]>

Here's a list of improvements:
1) Make it run correctly at rootfs time.
2) Handle link config items more reasonably.
3) Support read-only rootfs.
4) Avoid data loss when removing directories.

[YOCTO #3406]
[YOCTO #3404]
[YOCTO #3181]

---
 .../initscripts-1.0/populate-volatile.sh           |  287 ++++++++++----------
 1 file changed, 143 insertions(+), 144 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +143 -144
index d2175d7..61ef6c9 100755
@@ -8,192 +8,191 @@
 # Short-Description:  Populate the volatile filesystem
 ### END INIT INFO
 
-. /etc/default/rcS
-
-CFGDIR="/etc/default/volatiles"
-TMPROOT="/var/tmp"
+# Get ROOT_DIR
+DIRNAME=`dirname $0`
+ROOT_DIR=`echo $DIRNAME | sed -ne 's:etc/.*::p'`
+
+. ${ROOT_DIR}/etc/default/rcS
+# When running populat-volatile.sh at rootfs time, disable cache.
+[ "$ROOT_DIR" != "/" ] && VOLATILE_ENABLE_CACHE=no
+# If rootfs is read-only, disable cache.
+[ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no
+# All above statements will be moved to a central place, say var.sh which
+# encapsulates '. /etc/default/rcS'.
+
+CFGDIR="${ROOT_DIR}/etc/default/volatiles"
+TMPROOT="${ROOT_DIR}/var/volatile/tmp"
 COREDEF="00_core"
+READONLY_MATCH="readonly-"
 
-[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
+[ "${VERBOSE}" != "no" ] && echo "Setting up basic files related to volatile storage under ${ROOT_DIR}."
 
 create_file() {
-	EXEC=" 
-	touch \"$1\"; 
-	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
-	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 
+	EXEC="
+	touch \"$1\";
+	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" > /dev/null 2>&1;
+	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" > /dev/null 2>&1 "
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
 
 	[ -e "$1" ] && {
-	  [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
+		[ "${VERBOSE}" != "no" ] && echo "Target $1 already exists. Skipping."
 	} || {
-	  eval $EXEC &
+		if [ "$ROOT_DIR" = "/" ]; then
+			eval $EXEC
+		else
+			# Some operations at rootfs time may fail and should fail,
+		        # but these failures should not be logged.
+			eval $EXEC > /dev/null 2>&1
+		fi
 	}
 }
 
 mk_dir() {
-	EXEC=" 
-	mkdir -p \"$1\"; 
-	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
-	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
+	EXEC="
+	mkdir -p \"$1\";
+	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" 2>&1; 
+	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" 2>&1 "
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
-	
 	[ -e "$1" ] && {
-	  [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
+		[ "${VERBOSE}" != "no" ] && echo "Target ${1} already exists. Skipping."
 	} || {
-	  eval $EXEC
+		if [ "$ROOT_DIR" = "/" ]; then
+			eval $EXEC
+		else
+			# Some operations at rootfs time may fail and should fail,
+                        # but these failures should not be logged.
+			eval $EXEC > /dev/null 2>&1
+		fi
 	}
 }
 
 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
+		[ \"$(readlink -f \"$2\")\" != \"$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
+	elif [ -d \"$2\" ]; then
+		for f in $2/* $2/.[^.]*; do [ -e $f ] && cp -rf $f $1; done;
+		rm -rf \"$2\";
+		ln -sf \"$1\" \"$2\";
+	else
+		ln -sf \"$1\" \"$2\";
+	fi
+        "
+        test "$VOLATILE_ENABLE_CACHE" = yes && echo "   $EXEC" >> /etc/volatile.cache.build
+	if [ "$ROOT_DIR" = "/" ]; then
+		eval $EXEC
+	else
+		# Some operations at rootfs time may fail and should fail,
+                # but these failures should not be logged
+		eval $EXEC > /dev/null 2>&1
+	fi
 }
 
 check_requirements() {
+	cleanup() {
+		rm "${TMP_INTERMED}"
+		rm "${TMP_DEFINED}"
+		rm "${TMP_COMBINED}"
+	}
+	
+	CFGFILE="$1"
+	[ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
+	# read-only-rootfs specific conf files should only be applied when rootfs is read-only
+	case `basename "${CFGFILE}"` in
+		${READONLY_MATCH}*)
+		[ "$ROOTFS_READ_ONLY" = "yes" ] && return 0 || return 1
+		;;
+		*)
+		;;
+	esac
 
-  cleanup() {
-    rm "${TMP_INTERMED}"
-    rm "${TMP_DEFINED}"
-    rm "${TMP_COMBINED}"
-    }
-    
-  CFGFILE="$1"
-
-  [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
-
-  TMP_INTERMED="${TMPROOT}/tmp.$$"
-  TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
-  TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
-
-
-  cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
-  cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
-  cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
-
-  NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
-  NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
-
-  [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
-    echo "Undefined users:"
-    diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
-    cleanup
-    return 1
-    }
-
+	TMP_INTERMED="${TMPROOT}/tmp.$$"
+	TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
+	TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
+
+	cat ${ROOT_DIR}/etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
+	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
+	NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
+	NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
+
+	[ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
+		echo "Undefined users:"
+		diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
+		cleanup
+		return 1
+	}
 
-  cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
-  cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
-  cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
-  NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
-  NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
+	cat ${ROOT_DIR}/etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
+	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
-  [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
-    echo "Undefined groups:"
-    diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
-    cleanup
-    return 1
-    }
+	NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
+	NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
 
-  # Add checks for required directories here
+	[ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
+		echo "Undefined groups:"
+		diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
+		cleanup
+		return 1
+	}
 
-  cleanup
-  return 0
-  }
+	cleanup
+	return 0
+}
 
 apply_cfgfile() {
+	CFGFILE="$1"
+	[ ${VERBOSE} != "no" ] && echo "Applying config file: $CFGFILE"
+	
+	check_requirements "${CFGFILE}" || {
+		echo "Skipping ${CFGFILE}"
+		return 1
+	}
 
-  CFGFILE="$1"
-
-  check_requirements "${CFGFILE}" || {
-    echo "Skipping ${CFGFILE}"
-    return 1
-    }
-
-  cat ${CFGFILE} | grep -v "^#" | \
-  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}" &
-        }
-      continue
-      }
-
-    [ -L "${TNAME}" ] && {
-      [ "${VERBOSE}" != "no" ] && echo "Found link."
-      NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
-      echo ${NEWNAME} | grep -v "^/" >/dev/null && {
-        TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
-        [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
-        } || {
-        TNAME="${NEWNAME}"
-        [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
-        }
-      }
-
-    case "${TTYPE}" in
-      "f")  [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
-            create_file "${TNAME}" &
-	    ;;
-      "d")  [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
-            mk_dir "${TNAME}"
-	    # Add check to see if there's an entry in fstab to mount.
-	    ;;
-      *)    [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
-            continue
-	    ;;
-    esac
-
-
-    done
-
-  return 0
-
-  }
-
-clearcache=0
-exec 9</proc/cmdline
-while read line <&9
-do
-	case "$line" in
-		*clearcache*)  clearcache=1
-			       ;;
-		*)	       continue
-			       ;;
-	esac
-done
-exec 9>&-
+	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"`
+		TNAME=${ROOT_DIR}/${TNAME}
+		[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
+
+		[ "${TTYPE}" = "l" ] && {
+			TSOURCE="$TLTARGET"
+			[ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
+			link_file "${TSOURCE}" "${TNAME}"
+			continue
+		}
+		case "${TTYPE}" in
+			"f")  [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
+				create_file "${TNAME}"
+				;;
+			"d")  [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
+				mk_dir "${TNAME}"
+				;;
+			*)    [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
+				continue
+				;;
+		esac
+	done
+	return 0
+}
 
-if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
+if test -e ${ROOT_DIR}/etc/volatile.cache -a $VOLATILE_ENABLE_CACHE = yes -a x$1 != xupdate
 then
-	sh /etc/volatile.cache
+	sh ${ROOT_DIR}/etc/volatile.cache
 else	
-	rm -f /etc/volatile.cache /etc/volatile.cache.build
+	rm -f ${ROOT_DRI}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
 	for file in `ls -1 "${CFGDIR}" | sort`; do
 		apply_cfgfile "${CFGDIR}/${file}"
 	done
 
-	[ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache
+	[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
 fi
 
-if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache
+if [ "${ROOT_DIR}" = "/" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]
 then
 	ln -s /etc/ld.so.cache /var/run/ld.so.cache
 fi
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH 8/12 initscripts: let populate-volatile.sh create the /tmp link

In reply to [email protected]

From: Chen Qi <[email protected]>

Previously, the /tmp link (/tmp -> /var/tmp) was created by the bootmisc.sh script. So in case of a read-only rootfs, this symlink would not be created correctly.

The populate-volatile.sh script is intended to handle all directories and files related to volatile storage, so we should let it create the /tmp link.

In addition, because of the improments of populate-volatile.sh, the data loss problem of bug#3404 is also resolved by this patch.

[YOCTO #3406]
[YOCTO #3404]

---
 .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
 .../initscripts/initscripts-1.0/volatiles          |    1 +
 2 files changed, 2 insertions(+), 8 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +1 -8
index 4f76cb4..3b5a47f 100755
@@ -54,14 +54,7 @@ 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,
 # use the timestamp instead.
meta/recipes-core/initscripts/initscripts-1.0/volatiles +1 -0
index e0741aa..f7e2ef7 100644
@@ -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
Signature · 1 line
1.7.9.5
#17 lore raw

Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link

Quoted 28 lines · On 1/24/13 2:16 AM, [email protected] wrote:

From: Chen Qi <[email protected]>

Previously, the /tmp link (/tmp -> /var/tmp) was created by the bootmisc.sh script. So in case of a read-only rootfs, this symlink would not be created correctly.

The populate-volatile.sh script is intended to handle all directories and files related to volatile storage, so we should let it create the /tmp link.

In addition, because of the improments of populate-volatile.sh, the data loss problem of bug#3404 is also resolved by this patch.

[YOCTO #3406]
[YOCTO #3404]

---
  .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
  .../initscripts/initscripts-1.0/volatiles          |    1 +
  2 files changed, 2 insertions(+), 8 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -0
index 4f76cb4..3b5a47f 100755
@@ -54,14 +54,7 @@ fi
 

meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh fi · line 64

Quoted 10 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -8
  #
  # 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
-

I saw this the other day. It seems like the wrong solution, if the expectation is that all systems want this linked behavior. Instead the link should be configured in the meta/files/fs-perms.txt

Something like:

-/tmp                            01777   root    root    false - - -
+/tmp                            link    /var/tmp

Making that change would avoid this patch, and then all of the filesystems could inherit this behavior. (Other distributions that don't want it can provide their own custom fs-perms.txt file, and simply set the older value, which will append to the default.)

Quoted 17 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +1 -0
+#
  # Set the system clock from hardware clock
  # If the timestamp is more recent than the current time,
  # use the timestamp instead.
meta/recipes-core/initscripts/initscripts-1.0/volatiles +1 -0
index e0741aa..f7e2ef7 100644
@@ -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
author
#18 lore raw

Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link

Quoted 47 lines · Mark Hatle
Quoted 28 lines · On 1/24/13 2:16 AM, [email protected] wrote:

From: Chen Qi <[email protected]>

Previously, the /tmp link (/tmp -> /var/tmp) was created by the bootmisc.sh script. So in case of a read-only rootfs, this symlink would not be created correctly.

The populate-volatile.sh script is intended to handle all directories and files related to volatile storage, so we should let it create the /tmp link.

In addition, because of the improments of populate-volatile.sh, the data loss problem of bug#3404 is also resolved by this patch.

[YOCTO #3406]
[YOCTO #3404]

---
  .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
  .../initscripts/initscripts-1.0/volatiles          |    1 +
  2 files changed, 2 insertions(+), 8 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -0
index 4f76cb4..3b5a47f 100755
@@ -54,14 +54,7 @@ fi
 

meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh fi · line 64

Quoted 10 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -8
  #
  # 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
-

I saw this the other day. It seems like the wrong solution, if the expectation is that all systems want this linked behavior. Instead the link should be configured in the meta/files/fs-perms.txt

Something like:

(quoted diff) +1 -1
-/tmp                            01777   root    root    false - - -
+/tmp                            link    /var/tmp
Quoted 2 lines

Making that change would avoid this patch, and then all of the filesystems could inherit this behavior. (Other distributions that don't want it can provide their own custom fs-perms.txt file, and simply set the older value, which will append to the default.)

Thank you for your careful review :)

Here's a little more explanation on this patch. (Correct me if I'm wrong somewhere.)

No matter we're going to change the fs-perms.txt file or not, this patch is needed for things to work correctly. The populate-volatile.sh in sysvinit scripts, together with its configuration files, are a final means to ensure the directories, files and links related to volatile storage are created correctly.

There are link config items in fs-perms.txt.
${localstatedir}/cache link volatile/cache

${localstatedir}/run    link    volatile/run
${localstatedir}/log    link    volatile/log

${localstatedir}/lock link volatile/lock
${localstatedir}/tmp link volatile/tmp
There configurations are great and very reasonable, because they are common for different init systems.

But I'm not very sure about this link config item -- "/tmp link /var/tmp "

I want to restrict the creation of this link (/tmp -> /var/tmp) in the sysvinit scripts, because in this way, it doesn't affect other init systems such as systemd. The same strategy goes with the /run directory.

Here's the output from the mount command from a systemd-based core-image-minimal image:

root@qemux86:~# mount | grep tmpfs
devtmpfs on /dev type devtmpfs (rw,relatime,size=59032k,nr_inodes=14758,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
tmpfs on /tmp type tmpfs (rw)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)

Here's the output form the mount command from a sysv-based core-image-minimal image:

root@qemux86:~# mount | grep tmpfs
devtmpfs on /dev type devtmpfs (rw,relatime,size=59032k,nr_inodes=14758,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)

Best Regards,
Chen Qi

Quoted 25 lines
Quoted 10 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +1 -0
+#
  # Set the system clock from hardware clock
  # If the timestamp is more recent than the current time,
  # use the timestamp instead.
meta/recipes-core/initscripts/initscripts-1.0/volatiles +0 -0
index e0741aa..f7e2ef7 100644

meta/recipes-core/initscripts/initscripts-1.0/volatiles l root root 1777 /var/lock /var/volatile/lock · line 37

Quoted 7 lines
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

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#19 lore raw

Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link

In reply to [email protected]
Quoted 28 lines · On 1/24/13 2:16 AM, [email protected] wrote:

From: Chen Qi <[email protected]>

Previously, the /tmp link (/tmp -> /var/tmp) was created by the bootmisc.sh script. So in case of a read-only rootfs, this symlink would not be created correctly.

The populate-volatile.sh script is intended to handle all directories and files related to volatile storage, so we should let it create the /tmp link.

In addition, because of the improments of populate-volatile.sh, the data loss problem of bug#3404 is also resolved by this patch.

[YOCTO #3406]
[YOCTO #3404]

---
  .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
  .../initscripts/initscripts-1.0/volatiles          |    1 +
  2 files changed, 2 insertions(+), 8 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -0
index 4f76cb4..3b5a47f 100755
@@ -54,14 +54,7 @@ fi
 

meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh fi · line 64

Quoted 10 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +0 -8
  #
  # 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
-

I saw this the other day. It seems like the wrong solution, if the expectation is that all systems want this linked behavior. Instead the link should be configured in the meta/files/fs-perms.txt

Something like:

-/tmp                            01777   root    root    false - - -
+/tmp                            link    /var/tmp

Making that change would avoid this patch, and then all of the filesystems could inherit this behavior. (Other distributions that don't want it can provide their own custom fs-perms.txt file, and simply set the older value, which will append to the default.)

Quoted 17 lines
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +1 -0
+#
  # Set the system clock from hardware clock
  # If the timestamp is more recent than the current time,
  # use the timestamp instead.
meta/recipes-core/initscripts/initscripts-1.0/volatiles +1 -0
index e0741aa..f7e2ef7 100644
@@ -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
#20 lore raw

PATCH 9/12 initscripts: inherit volatiles to support read-only rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

---
 meta/recipes-core/initscripts/initscripts_1.0.bb |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts_1.0.bb +5 -1
index 6e15f88..a33c0f6 100644
@@ -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 = "r139"
+PR = "r140"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
@@ -42,6 +42,10 @@ ALTERNATIVE_PRIORITY = "90"
 ALTERNATIVE_${PN} = "functions"
 ALTERNATIVE_LINK_NAME[functions] = "${sysconfdir}/init.d/functions"
 
+inherit volatiles
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"
+
 HALTARGS ?= "-d -f"
 
 do_configure() {
Signature · 1 line
1.7.9.5
#21 lore raw

Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs

meta/recipes-core/initscripts/initscripts_1.0.bb ALTERNATIVE_PRIORITY = "90" · line 47

Quoted 2 lines · On 24 January 2013 08:16, <[email protected]> wrote:
meta/recipes-core/initscripts/initscripts_1.0.bb +2 -0
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"

A better solution would be to not attempt to save and restore a seed value that is intended to persist across reboots when it's on a tmpfs.
Putting the urandom seed into tmpfs is just a waste of time.

Ross

#22 lore raw

Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs

Quoted 7 lines · Ross

meta/recipes-core/initscripts/initscripts_1.0.bb ALTERNATIVE_PRIORITY = "90" · line 47

Quoted 2 lines · On 24 January 2013 08:16, <[email protected]> wrote:
meta/recipes-core/initscripts/initscripts_1.0.bb +2 -0
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"

A better solution would be to not attempt to save and restore a seed value that is intended to persist across reboots when it's on a tmpfs.
Putting the urandom seed into tmpfs is just a waste of time.

I have to wonder why we don't put a union mount tmpfs over /var/lib to be honest...

or if we don't want to depend on unionfs, a tmpfs over /var/lib...

Cheers,

Richard

author
#23 lore raw

Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs

Quoted 7 lines · Richard Purdie
Quoted 6 lines · Ross

meta/recipes-core/initscripts/initscripts_1.0.bb ALTERNATIVE_PRIORITY = "90" · line 47

Quoted 2 lines · On 24 January 2013 08:16, <[email protected]> wrote:
meta/recipes-core/initscripts/initscripts_1.0.bb +2 -0
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"

A better solution would be to not attempt to save and restore a seed value that is intended to persist across reboots when it's on a tmpfs.
Putting the urandom seed into tmpfs is just a waste of time.

Quoted 11 lines

I have to wonder why we don't put a union mount tmpfs over /var/lib to be honest...

or if we don't want to depend on unionfs, a tmpfs over /var/lib...

Cheers,

Richard

A union mount tmpfs over /var/lib (and maybe /etc) was the first solution that came into my mind. Then I saw a bug related to unionfs about getcwd() call, and I saw the unionfs was still disabled for live images. So I thought "maybe I should not use unionfs".

A tmpfs over /var/lib.
Hmm... I thought about that too. The reason that I didn't use this method was that I thought that some directories under /etc might also need to be written to. It turns out that this concern seems unnecessary.

Anyway, I'll try out the tmpfs-over-var-lib method and let you know the result.

Thanks,
Chen Qi

author
#24 lore raw

Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs

In reply to Burton, Ross
Quoted 10 lines · Ross

meta/recipes-core/initscripts/initscripts_1.0.bb ALTERNATIVE_PRIORITY = "90" · line 47

Quoted 2 lines · On 24 January 2013 08:16, <[email protected]> wrote:
meta/recipes-core/initscripts/initscripts_1.0.bb +2 -0
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"

A better solution would be to not attempt to save and restore a seed value that is intended to persist across reboots when it's on a tmpfs.
Putting the urandom seed into tmpfs is just a waste of time.

Ross

I agree.

I'll just remove this patch.

Thanks,
Chen Qi

#25 lore raw

PATCH 10/12 dropbear: inherit volatiles to support read-only rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

---
 meta/recipes-core/dropbear/dropbear.inc |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/recipes-core/dropbear/dropbear.inc +5 -2
index 3a39c95..efc685c 100644
@@ -2,7 +2,7 @@ DESCRIPTION = "Dropbear is a lightweight SSH and SCP implementation"
 HOMEPAGE = "http://matt.ucc.asn.au/dropbear/dropbear.html"
 SECTION = "console/network"
 
-INC_PR = "r2"
+INC_PR = "r3"
 
 # some files are from other projects and have others license terms:
 #   public domain, OpenSSH 3.5p1, OpenSSH3.6.1p2, PuTTY
@@ -26,11 +26,14 @@ PAM_SRC_URI = "file://dropbear-enable-pam.patch \
                file://dropbear-configuration-file.patch \
                file://dropbear"
 
-inherit autotools update-rc.d
+inherit autotools update-rc.d volatiles
 
 INITSCRIPT_NAME = "dropbear"
 INITSCRIPT_PARAMS = "defaults 10"
 
+VOLATILE_DIR = "/var/volatile/lib/dropbear"
+VOLATILE_LINK = "/var/lib/dropbear"
+
 CFLAGS_prepend = " -I. "
 LD = "${CC}"
 
Signature · 1 line
1.7.9.5
#26 lore raw

PATCH 11/12 nfs-utils: inherit volatiles to support read-only rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

---
 .../nfs-utils/nfs-utils_1.2.3.bb                   |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/recipes-connectivity/nfs-utils/nfs-utils_1.2.3.bb +5 -2
index 84b8e76..55208d5 100644
@@ -12,7 +12,7 @@ DEPENDS = "libcap libnfsidmap libevent util-linux tcp-wrappers"
 RDEPENDS_${PN} = "rpcbind"
 RRECOMMENDS_${PN} = "kernel-module-nfsd"
 
-PR = "r5"
+PR = "r6"
 
 SRC_URI = "${SOURCEFORGE_MIRROR}/nfs/nfs-utils-${PV}.tar.bz2 \
            file://nfs-utils-1.0.6-uclibc.patch \
@@ -34,7 +34,10 @@ INITSCRIPT_NAME = "nfsserver"
 # in the shutdown levels, but that works fine.
 INITSCRIPT_PARAMS = "defaults"
 
-inherit autotools update-rc.d
+inherit autotools update-rc.d volatiles
+
+VOLATILE_DIR = "/var/volatile/lib/nfs"
+VOLATILE_LINK = "/var/lib/nfs"
 
 # --enable-uuid is need for cross-compiling
 EXTRA_OECONF = "--with-statduser=nobody \
Signature · 1 line
1.7.9.5
#27 lore raw

PATCH 12/12 dbus: inherit volatiles to support read-only rootfs

In reply to [email protected]

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

---
 meta/recipes-core/dbus/dbus.inc |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/recipes-core/dbus/dbus.inc +5 -2
index 88218b7..f614285 100644
@@ -12,17 +12,20 @@ DEPENDS_class-nativesdk = "nativesdk-expat virtual/nativesdk-libintl virtual/lib
 RDEPENDS_dbus = "${@base_contains('DISTRO_FEATURES', 'ptest', 'dbus-ptest', '', d)}"
 RDEPENDS_class-native = ""
 
-INC_PR = "r5"
+INC_PR = "r6"
 
 SRC_URI = "http://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.gz \
            file://tmpdir.patch; \
            file://dbus-1.init"
 
-inherit useradd autotools pkgconfig gettext update-rc.d
+inherit useradd autotools pkgconfig gettext update-rc.d volatiles
 
 INITSCRIPT_NAME = "dbus-1"
 INITSCRIPT_PARAMS = "start 02 5 3 2 . stop 20 0 1 6 ."
 
+VOLATILE_DIR = "/var/volatile/lib/dbus"
+VOLATILE_LINK = "/var/lib/dbus"
+
 USERADD_PACKAGES = "${PN}"
 GROUPADD_PARAM_${PN} = "-r netdev"
 USERADD_PARAM_${PN} = "--system --home ${localstatedir}/lib/dbus \
Signature · 1 line
1.7.9.5
#28 lore raw

Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs

Quoted 3 lines · On 24 January 2013 08:16, <[email protected]> wrote:

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

Please explain why DBus needs volatiles.bbclass to support a readonly rootfs. Presumably it's because the machine UUID is written to /var/lib, are there any other reasons?

Ross

author
#29 lore raw

Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs

Quoted 11 lines · Ross
Quoted 3 lines · On 24 January 2013 08:16, <[email protected]> wrote:

From: Chen Qi <[email protected]>

Inherit volatiles.bbclass to support read-only rootfs.

Please explain why DBus needs volatiles.bbclass to support a readonly rootfs. Presumably it's because the machine UUID is written to /var/lib, are there any other reasons?

Ross

I added this patch because I encountered an error when starting the sato image. That is, the machine UUID needs to be written to /var/lib.

I'm not familiar with dbus. Is it not necessary?

Thanks,
Chen Qi

#30 lore raw

Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs

Quoted 5 lines · ChenQi

I added this patch because I encountered an error when starting the sato image.
That is, the machine UUID needs to be written to /var/lib.

I'm not familiar with dbus. Is it not necessary?

The file is necessary and needs to be persistent for at least the lifetime of a boot, so generating it on dbus startup and writing to a tmpfs is fine.

My point was that the commit doesn't say *why* it does what it does.

Ross