Re: Of removable devices

From: David Balazic (david.balazic@uni-mb.si)
Date: Wed Feb 16 2000 - 14:39:31 EST


To add my own $0.02 ...

The situation with removable devices is pretty bad. Redhat 6.x has TWO
packages to "solve" it. They are magicdev ( part of GNOME ) and autorun
( KDE ).

I observed their work with CDs , I don't know if they support floppies
too.

autorun/magicdev is started when the KDE/GNOME desktop is started (
startx or
xdm/kdm/gdm login ). They both wait for an inserted CD and then mount it
and
optionaly run the file /<cd-mount-point>/autorun .
They unmount and eject the CD when the :
 - eject command is executed
 - user clicks on "eject" in the context menu of the CD-drive icon
 - maybe some other cases I don't know

autorun also doesn't lock the drive so the user can eject it manually.
When that is detected autorun unmounts the CD ( if it is not in use,
if it is, shit happens )

Now my opinion is that both programs suck. The automatic execution of
the autorun file is stupid IMHO ( altough beginner may like it ).

Second the mounting functionality can be done (better?) by autofs.

I recomend/propose/use the following.
Let autofs mount the CD on access ( it makes no sense to mount it, if it
won't be used ). Configure a short umount period ( 5 secs , or even less
),
so the user can eject the CD by pressing the cd-drive's eject button
shortly
after finishing using the CD.
The door should be locked while the CD is mounted.

This solution works pretty well.
It is clean ( IMHO ).
Doesn't require extra software.
No danger of any corruptions. ( of kernel structures , like when the
medium is
  ejected while still mounted ).

Problems :
if the CD is unmounted ( due to timeout ) and then later accessed again,
the CD
is first spinned up ( my drive has a 10 sec timeout for spin-down ) and
something
is read from it. This takes about 5 secs and happens for even the
smallest access,
like "cd /auto/cd". It seems that the kernel driver checks if the medium
is still
the same which contents are cached.
( this is kernel 2.2.14 , ATAPI cdrom on /dev/hdc , type TEAC CD532E-B
).

For automatic program start ( for those who want it ) a simplified demon
might be used :

for(EVER){
 wait_for_CD_insertion(); /* code can be ripped from magicdev or
autorun */
 system(CD_PATH "/autorun"); /* autofs will mount it for us */
}

I also played with the idea to mount the CD when it is inserted, then
wait for either :
- /bin/eject is called
- some GUI equivalent to /bin/eject
- user press the EJECT button on the drive (*)
 and the either unmount it and eject it, or ,if unmount is not possible
, either do
nothing or inform the user that the CD can not be ejected , because it
is in use.

(*) - this is the problem. Even if both ATA and ATAPI standards specifiy
a method
of infroming the host that the eject button was pressed, my cd-rom drive
does not
support any method for that ( or I couldn't figure it out ).
I believe that 99 % of all ATAPI CD-ROM units ( situation with SCSI may
be better,
but I wouldn't bet my hat on it ) fail to support this.

So I dropped this idea.

As for floppies:

The autofs approach has the following problems :

Eject can not be prevented, so at least the following must be done :

- for read-only floppies : somehow unmount it , even if it is in use
  is this possible ?
 or maybe hide it from further access , return some error to apps that
 have open files on it and try to read from them, and when the last user
 terminates , unmount it for good.

- r/w floppy :
  - ( for caching ) if there is dirty data in caches, start writing them
    immediately , so that the drive LED is on and the user won't eject
it.
  - same as for r/o access ( hiding and returning errors for further use
)

Another possibility : somehow keep the LED on as long as the drive is
mounted.
  

Hope some of my babbling made sense :-)

--
David Balazic

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:15 EST