aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/fspacectl.2
blob: 2f581d1c1fb889abfa344ed8234082bdce4a371f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
.\"
.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
.\"
.\" Copyright (c) 2021 The FreeBSD Foundation
.\"
.\" This manual page was written by Ka Ho Ng under sponsorship from
.\" the FreeBSD Foundation.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 4, 2021
.Dt FSPACECTL 2
.Os
.Sh NAME
.Nm fspacectl
.Nd space management in a file
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In fcntl.h
.Ft int
.Fo fspacectl
.Fa "int fd"
.Fa "int cmd"
.Fa "const struct spacectl_range *rqsr"
.Fa "int flags"
.Fa "struct spacectl_range *rmsr"
.Fc
.Sh DESCRIPTION
.Nm
is a system call performing space management over a file.
The
.Fa fd
argument specifies the file descriptor to be operated on by the
.Fa cmd
argument.
The
.Fa rqsr
argument points to a
.Fa spacectl_range
structure that contains the requested operation range.
The
.Fa flags
argument controls the behavior of the operation to take place.
If the
.Fa rmsr
argument is non-NULL, the
.Fa spacectl_range
structure it points to is updated to contain the unprocessed operation range
after the system call returns.
Both
.Fa rqsr
and
.Fa rmsr
arguments can point to the same structure.
.Pp
The
.Fa spacectl_range
structure is defined as:
.Bd -literal
struct spacectl_range {
	off_t r_offset;
	off_t r_len;
};
.Ed
.Pp
The operation specified by the
.Fa cmd
argument may be one of:
.Bl -tag -width SPACECTL_DEALLOC
.It Dv SPACECTL_DEALLOC
Zero a region in the file specified by the
.Fa rqsr
argument.
The
.Va "rqsr->r_offset"
has to be a value greater than or equal to 0, and the
.Va "rqsr->r_len"
has to be a value greater than 0.
.Pp
If the file system supports hole-punching,
file system space deallocation may be performed in the given region.
.El
.Pp
The
.Fa flags
argument needs to be the value 0 currently.
.Sh RETURN VALUES
Upon successful completion, the value 0 is returned;
otherwise the value -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
Possible failure conditions:
.Bl -tag -width Er
.It Bq Er EBADF
The
.Fa fd
argument is not a valid file descriptor.
.It Bq Er EBADF
The
.Fa fd
argument references a file that was opened without write permission.
.It Bq Er EINTR
A signal was caught during execution.
.It Bq Er EINVAL
The
.Fa cmd
argument is not valid.
.It Bq Er EINVAL
If the
.Fa cmd
argument is
.Dv SPACECTL_DEALLOC ,
either the
.Fa "range->r_offset"
argument was less than zero, or the
.Fa "range->r_len"
argument was less than or equal to zero.
.It Bq Er EINVAL
An invalid or unsupported flag is included in
.Fa flags .
.It Bq Er EINVAL
A flag included in
.Fa flags
is not supported by the operation specified by the
.Fa cmd
argument.
.It Bq Er EFAULT
The
.Fa rqsr
or a non-NULL
.Fa rmsr
argument point outside the process' allocated address space.
.It Bq Er EIO
An I/O error occurred while reading from or writing to a file system.
.It Bq Er EINTEGRITY
Corrupted data was detected while reading from the file system.
.It Bq Er ENODEV
The
.Fa fd
argument does not refer to a file that supports
.Nm .
.It Bq Er ENOSPC
There is insufficient free space remaining on the file system storage
media.
.It Bq Er ENOTCAPABLE
The file descriptor
.Fa fd
has insufficient rights.
.It Bq Er ESPIPE
The
.Fa fd
argument is associated with a pipe or FIFO.
.El
.Sh SEE ALSO
.Xr creat 2 ,
.Xr ftruncate 2 ,
.Xr open 2 ,
.Xr unlink 2
.Sh HISTORY
The
.Nm
system call appeared in
.Fx 14.0 .
.Sh AUTHORS
.Nm
and this manual page were written by
.An Ka Ho Ng Aq Mt khng@FreeBSD.org
under sponsorship from the FreeBSD Foundation.