libgeom.h revision 126786
1110545Sphk/*-
2110545Sphk * Copyright (c) 2003 Poul-Henning Kamp
3110545Sphk * All rights reserved.
4110545Sphk *
5110545Sphk * Redistribution and use in source and binary forms, with or without
6110545Sphk * modification, are permitted provided that the following conditions
7110545Sphk * are met:
8110545Sphk * 1. Redistributions of source code must retain the above copyright
9110545Sphk *    notice, this list of conditions and the following disclaimer.
10110545Sphk * 2. Redistributions in binary form must reproduce the above copyright
11110545Sphk *    notice, this list of conditions and the following disclaimer in the
12110545Sphk *    documentation and/or other materials provided with the distribution.
13110545Sphk * 3. The names of the authors may not be used to endorse or promote
14110545Sphk *    products derived from this software without specific prior written
15110545Sphk *    permission.
16110545Sphk *
17110545Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18110545Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19110545Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20110545Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21110545Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22110545Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23110545Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24110545Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25110545Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26110545Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27110545Sphk * SUCH DAMAGE.
28110545Sphk *
29110545Sphk * $FreeBSD: head/lib/libgeom/libgeom.h 126786 2004-03-09 21:14:18Z jhb $
30110545Sphk */
31110545Sphk#ifndef _LIBGEOM_H_
32110545Sphk#define _LIBGEOM_H_
33110545Sphk
34126786Sjhb#include <sys/cdefs.h>
35126786Sjhb
36110603Sphk#include <sys/queue.h>
37110547Sphk#include <sys/time.h>
38110545Sphk
39112510Sphk#include <geom/geom_ctl.h>
40112510Sphk
41126786Sjhb__BEGIN_DECLS
42126786Sjhb
43110545Sphkvoid geom_stats_close(void);
44110545Sphkvoid geom_stats_resync(void);
45110545Sphkint geom_stats_open(void);
46110545Sphkvoid *geom_stats_snapshot_get(void);
47110545Sphkvoid geom_stats_snapshot_free(void *arg);
48110545Sphkvoid geom_stats_snapshot_timestamp(void *arg, struct timespec *tp);
49110545Sphkvoid geom_stats_snapshot_reset(void *arg);
50112372Sphkstruct devstat *geom_stats_snapshot_next(void *arg);
51110545Sphk
52110603Sphkchar *geom_getxml(void);
53110603Sphk
54110603Sphk/* geom_xml2tree.c */
55110603Sphk
56110603Sphk/*
57110603Sphk * These structs are used to build the tree based on the XML.
58110603Sphk * they're named as the kernel variant without the first '_'.
59110603Sphk */
60110603Sphk
61110603Sphkstruct gclass;
62110603Sphkstruct ggeom;
63110603Sphkstruct gconsumer;
64110603Sphkstruct gprovider;
65110603Sphk
66110603SphkLIST_HEAD(gconf, gconfig);
67110603Sphk
68110603Sphkstruct gident {
69126786Sjhb	void			*lg_id;
70126786Sjhb	void			*lg_ptr;
71110603Sphk	enum {	ISCLASS,
72110603Sphk		ISGEOM,
73110603Sphk		ISPROVIDER,
74126786Sjhb		ISCONSUMER }	lg_what;
75110603Sphk};
76110603Sphk
77110603Sphkstruct gmesh {
78126786Sjhb	LIST_HEAD(, gclass)	lg_class;
79126786Sjhb	struct gident		*lg_ident;
80110603Sphk};
81110603Sphk
82110603Sphkstruct gconfig {
83126786Sjhb	LIST_ENTRY(gconfig)	lg_config;
84126786Sjhb	char			*lg_name;
85126786Sjhb	char			*lg_val;
86110603Sphk};
87110603Sphk
88110603Sphkstruct gclass {
89126786Sjhb	void			*lg_id;
90126786Sjhb	char			*lg_name;
91126786Sjhb	LIST_ENTRY(gclass)	lg_class;
92126786Sjhb	LIST_HEAD(, ggeom)	lg_geom;
93126786Sjhb	struct gconf		lg_config;
94110603Sphk};
95110603Sphk
96110603Sphkstruct ggeom {
97126786Sjhb	void			*lg_id;
98126786Sjhb	struct gclass		*lg_class;
99126786Sjhb	char			*lg_name;
100126786Sjhb	u_int			lg_rank;
101126786Sjhb	LIST_ENTRY(ggeom)	lg_geom;
102126786Sjhb	LIST_HEAD(, gconsumer)	lg_consumer;
103126786Sjhb	LIST_HEAD(, gprovider)	lg_provider;
104126786Sjhb	struct gconf		lg_config;
105110603Sphk};
106110603Sphk
107110603Sphkstruct gconsumer {
108126786Sjhb	void			*lg_id;
109126786Sjhb	struct ggeom		*lg_geom;
110126786Sjhb	LIST_ENTRY(gconsumer)	lg_consumer;
111126786Sjhb	struct gprovider	*lg_provider;
112126786Sjhb	LIST_ENTRY(gconsumer)	lg_consumers;
113126786Sjhb	char			*lg_mode;
114126786Sjhb	struct gconf		lg_config;
115110603Sphk};
116110603Sphk
117110603Sphkstruct gprovider {
118126786Sjhb	void			*lg_id;
119126786Sjhb	char			*lg_name;
120126786Sjhb	struct ggeom		*lg_geom;
121126786Sjhb	LIST_ENTRY(gprovider)	lg_provider;
122126786Sjhb	LIST_HEAD(, gconsumer)	lg_consumers;
123126786Sjhb	char			*lg_mode;
124126786Sjhb	off_t			lg_mediasize;
125126786Sjhb	u_int			lg_sectorsize;
126126786Sjhb	struct gconf		lg_config;
127110603Sphk};
128110603Sphk
129112340Sphkstruct gident * geom_lookupid(struct gmesh *gmp, const void *id);
130110603Sphkint geom_xml2tree(struct gmesh *gmp, char *p);
131110603Sphkint geom_gettree(struct gmesh *gmp);
132110603Sphkvoid geom_deletetree(struct gmesh *gmp);
133110603Sphk
134112510Sphk/* geom_ctl.c */
135112510Sphk
136112709Sphkstruct gctl_req;
137112510Sphk
138112510Sphk#ifdef _STDIO_H_			/* limit #include pollution */
139112709Sphkvoid gctl_dump(struct gctl_req *req, FILE *f);
140112510Sphk#endif
141112709Sphkvoid gctl_free(struct gctl_req *req);
142115625Sphkstruct gctl_req *gctl_get_handle(void);
143112709Sphkconst char *gctl_issue(struct gctl_req *req);
144112709Sphkvoid gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* val);
145112709Sphkvoid gctl_rw_param(struct gctl_req *req, const char *name, int len, void* val);
146112510Sphk
147126786Sjhb__END_DECLS
148126786Sjhb
149110545Sphk#endif /* _LIBGEOM_H_ */
150