2 # Copyright (c) 2006-2009 Marcel Moolenaar
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/param.h>
30 #include <sys/malloc.h>
31 #include <sys/mutex.h>
34 #include <machine/bus.h>
35 #include <sys/systm.h>
36 #include <geom/geom.h>
37 #include <geom/part/g_part.h>
39 # The G_PART scheme interface.
43 # Default implementations of methods.
46 default_precheck(struct g_part_table *t __unused,
47 enum g_part_ctl r __unused, struct g_part_parms *p __unused)
53 # add() - scheme specific processing for the add verb.
55 struct g_part_table *table;
56 struct g_part_entry *entry;
57 struct g_part_parms *gpp;
60 # bootcode() - scheme specific processing for the bootcode verb.
62 struct g_part_table *table;
63 struct g_part_parms *gpp;
66 # create() - scheme specific processing for the create verb.
68 struct g_part_table *table;
69 struct g_part_parms *gpp;
72 # destroy() - scheme specific processing for the destroy verb.
74 struct g_part_table *table;
75 struct g_part_parms *gpp;
78 # devalias() - return the name (if any) to be used as an alias for
79 # the device special file created for the partition entry.
81 struct g_part_table *table;
82 struct g_part_entry *entry;
88 METHOD void dumpconf {
89 struct g_part_table *table;
90 struct g_part_entry *entry;
95 # dumpto() - return whether the partiton can be used for kernel dumps.
97 struct g_part_table *table;
98 struct g_part_entry *entry;
101 # modify() - scheme specific processing for the modify verb.
103 struct g_part_table *table;
104 struct g_part_entry *entry;
105 struct g_part_parms *gpp;
108 # name() - return the name of the given partition entry.
109 # Typical names are "p1", "s0" or "c".
110 METHOD const char * name {
111 struct g_part_table *table;
112 struct g_part_entry *entry;
117 # precheck() - method to allow schemes to check the parameters given
118 # to the mentioned ctl request. This only applies to the requests that
119 # operate on a GEOM. In other words, it does not apply to the create
121 # It is allowed (intended actually) to change the parameters according
122 # to the schemes needs before they are used. Returning an error will
123 # terminate the request immediately.
124 METHOD int precheck {
125 struct g_part_table *table;
127 struct g_part_parms *gpp;
128 } DEFAULT default_precheck;
130 # probe() - probe the provider attached to the given consumer for the
131 # existence of the scheme implemented by the G_PART interface handler.
133 struct g_part_table *table;
134 struct g_consumer *cp;
137 # read() - read the on-disk partition table into memory.
139 struct g_part_table *table;
140 struct g_consumer *cp;
143 # setunset() - set or unset partition entry attributes.
144 METHOD int setunset {
145 struct g_part_table *table;
146 struct g_part_entry *entry;
151 # type() - return a string representation of the partition type.
152 # Preferrably, the alias names.
153 METHOD const char * type {
154 struct g_part_table *table;
155 struct g_part_entry *entry;
160 # write() - write the in-memory partition table to disk.
162 struct g_part_table *table;
163 struct g_consumer *cp;