xref: /netbsd/lib/libc/sys/lfs_markv.2 (revision bf9ec67e)
1.\"	$NetBSD: lfs_markv.2,v 1.5 2002/02/08 01:28:18 ross 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.  All fields of
56the 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).  The
84.Fa blkcnt
85argument determines the size of the
86.Fa blkiov
87array.
88.Bd -literal
89typedef struct block_info {
90    ino_t       bi_inode;     /* inode # */
91    ufs_daddr_t bi_lbn;       /* logical block w/in file */
92    ufs_daddr_t bi_daddr;     /* disk address of block */
93    time_t      bi_segcreate; /* origin segment create time */
94    int         bi_version;   /* file version number */
95    void       *bi_bp;        /* data buffer */
96    int         bi_size;      /* size of the block (if fragment) */
97} BLOCK_INFO;
98.Ed
99.Sh RETURN VALUES
100.Fn lfs_markv
101returns 0 on success, or -1 on error.
102.Sh ERRORS
103An error return from
104.Fn lfs_markv
105indicates:
106.Bl -tag -width Er
107.It Bq Er EFAULT
108.Fa fsidp
109points outside the process's allocated address space.
110.It Bq Er EINVAL
111.Fa *fsidp
112does not specify a valid filesystem.
113.It Bq Er EBUSY
114One or more of the inodes whose blocks were to be written was locked,
115and its blocks were not rewritten.
116.El
117.Sh SEE ALSO
118.Xr lfs_markv 2 ,
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.  Among other things it could be
131used to work around the
132SF_IMMUTABLE
133and
134SF_APPEND
135file flags (see
136.Xr chflags 2 ) .
137