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