libgeom.h revision 110603
1110545Sphk/*- 2110545Sphk * Copyright (c) 2003 Poul-Henning Kamp 3110545Sphk * All rights reserved. 4110545Sphk * 5110545Sphk * Redistribution and use in source and binary forms, with or without 6110545Sphk * modification, are permitted provided that the following conditions 7110545Sphk * are met: 8110545Sphk * 1. Redistributions of source code must retain the above copyright 9110545Sphk * notice, this list of conditions and the following disclaimer. 10110545Sphk * 2. Redistributions in binary form must reproduce the above copyright 11110545Sphk * notice, this list of conditions and the following disclaimer in the 12110545Sphk * documentation and/or other materials provided with the distribution. 13110545Sphk * 3. The names of the authors may not be used to endorse or promote 14110545Sphk * products derived from this software without specific prior written 15110545Sphk * permission. 16110545Sphk * 17110545Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18110545Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19110545Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20110545Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21110545Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22110545Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23110545Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24110545Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25110545Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26110545Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27110545Sphk * SUCH DAMAGE. 28110545Sphk * 29110545Sphk * $FreeBSD: head/lib/libgeom/libgeom.h 110603 2003-02-10 00:11:43Z phk $ 30110545Sphk */ 31110545Sphk#ifndef _LIBGEOM_H_ 32110545Sphk#define _LIBGEOM_H_ 33110545Sphk 34110603Sphk#include <sys/queue.h> 35110547Sphk#include <sys/time.h> 36110545Sphk#include <geom/geom_stats.h> 37110545Sphk 38110545Sphkvoid geom_stats_close(void); 39110545Sphkvoid geom_stats_resync(void); 40110545Sphkint geom_stats_open(void); 41110545Sphkvoid *geom_stats_snapshot_get(void); 42110545Sphkvoid geom_stats_snapshot_free(void *arg); 43110545Sphkvoid geom_stats_snapshot_timestamp(void *arg, struct timespec *tp); 44110545Sphkvoid geom_stats_snapshot_reset(void *arg); 45110545Sphkstruct g_stat *geom_stats_snapshot_next(void *arg); 46110545Sphk 47110603Sphkchar *geom_getxml(void); 48110603Sphk 49110603Sphk/* geom_xml2tree.c */ 50110603Sphk 51110603Sphk/* 52110603Sphk * These structs are used to build the tree based on the XML. 53110603Sphk * they're named as the kernel variant without the first '_'. 54110603Sphk */ 55110603Sphk 56110603Sphkstruct gclass; 57110603Sphkstruct ggeom; 58110603Sphkstruct gconsumer; 59110603Sphkstruct gprovider; 60110603Sphk 61110603SphkLIST_HEAD(gconf, gconfig); 62110603Sphk 63110603Sphkstruct gident { 64110603Sphk void *id; 65110603Sphk void *ptr; 66110603Sphk enum { ISCLASS, 67110603Sphk ISGEOM, 68110603Sphk ISPROVIDER, 69110603Sphk ISCONSUMER } what; 70110603Sphk}; 71110603Sphk 72110603Sphkstruct gmesh { 73110603Sphk LIST_HEAD(, gclass) class; 74110603Sphk struct gident *ident; 75110603Sphk}; 76110603Sphk 77110603Sphkstruct gconfig { 78110603Sphk LIST_ENTRY(gconfig) config; 79110603Sphk char *name; 80110603Sphk char *val; 81110603Sphk}; 82110603Sphk 83110603Sphkstruct gclass { 84110603Sphk void *id; 85110603Sphk char *name; 86110603Sphk LIST_ENTRY(gclass) class; 87110603Sphk LIST_HEAD(, ggeom) geom; 88110603Sphk struct gconf config; 89110603Sphk}; 90110603Sphk 91110603Sphkstruct ggeom { 92110603Sphk void *id; 93110603Sphk struct gclass *class; 94110603Sphk char *name; 95110603Sphk u_int rank; 96110603Sphk LIST_ENTRY(ggeom) geom; 97110603Sphk LIST_HEAD(, gconsumer) consumer; 98110603Sphk LIST_HEAD(, gprovider) provider; 99110603Sphk struct gconf config; 100110603Sphk}; 101110603Sphk 102110603Sphkstruct gconsumer { 103110603Sphk void *id; 104110603Sphk struct ggeom *geom; 105110603Sphk LIST_ENTRY(gconsumer) consumer; 106110603Sphk struct gprovider *provider; 107110603Sphk LIST_ENTRY(gconsumer) consumers; 108110603Sphk char *mode; 109110603Sphk struct gconf config; 110110603Sphk}; 111110603Sphk 112110603Sphkstruct gprovider { 113110603Sphk void *id; 114110603Sphk char *name; 115110603Sphk struct ggeom *geom; 116110603Sphk LIST_ENTRY(gprovider) provider; 117110603Sphk LIST_HEAD(, gconsumer) consumers; 118110603Sphk char *mode; 119110603Sphk off_t mediasize; 120110603Sphk u_int sectorsize; 121110603Sphk struct gconf config; 122110603Sphk}; 123110603Sphk 124110603Sphkstruct gident * geom_lookupid(struct gmesh *gmp, void *id); 125110603Sphkint geom_xml2tree(struct gmesh *gmp, char *p); 126110603Sphkint geom_gettree(struct gmesh *gmp); 127110603Sphkvoid geom_deletetree(struct gmesh *gmp); 128110603Sphk 129110545Sphk#endif /* _LIBGEOM_H_ */ 130