Hi,
The following patch causes ide-floppy to register a disc
even if no cartridge is in the drive, so that devfs creates
nodes for the drive for later use. Without this patch,
if devfs is used, no device node is ever created, and
ide-floppy must be rmmoded and reloaded if a floppy is inserted
into a drive that was empty at boot time.
The reason is that grok_partitions() returns immediately if the
device passed has a size parameter of 0, which was the case
in ide-floppy with no cartrifge in the drive.
The patch is against 2.4.7.
It is somewhat a hack, perhaps somebody else finds a more elegant
way to do it. But it makes sense that an empty drive
does not return a capacity of 0, but the capacity of a standard media
cartridge.
Martin
--
Martin Wilck <[email protected]>
FSC EP PS DS1, Paderborn Tel. +49 5251 8 15113
--- 2.4.7a/drivers/ide/ide-probe.c Sun Mar 18 18:25:02 2001
+++ 2.4.7/drivers/ide/ide-probe.c Fri Jul 27 23:01:49 2001
@@ -122,6 +122,7 @@
printk("cdrom or floppy?, assuming ");
if (drive->media != ide_cdrom) {
printk ("FLOPPY");
+ drive->removable = 1;
break;
}
}
--- 2.4.7a/drivers/ide/ide-floppy.c Wed Jul 25 20:20:44 2001
+++ 2.4.7/drivers/ide/ide-floppy.c Fri Jul 27 23:00:38 2001
@@ -1279,7 +1279,15 @@
printk (KERN_NOTICE "%s: warning: non 512 bytes block size not fully supported\n", drive->name);
rc = 0;
}
- }
+ } else if (!i && descriptor->dc == CAPACITY_NO_CARTRIDGE
+ && drive->removable && !(length % 512)) {
+ /*
+ Set these two so that idefloppy_capacity returns a positive value,
+ needed for devfs registration.
+ */
+ floppy->blocks = blocks;
+ floppy->bs_factor = length / 512;
+ };
#if IDEFLOPPY_DEBUG_INFO
if (!i) printk (KERN_INFO "Descriptor 0 Code: %d\n", descriptor->dc);
printk (KERN_INFO "Descriptor %d: %dkB, %d blocks, %d sector size\n", i, blocks * length / 1024, blocks, length);
Also note that I have already forwarded a patch to Richard to make the devfs
nodes that get created when grok_partitions runs get removed when the media
is removed and new media is validated (i.e. the partition nodes will stay in
sync with the cartridge in the drive).
----- Original Message -----
From: "Martin Wilck" <[email protected]>
To: "Richard Gooch" <[email protected]>
Cc: "Martin Wilck" <[email protected]>; "devfs mailing list"
<[email protected]>; "Linux Kernel mailing list"
<[email protected]>
Sent: Friday, July 27, 2001 12:34 PM
Subject: [PATCH]: ide-floppy & devfs
>
> Hi,
>
> The following patch causes ide-floppy to register a disc
> even if no cartridge is in the drive, so that devfs creates
> nodes for the drive for later use. Without this patch,
> if devfs is used, no device node is ever created, and
> ide-floppy must be rmmoded and reloaded if a floppy is inserted
> into a drive that was empty at boot time.
>
> The reason is that grok_partitions() returns immediately if the
> device passed has a size parameter of 0, which was the case
> in ide-floppy with no cartrifge in the drive.
>
> The patch is against 2.4.7.
>
> It is somewhat a hack, perhaps somebody else finds a more elegant
> way to do it. But it makes sense that an empty drive
> does not return a capacity of 0, but the capacity of a standard media
> cartridge.
>
> Martin
>
> --
> Martin Wilck <[email protected]>
> FSC EP PS DS1, Paderborn Tel. +49 5251 8 15113
>
> --- 2.4.7a/drivers/ide/ide-probe.c Sun Mar 18 18:25:02 2001
> +++ 2.4.7/drivers/ide/ide-probe.c Fri Jul 27 23:01:49 2001
> @@ -122,6 +122,7 @@
> printk("cdrom or floppy?, assuming ");
> if (drive->media != ide_cdrom) {
> printk ("FLOPPY");
> + drive->removable = 1;
> break;
> }
> }
> --- 2.4.7a/drivers/ide/ide-floppy.c Wed Jul 25 20:20:44 2001
> +++ 2.4.7/drivers/ide/ide-floppy.c Fri Jul 27 23:00:38 2001
> @@ -1279,7 +1279,15 @@
> printk (KERN_NOTICE "%s: warning: non 512 bytes block size not fully
supported\n", drive->name);
> rc = 0;
> }
> - }
> + } else if (!i && descriptor->dc == CAPACITY_NO_CARTRIDGE
> + && drive->removable && !(length % 512)) {
> + /*
> + Set these two so that idefloppy_capacity returns a positive value,
> + needed for devfs registration.
> + */
> + floppy->blocks = blocks;
> + floppy->bs_factor = length / 512;
> + };
> #if IDEFLOPPY_DEBUG_INFO
> if (!i) printk (KERN_INFO "Descriptor 0 Code: %d\n", descriptor->dc);
> printk (KERN_INFO "Descriptor %d: %dkB, %d blocks, %d sector size\n", i,
blocks * length / 1024, blocks, length);
>
>
>
>
Kevin P. Fleming writes:
> Also note that I have already forwarded a patch to Richard to make
> the devfs nodes that get created when grok_partitions runs get
> removed when the media is removed and new media is validated
> (i.e. the partition nodes will stay in sync with the cartridge in
> the drive).
Are you saying that the two patch conflict? If not, can someone please
verify that both together are safe? Or is your patch a superset?
Either way, I can't really test these patches since I don't have
removable media devices, so I'd prefer if someone else nurses this
into Linus' tree (i.e. test it, call for testing and feed it to Linus
until it goes in).
Regards,
Richard....
Permanent: [email protected]
Current: [email protected]
<snip>
> Are you saying that the two patch conflict? If not, can someone please
> verify that both together are safe? Or is your patch a superset?
>
Actually, the patches are complementary. However, my patch I won't be
continuing to work on, as the entire way that partitions are
read/validated/passed to devfs/etc will be changed in 2.5, and I've already
forwarded this patch over to the maintainer of that code (whose name escapes
my memory at the moment). So I'd say don't worry about it from the devfs
end, you'll see the changes once 2.5 opens and these changes get merged in
to that tree.