cam: Remove trailing spaces from serial numbers too

The SanDisk SD8SB8U1 and likely others pad their serial number with
spaces on the end rather than the start (at least when connected to a
SAS3008). This makes them difficult to wire unit numbers to with the
serial because you have to specify the trailing spaces. Instead, strip
out the trailing spaces.

We already strip leading spaces both here. In addition, when glabel
creates the devfs device nodes, leading and trailing spaces are removed
already (so there will be no change there either).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D32684
This commit is contained in:
Warner Losh 2021-11-05 08:56:41 -06:00
parent 577f9aa266
commit bd82711aff

View file

@ -1615,6 +1615,14 @@ probedone(struct cam_periph *periph, union ccb *done_ccb)
*/
slen = 0;
}
/*
* In apparent violation of the spec, some
* devices pad their serial numbers with
* trailing spaces. Remove them.
*/
while (slen > 0 &&
serial_buf->serial_num[slen - 1] == ' ')
slen--;
memcpy(path->device->serial_num,
&serial_buf->serial_num[start], slen);
path->device->serial_num_len = slen;