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