]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/commands.h
use same ifndef/define format for all headers
[mirror_lxc.git] / src / lxc / commands.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2009
5 *
6 * Authors:
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef __LXC_COMMANDS_H
25 #define __LXC_COMMANDS_H
26
27 #include "state.h"
28
29 #define LXC_CMD_DATA_MAX (MAXPATHLEN*2)
30
31 /* https://developer.gnome.org/glib/2.28/glib-Type-Conversion-Macros.html */
32 #define INT_TO_PTR(n) ((void *) (long) (n))
33 #define PTR_TO_INT(p) ((int) (long) (p))
34
35 typedef enum {
36 LXC_CMD_CONSOLE,
37 LXC_CMD_CONSOLE_WINCH,
38 LXC_CMD_STOP,
39 LXC_CMD_GET_STATE,
40 LXC_CMD_GET_INIT_PID,
41 LXC_CMD_GET_CLONE_FLAGS,
42 LXC_CMD_GET_CGROUP,
43 LXC_CMD_GET_CONFIG_ITEM,
44 LXC_CMD_MAX,
45 } lxc_cmd_t;
46
47 struct lxc_cmd_req {
48 lxc_cmd_t cmd;
49 int datalen;
50 const void *data;
51 };
52
53 struct lxc_cmd_rsp {
54 int ret; /* 0 on success, -errno on failure */
55 int datalen;
56 void *data;
57 };
58
59 struct lxc_cmd_rr {
60 struct lxc_cmd_req req;
61 struct lxc_cmd_rsp rsp;
62 };
63
64 struct lxc_cmd_console_rsp_data {
65 int masterfd;
66 int ttynum;
67 };
68
69 extern int lxc_cmd_console_winch(const char *name, const char *lxcpath);
70 extern int lxc_cmd_console(const char *name, int *ttynum, int *fd,
71 const char *lxcpath);
72 /*
73 * Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container
74 * for a particular subsystem
75 */
76 extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
77 const char *subsystem);
78 extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath);
79 extern char *lxc_cmd_get_config_item(const char *name, const char *item, const char *lxcpath);
80 extern pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath);
81 extern lxc_state_t lxc_cmd_get_state(const char *name, const char *lxcpath);
82 extern int lxc_cmd_stop(const char *name, const char *lxcpath);
83
84 struct lxc_epoll_descr;
85 struct lxc_handler;
86
87 extern int lxc_cmd_init(const char *name, struct lxc_handler *handler,
88 const char *lxcpath);
89 extern int lxc_cmd_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
90 struct lxc_handler *handler);
91 extern int lxc_try_cmd(const char *name, const char *lxcpath);
92
93 #endif /* __commands_h */