diff options
author | Joe Thornber <thornber@redhat.com> | 2001-10-22 14:14:00 +0000 |
---|---|---|
committer | Joe Thornber <thornber@redhat.com> | 2001-10-22 14:14:00 +0000 |
commit | 5f16718b19a24dab41f8068b68c1b7bbf8832154 (patch) | |
tree | e884a7d9e26d148a6854e56f97f7c44679ac63b9 /old-tests/filters/pfilter_t.c | |
parent | c4151d1aa4ccb13fc0f7e9b6b773062e1affbb63 (diff) | |
download | lvm2-5f16718b19a24dab41f8068b68c1b7bbf8832154.tar.gz lvm2-5f16718b19a24dab41f8068b68c1b7bbf8832154.tar.xz lvm2-5f16718b19a24dab41f8068b68c1b7bbf8832154.zip |
o Filter which caches valid devices in a file. Pass in init == 1 to the
constructor if you want it to ignore the existing cache and check every
device again (eg, vgscan, pvscan).
Diffstat (limited to 'old-tests/filters/pfilter_t.c')
-rw-r--r-- | old-tests/filters/pfilter_t.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/old-tests/filters/pfilter_t.c b/old-tests/filters/pfilter_t.c new file mode 100644 index 00000000..d03e4f8a --- /dev/null +++ b/old-tests/filters/pfilter_t.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. + * + * This file is released under the GPL. + */ + +#include "filter-persistent.h" +#include "log.h" +#include "dbg_malloc.h" + +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> + +int main(int argc, char **argv) +{ + struct dev_filter *filter; + struct dev_iter *iter; + struct device *dev; + + if (argc > 2) { + fprintf(stderr, "Usage : %s <file>\n", argv[0]); + exit(1); + } + + init_log(stderr); + init_debug(_LOG_DEBUG); + + if (!dev_cache_init()) { + fprintf(stderr, "couldn't initialise dev_cache_init failed\n"); + exit(1); + } + + if (!dev_cache_add_dir("/dev")) { + fprintf(stderr, "couldn't add '/dev' to dev_cache\n"); + exit(1); + } + + if (!(filter = persistent_filter_create("./pfilter.cfg", 1))) { + fprintf(stderr, "couldn't build filter\n"); + exit(1); + } + + if (!(iter = dev_iter_create(filter))) { + log_err("couldn't create iterator"); + exit(1); + } + + while ((dev = dev_iter_get(iter))) + printf("%s\n", dev->name); + + dev_iter_destroy(iter); + filter->destroy(filter); + dev_cache_exit(); + + dump_memory(); + fin_log(); + return 0; +} + |