mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-07 05:58:00 +03:00
Move the core of the lib/config/config.c functionality into libdevmapper,
leaving behind the LVM-specific parts of the code (convenience wrappers that handle `struct device` and `struct cmd_context`, basically). A number of functions have been renamed (in addition to getting a dm_ prefix) -- namely, all of the config interface now has a dm_config_ prefix.
This commit is contained in:
parent
d35188058b
commit
e59e2f7c3c
@ -273,8 +273,8 @@ int activation(void)
|
||||
static int _passes_activation_filter(struct cmd_context *cmd,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
const char *str;
|
||||
char path[PATH_MAX];
|
||||
|
||||
@ -304,7 +304,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
|
||||
lv->vg->name, lv->name);
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Ignoring invalid string in config file "
|
||||
"activation/volume_list");
|
||||
continue;
|
||||
|
@ -269,7 +269,7 @@ int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
|
||||
char *dlid, *name;
|
||||
int r;
|
||||
|
||||
if (!(name = build_dm_name(mem, lv->vg->name, lv->name, layer))) {
|
||||
if (!(name = dm_build_dm_name(mem, lv->vg->name, lv->name, layer))) {
|
||||
log_error("name build failed for %s", lv->name);
|
||||
return 0;
|
||||
}
|
||||
@ -723,7 +723,7 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
/*
|
||||
* Build a name for the top layer.
|
||||
*/
|
||||
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, NULL)))
|
||||
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, NULL)))
|
||||
return_0;
|
||||
|
||||
if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, NULL)))
|
||||
@ -757,7 +757,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
/*
|
||||
* Build a name for the top layer.
|
||||
*/
|
||||
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
return_0;
|
||||
|
||||
/* FIXME dm_pool_free ? */
|
||||
@ -800,7 +800,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
/* Rename? */
|
||||
if ((suffix = strrchr(dl->dlid + sizeof(UUID_PREFIX) - 1, '-')))
|
||||
suffix++;
|
||||
new_name = build_dm_name(dm->mem, dm->vg_name, dl->lv->name,
|
||||
new_name = dm_build_dm_name(dm->mem, dm->vg_name, dl->lv->name,
|
||||
suffix);
|
||||
|
||||
static int _belong_to_vg(const char *vgname, const char *name)
|
||||
@ -843,7 +843,7 @@ static int _dev_manager_lv_mknodes(const struct logical_volume *lv)
|
||||
{
|
||||
char *name;
|
||||
|
||||
if (!(name = build_dm_name(lv->vg->cmd->mem, lv->vg->name,
|
||||
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name,
|
||||
lv->name, NULL)))
|
||||
return_0;
|
||||
|
||||
@ -861,7 +861,7 @@ int dev_manager_mknodes(const struct logical_volume *lv)
|
||||
char *name;
|
||||
int r = 0;
|
||||
|
||||
if (!(name = build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
|
||||
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
|
||||
return_0;
|
||||
|
||||
if ((r = _info_run(name, NULL, &dminfo, NULL, 1, 0, 0, 0, 0))) {
|
||||
@ -933,7 +933,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
char *dlid, *name;
|
||||
struct dm_info info, info2;
|
||||
|
||||
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
return_0;
|
||||
|
||||
if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer)))
|
||||
@ -1163,7 +1163,7 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
if (!(id = build_dm_uuid(dm->mem, seg->lv->lvid.s, errid)))
|
||||
return_NULL;
|
||||
|
||||
if (!(name = build_dm_name(dm->mem, seg->lv->vg->name,
|
||||
if (!(name = dm_build_dm_name(dm->mem, seg->lv->vg->name,
|
||||
seg->lv->name, errid)))
|
||||
return_NULL;
|
||||
if (!(node = dm_tree_add_new_dev(dtree, name, id, 0, 0, 0, 0, 0)))
|
||||
@ -1558,7 +1558,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
}
|
||||
}
|
||||
|
||||
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
|
||||
return_0;
|
||||
|
||||
if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer)))
|
||||
|
2
lib/cache/lvmcache.c
vendored
2
lib/cache/lvmcache.c
vendored
@ -677,7 +677,7 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
|
||||
/* Build config tree from vgmetadata, if not yet cached */
|
||||
if (!vginfo->cft &&
|
||||
!(vginfo->cft =
|
||||
create_config_tree_from_string(vginfo->vgmetadata)))
|
||||
dm_config_from_string(vginfo->vgmetadata)))
|
||||
goto_bad;
|
||||
|
||||
if (!(vg = import_vg_from_config_tree(vginfo->cft, fid)))
|
||||
|
6
lib/cache/lvmcache.h
vendored
6
lib/cache/lvmcache.h
vendored
@ -33,7 +33,7 @@
|
||||
struct cmd_context;
|
||||
struct format_type;
|
||||
struct volume_group;
|
||||
struct config_tree;
|
||||
struct dm_config_tree;
|
||||
|
||||
/* One per VG */
|
||||
struct lvmcache_vginfo {
|
||||
@ -48,8 +48,8 @@ struct lvmcache_vginfo {
|
||||
char *creation_host;
|
||||
size_t vgmetadata_size;
|
||||
char *vgmetadata; /* Copy of VG metadata as format_text string */
|
||||
struct config_tree *cft; /* Config tree created from vgmetadata */
|
||||
/* Lifetime is directly tied to vgmetadata */
|
||||
struct dm_config_tree *cft; /* Config tree created from vgmetadata */
|
||||
/* Lifetime is directly tied to vgmetadata */
|
||||
struct volume_group *cached_vg;
|
||||
unsigned holders;
|
||||
unsigned vg_use_count; /* Counter of vg reusage */
|
||||
|
@ -222,8 +222,8 @@ static int _process_config(struct cmd_context *cmd)
|
||||
mode_t old_umask;
|
||||
const char *read_ahead;
|
||||
struct stat st;
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
int64_t pv_min_kb;
|
||||
|
||||
/* umask */
|
||||
@ -358,7 +358,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
|
||||
if ((cn = find_config_tree_node(cmd, "activation/mlock_filter")))
|
||||
for (cv = cn->v; cv; cv = cv->next)
|
||||
if ((cv->type != CFG_STRING) || !cv->v.str[0])
|
||||
if ((cv->type != DM_CFG_STRING) || !cv->v.str[0])
|
||||
log_error("Ignoring invalid activation/mlock_filter entry in config file");
|
||||
|
||||
cmd->metadata_read_only = find_config_tree_int(cmd, "global/metadata_read_only",
|
||||
@ -392,11 +392,11 @@ static int _set_tag(struct cmd_context *cmd, const char *tag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _check_host_filters(struct cmd_context *cmd, const struct config_node *hn,
|
||||
static int _check_host_filters(struct cmd_context *cmd, const struct dm_config_node *hn,
|
||||
int *passes)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
|
||||
*passes = 1;
|
||||
|
||||
@ -405,10 +405,10 @@ static int _check_host_filters(struct cmd_context *cmd, const struct config_node
|
||||
continue;
|
||||
if (!strcmp(cn->key, "host_list")) {
|
||||
*passes = 0;
|
||||
if (cn->v->type == CFG_EMPTY_ARRAY)
|
||||
if (cn->v->type == DM_CFG_EMPTY_ARRAY)
|
||||
continue;
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid hostname string "
|
||||
"for tag %s", cn->key);
|
||||
return 0;
|
||||
@ -428,17 +428,17 @@ static int _check_host_filters(struct cmd_context *cmd, const struct config_node
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _init_tags(struct cmd_context *cmd, struct config_tree *cft)
|
||||
static int _init_tags(struct cmd_context *cmd, struct dm_config_tree *cft)
|
||||
{
|
||||
const struct config_node *tn, *cn;
|
||||
const struct dm_config_node *tn, *cn;
|
||||
const char *tag;
|
||||
int passes;
|
||||
|
||||
if (!(tn = find_config_node(cft->root, "tags")) || !tn->child)
|
||||
if (!(tn = dm_config_find_node(cft->root, "tags")) || !tn->child)
|
||||
return 1;
|
||||
|
||||
/* NB hosttags 0 when already 1 intentionally does not delete the tag */
|
||||
if (!cmd->hosttags && find_config_int(cft->root, "tags/hosttags",
|
||||
if (!cmd->hosttags && dm_config_find_int(cft->root, "tags/hosttags",
|
||||
DEFAULT_HOSTTAGS)) {
|
||||
/* FIXME Strip out invalid chars: only A-Za-z0-9_+.- */
|
||||
if (!_set_tag(cmd, cmd->hostname))
|
||||
@ -491,7 +491,7 @@ static int _load_config_file(struct cmd_context *cmd, const char *tag)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cfl->cft = create_config_tree(config_file, 0))) {
|
||||
if (!(cfl->cft = dm_config_create(config_file, 0))) {
|
||||
log_error("config_tree allocation failed");
|
||||
return 0;
|
||||
}
|
||||
@ -531,7 +531,7 @@ static int _init_lvm_conf(struct cmd_context *cmd)
|
||||
{
|
||||
/* No config file if LVM_SYSTEM_DIR is empty */
|
||||
if (!*cmd->system_dir) {
|
||||
if (!(cmd->cft = create_config_tree(NULL, 0))) {
|
||||
if (!(cmd->cft = dm_config_create(NULL, 0))) {
|
||||
log_error("Failed to create config tree");
|
||||
return 0;
|
||||
}
|
||||
@ -564,7 +564,7 @@ static int _merge_config_files(struct cmd_context *cmd)
|
||||
|
||||
/* Replace temporary duplicate copy of lvm.conf */
|
||||
if (cmd->cft->root) {
|
||||
if (!(cmd->cft = create_config_tree(NULL, 0))) {
|
||||
if (!(cmd->cft = dm_config_create(NULL, 0))) {
|
||||
log_error("Failed to create config tree");
|
||||
return 0;
|
||||
}
|
||||
@ -593,7 +593,7 @@ int config_files_changed(struct cmd_context *cmd)
|
||||
struct config_tree_list *cfl;
|
||||
|
||||
dm_list_iterate_items(cfl, &cmd->config_files) {
|
||||
if (config_file_changed(cfl->cft))
|
||||
if (dm_config_changed(cfl->cft))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -620,8 +620,8 @@ static void _destroy_tag_configs(struct cmd_context *cmd)
|
||||
|
||||
static int _init_dev_cache(struct cmd_context *cmd)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
size_t uninitialized_var(udev_dir_len), len;
|
||||
int device_list_from_udev;
|
||||
const char *uninitialized_var(udev_dir);
|
||||
@ -653,7 +653,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
}
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
"devices/scan");
|
||||
return 0;
|
||||
@ -680,7 +680,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
return 1;
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
"devices/loopfiles");
|
||||
return 0;
|
||||
@ -702,7 +702,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
{
|
||||
unsigned nr_filt = 0;
|
||||
const struct config_node *cn;
|
||||
const struct dm_config_node *cn;
|
||||
struct dev_filter *filters[MAX_FILTERS];
|
||||
|
||||
memset(filters, 0, sizeof(filters));
|
||||
@ -823,7 +823,7 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
|
||||
*/
|
||||
if (load_persistent_cache && !cmd->is_long_lived &&
|
||||
!stat(dev_cache, &st) &&
|
||||
(st.st_ctime > config_file_timestamp(cmd->cft)) &&
|
||||
(st.st_ctime > dm_config_timestamp(cmd->cft)) &&
|
||||
!persistent_filter_load(f4, NULL))
|
||||
log_verbose("Failed to load existing device cache from %s",
|
||||
dev_cache);
|
||||
@ -853,7 +853,7 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
struct format_type *fmt;
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
const struct config_node *cn;
|
||||
const struct dm_config_node *cn;
|
||||
#endif
|
||||
|
||||
label_init();
|
||||
@ -877,12 +877,12 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
if (!is_static() &&
|
||||
(cn = find_config_tree_node(cmd, "global/format_libraries"))) {
|
||||
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_value *cv;
|
||||
struct format_type *(*init_format_fn) (struct cmd_context *);
|
||||
void *lib;
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
"global/format_libraries");
|
||||
return 0;
|
||||
@ -1010,7 +1010,7 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
const struct config_node *cn;
|
||||
const struct dm_config_node *cn;
|
||||
#endif
|
||||
|
||||
for (i = 0; init_segtype_array[i]; i++) {
|
||||
@ -1040,12 +1040,12 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
if (!is_static() &&
|
||||
(cn = find_config_tree_node(cmd, "global/segment_libraries"))) {
|
||||
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_value *cv;
|
||||
int (*init_multiple_segtypes_fn) (struct cmd_context *,
|
||||
struct segtype_library *);
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
"global/segment_libraries");
|
||||
return 0;
|
||||
|
@ -47,11 +47,16 @@ struct config_info {
|
||||
char _padding[1];
|
||||
};
|
||||
|
||||
struct config_tree;
|
||||
struct dm_config_tree;
|
||||
struct archive_params;
|
||||
struct backup_params;
|
||||
struct arg_values;
|
||||
|
||||
struct config_tree_list {
|
||||
struct dm_list list;
|
||||
struct dm_config_tree *cft;
|
||||
};
|
||||
|
||||
/* FIXME Split into tool & library contexts */
|
||||
/* command-instance-related variables needed by library */
|
||||
struct cmd_context {
|
||||
@ -87,8 +92,8 @@ struct cmd_context {
|
||||
|
||||
struct dm_list config_files;
|
||||
int config_valid;
|
||||
struct config_tree *cft;
|
||||
struct config_tree *cft_override;
|
||||
struct dm_config_tree *cft;
|
||||
struct dm_config_tree *cft_override;
|
||||
struct config_info default_settings;
|
||||
struct config_info current_settings;
|
||||
|
||||
|
1259
lib/config/config.c
1259
lib/config/config.c
File diff suppressed because it is too large
Load Diff
@ -21,76 +21,26 @@
|
||||
struct device;
|
||||
struct cmd_context;
|
||||
|
||||
enum {
|
||||
CFG_STRING,
|
||||
CFG_FLOAT,
|
||||
CFG_INT,
|
||||
CFG_EMPTY_ARRAY
|
||||
};
|
||||
|
||||
struct config_value {
|
||||
int type;
|
||||
union {
|
||||
int64_t i;
|
||||
float r;
|
||||
const char *str;
|
||||
} v;
|
||||
struct config_value *next; /* for arrays */
|
||||
};
|
||||
|
||||
struct config_node {
|
||||
const char *key;
|
||||
struct config_node *parent, *sib, *child;
|
||||
struct config_value *v;
|
||||
};
|
||||
|
||||
struct config_tree {
|
||||
struct config_node *root;
|
||||
};
|
||||
|
||||
struct config_tree_list {
|
||||
struct dm_list list;
|
||||
struct config_tree *cft;
|
||||
};
|
||||
|
||||
struct config_tree *create_config_tree(const char *filename, int keep_open);
|
||||
struct config_tree *create_config_tree_from_string(const char *config_settings);
|
||||
|
||||
int override_config_tree_from_string(struct cmd_context *cmd,
|
||||
const char *config_settings);
|
||||
void destroy_config_tree(struct config_tree *cft);
|
||||
void destroy_config_tree(struct dm_config_tree *cft);
|
||||
|
||||
typedef uint32_t (*checksum_fn_t) (uint32_t initial, const uint8_t *buf, uint32_t size);
|
||||
|
||||
int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
int read_config_fd(struct dm_config_tree *cft, struct device *dev,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum);
|
||||
|
||||
int read_config_file(struct config_tree *cft);
|
||||
int write_config_file(struct config_tree *cft, const char *file,
|
||||
int argc, char **argv);
|
||||
int read_config_file(struct dm_config_tree *cft);
|
||||
|
||||
typedef int (*putline_fn)(const char *line, void *baton);
|
||||
int write_config_node(const struct config_node *cn, putline_fn putline, void *baton);
|
||||
|
||||
time_t config_file_timestamp(struct config_tree *cft);
|
||||
int config_file_changed(struct config_tree *cft);
|
||||
int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
|
||||
struct config_tree *newdata);
|
||||
|
||||
const struct config_node *find_config_node(const struct config_node *cn,
|
||||
const char *path);
|
||||
const char *find_config_str(const struct config_node *cn, const char *path,
|
||||
const char *fail);
|
||||
int find_config_int(const struct config_node *cn, const char *path, int fail);
|
||||
float find_config_float(const struct config_node *cn, const char *path,
|
||||
float fail);
|
||||
int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
|
||||
struct dm_config_tree *newdata);
|
||||
|
||||
/*
|
||||
* These versions check an override tree, if present, first.
|
||||
*/
|
||||
const struct config_node *find_config_tree_node(struct cmd_context *cmd,
|
||||
const char *path);
|
||||
const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd,
|
||||
const char *path);
|
||||
const char *find_config_tree_str(struct cmd_context *cmd,
|
||||
const char *path, const char *fail);
|
||||
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
||||
@ -100,34 +50,6 @@ int64_t find_config_tree_int64(struct cmd_context *cmd, const char *path,
|
||||
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||
float fail);
|
||||
|
||||
/*
|
||||
* Understands (0, ~0), (y, n), (yes, no), (on,
|
||||
* off), (true, false).
|
||||
*/
|
||||
int find_config_bool(const struct config_node *cn, const char *path, int fail);
|
||||
int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail);
|
||||
|
||||
int get_config_uint32(const struct config_node *cn, const char *path,
|
||||
uint32_t *result);
|
||||
|
||||
int get_config_uint64(const struct config_node *cn, const char *path,
|
||||
uint64_t *result);
|
||||
|
||||
int get_config_str(const struct config_node *cn, const char *path,
|
||||
const char **result);
|
||||
|
||||
unsigned maybe_config_section(const char *str, unsigned len);
|
||||
|
||||
const char *config_parent_name(const struct config_node *n);
|
||||
|
||||
struct config_node *clone_config_node_with_mem(struct dm_pool *mem,
|
||||
const struct config_node *node,
|
||||
int siblings);
|
||||
struct config_node *create_config_node(struct config_tree *cft, const char *key);
|
||||
struct config_value *create_config_value(struct config_tree *cft);
|
||||
struct config_node *clone_config_node(struct config_tree *cft, const struct config_node *cn,
|
||||
int siblings);
|
||||
|
||||
struct dm_pool *config_tree_memory(struct config_tree *cft);
|
||||
|
||||
#endif
|
||||
|
@ -644,8 +644,8 @@ void dev_cache_scan(int do_scan)
|
||||
|
||||
static int _init_preferred_names(struct cmd_context *cmd)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *v;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *v;
|
||||
struct dm_pool *scratch = NULL;
|
||||
const char **regex;
|
||||
unsigned count = 0;
|
||||
@ -654,14 +654,14 @@ static int _init_preferred_names(struct cmd_context *cmd)
|
||||
_cache.preferred_names_matcher = NULL;
|
||||
|
||||
if (!(cn = find_config_tree_node(cmd, "devices/preferred_names")) ||
|
||||
cn->v->type == CFG_EMPTY_ARRAY) {
|
||||
cn->v->type == DM_CFG_EMPTY_ARRAY) {
|
||||
log_very_verbose("devices/preferred_names not found in config file: "
|
||||
"using built-in preferences");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (v = cn->v; v; v = v->next) {
|
||||
if (v->type != CFG_STRING) {
|
||||
if (v->type != DM_CFG_STRING) {
|
||||
log_error("preferred_names patterns must be enclosed in quotes");
|
||||
return 0;
|
||||
}
|
||||
|
@ -64,13 +64,13 @@ int persistent_filter_wipe(struct dev_filter *f)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_array(struct pfilter *pf, struct config_tree *cft,
|
||||
static int _read_array(struct pfilter *pf, struct dm_config_tree *cft,
|
||||
const char *path, void *data)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
|
||||
if (!(cn = find_config_node(cft->root, path))) {
|
||||
if (!(cn = dm_config_find_node(cft->root, path))) {
|
||||
log_very_verbose("Couldn't find %s array in '%s'",
|
||||
path, pf->file);
|
||||
return 0;
|
||||
@ -81,7 +81,7 @@ static int _read_array(struct pfilter *pf, struct config_tree *cft,
|
||||
* devices as we go.
|
||||
*/
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_verbose("Devices array contains a value "
|
||||
"which is not a string ... ignoring");
|
||||
continue;
|
||||
@ -96,10 +96,10 @@ static int _read_array(struct pfilter *pf, struct config_tree *cft,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int persistent_filter_load(struct dev_filter *f, struct config_tree **cft_out)
|
||||
int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out)
|
||||
{
|
||||
struct pfilter *pf = (struct pfilter *) f->private;
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
struct stat info;
|
||||
int r = 0;
|
||||
|
||||
@ -122,7 +122,7 @@ int persistent_filter_load(struct dev_filter *f, struct config_tree **cft_out)
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!(cft = create_config_tree(pf->file, 1)))
|
||||
if (!(cft = dm_config_create(pf->file, 1)))
|
||||
return_0;
|
||||
|
||||
if (!read_config_file(cft))
|
||||
@ -173,7 +173,7 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
|
||||
first = 0;
|
||||
}
|
||||
|
||||
escape_double_quotes(buf, dm_hash_get_key(pf->devices, n));
|
||||
dm_escape_double_quotes(buf, dm_hash_get_key(pf->devices, n));
|
||||
fprintf(fp, "\t\t\"%s\"", buf);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ int persistent_filter_dump(struct dev_filter *f, int merge_existing)
|
||||
struct pfilter *pf;
|
||||
char *tmp_file;
|
||||
struct stat info, info2;
|
||||
struct config_tree *cft = NULL;
|
||||
struct dm_config_tree *cft = NULL;
|
||||
FILE *fp;
|
||||
int lockfd;
|
||||
int r = 0;
|
||||
|
@ -22,7 +22,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *f,
|
||||
const char *file);
|
||||
|
||||
int persistent_filter_wipe(struct dev_filter *f);
|
||||
int persistent_filter_load(struct dev_filter *f, struct config_tree **cft_out);
|
||||
int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
|
||||
int persistent_filter_dump(struct dev_filter *f, int merge_existing);
|
||||
|
||||
#endif
|
||||
|
@ -87,10 +87,10 @@ static int _extract_pattern(struct dm_pool *mem, const char *pat,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _build_matcher(struct rfilter *rf, const struct config_value *val)
|
||||
static int _build_matcher(struct rfilter *rf, const struct dm_config_value *val)
|
||||
{
|
||||
struct dm_pool *scratch;
|
||||
const struct config_value *v;
|
||||
const struct dm_config_value *v;
|
||||
char **regex;
|
||||
unsigned count = 0;
|
||||
int i, r = 0;
|
||||
@ -102,7 +102,7 @@ static int _build_matcher(struct rfilter *rf, const struct config_value *val)
|
||||
* count how many patterns we have.
|
||||
*/
|
||||
for (v = val; v; v = v->next) {
|
||||
if (v->type != CFG_STRING) {
|
||||
if (v->type != DM_CFG_STRING) {
|
||||
log_error("Filter patterns must be enclosed in quotes.");
|
||||
goto out;
|
||||
}
|
||||
@ -188,7 +188,7 @@ static void _regex_destroy(struct dev_filter *f)
|
||||
dm_pool_destroy(rf->mem);
|
||||
}
|
||||
|
||||
struct dev_filter *regex_filter_create(const struct config_value *patterns)
|
||||
struct dev_filter *regex_filter_create(const struct dm_config_value *patterns)
|
||||
{
|
||||
struct dm_pool *mem = dm_pool_create("filter regex", 10 * 1024);
|
||||
struct rfilter *rf;
|
||||
|
@ -27,6 +27,6 @@
|
||||
* r|.*| - reject everything else
|
||||
*/
|
||||
|
||||
struct dev_filter *regex_filter_create(const struct config_value *patterns);
|
||||
struct dev_filter *regex_filter_create(const struct dm_config_value *patterns);
|
||||
|
||||
#endif
|
||||
|
@ -177,7 +177,7 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f __attribute__((un
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
static int _scan_proc_dev(const char *proc, const struct dm_config_node *cn)
|
||||
{
|
||||
char line[80];
|
||||
char proc_devices[PATH_MAX];
|
||||
@ -186,7 +186,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
int line_maj = 0;
|
||||
int blocksection = 0;
|
||||
size_t dev_len = 0;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_value *cv;
|
||||
const char *name;
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
|
||||
/* Check devices/types for local variations */
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Expecting string in devices/types "
|
||||
"in config file");
|
||||
if (fclose(pd))
|
||||
@ -279,7 +279,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
dev_len = strlen(cv->v.str);
|
||||
name = cv->v.str;
|
||||
cv = cv->next;
|
||||
if (!cv || cv->type != CFG_INT) {
|
||||
if (!cv || cv->type != DM_CFG_INT) {
|
||||
log_error("Max partition count missing for %s "
|
||||
"in devices/types in config file",
|
||||
name);
|
||||
@ -316,7 +316,7 @@ int max_partitions(int major)
|
||||
}
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
const struct config_node *cn)
|
||||
const struct dm_config_node *cn)
|
||||
{
|
||||
struct dev_filter *f;
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#endif
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
const struct config_node *cn);
|
||||
const struct dm_config_node *cn);
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f);
|
||||
|
||||
|
@ -319,9 +319,9 @@ static int _out_line(const char *line, void *_f) {
|
||||
return out_text(f, "%s", line);
|
||||
}
|
||||
|
||||
int out_config_node(struct formatter *f, const struct config_node *cn)
|
||||
int out_config_node(struct formatter *f, const struct dm_config_node *cn)
|
||||
{
|
||||
return write_config_node(cn, _out_line, f);
|
||||
return dm_config_write_node(cn, _out_line, f);
|
||||
}
|
||||
|
||||
static int _print_header(struct formatter *f,
|
||||
@ -337,12 +337,12 @@ static int _print_header(struct formatter *f,
|
||||
outf(f, FORMAT_VERSION_FIELD " = %d", FORMAT_VERSION_VALUE);
|
||||
outnl(f);
|
||||
|
||||
if (!(buf = alloca(escaped_len(desc)))) {
|
||||
if (!(buf = alloca(dm_escaped_len(desc)))) {
|
||||
log_error("temporary stack allocation for description"
|
||||
"string failed");
|
||||
return 0;
|
||||
}
|
||||
outf(f, "description = \"%s\"", escape_double_quotes(buf, desc));
|
||||
outf(f, "description = \"%s\"", dm_escape_double_quotes(buf, desc));
|
||||
outnl(f);
|
||||
outf(f, "creation_host = \"%s\"\t# %s %s %s %s %s", _utsname.nodename,
|
||||
_utsname.sysname, _utsname.nodename, _utsname.release,
|
||||
@ -465,14 +465,14 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
|
||||
if (!(buf = alloca(escaped_len(pv_dev_name(pv))))) {
|
||||
if (!(buf = alloca(dm_escaped_len(pv_dev_name(pv))))) {
|
||||
log_error("temporary stack allocation for device name"
|
||||
"string failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
outhint(f, "device = \"%s\"",
|
||||
escape_double_quotes(buf, pv_dev_name(pv)));
|
||||
dm_escape_double_quotes(buf, pv_dev_name(pv)));
|
||||
outnl(f);
|
||||
|
||||
if (!_print_flag_config(f, pv->status, PV_FLAGS))
|
||||
|
@ -140,7 +140,7 @@ int print_flags(uint64_t status, int type, char *buffer, size_t size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read_flags(uint64_t *status, int type, const struct config_value *cv)
|
||||
int read_flags(uint64_t *status, int type, const struct dm_config_value *cv)
|
||||
{
|
||||
int f;
|
||||
uint64_t s = UINT64_C(0);
|
||||
@ -149,11 +149,11 @@ int read_flags(uint64_t *status, int type, const struct config_value *cv)
|
||||
if (!(flags = _get_flags(type)))
|
||||
return_0;
|
||||
|
||||
if (cv->type == CFG_EMPTY_ARRAY)
|
||||
if (cv->type == DM_CFG_EMPTY_ARRAY)
|
||||
goto out;
|
||||
|
||||
while (cv) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Status value is not a string.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
|
||||
* area->start to area->start+area->size is not used.
|
||||
* Only ~32KB seems to contain valid metadata records
|
||||
* (LVM2 format - format_text). As a result, I end up with
|
||||
* "maybe_config_section" returning true when there's no valid
|
||||
* "dm_config_maybe_section" returning true when there's no valid
|
||||
* metadata in a sector (sectors with all nulls).
|
||||
*/
|
||||
if (!(buf = dm_malloc(size + size2)))
|
||||
@ -236,7 +236,7 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
|
||||
/*
|
||||
* FIXME: We could add more sophisticated metadata detection
|
||||
*/
|
||||
if (maybe_config_section(buf, size + size2)) {
|
||||
if (dm_config_maybe_section(buf, size + size2)) {
|
||||
/* FIXME: Validate region, pull out timestamp?, etc */
|
||||
/* FIXME: Do something with this region */
|
||||
log_verbose ("Found LVM2 metadata record at "
|
||||
@ -2277,7 +2277,7 @@ static int _add_dir(const char *dir, struct dm_list *dir_list)
|
||||
}
|
||||
|
||||
static int _get_config_disk_area(struct cmd_context *cmd,
|
||||
const struct config_node *cn, struct dm_list *raw_list)
|
||||
const struct dm_config_node *cn, struct dm_list *raw_list)
|
||||
{
|
||||
struct device_area dev_area;
|
||||
const char *id_str;
|
||||
@ -2288,21 +2288,21 @@ static int _get_config_disk_area(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!get_config_uint64(cn, "start_sector", &dev_area.start)) {
|
||||
if (!dm_config_get_uint64(cn, "start_sector", &dev_area.start)) {
|
||||
log_error("Missing start_sector in metadata disk_area section "
|
||||
"of config file");
|
||||
return 0;
|
||||
}
|
||||
dev_area.start <<= SECTOR_SHIFT;
|
||||
|
||||
if (!get_config_uint64(cn, "size", &dev_area.size)) {
|
||||
if (!dm_config_get_uint64(cn, "size", &dev_area.size)) {
|
||||
log_error("Missing size in metadata disk_area section "
|
||||
"of config file");
|
||||
return 0;
|
||||
}
|
||||
dev_area.size <<= SECTOR_SHIFT;
|
||||
|
||||
if (!get_config_str(cn, "id", &id_str)) {
|
||||
if (!dm_config_get_str(cn, "id", &id_str)) {
|
||||
log_error("Missing uuid in metadata disk_area section "
|
||||
"of config file");
|
||||
return 0;
|
||||
@ -2332,8 +2332,8 @@ static int _get_config_disk_area(struct cmd_context *cmd,
|
||||
struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
{
|
||||
struct format_type *fmt;
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
struct mda_lists *mda_lists;
|
||||
|
||||
if (!(fmt = dm_malloc(sizeof(*fmt))))
|
||||
@ -2374,7 +2374,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
|
||||
if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) {
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
"metadata/dirs");
|
||||
goto err;
|
||||
|
@ -44,14 +44,14 @@ enum {
|
||||
};
|
||||
|
||||
struct text_vg_version_ops {
|
||||
int (*check_version) (const struct config_tree * cf);
|
||||
int (*check_version) (const struct dm_config_tree * cf);
|
||||
struct volume_group *(*read_vg) (struct format_instance * fid,
|
||||
const struct config_tree *cf,
|
||||
const struct dm_config_tree *cf,
|
||||
unsigned use_cached_pvs);
|
||||
void (*read_desc) (struct dm_pool * mem, const struct config_tree *cf,
|
||||
void (*read_desc) (struct dm_pool * mem, const struct dm_config_tree *cf,
|
||||
time_t *when, char **desc);
|
||||
const char *(*read_vgname) (const struct format_type *fmt,
|
||||
const struct config_tree *cft,
|
||||
const struct dm_config_tree *cft,
|
||||
struct id *vgid, uint64_t *vgstatus,
|
||||
char **creation_host);
|
||||
};
|
||||
@ -59,10 +59,10 @@ struct text_vg_version_ops {
|
||||
struct text_vg_version_ops *text_vg_vsn1_init(void);
|
||||
|
||||
int print_flags(uint64_t status, int type, char *buffer, size_t size);
|
||||
int read_flags(uint64_t *status, int type, const struct config_value *cv);
|
||||
int read_flags(uint64_t *status, int type, const struct dm_config_value *cv);
|
||||
|
||||
char *alloc_printed_tags(struct dm_list *tags);
|
||||
int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct config_value *cv);
|
||||
int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct dm_config_value *cv);
|
||||
|
||||
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
|
||||
int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf);
|
||||
|
@ -43,13 +43,13 @@ const char *text_vgname_import(const struct format_type *fmt,
|
||||
struct id *vgid, uint64_t *vgstatus,
|
||||
char **creation_host)
|
||||
{
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
struct text_vg_version_ops **vsn;
|
||||
const char *vgname = NULL;
|
||||
|
||||
_init_text_import();
|
||||
|
||||
if (!(cft = create_config_tree(NULL, 0)))
|
||||
if (!(cft = dm_config_create(NULL, 0)))
|
||||
return_NULL;
|
||||
|
||||
if ((!dev && !read_config_file(cft)) ||
|
||||
@ -86,7 +86,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
|
||||
time_t *when, char **desc)
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
struct text_vg_version_ops **vsn;
|
||||
|
||||
_init_text_import();
|
||||
@ -94,7 +94,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
|
||||
*desc = NULL;
|
||||
*when = 0;
|
||||
|
||||
if (!(cft = create_config_tree(file, 0)))
|
||||
if (!(cft = dm_config_create(file, 0)))
|
||||
return_NULL;
|
||||
|
||||
if ((!dev && !read_config_file(cft)) ||
|
||||
@ -131,7 +131,7 @@ struct volume_group *text_vg_import_file(struct format_instance *fid,
|
||||
when, desc);
|
||||
}
|
||||
|
||||
struct volume_group *import_vg_from_config_tree(const struct config_tree *cft,
|
||||
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
|
||||
struct format_instance *fid)
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
|
@ -26,21 +26,21 @@
|
||||
#include "defaults.h"
|
||||
|
||||
typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
|
||||
struct volume_group * vg, const struct config_node * pvn,
|
||||
const struct config_node * vgn,
|
||||
struct volume_group * vg, const struct dm_config_node * pvn,
|
||||
const struct dm_config_node * vgn,
|
||||
struct dm_hash_table * pv_hash,
|
||||
struct dm_hash_table * lv_hash,
|
||||
unsigned *scan_done_once,
|
||||
unsigned report_missing_devices);
|
||||
|
||||
#define _read_int32(root, path, result) \
|
||||
get_config_uint32(root, path, (uint32_t *) result)
|
||||
dm_config_get_uint32(root, path, (uint32_t *) result)
|
||||
|
||||
#define _read_uint32(root, path, result) \
|
||||
get_config_uint32(root, path, result)
|
||||
dm_config_get_uint32(root, path, result)
|
||||
|
||||
#define _read_int64(root, path, result) \
|
||||
get_config_uint64(root, path, result)
|
||||
dm_config_get_uint64(root, path, result)
|
||||
|
||||
/*
|
||||
* Logs an attempt to read an invalid format file.
|
||||
@ -54,21 +54,21 @@ static void _invalid_format(const char *str)
|
||||
* Checks that the config file contains vg metadata, and that it
|
||||
* we recognise the version number,
|
||||
*/
|
||||
static int _vsn1_check_version(const struct config_tree *cft)
|
||||
static int _vsn1_check_version(const struct dm_config_tree *cft)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn;
|
||||
const struct dm_config_value *cv;
|
||||
|
||||
/*
|
||||
* Check the contents field.
|
||||
*/
|
||||
if (!(cn = find_config_node(cft->root, CONTENTS_FIELD))) {
|
||||
if (!(cn = dm_config_find_node(cft->root, CONTENTS_FIELD))) {
|
||||
_invalid_format("missing contents field");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cv = cn->v;
|
||||
if (!cv || cv->type != CFG_STRING || strcmp(cv->v.str, CONTENTS_VALUE)) {
|
||||
if (!cv || cv->type != DM_CFG_STRING || strcmp(cv->v.str, CONTENTS_VALUE)) {
|
||||
_invalid_format("unrecognised contents field");
|
||||
return 0;
|
||||
}
|
||||
@ -76,13 +76,13 @@ static int _vsn1_check_version(const struct config_tree *cft)
|
||||
/*
|
||||
* Check the version number.
|
||||
*/
|
||||
if (!(cn = find_config_node(cft->root, FORMAT_VERSION_FIELD))) {
|
||||
if (!(cn = dm_config_find_node(cft->root, FORMAT_VERSION_FIELD))) {
|
||||
_invalid_format("missing version number");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cv = cn->v;
|
||||
if (!cv || cv->type != CFG_INT || cv->v.i != FORMAT_VERSION_VALUE) {
|
||||
if (!cv || cv->type != DM_CFG_INT || cv->v.i != FORMAT_VERSION_VALUE) {
|
||||
_invalid_format("unrecognised version number");
|
||||
return 0;
|
||||
}
|
||||
@ -106,11 +106,11 @@ static int _is_converting(struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _read_id(struct id *id, const struct config_node *cn, const char *path)
|
||||
static int _read_id(struct id *id, const struct dm_config_node *cn, const char *path)
|
||||
{
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_value *cv;
|
||||
|
||||
if (!(cn = find_config_node(cn, path))) {
|
||||
if (!(cn = dm_config_find_node(cn, path))) {
|
||||
log_error("Couldn't find uuid.");
|
||||
return 0;
|
||||
}
|
||||
@ -129,12 +129,12 @@ static int _read_id(struct id *id, const struct config_node *cn, const char *pat
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_flag_config(const struct config_node *n, uint64_t *status, int type)
|
||||
static int _read_flag_config(const struct dm_config_node *n, uint64_t *status, int type)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
const struct dm_config_node *cn;
|
||||
*status = 0;
|
||||
|
||||
if (!(cn = find_config_node(n, "status"))) {
|
||||
if (!(cn = dm_config_find_node(n, "status"))) {
|
||||
log_error("Could not find status flags.");
|
||||
return 0;
|
||||
}
|
||||
@ -144,7 +144,7 @@ static int _read_flag_config(const struct config_node *n, uint64_t *status, int
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cn = find_config_node(n, "flags"))) {
|
||||
if ((cn = dm_config_find_node(n, "flags"))) {
|
||||
if (!(read_flags(status, type, cn->v))) {
|
||||
log_error("Could not read flags.");
|
||||
return 0;
|
||||
@ -155,8 +155,8 @@ static int _read_flag_config(const struct config_node *n, uint64_t *status, int
|
||||
}
|
||||
|
||||
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
struct volume_group *vg, const struct config_node *pvn,
|
||||
const struct config_node *vgn __attribute__((unused)),
|
||||
struct volume_group *vg, const struct dm_config_node *pvn,
|
||||
const struct dm_config_node *vgn __attribute__((unused)),
|
||||
struct dm_hash_table *pv_hash,
|
||||
struct dm_hash_table *lv_hash __attribute__((unused)),
|
||||
unsigned *scan_done_once,
|
||||
@ -164,7 +164,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct pv_list *pvl;
|
||||
const struct config_node *cn;
|
||||
const struct dm_config_node *cn;
|
||||
uint64_t size;
|
||||
|
||||
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
|
||||
@ -238,7 +238,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
dm_list_init(&pv->segments);
|
||||
|
||||
/* Optional tags */
|
||||
if ((cn = find_config_node(pvn, "tags")) &&
|
||||
if ((cn = dm_config_find_node(pvn, "tags")) &&
|
||||
!(read_tags(mem, &pv->tags, cn->v))) {
|
||||
log_error("Couldn't read tags for physical volume %s in %s.",
|
||||
pv_dev_name(pv), vg->name);
|
||||
@ -292,13 +292,13 @@ static void _insert_segment(struct logical_volume *lv, struct lv_segment *seg)
|
||||
}
|
||||
|
||||
static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
struct logical_volume *lv, const struct config_node *sn,
|
||||
struct logical_volume *lv, const struct dm_config_node *sn,
|
||||
struct dm_hash_table *pv_hash)
|
||||
{
|
||||
uint32_t area_count = 0u;
|
||||
struct lv_segment *seg;
|
||||
const struct config_node *cn, *sn_child = sn->child;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_node *cn, *sn_child = sn->child;
|
||||
const struct dm_config_value *cv;
|
||||
uint32_t start_extent, extent_count;
|
||||
struct segment_type *segtype;
|
||||
const char *segtype_str;
|
||||
@ -322,7 +322,7 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
|
||||
segtype_str = "striped";
|
||||
|
||||
if ((cn = find_config_node(sn_child, "type"))) {
|
||||
if ((cn = dm_config_find_node(sn_child, "type"))) {
|
||||
cv = cn->v;
|
||||
if (!cv || !cv->v.str) {
|
||||
log_error("Segment type must be a string.");
|
||||
@ -350,7 +350,7 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
return_0;
|
||||
|
||||
/* Optional tags */
|
||||
if ((cn = find_config_node(sn_child, "tags")) &&
|
||||
if ((cn = dm_config_find_node(sn_child, "tags")) &&
|
||||
!(read_tags(mem, &seg->tags, cn->v))) {
|
||||
log_error("Couldn't read tags for a segment of %s/%s.",
|
||||
vg->name, lv->name);
|
||||
@ -377,15 +377,15 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
|
||||
const struct config_node *cn, struct dm_hash_table *pv_hash,
|
||||
int text_import_areas(struct lv_segment *seg, const struct dm_config_node *sn,
|
||||
const struct dm_config_node *cn, struct dm_hash_table *pv_hash,
|
||||
uint64_t status)
|
||||
{
|
||||
unsigned int s;
|
||||
const struct config_value *cv;
|
||||
const struct dm_config_value *cv;
|
||||
struct logical_volume *lv1;
|
||||
struct physical_volume *pv;
|
||||
const char *seg_name = config_parent_name(sn);
|
||||
const char *seg_name = dm_config_parent_name(sn);
|
||||
|
||||
if (!seg->area_count) {
|
||||
log_error("Zero areas not allowed for segment %s", seg_name);
|
||||
@ -395,7 +395,7 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
|
||||
for (cv = cn->v, s = 0; cv && s < seg->area_count; s++, cv = cv->next) {
|
||||
|
||||
/* first we read the pv */
|
||||
if (cv->type != CFG_STRING) {
|
||||
if (cv->type != DM_CFG_STRING) {
|
||||
log_error("Bad volume name in areas array for segment %s.", seg_name);
|
||||