Commit 0490d8f2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix removable partitioned media with devfs

From: Andrey Borzenkov <arvidjaar@mail.ru>

Current 2.5 does not register any device node in devfs for empty media
(capacity == 0) case.  This makes removables unusable with devfs.
Partition rescan is done only on bdev open, but without any device node for
device it is impossible to open it.

In 2.4 it was finally solved by always registering .../disc node as
representation for "whole" disk and using devfsd action to force partition
rescan on access to (non-existing) partition name.  For primary names it
was handled internally by devfs - it kept track of removable devices in
directory and initiated partition rescan when name was not found.

Both are obviously broken now.  You can't do partition rescan because no
node is registered at all and internal handling was removed.  Very nice.

The attached patch makes resgister_disk always register at least disc node.
 This now works for old and new compat names as per devfsd configuration;
canonical names are still broken:

  {pts/3}% ll /dev/scsi/host1/bus0/target4/lun0/part4
  ls: /dev/scsi/host1/bus0/target4/lun0/part4: No such file or directory

but it can be fixed using the same technique as above so I won't push it.
parent 37c2c764
...@@ -347,6 +347,9 @@ void register_disk(struct gendisk *disk) ...@@ -347,6 +347,9 @@ void register_disk(struct gendisk *disk)
return; return;
} }
/* always add handle for the whole disk */
devfs_add_partitioned(disk);
/* No such device (e.g., media were just removed) */ /* No such device (e.g., media were just removed) */
if (!get_capacity(disk)) if (!get_capacity(disk))
return; return;
...@@ -355,7 +358,6 @@ void register_disk(struct gendisk *disk) ...@@ -355,7 +358,6 @@ void register_disk(struct gendisk *disk)
if (blkdev_get(bdev, FMODE_READ, 0, BDEV_RAW) < 0) if (blkdev_get(bdev, FMODE_READ, 0, BDEV_RAW) < 0)
return; return;
state = check_partition(disk, bdev); state = check_partition(disk, bdev);
devfs_add_partitioned(disk);
if (state) { if (state) {
for (j = 1; j < state->limit; j++) { for (j = 1; j < state->limit; j++) {
sector_t size = state->parts[j].size; sector_t size = state->parts[j].size;
......
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