Skip to content

Commit 2ca5170

Browse files
sdcard.py: fix mounting multiple times detection
1 parent 47b0f52 commit 2ca5170

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

internal_filesystem/lib/mpos/sdcard.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ def _try_mount(self, mount_point):
2121
print(f"SD card mounted successfully at {mount_point}")
2222
return True
2323
except OSError as e:
24-
print(f"WARNING: Failed to mount SD card at {mount_point}: {e}")
25-
print(" - Possible causes: Unformatted SD card (needs FAT32), corrupted filesystem, or card removed")
26-
print(f" - Check: SD card format, ensure card is inserted")
27-
print(" - Try: Format card on PC, or proceed to auto-format if enabled")
28-
return False
24+
if e.errno == errno.EPERM: # EPERM is 1, meaning already mounted
25+
print(f"Got mount error {e} which means already mounted.")
26+
return True
27+
else:
28+
print(f"WARNING: Failed to mount SD card at {mount_point}: {e}")
29+
print(" - Possible causes: Unformatted SD card (needs FAT32), corrupted filesystem, or card removed")
30+
print(f" - Check: SD card format, ensure card is inserted")
31+
print(" - Try: Format card on PC, or proceed to auto-format if enabled")
32+
return False
2933

3034
def _format(self, mount_point):
3135
try:

0 commit comments

Comments
 (0)