Commit b03f38b6 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

Driver Core: block: add nodename support for block drivers.

This adds support for block drivers to report their requested nodename
to userspace.  It also updates a number of block drivers to provide the
needed subdirectory and device name to be used for them.
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarJan Blunck <jblunck@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f7a386c5
...@@ -996,10 +996,20 @@ struct class block_class = { ...@@ -996,10 +996,20 @@ struct class block_class = {
.name = "block", .name = "block",
}; };
static char *block_nodename(struct device *dev)
{
struct gendisk *disk = dev_to_disk(dev);
if (disk->nodename)
return disk->nodename(disk);
return NULL;
}
static struct device_type disk_type = { static struct device_type disk_type = {
.name = "disk", .name = "disk",
.groups = disk_attr_groups, .groups = disk_attr_groups,
.release = disk_release, .release = disk_release,
.nodename = block_nodename,
}; };
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -2855,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = { ...@@ -2855,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = {
.media_changed = pkt_media_changed, .media_changed = pkt_media_changed,
}; };
static char *pktcdvd_nodename(struct gendisk *gd)
{
return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
}
/* /*
* Set up mapping from pktcdvd device to CD-ROM device. * Set up mapping from pktcdvd device to CD-ROM device.
*/ */
...@@ -2907,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) ...@@ -2907,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
disk->fops = &pktcdvd_ops; disk->fops = &pktcdvd_ops;
disk->flags = GENHD_FL_REMOVABLE; disk->flags = GENHD_FL_REMOVABLE;
strcpy(disk->disk_name, pd->name); strcpy(disk->disk_name, pd->name);
disk->nodename = pktcdvd_nodename;
disk->private_data = pd; disk->private_data = pd;
disk->queue = blk_alloc_queue(GFP_KERNEL); disk->queue = blk_alloc_queue(GFP_KERNEL);
if (!disk->queue) if (!disk->queue)
...@@ -3062,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = { ...@@ -3062,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = {
static struct miscdevice pkt_misc = { static struct miscdevice pkt_misc = {
.minor = MISC_DYNAMIC_MINOR, .minor = MISC_DYNAMIC_MINOR,
.name = DRIVER_NAME, .name = DRIVER_NAME,
.name = "pktcdvd/control",
.fops = &pkt_ctl_fops .fops = &pkt_ctl_fops
}; };
......
...@@ -142,7 +142,7 @@ struct gendisk { ...@@ -142,7 +142,7 @@ struct gendisk {
* disks that can't be partitioned. */ * disks that can't be partitioned. */
char disk_name[DISK_NAME_LEN]; /* name of major driver */ char disk_name[DISK_NAME_LEN]; /* name of major driver */
char *(*nodename)(struct gendisk *gd);
/* Array of pointers to partitions indexed by partno. /* Array of pointers to partitions indexed by partno.
* Protected with matching bdev lock but stat and other * Protected with matching bdev lock but stat and other
* non-critical accesses use RCU. Always access through * non-critical accesses use RCU. Always access through
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment