2001-11-11 04:40:42

by Jack Howarth

[permalink] [raw]
Subject: ide-floppy.c vs devfs

Paul,
Is ide-floppy supposed to be devfs friendly? I ask
because on Linux 2.4.15-pre2 (and previous kernels)
on the Powermac (Debian ppc sid) I find that the
ide-floppy driver only creates device for my ide
zip if a zip disk is inserted at boot time. Otherwise
the /dev/ide/host1/bus0/target1/lun0 directory doesn't
contain a device node for the zip whereas the ide-cdrom
driver creates a /dev/ide/host1/bus0/target0/lun0/cd
fine without a cdrom disk inserted at boot time. I find
that the only way I can get the zip device created at
boot time without media inserted is to use ide-scsi
emulation and turn off ide-floppy when I configure the
kernel. Is this issue a known problem and does it
exist for other arches than powerpc (Powermac)? Thanks
in advance for any advice.
Jack
------------------------------------------------------------------------------
Jack W. Howarth, Ph.D. 231 Albert Sabin Way
NMR Facility Director Cincinnati, Ohio 45267-0524
Dept. of Molecular Genetics phone: (513) 558-4420
Univ. of Cincinnati College of Medicine fax: (513) 558-8474


2001-11-12 06:49:06

by Borsenkow Andrej

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

The fix for it is included in current Mandrake cooker. As I already
said, I do not like it (the fix is to pretend we have media when we have
none) but it is the only possible way given current partition layer
design it seems.

I would prefer that partition layer registered .../disc for removable
media irrespectively of whether media is inserted or not, but well ...
it's up to other people to decide.

-andrej

Sorry, replying off web archive.

2001-11-23 05:14:00

by Richard Gooch

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

Jack Howarth writes:
> Paul,
> Is ide-floppy supposed to be devfs friendly? I ask
> because on Linux 2.4.15-pre2 (and previous kernels)
> on the Powermac (Debian ppc sid) I find that the
> ide-floppy driver only creates device for my ide
> zip if a zip disk is inserted at boot time. Otherwise
> the /dev/ide/host1/bus0/target1/lun0 directory doesn't
> contain a device node for the zip whereas the ide-cdrom
> driver creates a /dev/ide/host1/bus0/target0/lun0/cd
> fine without a cdrom disk inserted at boot time. I find
> that the only way I can get the zip device created at
> boot time without media inserted is to use ide-scsi
> emulation and turn off ide-floppy when I configure the
> kernel. Is this issue a known problem and does it
> exist for other arches than powerpc (Powermac)? Thanks
> in advance for any advice.

Is this an LS-120 drive? If so, I'm soon getting one, so I can finally
play with this.

Regards,

Richard....
Permanent: [email protected]
Current: [email protected]

2001-11-25 22:05:20

by Paul Bristow

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

Hi Jack,

Try the devfs test version that I just uploaded to

http://paulbristow.net/linux/idefloppy.html

This is early days, and I'm not sure what the best approach is...

Feedback is greatly appreaciated.

Jack Howarth wrote:

> Paul,
> Is ide-floppy supposed to be devfs friendly? I ask
> because on Linux 2.4.15-pre2 (and previous kernels)
> on the Powermac (Debian ppc sid) I find that the
> ide-floppy driver only creates device for my ide
> zip if a zip disk is inserted at boot time. Otherwise
> the /dev/ide/host1/bus0/target1/lun0 directory doesn't
> contain a device node for the zip whereas the ide-cdrom
> driver creates a /dev/ide/host1/bus0/target0/lun0/cd
> fine without a cdrom disk inserted at boot time. I find
> that the only way I can get the zip device created at
> boot time without media inserted is to use ide-scsi
> emulation and turn off ide-floppy when I configure the
> kernel. Is this issue a known problem and does it
> exist for other arches than powerpc (Powermac)? Thanks
> in advance for any advice.
> Jack
> ------------------------------------------------------------------------------
> Jack W. Howarth, Ph.D. 231 Albert Sabin Way
> NMR Facility Director Cincinnati, Ohio 45267-0524
> Dept. of Molecular Genetics phone: (513) 558-4420
> Univ. of Cincinnati College of Medicine fax: (513) 558-8474
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>


--

Paul

Email:
[email protected]
Web:
http://paulbristow.net
ICQ:
11965223

2001-11-25 22:32:00

by Richard Gooch

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

Paul Bristow writes:
> Hi Jack,
>
> Try the devfs test version that I just uploaded to
>
> http://paulbristow.net/linux/idefloppy.html
>
> This is early days, and I'm not sure what the best approach is...
>
> Feedback is greatly appreaciated.

I haven't had time to look at this closely, but I question why you're
trying to prevent grok_partitions() from doing it's thing. There's
supposed to be a flag set for removable media which ensures media
revalidation on scanning the parent directory or looking up an entry.
I'd rather see that mechanism fixed.

Regards,

Richard....
Permanent: [email protected]
Current: [email protected]

2001-11-26 10:05:21

by Borsenkow Andrej

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

>> Try the devfs test version that I just uploaded to
>>
>> http://paulbristow.net/linux/idefloppy.html
>>
>> This is early days, and I'm not sure what the best approach is...
>>
>> Feedback is greatly appreaciated.
>

On this page you mention that Mandrake includes this patch, but your
driver (link on the above patch) differs from Mandrake one. In patch I
sent to Mandrake I just fake drive capacity in case
CAPACITY_NO_CARTRIDGE is returned.

>
> I haven't had time to look at this closely, but I question why you're
> trying to prevent grok_partitions() from doing it's thing. There's
> supposed to be a flag set for removable media which ensures media
> revalidation on scanning the parent directory or looking up an entry.
> I'd rather see that mechanism fixed.

Currently grok_partitions() silently ignores any media with size == 0,
irrespectively of whether removable is set or not. It means that *no*
entries for drive (either disc or part?) are created at all and there is
nothing that later on triggers revalidation.

I still believe grok_partitions() should create disc node for removables
even if current capacity == 0 (that for removable just means there is no
media inserted). Then it would work the way you describe and faking
drive capacity for empty drives could be removed (IIRC it happens for
other removables like SCSI disks as well).


-andrej

2001-11-26 17:42:31

by Paul Bristow

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

The problem is one of making it user-comprehensible.

If I just use grok_partitions I get no disc nodes created in devfs. If
I do my thing I get a floppy node created, regardless of wether a disk
is inserted at load time. This gives something for you to attempt to
mount after inserting a disk, that causes a revalidate, and gets the
correct disk nodes created.

This is made somewhat more complicated by the fact that ide-floppy disks
can use either the whole disk, with no partition table or, more
commonly, partition4. So a user-friendly solution would be to create a
floppy node that pointed to the partition, if it existed, or the whole
disk if it didn't. With appropriate code to handle that fact that
anyone can partition these disks in any way they like.

Note this doesn't take account of the nice ATAPI command that sets the
disk into "ignore track 0" mode, making a partition 4 look like an
entire floppy with 1 less track.

Anyone up to telling me how this is handled in the SCSI layer?

Borsenkow Andrej wrote:

>>>Try the devfs test version that I just uploaded to
>>>
>>>http://paulbristow.net/linux/idefloppy.html
>>>
>>>This is early days, and I'm not sure what the best approach is...
>>>
>>>Feedback is greatly appreaciated.
>>>
>
> On this page you mention that Mandrake includes this patch, but your
> driver (link on the above patch) differs from Mandrake one. In patch I
> sent to Mandrake I just fake drive capacity in case
> CAPACITY_NO_CARTRIDGE is returned.


Sorry, not trying to detract from anyone's work. That line refers to

mandrake having the clik support way before it was included in the stock

kernel. I'll clarify the web page.

