libgeom.h revision 115625
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 115625 2003-06-01 15:05:22Z phk $
30110545Sphk */
31110545Sphk#ifndef _LIBGEOM_H_
32110545Sphk#define _LIBGEOM_H_
33110545Sphk
34110603Sphk#include <sys/queue.h>
35110547Sphk#include <sys/time.h>
36110545Sphk
37112510Sphk#include <geom/geom_ctl.h>
38112510Sphk
39110545Sphkvoid geom_stats_close(void);
40110545Sphkvoid geom_stats_resync(void);
41110545Sphkint geom_stats_open(void);
42110545Sphkvoid *geom_stats_snapshot_get(void);
43110545Sphkvoid geom_stats_snapshot_free(void *arg);
44110545Sphkvoid geom_stats_snapshot_timestamp(void *arg, struct timespec *tp);
45110545Sphkvoid geom_stats_snapshot_reset(void *arg);
46112372Sphkstruct devstat *geom_stats_snapshot_next(void *arg);
47110545Sphk
48110603Sphkchar *geom_getxml(void);
49110603Sphk
50110603Sphk/* geom_xml2tree.c */
51110603Sphk
52110603Sphk/*
53110603Sphk * These structs are used to build the tree based on the XML.
54110603Sphk * they're named as the kernel variant without the first '_'.
55110603Sphk */
56110603Sphk
57110603Sphkstruct gclass;
58110603Sphkstruct ggeom;
59110603Sphkstruct gconsumer;
60110603Sphkstruct gprovider;
61110603Sphk
62110603SphkLIST_HEAD(gconf, gconfig);
63110603Sphk
64110603Sphkstruct gident {
65110603Sphk	void			*id;
66110603Sphk	void			*ptr;
67110603Sphk	enum {	ISCLASS,
68110603Sphk		ISGEOM,
69110603Sphk		ISPROVIDER,
70110603Sphk		ISCONSUMER }	what;
71110603Sphk};
72110603Sphk
73110603Sphkstruct gmesh {
74110603Sphk	LIST_HEAD(, gclass)	class;
75110603Sphk	struct gident		*ident;
76110603Sphk};
77110603Sphk
78110603Sphkstruct gconfig {
79110603Sphk	LIST_ENTRY(gconfig)	config;
80110603Sphk	char			*name;
81110603Sphk	char			*val;
82110603Sphk};
83110603Sphk
84110603Sphkstruct gclass {
85110603Sphk	void			*id;
86110603Sphk	char			*name;
87110603Sphk	LIST_ENTRY(gclass)	class;
88110603Sphk	LIST_HEAD(, ggeom)	geom;
89110603Sphk	struct gconf		config;
90110603Sphk};
91110603Sphk
92110603Sphkstruct ggeom {
93110603Sphk	void			*id;
94110603Sphk	struct gclass		*class;
95110603Sphk	char			*name;
96110603Sphk	u_int			rank;
97110603Sphk	LIST_ENTRY(ggeom)	geom;
98110603Sphk	LIST_HEAD(, gconsumer)	consumer;
99110603Sphk	LIST_HEAD(, gprovider)	provider;
100110603Sphk	struct gconf		config;
101110603Sphk};
102110603Sphk
103110603Sphkstruct gconsumer {
104110603Sphk	void			*id;
105110603Sphk	struct ggeom		*geom;
106110603Sphk	LIST_ENTRY(gconsumer)	consumer;
107110603Sphk	struct gprovider	*provider;
108110603Sphk	LIST_ENTRY(gconsumer)	consumers;
109110603Sphk	char			*mode;
110110603Sphk	struct gconf		config;
111110603Sphk};
112110603Sphk
113110603Sphkstruct gprovider {
114110603Sphk	void			*id;
115110603Sphk	char			*name;
116110603Sphk	struct ggeom		*geom;
117110603Sphk	LIST_ENTRY(gprovider)	provider;
118110603Sphk	LIST_HEAD(, gconsumer)	consumers;
119110603Sphk	char			*mode;
120110603Sphk	off_t			mediasize;
121110603Sphk	u_int			sectorsize;
122110603Sphk	struct gconf		config;
123110603Sphk};
124110603Sphk
125112340Sphkstruct gident * geom_lookupid(struct gmesh *gmp, const void *id);
126110603Sphkint geom_xml2tree(struct gmesh *gmp, char *p);
127110603Sphkint geom_gettree(struct gmesh *gmp);
128110603Sphkvoid geom_deletetree(struct gmesh *gmp);
129110603Sphk
130112510Sphk/* geom_ctl.c */
131112510Sphk
132112709Sphkstruct gctl_req;
133112510Sphk
134112510Sphk#ifdef _STDIO_H_			/* limit #include pollution */
135112709Sphkvoid gctl_dump(struct gctl_req *req, FILE *f);
136112510Sphk#endif
137112709Sphkvoid gctl_free(struct gctl_req *req);
138115625Sphkstruct gctl_req *gctl_get_handle(void);
139112709Sphkconst char *gctl_issue(struct gctl_req *req);
140112709Sphkvoid gctl_ro_param(struct gctl_req *req, const char *name, int len, const void* val);
141112709Sphkvoid gctl_rw_param(struct gctl_req *req, const char *name, int len, void* val);
142112510Sphk
143110545Sphk#endif /* _LIBGEOM_H_ */
144