1 .\" $NetBSD: disklabel.9,v 1.12 2004/09/25 19:11:02 chris Exp $
3 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Paul Kranenburg.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
38 .Nm bounds_check_with_label
39 .Nd disk label management routines
42 .Fn readdisklabel "dev_t dev" "void (*strat)(struct buf *)" "struct disklabel *lp" "struct cpu_disklabel *clp"
44 .Fn writedisklabel "dev_t dev" "void (*strat)(struct buf *)" "struct disklabel *lp" "struct cpu_disklabel *clp"
46 .Fn setdisklabel "struct disklabel *olp" "struct disklabel *nlp" "u_long openmask" "struct cpu_disklabel *clp"
48 .Fn bounds_check_with_label "struct buf *bp" "struct disklabel *lp" "int wlabel"
50 This collection of routines provides a disklabel management interface to
51 kernel device drivers.
52 These routines are classified as machine- or architecture-dependent because
53 of restrictions imposed by the machine architecture and boot-strapping code
54 on the location of the label, or because cooperation with other operating
55 systems requires specialized conversion code.
58 attempts to read a disklabel from the device identified by
60 using the device strategy routine passed in
62 Note that a buffer structure is required to pass to the strategy routine;
63 it needs to be acquired and parameterized for the intended I/O operation,
64 and disposed of when the operation has completed.
65 Some fields in the disklabel passed in
67 may be pre-initialized by the caller in order to meet device driver
68 requirements for the I/O operation initiated to get to the disklabel data
70 In particular, the field
72 if non-zero, is used by
74 to get an appropriately sized buffer to pass to the device strategy routine.
77 should be set to zero.
78 If the medium does not contain a native disklabel that can be read in directly,
80 may resort to constructing a label from other machine-dependent information
81 using the provided buffer passed in the
84 If a disk label can not be found or constructed, a string containing
85 an approximated description of the failure mode is returned.
91 stores disk label information contained in the disk label structure given by
93 on the device identified by
97 it acquires and sets up an I/O buffer to pass to the strategy routine
100 may elect to do a machine-dependent conversion of the native disk label
103 using the buffer pointed at by
106 to store the disk label onto the medium in a format complying with
107 architectural constraints.
109 returns 0 on success and
111 if the disk label specifies invalid or inconvertible values.
112 Otherwise, any error condition reported by the device strategy routine
118 checks a proposed new disk label passed in
120 for some amount of basic sanity.
121 This includes a check on attempts to
122 change the location, or reduce the size, of an existing disk partition
123 that is currently in use by the system.
124 The current disposition of the disk partitions is made available through
128 which provide, respectively, the existing disk label and a bit mask
129 identifying the partitions that are currently in use.
134 return value, while a vetoed update of the partition layout is signaled by a
137 Otherwise, 0 is returned.
139 .Fn bounds_check_with_label
140 is used to check whether a device transfer described by
142 to the device identified by
144 is properly contained within a disk partition of the disk with label
147 .Fn bounds_check_with_label
159 is zero, and the transfer is a write operation, a check is done if the transfer
162 the disklabel area on the medium.
174 should be set to a non-zero value if the intended operation is expected to
175 install or update the disk label.
176 Programs that intend to do so using the raw device interface should notify
177 the driver by using a