All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/1] udev-cache: take a read-only rootfs into consideration
@ 2013-06-28  7:48 Qi.Chen
  2013-06-28  7:48 ` [PATCH V2 1/1] " Qi.Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Qi.Chen @ 2013-06-28  7:48 UTC (permalink / raw)
  To: openembedded-core; +Cc: qingtao.cao

From: Chen Qi <Qi.Chen@windriver.com>

The following changes since commit 042203531b10b37ac9a8201b376f5dec403e51d8:

  sanity.bbclass: Fix COREBASE sanity tests (2013-06-27 12:48:56 +0100)

are available in the git repository at:

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

Chen Qi (1):
  udev-cache: take a read-only rootfs into consideration

 meta/recipes-core/udev/udev/init       |   54 +++++++++++++++++++-------------
 meta/recipes-core/udev/udev/udev-cache |    6 ++++
 2 files changed, 38 insertions(+), 22 deletions(-)

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH V2 1/1] udev-cache: take a read-only rootfs into consideration
  2013-06-28  7:48 [PATCH V2 0/1] udev-cache: take a read-only rootfs into consideration Qi.Chen
@ 2013-06-28  7:48 ` Qi.Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Qi.Chen @ 2013-06-28  7:48 UTC (permalink / raw)
  To: openembedded-core; +Cc: qingtao.cao

From: Chen Qi <Qi.Chen@windriver.com>

In case of a read-only rootfs, we skip the process of generating
udev cache, as the data cannot be persisted between reboots.

However, it's possbile that the $DEVCACHE (default to /etc/dev.tar)
exists in a read-only rootfs, no matter how it's generated or installed.
In such situation, we try to use $DEVCACHE if possible.

Besides the basic changes in the logic of udev cache handling,
this patch also adds code to output more information if the udev
cache is not used and VERBOSE enabled.

This patch also changes the readfile function to readfiles function
so that it could handle more than one file at once.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/udev/udev/init       |   54 +++++++++++++++++++-------------
 meta/recipes-core/udev/udev/udev-cache |    6 ++++
 2 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init
index 9b81700..fd8d476 100644
--- a/meta/recipes-core/udev/udev/init
+++ b/meta/recipes-core/udev/udev/init
@@ -18,15 +18,17 @@ export TZ=/etc/localtime
 [ -x @UDEVD@ ] || exit 1
 [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
 [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
+[ -f /etc/default/rcS ] && . /etc/default/rcS
 
-readfile () {
-   filename=$1
+readfiles () {
    READDATA=""
-   if [ -r $filename ]; then
-       while read line; do
-           READDATA="$READDATA$line"
-       done < $filename
-   fi
+   for filename in $@; do
+	   if [ -r $filename ]; then
+		   while read line; do
+			   READDATA="$READDATA$line"
+		   done < $filename
+	   fi
+   done
 }
 
 case "$1" in
@@ -52,29 +54,37 @@ case "$1" in
     mount -a -t tmpfs 2>/dev/null
     mkdir -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 /proc/atags"
     if [ "$DEVCACHE" != "" ]; then
-            readfile /proc/version
-            VERSION="$READDATA"
-            readfile /proc/cmdline
-            CMDLINE="$READDATA"
-            readfile /proc/devices
-            DEVICES="$READDATA"
-            readfile /proc/atags
-            ATAGS="$READDATA"
-
             if [ -e $DEVCACHE ]; then
-                    readfile /etc/udev/cache.data
-                    if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then
+		    readfiles $CMP_FILE_LIST
+		    NEWDATA="$READDATA"
+		    readfiles /etc/udev/cache.data
+		    OLDDATA="$READDATA"
+		    if [ "$OLDDATA" = "$NEWDATA" ]; then
                             (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
                             not_first_boot=1
                             [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
                             [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache
                     else
-                            echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
+			    # Output detailed reason why the cached /dev is not used
+			    if [ "$VERBOSE" != "no" ]; then
+				    echo "udev: udev cache not used"
+				    echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued"
+				    echo "udev: olddata: $OLDDATA"
+				    echo "udev: newdata: $NEWDATA"
+			    fi
+			    echo "$NEWDATA" > /dev/shm/udev.cache
                     fi
-            else
-                    echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
+	    else
+		    if [ "$ROOTFS_READ_ONLY" != "yes" ]; then
+			    # If rootfs is not read-only, it's possible that a new udev cache would be generated;
+			    # otherwise, we do not bother to read files.
+			    readfiles $CMP_FILE_LIST
+			    echo "$READDATA" > /dev/shm/udev.cache
+		    fi
             fi
     fi
 
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index 8a84fa9..db5a513 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -15,8 +15,14 @@ export TZ=/etc/localtime
 [ -x @UDEVD@ ] || exit 1
 [ -d /sys/class ] || exit 1
 
+[ -f /etc/default/rcS ] && . /etc/default/rcS
 [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
 
+if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
+    [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache"
+    exit 0
+fi
+
 if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then
 	echo "Populating dev cache"
 	(cd /; tar cf "$DEVCACHE" dev)
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-28  7:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-28  7:48 [PATCH V2 0/1] udev-cache: take a read-only rootfs into consideration Qi.Chen
2013-06-28  7:48 ` [PATCH V2 1/1] " Qi.Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.