1 /*	$NetBSD: filter-md.c,v 1.1.1.1 2008/12/22 00:17:58 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2004 Luca Berra
5  * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
6  *
7  * This file is part of LVM2.
8  *
9  * This copyrighted material is made available to anyone wishing to use,
10  * modify, copy, or redistribute it subject to the terms and conditions
11  * of the GNU Lesser General Public License v.2.1.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 
18 #include "lib.h"
19 #include "filter-md.h"
20 #include "metadata.h"
21 
22 #ifdef linux
23 
24 static int _ignore_md(struct dev_filter *f __attribute((unused)),
25 		      struct device *dev)
26 {
27 	int ret;
28 
29 	if (!md_filtering())
30 		return 1;
31 
32 	ret = dev_is_md(dev, NULL);
33 
34 	if (ret == 1) {
35 		log_debug("%s: Skipping md component device", dev_name(dev));
36 		return 0;
37 	}
38 
39 	if (ret < 0) {
40 		log_debug("%s: Skipping: error in md component detection",
41 			  dev_name(dev));
42 		return 0;
43 	}
44 
45 	return 1;
46 }
47 
48 static void _destroy(struct dev_filter *f)
49 {
50 	dm_free(f);
51 }
52 
53 struct dev_filter *md_filter_create(void)
54 {
55 	struct dev_filter *f;
56 
57 	if (!(f = dm_malloc(sizeof(*f)))) {
58 		log_error("md filter allocation failed");
59 		return NULL;
60 	}
61 
62 	f->passes_filter = _ignore_md;
63 	f->destroy = _destroy;
64 	f->private = NULL;
65 
66 	return f;
67 }
68 
69 #else
70 
71 struct dev_filter *md_filter_create(void)
72 {
73 	return NULL;
74 }
75 
76 #endif
77