On Wed, Nov 14, 2012 at 5:30 AM, ChenQi <span dir="ltr">&lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 11/14/2012 07:14 AM, Saul Wold wrote:<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 11/12/2012 03:33 AM, <a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;<br>
<br>
Change the way how populate_volatile.sh handles link-type config<br>
items. Previously, if a link-type config item is encountered, the<br>
script does not handle it correctly. If the target exists as a link,<br>
the config item is skipped no matter where the target actually points.<br>
If the target exists as a file or a directory, it does nothing.<br>
This behavious is sometimes confusing; for example, if /run has been<br>
created by other recipes, it will not be updated to a symlink as the<br>
config file states.<br>
<br>
This patch makes populate_volatile.sh do things as the config file<br>
tells it. As for link-type config items, it creates them properly<br>
with an effort to avoid data loss.<br>
<br>
Besides, it&#39;s not appropriate to divide volatile storage handling<br>
into two files. Operations for /tmp directory in bootmisc.sh should<br>
also be done by populate_volatile.sh.<br>
<br>
[YOCTO #3404]<br>
<br>
Signed-off-by: Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;<br>
---<br>
  .../initscripts/initscripts-1.<u></u>0/bootmisc.sh        |    7 -----<br>
  .../initscripts-1.0/populate-<u></u>volatile.sh           |   28 +++++++++-----------<br>
  .../initscripts/initscripts-1.<u></u>0/volatiles          |    1 +<br>
  meta/recipes-core/initscripts/<a href="http://initscripts_1.0.bb" target="_blank"><u></u>initscripts_1.0.bb</a>   |    2 +-<br>
  4 files changed, 15 insertions(+), 23 deletions(-)<br>
<br>
diff --git a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>bootmisc.sh b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>bootmisc.sh<br>
index 4f76cb4..80f7ead 100755<br>
--- a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>bootmisc.sh<br>
+++ b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>bootmisc.sh<br>
@@ -54,13 +54,6 @@ fi<br>
<br>
  #<br>
  # This is as good a place as any for a sanity check<br>
-# /tmp should be a symlink to /var/tmp to cut down on the number<br>
-# of mounted ramdisks.<br>
-if test ! -L /tmp &amp;&amp; test -d /var/tmp<br>
-then<br>
-    rm -rf /tmp<br>
-    ln -sf /var/tmp /tmp<br>
-fi<br>
<br>
  # Set the system clock from hardware clock<br>
  # If the timestamp is more recent than the current time,<br>
diff --git a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>populate-volatile.sh b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>populate-volatile.sh<br>
index d2175d7..baee2ef 100755<br>
--- a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>populate-volatile.sh<br>
+++ b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>populate-volatile.sh<br>
@@ -47,15 +47,16 @@ mk_dir() {<br>
  }<br>
<br>
  link_file() {<br>
-    EXEC=&quot;test -e \&quot;$2\&quot; -o -L $2 || ln -s \&quot;$1\&quot; \&quot;$2\&quot; &gt;/dev/tty0 2&gt;&amp;1&quot;<br>
-<br>
-    test &quot;$VOLATILE_ENABLE_CACHE&quot; = yes &amp;&amp; echo &quot;    $EXEC&quot; &gt;&gt; /etc/volatile.cache.build<br>
-<br>
-    [ -e &quot;$2&quot; ] &amp;&amp; {<br>
-      echo &quot;Cannot create link over existing -${TNAME}-.&quot; &gt;&amp;2<br>
-    } || {<br>
-      eval $EXEC &amp;<br>
-    }<br>
+    EXEC=&quot;<br>
+    if [ -L \&quot;$2\&quot; ]; then<br>
+        rm -f \&quot;$2\&quot;;<br>
+    elif [ -d \&quot;$2\&quot; ]; then<br>
+        cp -rf \&quot;$2/*\&quot; \&quot;$1\&quot;;<br>
+        rm -rf \&quot;$2\&quot;;<br>
+    fi;<br>
+    ln -sf \&quot;$1\&quot; \&quot;$2\&quot; &quot;<br>
+        test &quot;$VOLATILE_ENABLE_CACHE&quot; = yes &amp;&amp; echo &quot;   $EXEC&quot; &gt;&gt; /etc/volatile.<br>
</blockquote>
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.<br>
<br>
Sau!<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        eval $EXEC &amp;<br>
  }<br>
<br>
  check_requirements() {<br>
@@ -119,20 +120,17 @@ apply_cfgfile() {<br>
      return 1<br>
      }<br>
<br>
-  cat ${CFGFILE} | grep -v &quot;^#&quot; | \<br>
+  cat ${CFGFILE} | grep -v &quot;^#&quot; | sed -e &#39;/^$/ d&#39; | \<br>
    while read LINE; do<br>
<br>
      eval `echo &quot;$LINE&quot; | sed -n &quot;s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p&quot;`<br>
<br>
      [ &quot;${VERBOSE}&quot; != &quot;no&quot; ] &amp;&amp; echo &quot;Checking for -${TNAME}-.&quot;<br>
<br>
-<br>
      [ &quot;${TTYPE}&quot; = &quot;l&quot; ] &amp;&amp; {<br>
        TSOURCE=&quot;$TLTARGET&quot;<br>
-      [ -L &quot;${TNAME}&quot; ] || {<br>
-        [ &quot;${VERBOSE}&quot; != &quot;no&quot; ] &amp;&amp; echo &quot;Creating link -${TNAME}- pointing to -${TSOURCE}-.&quot;<br>
-        link_file &quot;${TSOURCE}&quot; &quot;${TNAME}&quot; &amp;<br>
-        }<br>
+      [ &quot;${VERBOSE}&quot; != &quot;no&quot; ] &amp;&amp; echo &quot;Creating link -${TNAME}- pointing to -${TSOURCE}-.&quot;<br>
+      link_file &quot;${TSOURCE}&quot; &quot;${TNAME}&quot; &amp;<br>
        continue<br>
        }<br>
<br>
diff --git a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>volatiles b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>volatiles<br>
index e0741aa..f7e2ef7 100644<br>
--- a/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>volatiles<br>
+++ b/meta/recipes-core/<u></u>initscripts/initscripts-1.0/<u></u>volatiles<br>
@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock<br>
  l root root 0755 /var/log /var/volatile/log<br>
  l root root 0755 /var/run /var/volatile/run<br>
  l root root 1777 /var/tmp /var/volatile/tmp<br>
+l root root 1777 /tmp /var/tmp<br>
  d root root 0755 /var/lock/subsys none<br>
  f root root 0664 /var/log/wtmp none<br>
  f root root 0664 /var/run/utmp none<br>
diff --git a/meta/recipes-core/<u></u>initscripts/<a href="http://initscripts_1.0.bb" target="_blank">initscripts_1.0.bb</a> b/meta/recipes-core/<u></u>initscripts/<a href="http://initscripts_1.0.bb" target="_blank">initscripts_1.0.bb</a><br>

index d25838b..251dd06 100644<br>
--- a/meta/recipes-core/<u></u>initscripts/<a href="http://initscripts_1.0.bb" target="_blank">initscripts_1.0.bb</a><br>
+++ b/meta/recipes-core/<u></u>initscripts/<a href="http://initscripts_1.0.bb" target="_blank">initscripts_1.0.bb</a><br>
@@ -3,7 +3,7 @@ DESCRIPTION = &quot;Initscripts provide the basic system startup initialization scrip<br>
  SECTION = &quot;base&quot;<br>
  LICENSE = &quot;GPLv2&quot;<br>
  LIC_FILES_CHKSUM = &quot;file://COPYING;md5=<u></u>751419260aa954499f7abaabaa882b<u></u>be&quot;<br>
-PR = &quot;r137&quot;<br>
+PR = &quot;r138&quot;<br>
<br>
  INHIBIT_DEFAULT_DEPS = &quot;1&quot;<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div></div>
Hi Saul:<br>
<br>
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.<br>

<br>
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.<br></blockquote><div><br></div><div>
I think it ought to ERROR in case it is not writable; and then work on a fix for it. In fact it doesn&#39;t work now so it ought to &quot;document&quot; it during boot and then a fix for it can be done.</div><div> </div></div>
-- <br>Otavio Salvador                             O.S. Systems<br>E-mail: <a href="mailto:otavio@ossystems.com.br" target="_blank">otavio@ossystems.com.br</a>  <a href="http://www.ossystems.com.br" target="_blank">http://www.ossystems.com.br</a><br>
Mobile: +55 53 9981-7854              <a href="http://projetos.ossystems.com.br" target="_blank">http://projetos.ossystems.com.br</a><br><br>