Re-introduce code that identifies already-mounted rootfs

This commit is contained in:
Carl D. Roth
2016-07-22 13:39:13 -07:00
parent b1b0b218fd
commit 551eb28d33

View File

@@ -41,18 +41,19 @@ class MountManager(object):
def mount(self, device, directory, mode='r', timeout=5):
mountargs = [ str(mode) ]
current = self.is_mounted(device, directory)
if current:
currentItems = [x for x in self.mounts.iteritems() if x[1]['dev'] == device]
if currentItems:
currentDirectory, current = currentItems[0]
if current['mode'] == mode:
# Already mounted as requested.
self.logger.debug("%s already mounted @ %s with mode %s. Doing nothing." % (device, directory, mode))
return True
elif device == current['dir']:
elif directory != currentDirectory:
# Already mounted, at a different location (e.g. '/'), but not in the requested mode.
self.logger.debug("%s mounted @ %s (%s) with mode %s. It will be remounted %s.",
device, directory, current['dir'], current['mode'], mode)
device, directory, currentDirectory, current['mode'], mode)
mountargs.append('remount')
directory = current['dir']
directory = currentDirectory
else:
# Already mounted, but not in the requested mode.
self.logger.debug("%s mounted @ %s with mode %s. It will be remounted %s." % (device, directory, current['mode'], mode))