From 039d6742ea9c8ba48aa1f070cee1cf91c48da987 Mon Sep 17 00:00:00 2001 From: Jefferyyen Date: Wed, 13 Nov 2024 18:20:27 +0800 Subject: [PATCH 1/4] Umount the device first during mount_usb_storage() (Bugfix) (#1587) To prevent the inserted storage from failing to mount twice, first ensure it is unmounted. Because the OS will auto-mount the inserted storage, the existing subprocess.call(["mount", device_to_mount, FOLDER_TO_MOUNT]) command will cause an error if the format of inserted storage is NTFS. Perform an umount on device_to_mount (e.g., for the media card in #1587, it would be umount /dev/mmcblk0p1) before attempting to mount it again to avoid this issue. --- checkbox-support/checkbox_support/scripts/usb_read_write.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/checkbox-support/checkbox_support/scripts/usb_read_write.py b/checkbox-support/checkbox_support/scripts/usb_read_write.py index 0668e8f10d..67f7906a36 100644 --- a/checkbox-support/checkbox_support/scripts/usb_read_write.py +++ b/checkbox-support/checkbox_support/scripts/usb_read_write.py @@ -170,6 +170,8 @@ def mount_usb_storage(partition): # use pipe so I could hide message like # "umount: /tmp/tmpjzwb6lys: not mounted" subprocess.call(["umount", FOLDER_TO_MOUNT], stderr=subprocess.PIPE) + # umount device_to_mount such as "umount /dev/mmcblk0p1" to avoid when the storage type is ntfs, which could not be mounted twice. + subprocess.call(["umount", device_to_mount], stderr=subprocess.PIPE) # mount the target device/partition # if the return code of the shell command is non-zero, # means something wrong. From eb9b90e2070c4d416b9e1fa8ac637e469f0b3736 Mon Sep 17 00:00:00 2001 From: Jefferyyen Date: Tue, 26 Nov 2024 11:44:32 +0800 Subject: [PATCH 2/4] Update usb_read_write.py --- checkbox-support/checkbox_support/scripts/usb_read_write.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/checkbox-support/checkbox_support/scripts/usb_read_write.py b/checkbox-support/checkbox_support/scripts/usb_read_write.py index 67f7906a36..f526354d47 100644 --- a/checkbox-support/checkbox_support/scripts/usb_read_write.py +++ b/checkbox-support/checkbox_support/scripts/usb_read_write.py @@ -170,7 +170,9 @@ def mount_usb_storage(partition): # use pipe so I could hide message like # "umount: /tmp/tmpjzwb6lys: not mounted" subprocess.call(["umount", FOLDER_TO_MOUNT], stderr=subprocess.PIPE) - # umount device_to_mount such as "umount /dev/mmcblk0p1" to avoid when the storage type is ntfs, which could not be mounted twice. + # Unmounting the device (e.g., "/dev/mmcblk0p1") to ensure the storage + # device is fully detached. This prevents issues with certain + # filesystem types like NTFS, which cannot be mounted multiple times. subprocess.call(["umount", device_to_mount], stderr=subprocess.PIPE) # mount the target device/partition # if the return code of the shell command is non-zero, From 62bb3e58a9c860bc12cff8f5931f8a2caefd31b5 Mon Sep 17 00:00:00 2001 From: Jefferyyen Date: Tue, 26 Nov 2024 16:31:41 +0800 Subject: [PATCH 3/4] Update usb_read_write.py update the comment correctly --- checkbox-support/checkbox_support/scripts/usb_read_write.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/checkbox-support/checkbox_support/scripts/usb_read_write.py b/checkbox-support/checkbox_support/scripts/usb_read_write.py index f526354d47..0f2a4988c5 100644 --- a/checkbox-support/checkbox_support/scripts/usb_read_write.py +++ b/checkbox-support/checkbox_support/scripts/usb_read_write.py @@ -167,13 +167,15 @@ def mount_usb_storage(partition): try: device_to_mount = os.path.join("/dev", partition) - # use pipe so I could hide message like - # "umount: /tmp/tmpjzwb6lys: not mounted" + + # Unmounting the folder ignoring any "not mounted" error messages. subprocess.call(["umount", FOLDER_TO_MOUNT], stderr=subprocess.PIPE) + # Unmounting the device (e.g., "/dev/mmcblk0p1") to ensure the storage # device is fully detached. This prevents issues with certain # filesystem types like NTFS, which cannot be mounted multiple times. subprocess.call(["umount", device_to_mount], stderr=subprocess.PIPE) + # mount the target device/partition # if the return code of the shell command is non-zero, # means something wrong. From 1fca8a100f8459db5225fec1df71b345ee3f381b Mon Sep 17 00:00:00 2001 From: Jefferyyen Date: Tue, 26 Nov 2024 16:44:26 +0800 Subject: [PATCH 4/4] Update usb_read_write.py Correct the blank line --- checkbox-support/checkbox_support/scripts/usb_read_write.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkbox-support/checkbox_support/scripts/usb_read_write.py b/checkbox-support/checkbox_support/scripts/usb_read_write.py index 0f2a4988c5..3aa2aa4cc0 100644 --- a/checkbox-support/checkbox_support/scripts/usb_read_write.py +++ b/checkbox-support/checkbox_support/scripts/usb_read_write.py @@ -170,12 +170,12 @@ def mount_usb_storage(partition): # Unmounting the folder ignoring any "not mounted" error messages. subprocess.call(["umount", FOLDER_TO_MOUNT], stderr=subprocess.PIPE) - + # Unmounting the device (e.g., "/dev/mmcblk0p1") to ensure the storage # device is fully detached. This prevents issues with certain # filesystem types like NTFS, which cannot be mounted multiple times. subprocess.call(["umount", device_to_mount], stderr=subprocess.PIPE) - + # mount the target device/partition # if the return code of the shell command is non-zero, # means something wrong.