Path: utzoo!utgpu!watserv1!watmath!att!bellcore!rutgers!cs.utexas.edu!samsung!uunet!crdgw1!ra!dixon From: dixon@ra.crd.ge.com (walt dixon) Newsgroups: comp.sys.ibm.pc Subject: Re: Retrieving the value of FILES=??? Keywords: Global File Handle Table Message-ID: <8641@crdgw1.crd.ge.com> Date: 16 Jun 90 13:13:14 GMT References: <605@digigw.digital.co.jp> <4057@jato.Jpl.Nasa.Gov> <1990Jun15.133128.17259@druid.uucp> Sender: news@crdgw1.crd.ge.com Reply-To: dixon@ra.crd.ge.com (walt dixon) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 70 In article <1990Jun15.133128.17259@druid.uucp> D'Arcy J.M. Cain writes: >In article <4057@jato.Jpl.Nasa.Gov> kaleb@mars.UUCP (Kaleb Keithley) writes: >> [Discussion about finding the files/process in DOS] >>How about: (in psuedo-code) >> fopen ("/CONFIG.SYS", "r"); >> fscanf (..., "FILES=", ...); >> fscanf (..., value, ...); >> fclose (...); >> >And if the table has been changed using int 67h it doesn't tell you the >correct value. What you need is a TSR that you run at startup which >does the following at initialisation. >Determines the value for max files using following: > From command line if given > From FILES= in config.sys if available > Normal default otherwise. >Use int 67h to set up this value - this makes sure value is known. >It then sets up a hook to int 67h to check for special value in BX (say >-1) and returns current value if it is that special value. Otherwise >it calls the original int 67h and keeps track of the new value. Then >your programs can call int 67h with -1 to get the current value. >No wonder they call it Messy-DOS. :-) There seems to be some confusion here. DOS maintains two separate tables. Each program contains the address and size of a Job File Table (JFT) within its PSP. The default size of the JFT is 20 files, and its default location is within the PSP. As far as I can tell from a real quick disassembly, int 21h ah=67h just replaces the JFT pointer and size in the PSP. (Of course it copies the existing JFT contents and initializes any new entries properly). DOS uses the file handle returned by open/create requests as an index into the job file table. Unused JFT entries contain a 0xff; active entries contain an integer in the 0 to 0xfe range. This entry is an index into the System File Table. The System File Table is a global table containing specific information about all open files and devices. Among the information in the SFT is the name of the file/device, a reference count, an owner PSP, a pointer to the device header for character devices or a pointer to the Device Control Block for block devices, various flags, and other miscellaneous information. The FILES statement in CONFIG.SYS sets the size of the System File Table NOT the size of the Job File Table. Int 21h AH=67h sets the size of the Job File Table. As I noted in a previous posting, the correct way to determine the size of the system file table is to find its base through int 21h ah=52h and walk the linked list of table blocks adding up block sizes. One could also count used/free table entries in this process. To determine the size of the JFT, one only has to look inside the PSP. Scanning the table pointed to by the appropriate PSP address, allows one to determine its free/used entries. This information is more fully described in Chapter 10 of "The MS-DOS Papers" (Howard Sams, 1988). I am the author of this chapter and the following one on device drivers. (BTW I derive no revenue from book sales). The material presented in Chapter 10 came from disassembling DOS 3.10 and may be a little dated. As I initially noted, I have not fully disassembled DOS 3.30 which actually supports int 21h AH=67h. Walt Dixon {internet: dixon@crd.ge.com } {us mail: ge crd } { po box 8 } { schenectady, ny 12301 } {phone: 518-387-5798 (W) } { 518-875-6203 (H) } Walt Dixon dixon@crd.ge.com