OSDN Git Service

ed216f1b470e7525d4a64e834d4031c7ae92532e
[linuxjm/LDP_man-pages.git] / original / man3 / posix_fallocate.3
1 .\" Copyright (c) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH POSIX_FALLOCATE 3  2010-09-20 "GNU" "Linux Programmer's Manual"
24 .SH NAME
25 posix_fallocate \- allocate file space
26 .SH SYNOPSIS
27 .nf
28 .B #include <fcntl.h>
29 .sp
30 .BI "int posix_fallocate(int " fd ", off_t " offset ", off_t " len );
31 .fi
32 .sp
33 .ad l
34 .in -4n
35 Feature Test Macro Requirements for glibc (see
36 .BR feature_test_macros (7)):
37 .in
38 .sp
39 .BR posix_fallocate ():
40 .RS 4
41 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
42 .RE
43 .ad
44 .SH DESCRIPTION
45 The function
46 .BR posix_fallocate ()
47 ensures that disk space is allocated for the file referred to by the
48 descriptor
49 .I fd
50 for the bytes in the range starting at
51 .I offset
52 and continuing for
53 .I len
54 bytes.
55 After a successful call to
56 .BR posix_fallocate (),
57 subsequent writes to bytes in the specified range are
58 guaranteed not to fail because of lack of disk space.
59
60 If the size of the file is less than
61 .IR offset + len ,
62 then the file is increased to this size;
63 otherwise the file size is left unchanged.
64 .SH "RETURN VALUE"
65 .BR posix_fallocate ()
66 returns zero on success, or an error number on failure.
67 Note that
68 .I errno
69 is not set.
70 .SH "ERRORS"
71 .TP
72 .B EBADF
73 .I fd
74 is not a valid file descriptor, or is not opened for writing.
75 .TP
76 .B EFBIG
77 .I offset+len
78 exceeds the maximum file size.
79 .TP
80 .B EINVAL
81 .I offset
82 was less than 0, or
83 .I len
84 was less than or equal to 0.
85 .TP
86 .B ENODEV
87 .I fd
88 does not refer to a regular file.
89 .TP
90 .B ENOSPC
91 There is not enough space left on the device containing the file
92 referred to by
93 .IR fd .
94 .TP
95 .B ESPIPE
96 .I fd
97 refers to a pipe of file descriptor.
98 .SH VERSIONS
99 .BR posix_fallocate ()
100 is available since glibc 2.1.94.
101 .SH "CONFORMING TO"
102 POSIX.1-2001.
103
104 POSIX.1-2008 says that an implementation
105 .I shall
106 give the
107 .B EINVAL
108 error if
109 .I len
110 was 0, or
111 .I offset
112 was less than 0.
113 POSIX.1-2001 says that an implementation
114 .I shall
115 give the
116 .B EINVAL
117 error if
118 .I len
119 is less than 0, or
120 .I offset
121 was less than 0, and
122 .I may
123 give the error if
124 .I len
125 equals zero.
126 .SH "SEE ALSO"
127 .BR fallocate (2),
128 .BR lseek (2),
129 .BR posix_fadvise (2)