Skip to content

Commit bb36fa1

Browse files
committed
feat: Using helper function for SCSI read capacity commands
There is a lot of reuse of the process for issuing read capacity and switching between 10B and 16B versions. This change will use the new helper function from opensea-transport to reduce complexity and a single common method for getting device capacity information. Signed-off-by: Tyler Erickson <[email protected]>
1 parent 612a1cf commit bb36fa1

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

src/openseachest_util_options.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const char* deviceHandleExample = "/dev/sg<#>";
3232
const char* deviceHandleName = "<sg_device>";
3333
const char* commandWindowType = "terminal";
3434
# endif
35-
#elif defined(__FreeBSD__) || defined (__DragonFly__)
35+
#elif defined(__FreeBSD__) || defined(__DragonFly__)
3636
const char* deviceHandleExample = "/dev/da<#>";
3737
const char* deviceHandleName = "<da_device>";
3838
const char* commandWindowType = "shell";
@@ -120,7 +120,8 @@ void print_Elevated_Privileges_Text(void)
120120
# endif
121121
# elif defined(__DragonFly__)
122122
printf("In DragonFlyBSD, put sudo before the command. This may require inputting your login password.\n");
123-
printf("In DragonFlyBSD, log in to a root terminal (su), then execute the command. This requires the root password.\n");
123+
printf("In DragonFlyBSD, log in to a root terminal (su), then execute the command. This requires the root "
124+
"password.\n");
124125
# elif defined(__FreeBSD__)
125126
printf("In FreeBSD, put sudo before the command. This may require inputting your login password.\n");
126127
printf("In FreeBSD, log in to a root terminal (su), then execute the command. This requires the root password.\n");

subprojects/opensea-common

utils/C/openSeaChest/openSeaChest_Raw.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,16 @@ int main(int argc, char* argv[])
13061306
if (RAW_DATA_LEN_ADJUST_BY_BLOCKS_FLAG)
13071307
{
13081308
// allocate based on logical block size
1309+
if (deviceList[deviceIter].drive_info.deviceBlockSize == 0)
1310+
{
1311+
//get the blocksize from read capacity first
1312+
readCapacityData readCapData;
1313+
safe_memset(&readCapData, sizeof(readCapacityData), 0, sizeof(readCapacityData));
1314+
if (SUCCESS == scsi_Read_Capacity_Cmd_Helper(&deviceList[deviceIter], &readCapData))
1315+
{
1316+
deviceList[deviceIter].drive_info.deviceBlockSize = readCapData.logicalBlockLength;
1317+
}
1318+
}
13091319
allocatedDataLength =
13101320
deviceList[deviceIter].drive_info.deviceBlockSize * RAW_DATA_LEN_FLAG;
13111321
}
@@ -1342,11 +1352,31 @@ int main(int argc, char* argv[])
13421352
int64_t fileOffset = RAW_INPUT_FILE_OFFSET_FLAG;
13431353
if (RAW_INPUT_OFFSET_ADJUST_BY_BLOCKS_FLAG)
13441354
{
1355+
if (deviceList[deviceIter].drive_info.deviceBlockSize == 0)
1356+
{
1357+
//get the blocksize from read capacity first
1358+
readCapacityData readCapData;
1359+
safe_memset(&readCapData, sizeof(readCapacityData), 0, sizeof(readCapacityData));
1360+
if (SUCCESS == scsi_Read_Capacity_Cmd_Helper(&deviceList[deviceIter], &readCapData))
1361+
{
1362+
deviceList[deviceIter].drive_info.deviceBlockSize = readCapData.logicalBlockLength;
1363+
}
1364+
}
13451365
fileOffset =
13461366
deviceList[deviceIter].drive_info.deviceBlockSize * RAW_INPUT_FILE_OFFSET_FLAG;
13471367
}
13481368
if (RAW_DATA_LEN_ADJUST_BY_BLOCKS_FLAG)
13491369
{
1370+
if (deviceList[deviceIter].drive_info.deviceBlockSize == 0)
1371+
{
1372+
//get the blocksize from read capacity first
1373+
readCapacityData readCapData;
1374+
safe_memset(&readCapData, sizeof(readCapacityData), 0, sizeof(readCapacityData));
1375+
if (SUCCESS == scsi_Read_Capacity_Cmd_Helper(&deviceList[deviceIter], &readCapData))
1376+
{
1377+
deviceList[deviceIter].drive_info.deviceBlockSize = readCapData.logicalBlockLength;
1378+
}
1379+
}
13501380
// allocate based on logical block size
13511381
allocatedDataLength =
13521382
deviceList[deviceIter].drive_info.deviceBlockSize * RAW_DATA_LEN_FLAG;

0 commit comments

Comments
 (0)