Tizen 2.1 base
[external/device-mapper.git] / lib / device / dev-cache.h
1 /*
2  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4  *
5  * This file is part of LVM2.
6  *
7  * This copyrighted material is made available to anyone wishing to use,
8  * modify, copy, or redistribute it subject to the terms and conditions
9  * of the GNU Lesser General Public License v.2.1.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  */
15
16 #ifndef _LVM_DEV_CACHE_H
17 #define _LVM_DEV_CACHE_H
18
19 #include "device.h"
20
21 /*
22  * predicate for devices.
23  */
24 struct dev_filter {
25         int (*passes_filter) (struct dev_filter * f, struct device * dev);
26         void (*destroy) (struct dev_filter * f);
27         unsigned use_count;
28         void *private;
29 };
30
31 /*
32  * The global device cache.
33  */
34 struct cmd_context;
35 int dev_cache_init(struct cmd_context *cmd);
36 void dev_cache_exit(void);
37
38 /* Trigger(1) or avoid(0) a scan */
39 void dev_cache_scan(int do_scan);
40 int dev_cache_has_scanned(void);
41
42 int dev_cache_add_dir(const char *path);
43 int dev_cache_add_loopfile(const char *path);
44 struct device *dev_cache_get(const char *name, struct dev_filter *f);
45
46 void dev_set_preferred_name(struct str_list *sl, struct device *dev);
47
48 /*
49  * Object for iterating through the cache.
50  */
51 struct dev_iter;
52 struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan);
53 void dev_iter_destroy(struct dev_iter *iter);
54 struct device *dev_iter_get(struct dev_iter *iter);
55
56 void dev_reset_error_count(struct cmd_context *cmd);
57
58 #endif