>>I haven't had time to look at this closely, but I question why you're
>>trying to prevent grok_partitions() from doing it's thing. There's
>>supposed to be a flag set for removable media which ensures media
>>revalidation on scanning the parent directory or looking up an entry.
>>I'd rather see that mechanism fixed.
>>
>
> Currently grok_partitions() silently ignores any media with size == 0,
> irrespectively of whether removable is set or not. It means that *no*
> entries for drive (either disc or part?) are created at all and there is
> nothing that later on triggers revalidation.
>
> I still believe grok_partitions() should create disc node for removables
> even if current capacity == 0 (that for removable just means there is no
> media inserted). Then it would work the way you describe and faking
> drive capacity for empty drives could be removed (IIRC it happens for
> other removables like SCSI disks as well).
>



--

Paul

Email:
[email protected]
Web:
http://paulbristow.net
ICQ:
11965223

2001-11-27 12:40:22

by Borsenkow Andrej

[permalink] [raw]
Subject: RE: ide-floppy.c vs devfs

>
> This is made somewhat more complicated by the fact that ide-floppy
disks
> can use either the whole disk, with no partition table or, more
> commonly, partition4. So a user-friendly solution would be to create
a
> floppy node that pointed to the partition, if it existed, or the whole
> disk if it didn't. With appropriate code to handle that fact that
> anyone can partition these disks in any way they like.
>

Where's the problem? Use .../disc for whole disc or .../part4 for
"normal" access. (Or /dev/hdc and /dev/hdc4 if you prefer) It is nice if
partition code can detect it but it is not ide-floppy driver problem.

> Note this doesn't take account of the nice ATAPI command that sets the
> disk into "ignore track 0" mode, making a partition 4 look like an
> entire floppy with 1 less track.
>

Why complicate things more than needed?

> Anyone up to telling me how this is handled in the SCSI layer?
>

When I boot without media in Jaz drive I get something like "no media
inserted, assuming 1GB 512B per sector". Actually I modeled my patch
from this - use some default values reported by drive when no media
currently exists.

-andrej

2001-11-27 17:45:05

by Paul Bristow

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs



Borsenkow Andrej wrote:

>>This is made somewhat more complicated by the fact that ide-floppy
>>
> disks
>
>>can use either the whole disk, with no partition table or, more
>>commonly, partition4. So a user-friendly solution would be to create
>>
> a
>
>>floppy node that pointed to the partition, if it existed, or the whole
>>disk if it didn't. With appropriate code to handle that fact that
>>anyone can partition these disks in any way they like.
>>
>>
>
> Where's the problem? Use .../disc for whole disc or .../part4 for
> "normal" access. (Or /dev/hdc and /dev/hdc4 if you prefer) It is nice if
> partition code can detect it but it is not ide-floppy driver problem.


Just wondering if we should be clever for the users here. Maybe I
should leave that to user-space tools? Or is there anything in devfs
that can take care of this? The nice solution for end-users might be
a /dev/idefloppy that is a symlink to the relevant node in the
/dev/ide... tree.


>>Note this doesn't take account of the nice ATAPI command that sets the
>>disk into "ignore track 0" mode, making a partition 4 look like an
>>entire floppy with 1 less track.
>>
>>
>
> Why complicate things more than needed?

Because you can boot from a zip or ls-120 drive, with the BIOS setting
it to this mode. There are disks out there that are unreadable unless
you ignore track zero, by formatting them in a PC like this.


>>Anyone up to telling me how this is handled in the SCSI layer?
>>
>>
>
> When I boot without media in Jaz drive I get something like "no media
> inserted, assuming 1GB 512B per sector". Actually I modeled my patch
> from this - use some default values reported by drive when no media
> currently exists.


OK. This makes the most sense here. I'm happy to go with this.

I'll dig out your patch - discovered I was on holiday when you
originally submitted it - and code and test something over the next day
or so. Thanks for the help


> -andrej


--

Paul

Email:
[email protected]
Web:
http://paulbristow.net
ICQ:
11965223

2001-11-27 20:38:48

by Mike Fedyk

[permalink] [raw]
Subject: Re: ide-floppy.c vs devfs

