1 /*- 2 * Copyright (c) 2003 Poul-Henning Kamp 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 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. The names of the authors may not be used to endorse or promote 14 * products derived from this software without specific prior written 15 * permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 #ifndef _LIBGEOM_H_ 32 #define _LIBGEOM_H_ 33 34 #include <sys/queue.h> 35 #include <sys/time.h> 36 37 #include <geom/geom_ctl.h> 38 39 void geom_stats_close(void); 40 void geom_stats_resync(void); 41 int geom_stats_open(void); 42 void *geom_stats_snapshot_get(void); 43 void geom_stats_snapshot_free(void *arg); 44 void geom_stats_snapshot_timestamp(void *arg, struct timespec *tp); 45 void geom_stats_snapshot_reset(void *arg); 46 struct devstat *geom_stats_snapshot_next(void *arg); 47 48 char *geom_getxml(void); 49 50 /* geom_xml2tree.c */ 51 52 /* 53 * These structs are used to build the tree based on the XML. 54 * they're named as the kernel variant without the first '_'. 55 */ 56 57 struct gclass; 58 struct ggeom; 59 struct gconsumer; 60 struct gprovider; 61 62 LIST_HEAD(gconf, gconfig); 63 64 struct gident { 65 void *id; 66 void *ptr; 67 enum { ISCLASS, 68 ISGEOM, 69 ISPROVIDER, 70 ISCONSUMER } what; 71 }; 72 73 struct gmesh { 74 LIST_HEAD(, gclass) class; 75 struct gident *ident; 76 }; 77 78 struct gconfig { 79 LIST_ENTRY(gconfig) config; 80 char *name; 81 char *val; 82 }; 83 84 struct gclass { 85 void *id; 86 char *name; 87 LIST_ENTRY(gclass) class; 88 LIST_HEAD(, ggeom) geom; 89 struct gconf config; 90 }; 91 92 struct ggeom { 93 void *id; 94 struct gclass *class; 95 char *name; 96 u_int rank; 97 LIST_ENTRY(ggeom) geom; 98 LIST_HEAD(, gconsumer) consumer; 99 LIST_HEAD(, gprovider) provider; 100 struct gconf config; 101 }; 102 103 struct gconsumer { 104 void *id; 105 struct ggeom *geom; 106 LIST_ENTRY(gconsumer) consumer; 107 struct gprovider *provider; 108 LIST_ENTRY(gconsumer) consumers; 109 char *mode; 110 struct gconf config; 111 }; 112 113 struct gprovider { 114 void *id; 115 char *name; 116 struct ggeom *geom; 117 LIST_ENTRY(gprovider) provider; 118 LIST_HEAD(, gconsumer) consumers; 119 char *mode; 120 off_t mediasize; 121 u_int sectorsize; 122 struct gconf config; 123 }; 124 125 struct gident * geom_lookupid(struct gmesh *gmp, const void *id); 126 int geom_xml2tree(struct gmesh *gmp, char *p); 127 int geom_gettree(struct gmesh *gmp); 128 void geom_deletetree(struct gmesh *gmp); 129 130 /* geom_ctl.c */ 131 132 struct gctl_req; 133 134 #ifdef _STDIO_H_ /* limit #include pollution */ 135 void gctl_dump(struct gctl_req *req, FILE *f); 136 #endif 137 void gctl_free(struct gctl_req *req); 138 struct gctl_req *gctl_get_handle(enum gctl_request req); 139 const char *gctl_issue(struct gctl_req *req); 140 void gctl_ro_meta(struct gctl_req *req, off_t offset, u_int len, const void* val); 141 void gctl_rw_meta(struct gctl_req *req, off_t offset, u_int len, void* val); 142 void gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* val); 143 void gctl_rw_param(struct gctl_req *req, const char *name, int len, void* val); 144 145 #endif /* _LIBGEOM_H_ */ 146