xref: /freebsd/share/man/man9/VOP_ALLOCATE.9 (revision a51584a2d2fb3731a68eaf93b59e14227e572427)
1ea41f49fSJohn Baldwin.\" -*- nroff -*-
2ea41f49fSJohn Baldwin.\"
3179fa75eSJohn Baldwin.\" Copyright (c) 2013 Hudson River Trading LLC
4ea41f49fSJohn Baldwin.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
5ea41f49fSJohn Baldwin.\" All rights reserved.
6ea41f49fSJohn Baldwin.\"
7ea41f49fSJohn Baldwin.\" Redistribution and use in source and binary forms, with or without
8ea41f49fSJohn Baldwin.\" modification, are permitted provided that the following conditions
9ea41f49fSJohn Baldwin.\" are met:
10ea41f49fSJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright
11ea41f49fSJohn Baldwin.\"    notice, this list of conditions and the following disclaimer.
12ea41f49fSJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright
13ea41f49fSJohn Baldwin.\"    notice, this list of conditions and the following disclaimer in the
14ea41f49fSJohn Baldwin.\"    documentation and/or other materials provided with the distribution.
15ea41f49fSJohn Baldwin.\"
16ea41f49fSJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17ea41f49fSJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18ea41f49fSJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19ea41f49fSJohn Baldwin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20ea41f49fSJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ea41f49fSJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22ea41f49fSJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23ea41f49fSJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24ea41f49fSJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25ea41f49fSJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26ea41f49fSJohn Baldwin.\" SUCH DAMAGE.
27ea41f49fSJohn Baldwin.\"
28b2bf1a57SRick Macklem.Dd November 8, 2021
29ea41f49fSJohn Baldwin.Dt VOP_ALLOCATE 9
30ea41f49fSJohn Baldwin.Os
31ea41f49fSJohn Baldwin.Sh NAME
32ea41f49fSJohn Baldwin.Nm VOP_ALLOCATE
33ea41f49fSJohn Baldwin.Nd allocate storage for a file
34ea41f49fSJohn Baldwin.Sh SYNOPSIS
35ea41f49fSJohn Baldwin.In sys/param.h
36ea41f49fSJohn Baldwin.In sys/vnode.h
37ea41f49fSJohn Baldwin.Ft int
38b2bf1a57SRick Macklem.Fo VOP_ALLOCATE
39b2bf1a57SRick Macklem.Fa "struct vnode *vp"
40b2bf1a57SRick Macklem.Fa "off_t *offset"
41b2bf1a57SRick Macklem.Fa "off_t *len"
42b2bf1a57SRick Macklem.Fa "int ioflag"
43b2bf1a57SRick Macklem.Fa "struct ucred *cred"
44b2bf1a57SRick Macklem.Fc
45ea41f49fSJohn Baldwin.Sh DESCRIPTION
46ea41f49fSJohn BaldwinThis call allocates storage for a range of offsets in a file.
47ea41f49fSJohn BaldwinIt is used to implement the
48*a51584a2SGraham Percival.Xr posix_fallocate 2
49ea41f49fSJohn Baldwinsystem call.
50ea41f49fSJohn Baldwin.Pp
51ea41f49fSJohn BaldwinIts arguments are:
52ea41f49fSJohn Baldwin.Bl -tag -width offset
53ea41f49fSJohn Baldwin.It Fa vp
54ea41f49fSJohn BaldwinThe vnode of the file.
55ea41f49fSJohn Baldwin.It Fa offset
56ea41f49fSJohn BaldwinThe start of the range to allocate storage for in the file.
57ea41f49fSJohn Baldwin.It Fa len
58ea41f49fSJohn BaldwinThe length of the range to allocate storage for in the file.
59b2bf1a57SRick Macklem.It Fa ioflag
60b2bf1a57SRick MacklemDirectives and hints to be given to the file system.
61b2bf1a57SRick Macklem.It Fa cred
62b2bf1a57SRick MacklemThe credentials of the caller.
63ea41f49fSJohn Baldwin.El
64ea41f49fSJohn Baldwin.Pp
65ea41f49fSJohn BaldwinThe
66ea41f49fSJohn Baldwin.Fa offset
67ea41f49fSJohn Baldwinand
68ea41f49fSJohn Baldwin.Fa len
69ea41f49fSJohn Baldwinarguments are updated to reflect the portion of the range that
70ea41f49fSJohn Baldwinstill needs to be allocated on return.
71ea41f49fSJohn BaldwinA partial allocation is considered a successful operation.
72ea41f49fSJohn BaldwinThe file's contents are not changed.
73ea41f49fSJohn Baldwin.Sh LOCKS
74ea41f49fSJohn BaldwinThe file should be exclusively locked on entry and will still be locked on exit.
75ea41f49fSJohn Baldwin.Sh RETURN VALUES
76ea41f49fSJohn BaldwinZero is returned if the call is successful, otherwise an appropriate
77ea41f49fSJohn Baldwinerror code is returned.
78ea41f49fSJohn Baldwin.Sh ERRORS
79ea41f49fSJohn Baldwin.Bl -tag -width Er
80ea41f49fSJohn Baldwin.It Bq Er EFBIG
81ea41f49fSJohn BaldwinAn attempt was made to write a file that exceeds the process's file size
82ea41f49fSJohn Baldwinlimit or the maximum file size.
83ea41f49fSJohn Baldwin.It Bq Er ENOSPC
84ea41f49fSJohn BaldwinThe file system is full.
85ea41f49fSJohn Baldwin.It Bq Er EPERM
86ea41f49fSJohn BaldwinAn append-only flag is set on the file, but the caller is attempting to
87ea41f49fSJohn Baldwinwrite before the current end of file.
88ea41f49fSJohn Baldwin.El
89ea41f49fSJohn Baldwin.Sh SEE ALSO
90ea41f49fSJohn Baldwin.Xr vnode 9 ,
91ea41f49fSJohn Baldwin.Xr VOP_READ 9 ,
92ea41f49fSJohn Baldwin.Xr VOP_WRITE 9
93