Skip to contentSkip to conversation

drivers/scsi: fix proc_scsi_write to return "length" on success with remove-single-device case

PATCH In review [email protected] 2 participants 2 messages Jun 9, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/31 drivers/scsi: fix proc_scsi_write to return "length" on success with remove-single-device case

From: Suzuki <[email protected]>

proc_scsi_write doesn't return the "length" upon successfully removing a device; instead it returns 0. This causes commands like "echo" to redo the write(), which ends up in something like,

$ echo "scsi remove-single-device 0 0 3 0" > /proc/scsi/scsi
"-bash: echo: write error: No such device or address"

, even though the device was removed.

---

 drivers/scsi/scsi_proc.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/scsi_proc.c renamed from drivers/scsi/scsi_proc.c~drivers-scsi-fix-proc_scsi_write-to-return-length-on +2 -0
diff -puN drivers/scsi/scsi_proc.c~drivers-scsi-fix-proc_scsi_write-to-return-length-on drivers/scsi/scsi_proc.c
@@ -280,6 +280,8 @@ static ssize_t proc_scsi_write(struct fi
 		lun = simple_strtoul(p + 1, &p, 0);
 
 		err = scsi_remove_single_device(host, channel, id, lun);
+		if (!err)
+			err = length;
 	}
 
 	/*

_

#1 lore raw
Quoted 10 lines · On Thu, 2006-06-08 at 22:23 -0700, [email protected] wrote:

From: Suzuki <[email protected]>

proc_scsi_write doesn't return the "length" upon successfully removing a device; instead it returns 0. This causes commands like "echo" to redo the write(), which ends up in something like,

$ echo "scsi remove-single-device 0 0 3 0" > /proc/scsi/scsi
"-bash: echo: write error: No such device or address"

, even though the device was removed.

A better version of this fix is already in SCSI misc.

James