diff options
author | Nao Nishijima <nao.nishijima.xt@hitachi.com> | 2011-08-25 05:04:06 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-29 03:16:19 -0400 |
commit | a72c5e5eb738033938ab30d6a634b74d1d060f10 (patch) | |
tree | 72cea6d75a62f7003d55f8a754c2d17149ada85f /include | |
parent | 76e4e12ff2b3ef86773989fd897b194eb38016e6 (diff) |
[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 <James.Bottomley@HansenPartnership.com>
Suggested-by: Jon Masters <jcm@redhat.com>
Signed-off-by: Nao Nishijima <nao.nishijima.xt@hitachi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/genhd.h | 4 |
1 files changed, 4 insertions, 0 deletions
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 @@ | |||
21 | #define dev_to_part(device) container_of((device), struct hd_struct, __dev) | 21 | #define dev_to_part(device) container_of((device), struct hd_struct, __dev) |
22 | #define disk_to_dev(disk) (&(disk)->part0.__dev) | 22 | #define disk_to_dev(disk) (&(disk)->part0.__dev) |
23 | #define part_to_dev(part) (&((part)->__dev)) | 23 | #define part_to_dev(part) (&((part)->__dev)) |
24 | #define alias_name(disk) ((disk)->alias ? (disk)->alias : \ | ||
25 | (disk)->disk_name) | ||
24 | 26 | ||
25 | extern struct device_type part_type; | 27 | extern struct device_type part_type; |
26 | extern struct kobject *block_depr; | 28 | extern struct kobject *block_depr; |
@@ -58,6 +60,7 @@ enum { | |||
58 | 60 | ||
59 | #define DISK_MAX_PARTS 256 | 61 | #define DISK_MAX_PARTS 256 |
60 | #define DISK_NAME_LEN 32 | 62 | #define DISK_NAME_LEN 32 |
63 | #define ALIAS_LEN 256 | ||
61 | 64 | ||
62 | #include <linux/major.h> | 65 | #include <linux/major.h> |
63 | #include <linux/device.h> | 66 | #include <linux/device.h> |
@@ -162,6 +165,7 @@ struct gendisk { | |||
162 | * disks that can't be partitioned. */ | 165 | * disks that can't be partitioned. */ |
163 | 166 | ||
164 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ | 167 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ |
168 | char *alias; /* alias name of disk */ | ||
165 | char *(*devnode)(struct gendisk *gd, mode_t *mode); | 169 | char *(*devnode)(struct gendisk *gd, mode_t *mode); |
166 | 170 | ||
167 | unsigned int events; /* supported events */ | 171 | unsigned int events; /* supported events */ |