xref: /freebsd/sys/geom/part/g_part_if.m (revision b3aaa0cc21c63d388230c7ef2a80abd631ff20d5)
1#-
2# Copyright (c) 2006-2009 Marcel Moolenaar
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
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.
14#
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.
25#
26# $FreeBSD$
27
28#include <sys/param.h>
29#include <sys/lock.h>
30#include <sys/malloc.h>
31#include <sys/mutex.h>
32#include <sys/sbuf.h>
33#include <sys/bus.h>
34#include <machine/bus.h>
35#include <sys/systm.h>
36#include <geom/geom.h>
37#include <geom/part/g_part.h>
38
39# The G_PART scheme interface.
40
41INTERFACE g_part;
42
43# Default implementations of methods.
44CODE {
45	static int
46	default_precheck(struct g_part_table *t __unused,
47	    enum g_part_ctl r __unused, struct g_part_parms *p __unused)
48	{
49		return (0);
50	}
51};
52
53# add() - scheme specific processing for the add verb.
54METHOD int add {
55	struct g_part_table *table;
56	struct g_part_entry *entry;
57	struct g_part_parms *gpp;
58};
59
60# bootcode() - scheme specific processing for the bootcode verb.
61METHOD int bootcode {
62	struct g_part_table *table;
63	struct g_part_parms *gpp;
64};
65
66# create() - scheme specific processing for the create verb.
67METHOD int create {
68	struct g_part_table *table;
69	struct g_part_parms *gpp;
70};
71
72# destroy() - scheme specific processing for the destroy verb.
73METHOD int destroy {
74	struct g_part_table *table;
75	struct g_part_parms *gpp;
76};
77
78# devalias() - return the name (if any) to be used as an alias for
79# the device special file created for the partition entry.
80METHOD int devalias {
81	struct g_part_table *table;
82	struct g_part_entry *entry;
83	char *buf;
84	size_t bufsz;
85};
86
87# dumpconf()
88METHOD void dumpconf {
89	struct g_part_table *table;
90	struct g_part_entry *entry;
91	struct sbuf *sb;
92	const char *indent;
93};
94
95# dumpto() - return whether the partiton can be used for kernel dumps.
96METHOD int dumpto {
97	struct g_part_table *table;
98	struct g_part_entry *entry;
99};
100
101# modify() - scheme specific processing for the modify verb.
102METHOD int modify {
103	struct g_part_table *table;
104	struct g_part_entry *entry;
105	struct g_part_parms *gpp;
106};
107
108# name() - return the name of the given partition entry.
109# Typical names are "p1", "s0" or "c".
110METHOD const char * name {
111	struct g_part_table *table;
112	struct g_part_entry *entry;
113	char *buf;
114	size_t bufsz;
115};
116
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
120# request.
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.
124METHOD int precheck {
125	struct g_part_table *table;
126	enum g_part_ctl req;
127	struct g_part_parms *gpp;
128} DEFAULT default_precheck;
129
130# probe() - probe the provider attached to the given consumer for the
131# existence of the scheme implemented by the G_PART interface handler.
132METHOD int probe {
133	struct g_part_table *table;
134	struct g_consumer *cp;
135};
136
137# read() - read the on-disk partition table into memory.
138METHOD int read {
139	struct g_part_table *table;
140	struct g_consumer *cp;
141};
142
143# setunset() - set or unset partition entry attributes.
144METHOD int setunset {
145	struct g_part_table *table;
146	struct g_part_entry *entry;
147	const char *attrib;
148	unsigned int set;
149};
150
151# type() - return a string representation of the partition type.
152# Preferrably, the alias names.
153METHOD const char * type {
154        struct g_part_table *table;
155        struct g_part_entry *entry;
156        char *buf;
157        size_t bufsz;
158};
159
160# write() - write the in-memory partition table to disk.
161METHOD int write {
162	struct g_part_table *table;
163	struct g_consumer *cp;
164};
165