<s>
A	O
File	B-Operating_System
Control	I-Operating_System
Block	I-Operating_System
(	O
FCB	O
)	O
is	O
a	O
file	B-Operating_System
system	O
structure	O
in	O
which	O
the	O
state	O
of	O
an	O
open	O
file	B-Operating_System
is	O
maintained	O
.	O
</s>
<s>
A	O
FCB	O
is	O
managed	O
by	O
the	O
operating	O
system	O
,	O
but	O
it	O
resides	O
in	O
the	O
memory	O
of	O
the	O
program	O
that	O
uses	O
the	O
file	B-Operating_System
,	O
not	O
in	O
operating	O
system	O
memory	O
.	O
</s>
<s>
This	O
allows	O
a	O
process	O
to	O
have	O
as	O
many	O
files	B-Device
open	O
at	O
one	O
time	O
as	O
it	O
wants	O
,	O
provided	O
it	O
can	O
spare	O
enough	O
memory	O
for	O
an	O
FCB	O
per	O
file	B-Operating_System
.	O
</s>
<s>
The	O
FCB	O
originates	O
from	O
CP/M	B-Application
and	O
is	O
also	O
present	O
in	O
most	O
variants	O
of	O
DOS	B-Device
,	O
though	O
only	O
as	O
a	O
backwards	O
compatibility	O
measure	O
in	O
MS-DOS	B-Application
versions	O
2.0	O
and	O
later	O
.	O
</s>
<s>
A	O
full	O
FCB	O
is	O
36	O
bytes	O
long	O
;	O
in	O
early	O
versions	O
of	O
CP/M	B-Application
,	O
it	O
was	O
33	O
bytes	O
.	O
</s>
<s>
This	O
fixed	O
size	O
,	O
which	O
could	O
not	O
be	O
increased	O
without	O
breaking	O
application	O
compatibility	O
,	O
led	O
to	O
the	O
FCB	O
's	O
eventual	O
demise	O
as	O
the	O
standard	O
method	O
of	O
accessing	O
files	B-Device
.	O
</s>
<s>
The	O
meanings	O
of	O
several	O
of	O
the	O
fields	O
in	O
the	O
FCB	O
differ	O
between	O
CP/M	B-Application
and	O
DOS	B-Device
,	O
and	O
also	O
depending	O
on	O
what	O
operation	O
is	O
being	O
performed	O
.	O
</s>
<s>
Offset	O
Bytesize	O
Contents	O
0x00	O
1	O
Drive	O
number	O
—	O
0	O
for	O
default	O
,	O
1	O
for	O
A	O
:	O
,	O
2	O
for	O
B	O
:	O
,	O
...	O
0x01	O
8	O
File	B-Operating_System
name	O
and	O
extension	O
—	O
together	O
these	O
form	O
a	O
8.3	O
file	B-Operating_System
name	O
.	O
</s>
<s>
0x20	O
1	O
Record	O
number	O
in	O
the	O
current	O
section	O
of	O
the	O
file	B-Operating_System
—	O
used	O
when	O
performing	O
sequential	B-General_Concept
access	I-General_Concept
.	O
</s>
<s>
0x21	O
3	O
Record	O
number	O
to	O
use	O
when	O
performing	O
random	B-General_Concept
access	I-General_Concept
.	O
</s>
<s>
The	O
20-byte-long	O
field	O
starting	O
at	O
offset	O
0x0C	O
contained	O
fields	O
which	O
(	O
among	O
others	O
)	O
provided	O
further	O
information	O
about	O
the	O
file	B-Operating_System
:	O
</s>
<s>
Offset	O
Bytesize	O
Contents	O
0x0E	O
2	O
File	B-Operating_System
's	O
record	O
length	O
in	O
bytes	O
.	O
</s>
<s>
0x10	O
4	O
Total	O
file	B-Operating_System
size	O
in	O
bytes	O
.	O
</s>
<s>
0x14	O
2	O
Date	O
of	O
last	O
modification	O
to	O
file	B-Operating_System
contents	O
.	O
</s>
<s>
Further	O
values	O
were	O
used	O
by	O
newer	O
versions	O
of	O
DOS	B-Device
until	O
new	O
information	O
could	O
no	O
longer	O
fit	O
in	O
these	O
20	O
bytes	O
.	O
</s>
<s>
Some	O
preceding	O
"	O
negative	O
offset	O
"	O
bytes	O
were	O
squeezed	O
from	O
reserved	O
spaces	O
in	O
CP/M	B-Application
Zero	O
Page	O
and	O
DOS	B-Device
Program	O
Segment	O
Prefix	O
for	O
storing	O
file	B-Operating_System
attributes	O
.	O
</s>
<s>
In	O
CP/M	B-Application
,	O
86-DOS	B-Operating_System
and	O
PC	B-Operating_System
DOS	I-Operating_System
1.x/MS	O
-DOS	O
1.xx	O
,	O
the	O
FCB	O
was	O
the	O
only	O
method	O
of	O
accessing	O
files	B-Device
.	O
</s>
<s>
Under	O
DOS	B-Device
a	O
few	O
INT	O
21h	O
subfunctions	O
provided	O
the	O
interface	O
to	O
operate	O
on	O
files	B-Device
using	O
the	O
FCB	O
.	O
</s>
<s>
When	O
,	O
with	O
MS-DOS	B-Application
2	O
,	O
preparations	O
were	O
made	O
to	O
support	O
multiple	O
processes	O
or	O
users	O
,	O
use	O
other	O
filesystems	O
than	O
FAT	O
or	O
to	O
share	O
files	B-Device
over	O
networks	O
in	O
the	O
future	O
,	O
FCBs	B-Device
were	O
felt	O
to	O
be	O
too	O
small	O
to	O
handle	O
the	O
extra	O
data	O
required	O
for	O
such	O
features	O
and	O
therefore	O
FCBs	B-Device
were	O
seen	O
as	O
inadequate	O
for	O
various	O
future	O
expansion	O
paths	O
.	O
</s>
<s>
Exposing	O
file	B-Operating_System
system	O
related	O
data	O
to	O
user-space	O
was	O
also	O
seen	O
as	O
a	O
security	O
risk	O
.	O
</s>
<s>
FCBs	B-Device
were	O
thus	O
superseded	O
by	O
file	B-Application
handles	I-Application
,	O
as	O
used	O
on	O
UNIX	B-Application
and	O
its	O
derivatives	O
.	O
</s>
<s>
File	B-Application
handles	I-Application
are	O
simply	O
consecutive	O
integer	O
numbers	O
associated	O
with	O
specific	O
open	O
files	B-Device
.	O
</s>
<s>
If	O
a	O
program	O
uses	O
the	O
newer	O
file	B-Application
handle	I-Application
API	O
to	O
open	O
a	O
file	B-Operating_System
,	O
the	O
operating	O
system	O
will	O
manage	O
its	O
internal	O
data	O
structure	O
associated	O
with	O
that	O
file	B-Operating_System
in	O
its	O
own	O
memory	O
area	O
.	O
</s>
<s>
This	O
has	O
the	O
great	O
advantage	O
that	O
these	O
structures	O
can	O
grow	O
in	O
size	O
in	O
later	O
operating	O
system	O
versions	O
without	O
breaking	O
compatibility	O
with	O
application	O
programs	O
;	O
its	O
disadvantage	O
is	O
that	O
,	O
given	O
the	O
rather	O
simplistic	O
memory	B-General_Concept
management	I-General_Concept
of	O
DOS	B-Device
,	O
space	O
for	O
as	O
many	O
of	O
these	O
structures	O
as	O
the	O
most	O
"	O
file-hungry	O
"	O
program	O
is	O
likely	O
to	O
use	O
has	O
to	O
be	O
reserved	O
at	O
boot	O
time	O
and	O
cannot	O
be	O
used	O
for	O
any	O
other	O
purpose	O
while	O
the	O
computer	O
is	O
running	O
.	O
</s>
<s>
Such	O
memory	O
reservation	O
is	O
done	O
using	O
the	O
FILES	B-Device
=	O
directive	O
in	O
the	O
CONFIG.SYS	B-Device
file	B-Operating_System
.	O
</s>
<s>
This	O
problem	O
does	O
not	O
occur	O
with	O
FCBs	B-Device
in	O
DOS	B-Device
1	O
or	O
in	O
CP/M	B-Application
,	O
since	O
the	O
operating	O
system	O
stores	O
all	O
that	O
it	O
needs	O
to	O
know	O
about	O
an	O
open	O
file	B-Operating_System
inside	O
the	O
FCB	O
and	O
thus	O
does	O
not	O
need	O
to	O
use	O
any	O
per-file	O
memory	O
in	O
operating	O
system	O
memory	O
space	O
.	O
</s>
<s>
When	O
using	O
FCBs	B-Device
in	O
MS-DOS	B-Application
3	O
or	O
later	O
,	O
the	O
FCB	O
format	O
depends	O
on	O
whether	O
SHARE.EXE	O
is	O
loaded	O
and	O
whether	O
the	O
FCB	O
refers	O
to	O
a	O
local	O
or	O
remote	O
file	B-Operating_System
and	O
often	O
refers	O
to	O
a	O
SFT	O
entry	O
.	O
</s>
<s>
Because	O
of	O
this	O
,	O
the	O
number	O
of	O
FCBs	B-Device
which	O
can	O
be	O
kept	O
open	O
at	O
once	O
in	O
DOS	B-Device
3	O
or	O
higher	O
is	O
limited	O
as	O
well	O
,	O
usually	O
to	O
4	O
;	O
using	O
the	O
FCBS	B-Device
=	O
directive	O
in	O
the	O
CONFIG.SYS	B-Device
file	B-Operating_System
,	O
it	O
may	O
be	O
increased	O
beyond	O
that	O
number	O
if	O
necessary	O
.	O
</s>
<s>
Under	O
DR-DOS	B-Application
,	O
both	O
FILES	B-Device
and	O
FCBS	B-Device
come	O
from	O
the	O
same	O
internal	O
pool	O
of	O
available	O
handles	O
structures	O
and	O
are	O
assigned	O
dynamically	O
as	O
needed	O
.	O
</s>
<s>
FCBs	B-Device
were	O
supported	O
in	O
all	O
versions	O
of	O
MS-DOS	B-Application
and	O
Windows	B-Application
until	O
the	O
introduction	O
of	O
the	O
FAT32	B-Application
filesystem	O
.	O
</s>
<s>
Windows	B-Application
95	I-Application
,	O
Windows	B-Device
98	I-Device
and	O
Windows	B-Device
Me	I-Device
do	O
not	O
support	O
the	O
use	O
of	O
FCBs	B-Device
on	O
FAT32	B-Application
drives	O
due	O
to	O
its	O
32-bit	O
cluster	O
numbers	O
,	O
except	O
to	O
read	O
the	O
volume	O
label	O
.	O
</s>
<s>
This	O
caused	O
some	O
old	O
DOS	B-Device
applications	O
,	O
including	O
WordStar	B-Application
,	O
to	O
fail	O
under	O
these	O
versions	O
of	O
Windows	B-Application
.	O
</s>
<s>
The	O
FCB	O
interface	O
does	O
not	O
work	O
properly	O
on	O
Windows	B-Device
NT	I-Device
,	O
2000	B-Application
,	O
etc	O
.	O
</s>
<s>
either	O
–	O
WordStar	B-Application
does	O
not	O
function	O
properly	O
on	O
these	O
operating	O
systems	O
.	O
</s>
<s>
DOS	B-Device
emulators	O
DOSEMU	B-Application
and	O
DOSBox	B-Application
implement	O
the	O
FCB	O
interface	O
properly	O
,	O
thus	O
they	O
are	O
a	O
way	O
to	O
run	O
older	O
DOS	B-Device
programs	O
that	O
need	O
FCBs	B-Device
on	O
modern	O
operating	O
systems	O
.	O
</s>
<s>
This	O
is	O
the	O
name	O
given	O
to	O
the	O
buffer	O
where	O
file	B-Operating_System
contents	O
(	O
records	O
)	O
would	O
be	O
read	O
into/written	O
from	O
.	O
</s>
<s>
File	B-Operating_System
access	O
functions	O
in	O
DOS	B-Device
that	O
used	O
the	O
FCB	O
assumed	O
a	O
fixed	O
location	O
for	O
the	O
DTA	O
,	O
initially	O
pointing	O
to	O
a	O
part	O
of	O
the	O
PSP	O
(	O
see	O
next	O
section	O
)	O
;	O
this	O
location	O
could	O
be	O
changed	O
by	O
calling	O
a	O
DOS	B-Device
function	O
,	O
with	O
subsequent	O
file	B-Operating_System
accesses	O
implicitly	O
using	O
the	O
new	O
location	O
.	O
</s>
<s>
With	O
the	O
deprecation	O
of	O
the	O
FCB	O
method	O
,	O
the	O
new	O
file	B-Operating_System
access	O
functions	O
which	O
used	O
file	B-Application
handles	I-Application
also	O
provided	O
a	O
means	O
to	O
specify	O
a	O
memory	O
buffer	O
for	O
file	B-Operating_System
contents	O
with	O
every	O
function	O
call	O
,	O
such	O
that	O
maintaining	O
concurrent	O
,	O
independent	O
buffers	O
(	O
either	O
for	O
different	O
files	B-Device
or	O
for	O
the	O
same	O
file	B-Operating_System
)	O
became	O
much	O
more	O
practical	O
.	O
</s>
<s>
Every	O
DOS	B-Device
executable	O
started	O
from	O
the	O
shell	O
(	O
COMMAND.COM	B-Operating_System
)	O
was	O
provided	O
with	O
a	O
pre-filled	O
256-byte	O
long	O
data	O
structure	O
called	O
the	O
Program	O
Segment	O
Prefix	O
(	O
PSP	O
)	O
.	O
</s>
<s>
This	O
data	O
structure	O
could	O
be	O
found	O
at	O
the	O
beginning	O
of	O
the	O
data	O
segment	O
whose	O
address	O
was	O
provided	O
by	O
DOS	B-Device
at	O
program	O
start	O
in	O
the	O
DS	O
and	O
ES	O
segment	O
registers	O
.	O
</s>
<s>
Besides	O
providing	O
the	O
program	O
's	O
command	O
line	O
verbatim	O
at	O
address	O
0x81	O
,	O
DOS	B-Device
also	O
tried	O
to	O
construct	O
two	O
FCB	O
's	O
corresponding	O
to	O
the	O
first	O
two	O
words	O
in	O
the	O
command	O
line	O
,	O
the	O
purpose	O
being	O
to	O
save	O
work	O
for	O
the	O
programmer	O
in	O
the	O
common	O
case	O
where	O
these	O
words	O
were	O
filenames	O
to	O
operate	O
on	O
.	O
</s>
<s>
Since	O
these	O
FCB	O
's	O
remained	O
unopened	O
,	O
no	O
problem	O
would	O
ensue	O
even	O
if	O
these	O
command	O
line	O
words	O
did	O
not	O
refer	O
to	O
files	B-Device
.	O
</s>
<s>
The	O
initial	O
address	O
for	O
the	O
DTA	O
was	O
set	O
to	O
overlay	O
the	O
area	O
in	O
the	O
PSP	O
(	O
at	O
address	O
0x80	O
)	O
where	O
the	O
command	O
line	O
arguments	O
were	O
stored	O
,	O
such	O
that	O
a	O
program	O
needed	O
to	O
parse	O
this	O
area	O
for	O
command	O
line	O
arguments	O
before	O
invoking	O
DOS	B-Device
functions	O
that	O
made	O
use	O
of	O
the	O
DTA	O
(	O
such	O
as	O
reading	O
in	O
a	O
file	B-Operating_System
record	O
)	O
,	O
unless	O
the	O
program	O
took	O
care	O
to	O
change	O
the	O
address	O
of	O
the	O
DTA	O
to	O
some	O
other	O
memory	O
region	O
(	O
or	O
not	O
use	O
the	O
DTA/FCB	O
functions	O
altogether	O
,	O
which	O
soon	O
became	O
deprecated	O
in	O
favour	O
of	O
file	B-Application
handles	I-Application
)	O
.	O
</s>
