Define constants for the lengths of the serial number, model number
and firmware revision in the controller's identify structure. Also modify consumers of these fields to ensure they only use the specified number of bytes for their respective fields. Sponsored by: Intel Reviewed by: carl MFC after: 3 days
This commit is contained in:
parent
6ded7d8bc2
commit
8281445679
@ -89,7 +89,7 @@ devlist(int argc, char *argv[])
|
|||||||
|
|
||||||
found++;
|
found++;
|
||||||
read_controller_data(fd, &cdata);
|
read_controller_data(fd, &cdata);
|
||||||
printf("%6s: %s\n", name, cdata.mn);
|
printf("%6s: %.*s\n", name, NVME_MODEL_NUMBER_LENGTH, cdata.mn);
|
||||||
|
|
||||||
for (i = 0; i < cdata.nn; i++) {
|
for (i = 0; i < cdata.nn; i++) {
|
||||||
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
|
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
|
||||||
|
@ -47,9 +47,12 @@ print_controller(struct nvme_controller_data *cdata)
|
|||||||
printf("================================\n");
|
printf("================================\n");
|
||||||
printf("Vendor ID: %04x\n", cdata->vid);
|
printf("Vendor ID: %04x\n", cdata->vid);
|
||||||
printf("Subsystem Vendor ID: %04x\n", cdata->ssvid);
|
printf("Subsystem Vendor ID: %04x\n", cdata->ssvid);
|
||||||
printf("Serial Number: %s\n", cdata->sn);
|
printf("Serial Number: %.*s\n",
|
||||||
printf("Model Number: %s\n", cdata->mn);
|
NVME_SERIAL_NUMBER_LENGTH, cdata->sn);
|
||||||
printf("Firmware Version: %s\n", cdata->fr);
|
printf("Model Number: %.*s\n",
|
||||||
|
NVME_MODEL_NUMBER_LENGTH, cdata->mn);
|
||||||
|
printf("Firmware Version: %.*s\n",
|
||||||
|
NVME_FIRMWARE_REVISION_LENGTH, cdata->fr);
|
||||||
printf("Recommended Arb Burst: %d\n", cdata->rab);
|
printf("Recommended Arb Burst: %d\n", cdata->rab);
|
||||||
printf("IEEE OUI Identifier: %02x %02x %02x\n",
|
printf("IEEE OUI Identifier: %02x %02x %02x\n",
|
||||||
cdata->ieee[0], cdata->ieee[1], cdata->ieee[2]);
|
cdata->ieee[0], cdata->ieee[1], cdata->ieee[2]);
|
||||||
|
@ -306,12 +306,16 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
|
|||||||
disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
|
disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* d_ident and d_descr are both far bigger than the length of either
|
||||||
|
* the serial or model number strings.
|
||||||
|
*/
|
||||||
strlcpy(disk->d_ident, nvme_ns_get_serial_number(ns),
|
strlcpy(disk->d_ident, nvme_ns_get_serial_number(ns),
|
||||||
sizeof(disk->d_ident));
|
min(sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH));
|
||||||
|
|
||||||
#if __FreeBSD_version >= 900034
|
#if __FreeBSD_version >= 900034
|
||||||
strlcpy(disk->d_descr, nvme_ns_get_model_number(ns),
|
strlcpy(disk->d_descr, nvme_ns_get_model_number(ns),
|
||||||
sizeof(disk->d_descr));
|
min(sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
disk_create(disk, DISK_VERSION);
|
disk_create(disk, DISK_VERSION);
|
||||||
|
@ -389,6 +389,10 @@ enum nvme_activate_action {
|
|||||||
NVME_AA_ACTIVATE = 0x2,
|
NVME_AA_ACTIVATE = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NVME_SERIAL_NUMBER_LENGTH 20
|
||||||
|
#define NVME_MODEL_NUMBER_LENGTH 40
|
||||||
|
#define NVME_FIRMWARE_REVISION_LENGTH 8
|
||||||
|
|
||||||
struct nvme_controller_data {
|
struct nvme_controller_data {
|
||||||
|
|
||||||
/* bytes 0-255: controller capabilities and features */
|
/* bytes 0-255: controller capabilities and features */
|
||||||
@ -400,13 +404,13 @@ struct nvme_controller_data {
|
|||||||
uint16_t ssvid;
|
uint16_t ssvid;
|
||||||
|
|
||||||
/** serial number */
|
/** serial number */
|
||||||
int8_t sn[20];
|
int8_t sn[NVME_SERIAL_NUMBER_LENGTH];
|
||||||
|
|
||||||
/** model number */
|
/** model number */
|
||||||
int8_t mn[40];
|
int8_t mn[NVME_MODEL_NUMBER_LENGTH];
|
||||||
|
|
||||||
/** firmware revision */
|
/** firmware revision */
|
||||||
uint8_t fr[8];
|
uint8_t fr[NVME_FIRMWARE_REVISION_LENGTH];
|
||||||
|
|
||||||
/** recommended arbitration burst */
|
/** recommended arbitration burst */
|
||||||
uint8_t rab;
|
uint8_t rab;
|
||||||
|
Loading…
Reference in New Issue
Block a user