bridge(4): document net.link.bridge.pfil_onlyip
[dragonfly.git] / sys / dev / disk / dm / dm_target_error.c
blob824fdd4e280ca71e8ed38f5c8d1ab6b908edf7d2
1 /* $NetBSD: dm_target_error.c,v 1.10 2010/01/04 00:12:22 haad Exp $ */
3 /*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Hamsik.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * This file implements initial version of device-mapper error target.
35 #include <dev/disk/dm/dm.h>
37 /* Strategy routine called from dm_strategy. */
38 static int
39 dm_target_error_strategy(dm_table_entry_t *table_en, struct buf *bp)
41 bp->b_error = EIO;
42 bp->b_resid = 0;
44 biodone(&bp->b_bio1);
46 return 0;
49 static int
50 dmte_mod_handler(module_t mod, int type, void *unused)
52 dm_target_t *dmt = NULL;
53 int err = 0;
55 switch(type) {
56 case MOD_LOAD:
57 if ((dmt = dm_target_lookup("error")) != NULL) {
58 dm_target_unbusy(dmt);
59 return EEXIST;
61 dmt = dm_target_alloc("error");
62 dmt->version[0] = 1;
63 dmt->version[1] = 0;
64 dmt->version[2] = 0;
65 dmt->strategy = &dm_target_error_strategy;
67 err = dm_target_insert(dmt);
68 if (err == 0)
69 kprintf("dm_target_error: Successfully initialized\n");
70 break;
72 case MOD_UNLOAD:
73 err = dm_target_remove("error");
74 if (err == 0)
75 kprintf("dm_target_error: unloaded\n");
76 break;
79 return err;
82 DM_TARGET_BUILTIN(dm_target_error, dmte_mod_handler);