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

Submitted by Maciej Borzecki on July 21, 2014, 9:34 p.m.

Details

Message ID 1405978453-16554-1-git-send-email-maciej.borzecki@open-rnd.pl
State New
Headers show

Commit Message

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(-)

Patch hide | download patch | download mbox

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

Comments

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.