1 BREAK <MFT Definitions>
3 ;** MSDOS MFT definitions
5 ; The Master File Table (MFT) associates the cannonicalized pathnames, lock
6 ; records and SFTs for all files open on this machine.
8 ; The MFT implementation employs a single memory buffer which is used from
9 ; both ends. This gives the effect (at least until they run into each
10 ; other) of two independent buffers.
14 ; The MFT buffer contains MFT name records and free space. It uses a
15 ; classic heap architecture: freed name records are marked free and
16 ; conglomerated with any adjacent free space. When one is to create a name
17 ; entry the free list is searched first-fit. The list of name and free
18 ; records is always terminated by a single END record.
22 ; The lock buffer contains fixed format records containing record locking
23 ; information. Since they are fixed format the space is handled as a series
24 ; of chains: one for each MFT name record and one for the free list. No
25 ; garbage collection is necessary.
29 ; The MFT is managed as a heap. Empty blocks are allocated on a first-fit
30 ; basis. If there is no single large enough empty block the list is garbage
36 ; |------|-----|-----|------|------|------|---------~~~~~~---------|
37 ; | FLAG | LEN | SUM | LPTR | SPTR | SERL | <.asciz string> |
38 ; --------------------------------------------------~~~~~~----------
40 ; FLAG = record type flag
41 ; LEN = total byte length of record.
42 ; SUM = sum of bytes in asciz string. Used to speed
44 ; LPTR= pointer to first record in lock chain segment
46 ; SPTR= pointer to first sft in sft chain
48 ; <string> = name string, zero-byte terminated. There
49 ; may be garbage bytes following the 00 byte;
50 ; these are counted in the LEN field.
56 ; |------|-----|----~~~~~~~~~~~~~~~~~~~~~~~~~~~---------|
57 ; | FLAG | LEN | free |
58 ; ------------------~~~~~~~~~~~~~~~~~~~~~~~~~~~----------
60 ; FLAG = record type flag
61 ; LEN = total byte length of record.
71 ; FLAG = record type flag
75 ;* NOTE: the flag and length fields are identical for all record types
76 ;* (except the END type has no length) This must remain so as
77 ;* some code depends upon it.
79 ;* NOTE: Many routines check for "n-1" of the N flag values and if no
80 ;* match is found assume the flag value must be the remaining
81 ;* possibility. If you add or remove flag values you must check
82 ;* all references to mft_flag.
86 mft_flag DB ? ; flag/len field
88 mft_sum DB ? ; string sum word
89 mft_lptr DW ? ; LCK pointer
90 mft_sptr DD ? ; sft pointer
91 mft_serl DW ? ; serial number
92 mft_name DB ? ; offset to start of name
96 MFLG_NAM EQU 1 ; min value for name record
97 MFLG_FRE EQU 0 ; free record
98 MFLG_END EQU -1 ; end record
100 ;* Record Lock Record (RLR):
103 ; |-------|--------|--------|--------|
104 ; | NEXT | FBA | LBA | SPTR |
105 ; | | lo hi | lo hi | |
106 ; ------------|--------|--------------
108 ; CHAIN = pointer to next RLR. 0 if end
109 ; FBA = offset of 1st byte of locked region
110 ; LBA = offset of last byte of locked region
111 ; SPTR = pointer to SFT lock was issued on
115 rlr_next DW ? ; chain to next RLR, 0 if end
116 rlr_fba DW ? ; first byte addr (offset) of reigion
118 rlr_lba DW ? ; last byte addr of region
120 rlr_sptr DD ? ; SFT pointer
121 rlr_pid dw ? ; process id of issuer
122 rlr_type dw ? ; lock type
125 rlr_lall equ 00h ; lock all ops
126 rlr_lwr equ 01h ; lock write ops
129 ; A pictorial diagram for the linkages is as follows:
133 ; +---+<----------|---sptr------+------------+
135 ; +-+-+ | +-+-+ +--+-+ +--+-+
136 ; V +--->|MFT+-lptr->-|LOCK+-next->|LOCK+->0
137 ; +---+ | +---+ +----+ +----+
147 ; Interesting behavior should be noted:
149 ; The sharer must maintain information on files in three forms:
151 ; local/remote handles. These are normal handles and behave in no
152 ; strange manner. They are identified by SF_mode not having the
153 ; sfIsFCB flag nor by having the sf_mode = 70. No problems with
154 ; locking. No problems with open. No problems with close.
155 ; CloseByName will iterate closes until the mft disappears.
156 ; CloseUser will iterate closes until no SFT for the particular user
157 ; appears. CloseProcess will iterate closes until no SFT for the
158 ; particular user/process appears.
160 ; local FCBs. There are no corresponding SFT's for these as the SFTs
161 ; are cached but will be valid for the particular file. There is
162 ; one SFT for each open on a file by a specific process. These are
163 ; identified the sfIsFCB flag in the sf_mode field. When multiple
164 ; opens occur, we merely find the sf pertinent to the file and
165 ; process. Close decrements the ref count. CloseByName, CloseUser,
166 ; CloseProcess will iterate closes until no more SFTs exist.
168 ; handles with mode 70. These represent FCB's open across the network.
169 ; As such, identical sfts may have been collapsed by the $open code.
170 ; This results in a reuse of the same SFT. The $Open code must
171 ; correctly set the ref-count for the sft to reflect the number of
172 ; collapses that have occurred. These are identified by a 70 in the
173 ; SF_mode field. There can be no locking on these SFTs. Open must
174 ; scan the list of SFTs for the file and increment its ref count