geom.h (115468) | geom.h (115473) |
---|---|
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 * | 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 115468 2003-05-31 16:59:27Z phk $ | 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> | 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> |
|
47 48struct g_class; 49struct g_geom; 50struct g_consumer; 51struct g_provider; 52struct g_stat; 53struct thread; 54struct bio; 55struct sbuf; 56struct gctl_req; 57struct g_configargs; 58 59typedef int g_config_t (struct g_configargs *ca); 60typedef int g_ctl_create_geom_t (struct gctl_req *, struct g_class *cp, struct g_provider *pp); 61typedef int g_ctl_destroy_geom_t (struct gctl_req *, struct g_class *cp, struct g_geom *gp); 62typedef int g_ctl_config_geom_t (struct gctl_req *, struct g_geom *gp, const char *verb); | 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); |
|
63typedef struct g_geom * g_taste_t (struct g_class *, struct g_provider *, 64 int flags); 65#define G_TF_NORMAL 0 66#define G_TF_INSIST 1 67#define G_TF_TRANSPARENT 2 68typedef int g_access_t (struct g_provider *, int, int, int); 69/* XXX: not sure about the thread arg */ 70typedef void g_orphan_t (struct g_consumer *); --- 9 unchanged lines hidden (view full) --- 80 * one common g_class and so on. 81 * Certain operations are instantiated on the class, most notably the 82 * taste and config_geom functions. 83 */ 84struct g_class { 85 const char *name; 86 g_taste_t *taste; 87 g_config_t *config; | 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; |
|
88 g_ctl_create_geom_t *create_geom; 89 g_ctl_destroy_geom_t *destroy_geom; 90 g_ctl_config_geom_t *config_geom; 91 /* 92 * The remaining elements are private 93 */ 94 LIST_ENTRY(g_class) class; 95 LIST_HEAD(,g_geom) geom; --- 92 unchanged lines hidden (view full) --- 188int g_waitfor_event(g_event_t *func, void *arg, int flag, ...); 189void g_cancel_event(void *ref); 190void g_orphan_provider(struct g_provider *pp, int error); 191void g_waitidle(void); 192 193/* geom_subr.c */ 194int g_access_abs(struct g_consumer *cp, int nread, int nwrite, int nexcl); 195int g_access_rel(struct g_consumer *cp, int nread, int nwrite, int nexcl); | 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); |
196void g_add_class(struct g_class *mp); | |
197int g_attach(struct g_consumer *cp, struct g_provider *pp); 198void g_destroy_consumer(struct g_consumer *cp); 199void g_destroy_geom(struct g_geom *pp); 200void g_destroy_provider(struct g_provider *pp); 201void g_detach(struct g_consumer *cp); 202void g_error_provider(struct g_provider *pp, int error); 203int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); 204#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) --- 5 unchanged lines hidden (view full) --- 210struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); 211void g_sanity(void *ptr); 212void g_spoil(struct g_provider *pp, struct g_consumer *cp); 213int g_std_access(struct g_provider *pp, int dr, int dw, int de); 214void g_std_done(struct bio *bp); 215void g_std_spoiled(struct g_consumer *cp); 216void g_wither_geom(struct g_geom *gp, int error); 217 | 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 |
|
218/* geom_io.c */ 219struct bio * g_clone_bio(struct bio *); 220void g_destroy_bio(struct bio *); 221void g_io_deliver(struct bio *bp, int error); 222int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr); 223void g_io_request(struct bio *bp, struct g_consumer *cp); 224struct bio *g_new_bio(void); 225void * g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error); --- 58 unchanged lines hidden (view full) --- 284 } while (0) 285 286#define g_topology_assert() \ 287 do { \ 288 g_sanity(NULL); \ 289 sx_assert(&topology_lock, SX_XLOCKED); \ 290 } while (0) 291 | 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 |
292#define DECLARE_GEOM_CLASS_INIT(class, name, init) \ 293 SYSINIT(name, SI_SUB_DRIVERS, SI_ORDER_FIRST, init, NULL); | 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); |
294 | 303 |
295#define DECLARE_GEOM_CLASS(class, name) \ 296 static void \ 297 name##init(void) \ 298 { \ 299 mtx_unlock(&Giant); \ 300 g_add_class(&class); \ 301 mtx_lock(&Giant); \ 302 } \ 303 DECLARE_GEOM_CLASS_INIT(class, name, name##init); 304 | |
305#endif /* _KERNEL */ 306 307/* geom_ctl.c */ 308int gctl_set_param(struct gctl_req *req, const char *param, void *ptr, int len); 309void *gctl_get_param(struct gctl_req *req, const char *param, int *len); 310void *gctl_get_paraml(struct gctl_req *req, const char *param, int len); 311int gctl_error(struct gctl_req *req, const char *fmt, ...); 312 313#endif /* _GEOM_GEOM_H_ */ | 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_ */ |