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