Selaa lähdekoodia

[SCSI] fix proc_scsi_write to return "length" on success with remove-single-device case

Problem spotted by: Suzuki K P <suzuki@in.ibm.com>

A zero return on success isn't correct for filesystem write functions.
They should either return negative error or the length of bytes
consumed.  Add code to convert our zero on success error return to
return the length of bytes passed in.

This fixes the following:

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

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
James Bottomley 19 vuotta sitten
vanhempi
commit
2ca48a1321
1 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 7 2
      drivers/scsi/scsi_proc.c

+ 7 - 2
drivers/scsi/scsi_proc.c

@@ -266,8 +266,6 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
 		lun = simple_strtoul(p + 1, &p, 0);
 		lun = simple_strtoul(p + 1, &p, 0);
 
 
 		err = scsi_add_single_device(host, channel, id, lun);
 		err = scsi_add_single_device(host, channel, id, lun);
-		if (err >= 0)
-			err = length;
 
 
 	/*
 	/*
 	 * Usage: echo "scsi remove-single-device 0 1 2 3" >/proc/scsi/scsi
 	 * Usage: echo "scsi remove-single-device 0 1 2 3" >/proc/scsi/scsi
@@ -284,6 +282,13 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
 		err = scsi_remove_single_device(host, channel, id, lun);
 		err = scsi_remove_single_device(host, channel, id, lun);
 	}
 	}
 
 
+	/*
+	 * convert success returns so that we return the 
+	 * number of bytes consumed.
+	 */
+	if (!err)
+		err = length;
+
  out:
  out:
 	free_page((unsigned long)buffer);
 	free_page((unsigned long)buffer);
 	return err;
 	return err;