[PATCH RFC] scsi {add,remove}-single-device and /proc/scsi/scsi
From: Tony Battersby
Date: Mon Jul 24 2023 - 16:57:33 EST
I am trying to fix a bug in the parser for these commands:
echo "scsi add-single-device host channel id lun" > /proc/scsi/scsi
echo "scsi remove-single-device host channel id lun" > /proc/scsi/scsi
With the current parser, if you omit some of the fields (for example the
lun), then the kernel will usually fill in the missing parameters with a
0, but on rare occasion it might supply something else. So my question
for linux-scsi is: does anyone rely on omitting some of the parameters
in the cmds above and expect the kernel to supply 0 for the missing
parameters (for example lun is often 0)? If so, then I can make the
parser always supply a 0 for the missing parameters. If not, then I can
make the parser return an error if there are paramters missing, on the
theory that guessing which device to add or remove is a bad idea.
Below is the patch to return an error for a missing parameter. The
patch to use 0 instead of returning an error is similar but intead of
goto uses:
host = (p < end) ? simple_strtoul(p, &p, 0) : 0;
channel = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
id = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
lun = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
---