diff options
-rw-r--r-- | drivers/scsi/sd.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9f7fc39891b8..e04c302fa4f7 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -262,6 +262,28 @@ sd_show_protection_type(struct device *dev, struct device_attribute *attr, | |||
262 | } | 262 | } |
263 | 263 | ||
264 | static ssize_t | 264 | static ssize_t |
265 | sd_store_protection_type(struct device *dev, struct device_attribute *attr, | ||
266 | const char *buf, size_t count) | ||
267 | { | ||
268 | struct scsi_disk *sdkp = to_scsi_disk(dev); | ||
269 | unsigned int val; | ||
270 | int err; | ||
271 | |||
272 | if (!capable(CAP_SYS_ADMIN)) | ||
273 | return -EACCES; | ||
274 | |||
275 | err = kstrtouint(buf, 10, &val); | ||
276 | |||
277 | if (err) | ||
278 | return err; | ||
279 | |||
280 | if (val >= 0 && val <= SD_DIF_TYPE3_PROTECTION) | ||
281 | sdkp->protection_type = val; | ||
282 | |||
283 | return count; | ||
284 | } | ||
285 | |||
286 | static ssize_t | ||
265 | sd_show_protection_mode(struct device *dev, struct device_attribute *attr, | 287 | sd_show_protection_mode(struct device *dev, struct device_attribute *attr, |
266 | char *buf) | 288 | char *buf) |
267 | { | 289 | { |
@@ -381,7 +403,8 @@ static struct device_attribute sd_disk_attrs[] = { | |||
381 | sd_store_allow_restart), | 403 | sd_store_allow_restart), |
382 | __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, | 404 | __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, |
383 | sd_store_manage_start_stop), | 405 | sd_store_manage_start_stop), |
384 | __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL), | 406 | __ATTR(protection_type, S_IRUGO|S_IWUSR, sd_show_protection_type, |
407 | sd_store_protection_type), | ||
385 | __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL), | 408 | __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL), |
386 | __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL), | 409 | __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL), |
387 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), | 410 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), |