1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
--- 18 unchanged lines hidden (view full) ---
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/geom/geom.h 115473 2003-05-31 18:13:07Z phk $
36 */
37
38#ifndef _GEOM_GEOM_H_
39#define _GEOM_GEOM_H_
40
41#include <sys/lock.h>
42#include <sys/mutex.h>
43#include <sys/sx.h>
44#include <sys/queue.h>
45#include <sys/ioccom.h>
46#include <sys/sbuf.h>
47#include <sys/module.h>
48
49struct g_class;
50struct g_geom;
51struct g_consumer;
52struct g_provider;
53struct g_stat;
54struct thread;
55struct bio;
56struct sbuf;
57struct gctl_req;
58struct g_configargs;
59
60typedef int g_config_t (struct g_configargs *ca);
61typedef int g_ctl_create_geom_t (struct gctl_req *, struct g_class *cp, struct g_provider *pp);
62typedef int g_ctl_destroy_geom_t (struct gctl_req *, struct g_class *cp, struct g_geom *gp);
63typedef int g_ctl_config_geom_t (struct gctl_req *, struct g_geom *gp, const char *verb);
64typedef void g_init_t (struct g_class *mp);
65typedef void g_fini_t (struct g_class *mp);
66typedef struct g_geom * g_taste_t (struct g_class *, struct g_provider *,
67 int flags);
68#define G_TF_NORMAL 0
69#define G_TF_INSIST 1
70#define G_TF_TRANSPARENT 2
71typedef int g_access_t (struct g_provider *, int, int, int);
72/* XXX: not sure about the thread arg */
73typedef void g_orphan_t (struct g_consumer *);
--- 9 unchanged lines hidden (view full) ---
83 * one common g_class and so on.
84 * Certain operations are instantiated on the class, most notably the
85 * taste and config_geom functions.
86 */
87struct g_class {
88 const char *name;
89 g_taste_t *taste;
90 g_config_t *config;
91 g_init_t *init;
92 g_fini_t *fini;
93 g_ctl_create_geom_t *create_geom;
94 g_ctl_destroy_geom_t *destroy_geom;
95 g_ctl_config_geom_t *config_geom;
96 /*
97 * The remaining elements are private
98 */
99 LIST_ENTRY(g_class) class;
100 LIST_HEAD(,g_geom) geom;
--- 92 unchanged lines hidden (view full) ---
193int g_waitfor_event(g_event_t *func, void *arg, int flag, ...);
194void g_cancel_event(void *ref);
195void g_orphan_provider(struct g_provider *pp, int error);
196void g_waitidle(void);
197
198/* geom_subr.c */
199int g_access_abs(struct g_consumer *cp, int nread, int nwrite, int nexcl);
200int g_access_rel(struct g_consumer *cp, int nread, int nwrite, int nexcl);
201int g_attach(struct g_consumer *cp, struct g_provider *pp);
202void g_destroy_consumer(struct g_consumer *cp);
203void g_destroy_geom(struct g_geom *pp);
204void g_destroy_provider(struct g_provider *pp);
205void g_detach(struct g_consumer *cp);
206void g_error_provider(struct g_provider *pp, int error);
207int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
208#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
--- 5 unchanged lines hidden (view full) ---
214struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...);
215void g_sanity(void *ptr);
216void g_spoil(struct g_provider *pp, struct g_consumer *cp);
217int g_std_access(struct g_provider *pp, int dr, int dw, int de);
218void g_std_done(struct bio *bp);
219void g_std_spoiled(struct g_consumer *cp);
220void g_wither_geom(struct g_geom *gp, int error);
221
222int g_modevent(module_t, int, void *);
223
224/* geom_io.c */
225struct bio * g_clone_bio(struct bio *);
226void g_destroy_bio(struct bio *);
227void g_io_deliver(struct bio *bp, int error);
228int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr);
229void g_io_request(struct bio *bp, struct g_consumer *cp);
230struct bio *g_new_bio(void);
231void * g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error);
--- 58 unchanged lines hidden (view full) ---
290 } while (0)
291
292#define g_topology_assert() \
293 do { \
294 g_sanity(NULL); \
295 sx_assert(&topology_lock, SX_XLOCKED); \
296 } while (0)
297
298#define DECLARE_GEOM_CLASS(class, name) \
299 static moduledata_t name##_mod = { \
300 #name, g_modevent, &class \
301 }; \
302 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
303
304#endif /* _KERNEL */
305
306/* geom_ctl.c */
307int gctl_set_param(struct gctl_req *req, const char *param, void *ptr, int len);
308void *gctl_get_param(struct gctl_req *req, const char *param, int *len);
309void *gctl_get_paraml(struct gctl_req *req, const char *param, int len);
310int gctl_error(struct gctl_req *req, const char *fmt, ...);
311
312#endif /* _GEOM_GEOM_H_ */
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
--- 18 unchanged lines hidden (view full) ---
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/geom/geom.h 115473 2003-05-31 18:13:07Z phk $
36 */
37
38#ifndef _GEOM_GEOM_H_
39#define _GEOM_GEOM_H_
40
41#include <sys/lock.h>
42#include <sys/mutex.h>
43#include <sys/sx.h>
44#include <sys/queue.h>
45#include <sys/ioccom.h>
46#include <sys/sbuf.h>
47#include <sys/module.h>
48
49struct g_class;
50struct g_geom;
51struct g_consumer;
52struct g_provider;
53struct g_stat;
54struct thread;
55struct bio;
56struct sbuf;
57struct gctl_req;
58struct g_configargs;
59
60typedef int g_config_t (struct g_configargs *ca);
61typedef int g_ctl_create_geom_t (struct gctl_req *, struct g_class *cp, struct g_provider *pp);
62typedef int g_ctl_destroy_geom_t (struct gctl_req *, struct g_class *cp, struct g_geom *gp);
63typedef int g_ctl_config_geom_t (struct gctl_req *, struct g_geom *gp, const char *verb);
64typedef void g_init_t (struct g_class *mp);
65typedef void g_fini_t (struct g_class *mp);
66typedef struct g_geom * g_taste_t (struct g_class *, struct g_provider *,
67 int flags);
68#define G_TF_NORMAL 0
69#define G_TF_INSIST 1
70#define G_TF_TRANSPARENT 2
71typedef int g_access_t (struct g_provider *, int, int, int);
72/* XXX: not sure about the thread arg */
73typedef void g_orphan_t (struct g_consumer *);
--- 9 unchanged lines hidden (view full) ---
83 * one common g_class and so on.
84 * Certain operations are instantiated on the class, most notably the
85 * taste and config_geom functions.
86 */
87struct g_class {
88 const char *name;
89 g_taste_t *taste;
90 g_config_t *config;
91 g_init_t *init;
92 g_fini_t *fini;
93 g_ctl_create_geom_t *create_geom;
94 g_ctl_destroy_geom_t *destroy_geom;
95 g_ctl_config_geom_t *config_geom;
96 /*
97 * The remaining elements are private
98 */
99 LIST_ENTRY(g_class) class;
100 LIST_HEAD(,g_geom) geom;
--- 92 unchanged lines hidden (view full) ---
193int g_waitfor_event(g_event_t *func, void *arg, int flag, ...);
194void g_cancel_event(void *ref);
195void g_orphan_provider(struct g_provider *pp, int error);
196void g_waitidle(void);
197
198/* geom_subr.c */
199int g_access_abs(struct g_consumer *cp, int nread, int nwrite, int nexcl);
200int g_access_rel(struct g_consumer *cp, int nread, int nwrite, int nexcl);
201int g_attach(struct g_consumer *cp, struct g_provider *pp);
202void g_destroy_consumer(struct g_consumer *cp);
203void g_destroy_geom(struct g_geom *pp);
204void g_destroy_provider(struct g_provider *pp);
205void g_detach(struct g_consumer *cp);
206void g_error_provider(struct g_provider *pp, int error);
207int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
208#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
--- 5 unchanged lines hidden (view full) ---
214struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...);
215void g_sanity(void *ptr);
216void g_spoil(struct g_provider *pp, struct g_consumer *cp);
217int g_std_access(struct g_provider *pp, int dr, int dw, int de);
218void g_std_done(struct bio *bp);
219void g_std_spoiled(struct g_consumer *cp);
220void g_wither_geom(struct g_geom *gp, int error);
221
222int g_modevent(module_t, int, void *);
223
224/* geom_io.c */
225struct bio * g_clone_bio(struct bio *);
226void g_destroy_bio(struct bio *);
227void g_io_deliver(struct bio *bp, int error);
228int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr);
229void g_io_request(struct bio *bp, struct g_consumer *cp);
230struct bio *g_new_bio(void);
231void * g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error);
--- 58 unchanged lines hidden (view full) ---
290 } while (0)
291
292#define g_topology_assert() \
293 do { \
294 g_sanity(NULL); \
295 sx_assert(&topology_lock, SX_XLOCKED); \
296 } while (0)
297
298#define DECLARE_GEOM_CLASS(class, name) \
299 static moduledata_t name##_mod = { \
300 #name, g_modevent, &class \
301 }; \
302 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
303
304#endif /* _KERNEL */
305
306/* geom_ctl.c */
307int gctl_set_param(struct gctl_req *req, const char *param, void *ptr, int len);
308void *gctl_get_param(struct gctl_req *req, const char *param, int *len);
309void *gctl_get_paraml(struct gctl_req *req, const char *param, int len);
310int gctl_error(struct gctl_req *req, const char *fmt, ...);
311
312#endif /* _GEOM_GEOM_H_ */