Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umount the device first during mount_usb_storage() (#1587) (BugFix) #1599

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions checkbox-support/checkbox_support/scripts/usb_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +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.
Expand Down
Loading