diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-05-21 16:08:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:36 -0500 |
commit | edfaa7c36574f1bf09c65ad602412db9da5f96bf (patch) | |
tree | d591b80ff9229e4845e41d68e2f4c5aadb017027 /drivers/block/nbd.c | |
parent | 09f82ea92822a7bbb7e816508abbda47ed54a77f (diff) |
Driver core: convert block from raw kobjects to core devices
This moves the block devices to /sys/class/block. It will create a
flat list of all block devices, with the disks and partitions in one
directory. For compatibility /sys/block is created and contains symlinks
to the disks.
/sys/class/block
|-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
|-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1
|-- sda10 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10
|-- sda5 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5
|-- sda6 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6
|-- sda7 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7
|-- sda8 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8
|-- sda9 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9
`-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
/sys/block/
|-- sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
`-- sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index b4c0888aedc3..ba9b17e507e0 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -375,14 +375,17 @@ harderror: | |||
375 | return NULL; | 375 | return NULL; |
376 | } | 376 | } |
377 | 377 | ||
378 | static ssize_t pid_show(struct gendisk *disk, char *page) | 378 | static ssize_t pid_show(struct device *dev, |
379 | struct device_attribute *attr, char *buf) | ||
379 | { | 380 | { |
380 | return sprintf(page, "%ld\n", | 381 | struct gendisk *disk = dev_to_disk(dev); |
382 | |||
383 | return sprintf(buf, "%ld\n", | ||
381 | (long) ((struct nbd_device *)disk->private_data)->pid); | 384 | (long) ((struct nbd_device *)disk->private_data)->pid); |
382 | } | 385 | } |
383 | 386 | ||
384 | static struct disk_attribute pid_attr = { | 387 | static struct device_attribute pid_attr = { |
385 | .attr = { .name = "pid", .mode = S_IRUGO }, | 388 | .attr = { .name = "pid", .mode = S_IRUGO, .owner = THIS_MODULE }, |
386 | .show = pid_show, | 389 | .show = pid_show, |
387 | }; | 390 | }; |
388 | 391 | ||
@@ -394,7 +397,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
394 | BUG_ON(lo->magic != LO_MAGIC); | 397 | BUG_ON(lo->magic != LO_MAGIC); |
395 | 398 | ||
396 | lo->pid = current->pid; | 399 | lo->pid = current->pid; |
397 | ret = sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); | 400 | ret = sysfs_create_file(&lo->disk->dev.kobj, &pid_attr.attr); |
398 | if (ret) { | 401 | if (ret) { |
399 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); | 402 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); |
400 | return ret; | 403 | return ret; |
@@ -403,7 +406,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
403 | while ((req = nbd_read_stat(lo)) != NULL) | 406 | while ((req = nbd_read_stat(lo)) != NULL) |
404 | nbd_end_request(req); | 407 | nbd_end_request(req); |
405 | 408 | ||
406 | sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); | 409 | sysfs_remove_file(&lo->disk->dev.kobj, &pid_attr.attr); |
407 | return 0; | 410 | return 0; |
408 | } | 411 | } |
409 | 412 | ||