[comp.sys.ibm.pc.programmer] DOS FAT table updates

dixon@sagittarius.crd.ge.com (walt dixon) (05/28/90)

In <30365@ut-emx.UUCP> David T. Croley asks:

>I am curious.  When DOS is saving a file, does it write the file
>to disk and then update the FAT and write it to disk, or is the order
>reversed.

In most cases the write comes first.  FAT access is cached.  DOS only
uses the disk cache for partial block reads and writes,  FAT access,
and directory access.  There are several conditions that cause DOS
to flush the cache.  Closing a file,  disk reset,  and running out of
cache blocks all cause the cache to be flushed.  Its been a while since
I looked through the caching code;  I may be missing some important
cases.  BTW the caching code is not particularly well written and
consequently is somewhat difficult to follow.

>Also, does anyone know where I can get info on the routines DOS uses
>to allocate clusters to a file.  I would like to replace these with my
>own routines if possible.

At least in IBM-DOS 3.10,  the search began after the last cluster in
the file and progressed until either the end of the disk had been reached
or the required number of clusters had been found.  There's no clean
way to replace the cluster allocation code.  You could try patching
the internal write routine or the cluster allocation routine.  The
strategy DOS uses actually is not too bad.

>I have looked in every DOS reference that I can find, and none are
>detailed enough to have this type of information.

I got my information with a disassembler.  The original draft of Chapter
10 of "The MS-DOS Papers" had a detailed explaination of how DOS
does disk i/o.  Unfortunately this material was edited out to save
space.

Walt Dixon		{internet:	dixon@crd.ge.com	}
			{us mail:	ge crd			}
			{		po box 8		}
			{		schenectady, ny 12301	}
			{voice:		518-387-5798		}
Walt Dixon dixon@crd.ge.com