* the slot with lxc_cmd_fd_cleanup(). The socket fd will be returned in the
* cmd response structure.
*/
-static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
+static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, bool *stopped,
const char *lxcpath, const char *hashed_sock_name)
{
__do_close int client_fd = -EBADF;
int lxc_try_cmd(const char *name, const char *lxcpath)
{
- int stopped, ret;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
- .req = { .cmd = LXC_CMD_GET_INIT_PID },
+ .req = {
+ .cmd = LXC_CMD_GET_INIT_PID,
+ },
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (stopped)
if (ret > 0)
return 0;
- /* At this point we weren't denied access, and the container *was*
+ /*
+ * At this point we weren't denied access, and the container *was*
* started. There was some inexplicable error in the protocol. I'm not
* clear on whether we should return -1 here, but we didn't receive a
* -EACCES, so technically it's not that we're not allowed to control
*/
pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
pid_t pid = -1;
struct lxc_cmd_rr cmd = {
.req = {
.data = PID_TO_PTR(pid)
}
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
if (pid < 0)
return -1;
- /* We need to assume that pid_t can actually hold any pid given to us
+ /*
+ * We need to assume that pid_t can actually hold any pid given to us
* by the kernel. If it can't it's a libc bug.
*/
return (pid_t)pid;
int lxc_cmd_get_init_pidfd(const char *name, const char *lxcpath)
{
- int pidfd;
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_INIT_PIDFD,
.ret = ENOSYS,
},
};
+ int pidfd, ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_devpts_fd(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_DEVPTS_FD,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_seccomp_notify_fd(const char *name, const char *lxcpath)
{
#ifdef HAVE_SECCOMP_NOTIFY
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_SECCOMP_NOTIFY_FD,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_cgroup_ctx(const char *name, const char *lxcpath,
size_t size_ret_ctx, struct cgroup_ctx *ret_ctx)
{
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_CGROUP_CTX,
.ret = -ENOSYS,
},
};
- int ret, stopped;
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
*/
int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_CLONE_FLAGS,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
const char *subsystem,
lxc_cmd_t command)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = command,
.datalen = 0,
},
};
+ int ret;
cmd.req.data = subsystem;
cmd.req.datalen = 0;
char *lxc_cmd_get_config_item(const char *name, const char *item,
const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = { .cmd = LXC_CMD_GET_CONFIG_ITEM,
.data = item,
.datalen = strlen(item) + 1,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
*/
int lxc_cmd_get_state(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_STATE,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0 && stopped)
*/
int lxc_cmd_stop(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_STOP,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0) {
int lxc_cmd_get_tty_fd(const char *name, int *ttynum, int *fd, const char *lxcpath)
{
__do_free struct lxc_cmd_tty_rsp_data *rspdata = NULL;
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_TTY_FD,
.data = INT_TO_PTR(*ttynum),
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
*/
char *lxc_cmd_get_name(const char *hashed_sock_name)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_NAME,
},
};
+ int ret;
ret = lxc_cmd(NULL, &cmd, &stopped, NULL, hashed_sock_name);
if (ret < 0)
*/
char *lxc_cmd_get_lxcpath(const char *hashed_sock_name)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_LXCPATH,
},
};
+ int ret;
ret = lxc_cmd(NULL, &cmd, &stopped, NULL, hashed_sock_name);
if (ret < 0)
int *state_client_fd)
{
__do_close int clientfd = -EBADF;
- int state, stopped;
- ssize_t ret;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_ADD_STATE_CLIENT,
.datalen = (sizeof(lxc_state_t) * MAX_STATE)
},
};
+ int state;
+ ssize_t ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (states[STOPPED] != 0 && stopped != 0)
int lxc_cmd_add_bpf_device_cgroup(const char *name, const char *lxcpath,
struct device_item *device)
{
- int stopped = 0;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_ADD_BPF_DEVICE_CGROUP,
int lxc_cmd_console_log(const char *name, const char *lxcpath,
struct lxc_console_log *log)
{
- int ret, stopped;
+ bool stopped = false;
+ int ret;
struct lxc_cmd_console_log data;
struct lxc_cmd_rr cmd;
int lxc_cmd_serve_state_clients(const char *name, const char *lxcpath,
lxc_state_t state)
{
- int stopped;
- ssize_t ret;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_SERVE_STATE_CLIENTS,
.data = INT_TO_PTR(state)
},
};
+ ssize_t ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
{
#ifdef HAVE_SECCOMP_NOTIFY
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_SECCOMP_NOTIFY_ADD_LISTENER,
.data = INT_TO_PTR(fd),
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_freeze(const char *name, const char *lxcpath, int timeout)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_FREEZE,
.data = INT_TO_PTR(timeout),
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret <= 0 || cmd.rsp.ret < 0)
int lxc_cmd_unfreeze(const char *name, const char *lxcpath, int timeout)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_UNFREEZE,
.data = INT_TO_PTR(timeout),
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret <= 0 || cmd.rsp.ret < 0)
int lxc_cmd_get_cgroup_fd(const char *name, const char *lxcpath,
size_t size_ret_fd, struct cgroup_fd *ret_fd)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_CGROUP_FD,
.data = ret_fd,
},
.rsp = {
- ret = -ENOSYS,
+ .ret = -ENOSYS,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_limit_cgroup_fd(const char *name, const char *lxcpath,
size_t size_ret_fd, struct cgroup_fd *ret_fd)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_LIMIT_CGROUP_FD,
.data = ret_fd,
},
.rsp = {
- ret = -ENOSYS,
+ .ret = -ENOSYS,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_cgroup2_fd(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_CGROUP2_FD,
},
.rsp = {
- ret = -ENOSYS,
+ .ret = -ENOSYS,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)
int lxc_cmd_get_limit_cgroup2_fd(const char *name, const char *lxcpath)
{
- int ret, stopped;
+ bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_GET_LIMIT_CGROUP2_FD,
.ret = -ENOSYS,
},
};
+ int ret;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0)