Skip to content

Commit 7c01479

Browse files
authored
Revert "fix: correct inverted status checks in the SCSI tape backend (#626)
1 parent d10f449 commit 7c01479

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/tape_drivers/linux/sg/sg_tape.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,9 +4630,7 @@ static bool is_ame(void *device)
46304630
unsigned char buf[TC_MP_READ_WRITE_CTRL_SIZE] = {0};
46314631
const int ret = sg_modesense(device, TC_MP_READ_WRITE_CTRL, TC_MP_PC_CURRENT, 0, buf, sizeof(buf));
46324632

4633-
/* sg_modesense returns the transferred byte count (> 0) on success and a
4634-
* negative error code on failure. */
4635-
if (ret < 0) {
4633+
if (ret != 0) {
46364634
char message[100] = {0};
46374635
sprintf(message, "failed to get MP %02Xh (%d)", TC_MP_READ_WRITE_CTRL, ret);
46384636
ltfsmsg(LTFS_DEBUG, 30392D, __FUNCTION__, message);
@@ -4722,7 +4720,7 @@ int sg_set_key(void *device, const unsigned char *keyalias, const unsigned char
47224720

47234721
unsigned char buf[TC_MP_READ_WRITE_CTRL_SIZE] = {0};
47244722
ret = sg_modesense(device, TC_MP_READ_WRITE_CTRL, TC_MP_PC_CURRENT, 0, buf, sizeof(buf));
4725-
if (ret < 0) /* sg_modesense returns a byte count (> 0) on success */
4723+
if (ret != DEVICE_GOOD)
47264724
goto out;
47274725

47284726
ltfs_u16tobe(buffer + 0, sps);
@@ -4769,9 +4767,8 @@ int sg_set_key(void *device, const unsigned char *keyalias, const unsigned char
47694767

47704768
memset(buf, 0, sizeof(buf));
47714769
ret = sg_modesense(device, TC_MP_READ_WRITE_CTRL, TC_MP_PC_CURRENT, 0, buf, sizeof(buf));
4772-
if (ret < 0) /* sg_modesense returns a byte count (> 0) on success */
4770+
if (ret != DEVICE_GOOD)
47734771
goto out;
4774-
ret = DEVICE_GOOD; /* normalize the byte count to a success code */
47754772

47764773
free:
47774774
free(buffer);

src/tape_drivers/osx/iokit/iokit_tape.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int _get_dump(struct iokit_data *priv, char *fname)
285285
long long data_length, buf_offset;
286286
int dumpfd = -1;
287287
int transfer_size, num_transfers, excess_transfer;
288-
int bytes;
288+
int i, bytes;
289289
unsigned char cap_buf[DUMP_HEADER_SIZE];
290290
unsigned char *dump_buf;
291291
int buf_id;
@@ -331,11 +331,14 @@ static int _get_dump(struct iokit_data *priv, char *fname)
331331

332332
/* start to transfer data */
333333
buf_offset = 0;
334+
i = 0;
334335
ltfsmsg(LTFS_DEBUG, 30859D);
335336
while(num_transfers)
336337
{
337338
int length;
338339

340+
i++;
341+
339342
/* Allocation Length is transfer_size or excess_transfer*/
340343
if(excess_transfer && num_transfers == 1)
341344
length = excess_transfer;
@@ -3409,9 +3412,7 @@ int iokit_set_xattr(void *device, const char *name, const char *buf, size_t size
34093412
free(null_terminated);
34103413

34113414
ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_SETXATTR));
3412-
/* ret is DEVICE_GOOD when one of the vendor attributes matched above;
3413-
* returning the hardcoded failure reported success as an error. */
3414-
return ret;
3415+
return -LTFS_NO_XATTR;
34153416
}
34163417

34173418
#define BLOCKLEN_DATA_SIZE 6
@@ -3628,7 +3629,7 @@ static const char *_generate_product_name(const char *product_id)
36283629

36293630
int iokit_get_device_list(struct tc_drive_info *buf, int count)
36303631
{
3631-
int i;
3632+
int i, ret;
36323633
int found = 0;
36333634
int32_t devs = iokit_get_ssc_device_count();
36343635
int drive_type;
@@ -3645,7 +3646,10 @@ int iokit_get_device_list(struct tc_drive_info *buf, int count)
36453646
if( devs > 0 ) {
36463647
for (i = 0; i < devs; i++) {
36473648
if(iokit_find_ssc_device(iokit_device, i) != 0)
3649+
{
3650+
ret = -EDEV_DEVICE_UNOPENABLE;
36483651
continue;
3652+
}
36493653
drive_type = iokit_get_drive_identifier(iokit_device, &identifier);
36503654
if (!drive_type) {
36513655
if (found < count && buf) {
@@ -3661,7 +3665,7 @@ int iokit_get_device_list(struct tc_drive_info *buf, int count)
36613665
}
36623666
found ++;
36633667
}
3664-
iokit_free_device(iokit_device);
3668+
ret = iokit_free_device(iokit_device);
36653669
}
36663670
}
36673671

0 commit comments

Comments
 (0)