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/cdefs.h> 35 36#include <sys/queue.h> 37#include <sys/time.h> 38 39#include <geom/geom_ctl.h> 40 41__BEGIN_DECLS 42 43#ifndef DEBUG_LIBGEOM 44#define DEBUG_LIBGEOM 0 45#endif 46 47void geom_stats_close(void); 48void geom_stats_resync(void); 49int geom_stats_open(void); 50void *geom_stats_snapshot_get(void); 51void geom_stats_snapshot_free(void *); 52void geom_stats_snapshot_timestamp(void *, struct timespec *); 53void geom_stats_snapshot_reset(void *); 54struct devstat *geom_stats_snapshot_next(void *); 55 56char *geom_getxml(void); 57 58/* geom_xml2tree.c */ 59 60/* 61 * These structs are used to build the tree based on the XML. 62 * they're named as the kernel variant without the first '_'. 63 */ 64 65struct gclass; 66struct ggeom; 67struct gconsumer; 68struct gprovider; 69 70LIST_HEAD(gconf, gconfig); 71 72struct gident { 73 void *lg_id; 74 void *lg_ptr; 75 enum { ISCLASS, 76 ISGEOM, 77 ISPROVIDER, 78 ISCONSUMER } lg_what; 79}; 80 81struct gmesh { 82 LIST_HEAD(, gclass) lg_class; 83 struct gident *lg_ident; 84}; 85 86struct gconfig { 87 LIST_ENTRY(gconfig) lg_config; 88 char *lg_name; 89 char *lg_val; 90}; 91 92struct gclass { 93 void *lg_id; 94 char *lg_name; 95 LIST_ENTRY(gclass) lg_class; 96 LIST_HEAD(, ggeom) lg_geom; 97 struct gconf lg_config; 98}; 99 100struct ggeom { 101 void *lg_id; 102 struct gclass *lg_class; 103 char *lg_name; 104 u_int lg_rank; 105 LIST_ENTRY(ggeom) lg_geom; 106 LIST_HEAD(, gconsumer) lg_consumer; 107 LIST_HEAD(, gprovider) lg_provider; 108 struct gconf lg_config; 109}; 110 111struct gconsumer { 112 void *lg_id; 113 struct ggeom *lg_geom; 114 LIST_ENTRY(gconsumer) lg_consumer; 115 struct gprovider *lg_provider; 116 LIST_ENTRY(gconsumer) lg_consumers; 117 char *lg_mode; 118 struct gconf lg_config; 119}; 120 121struct gprovider { 122 void *lg_id; 123 char *lg_name; 124 struct ggeom *lg_geom; 125 LIST_ENTRY(gprovider) lg_provider; 126 LIST_HEAD(, gconsumer) lg_consumers; 127 char *lg_mode; 128 off_t lg_mediasize; 129 u_int lg_sectorsize; 130 off_t lg_stripeoffset; 131 off_t lg_stripesize; 132 struct gconf lg_config; 133}; 134 135struct gident * geom_lookupid(struct gmesh *, const void *); 136int geom_xml2tree(struct gmesh *, char *); 137int geom_gettree(struct gmesh *); 138void geom_deletetree(struct gmesh *); 139 140/* geom_ctl.c */ 141 142struct gctl_req; 143 144#ifdef _STDIO_H_ /* limit #include pollution */ 145void gctl_dump(struct gctl_req *, FILE *); 146#endif 147void gctl_free(struct gctl_req *); 148struct gctl_req *gctl_get_handle(void); 149const char *gctl_issue(struct gctl_req *); 150void gctl_ro_param(struct gctl_req *, const char *, int, const void *); 151void gctl_rw_param(struct gctl_req *, const char *, int, void *); 152 153/* geom_util.c */ 154int g_open(const char *, int); 155int g_close(int); 156off_t g_mediasize(int); 157ssize_t g_sectorsize(int); 158off_t g_stripeoffset(int); 159off_t g_stripesize(int); 160int g_flush(int); 161int g_delete(int, off_t, off_t); 162int g_get_ident(int, char *, size_t); 163int g_get_name(const char *, char *, size_t); 164int g_open_by_ident(const char *, int, char *, size_t); 165char *g_device_path(const char *); 166char *g_providername(int); 167 168__END_DECLS 169 170#endif /* _LIBGEOM_H_ */ 171