]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/readahead.2
syscall.2: Corrections and improvements to Changhee Han's patch
[thirdparty/man-pages.git] / man2 / readahead.2
CommitLineData
fea681da
MK
1.\" This manpage is Copyright (C) 2004, Michael Kerrisk
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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
10d76543
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
c11b1abf 25.\" 2004-05-40 Created by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
26.\" 2004-10-05 aeb, minor correction
27.\"
86b91fdf 28.TH READAHEAD 2 2010-09-10 "Linux" "Linux Programmer's Manual"
fea681da
MK
29.SH NAME
30readahead \- perform file readahead into page cache
31.SH SYNOPSIS
32.nf
86b91fdf 33.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
fea681da
MK
34.B #include <fcntl.h>
35.sp
37cd82ad 36.BI "ssize_t readahead(int " fd ", off64_t " offset ", size_t " count );
fea681da
MK
37.fi
38.SH DESCRIPTION
63aa9df0 39.BR readahead ()
fea681da
MK
40populates the page cache with data from a file so that subsequent
41reads from that file will not block on disk I/O.
42The
43.I fd
44argument is a file descriptor identifying the file which is
45to be read.
46The
47.I offset
48argument specifies the starting point from which data is to be read
49and
50.I count
51specifies the number of bytes to be read.
c13182ef 52I/O is performed in whole pages, so that
fea681da
MK
53.I offset
54is effectively rounded down to a page boundary
55and bytes are read up to the next page boundary greater than or
56equal to
57.IR "(offset+count)" .
63aa9df0 58.BR readahead ()
fea681da 59does not read beyond the end of the file.
63aa9df0 60.BR readahead ()
fea681da
MK
61blocks until the specified data has been read.
62The current file offset of the open file referred to by
63.I fd
64is left unchanged.
47297adb 65.SH RETURN VALUE
c13182ef 66On success,
63aa9df0 67.BR readahead ()
fea681da
MK
68returns 0; on failure, \-1 is returned, with
69.I errno
70set to indicate the cause of the error.
71.SH ERRORS
72.TP
73.B EBADF
74.I fd
75is not a valid file descriptor or is not open for reading.
76.TP
77.B EINVAL
78.I fd
79does not refer to a file type to which
e511ffb6 80.BR readahead ()
fea681da 81can be applied.
0f940346
MK
82.SH VERSIONS
83The
84.BR readahead ()
85system call appeared in Linux 2.4.13;
86glibc support has been provided since version 2.3.
47297adb 87.SH CONFORMING TO
c13182ef 88The
63aa9df0 89.BR readahead ()
8382f16d 90system call is Linux-specific, and its use should be avoided
fea681da 91in portable applications.
47297adb 92.SH SEE ALSO
fea681da
MK
93.BR lseek (2),
94.BR madvise (2),
95.BR mmap (2),
cedfddcd 96.BR posix_fadvise (2),
fea681da 97.BR read (2)