]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/posix_fadvise.2
Replace mention of /etc/shadow by refernces to
[thirdparty/man-pages.git] / man2 / posix_fadvise.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright 2003 Abhijit Menon-Sen <ams@wiw.org>
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\"
f21a10c8
MK
24.\" 2005-04-08 mtk, noted kernel version and added BUGS
25.\"
fea681da
MK
26.TH POSIX_FADVISE 2 "14 Feb 2003" "Linux 2.5.60" "Linux Programmer's Manual"
27.SH NAME
28posix_fadvise \- predeclare an access pattern for file data
29.SH SYNOPSIS
30.nf
31.B #include <fcntl.h>
32.sp
33.BI "int posix_fadvise(int " fd ", off_t " offset ", off_t " len ", int " advice ");"
34.fi
35.SH DESCRIPTION
36Programs can use \fBposix_fadvise\fP to announce an intention to access
37file data in a specific pattern in the future, thus allowing the kernel
38to perform appropriate optimisations.
39
40The \fIadvice\fP applies to a (not necessarily existent) region starting
41at \fIoffset\fP and extending for \fIlen\fP bytes (or until the end of
42the file if \fIlen\fP is 0) within the file referred to by \fIfd\fP. The
43advice is not binding; it merely constitutes an expectation on behalf of
44the application.
45
46Permissible values for \fIadvice\fP include:
47.TP
48.B POSIX_FADV_NORMAL
49Indicates that the application has no advice to give about its access
50pattern for the specified data. If no advice is given for an open file,
51this is the default assumption.
52.TP
53.B POSIX_FADV_SEQUENTIAL
54The application expects to access the specified data sequentially (with
55lower offsets read before higher ones).
56.TP
57.B POSIX_FADV_RANDOM
58The specified data will be accessed in random order.
59.TP
60.B POSIX_FADV_NOREUSE
61The specified data will be accessed only once.
62.TP
63.B POSIX_FADV_WILLNEED
64The specified data will be accessed in the near future.
65.TP
66.B POSIX_FADV_DONTNEED
67The specified data will not be accessed in the near future.
68.SH "RETURN VALUE"
69On success, zero is returned. On error, \-1 is returned, and \fIerrno\fP
70is set appropriately.
71.SH ERRORS
72.TP
73.B EBADF
74The \fIfd\fP argument was not a valid file descriptor.
75.TP
76.B EINVAL
77An invalid value was specified for \fIadvice\fP.
78.TP
79.B ESPIPE
80The specified file descriptor refers to a pipe or FIFO. (Linux actually
81returns EINVAL in this case.)
82.SH NOTES
f21a10c8
MK
83.BR posix_fadvise
84appeared in kernel 2.5.60.
85.\" Actually as fadvise64() -- MTK
86
fea681da
MK
87Under Linux, \fBPOSIX_FADV_NORMAL\fP sets the readahead window to the
88default size for the backing device; \fBPOSIX_FADV_SEQUENTIAL\fP doubles
89this size, and \fBPOSIX_FADV_RANDOM\fP disables file readahead entirely.
90These changes affect the the entire file, not just the specified region
91(but other open file handles to the same file are unaffected).
92
93\fBPOSIX_FADV_WILLNEED\fP and \fBPOSIX_FADV_NOREUSE\fP both initiate a
94non-blocking read of the specified region into the page cache. The amount
95of data read may be decreased by the kernel depending on VM load. (A few
96megabytes will usually be fully satisfied, and more is rarely useful.)
97
98\fBPOSIX_FADV_DONTNEED\fP attempts to free cached pages associated with
99the specified region. This is useful, for example, while streaming large
100files. A program may periodically request the kernel to free cached data
101that has already been used, so that more useful cached pages are not
102discarded instead.
103
104Pages that have not yet been written out will be unaffected, so if the
105application wishes to guarantee that pages will be released, it should
106call \fBfsync\fP or \fBfdatasync\fP first.
107.SH "CONFORMING TO"
108SUSv3 (Advanced Realtime Option), POSIX 1003.1-2003.
109Note that the type of the
110.I len
111parameter was changed from size_t to off_t in POSIX 1003.1-2003 TC5.
f21a10c8
MK
112.SH BUGS
113In kernels before 2.6.6, if
114.I len
115was specified as 0, then this was interpreted literally as "zero bytes",
116rather than as meaning "all bytes through to the end of the file".
fea681da
MK
117.SH "SEE ALSO"
118.BR posix_fallocate "(2), " posix_madvise "(2)."