Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync src/scsi_id/scsi_id.c #203

Merged
merged 8 commits into from
Oct 16, 2021
66 changes: 33 additions & 33 deletions src/scsi_id/scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
#include <scsi/scsi.h>

struct scsi_ioctl_command {
unsigned int inlen; /* excluding scsi command length */
unsigned int outlen;
unsigned inlen; /* excluding scsi command length */
unsigned outlen;
unsigned char data[1];
/* on input, scsi command starts here then opt. data */
};

/*
* Default 5 second timeout
*/
#define DEF_TIMEOUT 5000
#define DEF_TIMEOUT 5000

#define SENSE_BUFF_LEN 32
#define SENSE_BUFF_LEN 32

/*
* The request buffer size passed to the SCSI INQUIRY commands, use 254,
* as this is a nice value for some devices, especially some of the usb
* mass storage devices.
*/
#define SCSI_INQ_BUFF_LEN 254
#define SCSI_INQ_BUFF_LEN 254

/*
* SCSI INQUIRY vendor and model (really product) lengths.
*/
#define VENDOR_LENGTH 8
#define MODEL_LENGTH 16
#define VENDOR_LENGTH 8
#define MODEL_LENGTH 16

#define INQUIRY_CMD 0x12
#define INQUIRY_CMDLEN 6
#define INQUIRY_CMD 0x12
#define INQUIRY_CMDLEN 6

/*
* INQUIRY VPD page 0x83 identifier descriptor related values. Reference the
Expand All @@ -52,48 +52,48 @@ struct scsi_ioctl_command {
/*
* id type values of id descriptors. These are assumed to fit in 4 bits.
*/
#define SCSI_ID_VENDOR_SPECIFIC 0
#define SCSI_ID_T10_VENDOR 1
#define SCSI_ID_EUI_64 2
#define SCSI_ID_NAA 3
#define SCSI_ID_RELPORT 4
#define SCSI_ID_VENDOR_SPECIFIC 0
#define SCSI_ID_T10_VENDOR 1
#define SCSI_ID_EUI_64 2
#define SCSI_ID_NAA 3
#define SCSI_ID_RELPORT 4
#define SCSI_ID_TGTGROUP 5
#define SCSI_ID_LUNGROUP 6
#define SCSI_ID_MD5 7
#define SCSI_ID_NAME 8
#define SCSI_ID_MD5 7
#define SCSI_ID_NAME 8

/*
* Supported NAA values. These fit in 4 bits, so the "don't care" value
* cannot conflict with real values.
*/
#define SCSI_ID_NAA_DONT_CARE 0xff
#define SCSI_ID_NAA_IEEE_REG 5
#define SCSI_ID_NAA_IEEE_REG_EXTENDED 6
#define SCSI_ID_NAA_DONT_CARE 0xff
#define SCSI_ID_NAA_IEEE_REG 0x05
#define SCSI_ID_NAA_IEEE_REG_EXTENDED 0x06

/*
* Supported Code Set values.
*/
#define SCSI_ID_BINARY 1
#define SCSI_ID_ASCII 2
#define SCSI_ID_BINARY 1
#define SCSI_ID_ASCII 2

struct scsi_id_search_values {
u_char id_type;
u_char naa_type;
u_char code_set;
u_char id_type;
u_char naa_type;
u_char code_set;
};

/*
* Following are the "true" SCSI status codes. Linux has traditionally
* used a 1 bit right and masked version of these. So now CHECK_CONDITION
* and friends (in <scsi/scsi.h>) are deprecated.
*/
#define SCSI_CHECK_CONDITION 0x2
#define SCSI_CONDITION_MET 0x4
#define SCSI_BUSY 0x8
#define SCSI_IMMEDIATE 0x10
#define SCSI_CHECK_CONDITION 0x02
#define SCSI_CONDITION_MET 0x04
#define SCSI_BUSY 0x08
#define SCSI_IMMEDIATE 0x10
#define SCSI_IMMEDIATE_CONDITION_MET 0x14
#define SCSI_RESERVATION_CONFLICT 0x18
#define SCSI_COMMAND_TERMINATED 0x22
#define SCSI_TASK_SET_FULL 0x28
#define SCSI_ACA_ACTIVE 0x30
#define SCSI_TASK_ABORTED 0x40
#define SCSI_RESERVATION_CONFLICT 0x18
#define SCSI_COMMAND_TERMINATED 0x22
#define SCSI_TASK_SET_FULL 0x28
#define SCSI_ACA_ACTIVE 0x30
#define SCSI_TASK_ABORTED 0x40
63 changes: 29 additions & 34 deletions src/scsi_id/scsi_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,34 @@ static char model_enc_str[256];
static char revision_str[16];
static char type_str[16];

static void set_type(const char *from, char *to, size_t len)
{
int type_num;
char *eptr;
const char *type = "generic";

type_num = strtoul(from, &eptr, 0);
if (eptr != from) {
switch (type_num) {
case 0:
type = "disk";
break;
case 1:
type = "tape";
break;
case 4:
type = "optical";
break;
case 5:
type = "cd";
break;
case 7:
type = "optical";
break;
case 0xe:
type = "disk";
break;
case 0xf:
type = "optical";
break;
default:
break;
}
static void set_type(unsigned type_num, char *to, size_t len) {
const char *type;

switch (type_num) {
case 0:
type = "disk";
break;
case 1:
type = "tape";
break;
case 4:
type = "optical";
break;
case 5:
type = "cd";
break;
case 7:
type = "optical";
break;
case 0xe:
type = "disk";
break;
case 0xf:
type = "optical";
break;
default:
type = "generic";
break;
}
strscpy(to, len, type);
}
Expand Down Expand Up @@ -337,7 +332,7 @@ static int set_options(struct udev *udev,
* file) we have to reset this back to 1.
*/
optind = 1;
while ((option = getopt_long(argc, argv, "d:f:gp:uvVxh", options, NULL)) >= 0)
while ((option = getopt_long(argc, argv, "d:f:gp:uvVxhbs:", options, NULL)) >= 0)
switch (option) {
case 'b':
all_good = false;
Expand Down
2 changes: 1 addition & 1 deletion src/scsi_id/scsi_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ struct scsi_id_device {
char vendor[9];
char model[17];
char revision[5];
char type[33];
char kernel[64];
char serial[MAX_SERIAL_LEN];
char serial_short[MAX_SERIAL_LEN];
unsigned type;
int use_sg;

/* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */
Expand Down
Loading