fix for SD card reading bug

This commit is contained in:
Peter D. Gray 2024-02-16 11:12:43 -05:00
parent a251f16ae7
commit c225e168bf
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
2 changed files with 11 additions and 6 deletions

View File

@ -242,6 +242,10 @@ class CardSlot:
self.mountpt = glob.VD.mount(self.readonly)
return self
if not self.is_inserted():
# bugfix on Q: #618
raise CardMissingError
# Get ready!
self.active_led.on()
@ -268,7 +272,7 @@ class CardSlot:
if self.mountpt == self.get_sd_root():
self._recover()
elif glob.VD:
glob.VD.unmount(self.wrote_files)
glob.VD.unmount(self.wrote_files, self.readonly)
self.mountpt = None

View File

@ -38,7 +38,7 @@ class VirtDisk:
VBLKDEV.callback(None)
glob.VD = None
def unmount(self, written_files):
def unmount(self, written_files, readonly=False):
# just unmount; ignore errors
try:
os.umount('/vdisk')
@ -51,9 +51,10 @@ class VirtDisk:
self.ignore.add(fn)
# allow host to change again
enable_usb()
if glob.VD:
VBLKDEV.set_inserted(True)
if not readonly:
enable_usb()
if glob.VD:
VBLKDEV.set_inserted(True)
def mount(self, readonly=False):
# Prepare to read the filesystem. Block host. Return mount pt.
@ -69,7 +70,7 @@ class VirtDisk:
try:
if not readonly:
disable_usb()
VBLKDEV.set_inserted(False)
VBLKDEV.set_inserted(False)
os.mount(VBLKDEV, '/vdisk', readonly=readonly)
st = os.statvfs('/vdisk')