Adjusted safety checks in ddrescue-tui
* Added NVMe/SMART check for destination * Addresses issue #102
This commit is contained in:
parent
8c6fcfe99c
commit
f5d806a51a
1 changed files with 19 additions and 7 deletions
|
|
@ -290,10 +290,10 @@ class RecoveryState():
|
|||
if source.is_dir():
|
||||
raise GenericError('Invalid source "{}"'.format(
|
||||
source.path))
|
||||
elif not dest.is_dev():
|
||||
if not dest.is_dev():
|
||||
raise GenericError('Invalid destination "{}"'.format(
|
||||
dest.path))
|
||||
elif source.size > dest.size:
|
||||
if source.size > dest.size:
|
||||
raise GenericError(
|
||||
'Destination is too small, refusing to continue.')
|
||||
else:
|
||||
|
|
@ -301,13 +301,13 @@ class RecoveryState():
|
|||
if not source.is_dev():
|
||||
raise GenericError('Invalid source "{}"'.format(
|
||||
source.path))
|
||||
elif not dest.is_dir():
|
||||
if not dest.is_dir():
|
||||
raise GenericError('Invalid destination "{}"'.format(
|
||||
dest.path))
|
||||
elif (source.size * 1.2) > dest.size:
|
||||
if (source.size * 1.2) > dest.size:
|
||||
raise GenericError(
|
||||
'Not enough free space, refusing to continue.')
|
||||
elif dest.fstype.lower() not in RECOMMENDED_FSTYPES:
|
||||
if dest.fstype.lower() not in RECOMMENDED_FSTYPES:
|
||||
print_error(
|
||||
'Destination filesystem "{}" is not recommended.'.format(
|
||||
dest.fstype.upper()))
|
||||
|
|
@ -316,13 +316,25 @@ class RecoveryState():
|
|||
print_standard(' ')
|
||||
if not ask('Proceed anyways? (Strongly discouraged)'):
|
||||
raise GenericAbort()
|
||||
elif not is_writable_dir(dest):
|
||||
if not is_writable_dir(dest):
|
||||
raise GenericError(
|
||||
'Destination is not writable, refusing to continue.')
|
||||
elif not is_writable_filesystem(dest):
|
||||
if not is_writable_filesystem(dest):
|
||||
raise GenericError(
|
||||
'Destination is mounted read-only, refusing to continue.')
|
||||
|
||||
# Destination NVMe/SMART safety check
|
||||
if dest.is_dev():
|
||||
disk_obj = DiskObj(dest.path)
|
||||
if disk_obj.nvme_attributes or disk_obj.smart_attributes:
|
||||
if not disk_obj.check_attributes():
|
||||
raise GenericError(
|
||||
'NVMe/SMART issue detected on destination, refusing to continue.')
|
||||
else:
|
||||
print_warning('No NVMe or SMART data available for destination')
|
||||
if not ask('Proceed anyways?'):
|
||||
raise GenericAbort()
|
||||
|
||||
# Safety checks passed
|
||||
self.block_pairs.append(BlockPair(self.mode, source, dest))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue