]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/readahead.2
Add SEE ALSO referring to posix_fadvise.2.
[thirdparty/man-pages.git] / man2 / readahead.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 2004, Michael Kerrisk
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.
18 .\"
19 .\" Formatted or processed versions of this manual, if unaccompanied by
20 .\" the source, must acknowledge the copyright and authors of this work.
21 .\"
22 .\" 2004-05-40 Created by Michael Kerrisk <mtk-manpages@gmx.net>
23 .\" 2004-10-05 aeb, minor correction
24 .\"
25 .TH READAHEAD 2 2004-10-05 "Linux 2.6.5" "Linux Programmer's Manual"
26 .SH NAME
27 readahead \- perform file readahead into page cache
28 .SH SYNOPSIS
29 .nf
30 .B #include <fcntl.h>
31 .sp
32 .BI "ssize_t readahead(int " fd ", off64_t *" offset ", size_t " count );
33 .fi
34 .SH DESCRIPTION
35 .BR readahead ()
36 populates the page cache with data from a file so that subsequent
37 reads from that file will not block on disk I/O.
38 The
39 .I fd
40 argument is a file descriptor identifying the file which is
41 to be read.
42 The
43 .I offset
44 argument specifies the starting point from which data is to be read
45 and
46 .I count
47 specifies the number of bytes to be read.
48 I/O is performed in whole pages, so that
49 .I offset
50 is effectively rounded down to a page boundary
51 and bytes are read up to the next page boundary greater than or
52 equal to
53 .IR "(offset+count)" .
54 .BR readahead ()
55 does not read beyond the end of the file.
56 .BR readahead ()
57 blocks until the specified data has been read.
58 The current file offset of the open file referred to by
59 .I fd
60 is left unchanged.
61 .SH "RETURN VALUE"
62 On success,
63 .BR readahead ()
64 returns 0; on failure, \-1 is returned, with
65 .I errno
66 set to indicate the cause of the error.
67 .SH ERRORS
68 .TP
69 .B EBADF
70 .I fd
71 is not a valid file descriptor or is not open for reading.
72 .TP
73 .B EINVAL
74 .I fd
75 does not refer to a file type to which
76 .BR readahead ()
77 can be applied.
78 .SH "CONFORMING TO"
79 The
80 .BR readahead ()
81 system call is Linux specific, and its use should be avoided
82 in portable applications.
83 .SH NOTES
84 The
85 .BR readahead ()
86 system call appeared in Linux 2.4.13.
87 .SH "SEE ALSO"
88 .BR fadvise (2),
89 .BR lseek (2),
90 .BR madvise (2),
91 .BR mmap (2),
92 .BR posix_fadvise (2),
93 .BR read (2)