mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
export size
This commit is contained in:
parent
64a462ea4d
commit
d7934cfd12
@ -1059,22 +1059,19 @@ size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf,
|
||||
return r;
|
||||
}
|
||||
|
||||
static size_t _export_vg_to_buffer(struct volume_group *vg, char **buf)
|
||||
{
|
||||
return text_vg_export_raw(vg, "", buf, NULL);
|
||||
}
|
||||
|
||||
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg)
|
||||
{
|
||||
char *buf = NULL;
|
||||
uint32_t buf_size = 0;
|
||||
struct dm_config_tree *vg_cft;
|
||||
|
||||
if (!_export_vg_to_buffer(vg, &buf)) {
|
||||
/* export vg to bufffer */
|
||||
if (!text_vg_export_raw(vg, "", &buf, &buf_size)) {
|
||||
log_error("Could not format metadata for VG %s.", vg->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(vg_cft = config_tree_from_string_without_dup_node_check(buf))) {
|
||||
if (!(vg_cft = config_tree_from_string_without_dup_node_check(buf, buf_size))) {
|
||||
log_error("Error parsing metadata for VG %s.", vg->name);
|
||||
free(buf);
|
||||
return NULL;
|
||||
|
@ -647,7 +647,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
*
|
||||
* 'Lazy' creation of such VG might improve performance, but we
|
||||
* lose important validation that written metadata can be parsed. */
|
||||
if (!(cft = config_tree_from_string_without_dup_node_check(write_buf))) {
|
||||
if (!(cft = config_tree_from_string_without_dup_node_check(write_buf, new_size - 1))) {
|
||||
log_error("Error parsing metadata for VG %s.", vg->name);
|
||||
goto out;
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ void chain_node(struct dm_config_node *cn,
|
||||
|
||||
}
|
||||
|
||||
struct dm_config_tree *config_tree_from_string_without_dup_node_check(const char *config_settings)
|
||||
struct dm_config_tree *config_tree_from_string_without_dup_node_check(const char *config_settings, size_t len)
|
||||
{
|
||||
struct dm_config_tree *cft;
|
||||
|
||||
if (!(cft = dm_config_create()))
|
||||
return_NULL;
|
||||
|
||||
if (!dm_config_parse_without_dup_node_check(cft, config_settings, config_settings + strlen(config_settings))) {
|
||||
if (!dm_config_parse_without_dup_node_check(cft, config_settings, config_settings + len)) {
|
||||
dm_config_destroy(cft);
|
||||
return_NULL;
|
||||
}
|
||||
|
@ -66,6 +66,6 @@ struct dm_config_node *config_make_nodes(struct dm_config_tree *cft,
|
||||
struct dm_config_node *pre_sib,
|
||||
...);
|
||||
|
||||
struct dm_config_tree *config_tree_from_string_without_dup_node_check(const char *config_settings);
|
||||
struct dm_config_tree *config_tree_from_string_without_dup_node_check(const char *config_settings, size_t len);
|
||||
|
||||
#endif /* _LVM_DAEMON_CONFIG_UTIL_H */
|
||||
|
@ -118,7 +118,7 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
|
||||
reply.error = errno;
|
||||
|
||||
if (buffer_read(h.socket_fd, &reply.buffer)) {
|
||||
reply.cft = config_tree_from_string_without_dup_node_check(reply.buffer.mem);
|
||||
reply.cft = config_tree_from_string_without_dup_node_check(reply.buffer.mem, reply.buffer.used);
|
||||
if (!reply.cft)
|
||||
reply.error = EPROTO;
|
||||
} else
|
||||
|
@ -450,7 +450,7 @@ static void *_client_thread(void *state)
|
||||
if (!buffer_read(ts->client.socket_fd, &req.buffer))
|
||||
goto fail;
|
||||
|
||||
req.cft = config_tree_from_string_without_dup_node_check(req.buffer.mem);
|
||||
req.cft = config_tree_from_string_without_dup_node_check(req.buffer.mem, req.buffer.used);
|
||||
|
||||
if (!req.cft)
|
||||
fprintf(stderr, "error parsing request:\n %s\n", req.buffer.mem);
|
||||
|
Loading…
Reference in New Issue
Block a user