Allow mounting of protected macOS partitions
Renamed mount_volumes() to mount_disk() to better match diskutil naming. Dropped read_write from mount_disk() since it isn't used
This commit is contained in:
parent
7c1a9f4bdc
commit
207c52663b
2 changed files with 18 additions and 7 deletions
|
|
@ -1394,7 +1394,7 @@ def ost_generate_volume_report(dev):
|
||||||
|
|
||||||
# OS Check
|
# OS Check
|
||||||
if PLATFORM == 'Darwin':
|
if PLATFORM == 'Darwin':
|
||||||
vol_report = wk_os.mac.mount_volumes(
|
vol_report = wk_os.mac.mount_disk(
|
||||||
device_path=dev.path,
|
device_path=dev.path,
|
||||||
read_write=False,
|
read_write=False,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ def get_apfs_volumes(device_path):
|
||||||
# Add volumes
|
# Add volumes
|
||||||
for container in containers:
|
for container in containers:
|
||||||
for volume in container['Volumes']:
|
for volume in container['Volumes']:
|
||||||
|
mount_volume(volume['DeviceIdentifier'])
|
||||||
volumes.append(Disk(f'/dev/{volume["DeviceIdentifier"]}'))
|
volumes.append(Disk(f'/dev/{volume["DeviceIdentifier"]}'))
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
|
@ -125,15 +126,29 @@ def get_core_storage_volumes(device_path):
|
||||||
continue
|
continue
|
||||||
if 'Partitions' in disk_data:
|
if 'Partitions' in disk_data:
|
||||||
for part in disk_data['Partitions']:
|
for part in disk_data['Partitions']:
|
||||||
|
mount_volume(part['DeviceIdentifier'])
|
||||||
volumes.append(Disk(f'/dev/{part["DeviceIdentifier"]}'))
|
volumes.append(Disk(f'/dev/{part["DeviceIdentifier"]}'))
|
||||||
elif 'VolumeName' in disk_data:
|
elif 'VolumeName' in disk_data:
|
||||||
|
mount_volume(disk_data['DeviceIdentifier'])
|
||||||
volumes.append(Disk(f'/dev/{disk_data["DeviceIdentifier"]}'))
|
volumes.append(Disk(f'/dev/{disk_data["DeviceIdentifier"]}'))
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
|
|
||||||
def mount_volumes(device_path=None, read_write=False):
|
def mount_volume(volume_path, read_only=True):
|
||||||
|
"""Try to mount a volume, returns subprocess.CompletedProcess."""
|
||||||
|
cmd = ['sudo', 'diskutil', 'mount']
|
||||||
|
if read_only:
|
||||||
|
cmd.append('readOnly')
|
||||||
|
cmd.append(volume_path)
|
||||||
|
proc = run_program(cmd, check=False)
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return proc
|
||||||
|
|
||||||
|
|
||||||
|
def mount_disk(device_path=None):
|
||||||
"""Mount all detected volumes, returns list.
|
"""Mount all detected volumes, returns list.
|
||||||
|
|
||||||
NOTE: If device_path is specified then only volumes
|
NOTE: If device_path is specified then only volumes
|
||||||
|
|
@ -160,11 +175,7 @@ def mount_volumes(device_path=None, read_write=False):
|
||||||
|
|
||||||
# Mount and add volumes
|
# Mount and add volumes
|
||||||
for part in plist_data['AllDisksAndPartitions'][0]['Partitions']:
|
for part in plist_data['AllDisksAndPartitions'][0]['Partitions']:
|
||||||
cmd = ['diskutil', 'mount', 'readOnly', part['DeviceIdentifier']]
|
proc = mount_volume(part['DeviceIdentifier'])
|
||||||
if read_write:
|
|
||||||
# NOTE: Unused 2021-03
|
|
||||||
cmd.pop(2)
|
|
||||||
proc = run_program(cmd, check=False)
|
|
||||||
|
|
||||||
# Add volume
|
# Add volume
|
||||||
volumes.append(Disk(f'/dev/{part["DeviceIdentifier"]}'))
|
volumes.append(Disk(f'/dev/{part["DeviceIdentifier"]}'))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue