1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

segtype: better get_monitor_dso_path api

Instead of allocating always 4K for dso path, use only real needed size.
Also simplify API call and move common functionality into function
itself.
This commit is contained in:
Zdenek Kabelac 2018-02-10 20:22:32 +01:00
parent e113df129e
commit 27399755fd
6 changed files with 10 additions and 18 deletions

View File

@ -1685,18 +1685,14 @@ bad:
return NULL;
}
char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath)
char *get_monitor_dso_path(struct cmd_context *cmd, int id)
{
char *path;
const char *libpath = find_config_tree_str(cmd, id, NULL);
char path[PATH_MAX];
if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) {
log_error("Failed to allocate dmeventd library path.");
return NULL;
}
get_shared_library_path(cmd, libpath, path, sizeof(path));
get_shared_library_path(cmd, libpath, path, PATH_MAX);
return path;
return dm_pool_strdup(cmd->mem, path);
}
static char *_build_target_uuid(struct cmd_context *cmd, const struct logical_volume *lv)

View File

@ -206,7 +206,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
#ifdef DMEVENTD
# include "libdevmapper-event.h"
char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath);
char *get_monitor_dso_path(struct cmd_context *cmd, int id);
int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,
const struct logical_volume *lv, int *pending, int *monitored);
int target_register_events(struct cmd_context *cmd, const char *dso, const struct logical_volume *lv,

View File

@ -572,8 +572,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_mirror_library_CFG, NULL));
segtype->dso = get_monitor_dso_path(cmd, dmeventd_mirror_library_CFG);
if (segtype->dso)
segtype->flags |= SEG_MONITORED;

View File

@ -656,8 +656,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_raid_library_CFG, NULL));
dso = get_monitor_dso_path(cmd, dmeventd_raid_library_CFG);
if (dso)
monitored = SEG_MONITORED;

View File

@ -263,8 +263,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_snapshot_library_CFG, NULL));
segtype->dso = get_monitor_dso_path(cmd, dmeventd_snapshot_library_CFG);
if (segtype->dso)
segtype->flags |= SEG_MONITORED;

View File

@ -816,8 +816,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
segtype->dso = get_monitor_dso_path(cmd,
find_config_tree_str(cmd, dmeventd_thin_library_CFG, NULL));
segtype->dso = get_monitor_dso_path(cmd, dmeventd_thin_library_CFG);
if ((reg_segtypes[i].flags & SEG_THIN_POOL) &&
segtype->dso)