Skip to content

Commit dbf3a05

Browse files
committed
feat: Finish drive_info_cleanup
Finishing the changes necessary for improving how we read drive information on ATA and SCSI devices/translators. This includes working around issues where a command is not supported to respond to certain SCSI error codes better and avoid repeating commands that are not supported at all.
2 parents 30ef394 + 5824515 commit dbf3a05

20 files changed

+37
-27
lines changed

subprojects/opensea-common

subprojects/wingetopt

utils/C/openSeaChest/openSeaChest_Basics.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
////////////////////////
4040
const char *util_name = "openSeaChest_Basics";
4141

42-
const char *buildVersion = "3.6.0";
42+
const char *buildVersion = "3.6.1";
4343

4444
////////////////////////////
4545
// functions to declare //
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
6767
/////////////////
6868
//common utility variables
6969
int ret = SUCCESS;
70-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
70+
int exitCode = UTIL_EXIT_NO_ERROR;
7171
DEVICE_UTIL_VARS
7272
DEVICE_INFO_VAR
7373
SAT_INFO_VAR
@@ -1948,7 +1948,7 @@ int main(int argc, char *argv[])
19481948
if (DATA_ERASE_FLAG)
19491949
{
19501950
//check the time
1951-
uint64_t overwriteSeconds = SECONDS_TIME_FLAG + (MINUTES_TIME_FLAG * 60) + (HOURS_TIME_FLAG * 3600);
1951+
uint64_t overwriteSeconds = C_CAST(uint64_t, SECONDS_TIME_FLAG) + (C_CAST(uint64_t, MINUTES_TIME_FLAG) * UINT64_C(60)) + (C_CAST(uint64_t, HOURS_TIME_FLAG) * UINT64_C(3600));
19521952
//determine if it's timed or a range
19531953
if (overwriteSeconds == 0)
19541954
{

utils/C/openSeaChest/openSeaChest_Configure.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// Global Variables //
3535
////////////////////////
3636
const char *util_name = "openSeaChest_Configure";
37-
const char *buildVersion = "2.7.0";
37+
const char *buildVersion = "2.7.1";
3838

3939
////////////////////////////
4040
// functions to declare //
@@ -61,7 +61,7 @@ int32_t main(int argc, char *argv[])
6161
/////////////////
6262
//common utility variables
6363
int ret = SUCCESS;
64-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
64+
int exitCode = UTIL_EXIT_NO_ERROR;
6565
DEVICE_UTIL_VARS
6666
DEVICE_INFO_VAR
6767
SAT_INFO_VAR
@@ -3921,11 +3921,16 @@ int32_t main(int argc, char *argv[])
39213921
if (SUCCESS == get_SCSI_Mode_Page(&deviceList[deviceIter], MPC_CURRENT_VALUES, SCSI_SET_MP_PAGE_NUMBER, SCSI_SET_MP_SUBPAGE_NUMBER, NULL, NULL, true, rawmodePageBuffer, rawModePageSize, NULL, &usedSizeByteCmd))
39223922
{
39233923
uint32_t modeHeaderLen = usedSizeByteCmd ? MODE_PARAMETER_HEADER_6_LEN : MODE_PARAMETER_HEADER_10_LEN;
3924-
uint32_t blockDescriptorLength = (deviceList[deviceIter].drive_info.scsiVersion < SCSI_VERSION_SCSI2) ? SHORT_LBA_BLOCK_DESCRIPTOR_LEN : 0;//the get_SCSI_MP function will only pull a block descriptor on old drives for compatibility using mode sense 6 commands, which is why this check is minimal
3924+
uint32_t blockDescriptorLength = usedSizeByteCmd ? rawmodePageBuffer[2] : M_BytesTo2ByteValue(rawmodePageBuffer[6], rawmodePageBuffer[7]);
39253925
uint32_t dataLengthAdjustment = modeHeaderLen + blockDescriptorLength;
39263926
uint32_t modePageSize = rawModePageSize - dataLengthAdjustment;
39273927
uint8_t* modePageBuffer = rawmodePageBuffer + dataLengthAdjustment;
39283928
//TODO: some of this code can probably be simplified a bit more than it currently is.
3929+
if (blockDescriptorLength > 0)
3930+
{
3931+
//Before going too far, clear the block descriptor to zeroes to make sure we are clearly communicating that no changes are requested.
3932+
memset(&rawmodePageBuffer[modeHeaderLen], 0, blockDescriptorLength);
3933+
}
39293934
//now we have the data, we can begin modifying the field requested.
39303935
if (SCSI_SET_MP_FIELD_LEN_BITS % BITSPERBYTE)
39313936
{

utils/C/openSeaChest/openSeaChest_Erase.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int32_t main(int argc, char *argv[])
8080
/////////////////
8181
//common utility variables
8282
int ret = SUCCESS;
83-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
83+
int exitCode = UTIL_EXIT_NO_ERROR;
8484
DEVICE_UTIL_VARS
8585
DEVICE_INFO_VAR
8686
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Firmware.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int32_t main(int argc, char *argv[])
7171
/////////////////
7272
//common utility variables
7373
int ret = SUCCESS;
74-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
74+
int exitCode = UTIL_EXIT_NO_ERROR;
7575
DEVICE_UTIL_VARS
7676
DEVICE_INFO_VAR
7777
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Format.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int32_t main(int argc, char *argv[])
5959
/////////////////
6060
//common utility variables
6161
int ret = SUCCESS;
62-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
62+
int exitCode = UTIL_EXIT_NO_ERROR;
6363
DEVICE_UTIL_VARS
6464
DEVICE_INFO_VAR
6565
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_GenericTests.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int32_t main(int argc, char *argv[])
5757
/////////////////
5858
//common utility variables
5959
int ret = SUCCESS;
60-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
60+
int exitCode = UTIL_EXIT_NO_ERROR;
6161
DEVICE_UTIL_VARS
6262
DEVICE_INFO_VAR
6363
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Info.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int32_t main(int argc, char *argv[])
6363
/////////////////
6464
//common utility variables
6565
int ret = SUCCESS;
66-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
66+
int exitCode = UTIL_EXIT_NO_ERROR;
6767
DEVICE_UTIL_VARS
6868
DEVICE_INFO_VAR
6969
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Logs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int32_t main(int argc, char *argv[])
6262
/////////////////
6363
//common utility variables
6464
int ret = SUCCESS;
65-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
65+
int exitCode = UTIL_EXIT_NO_ERROR;
6666
DEVICE_UTIL_VARS
6767
OUTPUTPATH_VAR
6868
DEVICE_INFO_VAR

utils/C/openSeaChest/openSeaChest_NVMe.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void utility_Usage(bool shortUsage);
5757
//-----------------------------------------------------------------------------
5858
int32_t main(int argc, char *argv[])
5959
{
60-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
60+
int exitCode = UTIL_EXIT_NO_ERROR;
6161
/////////////////
6262
// Variables //
6363
/////////////////

utils/C/openSeaChest/openSeaChest_PassthroughTest.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int32_t main(int argc, char *argv[])
254254
/////////////////
255255
//common utility variables
256256
int ret = SUCCESS;
257-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
257+
int exitCode = UTIL_EXIT_NO_ERROR;
258258
DEVICE_UTIL_VARS
259259
DEVICE_INFO_VAR
260260
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_PowerControl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int32_t main(int argc, char *argv[])
5858
/////////////////
5959
//common utility variables
6060
int ret = SUCCESS;
61-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
61+
int exitCode = UTIL_EXIT_NO_ERROR;
6262
DEVICE_UTIL_VARS
6363
DEVICE_INFO_VAR
6464
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Reservations.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int32_t main(int argc, char *argv[])
5656
/////////////////
5757
//common utility variables
5858
int ret = SUCCESS;
59-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
59+
int exitCode = UTIL_EXIT_NO_ERROR;
6060
DEVICE_UTIL_VARS
6161
DEVICE_INFO_VAR
6262
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_SMART.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int32_t main(int argc, char *argv[])
6060
/////////////////
6161
//common utility variables
6262
int ret = SUCCESS;
63-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
63+
int exitCode = UTIL_EXIT_NO_ERROR;
6464
DEVICE_UTIL_VARS
6565
DEVICE_INFO_VAR
6666
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Sample.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int32_t main(int argc, char *argv[])
5555
/////////////////
5656
//common utility variables
5757
int ret = SUCCESS;
58-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
58+
int exitCode = UTIL_EXIT_NO_ERROR;
5959
DEVICE_UTIL_VARS
6060
DEVICE_INFO_VAR
6161
SAT_INFO_VAR

utils/C/openSeaChest/openSeaChest_Security.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// Global Variables //
4444
////////////////////////
4545
const char *util_name = "openSeaChest_Security";
46-
const char *buildVersion = "3.4.0";
46+
const char *buildVersion = "3.4.1";
4747

4848
typedef enum _eSeaChestSecurityExitCodes
4949
{
@@ -76,7 +76,7 @@ int32_t main(int argc, char *argv[])
7676
/////////////////
7777
//common utility variables
7878
int ret = SUCCESS;
79-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
79+
int exitCode = UTIL_EXIT_NO_ERROR;
8080
DEVICE_UTIL_VARS
8181
DEVICE_INFO_VAR
8282
SAT_INFO_VAR
@@ -518,16 +518,21 @@ int32_t main(int argc, char *argv[])
518518
}
519519
else if (strcmp(longopts[optionIndex].name, DISPLAY_LBA_LONG_OPT_STRING) == 0)
520520
{
521-
DISPLAY_LBA_FLAG = true;
522-
if (0 == sscanf(optarg, "%" SCNu64, &DISPLAY_LBA_THE_LBA))
521+
if (get_And_Validate_Integer_Input(C_CAST(const char*, optarg), &DISPLAY_LBA_THE_LBA))
522+
{
523+
DISPLAY_LBA_FLAG = true;
524+
}
525+
else
523526
{
524527
if (strcmp(optarg, "maxLBA") == 0)
525528
{
526529
USE_MAX_LBA = true;
530+
DISPLAY_LBA_FLAG = true;
527531
}
528532
else if (strcmp(optarg, "childMaxLBA") == 0)
529533
{
530534
USE_CHILD_MAX_LBA = true;
535+
DISPLAY_LBA_FLAG = true;
531536
}
532537
else
533538
{

utils/C/openSeaChest/openSeaChest_ZBD.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int32_t main(int argc, char *argv[])
5656
/////////////////
5757
//common utility variables
5858
int ret = SUCCESS;
59-
eUtilExitCodes exitCode = UTIL_EXIT_NO_ERROR;
59+
int exitCode = UTIL_EXIT_NO_ERROR;
6060
DEVICE_UTIL_VARS
6161
DEVICE_INFO_VAR
6262
SAT_INFO_VAR

0 commit comments

Comments
 (0)