dm_target_zero.c revision 1.1.2.6 1 1.1.2.6 haad /* $NetBSD: dm_target_zero.c,v 1.1.2.6 2008/08/19 13:30:36 haad Exp $ */
2 1.1.2.6 haad
3 1.1.2.1 haad /*
4 1.1.2.1 haad * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
5 1.1.2.1 haad * All rights reserved.
6 1.1.2.1 haad *
7 1.1.2.1 haad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.1 haad * by Adam Hamsik.
9 1.1.2.1 haad *
10 1.1.2.1 haad * Redistribution and use in source and binary forms, with or without
11 1.1.2.1 haad * modification, are permitted provided that the following conditions
12 1.1.2.1 haad * are met:
13 1.1.2.1 haad * 1. Redistributions of source code must retain the above copyright
14 1.1.2.1 haad * notice, this list of conditions and the following disclaimer.
15 1.1.2.1 haad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.1 haad * notice, this list of conditions and the following disclaimer in the
17 1.1.2.1 haad * documentation and/or other materials provided with the distribution.
18 1.1.2.1 haad *
19 1.1.2.1 haad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.1 haad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.1 haad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.1 haad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.1 haad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.1 haad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.1 haad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.1 haad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.1 haad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.1 haad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.1 haad * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.1 haad */
31 1.1.2.1 haad
32 1.1.2.1 haad
33 1.1.2.1 haad /*
34 1.1.2.1 haad * This file implements initial version of device-mapper zero target.
35 1.1.2.1 haad */
36 1.1.2.1 haad #include <sys/types.h>
37 1.1.2.1 haad #include <sys/param.h>
38 1.1.2.1 haad
39 1.1.2.1 haad #include <sys/buf.h>
40 1.1.2.1 haad #include <sys/errno.h>
41 1.1.2.1 haad #include <sys/ioctl.h>
42 1.1.2.1 haad #include <sys/ioccom.h>
43 1.1.2.1 haad #include <sys/kmem.h>
44 1.1.2.1 haad #include <sys/types.h>
45 1.1.2.1 haad #include <sys/param.h>
46 1.1.2.1 haad #include <sys/queue.h>
47 1.1.2.1 haad
48 1.1.2.1 haad #include "dm.h"
49 1.1.2.1 haad
50 1.1.2.1 haad /*
51 1.1.2.1 haad * Zero target init function. This target doesn't need
52 1.1.2.1 haad * target specific config area.
53 1.1.2.1 haad */
54 1.1.2.1 haad int
55 1.1.2.4 haad dm_target_zero_init(struct dm_dev *dmv, void **target_config, char *argv)
56 1.1.2.1 haad {
57 1.1.2.1 haad
58 1.1.2.1 haad printf("Zero target init function called!!\n");
59 1.1.2.1 haad
60 1.1.2.3 haad dmv->dev_type = DM_ZERO_DEV;
61 1.1.2.3 haad
62 1.1.2.1 haad *target_config = NULL;
63 1.1.2.1 haad
64 1.1.2.1 haad return 0;
65 1.1.2.1 haad }
66 1.1.2.1 haad
67 1.1.2.5 haad /* Status routine called to get params string. */
68 1.1.2.5 haad char *
69 1.1.2.5 haad dm_target_zero_status(void *target_config)
70 1.1.2.5 haad {
71 1.1.2.5 haad return NULL;
72 1.1.2.5 haad }
73 1.1.2.5 haad
74 1.1.2.5 haad
75 1.1.2.1 haad /*
76 1.1.2.1 haad * This routine does IO operations.
77 1.1.2.1 haad */
78 1.1.2.1 haad int
79 1.1.2.1 haad dm_target_zero_strategy(struct dm_table_entry *table_en, struct buf *bp)
80 1.1.2.1 haad {
81 1.1.2.1 haad
82 1.1.2.2 haad printf("Zero target read function called %d!!\n", bp->b_bcount);
83 1.1.2.1 haad
84 1.1.2.1 haad memset(bp->b_data, 0, bp->b_bcount);
85 1.1.2.1 haad bp->b_resid = 0; /* nestiobuf_done wants b_resid = 0 to be sure
86 1.1.2.1 haad that there is no other io to done */
87 1.1.2.1 haad
88 1.1.2.1 haad biodone(bp);
89 1.1.2.1 haad
90 1.1.2.1 haad return 0;
91 1.1.2.1 haad }
92 1.1.2.1 haad
93 1.1.2.1 haad /* Doesn't not need to do anything here. */
94 1.1.2.1 haad int
95 1.1.2.1 haad dm_target_zero_destroy(struct dm_table_entry *table_en)
96 1.1.2.1 haad {
97 1.1.2.5 haad table_en->target_config = NULL;
98 1.1.2.5 haad
99 1.1.2.1 haad return 0;
100 1.1.2.1 haad }
101 1.1.2.1 haad
102 1.1.2.1 haad /* Unsuported for this target. */
103 1.1.2.1 haad int
104 1.1.2.1 haad dm_target_zero_upcall(struct dm_table_entry *table_en, struct buf *bp)
105 1.1.2.1 haad {
106 1.1.2.1 haad return 0;
107 1.1.2.1 haad }
108 1.1.2.1 haad
109