]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/posix_fadvise.2
sqlite3: Vendor import of sqlite3 3.43.1
[FreeBSD/FreeBSD.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 .\" 3. 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 .\"
30 .Dd March 30, 2020
31 .Dt POSIX_FADVISE 2
32 .Os
33 .Sh NAME
34 .Nm posix_fadvise
35 .Nd give advice about use of file data
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .In fcntl.h
40 .Ft int
41 .Fn posix_fadvise "int fd" "off_t offset" "off_t len" "int advice"
42 .Sh DESCRIPTION
43 The
44 .Fn posix_fadvise
45 system call
46 allows a process to describe to the system its data access behavior for an
47 open file descriptor
48 .Fa fd .
49 The advice covers the data starting at offset
50 .Fa offset
51 and continuing for
52 .Fa len
53 bytes.
54 If
55 .Fa len
56 is zero,
57 all data from
58 .Fa offset
59 to the end of the file is covered.
60 .Pp
61 The behavior is specified by the
62 .Fa advice
63 parameter and may be one of:
64 .Bl -tag -width POSIX_FADV_SEQUENTIAL
65 .It Dv POSIX_FADV_NORMAL
66 Tells the system to revert to the default data access behavior.
67 .It Dv POSIX_FADV_RANDOM
68 Is a hint that file data will be accessed randomly,
69 and prefetching is likely not advantageous.
70 .It Dv POSIX_FADV_SEQUENTIAL
71 Tells the system that file data will be accessed sequentially.
72 This currently does nothing as the default behavior uses heuristics to
73 detect sequential behavior.
74 .It Dv POSIX_FADV_WILLNEED
75 Tells the system that the specified data will be accessed in the near future.
76 The system may initiate an asynchronous read of the data if it is not already
77 present in memory.
78 .It Dv POSIX_FADV_DONTNEED
79 Tells the system that the specified data will not be accessed in the near
80 future.
81 The system may decrease the in-memory priority of clean data within the
82 specified range and future access to this data may require a read operation.
83 .It Dv POSIX_FADV_NOREUSE
84 Tells the system that the specified data will only be accessed once and
85 then not reused.
86 The system may decrease the in-memory priority of data once it has been
87 read or written.
88 Future access to this data may require a read operation.
89 .El
90 .Sh RETURN VALUES
91 If successful,
92 .Fn posix_fadvise
93 returns zero.
94 It returns an error on failure, without setting
95 .Va errno .
96 .Sh ERRORS
97 Possible failure conditions:
98 .Bl -tag -width Er
99 .It Bq Er EBADF
100 The
101 .Fa fd
102 argument is not a valid file descriptor.
103 .It Bq Er EINVAL
104 The
105 .Fa advice
106 argument is not valid.
107 .It Bq Er EINVAL
108 The
109 .Fa offset
110 or
111 .Fa len
112 arguments are negative,
113 or
114 .Fa offset
115 +
116 .Fa len
117 is greater than the maximum file size.
118 .It Bq Er ENODEV
119 The
120 .Fa fd
121 argument does not refer to a regular file.
122 .It Bq Er ESPIPE
123 The
124 .Fa fd
125 argument is associated with a pipe or FIFO.
126 .It Bq Er EIO
127 An I/O error occurred while reading from or writing to a file system.
128 .It Bq Er EINTEGRITY
129 Corrupted data was detected while reading from the file system.
130 .El
131 .Sh SEE ALSO
132 .Xr madvise 2
133 .Sh STANDARDS
134 The
135 .Fn posix_fadvise
136 interface conforms to
137 .St -p1003.1-2001 .
138 .Sh HISTORY
139 The
140 .Fn posix_fadvise
141 system call first appeared in
142 .Fx 9.1 .