On Tue, Nov 27, 2001 at 06:47:03PM +0100, Paul Bristow wrote:
>
>
> Borsenkow Andrej wrote:
>
> >>This is made somewhat more complicated by the fact that ide-floppy
> >>
> >disks
> >
> >>can use either the whole disk, with no partition table or, more
> >>commonly, partition4. So a user-friendly solution would be to create
> >>
> >a
> >
> >>floppy node that pointed to the partition, if it existed, or the whole
> >>disk if it didn't. With appropriate code to handle that fact that
> >>anyone can partition these disks in any way they like.
> >>
> >>
> >
> >Where's the problem? Use .../disc for whole disc or .../part4 for
> >"normal" access. (Or /dev/hdc and /dev/hdc4 if you prefer) It is nice if
> >partition code can detect it but it is not ide-floppy driver problem.
>
>
> Just wondering if we should be clever for the users here. Maybe I
> should leave that to user-space tools? Or is there anything in devfs
> that can take care of this? The nice solution for end-users might be
> a /dev/idefloppy that is a symlink to the relevant node in the
> /dev/ide... tree.
>

Can't devfsd be configured to do something like this?

> >Why complicate things more than needed?
>
> Because you can boot from a zip or ls-120 drive, with the BIOS setting
> it to this mode. There are disks out there that are unreadable unless
> you ignore track zero, by formatting them in a PC like this.
>

If that's what is required to boot from ls-120 and zip, then it probably
needs to be in kernel space.

MF

2001-11-28 18:34:24

by Paul Bristow

[permalink] [raw]
Subject: [PATCH] ide-floppy real devfs support for testing

diff -burN -X dontdiff linux-2.4.16-clean/drivers/ide/ide-floppy.c linux-2.4.16/drivers/ide/ide-floppy.c
--- linux-2.4.16-clean/drivers/ide/ide-floppy.c Wed Nov 28 19:25:34 2001
+++ linux-2.4.16/drivers/ide/ide-floppy.c Wed Nov 28 19:30:36 2001
@@ -1,10 +1,12 @@
/*
- * linux/drivers/ide/ide-floppy.c Version 0.97.sv Jan 14 2001
+ * linux/drivers/ide/ide-floppy.c
*
* Copyright (C) 1996 - 1999 Gadi Oxman <[email protected]>
* Copyright (C) 2000 - 2001 Paul Bristow <[email protected]>
*/

+#define IDEFLOPPY_VERSION "0.99-devfs-test4"
+
/*
* IDE ATAPI floppy driver.
*
@@ -82,9 +84,9 @@
* msec works on my system. The variable ticks is exposed
* in /proc/ide/hdx/settings. Each tick is 10 msec. If ticks is
* set to zero, the driver reverts to the old algorithm. --Skip
+ * Ver 0.99 Nov 22 01 Add devfs support
*/

-#define IDEFLOPPY_VERSION "0.98"

#include <linux/config.h>
#include <linux/module.h>
@@ -101,6 +103,7 @@
#include <linux/slab.h>
#include <linux/cdrom.h>
#include <linux/ide.h>
+#include <linux/devfs_fs_kernel.h>

