]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/open.2
Fix RETURN VALUE description: in some cases reboot() does not return.
[thirdparty/man-pages.git] / man2 / open.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4.\" 1993 Michael Haardt, Ian Jackson.
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
c13182ef 14.\"
fea681da
MK
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein. The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
c13182ef 22.\"
fea681da
MK
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
25.\"
26.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27.\" Modified 1994-08-21 by Michael Haardt
28.\" Modified 1996-04-13 by Andries Brouwer <aeb@cwi.nl>
29.\" Modified 1996-05-13 by Thomas Koenig
30.\" Modified 1996-12-20 by Michael Haardt
31.\" Modified 1999-02-19 by Andries Brouwer <aeb@cwi.nl>
32.\" Modified 1998-11-28 by Joseph S. Myers <jsm28@hermes.cam.ac.uk>
33.\" Modified 1999-06-03 by Michael Haardt
c11b1abf
MK
34.\" Modified 2002-05-07 by Michael Kerrisk <mtk.manpages@gmail.com>
35.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
1c1e15ed
MK
36.\" 2004-12-08, mtk, reordered flags list alphabetically
37.\" 2004-12-08, Martin Pool <mbp@sourcefrog.net> (& mtk), added O_NOATIME
fe75ec04 38.\" 2007-09-18, mtk, Added description of O_CLOEXEC + other minor edits
447bb15e 39.\" 2008-01-03, mtk, with input from Trond Myklebust
f4b9d6a5
MK
40.\" <trond.myklebust@fys.uio.no> and Timo Sirainen <tss@iki.fi>
41.\" Rewrite description of O_EXCL.
fea681da 42.\"
f4b9d6a5 43.TH OPEN 2 2008-01-03 "Linux" "Linux Programmer's Manual"
fea681da
MK
44.SH NAME
45open, creat \- open and possibly create a file or device
46.SH SYNOPSIS
47.nf
48.B #include <sys/types.h>
49.B #include <sys/stat.h>
50.B #include <fcntl.h>
51.sp
52.BI "int open(const char *" pathname ", int " flags );
53.BI "int open(const char *" pathname ", int " flags ", mode_t " mode );
5895e7eb 54
fea681da
MK
55.BI "int creat(const char *" pathname ", mode_t " mode );
56.fi
57.SH DESCRIPTION
e366dbc4 58Given a
0daa9e92 59.I pathname
e366dbc4 60for a file,
1f6ceb40 61.BR open ()
c13182ef 62returns a file descriptor, a small, non-negative integer
e366dbc4
MK
63for use in subsequent system calls
64.RB ( read "(2), " write "(2), " lseek "(2), " fcntl "(2), etc.)."
65The file descriptor returned by a successful call will be
2c4bff36 66the lowest-numbered file descriptor not currently open for the process.
e366dbc4 67.PP
fe75ec04 68By default, the new file descriptor is set to remain open across an
e366dbc4 69.BR execve (2)
1f6ceb40
MK
70(i.e., the
71.B FD_CLOEXEC
72file descriptor flag described in
73.BR fcntl (2)
fe75ec04
MK
74is initially disabled; the Linux-specific
75.B O_CLOEXEC
76flag, described below, can be used to change this default).
1f6ceb40 77The file offset is set to the beginning of the file (see
c13182ef 78.BR lseek (2)).
e366dbc4
MK
79.PP
80A call to
81.BR open ()
82creates a new
83.IR "open file description" ,
84an entry in the system-wide table of open files.
e366dbc4
MK
85This entry records the file offset and the file status flags
86(modifiable via the
0bfa087b 87.BR fcntl (2)
e366dbc4
MK
88.B F_SETFL
89operation).
2c4bff36
MK
90A file descriptor is a reference to one of these entries;
91this reference is unaffected if
92.I pathname
93is subsequently removed or modified to refer to a different file.
e366dbc4 94The new open file description is initially not shared
2c4bff36
MK
95with any other process,
96but sharing may arise via
97.BR fork (2).
e366dbc4 98.PP
fea681da
MK
99The parameter
100.I flags
e366dbc4
MK
101must include one of the following
102.IR "access modes" :
c7992edc 103.BR O_RDONLY ", " O_WRONLY ", or " O_RDWR .
e366dbc4
MK
104These request opening the file read-only, write-only, or read/write,
105respectively.
bfe9ba67
MK
106
107In addition, zero or more file creation flags and file status flags
c13182ef 108can be
fea681da 109.RI bitwise- or 'd
e366dbc4 110in
bfe9ba67 111.IR flags .
c13182ef
MK
112The
113.I file creation flags
114are
bfe9ba67 115.BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", and " O_TRUNC .
c13182ef
MK
116The
117.I file status flags
bfe9ba67
MK
118are all of the remaining flags listed below.
119The distinction between these two groups of flags is that
120the file status flags can be retrieved and (in some cases)
121modified using
122.BR fcntl (2).
123The full list of file creation flags and file status flags is as follows:
fea681da 124.TP
1c1e15ed 125.B O_APPEND
c13182ef
MK
126The file is opened in append mode.
127Before each
0bfa087b 128.BR write (2),
1e568304 129the file offset is positioned at the end of the file,
1c1e15ed 130as if with
0bfa087b 131.BR lseek (2).
1c1e15ed
MK
132.B O_APPEND
133may lead to corrupted files on NFS file systems if more than one process
c13182ef
MK
134appends data to a file at once.
135This is because NFS does not support
1c1e15ed
MK
136appending to a file, so the client kernel has to simulate it, which
137can't be done without a race condition.
138.TP
139.B O_ASYNC
b50582eb 140Enable signal-driven I/O:
8bd58774
MK
141generate a signal
142.RB ( SIGIO
143by default, but this can be changed via
1c1e15ed
MK
144.BR fcntl (2))
145when input or output becomes possible on this file descriptor.
c13182ef 146This feature is only available for terminals, pseudo-terminals,
1f6ceb40
MK
147sockets, and (since Linux 2.6) pipes and FIFOs.
148See
1c1e15ed
MK
149.BR fcntl (2)
150for further details.
fe75ec04
MK
151.TP
152.BR O_CLOEXEC " (Since Linux 2.6.23)"
153Enable the close-on-exec flag for the new file descriptor.
fb7339df 154Specifying this flag permits a program to avoid an additional
fe75ec04
MK
155.BR fcntl (2)
156.B F_SETFD
157operation to set the
0daa9e92 158.B FD_CLOEXEC
fe75ec04
MK
159flag.
160Additionally,
161use of this flag is essential in some multithreaded programs
162since using a separate
163.BR fcntl (2)
164.B F_SETFD
165operation to set the
0daa9e92 166.B FD_CLOEXEC
fe75ec04
MK
167flag does not suffice to avoid race conditions
168where one thread opens a file descriptor at the same
169time as another thread does a
170.BR fork (2)
171plus
172.BR execve (2).
173.\" This flag fixes only one form of the race condition;
174.\" The race can also occur with, for example, descriptors
175.\" returned by accept(), pipe(), etc.
1c1e15ed 176.TP
fea681da
MK
177.B O_CREAT
178If the file does not exist it will be created.
179The owner (user ID) of the file is set to the effective user ID
c13182ef
MK
180of the process.
181The group ownership (group ID) is set either to
fea681da
MK
182the effective group ID of the process or to the group ID of the
183parent directory (depending on filesystem type and mount options,
75b94dc3 184and the mode of the parent directory, see, for example, the mount options
fea681da
MK
185.I bsdgroups
186and
187.I sysvgroups
188of the ext2 filesystem, as described in
189.BR mount (8)).
190.TP
fe75ec04 191.BR O_DIRECT " (Since Linux 2.6.10)"
1c1e15ed
MK
192Try to minimize cache effects of the I/O to and from this file.
193In general this will degrade performance, but it is useful in
194special situations, such as when applications do their own caching.
195File I/O is done directly to/from user space buffers.
75b94dc3 196The I/O is synchronous, that is, at the completion of a
1c1e15ed
MK
197.BR read (2)
198or
e366dbc4
MK
199.BR write (2),
200data is guaranteed to have been transferred.
1c1e15ed
MK
201Under Linux 2.4 transfer sizes, and the alignment of user buffer
202and file offset must all be multiples of the logical block size
c13182ef
MK
203of the file system.
204Under Linux 2.6 alignment to 512-byte boundaries
1c1e15ed
MK
205suffices.
206.\" Alignment should satisfy requirements for the underlying device
207.\" There may be coherency problems.
9b54d4fa 208.sp
c13182ef 209A semantically similar (but deprecated) interface for block devices
9b54d4fa 210is described in
1c1e15ed
MK
211.BR raw (8).
212.TP
213.B O_DIRECTORY
a8d55537 214If \fIpathname\fP is not a directory, cause the open to fail.
9f8d688a
MK
215.\" But see the following and its replies:
216.\" http://marc.theaimsgroup.com/?t=112748702800001&r=1&w=2
217.\" [PATCH] open: O_DIRECTORY and O_CREAT together should fail
218.\" O_DIRECTORY | O_CREAT causes O_DIRECTORY to be ignored.
8382f16d 219This flag is Linux-specific, and was added in kernel version 2.1.126, to
60a90ecd
MK
220avoid denial-of-service problems if
221.BR opendir (3)
222is called on a
1c1e15ed 223FIFO or tape device, but should not be used outside of the
9e370fba
MK
224implementation of
225.BR opendir (3).
1c1e15ed 226.TP
fea681da 227.B O_EXCL
f4b9d6a5
MK
228Ensure that this call creates the file:
229if this flag is specified in conjunction with
fea681da 230.BR O_CREAT ,
f4b9d6a5
MK
231and
232.I pathname
233already exists, then
1c1e15ed 234.BR open ()
c13182ef 235will fail.
f4b9d6a5
MK
236The behavior of
237.B O_EXCL
238is undefined if
239.B O_CREAT
240is not specified.
241
242When these two flags are specified, symbolic links are not followed:
243.\" POSIX.1-2001 explicitly requires this behavior.
244if
245.I pathname
246is a symbolic link, then
247.BR open ()
248fails regardless of where the symbolic link points to.
249
250.B O_EXCL
7db44341 251is not supported on NFSv2 or on Linux before kernel 2.6;
f4b9d6a5
MK
252it is supported on Linux 2.6 and later, with NFSv3 or later.
253In environments where NFS
fea681da 254.B O_EXCL
f4b9d6a5
MK
255support is not provided, programs that rely on it
256for performing locking tasks will contain a race condition.
257Portable programs that want to perform atomic file locking using a lockfile,
258and need to avoid reliance on NFS support for
259.BR O_EXCL ,
260can create a unique file on
261the same file system (e.g., incorporating hostname and PID), and use
fea681da 262.BR link (2)
c13182ef 263to make a link to the lockfile.
60a90ecd
MK
264If
265.BR link (2)
f4b9d6a5 266returns 0, the lock is successful.
c13182ef 267Otherwise, use
fea681da
MK
268.BR stat (2)
269on the unique file to check if its link count has increased to 2,
270in which case the lock is also successful.
271.TP
1c1e15ed
MK
272.B O_LARGEFILE
273(LFS)
274Allow files whose sizes cannot be represented in an
8478ee02 275.I off_t
1c1e15ed 276(but can be represented in an
8478ee02 277.IR off64_t )
1c1e15ed 278to be opened.
c13182ef 279The
bcdd964e
MK
280.B _LARGEFILE64_SOURCE
281macro must be defined in order to obtain this definition.
c13182ef 282Setting the
bcdd964e 283.B _FILE_OFFSET_BITS
9f3d8b28
MK
284feature test macro to 64 (rather than using
285.BR O_LARGEFILE )
286is the preferred method of obtaining
287method of accessing large files on 32-bit systems (see
2dcbf4f7 288.BR feature_test_macros (7)).
1c1e15ed 289.TP
fe75ec04 290.BR O_NOATIME " (Since Linux 2.6.8)"
310b7919
MK
291Do not update the file last access time (st_atime in the inode)
292when the file is
1c1e15ed
MK
293.BR read (2).
294This flag is intended for use by indexing or backup programs,
295where its use can significantly reduce the amount of disk activity.
296This flag may not be effective on all filesystems.
297One example is NFS, where the server maintains the access time.
0e1ad98c 298.\" The O_NOATIME flag also affects the treatment of st_atime
92057f4d 299.\" by mmap() and readdir(2), MTK, Dec 04.
1c1e15ed 300.TP
fea681da
MK
301.B O_NOCTTY
302If
303.I pathname
304refers to a terminal device \(em see
305.BR tty (4)
306\(em it will not become the process's controlling terminal even if the
307process does not have one.
308.TP
1c1e15ed 309.B O_NOFOLLOW
a8d55537 310If \fIpathname\fP is a symbolic link, then the open fails.
c13182ef 311This is a FreeBSD extension, which was added to Linux in version 2.1.126.
1c1e15ed 312Symbolic links in earlier components of the pathname will still be
e366dbc4
MK
313followed.
314.\" The headers from glibc 2.0.100 and later include a
315.\" definition of this flag; \fIkernels before 2.1.126 will ignore it if
a8d55537 316.\" used\fP.
fea681da
MK
317.TP
318.BR O_NONBLOCK " or " O_NDELAY
c13182ef
MK
319When possible, the file is opened in non-blocking mode.
320Neither the
1c1e15ed 321.BR open ()
fea681da
MK
322nor any subsequent operations on the file descriptor which is
323returned will cause the calling process to wait.
324For the handling of FIFOs (named pipes), see also
af5b2ef2 325.BR fifo (7).
db28bfac 326For a discussion of the effect of
0daa9e92 327.B O_NONBLOCK
db28bfac
MK
328in conjunction with mandatory file locks and with file leases, see
329.BR fcntl (2).
fea681da
MK
330.TP
331.B O_SYNC
c13182ef
MK
332The file is opened for synchronous I/O.
333Any
0bfa087b 334.BR write (2)s
fea681da
MK
335on the resulting file descriptor will block the calling process until
336the data has been physically written to the underlying hardware.
b07cd0a9 337.IR "But see NOTES below" .
fea681da 338.TP
1c1e15ed
MK
339.B O_TRUNC
340If the file already exists and is a regular file and the open mode allows
682edefb
MK
341writing (i.e., is
342.B O_RDWR
343or
344.BR O_WRONLY )
345it will be truncated to length 0.
346If the file is a FIFO or terminal device file, the
347.B O_TRUNC
c13182ef 348flag is ignored.
682edefb
MK
349Otherwise the effect of
350.B O_TRUNC
351is unspecified.
fea681da
MK
352.PP
353Some of these optional flags can be altered using
0bfa087b 354.BR fcntl (2)
fea681da
MK
355after the file has been opened.
356
357The argument
358.I mode
c13182ef
MK
359specifies the permissions to use in case a new file is created.
360It is
fea681da 361modified by the process's
0daa9e92 362.I umask
fea681da 363in the usual way: the permissions of the created file are
66ee0c7e 364.IR "(mode & ~umask)" .
fea681da
MK
365Note that this mode only applies to future accesses of the
366newly created file; the
1c1e15ed 367.BR open ()
fea681da
MK
368call that creates a read-only file may well return a read/write
369file descriptor.
370.PP
371The following symbolic constants are provided for
372.IR mode :
373.TP
374.B S_IRWXU
37500700 user (file owner) has read, write and execute permission
376.TP
cc513f7f 377.B S_IRUSR
fea681da
MK
37800400 user has read permission
379.TP
cc513f7f 380.B S_IWUSR
fea681da
MK
38100200 user has write permission
382.TP
cc513f7f 383.B S_IXUSR
fea681da
MK
38400100 user has execute permission
385.TP
386.B S_IRWXG
38700070 group has read, write and execute permission
388.TP
389.B S_IRGRP
39000040 group has read permission
391.TP
392.B S_IWGRP
39300020 group has write permission
394.TP
395.B S_IXGRP
39600010 group has execute permission
397.TP
398.B S_IRWXO
39900007 others have read, write and execute permission
400.TP
401.B S_IROTH
40200004 others have read permission
403.TP
404.B S_IWOTH
d301ee6c 40500002 others have write permission
fea681da
MK
406.TP
407.B S_IXOTH
40800001 others have execute permission
409.PP
410.I mode
411must be specified when
412.B O_CREAT
413is in the
414.IR flags ,
415and is ignored otherwise.
416
1c1e15ed 417.BR creat ()
fea681da 418is equivalent to
1c1e15ed 419.BR open ()
fea681da
MK
420with
421.I flags
422equal to
423.BR O_CREAT|O_WRONLY|O_TRUNC .
424.SH "RETURN VALUE"
c13182ef
MK
425.BR open ()
426and
e1d6264d 427.BR creat ()
1c1e15ed
MK
428return the new file descriptor, or \-1 if an error occurred
429(in which case,
fea681da
MK
430.I errno
431is set appropriately).
fea681da
MK
432.SH ERRORS
433.TP
434.B EACCES
435The requested access to the file is not allowed, or search permission
436is denied for one of the directories in the path prefix of
437.IR pathname ,
438or the file did not exist yet and write access to the parent directory
439is not allowed.
440(See also
ad7cc990 441.BR path_resolution (7).)
fea681da
MK
442.TP
443.B EEXIST
444.I pathname
445already exists and
446.BR O_CREAT " and " O_EXCL
447were used.
448.TP
449.B EFAULT
0daa9e92 450.I pathname
e1d6264d 451points outside your accessible address space.
fea681da 452.TP
9f5773f7
MK
453.B EFBIG
454.I pathname
682edefb
MK
455refers to a regular file, too large to be opened; see
456.B O_LARGEFILE
457above.
c13182ef 458(POSIX.1-2001 specifies the error
9f5773f7
MK
459.B EOVERFLOW
460for this case.)
0e1ad98c 461.\" FIXME . Maybe this deviation from the standard will get repaired.
9f5773f7
MK
462.\" See http://bugzilla.kernel.org/show_bug.cgi?id=7253
463.\" "Open of a large file on 32-bit fails with EFBIG, should be EOVERFLOW"
464.\" Reported 2006-10-03
465.TP
fea681da
MK
466.B EISDIR
467.I pathname
468refers to a directory and the access requested involved writing
469(that is,
470.B O_WRONLY
471or
472.B O_RDWR
473is set).
474.TP
475.B ELOOP
476Too many symbolic links were encountered in resolving
477.IR pathname ,
a8d55537 478or \fBO_NOFOLLOW\fP was specified but
fea681da
MK
479.I pathname
480was a symbolic link.
481.TP
482.B EMFILE
483The process already has the maximum number of files open.
484.TP
485.B ENAMETOOLONG
0daa9e92 486.I pathname
e1d6264d 487was too long.
fea681da
MK
488.TP
489.B ENFILE
490The system limit on the total number of open files has been reached.
491.TP
492.B ENODEV
493.I pathname
494refers to a device special file and no corresponding device exists.
682edefb
MK
495(This is a Linux kernel bug; in this situation
496.B ENXIO
497must be returned.)
fea681da
MK
498.TP
499.B ENOENT
682edefb
MK
500.B O_CREAT
501is not set and the named file does not exist.
fea681da
MK
502Or, a directory component in
503.I pathname
504does not exist or is a dangling symbolic link.
505.TP
506.B ENOMEM
507Insufficient kernel memory was available.
508.TP
509.B ENOSPC
510.I pathname
511was to be created but the device containing
512.I pathname
513has no room for the new file.
514.TP
515.B ENOTDIR
516A component used as a directory in
517.I pathname
a8d55537 518is not, in fact, a directory, or \fBO_DIRECTORY\fP was specified and
fea681da
MK
519.I pathname
520was not a directory.
521.TP
522.B ENXIO
682edefb
MK
523.BR O_NONBLOCK " | " O_WRONLY
524is set, the named file is a FIFO and
fea681da
MK
525no process has the file open for reading.
526Or, the file is a device special file and no corresponding device exists.
527.TP
1c1e15ed
MK
528.B EPERM
529The
530.B O_NOATIME
531flag was specified, but the effective user ID of the caller
532.\" Strictly speaking, it's the file system UID... (MTK)
533did not match the owner of the file and the caller was not privileged
534.RB ( CAP_FOWNER ).
535.TP
fea681da
MK
536.B EROFS
537.I pathname
538refers to a file on a read-only filesystem and write access was
539requested.
540.TP
541.B ETXTBSY
542.I pathname
543refers to an executable image which is currently being executed and
544write access was requested.
d3952311
MK
545.TP
546.B EWOULDBLOCK
547The
548.B O_NONBLOCK
549flag was specified, and an incompatible lease was held on the file
550(see
551.BR fcntl (2)).
fea681da 552.SH "CONFORMING TO"
97c1eac8 553SVr4, 4.3BSD, POSIX.1-2001.
fea681da 554The
fe75ec04
MK
555.BR O_CLOEXEC ,
556.BR O_DIRECTORY ,
1c1e15ed 557.BR O_NOATIME ,
fea681da 558and
0daa9e92 559.B O_NOFOLLOW
8382f16d 560flags are Linux-specific.
fea681da
MK
561One may have to define the
562.B _GNU_SOURCE
563macro to get their definitions.
0daa9e92 564.B O_DIRECT
fb7339df 565is not specified in POSIX; one has to define
fe75ec04
MK
566.B _GNU_SOURCE
567to get its definition.
a1d5f77c 568.SH NOTES
988db661 569Under Linux, the
a1d5f77c
MK
570.B O_NONBLOCK
571flag indicates that one wants to open
572but does not necessarily have the intention to read or write.
573This is typically used to open devices in order to get a file descriptor
574for use with
575.BR ioctl (2).
fea681da
MK
576.LP
577The (undefined) effect of
578.B O_RDONLY | O_TRUNC
c13182ef 579varies among implementations.
bcdd964e 580On many systems the file is actually truncated.
fea681da
MK
581.\" Linux 2.0, 2.5: truncate
582.\" Solaris 5.7, 5.8: truncate
583.\" Irix 6.5: truncate
584.\" Tru64 5.1B: truncate
585.\" HP-UX 11.22: truncate
586.\" FreeBSD 4.7: truncate
587.LP
588The
589.B O_DIRECT
590flag was introduced in SGI IRIX, where it has alignment restrictions
c13182ef
MK
591similar to those of Linux 2.4.
592IRIX has also a fcntl(2) call to
593query appropriate alignments, and sizes.
594FreeBSD 4.x introduced
fea681da
MK
595a flag of same name, but without alignment restrictions.
596Support was added under Linux in kernel version 2.4.10.
597Older Linux kernels simply ignore this flag.
1f6ceb40
MK
598One may have to define the
599.B _GNU_SOURCE
600macro to get its definition.
a1d5f77c
MK
601.PP
602There are many infelicities in the protocol underlying NFS, affecting
603amongst others
604.BR O_SYNC " and " O_NDELAY .
605
d9bfdb9c 606POSIX provides for three different variants of synchronized I/O,
a8d55537
MK
607corresponding to the flags \fBO_SYNC\fP, \fBO_DSYNC\fP and
608\fBO_RSYNC\fP.
a1d5f77c
MK
609Currently (2.1.130) these are all synonymous under Linux.
610
611Note that
612.BR open ()
613can open device special files, but
614.BR creat ()
615cannot create them; use
616.BR mknod (2)
617instead.
618.LP
619On NFS file systems with UID mapping enabled,
620.BR open ()
621may
75b94dc3 622return a file descriptor but, for example,
a1d5f77c
MK
623.BR read (2)
624requests are denied
625with \fBEACCES\fP.
626This is because the client performs
627.BR open ()
628by checking the
629permissions, but UID mapping is performed by the server upon
630read and write requests.
631
632If the file is newly created, its
988db661 633.IR st_atime ,
a1d5f77c
MK
634.IR st_ctime ,
635.I st_mtime
636fields
637(respectively, time of last access, time of last status change, and
638time of last modification; see
639.BR stat (2))
640are set
641to the current time, and so are the
642.I st_ctime
988db661 643and
a1d5f77c
MK
644.I st_mtime
645fields of the
646parent directory.
988db661 647Otherwise, if the file is modified because of the
a1d5f77c
MK
648.B O_TRUNC
649flag, its st_ctime and st_mtime fields are set to the current time.
fea681da
MK
650.SH BUGS
651"The thing that has always disturbed me about O_DIRECT is that the whole
652interface is just stupid, and was probably designed by a deranged monkey
e9496f74 653on some serious mind-controlling substances." \(em Linus
b50582eb
MK
654
655Currently, it is not possible to enable signal-driven
656I/O by specifying
657.B O_ASYNC
c13182ef 658when calling
b50582eb
MK
659.BR open ();
660use
661.BR fcntl (2)
662to enable this flag.
0e1ad98c 663.\" FIXME . Check bugzilla report on open(O_ASYNC)
92057f4d 664.\" See http://bugzilla.kernel.org/show_bug.cgi?id=5993
fea681da
MK
665.SH "SEE ALSO"
666.BR close (2),
e366dbc4 667.BR dup (2),
fea681da
MK
668.BR fcntl (2),
669.BR link (2),
1f6ceb40 670.BR lseek (2),
fea681da
MK
671.BR mknod (2),
672.BR mount (2),
e366dbc4 673.BR mmap (2),
28c54d45 674.BR openat (2),
fea681da
MK
675.BR read (2),
676.BR socket (2),
677.BR stat (2),
678.BR umask (2),
679.BR unlink (2),
680.BR write (2),
681.BR fopen (3),
50e5322c 682.BR fifo (7),
ad7cc990
MK
683.BR feature_test_macros (7),
684.BR path_resolution (7)