diff --git a/shared/files.py b/shared/files.py index 407f7219..e3e5de00 100644 --- a/shared/files.py +++ b/shared/files.py @@ -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 diff --git a/shared/vdisk.py b/shared/vdisk.py index fb32dbae..8b4fcab4 100644 --- a/shared/vdisk.py +++ b/shared/vdisk.py @@ -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')