ID Number: Q44038
2.x 3.x 4.00 4.01
MS-DOS
Summary:
The use of FCBs is problematic. In addition to obvious problems, such
as lack of subdirectory support, there are other, less obvious problems.
FCB structures are maintained in the data space; therefore, they may
be moved at will. Most importantly, there have never been any "rules
for behavior" for FCB manipulation -- there was no protocol for their
usage. This results in the following misbehavior by an application:
1. Multiple opens of the same file
while (TRUE) { while (TRUE) {
OpenFCB(FCB); OpenFCB(FCB);
ReadFCB(FCB); WriteFCB(FCB);
} }
2. Multiple opens of different files
while (TRUE) { while (TRUE) {
OpenFCB(FCB[i++]); OpenFCB(FCB[i++]);
ReadFCB(FCB); WriteFCB(FCB);
} }
3. Multiple closes of the same file
OpenFCB(FCB);
while (TRUE) {
CloseFCB(FCB);
}
4. I/O after closing file
OpenFCB(FCB); OpenFCB(FCB);
while (TRUE) { while (TRUE) {
CloseFCB(FCB); WriteFCB(FCB);
} }
Using the MS-DOS SHARE utility, this behavior is no longer allowed.
SHARE, which is transparent to the application that is using the FCBs,
shadows the FCB I/O requests into file handle I/O requests internally.
Then, it can enforce file system integrity rules with the FCBs
alongside the file handles.
Such improper use of FCBs by an application is discovered when running
the SHARE utility. This is even more widespread when using MS-DOS
Version 4.00 on a partition larger than 32 MB, which REQUIRES that
SHARE be loaded.
Whenever possible, use file handle I/O instead of FCB I/O.