]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - lib/libc/sys/posix_fadvise.2
MFC 226217,227070,227341,227502:
[FreeBSD/stable/8.git] / lib / libc / sys / posix_fadvise.2
1 .\" Copyright (c) 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)madvise.2   8.1 (Berkeley) 6/9/93
29 .\" $FreeBSD$
30 .\"
31 .Dd October 26, 2011
32 .Dt POSIX_FADVISE 2
33 .Os
34 .Sh NAME
35 .Nm posix_fadvise
36 .Nd give advice about use of file data
37 .Sh LIBRARY
38 .Lb libc
39 .Sh SYNOPSIS
40 .In fcntl.h
41 .Ft int
42 .Fn posix_fadvise "int fd" "off_t offset" "off_t len" "int advice"
43 .Sh DESCRIPTION
44 The
45 .Fn posix_fadvise
46 system call
47 allows a process to describe to the system its data access behavior for an
48 open file descriptor
49 .Fa fd .
50 The advice covers the data starting at offset
51 .Fa offset
52 and continuing for
53 .Fa len
54 bytes.
55 If
56 .Fa len
57 is zero,
58 all data from
59 .Fa offset
60 to the end of the file is covered.
61 .Pp
62 The behavior is specified by the
63 .Fa advice
64 parameter and may be one of:
65 .Bl -tag -width POSIX_FADV_SEQUENTIAL
66 .It Dv POSIX_FADV_NORMAL
67 Tells the system to revert to the default data access behavior.
68 .It Dv POSIX_FADV_RANDOM
69 Is a hint that file data will be accessed randomly,
70 and prefetching is likely not advantageous.
71 .It Dv POSIX_FADV_SEQUENTIAL
72 Tells the system that file data will be accessed sequentially.
73 This currently does nothing as the default behavior uses heuristics to
74 detect sequential behavior.
75 .It Dv POSIX_FADV_WILLNEED
76 Tells the system that the specified data will be accessed in the near future.
77 The system may initiate an asychronous read of the data if it is not already
78 present in memory.
79 .It Dv POSIX_FADV_DONTNEED
80 Tells the system that the specified data will not be accessed in the near
81 future.
82 The system may decrease the in-memory priority of clean data within the
83 specified range and future access to this data may require a read operation.
84 .It Dv POSIX_FADV_NOREUSE
85 Tells the system that the specified data will only be accessed once and
86 then not reused.
87 Accesses to data within the specified range are treated as if the file
88 descriptor has the
89 .Dv O_DIRECT
90 flag enabled.
91 .El
92 .Pp
93 .Sh RETURN VALUES
94 .Rv -std posix_fadvise
95 .Sh ERRORS
96 The
97 .Fn posix_fadvise
98 system call will fail if:
99 .Bl -tag -width Er
100 .It Bq Er EBADF
101 The
102 .Fa fd
103 argument is not a valid file descriptor.
104 .It Bq Er EINVAL
105 The
106 .Fa advice
107 argument is not valid.
108 .It Bq Er EINVAL
109 The
110 .Fa offset
111 or
112 .Fa len
113 arguments are negative,
114 or
115 .Fa offset
116 +
117 .Fa len
118 is greater than the maximum file size.
119 .It Bq Er ENODEV
120 The
121 .Fa fd
122 argument does not refer to a regular file.
123 .It Bq Er ESPIPE
124 The
125 .Fa fd
126 argument is associated with a pipe or FIFO.
127 .El
128 .Sh SEE ALSO
129 .Xr madvise 2
130 .Sh STANDARDS
131 The
132 .Fn posix_fadvise
133 interface conforms to
134 .St -p1003.1-2001 .
135 .Sh HISTORY
136 The
137 .Fn posix_fadvise
138 system call first appeared in
139 .Fx 10.0 .