~ubuntu-branches/ubuntu/breezy/lvm2/breezy

« back to all changes in this revision

Viewing changes to test/device/dev_cache_t.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Caulfield
  • Date: 2004-11-03 09:37:56 UTC
  • Revision ID: james.westby@ubuntu.com-20041103093756-jt0nj8z0v8k1lyiv
Tags: upstream-2.00.25
ImportĀ upstreamĀ versionĀ 2.00.25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
 
3
 * Copyright (C) 2004 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 General Public License v.2.
 
10
 *
 
11
 * You should have received a copy of the GNU 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
#include "dbg_malloc.h"
 
17
#include "dev-cache.h"
 
18
#include "log.h"
 
19
 
 
20
#include <stdio.h>
 
21
 
 
22
int main(int argc, char **argv)
 
23
{
 
24
        int i;
 
25
        struct device *dev;
 
26
        struct dev_iter *iter;
 
27
        struct list_head *tmp;
 
28
        struct str_list *sl;
 
29
 
 
30
        if (argc < 2) {
 
31
                fprintf(stderr, "usage: %s <dir>\n", argv[0]);
 
32
                exit(1);
 
33
        }
 
34
 
 
35
        init_log(stderr);
 
36
        init_debug(_LOG_INFO);
 
37
 
 
38
        if (!dev_cache_init()) {
 
39
                log_err("couldn't initialise dev_cache_init failed");
 
40
                exit(1);
 
41
        }
 
42
 
 
43
        for (i = 1; i < argc; i++) {
 
44
                if (!dev_cache_add_dir(argv[i])) {
 
45
                        log_err("couldn't add '%s' to dev_cache", argv[i]);
 
46
                        exit(1);
 
47
                }
 
48
        }
 
49
 
 
50
        if (!(iter = dev_iter_create(NULL))) {
 
51
                log_err("couldn't create iterator");
 
52
                exit(1);
 
53
        }
 
54
 
 
55
        while ((dev = dev_iter_get(iter))) {
 
56
                printf("%s", dev->name);
 
57
 
 
58
                list_for_each(tmp, &dev->aliases) {
 
59
                        sl = list_entry(tmp, struct str_list, list);
 
60
                        printf(", %s", sl->str);
 
61
                }
 
62
                printf("\n");
 
63
        }
 
64
 
 
65
        dev_iter_destroy(iter);
 
66
        dev_cache_exit();
 
67
 
 
68
        dump_memory();
 
69
        fin_log();
 
70
        return 0;
 
71
}