]> sourceware.org Git - lvm2.git/blame - daemons/common/daemon-client.h
More scavenging of common daemon code, this time the clvmd local socket setup
[lvm2.git] / daemons / common / daemon-client.h
CommitLineData
56517bad
PR
1/*
2 * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
3 *
4 * This file is part of LVM2.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU Lesser General Public License v.2.1.
9 *
10 * You should have received a copy of the GNU Lesser General Public License
11 * along with this program; if not, write to the Free Software Foundation,
12 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13 */
14
15#ifndef _LVM_DAEMON_COMMON_CLIENT_H
16#define _LVM_DAEMON_COMMON_CLIENT_H
17
18typedef struct {
19 int socket_fd; /* the fd we use to talk to the daemon */
20 int protocol; /* version of the protocol the daemon uses */
21 char *read_buf;
22} daemon_handle;
23
24typedef struct {
25 const char *path; /* the binary of the daemon */
26 const char *socket; /* path to the comms socket */
27 unsigned autostart:1; /* start the daemon if not running? */
28} daemon_info;
29
30typedef struct {
31 char *request;
32} daemon_request;
33
34typedef struct {
35 int errno; /* 0 for success */
36 char *reply; /* textual reply */
37 struct config_tree *cft; /* parsed reply, if available */
38} daemon_reply;
39
40/*
41 * Open the communication channel to the daemon. If the daemon is not running,
42 * it may be autostarted based on the binary path provided in the info (this
43 * will only happen if autostart is set to true). If the call fails for any
44 * reason, daemon_handle_valid(h) for the response will return false. Otherwise,
45 * the connection is good to start serving requests.
46 */
47daemon_handle daemon_open(daemon_info i);
48
49/*
50 * Send a request to the daemon, waiting for the reply. All communication with
51 * the daemon is synchronous. The function handles the IO details and parses the
52 * response, handling common error conditions. See "daemon_reply" for details.
53 */
54daemon_reply daemon_request(daemon_handle h, daemon_request r);
55
56/* Shut down the communication to the daemon. Compulsory. */
57void daemon_close(daemon_handle h);
58
59#endif
This page took 0.026176 seconds and 5 git commands to generate.