diff options
-rw-r--r-- | drivers/scsi/sd.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f899ff0cf005..2e96c3d8f7e2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -208,6 +208,23 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf, | |||
208 | return count; | 208 | return count; |
209 | } | 209 | } |
210 | 210 | ||
211 | static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, | ||
212 | size_t count) | ||
213 | { | ||
214 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | ||
215 | struct scsi_device *sdp = sdkp->device; | ||
216 | |||
217 | if (!capable(CAP_SYS_ADMIN)) | ||
218 | return -EACCES; | ||
219 | |||
220 | if (sdp->type != TYPE_DISK) | ||
221 | return -EINVAL; | ||
222 | |||
223 | sdp->allow_restart = simple_strtoul(buf, NULL, 10); | ||
224 | |||
225 | return count; | ||
226 | } | ||
227 | |||
211 | static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) | 228 | static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) |
212 | { | 229 | { |
213 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | 230 | struct scsi_disk *sdkp = to_scsi_disk(cdev); |
@@ -223,10 +240,19 @@ static ssize_t sd_show_fua(struct class_device *cdev, char *buf) | |||
223 | return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); | 240 | return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); |
224 | } | 241 | } |
225 | 242 | ||
243 | static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) | ||
244 | { | ||
245 | struct scsi_disk *sdkp = to_scsi_disk(cdev); | ||
246 | |||
247 | return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); | ||
248 | } | ||
249 | |||
226 | static struct class_device_attribute sd_disk_attrs[] = { | 250 | static struct class_device_attribute sd_disk_attrs[] = { |
227 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, | 251 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, |
228 | sd_store_cache_type), | 252 | sd_store_cache_type), |
229 | __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), | 253 | __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), |
254 | __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart, | ||
255 | sd_store_allow_restart), | ||
230 | __ATTR_NULL, | 256 | __ATTR_NULL, |
231 | }; | 257 | }; |
232 | 258 | ||