xref: /dragonfly/lib/libc/stdlib/posix_fadvise.3 (revision 5fb3968e)
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.\" $FreeBSD: head/lib/libc/sys/posix_fadvise.2 314436 2017-02-28 23:42:47Z imp $
30.\"
31.Dd May 4, 2019
32.Dt POSIX_FADVISE 3
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.Em Note
45that this implementation is a no-op.
46It only does some failure checks.
47Any
48.Fa advice
49has no effect on the system's data access behavior.
50.Pp
51The
52.Fn posix_fadvise
53function
54allows a process to describe to the system its data access behavior for an
55open file descriptor
56.Fa fd .
57The advice covers the data starting at offset
58.Fa offset
59and continuing for
60.Fa len
61bytes.
62If
63.Fa len
64is zero,
65all data from
66.Fa offset
67to the end of the file is covered.
68.Pp
69The behavior is specified by the
70.Fa advice
71parameter and may be one of:
72.Bl -tag -width POSIX_FADV_SEQUENTIAL
73.It Dv POSIX_FADV_NORMAL
74Tells the system to revert to the default data access behavior.
75.It Dv POSIX_FADV_RANDOM
76Is a hint that file data will be accessed randomly,
77and prefetching is likely not advantageous.
78.It Dv POSIX_FADV_SEQUENTIAL
79Tells the system that file data will be accessed sequentially.
80This currently does nothing as the default behavior uses heuristics to
81detect sequential behavior.
82.It Dv POSIX_FADV_WILLNEED
83Tells the system that the specified data will be accessed in the near future.
84The system may initiate an asynchronous read of the data if it is not already
85present in memory.
86.It Dv POSIX_FADV_DONTNEED
87Tells the system that the specified data will not be accessed in the near
88future.
89The system may decrease the in-memory priority of clean data within the
90specified range and future access to this data may require a read operation.
91.It Dv POSIX_FADV_NOREUSE
92Tells the system that the specified data will only be accessed once and
93then not reused.
94The system may decrease the in-memory priority of data once it has been
95read or written.
96Future access to this data may require a read operation.
97.El
98.Sh RETURN VALUES
99If successful,
100.Fn posix_fadvise
101returns zero.
102It returns an error on failure, without setting
103.Va errno .
104.Sh ERRORS
105Possible failure conditions:
106.Bl -tag -width Er
107.It Bq Er EBADF
108The
109.Fa fd
110argument is not a valid file descriptor.
111.It Bq Er EINVAL
112The
113.Fa advice
114argument is not valid.
115.It Bq Er EINVAL
116The
117.Fa offset
118or
119.Fa len
120arguments are negative,
121or
122.Fa offset
123+
124.Fa len
125is greater than the maximum file size.
126.It Bq Er ENODEV
127The
128.Fa fd
129argument does not refer to a regular file.
130.It Bq Er ESPIPE
131The
132.Fa fd
133argument is associated with a pipe or FIFO.
134.El
135.Sh SEE ALSO
136.Xr madvise 2
137.Sh STANDARDS
138The
139.Fn posix_fadvise
140interface conforms to
141.St -p1003.1-2001 .
142.Sh HISTORY
143The
144.Fn posix_fadvise
145function first appeared in
146.Dx 5.5 .
147