Patchwork [1/2] wic: original fstab restored too early

login
register
mail settings
Submitter Maciej Borzecki
Date July 21, 2014, 9:34 p.m.
Message ID <1405978453-16554-1-git-send-email-maciej.borzecki@open-rnd.pl>
Download mbox | patch
Permalink /patch/76219/
State New
Headers show

Comments

Maciej Borzecki - July 21, 2014, 9:34 p.m.
Contents of /etc/fstab were restored too early, thus overwriting the
autogenerated ones.

Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
---
 scripts/lib/mic/imager/direct.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Tom Zanussi - July 23, 2014, 7:21 p.m.
Sorry, I'm not seeing how this fixes the problem (best would be to
explain that in the patch description too), or for that matter, how to
reproduce the problem.  Could you elaborate?

Tom

On Mon, 2014-07-21 at 23:34 +0200, Maciej Borzecki wrote:
> Contents of /etc/fstab were restored too early, thus overwriting the
> autogenerated ones.
> 
> Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
> Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
> ---
>  scripts/lib/mic/imager/direct.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/mic/imager/direct.py b/scripts/lib/mic/imager/direct.py
> index 2cf4c8d..beae372 100644
> --- a/scripts/lib/mic/imager/direct.py
> +++ b/scripts/lib/mic/imager/direct.py
> @@ -266,7 +266,6 @@ class DirectImageCreator(BaseImageCreator):
>                        self.bootimg_dir, self.kernel_dir, self.native_sysroot)
>  
>              fstab = self.__write_fstab(p.get_rootfs())
> -            self._restore_fstab(fstab)
>  
>              self.__instimage.add_partition(int(p.size),
>                                             p.disk,
> @@ -278,6 +277,9 @@ class DirectImageCreator(BaseImageCreator):
>                                             boot = p.active,
>                                             align = p.align,
>                                             part_type = p.part_type)
> +
> +            self._restore_fstab(fstab)
> +
>          self.__instimage.layout_partitions(self._ptable_format)
>  
>          self.__imgdir = self.workdir
Maciej Borzecki - July 23, 2014, 7:37 p.m.
On ?ro, 2014-07-23 at 14:21 -0500, Tom Zanussi wrote:
> Sorry, I'm not seeing how this fixes the problem (best would be to
> explain that in the patch description too), or for that matter, how to
> reproduce the problem.  Could you elaborate?

Right, the wording might be unfortunate and not reflect what actually
happens behind the scenes.

DirectImageCreator.__write_fstab() generates new /etc/fstab in sysroot.
The contents are the original entries in /etc/fstab + the partitions
listed in *.wks (skipping / and /boot). A backup of the
original /etc/fstab is made in temp.

A counterpart call to DirectImageCreator.__restore_fstab() brings back
the original version into sysroot, so that the whole process does not
leave any files in the original tree.

The problem is that calling __restore_fstab() before
__instimage.add_partition() brings back the original fstab before the
partition file actually is built. As such, any extra partitions listed
in *.wks never make it to /etc/fstab. 

For instance I add an extra user data partition like this:

part /media/data --ondisk mmcblk0p --fstype=vfat --label data --...

will not be reflected in /etc/fstab and not mounted when system is
brought up. The patch resolves this problem.

Patch

diff --git a/scripts/lib/mic/imager/direct.py b/scripts/lib/mic/imager/direct.py
index 2cf4c8d..beae372 100644
--- a/scripts/lib/mic/imager/direct.py
+++ b/scripts/lib/mic/imager/direct.py
@@ -266,7 +266,6 @@  class DirectImageCreator(BaseImageCreator):
                       self.bootimg_dir, self.kernel_dir, self.native_sysroot)
 
             fstab = self.__write_fstab(p.get_rootfs())
-            self._restore_fstab(fstab)
 
             self.__instimage.add_partition(int(p.size),
                                            p.disk,
@@ -278,6 +277,9 @@  class DirectImageCreator(BaseImageCreator):
                                            boot = p.active,
                                            align = p.align,
                                            part_type = p.part_type)
+
+            self._restore_fstab(fstab)
+
         self.__instimage.layout_partitions(self._ptable_format)
 
         self.__imgdir = self.workdir