Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / lvm2 / dist / lib / device / dev-cache.h
1 /*      $NetBSD: dev-cache.h,v 1.1.1.1 2008/12/22 00:17:55 haad Exp $   */
2
3 /*
4  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
5  * Copyright (C) 2004-2007 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 #ifndef _LVM_DEV_CACHE_H
19 #define _LVM_DEV_CACHE_H
20
21 #include "device.h"
22
23 /*
24  * predicate for devices.
25  */
26 struct dev_filter {
27         int (*passes_filter) (struct dev_filter * f, struct device * dev);
28         void (*destroy) (struct dev_filter * f);
29         void *private;
30 };
31
32 /*
33  * The global device cache.
34  */
35 struct cmd_context;
36 int dev_cache_init(struct cmd_context *cmd);
37 void dev_cache_exit(void);
38
39 /* Trigger(1) or avoid(0) a scan */
40 void dev_cache_scan(int do_scan);
41 int dev_cache_has_scanned(void);
42
43 int dev_cache_add_dir(const char *path);
44 int dev_cache_add_loopfile(const char *path);
45 struct device *dev_cache_get(const char *name, struct dev_filter *f);
46
47 void dev_set_preferred_name(struct str_list *sl, struct device *dev);
48
49 /*
50  * Object for iterating through the cache.
51  */
52 struct dev_iter;
53 struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan);
54 void dev_iter_destroy(struct dev_iter *iter);
55 struct device *dev_iter_get(struct dev_iter *iter);
56
57 #endif