#include <asm/byteorder.h>
#include <asm/irq.h>
@@ -275,6 +278,7 @@
*/
typedef struct {
ide_drive_t *drive;
+ devfs_handle_t de; /* devfs entry */

idefloppy_pc_t *pc; /* Current packet command */
idefloppy_pc_t *failed_pc; /* Last failed packet command */
@@ -673,6 +677,8 @@
#define IDEFLOPPY_MIN(a,b) ((a)<(b) ? (a):(b))
#define IDEFLOPPY_MAX(a,b) ((a)>(b) ? (a):(b))

+extern devfs_handle_t ide_devfs_handle; /* Hook into ide devfs chain */
+
/*
* Too bad. The drive wants to send us data which we are not ready to accept.
* Just throw it away.
@@ -1097,6 +1103,7 @@
return ide_started;
}

+
/*
* Issue a packet command
*/
@@ -1483,9 +1490,14 @@
if (memcmp (descriptor, &floppy->capacity, sizeof (idefloppy_capacity_descriptor_t)))
printk (KERN_INFO "%s: %dkB, %d blocks, %d sector size\n", drive->name, blocks * length / 1024, blocks, length);
floppy->capacity = *descriptor;
- if (!length || length % 512)
+ if (!length || length % 512) {
printk (KERN_NOTICE "%s: %d bytes block size not supported\n", drive->name, length);
- else {
+ } 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;
+ } else {
floppy->blocks = blocks;
floppy->block_size = length;
if ((floppy->bs_factor = length / 512) != 1)
@@ -2027,6 +2039,7 @@
ide_add_setting(drive, "ticks", SETTING_RW, -1, -1, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL);
}

+
/*
* Driver initialization.
*/
@@ -2035,6 +2048,9 @@
struct idefloppy_id_gcw gcw;
int major = HWIF(drive)->major, i;
int minor = drive->select.b.unit << PARTN_BITS;
+ char fname[64],iname[64]; /* for devfs */
+ devfs_handle_t idefloppy_devfs_handle; /* for devfs */
+ ide_hwif_t *hwif = HWIF(drive);

*((unsigned short *) &gcw) = drive->id->config;
drive->driver_data = floppy;
@@ -2080,26 +2096,46 @@
set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags);
}

-
(void) idefloppy_get_capacity (drive);
idefloppy_add_settings(drive);
+
for (i = 0; i < MAX_DRIVES; ++i) {
- ide_hwif_t *hwif = HWIF(drive);

if (drive != &hwif->drives[i]) continue;
hwif->gd->de_arr[i] = drive->de;
+
if (drive->removable)
hwif->gd->flags[i] |= GENHD_FL_REMOVABLE;
break;
}
+
+ /* Always register drive with devfs */
+ floppy->de = devfs_register (drive->de, "disc", DEVFS_FL_REMOVABLE,
+ major, minor,
+ S_IFBLK | S_IRUGO | S_IWUGO,
+ ide_fops, NULL);
+ /* Create ide/fd entry in devfs */
+ idefloppy_devfs_handle = devfs_mk_dir(ide_devfs_handle,"fd",NULL);
+
+ sprintf (fname, "c%db%dt%du%d",
+ (hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,
+ hwif->channel, i, hwif->drives[i].lun);
+ sprintf (iname, "../host%d/bus%d/target%d/lun%d/disc",
+ (hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,
+ hwif->channel, i, hwif->drives[i].lun);
+ devfs_mk_symlink(idefloppy_devfs_handle, fname, DEVFS_FL_REMOVABLE, iname, NULL, NULL);
}

+
static int idefloppy_cleanup (ide_drive_t *drive)
{
idefloppy_floppy_t *floppy = drive->driver_data;

if (ide_unregister_subdriver (drive))
return 1;
+
+ devfs_unregister(floppy->de);
+
drive->driver_data = NULL;
kfree (floppy);
return 0;
@@ -2212,6 +2248,7 @@

module_init(idefloppy_init);
module_exit(idefloppy_exit);
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Maintainer: Paul Bristow <[email protected]>");
MODULE_DESCRIPTION("ATAPI Floppy Driver V"IDEFLOPPY_VERSION);
diff -burN -X dontdiff linux-2.4.16-clean/drivers/ide/ide-probe.c linux-2.4.16/drivers/ide/ide-probe.c
--- linux-2.4.16-clean/drivers/ide/ide-probe.c Mon Nov 26 14:29:17 2001
+++ linux-2.4.16/drivers/ide/ide-probe.c Wed Nov 28 18:49:38 2001
@@ -121,6 +121,7 @@
if (!strstr(id->model, "oppy") && !strstr(id->model, "poyp") && !strstr(id->model, "ZIP"))
printk("cdrom or floppy?, assuming ");
if (drive->media != ide_cdrom) {
+ drive->removable = 1;
printk ("FLOPPY");
break;
}


Attachments:
ide-floppy-devfs-patch (5.55 kB)