Commits

Michał Górny  committed beea8be

Handle mount and unmount errors explicitly and sanely.

  • Participants
  • Parent commits 7ba8924

Comments (0)

Files changed (1)

File ecleankernel/cli.py

 from optparse import OptionParser
 
 from .bootloader import bootloaders, get_bootloader
-from .kernel import find_kernels, Kernel
+from .kernel import find_kernels, Kernel, ReadAccessError, WriteAccessError
 from .process import get_removal_list
 
 ecleankern_desc = '''
 	def umount(self):
 		pass
 
+class MountError(Exception):
+	def __init__(self):
+		Exception.__init__(self, 'Unable to mount /boot')
+
 class NullDebugger(object):
 	def __init__(self):
 		self._indent = 1
 		if opts.mount:
 			bootfs = pymountboot.BootMountpoint()
 
-	bootfs.mount()
+	try:
+		bootfs.mount()
+	except RuntimeError:
+		raise MountError()
+
 	try:
 		kernels = find_kernels(exclusions = exclusions)
 
 
 		return 0
 	finally:
-		bootfs.umount()
+		try:
+			bootfs.umount()
+		except RuntimeError:
+			print('Note: unmounting /boot failed')