aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-28 19:44:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-28 19:44:18 -0400
commitec7ae517537ae5c7b0b2cd7f562dfa3e7a05b954 (patch)
treee6b0c64a51a7c0aa0efd09d4f7a80872e3b1657a /block
parent97d2eb13a019ec09cc1a7ea2d3705c0b117b3c0d (diff)
parent590134fa78fbdbe5fea78c7ae0b2c3364bc9572f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (204 commits) [SCSI] qla4xxx: export address/port of connection (fix udev disk names) [SCSI] ipr: Fix BUG on adapter dump timeout [SCSI] megaraid_sas: Fix instance access in megasas_reset_timer [SCSI] hpsa: change confusing message to be more clear [SCSI] iscsi class: fix vlan configuration [SCSI] qla4xxx: fix data alignment and use nl helpers [SCSI] iscsi class: fix link local mispelling [SCSI] iscsi class: Replace iscsi_get_next_target_id with IDA [SCSI] aacraid: use lower snprintf() limit [SCSI] lpfc 8.3.27: Change driver version to 8.3.27 [SCSI] lpfc 8.3.27: T10 additions for SLI4 [SCSI] lpfc 8.3.27: Fix queue allocation failure recovery [SCSI] lpfc 8.3.27: Change algorithm for getting physical port name [SCSI] lpfc 8.3.27: Changed worst case mailbox timeout [SCSI] lpfc 8.3.27: Miscellanous logic and interface fixes [SCSI] megaraid_sas: Changelog and version update [SCSI] megaraid_sas: Add driver workaround for PERC5/1068 kdump kernel panic [SCSI] megaraid_sas: Add multiple MSI-X vector/multiple reply queue support [SCSI] megaraid_sas: Add support for MegaRAID 9360/9380 12GB/s controllers [SCSI] megaraid_sas: Clear FUSION_IN_RESET before enabling interrupts ...
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index e2f67902dd02..94855a9717de 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -19,6 +19,7 @@
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/idr.h> 20#include <linux/idr.h>
21#include <linux/log2.h> 21#include <linux/log2.h>
22#include <linux/ctype.h>
22 23
23#include "blk.h" 24#include "blk.h"
24 25
@@ -909,6 +910,74 @@ static int __init genhd_device_init(void)
909 910
910subsys_initcall(genhd_device_init); 911subsys_initcall(genhd_device_init);
911 912
913static ssize_t alias_show(struct device *dev,
914 struct device_attribute *attr, char *buf)
915{
916 struct gendisk *disk = dev_to_disk(dev);
917 ssize_t ret = 0;
918
919 if (disk->alias)
920 ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
921 return ret;
922}
923
924static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
925 const char *buf, size_t count)
926{
927 struct gendisk *disk = dev_to_disk(dev);
928 char *alias;
929 char *envp[] = { NULL, NULL };
930 unsigned char c;
931 int i;
932 ssize_t ret = count;
933
934 if (!count)
935 return -EINVAL;
936
937 if (count >= ALIAS_LEN) {
938 printk(KERN_ERR "alias: alias is too long\n");
939 return -EINVAL;
940 }
941
942 /* Validation check */
943 for (i = 0; i < count; i++) {
944 c = buf[i];
945 if (i == count - 1 && c == '\n')
946 break;
947 if (!isalnum(c) && c != '_' && c != '-') {
948 printk(KERN_ERR "alias: invalid alias\n");
949 return -EINVAL;
950 }
951 }
952
953 if (disk->alias) {
954 printk(KERN_INFO "alias: %s is already assigned (%s)\n",
955 disk->disk_name, disk->alias);
956 return -EINVAL;
957 }
958
959 alias = kasprintf(GFP_KERNEL, "%s", buf);
960 if (!alias)
961 return -ENOMEM;
962
963 if (alias[count - 1] == '\n')
964 alias[count - 1] = '\0';
965
966 envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
967 if (!envp[0]) {
968 kfree(alias);
969 return -ENOMEM;
970 }
971
972 disk->alias = alias;
973 printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
974
975 kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
976
977 kfree(envp[0]);
978 return ret;
979}
980
912static ssize_t disk_range_show(struct device *dev, 981static ssize_t disk_range_show(struct device *dev,
913 struct device_attribute *attr, char *buf) 982 struct device_attribute *attr, char *buf)
914{ 983{
@@ -968,6 +1037,7 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
968 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); 1037 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
969} 1038}
970 1039
1040static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
971static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 1041static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
972static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); 1042static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
973static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); 1043static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -990,6 +1060,7 @@ static struct device_attribute dev_attr_fail_timeout =
990#endif 1060#endif
991 1061
992static struct attribute *disk_attrs[] = { 1062static struct attribute *disk_attrs[] = {
1063 &dev_attr_alias.attr,
993 &dev_attr_range.attr, 1064 &dev_attr_range.attr,
994 &dev_attr_ext_range.attr, 1065 &dev_attr_ext_range.attr,
995 &dev_attr_removable.attr, 1066 &dev_attr_removable.attr,