2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
4 * This file is released under the GPL.
7 #include <linux/device-mapper.h>
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/bio.h>
13 #define DM_MSG_PREFIX "zero"
16 * Construct a dummy mapping that only returns zeros
18 static int zero_ctr(struct dm_target
*ti
, unsigned int argc
, char **argv
)
21 ti
->error
= "No arguments required";
26 * Silently drop discards, avoiding -EOPNOTSUPP.
28 ti
->num_discard_requests
= 1;
34 * Return zeros only on reads
36 static int zero_map(struct dm_target
*ti
, struct bio
*bio
,
37 union map_info
*map_context
)
44 /* readahead of null bytes only wastes buffer cache */
47 /* writes get silently dropped */
53 /* accepted bio, don't make new request */
54 return DM_MAPIO_SUBMITTED
;
57 static struct target_type zero_target
= {
60 .module
= THIS_MODULE
,
65 static int __init
dm_zero_init(void)
67 int r
= dm_register_target(&zero_target
);
70 DMERR("register failed %d", r
);
75 static void __exit
dm_zero_exit(void)
77 dm_unregister_target(&zero_target
);
80 module_init(dm_zero_init
)
81 module_exit(dm_zero_exit
)
83 MODULE_AUTHOR("Christophe Saout <christophe@saout.de>");
84 MODULE_DESCRIPTION(DM_NAME
" dummy target returning zeros");
85 MODULE_LICENSE("GPL");