From: djung@economics.adelaide.edu.au (David Jung)
Newsgroups: comp.sys.amiga.programmer
Subject: A few Handler/FileSys Q's (Mod.Long.)
Date: 17 Dec 92 05:19:05 ACST
Organization: Economics, University of Adelaide
NNTP-Posting-Host: eco.economics.adelaide.edu.au
Keywords: handler filesystem packets Amiga DOS AmigaDOS lock FileLock

I am in the process (well beginning anyway) of writing a filesystem.  I have a
few questions.

First here's what I have discovered ... a scenario ...

(to carry this out you need two floppy drives and a disk with a moderately
long text file)

If I place a disk containing a text file into one drive - say df0, then open
up a shell and type 'cd more' & 'more file' the file is displayed and the
more program obtains a lock on the file (and the root dir incidently).

If I then remove the disk - the locks the FFS filesystem issued to More
appear on the dol_LockList of the disk's volume node in the DosList.

If I then open a second shell and type 'ls diskname:' (where diskname: is the
disk I just ejected) - I get the usual "please insert volume diskname in any
drive".  This is because DOS has discovered the volume node's dol_Task is NULL.

OK - so far so good.

Cancel the requester.  Now - with the disk still ejected - press the space bar
in the more window until more runs out of buffered file and has to read more
from the disk.  Now I get a "Please insert volume diskname in device df0:".
(Note this also happens if the disk has been inserted into the other drive!!)
(i.e. is wants me to remove it from df1 and insert it into df0!)

Note that it wants df0 not any drive.  I ASSUME the following has happened.

More has asked DOS to read more of the file, and DOS has used the FileLock's
fl_Task field to decide which handler to send the packet to. (only place
it can get it from since the volume node's dol_Task is NULL).

The handler has recieved a packet containing a lock that it is no longer
managing (no matching key or whatever) - and has put up the requester asking
for the volume.  My questions are (finally)

1) How can it do this??

If it called AutoRequest() or ErrorReport() it would be tied up - but it
still appears to be accepting packets.  If you repeat this whole thing but
bring up two more windows, then after getting a requester from pressing space
in the first more window - if you press space in the second window a second
identical requester appears.  if my ASSUMPTION is correct - the handler has
received another packet and done the same thing.

I looked at the task list - nothing is creating extra tasks specifically to
bring up requesters.


2) Is it legal, as a filesystem, to set the FileLock's fl_Task fields to
NULL before putting them on the dol_LockList when a volume has been removed?
Or is this rubbish. (wishfully thinking DOS might put up a requester for me)

3) As a filesystem, if a volume has just been inserted into the device you're
managing, and you grab the locks from the dol_LockList, can you Forbid(), go
through and change the fl_Task field of all the locks to yourself, then Permit()
so that any further use of the active FileLocks will be directed to you?


4) If, again as a filesystem, I get an argument FileLock for a volume I am
no longer managing (volume was ejected from my device), can I, upon inspection
of the DosList finding a non-NULL dol_Task field, send the packet onto
the other filesystem that is managing the volume now (assuming the dol_Task
field is non-NULL because the volume has been inserted into another device).
I would have to set up the packet so it was returned either to me, or directly
to the application/DOS.

Hope this makes sense.  Thanks for taking the time to read it.  Hope you
can shead some light for me.

                        -David Jung.

-- 
------
Freelance Software Developer    internet: djung@eco.adelaide.edu.au           //
Adelaide, Australia.               or     david@maxus.levels.unisa.edu.au \\ //
Newsgroups: comp.sys.amiga.programmer