Messages in this thread Patch in this message | | | Subject | [PATCH] block core: export MAJOR/MINOR to the hotplug env | Date | Wed, 9 Mar 2005 16:34:41 -0800 | From | Greg KH <> |
| |
ChangeSet 1.2040, 2005/03/09 09:32:58-08:00, kay.sievers@vrfy.org
[PATCH] block core: export MAJOR/MINOR to the hotplug env
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/block/genhd.c | 53 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 34 insertions(+), 19 deletions(-)
diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c --- a/drivers/block/genhd.c 2005-03-09 16:29:48 -08:00 +++ b/drivers/block/genhd.c 2005-03-09 16:29:48 -08:00 @@ -430,42 +430,57 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { - struct device *dev = NULL; struct kobj_type *ktype = get_ktype(kobj); + struct device *physdev; + struct gendisk *disk; + struct hd_struct *part; int length = 0; int i = 0; - /* get physical device backing disk or partition */ if (ktype == &ktype_block) { - struct gendisk *disk = container_of(kobj, struct gendisk, kobj); - dev = disk->driverfs_dev; + disk = container_of(kobj, struct gendisk, kobj); + add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, + &length, "MINOR=%u", disk->first_minor); } else if (ktype == &ktype_part) { - struct gendisk *disk = container_of(kobj->parent, struct gendisk, kobj); - dev = disk->driverfs_dev; - } - - if (dev) { - /* add physical device, backing this device */ - char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); + disk = container_of(kobj->parent, struct gendisk, kobj); + part = container_of(kobj, struct hd_struct, kobj); + add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, + &length, "MINOR=%u", + disk->first_minor + part->partno); + } else + return 0; + + add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, + "MAJOR=%u", disk->major); + + /* add physical device, backing this device */ + physdev = disk->driverfs_dev; + if (physdev) { + char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL); add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, "PHYSDEVPATH=%s", path); kfree(path); - /* add bus name of physical device */ - if (dev->bus) + if (physdev->bus) add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, - "PHYSDEVBUS=%s", dev->bus->name); + "PHYSDEVBUS=%s", + physdev->bus->name); - /* add driver name of physical device */ - if (dev->driver) + if (physdev->driver) add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, - "PHYSDEVDRIVER=%s", dev->driver->name); - - envp[i] = NULL; + "PHYSDEVDRIVER=%s", + physdev->driver->name); } + + /* terminate, set to next free slot, shrink available space */ + envp[i] = NULL; + envp = &envp[i]; + num_envp -= i; + buffer = &buffer[length]; + buffer_size -= length; return 0; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |