xref: /freebsd/lib/libgeom/libgeom.h (revision f9218d3d4fd34f082473b3a021c6d4d109fb47cf)
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 #include <geom/geom_stats.h>
37 
38 void geom_stats_close(void);
39 void geom_stats_resync(void);
40 int geom_stats_open(void);
41 void *geom_stats_snapshot_get(void);
42 void geom_stats_snapshot_free(void *arg);
43 void geom_stats_snapshot_timestamp(void *arg, struct timespec *tp);
44 void geom_stats_snapshot_reset(void *arg);
45 struct g_stat *geom_stats_snapshot_next(void *arg);
46 
47 char *geom_getxml(void);
48 
49 /* geom_xml2tree.c */
50 
51 /*
52  * These structs are used to build the tree based on the XML.
53  * they're named as the kernel variant without the first '_'.
54  */
55 
56 struct gclass;
57 struct ggeom;
58 struct gconsumer;
59 struct gprovider;
60 
61 LIST_HEAD(gconf, gconfig);
62 
63 struct gident {
64 	void			*id;
65 	void			*ptr;
66 	enum {	ISCLASS,
67 		ISGEOM,
68 		ISPROVIDER,
69 		ISCONSUMER }	what;
70 };
71 
72 struct gmesh {
73 	LIST_HEAD(, gclass)	class;
74 	struct gident		*ident;
75 };
76 
77 struct gconfig {
78 	LIST_ENTRY(gconfig)	config;
79 	char			*name;
80 	char			*val;
81 };
82 
83 struct gclass {
84 	void			*id;
85 	char			*name;
86 	LIST_ENTRY(gclass)	class;
87 	LIST_HEAD(, ggeom)	geom;
88 	struct gconf		config;
89 };
90 
91 struct ggeom {
92 	void			*id;
93 	struct gclass		*class;
94 	char			*name;
95 	u_int			rank;
96 	LIST_ENTRY(ggeom)	geom;
97 	LIST_HEAD(, gconsumer)	consumer;
98 	LIST_HEAD(, gprovider)	provider;
99 	struct gconf		config;
100 };
101 
102 struct gconsumer {
103 	void			*id;
104 	struct ggeom		*geom;
105 	LIST_ENTRY(gconsumer)	consumer;
106 	struct gprovider	*provider;
107 	LIST_ENTRY(gconsumer)	consumers;
108 	char			*mode;
109 	struct gconf		config;
110 };
111 
112 struct gprovider {
113 	void			*id;
114 	char			*name;
115 	struct ggeom		*geom;
116 	LIST_ENTRY(gprovider)	provider;
117 	LIST_HEAD(, gconsumer)	consumers;
118 	char			*mode;
119 	off_t			mediasize;
120 	u_int			sectorsize;
121 	struct gconf		config;
122 };
123 
124 struct gident * geom_lookupid(struct gmesh *gmp, void *id);
125 int geom_xml2tree(struct gmesh *gmp, char *p);
126 int geom_gettree(struct gmesh *gmp);
127 void geom_deletetree(struct gmesh *gmp);
128 
129 #endif /* _LIBGEOM_H_ */
130