From a72c5e5eb738033938ab30d6a634b74d1d060f10 Mon Sep 17 00:00:00 2001 From: Nao Nishijima Date: Thu, 25 Aug 2011 18:04:06 +0900 Subject: [SCSI] genhd: add a new attribute "alias" in gendisk This patch allows the user to set an "alias" of the disk via sysfs interface. This patch only adds a new attribute "alias" in gendisk structure. To show the alias instead of the device name in kernel messages, we need to revise printk messages and use alias_name() in them. Example: (current) printk("disk name is %s\n", disk->disk_name); (new) printk("disk name is %s\n", alias_name(disk)); Users can use alphabets, numbers, '-' and '_' in "alias" attribute. A disk can have an "alias" which length is up to 255 bytes. This attribute is write-once. Suggested-by: James Bottomley Suggested-by: Jon Masters Signed-off-by: Nao Nishijima Signed-off-by: James Bottomley --- include/linux/genhd.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux') diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 02fa4697a0e5..6957350e122f 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -21,6 +21,8 @@ #define dev_to_part(device) container_of((device), struct hd_struct, __dev) #define disk_to_dev(disk) (&(disk)->part0.__dev) #define part_to_dev(part) (&((part)->__dev)) +#define alias_name(disk) ((disk)->alias ? (disk)->alias : \ + (disk)->disk_name) extern struct device_type part_type; extern struct kobject *block_depr; @@ -58,6 +60,7 @@ enum { #define DISK_MAX_PARTS 256 #define DISK_NAME_LEN 32 +#define ALIAS_LEN 256 #include #include @@ -162,6 +165,7 @@ struct gendisk { * disks that can't be partitioned. */ char disk_name[DISK_NAME_LEN]; /* name of major driver */ + char *alias; /* alias name of disk */ char *(*devnode)(struct gendisk *gd, mode_t *mode); unsigned int events; /* supported events */ -- cgit v1.2.3