1e13db587SPoul-Henning Kamp /*- 2e13db587SPoul-Henning Kamp * Copyright (c) 2003 Poul-Henning Kamp 3e13db587SPoul-Henning Kamp * All rights reserved. 4e13db587SPoul-Henning Kamp * 5e13db587SPoul-Henning Kamp * Redistribution and use in source and binary forms, with or without 6e13db587SPoul-Henning Kamp * modification, are permitted provided that the following conditions 7e13db587SPoul-Henning Kamp * are met: 8e13db587SPoul-Henning Kamp * 1. Redistributions of source code must retain the above copyright 9e13db587SPoul-Henning Kamp * notice, this list of conditions and the following disclaimer. 10e13db587SPoul-Henning Kamp * 2. Redistributions in binary form must reproduce the above copyright 11e13db587SPoul-Henning Kamp * notice, this list of conditions and the following disclaimer in the 12e13db587SPoul-Henning Kamp * documentation and/or other materials provided with the distribution. 13e13db587SPoul-Henning Kamp * 3. The names of the authors may not be used to endorse or promote 14e13db587SPoul-Henning Kamp * products derived from this software without specific prior written 15e13db587SPoul-Henning Kamp * permission. 16e13db587SPoul-Henning Kamp * 17e13db587SPoul-Henning Kamp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18e13db587SPoul-Henning Kamp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19e13db587SPoul-Henning Kamp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20e13db587SPoul-Henning Kamp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21e13db587SPoul-Henning Kamp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22e13db587SPoul-Henning Kamp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23e13db587SPoul-Henning Kamp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24e13db587SPoul-Henning Kamp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25e13db587SPoul-Henning Kamp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26e13db587SPoul-Henning Kamp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27e13db587SPoul-Henning Kamp * SUCH DAMAGE. 28e13db587SPoul-Henning Kamp * 29e13db587SPoul-Henning Kamp * $FreeBSD$ 30e13db587SPoul-Henning Kamp */ 31e13db587SPoul-Henning Kamp #ifndef _LIBGEOM_H_ 32e13db587SPoul-Henning Kamp #define _LIBGEOM_H_ 33e13db587SPoul-Henning Kamp 34ccac9da4SJohn Baldwin #include <sys/cdefs.h> 35ccac9da4SJohn Baldwin 367bd4e7b4SPoul-Henning Kamp #include <sys/queue.h> 37ba798fb2SPoul-Henning Kamp #include <sys/time.h> 38e13db587SPoul-Henning Kamp 394b8938c1SPoul-Henning Kamp #include <geom/geom_ctl.h> 404b8938c1SPoul-Henning Kamp 41ccac9da4SJohn Baldwin __BEGIN_DECLS 42ccac9da4SJohn Baldwin 43e13db587SPoul-Henning Kamp void geom_stats_close(void); 44e13db587SPoul-Henning Kamp void geom_stats_resync(void); 45e13db587SPoul-Henning Kamp int geom_stats_open(void); 46e13db587SPoul-Henning Kamp void *geom_stats_snapshot_get(void); 47e13db587SPoul-Henning Kamp void geom_stats_snapshot_free(void *arg); 48e13db587SPoul-Henning Kamp void geom_stats_snapshot_timestamp(void *arg, struct timespec *tp); 49e13db587SPoul-Henning Kamp void geom_stats_snapshot_reset(void *arg); 502892a228SPoul-Henning Kamp struct devstat *geom_stats_snapshot_next(void *arg); 51e13db587SPoul-Henning Kamp 527bd4e7b4SPoul-Henning Kamp char *geom_getxml(void); 537bd4e7b4SPoul-Henning Kamp 547bd4e7b4SPoul-Henning Kamp /* geom_xml2tree.c */ 557bd4e7b4SPoul-Henning Kamp 567bd4e7b4SPoul-Henning Kamp /* 577bd4e7b4SPoul-Henning Kamp * These structs are used to build the tree based on the XML. 587bd4e7b4SPoul-Henning Kamp * they're named as the kernel variant without the first '_'. 597bd4e7b4SPoul-Henning Kamp */ 607bd4e7b4SPoul-Henning Kamp 617bd4e7b4SPoul-Henning Kamp struct gclass; 627bd4e7b4SPoul-Henning Kamp struct ggeom; 637bd4e7b4SPoul-Henning Kamp struct gconsumer; 647bd4e7b4SPoul-Henning Kamp struct gprovider; 657bd4e7b4SPoul-Henning Kamp 667bd4e7b4SPoul-Henning Kamp LIST_HEAD(gconf, gconfig); 677bd4e7b4SPoul-Henning Kamp 687bd4e7b4SPoul-Henning Kamp struct gident { 69ccac9da4SJohn Baldwin void *lg_id; 70ccac9da4SJohn Baldwin void *lg_ptr; 717bd4e7b4SPoul-Henning Kamp enum { ISCLASS, 727bd4e7b4SPoul-Henning Kamp ISGEOM, 737bd4e7b4SPoul-Henning Kamp ISPROVIDER, 74ccac9da4SJohn Baldwin ISCONSUMER } lg_what; 757bd4e7b4SPoul-Henning Kamp }; 767bd4e7b4SPoul-Henning Kamp 777bd4e7b4SPoul-Henning Kamp struct gmesh { 78ccac9da4SJohn Baldwin LIST_HEAD(, gclass) lg_class; 79ccac9da4SJohn Baldwin struct gident *lg_ident; 807bd4e7b4SPoul-Henning Kamp }; 817bd4e7b4SPoul-Henning Kamp 827bd4e7b4SPoul-Henning Kamp struct gconfig { 83ccac9da4SJohn Baldwin LIST_ENTRY(gconfig) lg_config; 84ccac9da4SJohn Baldwin char *lg_name; 85ccac9da4SJohn Baldwin char *lg_val; 867bd4e7b4SPoul-Henning Kamp }; 877bd4e7b4SPoul-Henning Kamp 887bd4e7b4SPoul-Henning Kamp struct gclass { 89ccac9da4SJohn Baldwin void *lg_id; 90ccac9da4SJohn Baldwin char *lg_name; 91ccac9da4SJohn Baldwin LIST_ENTRY(gclass) lg_class; 92ccac9da4SJohn Baldwin LIST_HEAD(, ggeom) lg_geom; 93ccac9da4SJohn Baldwin struct gconf lg_config; 947bd4e7b4SPoul-Henning Kamp }; 957bd4e7b4SPoul-Henning Kamp 967bd4e7b4SPoul-Henning Kamp struct ggeom { 97ccac9da4SJohn Baldwin void *lg_id; 98ccac9da4SJohn Baldwin struct gclass *lg_class; 99ccac9da4SJohn Baldwin char *lg_name; 100ccac9da4SJohn Baldwin u_int lg_rank; 101ccac9da4SJohn Baldwin LIST_ENTRY(ggeom) lg_geom; 102ccac9da4SJohn Baldwin LIST_HEAD(, gconsumer) lg_consumer; 103ccac9da4SJohn Baldwin LIST_HEAD(, gprovider) lg_provider; 104ccac9da4SJohn Baldwin struct gconf lg_config; 1057bd4e7b4SPoul-Henning Kamp }; 1067bd4e7b4SPoul-Henning Kamp 1077bd4e7b4SPoul-Henning Kamp struct gconsumer { 108ccac9da4SJohn Baldwin void *lg_id; 109ccac9da4SJohn Baldwin struct ggeom *lg_geom; 110ccac9da4SJohn Baldwin LIST_ENTRY(gconsumer) lg_consumer; 111ccac9da4SJohn Baldwin struct gprovider *lg_provider; 112ccac9da4SJohn Baldwin LIST_ENTRY(gconsumer) lg_consumers; 113ccac9da4SJohn Baldwin char *lg_mode; 114ccac9da4SJohn Baldwin struct gconf lg_config; 1157bd4e7b4SPoul-Henning Kamp }; 1167bd4e7b4SPoul-Henning Kamp 1177bd4e7b4SPoul-Henning Kamp struct gprovider { 118ccac9da4SJohn Baldwin void *lg_id; 119ccac9da4SJohn Baldwin char *lg_name; 120ccac9da4SJohn Baldwin struct ggeom *lg_geom; 121ccac9da4SJohn Baldwin LIST_ENTRY(gprovider) lg_provider; 122ccac9da4SJohn Baldwin LIST_HEAD(, gconsumer) lg_consumers; 123ccac9da4SJohn Baldwin char *lg_mode; 124ccac9da4SJohn Baldwin off_t lg_mediasize; 125ccac9da4SJohn Baldwin u_int lg_sectorsize; 126ccac9da4SJohn Baldwin struct gconf lg_config; 1277bd4e7b4SPoul-Henning Kamp }; 1287bd4e7b4SPoul-Henning Kamp 1292ad2651aSPoul-Henning Kamp struct gident * geom_lookupid(struct gmesh *gmp, const void *id); 1307bd4e7b4SPoul-Henning Kamp int geom_xml2tree(struct gmesh *gmp, char *p); 1317bd4e7b4SPoul-Henning Kamp int geom_gettree(struct gmesh *gmp); 1327bd4e7b4SPoul-Henning Kamp void geom_deletetree(struct gmesh *gmp); 1337bd4e7b4SPoul-Henning Kamp 1344b8938c1SPoul-Henning Kamp /* geom_ctl.c */ 1354b8938c1SPoul-Henning Kamp 13663728c47SPoul-Henning Kamp struct gctl_req; 1374b8938c1SPoul-Henning Kamp 1384b8938c1SPoul-Henning Kamp #ifdef _STDIO_H_ /* limit #include pollution */ 13963728c47SPoul-Henning Kamp void gctl_dump(struct gctl_req *req, FILE *f); 1404b8938c1SPoul-Henning Kamp #endif 14163728c47SPoul-Henning Kamp void gctl_free(struct gctl_req *req); 1427e02e189SPoul-Henning Kamp struct gctl_req *gctl_get_handle(void); 14363728c47SPoul-Henning Kamp const char *gctl_issue(struct gctl_req *req); 14463728c47SPoul-Henning Kamp void gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* val); 14563728c47SPoul-Henning Kamp void gctl_rw_param(struct gctl_req *req, const char *name, int len, void* val); 1464b8938c1SPoul-Henning Kamp 147ccac9da4SJohn Baldwin __END_DECLS 148ccac9da4SJohn Baldwin 149e13db587SPoul-Henning Kamp #endif /* _LIBGEOM_H_ */ 150