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); 475f145b19SDag-Erling Smørgrav void geom_stats_snapshot_free(void *); 485f145b19SDag-Erling Smørgrav void geom_stats_snapshot_timestamp(void *, struct timespec *); 495f145b19SDag-Erling Smørgrav void geom_stats_snapshot_reset(void *); 505f145b19SDag-Erling Smørgrav struct devstat *geom_stats_snapshot_next(void *); 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 1295f145b19SDag-Erling Smørgrav struct gident * geom_lookupid(struct gmesh *, const void *); 1305f145b19SDag-Erling Smørgrav int geom_xml2tree(struct gmesh *, char *); 1315f145b19SDag-Erling Smørgrav int geom_gettree(struct gmesh *); 1325f145b19SDag-Erling Smørgrav void geom_deletetree(struct gmesh *); 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 */ 1395f145b19SDag-Erling Smørgrav void gctl_dump(struct gctl_req *, FILE *); 1404b8938c1SPoul-Henning Kamp #endif 1415f145b19SDag-Erling Smørgrav void gctl_free(struct gctl_req *); 1427e02e189SPoul-Henning Kamp struct gctl_req *gctl_get_handle(void); 1435f145b19SDag-Erling Smørgrav const char *gctl_issue(struct gctl_req *); 1445f145b19SDag-Erling Smørgrav void gctl_ro_param(struct gctl_req *, const char *, int, const void *); 1455f145b19SDag-Erling Smørgrav void gctl_rw_param(struct gctl_req *, const char *, int, void *); 1464b8938c1SPoul-Henning Kamp 147fbda685dSPawel Jakub Dawidek /* geom_util.c */ 1485f145b19SDag-Erling Smørgrav int g_open(const char *, int); 1495f145b19SDag-Erling Smørgrav int g_close(int); 1505f145b19SDag-Erling Smørgrav off_t g_mediasize(int); 1515f145b19SDag-Erling Smørgrav ssize_t g_sectorsize(int); 1525f145b19SDag-Erling Smørgrav int g_flush(int); 1535f145b19SDag-Erling Smørgrav int g_delete(int, off_t, off_t); 1545f145b19SDag-Erling Smørgrav int g_get_ident(int, char *, size_t); 1555f145b19SDag-Erling Smørgrav int g_get_name(const char *, char *, size_t); 1565f145b19SDag-Erling Smørgrav int g_open_by_ident(const char *, int, char *, size_t); 157fbda685dSPawel Jakub Dawidek 158ccac9da4SJohn Baldwin __END_DECLS 159ccac9da4SJohn Baldwin 160e13db587SPoul-Henning Kamp #endif /* _LIBGEOM_H_ */ 161