Driver Core: block: add nodename support for block drivers.
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 30 Apr 2009 13:23:42 +0000 (15:23 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:30:25 +0000 (21:30 -0700)
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: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
block/genhd.c
drivers/block/pktcdvd.c
include/linux/genhd.h

index fe7ccc0a618f35e21ed7fbbe19ae49665270d498..f4c64c2b303a33e2f46bd10b01d36c2cd931b4d6 100644 (file)
@@ -996,10 +996,20 @@ struct class block_class = {
        .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 = {
        .name           = "disk",
        .groups         = disk_attr_groups,
        .release        = disk_release,
+       .nodename       = block_nodename,
 };
 
 #ifdef CONFIG_PROC_FS
index d57f11759480c1c2874922e773cee62ac6571472..37e0f81cada28f8966dcf69aeedee7c184b3d609 100644 (file)
@@ -2855,6 +2855,11 @@ static struct block_device_operations pktcdvd_ops = {
        .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.
  */
@@ -2907,6 +2912,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
        disk->fops = &pktcdvd_ops;
        disk->flags = GENHD_FL_REMOVABLE;
        strcpy(disk->disk_name, pd->name);
+       disk->nodename = pktcdvd_nodename;
        disk->private_data = pd;
        disk->queue = blk_alloc_queue(GFP_KERNEL);
        if (!disk->queue)
@@ -3062,6 +3068,7 @@ static const struct file_operations pkt_ctl_fops = {
 static struct miscdevice pkt_misc = {
        .minor          = MISC_DYNAMIC_MINOR,
        .name           = DRIVER_NAME,
+       .name           = "pktcdvd/control",
        .fops           = &pkt_ctl_fops
 };
 
index 7cbd38d363a2f051af1abbd30d7bbf90c066151e..45fc320a53c6f002fbb466d2b38315254b19ff94 100644 (file)
@@ -142,7 +142,7 @@ struct gendisk {
                                          * disks that can't be partitioned. */
 
        char disk_name[DISK_NAME_LEN];  /* name of major driver */
-
+       char *(*nodename)(struct gendisk *gd);
        /* Array of pointers to partitions indexed by partno.
         * Protected with matching bdev lock but stat and other
         * non-critical accesses use RCU.  Always access through