signed char opt;
daemon_state s = { .private = NULL };
lvmetad_state ls;
- int _restart = 0;
int _socket_override = 1;
s.name = "lvmetad";
void lvmetad_set_token(const struct dm_config_value *filter)
{
+ int ft = 0;
+
if (_lvmetad_token)
dm_free(_lvmetad_token);
- int ft = 0;
+
while (filter && filter->type == DM_CFG_STRING) {
ft = calc_crc(ft, (const uint8_t *) filter->v.str, strlen(filter->v.str));
filter = filter->next;
}
+
if (!dm_asprintf(&_lvmetad_token, "filter:%u", ft))
log_warn("WARNING: Failed to set lvmetad token. Out of memory?");
}
static daemon_reply _lvmetad_send(const char *id, ...);
-static int _token_update()
+static int _token_update(void)
{
daemon_reply repl = _lvmetad_send("token_update", NULL);
static daemon_reply _lvmetad_send(const char *id, ...)
{
va_list ap;
- daemon_reply repl, token_set;
+ daemon_reply repl;
daemon_request req;
int try = 0;
}
}
-out:
return repl;
}
{
struct _extract_mda_baton *b = baton;
struct dm_config_node *cn;
- int result = 0;
char id[32];
if (!mda->ops->mda_export_text) /* do nothing */
char uuid[64];
daemon_reply reply;
struct lvmcache_info *info;
- const char *mdas = NULL;
struct dm_config_tree *pvmeta, *vgmeta;
const char *status;
int result;
const struct dm_config_node *cn;
const struct dm_config_value *cv;
int64_t pv_min_kb;
+ const char *lvmetad_socket;
/* umask */
cmd->default_settings.umask = find_config_tree_int(cmd,
DEFAULT_DETECT_INTERNAL_VG_CACHE_CORRUPTION));
lvmetad_disconnect();
- const char *lvmetad_socket = getenv("LVM_LVMETAD_SOCKET");
+
+ lvmetad_socket = getenv("LVM_LVMETAD_SOCKET");
if (!lvmetad_socket)
lvmetad_socket = DEFAULT_RUN_DIR "/lvmetad.socket";
struct pv_list *pvl, *pvl2;
struct dm_list all_pvs;
char uuid[64] __attribute__((aligned(8)));
- int seqno = 0;
+ unsigned seqno = 0;
if (is_orphan_vg(vgname)) {
if (use_precommitted) {
int lv_raid_split(struct logical_volume *lv, const char *split_name,
uint32_t new_count, struct dm_list *splittable_pvs)
{
- const char *old_name;
struct lv_list *lvl;
struct dm_list removal_list, data_list;
struct cmd_context *cmd = lv->vg->cmd;
dm_list_iterate_items(lvl, &data_list)
break;
- old_name = lvl->lv->name;
lvl->lv->name = split_name;
if (!vg_write(lv->vg)) {
break;
}
- if (s >= seg->area_count) {
+ if (s >= (int) seg->area_count) {
log_error("Unable to find image to satisfy request");
return 0;
}
int buffer_append_vf(struct buffer *buf, va_list ap)
{
- char *append, *old;
+ char *append;
char *next;
int keylen;
int buffer_append_f(struct buffer *buf, ...)
{
+ int res;
va_list ap;
+
va_start(ap, buf);
- int res = buffer_append_vf(buf, ap);
+ res = buffer_append_vf(buf, ap);
va_end(ap);
+
return res;
}
{
const char *next;
struct dm_config_node *first = NULL;
+ struct dm_config_node *cn;
+ const char *fmt, *key;
while ((next = va_arg(ap, char *))) {
- struct dm_config_node *cn = NULL;
- const char *fmt = strchr(next, '=');
+ cn = NULL;
+ fmt = strchr(next, '=');
if (!fmt) {
log_error(INTERNAL_ERROR "Bad format string '%s'", fmt);
}
fmt += 2;
- char *key = dm_pool_strdup(cft->mem, next);
+ key = dm_pool_strdup(cft->mem, next);
*strchr(key, '=') = 0;
if (!strcmp(fmt, "%d") || !strcmp(fmt, "%" PRId64)) {
struct dm_config_node *pre_sib,
...)
{
+ struct dm_config_node *res;
va_list ap;
+
va_start(ap, pre_sib);
- struct dm_config_node *res = config_make_nodes_v(cft, parent, pre_sib, ap);
+ res = config_make_nodes_v(cft, parent, pre_sib, ap);
va_end(ap);
+
return res;
}
int buffer_append(struct buffer *buf, const char *string)
{
int len = strlen(string);
- char *new;
if (buf->allocated - buf->used <= len)
buffer_realloc(buf, len + 1);
daemon_reply daemon_send(daemon_handle h, daemon_request rq)
{
+ struct buffer buffer;
daemon_reply reply = { .cft = NULL, .error = 0 };
assert(h.socket_fd >= 0);
- struct buffer buffer = rq.buffer;
+ buffer = rq.buffer;
if (!buffer.mem)
dm_config_write_node(rq.cft->root, buffer_line, &buffer);
daemon_reply daemon_send_simple(daemon_handle h, const char *id, ...)
{
+ daemon_reply r;
va_list ap;
+
va_start(ap, id);
- daemon_reply r = daemon_send_simple_v(h, id, ap);
+ r = daemon_send_simple_v(h, id, ap);
va_end(ap);
+
return r;
}
int daemon_request_extend(daemon_request r, ...)
{
+ int res;
va_list ap;
+
va_start(ap, r);
- int res = daemon_request_extend_v(r, ap);
+ res = daemon_request_extend_v(r, ap);
va_end(ap);
+
return res;
}
static void log_syslog(log_state *s, void **state, int type, const char *message)
{
+ int prio;
+
if (!*state) { /* initialize */
*state = (void *)1;
openlog(s->name, LOG_PID, LOG_DAEMON);
}
- int prio = LOG_DEBUG;
+
switch (type) {
case DAEMON_LOG_INFO: prio = LOG_INFO; break;
case DAEMON_LOG_WARN: prio = LOG_WARNING; break;
case DAEMON_LOG_FATAL: prio = LOG_CRIT; break;
+ default: prio = LOG_DEBUG; break;
}
syslog(prio, "%s", message);
static void log_stderr(log_state *s, void **state, int type, const char *message)
{
- const char *prefix = "";
+ const char *prefix;
+
switch (type) {
case DAEMON_LOG_INFO: prefix = "I: "; break;
case DAEMON_LOG_WARN: prefix = "W: " ; break;
- case DAEMON_LOG_ERROR:
+ case DAEMON_LOG_ERROR: /* fall through */
case DAEMON_LOG_FATAL: prefix = "E: " ; break;
+ default: prefix = ""; break;
}
fprintf(stderr, "%s%s\n", prefix, message);
void daemon_log_cft(log_state *s, int type, const char *prefix, const struct dm_config_node *n)
{
+ struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
+
if (!_type_interesting(s, type))
return;
- struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
dm_config_write_node(n, &_log_line, &b);
}
void daemon_log_multi(log_state *s, int type, const char *prefix, const char *msg)
{
+ struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
+ char *buf;
+ char *pos;
+
if (!_type_interesting(s, type))
return;
- struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
- char *buf = dm_strdup(msg);
- char *pos = buf;
+ buf = dm_strdup(msg);
+ pos = buf;
if (!buf)
return; /* _0 */
static response builtin_handler(daemon_state s, client_handle h, request r)
{
const char *rq = daemon_request_str(r, "request", "NONE");
+ response res = { .error = EPROTO };
if (!strcmp(rq, "hello")) {
return daemon_reply_simple("OK", "protocol = %s", s.protocol ?: "default",
"version = %" PRId64, (int64_t) s.protocol_version, NULL);
}
- response res = { .error = EPROTO };
buffer_init(&res.buffer);
return res;
}
void daemon_start(daemon_state s)
{
int failed = 0;
+ log_state _log = { { 0 } };
+
/*
* Switch to C locale to avoid reading large locale-archive file used by
* some glibc (on some distributions it takes over 100MB). Some daemons
if (!s.foreground)
_daemonise();
- log_state _log = { { 0 } };
s.log = &_log;
s.log->name = s.name;