1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/daemons/lvmetad/lvmetad-core.c
Petr Rockai 94bb67ab37 Add int/str lookup routines specific to the reply (in client) and request (in
server) for nicer-looking code (thin wrapping around find_config_{int,str}).
2011-06-27 14:03:58 +00:00

75 lines
1.6 KiB
C

#include "metadata-exported.h"
#include "../common/daemon-server.h"
typedef struct {
} lvmetad_state;
static response handler(daemon_state s, client_handle h, request r)
{
fprintf(stderr, "[D] REQUEST: %s, param = %d\n", daemon_request_str(r, "request", "NONE"),
daemon_request_int(r, "param", -1));
return daemon_reply_simple("hey there", "param = %d", 42, NULL);
}
static int setup_post(daemon_state *s)
{
lvmetad_state *ls = s->private;
/* if (ls->initial_registrations)
_process_initial_registrations(ds->initial_registrations); */
return 1;
}
static void usage(char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
"%s [-V] [-h] [-d] [-d] [-d] [-f]\n\n"
" -V Show version of lvmetad\n"
" -h Show this help information\n"
" -d Log debug messages to syslog (-d, -dd, -ddd)\n"
" -R Replace a running lvmetad instance, loading its data\n"
" -f Don't fork, run in the foreground\n\n", prog);
}
int main(int argc, char *argv[])
{
signed char opt;
daemon_state s;
lvmetad_state ls;
int _restart = 0;
s.private = &ls;
s.setup_post = setup_post;
s.handler = handler;
s.socket_path = "/var/run/lvm/lvmetad.socket";
s.pidfile = "/var/run/lvm/lvmetad.pid";
while ((opt = getopt(argc, argv, "?fhVdR")) != EOF) {
switch (opt) {
case 'h':
usage(argv[0], stdout);
exit(0);
case '?':
usage(argv[0], stderr);
exit(0);
case 'R':
_restart++;
break;
case 'f':
s.foreground = 1;
break;
case 'd':
s.log_level++;
break;
case 'V':
printf("lvmetad version 0\n");
exit(1);
break;
}
}
daemon_start(s);
return 0;
}