Skip to content

Commit

Permalink
nvmecmds.cpp, nvmprint.cpp: Also suppress NVMe Namespace IEEE EUI-64 …
Browse files Browse the repository at this point in the history
…info

if '-q noserial' is specified.
smartctl.8.in: Update '-q noserial' documentation.

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools@5473 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
chrfranke committed May 30, 2023
1 parent 8feb673 commit d9d9d94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ $Id$

2023-05-30 Christian Franke <[email protected]>

nvmecmds.cpp, nvmprint.cpp: Also suppress NVMe Namespace IEEE EUI-64
info if '-q noserial' is specified.
smartctl.8.in: Update '-q noserial' documentation.

smartd.cpp: Don't report new non-device related errors as critical
(#1222).
smartd.conf.5.in: Document new functionality.
Expand Down
16 changes: 11 additions & 5 deletions nvmecmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ static bool nvme_pass_through(nvme_device * device, const nvme_cmd_in & in,
pout(" [Duration: %.6fs]\n", duration_usec / 1000000.0);
}

if ( dont_print_serial_number && ok
&& in.opcode == nvme_admin_identify && in.cdw10 == 0x01) {
// Invalidate serial number
nvme_id_ctrl & id_ctrl = *reinterpret_cast<nvme_id_ctrl *>(in.buffer);
memset(id_ctrl.sn, 'X', sizeof(id_ctrl.sn));
if (dont_print_serial_number && ok && in.opcode == nvme_admin_identify) {
if (in.cdw10 == 0x01 && in.size >= sizeof(nvme_id_ctrl)) {
// Identify controller: Invalidate serial number
nvme_id_ctrl & id_ctrl = *reinterpret_cast<nvme_id_ctrl *>(in.buffer);
memset(id_ctrl.sn, 'X', sizeof(id_ctrl.sn));
}
else if (in.cdw10 == 0x00 && in.size >= sizeof(nvme_id_ns)) {
// Identify namespace: Invalidate IEEE EUI-64
nvme_id_ns & id_ns = *reinterpret_cast<nvme_id_ns *>(in.buffer);
memset(id_ns.eui64, 0x00, sizeof(id_ns.eui64));
}
}

if (nvme_debugmode) {
Expand Down
2 changes: 1 addition & 1 deletion nvmeprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void print_drive_info(const nvme_id_ctrl & id_ctrl, const nvme_id_ns & id
jrns["formatted_lba_size"] = (1U << fmt_lba_bits);
jglb["logical_block_size"] = (1U << fmt_lba_bits);

if (show_all || nonempty(id_ns.eui64, sizeof(id_ns.eui64))) {
if (!dont_print_serial_number && (show_all || nonempty(id_ns.eui64, sizeof(id_ns.eui64)))) {
jout("Namespace %u IEEE EUI-64: %s%02x%02x%02x %02x%02x%02x%02x%02x\n",
nsid, align, id_ns.eui64[0], id_ns.eui64[1], id_ns.eui64[2], id_ns.eui64[3],
id_ns.eui64[4], id_ns.eui64[5], id_ns.eui64[6], id_ns.eui64[7]);
Expand Down
7 changes: 7 additions & 0 deletions smartctl.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ use the exit status of \fBsmartctl\fP (see EXIT STATUS below).
.Sp
.I noserial
\- Do not print the serial number of the device.
This also suppresses the LU WWN Device Id (ATA) and the SAS addresses (SCSI).
The related fields are also invalidated in the ATA and NVMe debug outputs.
.br
Note: This is not the case in SCSI debug output.
.br
[NEW EXPERIMENTAL SMARTCTL FEATURE]
The Namespace IEEE EUI-64 (NVMe) is also suppressed.
.TP
.B \-d TYPE, \-\-device=TYPE
Specifies the type of the device.
Expand Down

0 comments on commit d9d9d94

Please sign in to comment.