All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs
@ 2017-10-12  6:56 weiping zhang
  2017-10-12  6:56 ` [PATCH v2 1/2] scsi: sd: change allow_restart to bool in sysfs interface weiping zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: weiping zhang @ 2017-10-12  6:56 UTC (permalink / raw)
  To: martin.petersen, jejb; +Cc: linux-scsi

Changes since V1:
switch kstrtoint to kstrtobool.
add fix for manage_start_stop.

weiping zhang (2):
  scsi: sd: change allow_restart to bool in sysfs interface
  scsi: sd: change manage_start_stop to bool in sysfs interface

 drivers/scsi/sd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

-- 
2.9.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] scsi: sd: change allow_restart to bool in sysfs interface
  2017-10-12  6:56 [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs weiping zhang
@ 2017-10-12  6:56 ` weiping zhang
  2017-10-12  6:57 ` [PATCH v2 2/2] scsi: sd: change manage_start_stop " weiping zhang
  2017-10-17  5:27 ` [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: weiping zhang @ 2017-10-12  6:56 UTC (permalink / raw)
  To: martin.petersen, jejb; +Cc: linux-scsi

/sys/class/scsi_disk/0:2:0:0/allow_restart can be changed to 0 unexpectly
by writing invalid string, like following:

echo asdf > /sys/class/scsi_disk/0:2:0:0/allow_restart

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 drivers/scsi/sd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3ef2214..e653dc5 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -253,6 +253,7 @@ static ssize_t
 allow_restart_store(struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
+	bool v;
 	struct scsi_disk *sdkp = to_scsi_disk(dev);
 	struct scsi_device *sdp = sdkp->device;
 
@@ -262,7 +263,10 @@ allow_restart_store(struct device *dev, struct device_attribute *attr,
 	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		return -EINVAL;
 
-	sdp->allow_restart = simple_strtoul(buf, NULL, 10);
+	if (kstrtobool(buf, &v))
+		return -EINVAL;
+
+	sdp->allow_restart = v ? 1 : 0;
 
 	return count;
 }
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] scsi: sd: change manage_start_stop to bool in sysfs interface
  2017-10-12  6:56 [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs weiping zhang
  2017-10-12  6:56 ` [PATCH v2 1/2] scsi: sd: change allow_restart to bool in sysfs interface weiping zhang
@ 2017-10-12  6:57 ` weiping zhang
  2017-10-17  5:27 ` [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: weiping zhang @ 2017-10-12  6:57 UTC (permalink / raw)
  To: martin.petersen, jejb; +Cc: linux-scsi

/sys/class/scsi_disk/0:2:0:0/manage_start_stop can be changed to 0
unexpectly by writing invalid string.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 drivers/scsi/sd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index e653dc5..00c9837 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -231,11 +231,15 @@ manage_start_stop_store(struct device *dev, struct device_attribute *attr,
 {
 	struct scsi_disk *sdkp = to_scsi_disk(dev);
 	struct scsi_device *sdp = sdkp->device;
+	bool v;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	sdp->manage_start_stop = simple_strtoul(buf, NULL, 10);
+	if (kstrtobool(buf, &v))
+		return -EINVAL;
+
+	sdp->manage_start_stop = v ? 1 : 0;
 
 	return count;
 }
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs
  2017-10-12  6:56 [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs weiping zhang
  2017-10-12  6:56 ` [PATCH v2 1/2] scsi: sd: change allow_restart to bool in sysfs interface weiping zhang
  2017-10-12  6:57 ` [PATCH v2 2/2] scsi: sd: change manage_start_stop " weiping zhang
@ 2017-10-17  5:27 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-10-17  5:27 UTC (permalink / raw)
  To: weiping zhang; +Cc: martin.petersen, jejb, linux-scsi


weiping,

> weiping zhang (2):
>   scsi: sd: change allow_restart to bool in sysfs interface
>   scsi: sd: change manage_start_stop to bool in sysfs interface

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-17  5:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12  6:56 [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs weiping zhang
2017-10-12  6:56 ` [PATCH v2 1/2] scsi: sd: change allow_restart to bool in sysfs interface weiping zhang
2017-10-12  6:57 ` [PATCH v2 2/2] scsi: sd: change manage_start_stop " weiping zhang
2017-10-17  5:27 ` [PATCH v2 0/2] change allow_restart, manage_start_stop to bool in sysfs Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.