aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 9253839714ff..02e9fca80825 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -19,7 +19,6 @@
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>
23 22
24#include "blk.h" 23#include "blk.h"
25 24
@@ -916,74 +915,6 @@ static int __init genhd_device_init(void)
916 915
917subsys_initcall(genhd_device_init); 916subsys_initcall(genhd_device_init);
918 917
919static ssize_t alias_show(struct device *dev,
920 struct device_attribute *attr, char *buf)
921{
922 struct gendisk *disk = dev_to_disk(dev);
923 ssize_t ret = 0;
924
925 if (disk->alias)
926 ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
927 return ret;
928}
929
930static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
931 const char *buf, size_t count)
932{
933 struct gendisk *disk = dev_to_disk(dev);
934 char *alias;
935 char *envp[] = { NULL, NULL };
936 unsigned char c;
937 int i;
938 ssize_t ret = count;
939
940 if (!count)
941 return -EINVAL;
942
943 if (count >= ALIAS_LEN) {
944 printk(KERN_ERR "alias: alias is too long\n");
945 return -EINVAL;
946 }
947
948 /* Validation check */
949 for (i = 0; i < count; i++) {
950 c = buf[i];
951 if (i == count - 1 && c == '\n')
952 break;
953 if (!isalnum(c) && c != '_' && c != '-') {
954 printk(KERN_ERR "alias: invalid alias\n");
955 return -EINVAL;
956 }
957 }
958
959 if (disk->alias) {
960 printk(KERN_INFO "alias: %s is already assigned (%s)\n",
961 disk->disk_name, disk->alias);
962 return -EINVAL;
963 }
964
965 alias = kasprintf(GFP_KERNEL, "%s", buf);
966 if (!alias)
967 return -ENOMEM;
968
969 if (alias[count - 1] == '\n')
970 alias[count - 1] = '\0';
971
972 envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
973 if (!envp[0]) {
974 kfree(alias);
975 return -ENOMEM;
976 }
977
978 disk->alias = alias;
979 printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
980
981 kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
982
983 kfree(envp[0]);
984 return ret;
985}
986
987static ssize_t disk_range_show(struct device *dev, 918static ssize_t disk_range_show(struct device *dev,
988 struct device_attribute *attr, char *buf) 919 struct device_attribute *attr, char *buf)
989{ 920{
@@ -1043,7 +974,6 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
1043 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); 974 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
1044} 975}
1045 976
1046static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
1047static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 977static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
1048static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); 978static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
1049static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); 979static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -1066,7 +996,6 @@ static struct device_attribute dev_attr_fail_timeout =
1066#endif 996#endif
1067 997
1068static struct attribute *disk_attrs[] = { 998static struct attribute *disk_attrs[] = {
1069 &dev_attr_alias.attr,
1070 &dev_attr_range.attr, 999 &dev_attr_range.attr,
1071 &dev_attr_ext_range.attr, 1000 &dev_attr_ext_range.attr,
1072 &dev_attr_removable.attr, 1001 &dev_attr_removable.attr,