mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-11 09:18:25 +03:00
Adapt the daemon/common code to use the new dm_config interface.
This commit is contained in:
parent
d60c24dda8
commit
5c43b9bda7
@ -44,7 +44,7 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
|
||||
write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer));
|
||||
|
||||
if (read_buffer(h.socket_fd, &reply.buffer)) {
|
||||
reply.cft = create_config_tree_from_string(reply.buffer);
|
||||
reply.cft = dm_config_from_string(reply.buffer);
|
||||
} else
|
||||
reply.error = 1;
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
#include "libdevmapper.h" // for dm_list, needed by config.h
|
||||
#include "config.h" // should become part of libdevmapper later
|
||||
|
||||
#ifndef _LVM_DAEMON_COMMON_CLIENT_H
|
||||
#define _LVM_DAEMON_COMMON_CLIENT_H
|
||||
@ -42,13 +41,13 @@ typedef struct {
|
||||
* knobs = [ "twiddle", "tweak" ]
|
||||
* }
|
||||
*/
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
} daemon_request;
|
||||
|
||||
typedef struct {
|
||||
int error; /* 0 for success */
|
||||
char *buffer; /* textual reply */
|
||||
struct config_tree *cft; /* parsed reply, if available */
|
||||
struct dm_config_tree *cft; /* parsed reply, if available */
|
||||
} daemon_reply;
|
||||
|
||||
/*
|
||||
@ -83,11 +82,11 @@ daemon_reply daemon_send_simple(daemon_handle h, char *id, ...);
|
||||
void daemon_reply_destroy(daemon_reply r);
|
||||
|
||||
static inline int daemon_reply_int(daemon_reply r, const char *path, int def) {
|
||||
return find_config_int(r.cft->root, path, def);
|
||||
return dm_config_find_int(r.cft->root, path, def);
|
||||
}
|
||||
|
||||
static inline const char *daemon_reply_str(daemon_reply r, const char *path, const char *def) {
|
||||
return find_config_str(r.cft->root, path, def);
|
||||
return dm_config_find_str(r.cft->root, path, def);
|
||||
}
|
||||
|
||||
|
||||
|
@ -242,7 +242,7 @@ void *client_thread(void *baton)
|
||||
if (!read_buffer(b->client.socket_fd, &req.buffer))
|
||||
goto fail;
|
||||
|
||||
req.cft = create_config_tree_from_string(req.buffer);
|
||||
req.cft = dm_config_from_string(req.buffer);
|
||||
if (!req.cft)
|
||||
fprintf(stderr, "error parsing request:\n %s\n", req.buffer);
|
||||
response res = b->s.handler(b->s, b->client, req);
|
||||
@ -251,7 +251,7 @@ void *client_thread(void *baton)
|
||||
dm_free(req.buffer);
|
||||
|
||||
if (!res.buffer) {
|
||||
write_config_node(res.cft->root, buffer_line, &res);
|
||||
dm_config_write_node(res.cft->root, buffer_line, &res);
|
||||
buffer_rewrite(&res.buffer, "%s\n\n", NULL);
|
||||
destroy_config_tree(res.cft);
|
||||
}
|
||||
@ -323,6 +323,7 @@ void daemon_start(daemon_state s)
|
||||
signal(SIGHUP, &_exit_handler);
|
||||
signal(SIGQUIT, &_exit_handler);
|
||||
signal(SIGTERM, &_exit_handler);
|
||||
signal(SIGALRM, &_exit_handler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
#ifdef linux
|
||||
|
@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
#include "daemon-client.h"
|
||||
#include "config.h" // XXX will be in libdevmapper.h later
|
||||
|
||||
#ifndef _LVM_DAEMON_COMMON_SERVER_H
|
||||
#define _LVM_DAEMON_COMMON_SERVER_H
|
||||
@ -26,13 +25,13 @@ typedef struct {
|
||||
} client_handle;
|
||||
|
||||
typedef struct {
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
char *buffer;
|
||||
} request;
|
||||
|
||||
typedef struct {
|
||||
int error;
|
||||
struct config_tree *cft;
|
||||
struct dm_config_tree *cft;
|
||||
char *buffer;
|
||||
} response;
|
||||
|
||||
@ -47,13 +46,13 @@ response daemon_reply_simple(char *id, ...);
|
||||
static inline int daemon_request_int(request r, const char *path, int def) {
|
||||
if (!r.cft)
|
||||
return def;
|
||||
return find_config_int(r.cft->root, path, def);
|
||||
return dm_config_find_int(r.cft->root, path, def);
|
||||
}
|
||||
|
||||
static inline const char *daemon_request_str(request r, const char *path, const char *def) {
|
||||
if (!r.cft)
|
||||
return def;
|
||||
return find_config_str(r.cft->root, path, def);
|
||||
return dm_config_find_str(r.cft->root, path, def);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user