diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2017-01-20 21:50:23 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2017-01-20 23:55:50 +0100 |
commit | bc7a1d70d4936fd892223686388fd6fe5c8c3934 (patch) | |
tree | c494b9d83fa2f6d1b1a8c6b96fa4c8144b2e70fd | |
parent | 14746a6c0025fad0d918bff7f1ee105e0eee10c3 (diff) | |
download | lvm2-bc7a1d70d4936fd892223686388fd6fe5c8c3934.tar.gz |
dmeventd_thin: init command
When dmeventd configured command does not start with 'lvm ' prefix,
it's going to be an 'external' command.
In this case we split command by spaces to argv strings.
-rw-r--r-- | daemons/dmeventd/plugins/thin/dmeventd_thin.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c index 74b010ad7..86a21157c 100644 --- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c +++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c @@ -549,6 +549,8 @@ int register_device(const char *device, void **user) { struct dso_state *state; + int maxcmd; + char *str; if (!dmeventd_lvm2_init_with_pool("thin_pool_state", state)) goto_bad; @@ -561,6 +563,20 @@ int register_device(const char *device, goto_bad; } + if (strncmp(state->cmd_str, "lvm ", 4)) { + maxcmd = 2; /* space for last NULL element */ + for (str = state->cmd_str; *str; str++) + if (*str == ' ') + maxcmd++; + if (!(str = dm_pool_strdup(state->mem, state->cmd_str)) || + !(state->argv = dm_pool_zalloc(state->mem, maxcmd * sizeof(char *)))) { + log_error("Failed to allocate memory for command."); + goto bad; + } + + dm_split_words(str, maxcmd - 1, 0, state->argv); + } + state->metadata_percent_check = CHECK_MINIMUM; state->data_percent_check = CHECK_MINIMUM; state->pid = -1; |