Skip to content

Commit

Permalink
Fix bugs to fetch supported drive list (LinearTapeFileSystem#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
piste2750 authored Jun 22, 2021
1 parent 4eafde6 commit f057535
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/tape_drivers/freebsd/cam/cam_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ int camtape_open(const char *devname, void **handle)
ltfsmsg(LTFS_INFO, 31229I, vendor);

/* Check the drive is supportable */
struct supported_device **cur = get_supported_devs(softc->vendor);
struct supported_device **cur = get_supported_devs((char *)softc->cd->inq_data.vendor);
while(*cur) {
if ((! strncmp((char*)softc->cd->inq_data.vendor, (*cur)->vendor_id, strlen((*cur)->vendor_id)) ) &&
(! strncmp((char*)softc->cd->inq_data.product, (*cur)->product_id, strlen((*cur)->product_id)) ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/tape_drivers/linux/sg/sg_tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ static int _raw_open(struct sg_data *priv)
return ret;
}

struct supported_device **cur = get_supported_devs(priv->vendor);
struct supported_device **cur = get_supported_devs(id_data.vendor_id);
while(*cur) {
if((! strncmp(id_data.vendor_id, (*cur)->vendor_id, strlen((*cur)->vendor_id)) ) &&
(! strncmp(id_data.product_id, (*cur)->product_id, strlen((*cur)->product_id)) ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/tape_drivers/osx/iokit/iokit_tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ int iokit_open(const char *devname, void **handle)
strncpy(priv->drive_serial, id_data.unit_serial, UNIT_SERIAL_LENGTH - 1);

/* Check the drive is supportable */
struct supported_device **cur = get_supported_devs(priv->vendor);
struct supported_device **cur = get_supported_devs(id_data.vendor_id);
while(cur && *cur) {
if((! strncmp(id_data.vendor_id, (*cur)->vendor_id, strlen((*cur)->vendor_id)) ) &&
(! strncmp(id_data.product_id, (*cur)->product_id, strlen((*cur)->product_id)) ) ) {
Expand Down
21 changes: 9 additions & 12 deletions src/tape_drivers/vendor_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,18 @@ struct error_table standard_tape_errors[] = {
{0xFFFFFF, -EDEV_UNKNOWN, "Unknown Error code"},
};

struct supported_device **get_supported_devs(int vendor)
struct supported_device **get_supported_devs(const char *vendor_str)
{
struct supported_device **cur = NULL;

switch (vendor) {
case VENDOR_IBM:
cur = ibm_supported_drives;
break;
case VENDOR_HP:
cur = hp_supported_drives;
break;
case VENDOR_QUANTUM:
cur = quantum_supported_drives;
break;
}
if (! strncmp(vendor_str, IBM_VENDOR_ID, strlen(IBM_VENDOR_ID)))
cur = ibm_supported_drives;
else if (! strncmp(vendor_str, HP_VENDOR_ID, strlen(IBM_VENDOR_ID)))
cur = hp_supported_drives;
else if (! strncmp(vendor_str, HPE_VENDOR_ID, strlen(IBM_VENDOR_ID)))
cur = hp_supported_drives;
else if (! strncmp(vendor_str, QUANTUM_VENDOR_ID, strlen(IBM_VENDOR_ID)))
cur = quantum_supported_drives;

return cur;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tape_drivers/vendor_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern "C" {

extern struct error_table standard_tape_errors[];

struct supported_device **get_supported_devs(int vendor);
struct supported_device **get_supported_devs(const char *vendor_str);
bool drive_has_supported_fw(int vendor, int drive_type, const unsigned char * const revision);
unsigned char assume_cart_type(const unsigned char dc);
int is_supported_tape(unsigned char type, unsigned char density, bool *is_worm);
Expand Down

0 comments on commit f057535

Please sign in to comment.