4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
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.
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
21 #include "lvm-types.h"
40 struct config_value
*next
; /* for arrays */
45 struct config_node
*parent
, *sib
, *child
;
46 struct config_value
*v
;
50 struct config_node
*root
;
53 struct config_tree_list
{
55 struct config_tree
*cft
;
58 struct config_tree
*create_config_tree(const char *filename
, int keep_open
);
59 struct config_tree
*create_config_tree_from_string(struct cmd_context
*cmd
,
60 const char *config_settings
);
61 int override_config_tree_from_string(struct cmd_context
*cmd
,
62 const char *config_settings
);
63 void destroy_config_tree(struct config_tree
*cft
);
65 typedef uint32_t (*checksum_fn_t
) (uint32_t initial
, const void *buf
, uint32_t size
);
67 int read_config_fd(struct config_tree
*cft
, struct device
*dev
,
68 off_t offset
, size_t size
, off_t offset2
, size_t size2
,
69 checksum_fn_t checksum_fn
, uint32_t checksum
);
71 int read_config_file(struct config_tree
*cft
);
72 int write_config_file(struct config_tree
*cft
, const char *file
,
73 int argc
, char **argv
);
75 typedef int (*putline_fn
)(const char *line
, void *baton
);
76 int write_config_node(const struct config_node
*cn
, putline_fn putline
, void *baton
);
78 time_t config_file_timestamp(struct config_tree
*cft
);
79 int config_file_changed(struct config_tree
*cft
);
80 int merge_config_tree(struct cmd_context
*cmd
, struct config_tree
*cft
,
81 struct config_tree
*newdata
);
83 struct config_node
*find_config_node(const struct config_node
*cn
,
85 const char *find_config_str(const struct config_node
*cn
, const char *path
,
87 int find_config_int(const struct config_node
*cn
, const char *path
, int fail
);
88 float find_config_float(const struct config_node
*cn
, const char *path
,
92 * These versions check an override tree, if present, first.
94 struct config_node
*find_config_tree_node(struct cmd_context
*cmd
,
96 const char *find_config_tree_str(struct cmd_context
*cmd
,
97 const char *path
, const char *fail
);
98 int find_config_tree_int(struct cmd_context
*cmd
, const char *path
,
100 float find_config_tree_float(struct cmd_context
*cmd
, const char *path
,
104 * Understands (0, ~0), (y, n), (yes, no), (on,
105 * off), (true, false).
107 int find_config_bool(const struct config_node
*cn
, const char *path
, int fail
);
108 int find_config_tree_bool(struct cmd_context
*cmd
, const char *path
, int fail
);
110 int get_config_uint32(const struct config_node
*cn
, const char *path
,
113 int get_config_uint64(const struct config_node
*cn
, const char *path
,
116 int get_config_str(const struct config_node
*cn
, const char *path
,
119 unsigned maybe_config_section(const char *str
, unsigned len
);
121 const char *config_parent_name(const struct config_node
*n
);
123 struct config_node
*clone_config_node(struct dm_pool
*mem
, const struct config_node
*cn
,