<s>
For	O
most	O
file	B-Application
systems	I-Application
,	O
a	O
program	B-Application
initializes	O
access	O
to	O
a	O
file	B-Operating_System
in	O
a	O
file	B-Application
system	I-Application
using	O
the	O
open	B-Language
system	I-Language
call	I-Language
.	O
</s>
<s>
This	O
allocates	O
resources	O
associated	O
to	O
the	O
file	B-Operating_System
(	O
the	O
file	B-Application
descriptor	I-Application
)	O
,	O
and	O
returns	O
a	O
handle	O
that	O
the	O
process	B-Operating_System
will	O
use	O
to	O
refer	O
to	O
that	O
file	B-Operating_System
.	O
</s>
<s>
The	O
same	O
file	B-Operating_System
may	O
be	O
opened	O
simultaneously	O
by	O
several	O
processes	O
,	O
and	O
even	O
by	O
the	O
same	O
process	B-Operating_System
,	O
resulting	O
in	O
several	O
file	B-Application
descriptors	I-Application
for	O
the	O
same	O
file	B-Operating_System
;	O
depending	O
on	O
the	O
file	B-Operating_System
organization	O
and	O
filesystem	B-Application
.	O
</s>
<s>
Operations	O
on	O
the	O
descriptors	O
such	O
as	O
moving	O
the	O
file	B-Language
pointer	I-Language
or	O
closing	O
it	O
are	O
independentthey	O
do	O
not	O
affect	O
other	O
descriptors	O
for	O
the	O
same	O
file	B-Operating_System
.	O
</s>
<s>
Operations	O
on	O
the	O
file	B-Operating_System
,	O
such	O
as	O
a	O
write	B-Language
,	O
can	O
be	O
seen	O
by	O
operations	O
on	O
the	O
other	O
descriptors	O
:	O
a	O
later	O
read	O
can	O
read	O
the	O
newly	O
written	O
data	O
.	O
</s>
<s>
During	O
the	O
open	O
,	O
the	O
filesystem	B-Application
may	O
allocate	O
memory	O
for	O
buffers	B-General_Concept
,	O
or	O
it	O
may	O
wait	O
until	O
the	O
first	O
operation	O
.	O
</s>
<s>
The	O
absolute	O
file	B-Application
path	I-Application
is	O
resolved	O
.	O
</s>
<s>
The	O
first	O
access	O
to	O
at	O
least	O
the	O
directory	B-Application
within	O
the	O
filesystem	B-Application
is	O
performed	O
.	O
</s>
<s>
An	O
error	O
will	O
usually	O
be	O
returned	O
if	O
the	O
higher	O
level	O
components	O
of	O
the	O
path	O
(	O
directories	B-Application
)	O
cannot	O
be	O
located	O
or	O
accessed	O
.	O
</s>
<s>
An	O
error	O
will	O
be	O
returned	O
if	O
the	O
file	B-Operating_System
is	O
expected	O
to	O
exist	O
and	O
it	O
does	O
not	O
or	O
if	O
the	O
file	B-Operating_System
should	O
not	O
already	O
exist	O
and	O
it	O
does	O
.	O
</s>
<s>
If	O
the	O
file	B-Operating_System
is	O
expected	O
to	O
exist	O
and	O
it	O
does	O
,	O
the	O
file	B-Application
access	I-Application
,	O
as	O
restricted	O
by	O
permission	O
flags	O
within	O
the	O
file	B-Operating_System
meta	O
data	O
or	O
access	O
control	O
list	O
,	O
is	O
validated	O
against	O
the	O
requested	O
type	O
of	O
operations	O
.	O
</s>
<s>
This	O
usually	O
requires	O
an	O
additional	O
filesystem	B-Application
access	O
although	O
in	O
some	O
filesystems	B-Application
meta-flags	O
may	O
be	O
part	O
of	O
the	O
directory	B-Application
structure	O
.	O
</s>
<s>
If	O
the	O
file	B-Operating_System
is	O
being	O
created	O
,	O
the	O
filesystem	B-Application
may	O
allocate	O
the	O
default	O
initial	O
amount	O
of	O
storage	O
or	O
a	O
specified	O
amount	O
depending	O
on	O
the	O
file	B-Application
system	I-Application
capabilities	O
.	O
</s>
<s>
Updating	O
the	O
directory	B-Application
with	O
the	O
new	O
entry	O
may	O
be	O
performed	O
or	O
it	O
may	O
be	O
delayed	O
until	O
the	O
close	B-Language
is	O
performed	O
.	O
</s>
<s>
Various	O
other	O
errors	O
which	O
may	O
occur	O
during	O
the	O
open	O
include	O
directory	B-Application
update	O
failures	O
,	O
un-permitted	O
multiple	O
connections	O
,	O
media	O
failures	O
,	O
communication	O
link	O
failures	O
and	O
device	O
failures	O
.	O
</s>
<s>
In	O
many	O
cases	O
programming	O
language-specific	O
run-time	O
library	O
opens	O
may	O
perform	O
additional	O
actions	O
including	O
initializing	O
a	O
run-time	O
library	O
structure	O
related	O
to	O
the	O
file	B-Operating_System
.	O
</s>
<s>
As	O
soon	O
as	O
a	O
file	B-Operating_System
is	O
no	O
longer	O
needed	O
,	O
the	O
program	B-Application
should	O
close	B-Language
it	O
.	O
</s>
<s>
This	O
will	O
cause	O
run-time	O
library	O
and	O
filesystem	B-Application
buffers	B-General_Concept
to	O
be	O
updated	O
to	O
the	O
physical	O
media	O
and	O
permit	O
other	O
processes	O
to	O
access	O
the	O
data	O
if	O
exclusive	O
use	O
had	O
been	O
required	O
.	O
</s>
<s>
Some	O
run-time	O
libraries	O
may	O
close	B-Language
a	O
file	B-Operating_System
if	O
the	O
program	B-Application
calls	O
the	O
run-time	O
exit	O
.	O
</s>
<s>
Some	O
filesystems	B-Application
may	O
perform	O
the	O
necessary	O
operations	O
if	O
the	O
program	B-Application
terminates	O
.	O
</s>
<s>
This	O
can	O
cause	O
damaged	O
filesystem	B-Application
structures	O
requiring	O
the	O
running	O
of	O
privileged	O
and	O
lengthy	O
filesystem	B-Application
utilities	O
during	O
which	O
the	O
entire	O
filesystem	B-Application
may	O
be	O
inaccessible	O
.	O
</s>
<s>
The	O
pathname	B-Application
to	O
the	O
file	B-Operating_System
,	O
</s>
<s>
The	O
kind	O
of	O
access	O
requested	O
on	O
the	O
file	B-Operating_System
(	O
read	O
,	O
write	B-Language
,	O
append	O
etc	O
.	O
</s>
<s>
The	O
initial	O
file	B-Operating_System
permission	O
is	O
requested	O
using	O
the	O
third	O
argument	O
called	O
mode	O
.	O
</s>
<s>
This	O
argument	O
is	O
relevant	O
only	O
when	O
a	O
new	O
file	B-Operating_System
is	O
being	O
created	O
.	O
</s>
<s>
After	O
using	O
the	O
file	B-Operating_System
,	O
the	O
process	B-Operating_System
should	O
close	B-Language
the	O
file	B-Operating_System
using	O
close	B-Language
call	O
,	O
which	O
takes	O
the	O
file	B-Application
descriptor	I-Application
of	O
the	O
file	B-Operating_System
to	O
be	O
closed	O
.	O
</s>
<s>
Some	O
filesystems	B-Application
include	O
a	O
disposition	O
to	O
permit	O
releasing	O
the	O
file	B-Operating_System
.	O
</s>
<s>
Some	O
computer	O
languages	O
include	O
run-time	O
libraries	O
which	O
include	O
additional	O
functionality	O
for	O
particular	O
filesystems	B-Application
.	O
</s>
<s>
Some	O
open	O
routines	O
include	O
specification	O
of	O
the	O
program	B-Application
code	O
to	O
be	O
executed	O
in	O
the	O
event	O
of	O
an	O
error	O
.	O
</s>
<s>
file	B-Operating_System
.	O
</s>
<s>
The	O
tie::AnyDBM_File	O
function	O
associates	O
a	O
hash	O
with	O
a	O
file	B-Operating_System
.	O
</s>
<s>
The	O
call	O
is	O
standardized	O
by	O
the	O
POSIX	O
specification	O
for	O
C	B-Language
language	I-Language
:	O
</s>
<s>
The	O
value	O
returned	O
is	O
a	O
file	B-Application
descriptor	I-Application
which	O
is	O
a	O
reference	O
to	O
a	O
process	B-Operating_System
specific	O
structure	O
which	O
contains	O
,	O
among	O
other	O
things	O
,	O
a	O
position	O
pointer	O
that	O
indicates	O
which	O
place	O
in	O
the	O
file	B-Operating_System
will	O
be	O
acted	O
upon	O
by	O
the	O
next	O
operation	O
.	O
</s>
<s>
Open	O
may	O
return	O
−1	O
indicating	O
a	O
failure	O
with	O
errno	B-Error_Name
detailing	O
the	O
error	O
.	O
</s>
<s>
The	O
file	B-Application
system	I-Application
also	O
updates	O
a	O
global	O
table	O
of	O
all	O
open	O
files	O
which	O
is	O
used	O
for	O
determining	O
if	O
a	O
file	B-Operating_System
is	O
currently	O
in	O
use	O
by	O
any	O
process	B-Operating_System
.	O
</s>
<s>
The	O
name	O
of	O
the	O
file	B-Operating_System
to	O
open	O
.	O
</s>
<s>
It	O
includes	O
the	O
file	B-Application
path	I-Application
defining	O
where	O
,	O
in	O
which	O
file	B-Application
system	I-Application
,	O
the	O
file	B-Operating_System
is	O
found	O
(	O
or	O
should	O
be	O
created	O
)	O
.	O
</s>
<s>
openat	B-Language
expects	O
a	O
relative	O
path	O
.	O
</s>
<s>
This	O
argument	O
formed	O
by	O
OR'ing	O
together	O
optional	O
parameters	O
and	O
(	O
from	O
<fcntl.h>	O
)	O
one	O
of	O
:	O
</s>
<s>
O_APPEND	O
data	O
written	O
will	O
be	O
appended	O
to	O
the	O
end	O
of	O
the	O
file	B-Operating_System
.	O
</s>
<s>
The	O
file	B-Operating_System
operations	O
will	O
always	O
adjust	O
the	O
position	O
pointer	O
to	O
the	O
end	O
of	O
the	O
file	B-Operating_System
.	O
</s>
<s>
O_CREAT	O
Create	O
the	O
file	B-Operating_System
if	O
it	O
does	O
not	O
exist	O
;	O
otherwise	O
the	O
open	O
fails	O
setting	O
errno	B-Error_Name
to	O
ENOENT	O
.	O
</s>
<s>
O_EXCL	O
Used	O
with	O
O_CREAT	O
if	O
the	O
file	B-Operating_System
already	O
exists	O
,	O
then	O
fail	O
,	O
setting	O
errno	B-Error_Name
to	O
EEXIST	O
.	O
</s>
<s>
O_TRUNC	O
If	O
the	O
file	B-Operating_System
already	O
exists	O
then	O
discard	O
its	O
previous	O
contents	O
,	O
reducing	O
it	O
to	O
an	O
empty	O
file	B-Operating_System
.	O
</s>
<s>
uses	O
string	O
flags	O
such	O
as	O
r	O
,	O
w	O
,	O
a	O
and	O
+	O
and	O
returns	O
a	O
file	B-Language
pointer	I-Language
used	O
with	O
,	O
and	O
.	O
</s>
<s>
file	B-Operating_System
permissions	O
.	O
</s>
<s>
These	O
include	O
read	O
,	O
write	B-Language
or	O
execute	O
the	O
file	B-Operating_System
by	O
the	O
owner	O
,	O
group	O
or	O
all	O
users	O
.	O
</s>
<s>
The	O
mode	O
is	O
masked	O
by	O
the	O
calling	O
process	B-Operating_System
's	O
umask	O
:	O
bits	O
set	O
in	O
the	O
umask	O
are	O
cleared	O
in	O
the	O
mode	O
.	O
</s>
