Remove redundant ATA prefix from the model number.

We already determine the bus type,
ATA, USB, NVME, VIRT (loop) etc
and display the bus type on the GUI.
libparted prefixes the model number
with ATA which we don't need, especially
as we try to keep the drive display length
to a maximum of 80 characters.
This commit is contained in:
PartialVolume
2020-04-08 17:05:06 +01:00
parent 5aded13bf7
commit fcd35ea910
2 changed files with 20 additions and 0 deletions

View File

@@ -206,6 +206,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
/* Get device information */
next_device->device_model = dev->model;
remove_ATA_prefix( next_device->device_model );
next_device->device_name = dev->path;
next_device->device_size = dev->length * dev->sector_size;
Determine_C_B_nomenclature( next_device->device_size, next_device->device_size_txt, NWIPE_DEVICE_SIZE_TXT_LENGTH );
@@ -683,3 +684,21 @@ void strip_CR_LF( char* str )
idx++;
}
}
void remove_ATA_prefix( char* str )
{
/* Remove "ATA " prefix if present in the model no. string, left justifing string */
int idx_pre = 4;
int idx_post = 0;
if( !strncmp( str, "ATA ", 4 ) )
{
while( str[idx_pre] != 0 )
{
str[idx_post++] = str[idx_pre++];
}
str[idx_post] = 0;
}
}

View File

@@ -29,5 +29,6 @@ int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames );
int nwipe_get_device_bus_type_and_serialno( char*, nwipe_device_t*, char* );
void strip_CR_LF( char* );
void determine_disk_capacity_nomenclature( u64, char* );
void remove_ATA_prefix( char* );
#endif /* DEVICE_H_ */