source: buchla-68k/orig/DOC/FILESYS.TXT

Last change on this file was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 4.2 KB
Line 
1filesys.c -- file system support functions
2Version 11 -- 1987-06-03 -- D.N. Lynx Crowe
3
4These functions support a {MS,GEM}DOS-like file system.
5Subdirectories are not supported in this version.
6
7Variables:
8----------
9
10 struct bpb *_thebpb;
11 struct dirent _thedir[MAXDIRNT];
12 struct dirent *_dptr;
13
14 short _thefat[MAXFAT * WDPSEC];
15
16 int _fatin, _dirin, _bpbin;
17 long _berrno;
18
19Functions:
20----------
21
22 ClusMap(fcp)
23 SnapFCB(fcp)
24
25 _cl2lsn(bpp, clnum)
26 _deadio(fcp)
27 _dsrch(de)
28 _fmake(fcp)
29 _fsize(fcp)
30 _ftrnc(dp)
31 _getfat(bufad, bpp, nfat)
32 _gtcl12(fat, cl)
33 _inifcb(fcp, name,ext, mode)
34 _nsic(fcp, bpp, fp)
35 _opfcb(fcp)
36 _ptcl12(fat, cl, val)
37 _rdfat(bufad, bpp)
38 _rdroot(buf, bpp)
39 _rdsec(fcp, buf, ns)
40 _seek(fcp)
41 _sksec(fcp, sec)
42
43
44_cl2lsn(bpp, clnum)
45
46 Returns the logical sector number for cluster 'clnum' using the BPB
47 pointed to by 'bpp'.
48
49 int
50 _cl2lsn(bpp, clnum)
51 struct bpb *bpp;
52 int clnum;
53
54
55_ptcl12(fat, cl, val)
56
57 Puts 'val' into cluster 'cl' in the FAT at 'fat'.
58
59 putlc12(fat, cl, val)
60 register char *fat;
61 int cl, val;
62
63_gtcl12(fat, cl)
64
65 Returns the 12 bit cluster entry 'cl' from the FAT pointed to by 'fat'.
66
67 int
68 _gtcl12(fat, cl)
69 register char *fat;
70 int cl;
71
72
73_getfat(bufad, bpp, nfat)
74
75 Gets the FAT 'nfat' into the buffer pointed to by 'bufad' using
76 the BPB pointed to by 'bpp'.
77
78 int
79 _getfat(bufad, bpp, nfat)
80 int *bufad, nfat;
81 register struct bpb *bpp;
82
83_rdfat(bufad, bpp)
84
85 Reads the FAT into the buffer pointed to by 'bufad'using the BPB
86 pointed to by 'bpp'.
87
88 int
89 _rdfat(bufad, bpp)
90 int *bufad;
91 struct bpb *bpp;
92
93_rdroot(buf, bpp)
94
95 Reads the root directory into the buffer pointed to by 'buf'
96 using the BPB pointed to by 'bpp'.
97
98 int
99 _rdroot(buf, bpp)
100 int *buf;
101 register struct bpb *bpp;
102
103_nsic(fcp, bpp, fp)
104
105 Gets the next sector in the file controlled by the FCB at 'fcp',
106 using the BPB pointed to by 'bpp' and the FAT pointed to by 'fp'.
107 Returns: 0 if successful, -1 on error, or 1 on EOF;
108
109 int
110 _nsic(fcp, bpp, fp)
111 register struct fcb *fcp;
112 struct bpb *bpp;
113 char *fp;
114
115_dsrch(de)
116
117 Searches for the directory entry pointed to by 'de' in
118 the current directory.
119
120 struct dirent *
121 _dsrch(de)
122 register struct dirent *de;
123
124
125_deadio(fcp)
126
127 Marks the FCB pointed to by 'fcp' as 'in error'.
128
129 _deadio(fcp)
130 register struct fcb *fcp;
131
132_seek(fcp)
133
134 Seeks to to logical sector number in FCB pointed to by 'fcp'
135 Returns: -1 = error, 0 = OK, 1 = EOF.
136
137 int
138 _seek(fcp)
139 register struct fcb *fcp;
140
141_ftrnc(dp)
142
143 Truncates the file pointed to by directory entry 'dp'.
144
145 int
146 _ftrnc(dp)
147 struct dirent *dp;
148
149_fmake(fcp)
150
151 Makes a new file from the FCB pointed to by 'fcp'.
152
153 int
154 _fmake(fcp)
155 struct fcb *fcp;
156
157_opfcb(fcp)
158
159 Opens the FCB pointed to by 'fcp'. Returns 0 if opened successfully,
160 -1 if an error occurred, with the error code in errno.
161
162 int
163 _opfcb(fcp)
164 register struct fcb *fcp;
165
166_inifcb(fcp, name,ext, mode)
167
168 Initializes the FCB pointed to by 'fcp' for the file named 'name'.'ext'
169 in mode 'mode'. Returns 0 if ok, -1 if not.
170
171 int
172 _inifcb(fcp, name, ext, mode)
173 register struct fcb *fcp;
174 char *name, *ext;
175 int mode;
176
177
178_sksec(fcp, sec)
179
180 Seeks the FCB pointed to by 'fcp' to sector 'sec'.
181 Returns: -1 = error, 0 = OK, 1 = EOF
182
183 int
184 _sksec(fcp, sec)
185 struct fcb *fcp;
186 long sec;
187
188_fsize(fcp)
189
190 Returns the size, in sectors, of the file associated with
191 the FCB pointed to by 'fcp', or -1 if the FCB isn't open.
192
193 int
194 _fsize(fcp)
195 struct fcb *fcp;
196
197_rdsec(fcp, buf, ns)
198
199 Reads 'ns' sectors into the buffer at 'buf' from the file associated
200 with the FCB pointed to b 'fcp'. Returns 0 if OK, -1 if not.
201
202 int
203 _rdsec(fcp, buf, ns)
204 struct fcb *fcp;
205 char *buf;
206 long ns;
207
208ClusMap(fcp)
209
210 Prints a map of the clusters for the file associated with
211 the FCB pointed to by 'fcp'. Ignored if file isn't open.
212 Returns 0 if map was printed, -1 otherwise.
213
214 int
215 ClusMap(fcp)
216 struct fcb *fcp;
217
218SnapFCB(fcp)
219
220 Prints the contents of an FCB pointed to by 'fcp'. Only included
221 in test versions of 'filesys.c' where TESTER is defined non-zero.
222
223 SnapFCB(fcp)
224 struct fcb *fcp;
Note: See TracBrowser for help on using the repository browser.