xref: /freebsd/lib/libgeom/libgeom.h (revision 7e02e189ae89bcf8f59a4069de3872f734525376)
1e13db587SPoul-Henning Kamp /*-
2e13db587SPoul-Henning Kamp  * Copyright (c) 2003 Poul-Henning Kamp
3e13db587SPoul-Henning Kamp  * All rights reserved.
4e13db587SPoul-Henning Kamp  *
5e13db587SPoul-Henning Kamp  * Redistribution and use in source and binary forms, with or without
6e13db587SPoul-Henning Kamp  * modification, are permitted provided that the following conditions
7e13db587SPoul-Henning Kamp  * are met:
8e13db587SPoul-Henning Kamp  * 1. Redistributions of source code must retain the above copyright
9e13db587SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer.
10e13db587SPoul-Henning Kamp  * 2. Redistributions in binary form must reproduce the above copyright
11e13db587SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer in the
12e13db587SPoul-Henning Kamp  *    documentation and/or other materials provided with the distribution.
13e13db587SPoul-Henning Kamp  * 3. The names of the authors may not be used to endorse or promote
14e13db587SPoul-Henning Kamp  *    products derived from this software without specific prior written
15e13db587SPoul-Henning Kamp  *    permission.
16e13db587SPoul-Henning Kamp  *
17e13db587SPoul-Henning Kamp  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18e13db587SPoul-Henning Kamp  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19e13db587SPoul-Henning Kamp  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20e13db587SPoul-Henning Kamp  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21e13db587SPoul-Henning Kamp  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22e13db587SPoul-Henning Kamp  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23e13db587SPoul-Henning Kamp  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24e13db587SPoul-Henning Kamp  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25e13db587SPoul-Henning Kamp  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26e13db587SPoul-Henning Kamp  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27e13db587SPoul-Henning Kamp  * SUCH DAMAGE.
28e13db587SPoul-Henning Kamp  *
29e13db587SPoul-Henning Kamp  * $FreeBSD$
30e13db587SPoul-Henning Kamp  */
31e13db587SPoul-Henning Kamp #ifndef _LIBGEOM_H_
32e13db587SPoul-Henning Kamp #define _LIBGEOM_H_
33e13db587SPoul-Henning Kamp 
347bd4e7b4SPoul-Henning Kamp #include <sys/queue.h>
35ba798fb2SPoul-Henning Kamp #include <sys/time.h>
36e13db587SPoul-Henning Kamp 
374b8938c1SPoul-Henning Kamp #include <geom/geom_ctl.h>
384b8938c1SPoul-Henning Kamp 
39e13db587SPoul-Henning Kamp void geom_stats_close(void);
40e13db587SPoul-Henning Kamp void geom_stats_resync(void);
41e13db587SPoul-Henning Kamp int geom_stats_open(void);
42e13db587SPoul-Henning Kamp void *geom_stats_snapshot_get(void);
43e13db587SPoul-Henning Kamp void geom_stats_snapshot_free(void *arg);
44e13db587SPoul-Henning Kamp void geom_stats_snapshot_timestamp(void *arg, struct timespec *tp);
45e13db587SPoul-Henning Kamp void geom_stats_snapshot_reset(void *arg);
462892a228SPoul-Henning Kamp struct devstat *geom_stats_snapshot_next(void *arg);
47e13db587SPoul-Henning Kamp 
487bd4e7b4SPoul-Henning Kamp char *geom_getxml(void);
497bd4e7b4SPoul-Henning Kamp 
507bd4e7b4SPoul-Henning Kamp /* geom_xml2tree.c */
517bd4e7b4SPoul-Henning Kamp 
527bd4e7b4SPoul-Henning Kamp /*
537bd4e7b4SPoul-Henning Kamp  * These structs are used to build the tree based on the XML.
547bd4e7b4SPoul-Henning Kamp  * they're named as the kernel variant without the first '_'.
557bd4e7b4SPoul-Henning Kamp  */
567bd4e7b4SPoul-Henning Kamp 
577bd4e7b4SPoul-Henning Kamp struct gclass;
587bd4e7b4SPoul-Henning Kamp struct ggeom;
597bd4e7b4SPoul-Henning Kamp struct gconsumer;
607bd4e7b4SPoul-Henning Kamp struct gprovider;
617bd4e7b4SPoul-Henning Kamp 
627bd4e7b4SPoul-Henning Kamp LIST_HEAD(gconf, gconfig);
637bd4e7b4SPoul-Henning Kamp 
647bd4e7b4SPoul-Henning Kamp struct gident {
657bd4e7b4SPoul-Henning Kamp 	void			*id;
667bd4e7b4SPoul-Henning Kamp 	void			*ptr;
677bd4e7b4SPoul-Henning Kamp 	enum {	ISCLASS,
687bd4e7b4SPoul-Henning Kamp 		ISGEOM,
697bd4e7b4SPoul-Henning Kamp 		ISPROVIDER,
707bd4e7b4SPoul-Henning Kamp 		ISCONSUMER }	what;
717bd4e7b4SPoul-Henning Kamp };
727bd4e7b4SPoul-Henning Kamp 
737bd4e7b4SPoul-Henning Kamp struct gmesh {
747bd4e7b4SPoul-Henning Kamp 	LIST_HEAD(, gclass)	class;
757bd4e7b4SPoul-Henning Kamp 	struct gident		*ident;
767bd4e7b4SPoul-Henning Kamp };
777bd4e7b4SPoul-Henning Kamp 
787bd4e7b4SPoul-Henning Kamp struct gconfig {
797bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(gconfig)	config;
807bd4e7b4SPoul-Henning Kamp 	char			*name;
817bd4e7b4SPoul-Henning Kamp 	char			*val;
827bd4e7b4SPoul-Henning Kamp };
837bd4e7b4SPoul-Henning Kamp 
847bd4e7b4SPoul-Henning Kamp struct gclass {
857bd4e7b4SPoul-Henning Kamp 	void			*id;
867bd4e7b4SPoul-Henning Kamp 	char			*name;
877bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(gclass)	class;
887bd4e7b4SPoul-Henning Kamp 	LIST_HEAD(, ggeom)	geom;
897bd4e7b4SPoul-Henning Kamp 	struct gconf		config;
907bd4e7b4SPoul-Henning Kamp };
917bd4e7b4SPoul-Henning Kamp 
927bd4e7b4SPoul-Henning Kamp struct ggeom {
937bd4e7b4SPoul-Henning Kamp 	void			*id;
947bd4e7b4SPoul-Henning Kamp 	struct gclass		*class;
957bd4e7b4SPoul-Henning Kamp 	char			*name;
967bd4e7b4SPoul-Henning Kamp 	u_int			rank;
977bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(ggeom)	geom;
987bd4e7b4SPoul-Henning Kamp 	LIST_HEAD(, gconsumer)	consumer;
997bd4e7b4SPoul-Henning Kamp 	LIST_HEAD(, gprovider)	provider;
1007bd4e7b4SPoul-Henning Kamp 	struct gconf		config;
1017bd4e7b4SPoul-Henning Kamp };
1027bd4e7b4SPoul-Henning Kamp 
1037bd4e7b4SPoul-Henning Kamp struct gconsumer {
1047bd4e7b4SPoul-Henning Kamp 	void			*id;
1057bd4e7b4SPoul-Henning Kamp 	struct ggeom		*geom;
1067bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(gconsumer)	consumer;
1077bd4e7b4SPoul-Henning Kamp 	struct gprovider	*provider;
1087bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(gconsumer)	consumers;
1097bd4e7b4SPoul-Henning Kamp 	char			*mode;
1107bd4e7b4SPoul-Henning Kamp 	struct gconf		config;
1117bd4e7b4SPoul-Henning Kamp };
1127bd4e7b4SPoul-Henning Kamp 
1137bd4e7b4SPoul-Henning Kamp struct gprovider {
1147bd4e7b4SPoul-Henning Kamp 	void			*id;
1157bd4e7b4SPoul-Henning Kamp 	char			*name;
1167bd4e7b4SPoul-Henning Kamp 	struct ggeom		*geom;
1177bd4e7b4SPoul-Henning Kamp 	LIST_ENTRY(gprovider)	provider;
1187bd4e7b4SPoul-Henning Kamp 	LIST_HEAD(, gconsumer)	consumers;
1197bd4e7b4SPoul-Henning Kamp 	char			*mode;
1207bd4e7b4SPoul-Henning Kamp 	off_t			mediasize;
1217bd4e7b4SPoul-Henning Kamp 	u_int			sectorsize;
1227bd4e7b4SPoul-Henning Kamp 	struct gconf		config;
1237bd4e7b4SPoul-Henning Kamp };
1247bd4e7b4SPoul-Henning Kamp 
1252ad2651aSPoul-Henning Kamp struct gident * geom_lookupid(struct gmesh *gmp, const void *id);
1267bd4e7b4SPoul-Henning Kamp int geom_xml2tree(struct gmesh *gmp, char *p);
1277bd4e7b4SPoul-Henning Kamp int geom_gettree(struct gmesh *gmp);
1287bd4e7b4SPoul-Henning Kamp void geom_deletetree(struct gmesh *gmp);
1297bd4e7b4SPoul-Henning Kamp 
1304b8938c1SPoul-Henning Kamp /* geom_ctl.c */
1314b8938c1SPoul-Henning Kamp 
13263728c47SPoul-Henning Kamp struct gctl_req;
1334b8938c1SPoul-Henning Kamp 
1344b8938c1SPoul-Henning Kamp #ifdef _STDIO_H_			/* limit #include pollution */
13563728c47SPoul-Henning Kamp void gctl_dump(struct gctl_req *req, FILE *f);
1364b8938c1SPoul-Henning Kamp #endif
13763728c47SPoul-Henning Kamp void gctl_free(struct gctl_req *req);
1387e02e189SPoul-Henning Kamp struct gctl_req *gctl_get_handle(void);
13963728c47SPoul-Henning Kamp const char *gctl_issue(struct gctl_req *req);
14063728c47SPoul-Henning Kamp void gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* val);
14163728c47SPoul-Henning Kamp void gctl_rw_param(struct gctl_req *req, const char *name, int len, void* val);
1424b8938c1SPoul-Henning Kamp 
143e13db587SPoul-Henning Kamp #endif /* _LIBGEOM_H_ */
144