Skip to content

Commit

Permalink
[PATCH] Driver core: Make block devices create the proper symlink name
Browse files Browse the repository at this point in the history
Block devices need to add the block device name to the symlink they put
in the device directory, otherwise multiple symlinks of the same name
can be created.  This matches the class system, which works the same
way, we just forgot to convert block at the same time.

Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Jan 5, 2006
1 parent 874c624 commit 8218ef8
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions fs/partitions/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
disk->part[part-1] = p;
}

static char *make_block_name(struct gendisk *disk)
{
char *name;
static char *block_str = "block:";
int size;

size = strlen(block_str) + strlen(disk->disk_name) + 1;
name = kmalloc(size, GFP_KERNEL);
if (!name)
return NULL;
strcpy(name, block_str);
strcat(name, disk->disk_name);
return name;
}

static void disk_sysfs_symlinks(struct gendisk *disk)
{
struct device *target = get_device(disk->driverfs_dev);
if (target) {
char *disk_name = make_block_name(disk);
sysfs_create_link(&disk->kobj,&target->kobj,"device");
sysfs_create_link(&target->kobj,&disk->kobj,"block");
if (disk_name) {
sysfs_create_link(&target->kobj,&disk->kobj,disk_name);
kfree(disk_name);
}
}
}

Expand Down Expand Up @@ -461,8 +480,12 @@ void del_gendisk(struct gendisk *disk)
devfs_remove_disk(disk);

if (disk->driverfs_dev) {
char *disk_name = make_block_name(disk);
sysfs_remove_link(&disk->kobj, "device");
sysfs_remove_link(&disk->driverfs_dev->kobj, "block");
if (disk_name) {
sysfs_remove_link(&disk->driverfs_dev->kobj, disk_name);
kfree(disk_name);
}
put_device(disk->driverfs_dev);
}
kobject_uevent(&disk->kobj, KOBJ_REMOVE);
Expand Down

0 comments on commit 8218ef8

Please sign in to comment.