libgeom.h revision 330897
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2003 Poul-Henning Kamp 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The names of the authors may not be used to endorse or promote 16 * products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $FreeBSD: stable/11/lib/libgeom/libgeom.h 330897 2018-03-14 03:19:51Z eadler $ 32 */ 33#ifndef _LIBGEOM_H_ 34#define _LIBGEOM_H_ 35 36#include <sys/cdefs.h> 37 38#include <sys/queue.h> 39#include <sys/time.h> 40 41#include <geom/geom_ctl.h> 42 43__BEGIN_DECLS 44 45#ifndef DEBUG_LIBGEOM 46#define DEBUG_LIBGEOM 0 47#endif 48 49void geom_stats_close(void); 50void geom_stats_resync(void); 51int geom_stats_open(void); 52void *geom_stats_snapshot_get(void); 53void geom_stats_snapshot_free(void *); 54void geom_stats_snapshot_timestamp(void *, struct timespec *); 55void geom_stats_snapshot_reset(void *); 56struct devstat *geom_stats_snapshot_next(void *); 57 58char *geom_getxml(void); 59 60/* geom_xml2tree.c */ 61 62/* 63 * These structs are used to build the tree based on the XML. 64 * they're named as the kernel variant without the first '_'. 65 */ 66 67struct gclass; 68struct ggeom; 69struct gconsumer; 70struct gprovider; 71 72LIST_HEAD(gconf, gconfig); 73 74struct gident { 75 void *lg_id; 76 void *lg_ptr; 77 enum { ISCLASS, 78 ISGEOM, 79 ISPROVIDER, 80 ISCONSUMER } lg_what; 81}; 82 83struct gmesh { 84 LIST_HEAD(, gclass) lg_class; 85 struct gident *lg_ident; 86}; 87 88struct gconfig { 89 LIST_ENTRY(gconfig) lg_config; 90 char *lg_name; 91 char *lg_val; 92}; 93 94struct gclass { 95 void *lg_id; 96 char *lg_name; 97 LIST_ENTRY(gclass) lg_class; 98 LIST_HEAD(, ggeom) lg_geom; 99 struct gconf lg_config; 100}; 101 102struct ggeom { 103 void *lg_id; 104 struct gclass *lg_class; 105 char *lg_name; 106 u_int lg_rank; 107 LIST_ENTRY(ggeom) lg_geom; 108 LIST_HEAD(, gconsumer) lg_consumer; 109 LIST_HEAD(, gprovider) lg_provider; 110 struct gconf lg_config; 111}; 112 113struct gconsumer { 114 void *lg_id; 115 struct ggeom *lg_geom; 116 LIST_ENTRY(gconsumer) lg_consumer; 117 struct gprovider *lg_provider; 118 LIST_ENTRY(gconsumer) lg_consumers; 119 char *lg_mode; 120 struct gconf lg_config; 121}; 122 123struct gprovider { 124 void *lg_id; 125 char *lg_name; 126 struct ggeom *lg_geom; 127 LIST_ENTRY(gprovider) lg_provider; 128 LIST_HEAD(, gconsumer) lg_consumers; 129 char *lg_mode; 130 off_t lg_mediasize; 131 u_int lg_sectorsize; 132 off_t lg_stripeoffset; 133 off_t lg_stripesize; 134 struct gconf lg_config; 135}; 136 137struct gident * geom_lookupid(struct gmesh *, const void *); 138int geom_xml2tree(struct gmesh *, char *); 139int geom_gettree(struct gmesh *); 140void geom_deletetree(struct gmesh *); 141 142/* geom_ctl.c */ 143 144struct gctl_req; 145 146#ifdef _STDIO_H_ /* limit #include pollution */ 147void gctl_dump(struct gctl_req *, FILE *); 148#endif 149void gctl_free(struct gctl_req *); 150struct gctl_req *gctl_get_handle(void); 151const char *gctl_issue(struct gctl_req *); 152void gctl_ro_param(struct gctl_req *, const char *, int, const void *); 153void gctl_rw_param(struct gctl_req *, const char *, int, void *); 154 155/* geom_util.c */ 156int g_open(const char *, int); 157int g_close(int); 158off_t g_mediasize(int); 159ssize_t g_sectorsize(int); 160off_t g_stripeoffset(int); 161off_t g_stripesize(int); 162int g_flush(int); 163int g_delete(int, off_t, off_t); 164int g_get_ident(int, char *, size_t); 165int g_get_name(const char *, char *, size_t); 166int g_open_by_ident(const char *, int, char *, size_t); 167char *g_device_path(const char *); 168char *g_providername(int); 169 170__END_DECLS 171 172#endif /* _LIBGEOM_H_ */ 173