SPDX-License-Identifier: BSD-2-Clause

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 25, 2021 .Dt VN_DEALLOCATE 9 .Os .Sh NAME .Nm vn_deallocate .Nd zero and/or deallocate storage from a file .Sh SYNOPSIS n sys/param.h n sys/vnode.h .Ft int .Fo vn_deallocate .Fa "struct vnode *vp" .Fa "off_t *offset" .Fa "off_t *length" .Fa "int flags" .Fa "int ioflag" .Fa "struct ucred *active_cred" .Fa "struct ucred *file_cred" .Fc .Sh DESCRIPTION The .Fn vn_deallocate function zeros and/or deallocates backing storage space from a file. This function only works on vnodes with .Dv VREG type.

p The arguments are: l -tag -width active_cred t Fa vp The vnode of the file. t Fa offset The starting offset of the operation range. t Fa length The length of the operation range. This must be greater than 0. t Fa flags The control flags of the operation. This should be set to 0 for now. t Fa ioflag Directives and hints to be given to the file system. t Fa active_cred The user credentials of the calling thread. t Fa file_cred The credentials installed on the file description pointing to the vnode or NOCRED. .El

p The .Fn ioflag argument gives directives and hints to the file system. It may include one or more of the following flags: l -tag -width IO_RANGELOCKED t Dv IO_NODELOCKED The vnode was locked before the call. t Dv IO_RANGELOCKED Rangelock was owned around the call. t Dv IO_NOMACCHECK Skip MAC checking in the call. t Dv IO_SYNC Do I/O synchronously. t Dv IO_DIRECT Attempt to bypass buffer cache. .El

p .Fa *offset and .Fa *length are updated to reflect the unprocessed operation range of the call. For a successful completion, .Fa *length is updated to be the value 0, and .Fa *offset is incremented by the number of bytes zeroed before the end-of-file. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. .Sh SEE ALSO .Xr vnode 9 , .Xr VOP_DEALLOCATE 9 .Sh AUTHORS .Nm and this manual page was written by .An Ka Ho Ng Aq Mt khng@FreeBSD.org under sponsorship from the FreeBSD Foundation.