37
37
// Global Variables //
38
38
////////////////////////
39
39
const char * util_name = "openSeaChest_Format" ;
40
- const char * buildVersion = "3.3.2 " ;
40
+ const char * buildVersion = "3.4.0 " ;
41
41
42
42
////////////////////////////
43
43
// functions to declare //
@@ -104,6 +104,7 @@ int main(int argc, char* argv[])
104
104
SET_SECTOR_SIZE_VARS
105
105
SHOW_PHYSICAL_ELEMENT_STATUS_VAR
106
106
REMOVE_PHYSICAL_ELEMENT_VAR
107
+ REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_VAR
107
108
REPOPULATE_ELEMENTS_VAR
108
109
DEPOP_MAX_LBA_VAR
109
110
NVM_FORMAT_VARS
@@ -164,6 +165,7 @@ int main(int argc, char* argv[])
164
165
SHOW_SUPPORTED_FORMATS_LONG_OPT ,
165
166
SHOW_PHYSICAL_ELEMENT_STATUS_LONG_OPT ,
166
167
REMOVE_PHYSICAL_ELEMENT_LONG_OPT ,
168
+ REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_LONG_OPT ,
167
169
REPOPULATE_ELEMENTS_LONG_OPT ,
168
170
DEPOP_MAX_LBA_LONG_OPT ,
169
171
NVM_FORMAT_LONG_OPT ,
@@ -350,8 +352,7 @@ int main(int argc, char* argv[])
350
352
exit (UTIL_EXIT_ERROR_IN_COMMAND_LINE );
351
353
}
352
354
}
353
- else if (strcmp (longopts [optionIndex ].name , REMOVE_PHYSICAL_ELEMENT_LONG_OPT_STRING ) ==
354
- 0 ) // REMOVE_PHYSICAL_ELEMENT_LONG_OPT_STRING
355
+ else if (strcmp (longopts [optionIndex ].name , REMOVE_PHYSICAL_ELEMENT_LONG_OPT_STRING ) == 0 )
355
356
{
356
357
if (!get_And_Validate_Integer_Input_Uint32 (C_CAST (const char * , optarg ), M_NULLPTR , ALLOW_UNIT_NONE ,
357
358
& REMOVE_PHYSICAL_ELEMENT_FLAG ))
@@ -360,6 +361,15 @@ int main(int argc, char* argv[])
360
361
exit (UTIL_EXIT_ERROR_IN_COMMAND_LINE );
361
362
}
362
363
}
364
+ else if (strcmp (longopts [optionIndex ].name , REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_LONG_OPT_STRING ) == 0 )
365
+ {
366
+ if (!get_And_Validate_Integer_Input_Uint32 (C_CAST (const char * , optarg ), M_NULLPTR , ALLOW_UNIT_NONE ,
367
+ & REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG ))
368
+ {
369
+ print_Error_In_Cmd_Line_Args (REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_LONG_OPT_STRING , optarg );
370
+ exit (UTIL_EXIT_ERROR_IN_COMMAND_LINE );
371
+ }
372
+ }
363
373
else if (strcmp (longopts [optionIndex ].name , NVM_FORMAT_LONG_OPT_STRING ) == 0 )
364
374
{
365
375
NVM_FORMAT_FLAG = true;
@@ -881,7 +891,9 @@ int main(int argc, char* argv[])
881
891
// check for other tool specific options here
882
892
|| FORMAT_UNIT_FLAG || DISPLAY_LBA_FLAG || (PROGRESS_CHAR != M_NULLPTR ) || SHOW_FORMAT_STATUS_LOG_FLAG ||
883
893
SET_SECTOR_SIZE_FLAG || SHOW_SUPPORTED_FORMATS_FLAG || SHOW_PHYSICAL_ELEMENT_STATUS_FLAG ||
884
- REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REPOPULATE_ELEMENTS_FLAG || NVM_FORMAT_FLAG ))
894
+ REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REPOPULATE_ELEMENTS_FLAG || NVM_FORMAT_FLAG ||
895
+ REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG > 0
896
+ ))
885
897
{
886
898
utility_Usage (true);
887
899
free_Handle_List (& HANDLE_LIST , DEVICE_LIST_COUNT );
@@ -935,7 +947,8 @@ int main(int argc, char* argv[])
935
947
flags |= HANDLE_RECOMMEND_EXCLUSIVE_ACCESS ;
936
948
}
937
949
938
- if (SET_SECTOR_SIZE_FLAG || FAST_FORMAT_FLAG || REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REPOPULATE_ELEMENTS_FLAG )
950
+ if (SET_SECTOR_SIZE_FLAG || FAST_FORMAT_FLAG || REMOVE_PHYSICAL_ELEMENT_FLAG > 0 ||
951
+ REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG > 0 || REPOPULATE_ELEMENTS_FLAG )
939
952
{
940
953
flags |= HANDLE_REQUIRE_EXCLUSIVE_ACCESS ;
941
954
}
@@ -1056,8 +1069,8 @@ int main(int argc, char* argv[])
1056
1069
}
1057
1070
free_Handle_List (& HANDLE_LIST , DEVICE_LIST_COUNT );
1058
1071
1059
- if (SET_SECTOR_SIZE_FLAG || REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REPOPULATE_ELEMENTS_FLAG ||
1060
- (FORMAT_UNIT_FLAG && FAST_FORMAT_FLAG ))
1072
+ if (SET_SECTOR_SIZE_FLAG || REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG > 0 ||
1073
+ REPOPULATE_ELEMENTS_FLAG || (FORMAT_UNIT_FLAG && FAST_FORMAT_FLAG ))
1061
1074
{
1062
1075
// These options all do a low-level format that has a risk of leaving the drive inoperable if it is interrupted.
1063
1076
// Warn the user one last time and provide 30 seconds to cancel the operation
@@ -1403,16 +1416,19 @@ int main(int argc, char* argv[])
1403
1416
ptrPhysicalElement elementList = M_REINTERPRET_CAST (
1404
1417
ptrPhysicalElement , safe_malloc (numberOfDescriptors * sizeof (physicalElement )));
1405
1418
uint32_t depopElementID = UINT32_C (0 );
1406
- uint16_t maxDepop = UINT16_C (0 );
1407
- uint16_t currentDepop = UINT16_C (0 );
1419
+ uint16_t maxDepop = UINT16_C (0 );
1420
+ uint16_t currentDepop = UINT16_C (0 );
1408
1421
if (elementList )
1409
1422
{
1410
1423
safe_memset (elementList , numberOfDescriptors * sizeof (physicalElement ), 0 ,
1411
1424
numberOfDescriptors * sizeof (physicalElement ));
1412
- if (SUCCESS ==
1413
- get_Physical_Element_Descriptors_2 (& deviceList [deviceIter ], numberOfDescriptors , & depopElementID , & maxDepop , & currentDepop , elementList ))
1425
+ if (SUCCESS == get_Physical_Element_Descriptors_2 (& deviceList [deviceIter ], numberOfDescriptors ,
1426
+ & depopElementID , & maxDepop , & currentDepop ,
1427
+ elementList ))
1414
1428
{
1415
- show_Physical_Element_Descriptors_2 (numberOfDescriptors , elementList , depopTime , depopElementID , maxDepop , currentDepop );
1429
+ printf ("Depop time (Dec/Hex): %" PRIu64 "/%" PRIX64 "h\n" , depopTime , depopTime );
1430
+ show_Physical_Element_Descriptors_2 (numberOfDescriptors , elementList , depopTime ,
1431
+ depopElementID , maxDepop , currentDepop );
1416
1432
}
1417
1433
else
1418
1434
{
@@ -1733,32 +1749,60 @@ int main(int argc, char* argv[])
1733
1749
}
1734
1750
}
1735
1751
1736
- if (REMOVE_PHYSICAL_ELEMENT_FLAG > 0 )
1752
+ if (REMOVE_PHYSICAL_ELEMENT_FLAG > 0 || REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG > 0 )
1737
1753
{
1738
1754
if (LOW_LEVEL_FORMAT_FLAG )
1739
1755
{
1740
1756
bool depopSupport = is_Depopulation_Feature_Supported (& deviceList [deviceIter ], M_NULLPTR );
1741
1757
if (depopSupport )
1742
1758
{
1743
- switch (perform_Depopulate_Physical_Element (& deviceList [deviceIter ], REMOVE_PHYSICAL_ELEMENT_FLAG ,
1744
- DEPOP_MAX_LBA_FLAG , POLL_FLAG ))
1759
+ bool modifyZones = false;
1760
+ uint32_t elementID = REMOVE_PHYSICAL_ELEMENT_FLAG ;
1761
+ if (REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG > 0 )
1762
+ {
1763
+ elementID = REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_FLAG ;
1764
+ modifyZones = true;
1765
+ }
1766
+ switch (perform_Depopulate_Physical_Element2 (& deviceList [deviceIter ], elementID , DEPOP_MAX_LBA_FLAG ,
1767
+ POLL_FLAG , modifyZones ))
1745
1768
{
1746
1769
case SUCCESS :
1747
1770
if (VERBOSITY_QUIET < toolVerbosity )
1748
1771
{
1749
1772
if (POLL_FLAG )
1750
1773
{
1751
- printf ("Successfully depopulated physical element %" PRIu32 "!\n" ,
1752
- REMOVE_PHYSICAL_ELEMENT_FLAG );
1774
+ if (modifyZones )
1775
+ {
1776
+ printf ("Successfully depopulated physical element %" PRIu32
1777
+ " and modified zones!\n" ,
1778
+ elementID );
1779
+ }
1780
+ else
1781
+ {
1782
+ printf ("Successfully depopulated physical element %" PRIu32 "!\n" , elementID );
1783
+ }
1753
1784
}
1754
1785
else
1755
1786
{
1756
- printf ("Successfully started depopulation for physical element %" PRIu32 "!\n" ,
1757
- REMOVE_PHYSICAL_ELEMENT_FLAG );
1758
- printf ("The device may take a long time before it is ready to accept all commands "
1759
- "again.\n" );
1760
- printf ("Use \"--%s depop\" or \"--%s\" to check progress.\n" , PROGRESS_LONG_OPT_STRING ,
1761
- SHOW_PHYSICAL_ELEMENT_STATUS_LONG_OPT_STRING );
1787
+ if (modifyZones )
1788
+ {
1789
+ printf ("Successfully started depopulation for physical element %" PRIu32
1790
+ " and modifying zones!\n" ,
1791
+ elementID );
1792
+ printf ("The device may take a long time before it is ready to accept all commands "
1793
+ "again.\n" );
1794
+ printf ("Use \"--%s depop\" or \"--%s\" to check progress.\n" ,
1795
+ PROGRESS_LONG_OPT_STRING , SHOW_PHYSICAL_ELEMENT_STATUS_LONG_OPT_STRING );
1796
+ }
1797
+ else
1798
+ {
1799
+ printf ("Successfully started depopulation for physical element %" PRIu32 "!\n" ,
1800
+ elementID );
1801
+ printf ("The device may take a long time before it is ready to accept all commands "
1802
+ "again.\n" );
1803
+ printf ("Use \"--%s depop\" or \"--%s\" to check progress.\n" ,
1804
+ PROGRESS_LONG_OPT_STRING , SHOW_PHYSICAL_ELEMENT_STATUS_LONG_OPT_STRING );
1805
+ }
1762
1806
}
1763
1807
if (deviceList [deviceIter ].drive_info .numberOfLUs > 1 )
1764
1808
{
@@ -1784,7 +1828,7 @@ int main(int argc, char* argv[])
1784
1828
default :
1785
1829
if (VERBOSITY_QUIET < toolVerbosity )
1786
1830
{
1787
- printf ("Failed to depopulate element %" PRIu32 ".\n" , REMOVE_PHYSICAL_ELEMENT_FLAG );
1831
+ printf ("Failed to depopulate element %" PRIu32 ".\n" , elementID );
1788
1832
}
1789
1833
exitCode = UTIL_EXIT_OPERATION_FAILURE ;
1790
1834
break ;
@@ -2145,6 +2189,7 @@ void utility_Usage(bool shortUsage)
2145
2189
printf ("\t%s -d %s --%s\n" , util_name , deviceHandleExample , LOWLEVEL_INFO_LONG_OPT_STRING );
2146
2190
printf ("\t%s -d %s --%s\n" , util_name , deviceHandleExample , SHOW_PHYSICAL_ELEMENT_STATUS_LONG_OPT_STRING );
2147
2191
printf ("\t%s -d %s --%s 2\n" , util_name , deviceHandleExample , REMOVE_PHYSICAL_ELEMENT_LONG_OPT_STRING );
2192
+ printf ("\t%s -d %s --%s 2\n" , util_name , deviceHandleExample , REMOVE_PHYSICAL_ELEMENT_MOD_ZONES_LONG_OPT_STRING );
2148
2193
printf ("\t%s -d %s --%s\n" , util_name , deviceHandleExample , REPOPULATE_ELEMENTS_LONG_OPT_STRING );
2149
2194
printf ("\t%s -d %s --%s\n" , util_name , deviceHandleExample , SHOW_SUPPORTED_FORMATS_LONG_OPT_STRING );
2150
2195
printf ("\t%s -d %s --%s\n" , util_name , deviceHandleExample , SHOW_FORMAT_STATUS_LOG_LONG_OPT_STRING );
@@ -2233,6 +2278,7 @@ void utility_Usage(bool shortUsage)
2233
2278
// utility data destructive tests/operations go here
2234
2279
print_Pattern_Help (shortUsage );
2235
2280
print_Remove_Physical_Element_Status_Help (shortUsage );
2281
+ print_Remove_Physical_Element_And_Modify_Zones_Help (shortUsage );
2236
2282
print_Repopulate_Elements_Help (shortUsage );
2237
2283
print_Set_Sector_Size_Help (shortUsage );
2238
2284
printf ("\n\tSAS Only:\n\t=========\n" );
0 commit comments