Allow mounting all volumes per device
This commit is contained in:
parent
8a86edb5bb
commit
b3b821a868
1 changed files with 32 additions and 24 deletions
|
|
@ -153,7 +153,7 @@ def cleanup_transfer(dest_path):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
def find_core_storage_volumes():
|
||||
def find_core_storage_volumes(device_path=None):
|
||||
"""Try to create block devices for any Apple CoreStorage volumes."""
|
||||
corestorage_uuid = '53746f72-6167-11aa-aa11-00306543ecac'
|
||||
dmsetup_cmd_file = '{TmpDir}/dmsetup_command'.format(**global_vars)
|
||||
|
|
@ -162,6 +162,8 @@ def find_core_storage_volumes():
|
|||
cmd = [
|
||||
'lsblk', '--json', '--list', '--paths',
|
||||
'--output', 'NAME,PARTTYPE']
|
||||
if device_path:
|
||||
cmd.append(device_path)
|
||||
result = run_program(cmd)
|
||||
json_data = json.loads(result.stdout.decode())
|
||||
devs = json_data.get('blockdevices', [])
|
||||
|
|
@ -248,7 +250,9 @@ def get_mounted_volumes():
|
|||
mounted_volumes.extend(item.get('children', []))
|
||||
return {item['source']: item for item in mounted_volumes}
|
||||
|
||||
def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
||||
def mount_volumes(
|
||||
all_devices=True, device_path=None,
|
||||
read_write=False, core_storage=True):
|
||||
"""Mount all detected filesystems."""
|
||||
report = {}
|
||||
cmd = [
|
||||
|
|
@ -257,9 +261,10 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
|||
if not all_devices and device_path:
|
||||
# Only mount volumes for specific device
|
||||
cmd.append(device_path)
|
||||
else:
|
||||
|
||||
# Check for Apple CoreStorage volumes first
|
||||
find_core_storage_volumes()
|
||||
if core_storage:
|
||||
find_core_storage_volumes(device_path)
|
||||
|
||||
# Get list of block devices
|
||||
result = run_program(cmd)
|
||||
|
|
@ -269,7 +274,10 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
|||
# Get list of volumes
|
||||
volumes = {}
|
||||
for dev in devs:
|
||||
if not dev.get('children', []):
|
||||
volumes.update({dev['name']: dev})
|
||||
for child in dev.get('children', []):
|
||||
if not child.get('children', []):
|
||||
volumes.update({child['name']: child})
|
||||
for grandchild in child.get('children', []):
|
||||
volumes.update({grandchild['name']: grandchild})
|
||||
|
|
@ -416,7 +424,7 @@ def run_fast_copy(items, dest):
|
|||
raise Exception
|
||||
|
||||
cmd = [global_vars['Tools']['FastCopy'], *FAST_COPY_ARGS]
|
||||
cmd.append(r'/logfile={}\FastCopy.log'.format(global_vars['LogDir']))
|
||||
cmd.append(r'/logfile={LogDir}\Tools\FastCopy.log'.format(**global_vars))
|
||||
cmd.extend(items)
|
||||
cmd.append('/to={}\\'.format(dest))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue