]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/commands_utils.h
tools: lxc-unshare: remove unnecessary initialization
[mirror_lxc.git] / src / lxc / commands_utils.h
1 /* liblxcapi
2 *
3 * Copyright © 2017 Christian Brauner <christian.brauner@ubuntu.com>.
4 * Copyright © 2017 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef __LXC_COMMANDS_UTILS_H
21 #define __LXC_COMMANDS_UTILS_H
22
23 #include <stdio.h>
24
25 #include "state.h"
26 #include "commands.h"
27
28 int lxc_make_abstract_socket_name(char *path, int len, const char *lxcname,
29 const char *lxcpath,
30 const char *hashed_sock_name,
31 const char *suffix);
32
33 /* lxc_cmd_sock_get_state Register a new state client fd in the container's
34 * in-memory handler and retrieve the requested
35 * states.
36 *
37 * @param[in] name Name of container to connect to.
38 * @param[in] lxcpath The lxcpath in which the container is running.
39 * @param[in] states The states to wait for.
40 * @return Return < 0 on error
41 * < MAX_STATE current container state
42 */
43 extern int lxc_cmd_sock_get_state(const char *name, const char *lxcpath,
44 lxc_state_t states[MAX_STATE], int timeout);
45
46 /* lxc_cmd_sock_rcv_state Retrieve the requested state from a state client
47 * fd registerd in the container's in-memory
48 * handler.
49 *
50 * @param[int] state_client_fd The state client fd from which the state can be
51 * received.
52 * @return Return < 0 on error
53 * < MAX_STATE current container state
54 */
55 extern int lxc_cmd_sock_rcv_state(int state_client_fd, int timeout);
56
57 /* lxc_add_state_client Add a new state client to the container's
58 * in-memory handler.
59 *
60 * @param[int] state_client_fd The state client fd to add.
61 * @param[int] handler The container's in-memory handler.
62 * @param[in] states The states to wait for.
63 *
64 * @return Return < 0 on error
65 * 0 on success
66 */
67 extern int lxc_add_state_client(int state_client_fd,
68 struct lxc_handler *handler,
69 lxc_state_t states[MAX_STATE]);
70
71 /* lxc_cmd_connect Connect to the container's command socket.
72 *
73 * @param[in] name Name of container to connect to.
74 * @param[in] lxcpath The lxcpath in which the container is running.
75 * @param[in] hashed_sock_name The hashed name of the socket (optional). Can be
76 * NULL.
77 *
78 * @return Return < 0 on error
79 * >= 0 client fd
80 */
81 extern int lxc_cmd_connect(const char *name, const char *lxcpath,
82 const char *hashed_sock_name, const char *suffix);
83
84 #endif /* __LXC_COMMANDS_UTILS_H */