The various code sections in the enclosed *.s files are related as follows:

M_DTA.S		defines the M_dta data structure used by BetaDOS
M_DTALIB.S	contains subroutines for handling M_dta linked lists
MDFUNCFS.S	contains the BetaDOS subroutines for Fsfirst and Fsnext
INIT_DTA.S	contains the code that initializes the M_dta list

The M_dta struct allows BetaDOS to associate various extra data with a DTA
specified by calling APPs.  For BNeT its usage will of course need to be
somewhat different, but the main approach can still be the same.

This main approach is that M_dta structs are allocated from a limited pool,
in the case of BetaDOS having 100 entries.  Such an entry may be released
in a number of circumstances when detecting that the DTA block associated
with it is used in some conflicting manner (eg: part of an Mfree block),
such as will often be the case when an APP using DTAs terminates.

But since no formal call for releasing DTA blocks is defined, and many APPs
may stay permanently resident, and using various DTAs even when not needed,
it is sometimes inevitable that all M_dta entries will be 'used up'.

The solution to this in Atari MetaDOS (though badly implemented) is the same
as in my BetaDOS, namely to reallocate the least recently referred DTA blocks.

This has the (negative ?) consequence that APPs which do really stupid things,
such as starting an Fsfirst access one day and trying to continue with the
scan of that directory a few days later, are quite likely to fail.  About
this limitation of the method all I can say is 'BFD!'...    ;-)

Fsfirst/Fsnext scans are inherently short-term operations, as the directorys
may otherwise have been altered or even erased when a scan is continued. That
will also cause strange failures even with an unlimited supply of DTA structs.
Such programs must be considered garbage anyway, and should be deleted, IMHO.

So, the method to use (even according to Atari) is 'least recent reference'
reallocation, and BetaDOS does this by establishing a fully linked list of
M_dta structs all of which are ordered by how recently each struct has been
referred to in a legal APP call to Fsfirst/Fsnext.  At one end we have the
most recently referred M_dta, pointed to by the root pointer M_dta_last,
and at the other end we have the least recently referred M_dta, or those
never referred at all (when not all have been used yet) and this end of
the list is pointed to by the root pointer M_dta_first.  The latter name
was chosen to indicate that this is the first M_dta that will be allocated
by future Fsfirst calls.  (Fsnext never allocates a new M_dta.)

For BNeT, it may be necessary to duplicate this system, using one M_dta
definition for the end local to the calling APP, with another M_dta
definition for the remote end.  And of course both systems will need to
coexist inside BNET.APP, for cases where MagiC is not used.  As I am not
well informed on the needs of the current BNeT version you'll have to solve
those parts yourself.

Hopefully the information already given is enough for you to implement a
similar system for BNeT.  If not, let's get back to it in further Email.
