git: bd82711aff98 - main - cam: Remove trailing spaces from serial numbers too
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 05 Nov 2021 15:25:41 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bd82711aff986b66e9fae60847a79d9db938a467 commit bd82711aff986b66e9fae60847a79d9db938a467 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-11-05 14:56:41 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-11-05 14:56:41 +0000 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 --- sys/cam/scsi/scsi_xpt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 6bcf95506963..77c47d578ae3 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -1615,6 +1615,14 @@ probe_device_check: */ 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;