Jelajahi Sumber

swupdate-usb: update service to use mount points dynamically

swupdate-usb service uses a fixed mount point which caters block devices with one partition only.
If a device has multiple partitions swupdate-usb service launches for every partition and tries
to mount it at same mount point which is not a clean way. This also results in failures during
un-mounting even if the update is performed successfully.
This is due to the fact that when multiple partitons are mounted at same mount point,
it acts like a stack and with each un-mount the latest mounted partition is removed. An example
case is if a USB with 3 partitions are plugged in it launches services for all, say all partitions
are mounted in sequence as sda1, sda2 and sda3.
However, if only one partiton say sda2 contains the update image it will start update from it and
services for sda1 and sda3 will exit as no image is present in them. This will cause services for
sda1 and sda3 to run umount twice on /mnt/ but second partition in mounting sequence was sda2 which
is busy, and it would fail to un-mount. Now when swupdate-usb@sda2 will exit after update it will
run umount once and one partition will still be left mounted as corresponding umount for that
service failed.
This commit introduces a change that for every partiton a unique mount point is created, and when
done, that mount point is removed, this ensures no such conficts occur and every service uses a
mount point unique to the partiton against which service was launched.

This also replaces mount point 'mnt' with 'tmp' to guarantee writable mount-point in-case the
rootfs is read-only.

Signed-off-by: Muhammad Hamza muhammad_hamza@mentor.com<mailto:muhammad_hamza@mentor.com>
Signed-off-by: Stefano Babic <sbabic@denx.de>
Hamza, Muhammad 3 tahun lalu
induk
melakukan
c8358f2e0c
1 mengubah file dengan 5 tambahan dan 3 penghapusan
  1. 5 3
      recipes-support/swupdate/swupdate/swupdate-usb@.service

+ 5 - 3
recipes-support/swupdate/swupdate/swupdate-usb@.service

@@ -4,6 +4,8 @@ Requires=swupdate.service
 Requires=swupdate-progress.service
 
 [Service]
-ExecStartPre=/bin/mount /dev/%I /mnt
-ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu"
-ExecStopPost=/bin/umount /mnt
+ExecStartPre=/bin/mkdir -p /tmp/%I
+ExecStartPre=/bin/mount /dev/%I /tmp/%I
+ExecStart=/bin/sh -c "swupdate-client -v /tmp/%I/*.swu"
+ExecStopPost=/bin/umount /tmp/%I
+ExecStopPost=/bin/rmdir /tmp/%I