Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328887
b: refs/heads/master
c: 8172499
h: refs/heads/master
i:
  328885: ca02b8a
  328883: bff32bf
  328879: e9b085b
v: v3
  • Loading branch information
Martin K. Petersen authored and James Bottomley committed Sep 24, 2012
1 parent e8ed8e2 commit ece7759
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c579ab69d50a416887390ba4b89598a7b2fa0b6
refs/heads/master: 8172499aae4d375334cfe6361900929c3b31a03f
25 changes: 24 additions & 1 deletion trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,28 @@ sd_show_protection_type(struct device *dev, struct device_attribute *attr,
return snprintf(buf, 20, "%u\n", sdkp->protection_type);
}

static ssize_t
sd_store_protection_type(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_disk *sdkp = to_scsi_disk(dev);
unsigned int val;
int err;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

err = kstrtouint(buf, 10, &val);

if (err)
return err;

if (val >= 0 && val <= SD_DIF_TYPE3_PROTECTION)
sdkp->protection_type = val;

return count;
}

static ssize_t
sd_show_protection_mode(struct device *dev, struct device_attribute *attr,
char *buf)
Expand Down Expand Up @@ -381,7 +403,8 @@ static struct device_attribute sd_disk_attrs[] = {
sd_store_allow_restart),
__ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop,
sd_store_manage_start_stop),
__ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL),
__ATTR(protection_type, S_IRUGO|S_IWUSR, sd_show_protection_type,
sd_store_protection_type),
__ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL),
__ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL),
__ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL),
Expand Down

0 comments on commit ece7759

Please sign in to comment.