mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-20 13:42:14 +00:00
HPA_DCO_010 Continuation of HPA/DCO integration.
The Seagate EXOS family of drives don't support the ATA drive configuration overlay (DCO) command, however they do support host protected area (HPA). Therefore these drives can have hidden sectors. The code was changed to accommodate the slightly different way these drives respond to a hdparm -N, that is, the response is accessible max address enabled or accessible max address disabled. The new code correctly determines a the status of a drive in regards to whether it has hidden sectors or not and what it's apparent and real size is.
This commit is contained in:
@@ -185,7 +185,7 @@ int hpa_dco_status( nwipe_context_t* ptr )
|
||||
|
||||
/* Scan the hdparm results for HPA is disabled
|
||||
*/
|
||||
if( strstr( result, "SG_IO: bad/missing sense data" ) != 0 )
|
||||
if( strstr( result, "sg_io: bad/missing sense data" ) != 0 )
|
||||
{
|
||||
c->HPA_status = HPA_UNKNOWN;
|
||||
nwipe_log( NWIPE_LOG_ERROR, "SG_IO bad/missing sense data %s", hdparm_cmd_get_hpa );
|
||||
@@ -203,6 +203,7 @@ int hpa_dco_status( nwipe_context_t* ptr )
|
||||
"says HPA is enabled. Further checks are conducted below..",
|
||||
c->device_name );
|
||||
hpa_line_found = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,32 +216,65 @@ int hpa_dco_status( nwipe_context_t* ptr )
|
||||
"and it says HPA is enabled. Further checks are conducted below..",
|
||||
c->device_name );
|
||||
hpa_line_found = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( strstr( result, "invalid" ) != 0 )
|
||||
if( strstr( result, "accessible max address disabled" ) != 0 )
|
||||
{
|
||||
c->HPA_status = HPA_ENABLED;
|
||||
nwipe_log( NWIPE_LOG_WARNING,
|
||||
"hdparm reports invalid output, sector information may be invalid, buggy "
|
||||
"drive firmware on %s?",
|
||||
c->HPA_status = HPA_DISABLED;
|
||||
nwipe_log( NWIPE_LOG_DEBUG,
|
||||
"hdparm says the accessible max address disabled on %s"
|
||||
"this means that there are no hidden sectors, "
|
||||
"",
|
||||
c->device_name );
|
||||
// We'll assume the HPA values are in the string as we may be able to extract something
|
||||
// meaningful
|
||||
hpa_line_found = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( strstr( result, "accessible max address enabled" ) != 0 )
|
||||
{
|
||||
c->HPA_status = HPA_ENABLED;
|
||||
nwipe_log( NWIPE_LOG_DEBUG,
|
||||
"hdparm says the accessible max address enabled on %s"
|
||||
"this means that there are hidden sectors",
|
||||
c->device_name );
|
||||
hpa_line_found = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( strstr( result, "invalid" ) != 0 )
|
||||
{
|
||||
c->HPA_status = HPA_ENABLED;
|
||||
nwipe_log(
|
||||
NWIPE_LOG_WARNING,
|
||||
"hdparm reports invalid output, sector information may be invalid, buggy "
|
||||
"drive firmware on %s?",
|
||||
c->device_name );
|
||||
// We'll assume the HPA values are in the string as we may be able to extract
|
||||
// something meaningful
|
||||
hpa_line_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if the line was found that contains hpa is enabled or disabled message
|
||||
* then process the line, extracting the 'hpa set' and 'hpa real' values.
|
||||
/* if the HPA line was found then process the line,
|
||||
* extracting the 'hpa set' and 'hpa real' values.
|
||||
*/
|
||||
if( hpa_line_found == 1 )
|
||||
{
|
||||
/* Extract the 'HPA set' value, the first value in the line and convert
|
||||
* to binary and save in context */
|
||||
|
||||
nwipe_log( NWIPE_LOG_INFO, "HPA: %s on %s", result, c->device_name );
|
||||
|
||||
c->HPA_reported_set = str_ascii_number_to_ll( result );
|
||||
|
||||
/* Extract the 'HPA real' value, the second value in the line and convert
|
||||
@@ -270,7 +304,7 @@ int hpa_dco_status( nwipe_context_t* ptr )
|
||||
{
|
||||
c->HPA_status = HPA_UNKNOWN;
|
||||
nwipe_log( NWIPE_LOG_WARNING,
|
||||
"[UNKNOWN] We can't find the HPA line, has hdparm ouput changed? %s",
|
||||
"[UNKNOWN] We can't find the HPA line, has hdparm ouput unknown/changed? %s",
|
||||
c->device_name );
|
||||
}
|
||||
|
||||
@@ -655,7 +689,7 @@ int hpa_dco_status( nwipe_context_t* ptr )
|
||||
c->HPA_size_text[0] = 0;
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_INFO,
|
||||
nwipe_log( NWIPE_LOG_DEBUG,
|
||||
"c->Calculated_real_max_size_in_bytes=%lli, c->device_size=%lli, c->device_sector_size=%lli, "
|
||||
"c->DCO_reported_real_max_size=%lli, c->HPA_sectors=%lli c->device_type=%i ",
|
||||
c->Calculated_real_max_size_in_bytes,
|
||||
|
||||
@@ -251,7 +251,6 @@ void convert_double_to_string( char* output_str, double value )
|
||||
char percstr[512] = "";
|
||||
|
||||
snprintf( percstr, sizeof( percstr ), "%5.32lf", value );
|
||||
printf( "percstr=%s%%", percstr );
|
||||
|
||||
while( percstr[idx] != 0 )
|
||||
{
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
* used by configure to dynamically assign those values
|
||||
* to documentation files.
|
||||
*/
|
||||
const char* version_string = "0.34.82 Development code, not for production use!";
|
||||
const char* version_string = "0.34.83 Development code, not for production use!";
|
||||
const char* program_name = "nwipe";
|
||||
const char* author_name = "Martijn van Brummelen";
|
||||
const char* email_address = "git@brumit.nl";
|
||||
const char* years = "2022";
|
||||
const char* years = "2023";
|
||||
const char* copyright = "Copyright Darik Horn <dajhorn-dban@vanadac.com>\n\
|
||||
Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
|
||||
This is free software; see the source for copying conditions.\n\
|
||||
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
|
||||
FOR A PARTICULAR PURPOSE.\n";
|
||||
const char* banner = "nwipe 0.34.82 Development code, not for production use!";
|
||||
const char* banner = "nwipe 0.34.83 Development code, not for production use!";
|
||||
|
||||
Reference in New Issue
Block a user