[OE-core] [PATCH] wic: Prevent duplicate entries on fstab
Fabio Berton
fabio.berton at ossystems.com.br
Thu Feb 23 18:13:09 UTC 2017
Add function to read fstab and return all mount points. This function
is useful to _update_fstab doesn't duplicate entries in /etc/fstab.
Signed-off-by: Fabio Berton <fabio.berton at ossystems.com.br>
---
scripts/lib/wic/plugins/imager/direct.py | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 481d24d5ba..570dbbbf79 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -97,6 +97,25 @@ class DirectPlugin(ImagerPlugin):
finally:
self.cleanup()
+ def _get_fstab_mountpoints(self):
+ """ Read file /etc/fstab and returns all mountpoints."""
+ image_rootfs = self.rootfs_dir.get("ROOTFS_DIR")
+ if not image_rootfs:
+ return
+
+ fstab_path = image_rootfs + "/etc/fstab"
+ if not os.path.isfile(fstab_path):
+ return
+
+ with open(fstab_path) as fp:
+ mp = []
+ for l in fp:
+ if not l.startswith("#"):
+ valid_mp = l.replace("\t", " ").split()
+ if len(valid_mp) >= 2:
+ mp.append(valid_mp[1])
+ return mp
+
def _write_fstab(self, image_rootfs):
"""overriden to generate fstab (temporarily) in rootfs. This is called
from _create, make sure it doesn't get called from
@@ -125,7 +144,7 @@ class DirectPlugin(ImagerPlugin):
updated = False
for part in parts:
if not part.realnum or not part.mountpoint \
- or part.mountpoint in ("/", "/boot"):
+ or part.mountpoint in self._get_fstab_mountpoints():
continue
# mmc device partitions are named mmcblk0p1, mmcblk0p2..
--
2.11.0
More information about the Openembedded-core
mailing list