summaryrefslogtreecommitdiff
path: root/v4.0/src/INC/MFT.INC
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/INC/MFT.INC')
-rw-r--r--v4.0/src/INC/MFT.INC176
1 files changed, 176 insertions, 0 deletions
diff --git a/v4.0/src/INC/MFT.INC b/v4.0/src/INC/MFT.INC
new file mode 100644
index 0000000..0359f80
--- /dev/null
+++ b/v4.0/src/INC/MFT.INC
@@ -0,0 +1,176 @@
1BREAK <MFT Definitions>
2
3;** MSDOS MFT definitions
4;
5; The Master File Table (MFT) associates the cannonicalized pathnames, lock
6; records and SFTs for all files open on this machine.
7;
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.
11;
12; MFT buffer
13; ==========
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.
19;
20; LOCK buffer
21; ===========
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.
26;
27; Space allocation
28; ================
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
31; collected.
32;
33; MFT name records:
34;
35; 8 16 8 16 32 16 n
36; |------|-----|-----|------|------|------|---------~~~~~~---------|
37; | FLAG | LEN | SUM | LPTR | SPTR | SERL | <.asciz string> |
38; --------------------------------------------------~~~~~~----------
39;
40; FLAG = record type flag
41; LEN = total byte length of record.
42; SUM = sum of bytes in asciz string. Used to speed
43; searches
44; LPTR= pointer to first record in lock chain segment
45; is MFT segment
46; SPTR= pointer to first sft in sft chain
47; SERL= serial number
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.
51;
52;
53; MFT free records
54;
55; 8 16
56; |------|-----|----~~~~~~~~~~~~~~~~~~~~~~~~~~~---------|
57; | FLAG | LEN | free |
58; ------------------~~~~~~~~~~~~~~~~~~~~~~~~~~~----------
59;
60; FLAG = record type flag
61; LEN = total byte length of record.
62;
63;
64; MFT END records
65;
66; 8
67; |------|
68; | FLAG |
69; --------
70;
71; FLAG = record type flag
72
73;** MFT definitions
74;*
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.
78;*
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.
83
84MFT_entry STRUC
85
86mft_flag DB ? ; flag/len field
87mft_len DW ?
88mft_sum DB ? ; string sum word
89mft_lptr DW ? ; LCK pointer
90mft_sptr DD ? ; sft pointer
91mft_serl DW ? ; serial number
92mft_name DB ? ; offset to start of name
93
94MFT_entry ENDS
95
96MFLG_NAM EQU 1 ; min value for name record
97MFLG_FRE EQU 0 ; free record
98MFLG_END EQU -1 ; end record
99
100;* Record Lock Record (RLR):
101;
102; 16 32 32 32
103; |-------|--------|--------|--------|
104; | NEXT | FBA | LBA | SPTR |
105; | | lo hi | lo hi | |
106; ------------|--------|--------------
107;
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
112
113RLR_entry STRUC
114
115rlr_next DW ? ; chain to next RLR, 0 if end
116rlr_fba DW ? ; first byte addr (offset) of reigion
117 DW ?
118rlr_lba DW ? ; last byte addr of region
119 DW ?
120rlr_sptr DD ? ; SFT pointer
121rlr_pid dw ? ; process id of issuer
122rlr_type dw ? ; lock type
123RLR_entry ENDS
124
125rlr_lall equ 00h ; lock all ops
126rlr_lwr equ 01h ; lock write ops
127
128;
129; A pictorial diagram for the linkages is as follows:
130;
131; +---sptr------+
132; V |
133; +---+<----------|---sptr------+------------+
134; |SFT+----+ | | |
135; +-+-+ | +-+-+ +--+-+ +--+-+
136; V +--->|MFT+-lptr->-|LOCK+-next->|LOCK+->0
137; +---+ | +---+ +----+ +----+
138; |SFT+----+ ^
139; +-+-+ |
140; | |
141; +-------------+
142;
143;
144
145;**
146;
147; Interesting behavior should be noted:
148;
149; The sharer must maintain information on files in three forms:
150;
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.
159;
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.
167;
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
175; appropriately.
176 \ No newline at end of file