1.\" $NetBSD: lfs_markv.2,v 1.7 2002/10/01 18:10:44 wiz Exp $ 2.\" 3.\" Copyright (c) 2000 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Konrad Schroder. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd May 23, 2000 38.Dt LFS_MARKV 2 39.Os 40.Sh NAME 41.Nm lfs_markv 42.Nd rewrite disk blocks to new disk locations 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.Fd #include \*[Lt]sys/types.h\*[Gt] 47.Fd #include \*[Lt]ufs/lfs/lfs.h\*[Gt] 48.Ft int 49.Fn lfs_markv "fsid_t *fsidp" "BLOCK_INFO *blkiov" "int blkcnt" 50.Sh DESCRIPTION 51.Fn lfs_markv 52rewrites the blocks specified in 53.Fa blkiov 54to new disk locations, for the purposes of grouping them next to one 55another, or to move them out of a segment to clean it. 56All fields of the BLOCK_INFO structure must be filled in, except for 57.Fa bi_segcreate . 58If 59.Fa bi_daddr 60is not the correct current address for logical block 61.Fa bi_lbn 62of the file with inode number 63.Fa bi_inode , 64or if the file's version number does not match 65.Fa bi_version , 66the block will not be written to disk, but no error will be returned. 67.Pp 68The 69.Fa fsidp 70argument contains the id of the filesystem to which the inodes and 71blocks belong. 72The 73.Fa bi_bp 74field contains 75.Fa bi_size 76bytes of data to be written into the appropriate block. 77If 78.Fa bi_lbn 79is specified as LFS_UNUSED_LBN, the inode itself will be rewritten. 80.Pp 81The 82.Fa blkiov 83argument is an array of BLOCK_INFO structures (see below). 84The 85.Fa blkcnt 86argument determines the size of the 87.Fa blkiov 88array. 89.Bd -literal 90typedef struct block_info { 91 ino_t bi_inode; /* inode # */ 92 ufs_daddr_t bi_lbn; /* logical block w/in file */ 93 ufs_daddr_t bi_daddr; /* disk address of block */ 94 time_t bi_segcreate; /* origin segment create time */ 95 int bi_version; /* file version number */ 96 void *bi_bp; /* data buffer */ 97 int bi_size; /* size of the block (if fragment) */ 98} BLOCK_INFO; 99.Ed 100.Sh RETURN VALUES 101.Fn lfs_markv 102returns 0 on success, or -1 on error. 103.Sh ERRORS 104An error return from 105.Fn lfs_markv 106indicates: 107.Bl -tag -width Er 108.It Bq Er EFAULT 109.Fa fsidp 110points outside the process's allocated address space. 111.It Bq Er EINVAL 112.Fa *fsidp 113does not specify a valid filesystem. 114.It Bq Er EBUSY 115One or more of the inodes whose blocks were to be written was locked, 116and its blocks were not rewritten. 117.El 118.Sh SEE ALSO 119.Xr lfs_segclean 2 , 120.Xr lfs_segwait 2 , 121.Xr lfs_cleanerd 8 122.Sh HISTORY 123The 124.Fn lfs_markv 125function call appeared in 126.Bx 4.4 . 127.Sh BUGS 128The functionality of 129.Fn lfs_markv 130does not really belong in user space. 131Among other things it could be used to work around the 132SF_IMMUTABLE 133and 134SF_APPEND 135file flags (see 136.Xr chflags 2 ) . 137