1166551Smarcel#- 2188723Smarcel# Copyright (c) 2006-2009 Marcel Moolenaar 3166551Smarcel# All rights reserved. 4166551Smarcel# 5166551Smarcel# Redistribution and use in source and binary forms, with or without 6166551Smarcel# modification, are permitted provided that the following conditions 7166551Smarcel# are met: 8166551Smarcel# 9166551Smarcel# 1. Redistributions of source code must retain the above copyright 10166551Smarcel# notice, this list of conditions and the following disclaimer. 11166551Smarcel# 2. Redistributions in binary form must reproduce the above copyright 12166551Smarcel# notice, this list of conditions and the following disclaimer in the 13166551Smarcel# documentation and/or other materials provided with the distribution. 14166551Smarcel# 15166551Smarcel# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16166551Smarcel# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17166551Smarcel# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18166551Smarcel# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19166551Smarcel# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20166551Smarcel# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21166551Smarcel# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22166551Smarcel# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23166551Smarcel# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24166551Smarcel# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25166551Smarcel# 26166551Smarcel# $FreeBSD: releng/10.2/sys/geom/part/g_part_if.m 214352 2010-10-25 16:23:35Z ae $ 27166551Smarcel 28166551Smarcel#include <sys/param.h> 29166551Smarcel#include <sys/lock.h> 30166551Smarcel#include <sys/malloc.h> 31166551Smarcel#include <sys/mutex.h> 32166551Smarcel#include <sys/sbuf.h> 33166551Smarcel#include <sys/bus.h> 34166551Smarcel#include <machine/bus.h> 35166561Srodrigc#include <sys/systm.h> 36166551Smarcel#include <geom/geom.h> 37166551Smarcel#include <geom/part/g_part.h> 38166551Smarcel 39166551Smarcel# The G_PART scheme interface. 40166551Smarcel 41166551SmarcelINTERFACE g_part; 42166551Smarcel 43188723Smarcel# Default implementations of methods. 44188723SmarcelCODE { 45191130Smarcel static void 46191130Smarcel default_fullname(struct g_part_table *table, 47191130Smarcel struct g_part_entry *entry, struct sbuf *sb, const char *pfx) 48191130Smarcel { 49191130Smarcel char buf[32]; 50191130Smarcel 51191130Smarcel sbuf_printf(sb, "%s%s", pfx, 52191130Smarcel G_PART_NAME(table, entry, buf, sizeof(buf))); 53191130Smarcel } 54191130Smarcel 55188723Smarcel static int 56188723Smarcel default_precheck(struct g_part_table *t __unused, 57188723Smarcel enum g_part_ctl r __unused, struct g_part_parms *p __unused) 58188723Smarcel { 59188723Smarcel return (0); 60188723Smarcel } 61207094Smarcel 62207094Smarcel static int 63207094Smarcel default_resize(struct g_part_table *t __unused, 64207094Smarcel struct g_part_entry *e __unused, struct g_part_parms *p __unused) 65207094Smarcel { 66207094Smarcel return (ENOSYS); 67207094Smarcel } 68214352Sae 69214352Sae static int 70214352Sae default_recover(struct g_part_table *t __unused) 71214352Sae { 72214352Sae return (ENOSYS); 73214352Sae } 74188723Smarcel}; 75188723Smarcel 76166551Smarcel# add() - scheme specific processing for the add verb. 77166551SmarcelMETHOD int add { 78166551Smarcel struct g_part_table *table; 79166551Smarcel struct g_part_entry *entry; 80166551Smarcel struct g_part_parms *gpp; 81166551Smarcel}; 82166551Smarcel 83178180Smarcel# bootcode() - scheme specific processing for the bootcode verb. 84178180SmarcelMETHOD int bootcode { 85178180Smarcel struct g_part_table *table; 86178180Smarcel struct g_part_parms *gpp; 87178180Smarcel}; 88178180Smarcel 89166551Smarcel# create() - scheme specific processing for the create verb. 90166551SmarcelMETHOD int create { 91166551Smarcel struct g_part_table *table; 92166551Smarcel struct g_part_parms *gpp; 93166551Smarcel}; 94166551Smarcel 95166551Smarcel# destroy() - scheme specific processing for the destroy verb. 96166551SmarcelMETHOD int destroy { 97166551Smarcel struct g_part_table *table; 98166551Smarcel struct g_part_parms *gpp; 99166551Smarcel}; 100166551Smarcel 101166551Smarcel# dumpconf() 102166551SmarcelMETHOD void dumpconf { 103166551Smarcel struct g_part_table *table; 104166551Smarcel struct g_part_entry *entry; 105166551Smarcel struct sbuf *sb; 106166551Smarcel const char *indent; 107166551Smarcel}; 108166551Smarcel 109166551Smarcel# dumpto() - return whether the partiton can be used for kernel dumps. 110166551SmarcelMETHOD int dumpto { 111166551Smarcel struct g_part_table *table; 112166551Smarcel struct g_part_entry *entry; 113166551Smarcel}; 114166551Smarcel 115191130Smarcel# fullname() - write the name of the given partition entry to the sbuf. 116191130SmarcelMETHOD void fullname { 117191130Smarcel struct g_part_table *table; 118191130Smarcel struct g_part_entry *entry; 119191130Smarcel struct sbuf *sb; 120191130Smarcel const char *pfx; 121191130Smarcel} DEFAULT default_fullname; 122191130Smarcel 123166551Smarcel# modify() - scheme specific processing for the modify verb. 124166551SmarcelMETHOD int modify { 125166551Smarcel struct g_part_table *table; 126166551Smarcel struct g_part_entry *entry; 127166551Smarcel struct g_part_parms *gpp; 128166551Smarcel}; 129166551Smarcel 130207094Smarcel# resize() - scheme specific processing for the resize verb. 131207094SmarcelMETHOD int resize { 132207094Smarcel struct g_part_table *table; 133207094Smarcel struct g_part_entry *entry; 134207094Smarcel struct g_part_parms *gpp; 135207094Smarcel} DEFAULT default_resize; 136207094Smarcel 137166551Smarcel# name() - return the name of the given partition entry. 138166551Smarcel# Typical names are "p1", "s0" or "c". 139166551SmarcelMETHOD const char * name { 140166551Smarcel struct g_part_table *table; 141166551Smarcel struct g_part_entry *entry; 142166551Smarcel char *buf; 143166551Smarcel size_t bufsz; 144166551Smarcel}; 145166551Smarcel 146188659Smarcel# precheck() - method to allow schemes to check the parameters given 147188659Smarcel# to the mentioned ctl request. This only applies to the requests that 148188659Smarcel# operate on a GEOM. In other words, it does not apply to the create 149188659Smarcel# request. 150188659Smarcel# It is allowed (intended actually) to change the parameters according 151188659Smarcel# to the schemes needs before they are used. Returning an error will 152188659Smarcel# terminate the request immediately. 153188659SmarcelMETHOD int precheck { 154188659Smarcel struct g_part_table *table; 155188659Smarcel enum g_part_ctl req; 156188659Smarcel struct g_part_parms *gpp; 157188723Smarcel} DEFAULT default_precheck; 158188659Smarcel 159166551Smarcel# probe() - probe the provider attached to the given consumer for the 160166551Smarcel# existence of the scheme implemented by the G_PART interface handler. 161166551SmarcelMETHOD int probe { 162166551Smarcel struct g_part_table *table; 163166551Smarcel struct g_consumer *cp; 164166551Smarcel}; 165166551Smarcel 166166551Smarcel# read() - read the on-disk partition table into memory. 167166551SmarcelMETHOD int read { 168166551Smarcel struct g_part_table *table; 169166551Smarcel struct g_consumer *cp; 170166551Smarcel}; 171166551Smarcel 172214352Sae# recover() - scheme specific processing for the recover verb. 173214352SaeMETHOD int recover { 174214352Sae struct g_part_table *table; 175214352Sae} DEFAULT default_recover; 176214352Sae 177179853Smarcel# setunset() - set or unset partition entry attributes. 178179853SmarcelMETHOD int setunset { 179179853Smarcel struct g_part_table *table; 180179853Smarcel struct g_part_entry *entry; 181179853Smarcel const char *attrib; 182179853Smarcel unsigned int set; 183179853Smarcel}; 184179853Smarcel 185166551Smarcel# type() - return a string representation of the partition type. 186166551Smarcel# Preferrably, the alias names. 187166551SmarcelMETHOD const char * type { 188166551Smarcel struct g_part_table *table; 189166551Smarcel struct g_part_entry *entry; 190166551Smarcel char *buf; 191166551Smarcel size_t bufsz; 192166551Smarcel}; 193166551Smarcel 194166551Smarcel# write() - write the in-memory partition table to disk. 195166551SmarcelMETHOD int write { 196166551Smarcel struct g_part_table *table; 197166551Smarcel struct g_consumer *cp; 198166551Smarcel}; 199