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