tree-wide: s/syerrno_set()/syserror_set()/g

parent 6d829cd2
...@@ -228,14 +228,14 @@ again: ...@@ -228,14 +228,14 @@ again:
for (idx = 0; idx < num_raw; idx++) for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]); close(fds_raw[idx]);
return syserrno_set(-EFBIG, "Received excessive number of file descriptors"); return syserror_set(-EFBIG, "Received excessive number of file descriptors");
} }
if (msg.msg_flags & MSG_CTRUNC) { if (msg.msg_flags & MSG_CTRUNC) {
for (idx = 0; idx < num_raw; idx++) for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]); close(fds_raw[idx]);
return syserrno_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message"); return syserror_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message");
} }
if (ret_fds->fd_count_max > num_raw) { if (ret_fds->fd_count_max > num_raw) {
...@@ -243,7 +243,7 @@ again: ...@@ -243,7 +243,7 @@ again:
for (idx = 0; idx < num_raw; idx++) for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]); close(fds_raw[idx]);
return syserrno_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u", return syserror_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u",
ret_fds->fd_count_max, num_raw); ret_fds->fd_count_max, num_raw);
} }
...@@ -261,7 +261,7 @@ again: ...@@ -261,7 +261,7 @@ again:
for (idx = 0; idx < num_raw; idx++) for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]); close(fds_raw[idx]);
return syserrno_set(-EINVAL, "Received more file descriptors than we expected %u != %u", return syserror_set(-EINVAL, "Received more file descriptors than we expected %u != %u",
ret_fds->fd_count_max, num_raw); ret_fds->fd_count_max, num_raw);
} }
...@@ -280,7 +280,7 @@ again: ...@@ -280,7 +280,7 @@ again:
for (idx = 0; idx < num_raw; idx++) for (idx = 0; idx < num_raw; idx++)
close(fds_raw[idx]); close(fds_raw[idx]);
return syserrno_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u", return syserror_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u",
ret_fds->fd_count_max, num_raw); ret_fds->fd_count_max, num_raw);
} }
...@@ -296,7 +296,7 @@ again: ...@@ -296,7 +296,7 @@ again:
/* We expected to receive file descriptors. */ /* We expected to receive file descriptors. */
if ((ret_fds->flags & UNIX_FDS_ACCEPT_MASK) && if ((ret_fds->flags & UNIX_FDS_ACCEPT_MASK) &&
!(ret_fds->flags & UNIX_FDS_ACCEPT_NONE)) !(ret_fds->flags & UNIX_FDS_ACCEPT_NONE))
return syserrno_set(-EINVAL, "Received no file descriptors"); return syserror_set(-EINVAL, "Received no file descriptors");
} }
return ret; return ret;
......
...@@ -425,7 +425,7 @@ static int cgroup_hierarchy_add(struct cgroup_ops *ops, int dfd_mnt, char *mnt, ...@@ -425,7 +425,7 @@ static int cgroup_hierarchy_add(struct cgroup_ops *ops, int dfd_mnt, char *mnt,
int idx; int idx;
if (abspath(base_cgroup)) if (abspath(base_cgroup))
return syserrno_set(-EINVAL, "Container base path must be relative to controller mount"); return syserror_set(-EINVAL, "Container base path must be relative to controller mount");
new = zalloc(sizeof(*new)); new = zalloc(sizeof(*new));
if (!new) if (!new)
...@@ -736,10 +736,10 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode, ...@@ -736,10 +736,10 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
* absolute nor walks upwards. * absolute nor walks upwards.
*/ */
if (abspath(cur)) if (abspath(cur))
return syserrno_set(-EINVAL, "No absolute paths allowed"); return syserror_set(-EINVAL, "No absolute paths allowed");
if (strnequal(cur, "..", STRLITERALLEN(".."))) if (strnequal(cur, "..", STRLITERALLEN("..")))
return syserrno_set(-EINVAL, "No upward walking paths allowed"); return syserror_set(-EINVAL, "No upward walking paths allowed");
ret = mkdirat(dfd_cur, cur, mode); ret = mkdirat(dfd_cur, cur, mode);
if (ret < 0) { if (ret < 0) {
...@@ -768,7 +768,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode, ...@@ -768,7 +768,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
/* The final cgroup must be succesfully creatd by us. */ /* The final cgroup must be succesfully creatd by us. */
if (ret) { if (ret) {
if (ret != -EEXIST || !eexist_ignore) if (ret != -EEXIST || !eexist_ignore)
return syserrno_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path); return syserror_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path);
} }
return move_fd(dfd_final); return move_fd(dfd_final);
...@@ -1339,7 +1339,7 @@ static int chown_cgroup_wrapper(void *data) ...@@ -1339,7 +1339,7 @@ static int chown_cgroup_wrapper(void *data)
int dirfd = arg->hierarchies[i]->dfd_con; int dirfd = arg->hierarchies[i]->dfd_con;
if (dirfd < 0) if (dirfd < 0)
return syserrno_set(-EBADF, "Invalid cgroup file descriptor"); return syserror_set(-EBADF, "Invalid cgroup file descriptor");
(void)fchowmodat(dirfd, "", destuid, nsgid, 0775); (void)fchowmodat(dirfd, "", destuid, nsgid, 0775);
...@@ -2787,7 +2787,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops, ...@@ -2787,7 +2787,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
else else
ret = device_cgroup_rule_parse(&device_item, key, val); ret = device_cgroup_rule_parse(&device_item, key, val);
if (ret < 0) if (ret < 0)
return syserrno_set(EINVAL, "Failed to parse device rule %s=%s", key, val); return syserror_set(EINVAL, "Failed to parse device rule %s=%s", key, val);
/* /*
* Note that bpf_list_add_device() returns 1 if it altered the device * Note that bpf_list_add_device() returns 1 if it altered the device
...@@ -2930,10 +2930,10 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg ...@@ -2930,10 +2930,10 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
* absolute nor walks upwards. * absolute nor walks upwards.
*/ */
if (abspath(cur)) if (abspath(cur))
return syserrno_set(-EINVAL, "No absolute paths allowed"); return syserror_set(-EINVAL, "No absolute paths allowed");
if (strnequal(cur, "..", STRLITERALLEN(".."))) if (strnequal(cur, "..", STRLITERALLEN("..")))
return syserrno_set(-EINVAL, "No upward walking paths allowed"); return syserror_set(-EINVAL, "No upward walking paths allowed");
ret = lxc_writeat(dfd_cur, "cgroup.subtree_control", add_controllers, full_len); ret = lxc_writeat(dfd_cur, "cgroup.subtree_control", add_controllers, full_len);
if (ret < 0) if (ret < 0)
...@@ -3258,7 +3258,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3258,7 +3258,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
} }
if (!controllers_available(ops)) if (!controllers_available(ops))
return syserrno_set(-ENOENT, "One or more requested controllers unavailable or not delegated"); return syserror_set(-ENOENT, "One or more requested controllers unavailable or not delegated");
return 0; return 0;
} }
...@@ -3436,7 +3436,7 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name, ...@@ -3436,7 +3436,7 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
} }
if (idx == 0) if (idx == 0)
return syserrno_set(-ENOENT, "Failed to attach to cgroups"); return syserror_set(-ENOENT, "Failed to attach to cgroups");
TRACE("Attached to %s cgroup layout", cgroup_layout_name(ctx->layout)); TRACE("Attached to %s cgroup layout", cgroup_layout_name(ctx->layout));
return 0; return 0;
......
...@@ -352,7 +352,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type, ...@@ -352,7 +352,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
return ret_errno(EBADF); return ret_errno(EBADF);
if (flags & ~(BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI | BPF_F_REPLACE)) if (flags & ~(BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI | BPF_F_REPLACE))
return syserrno_set(-EINVAL, "Invalid flags for bpf program"); return syserror_set(-EINVAL, "Invalid flags for bpf program");
/* /*
* Don't allow the bpf program to be overwritten for now. If we ever * Don't allow the bpf program to be overwritten for now. If we ever
...@@ -513,11 +513,11 @@ int bpf_list_add_device(struct bpf_devices *bpf_devices, ...@@ -513,11 +513,11 @@ int bpf_list_add_device(struct bpf_devices *bpf_devices,
list_elem = malloc(sizeof(*list_elem)); list_elem = malloc(sizeof(*list_elem));
if (!list_elem) if (!list_elem)
return syserrno_set(ENOMEM, "Failed to allocate new device list"); return syserror_set(ENOMEM, "Failed to allocate new device list");
new_device = memdup(device, sizeof(struct device_item)); new_device = memdup(device, sizeof(struct device_item));
if (!new_device) if (!new_device)
return syserrno_set(ENOMEM, "Failed to allocate new device item"); return syserror_set(ENOMEM, "Failed to allocate new device item");
lxc_list_add_elem(list_elem, move_ptr(new_device)); lxc_list_add_elem(list_elem, move_ptr(new_device));
lxc_list_add_tail(&bpf_devices->device_item, move_ptr(list_elem)); lxc_list_add_tail(&bpf_devices->device_item, move_ptr(list_elem));
......
...@@ -231,7 +231,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd) ...@@ -231,7 +231,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
*/ */
if ((rsp->datalen > LXC_CMD_DATA_MAX) && if ((rsp->datalen > LXC_CMD_DATA_MAX) &&
(cur_cmd != LXC_CMD_CONSOLE_LOG)) (cur_cmd != LXC_CMD_CONSOLE_LOG))
return syserrno_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d", return syserror_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d",
cur_cmdstr, rsp->datalen, LXC_CMD_DATA_MAX); cur_cmdstr, rsp->datalen, LXC_CMD_DATA_MAX);
/* /*
...@@ -254,14 +254,14 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd) ...@@ -254,14 +254,14 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
__fallthrough; __fallthrough;
case LXC_CMD_GET_LIMIT_CGROUP_FD: /* data */ case LXC_CMD_GET_LIMIT_CGROUP_FD: /* data */
if (rsp->datalen > sizeof(struct cgroup_fd)) if (rsp->datalen > sizeof(struct cgroup_fd))
return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr); return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
/* Don't pointlessly allocate. */ /* Don't pointlessly allocate. */
rsp->data = (void *)cmd->req.data; rsp->data = (void *)cmd->req.data;
break; break;
case LXC_CMD_GET_CGROUP_CTX: /* data */ case LXC_CMD_GET_CGROUP_CTX: /* data */
if (rsp->datalen > sizeof(struct cgroup_ctx)) if (rsp->datalen > sizeof(struct cgroup_ctx))
return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr); return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
/* Don't pointlessly allocate. */ /* Don't pointlessly allocate. */
rsp->data = (void *)cmd->req.data; rsp->data = (void *)cmd->req.data;
...@@ -284,7 +284,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd) ...@@ -284,7 +284,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
rsp->data = tty; rsp->data = tty;
break; break;
} }
return syserrno_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr); return syserror_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr);
case LXC_CMD_CONSOLE_LOG: /* data */ case LXC_CMD_CONSOLE_LOG: /* data */
__data = zalloc(rsp->datalen + 1); __data = zalloc(rsp->datalen + 1);
rsp->data = __data; rsp->data = __data;
...@@ -305,7 +305,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd) ...@@ -305,7 +305,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
* Either static or allocated memory. * Either static or allocated memory.
*/ */
if (!rsp->data) if (!rsp->data)
return syserrno_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"", return syserror_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"",
cur_cmdstr); cur_cmdstr);
bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0); bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0);
...@@ -744,7 +744,7 @@ static int lxc_cmd_get_seccomp_notify_fd_callback(int fd, struct lxc_cmd_req *re ...@@ -744,7 +744,7 @@ static int lxc_cmd_get_seccomp_notify_fd_callback(int fd, struct lxc_cmd_req *re
rsp.ret = 0; rsp.ret = 0;
return rsp_one_fd_reap(fd, handler->conf->seccomp.notifier.notify_fd, &rsp); return rsp_one_fd_reap(fd, handler->conf->seccomp.notifier.notify_fd, &rsp);
#else #else
return syserrno_set(-EOPNOTSUPP, "Seccomp notifier not supported"); return syserror_set(-EOPNOTSUPP, "Seccomp notifier not supported");
#endif #endif
} }
...@@ -1388,17 +1388,17 @@ int lxc_cmd_add_bpf_device_cgroup(const char *name, const char *lxcpath, ...@@ -1388,17 +1388,17 @@ int lxc_cmd_add_bpf_device_cgroup(const char *name, const char *lxcpath,
struct lxc_cmd_rr cmd; struct lxc_cmd_rr cmd;
if (strlen(device->access) > STRLITERALLEN("rwm")) if (strlen(device->access) > STRLITERALLEN("rwm"))
return syserrno_set(-EINVAL, "Invalid access mode specified %s", device->access); return syserror_set(-EINVAL, "Invalid access mode specified %s", device->access);
lxc_cmd_init(&cmd, LXC_CMD_ADD_BPF_DEVICE_CGROUP); lxc_cmd_init(&cmd, LXC_CMD_ADD_BPF_DEVICE_CGROUP);
lxc_cmd_data(&cmd, sizeof(struct device_item), device); lxc_cmd_data(&cmd, sizeof(struct device_item), device);
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL); ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0) if (ret < 0)
return syserrno_set(ret, "Failed to process new bpf device cgroup command"); return syserror_set(ret, "Failed to process new bpf device cgroup command");
if (cmd.rsp.ret < 0) if (cmd.rsp.ret < 0)
return syserrno_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule"); return syserror_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule");
return 0; return 0;
} }
...@@ -1856,7 +1856,7 @@ static int lxc_cmd_rsp_send_enosys(int fd, int id) ...@@ -1856,7 +1856,7 @@ static int lxc_cmd_rsp_send_enosys(int fd, int id)
}; };
__lxc_cmd_rsp_send(fd, &rsp); __lxc_cmd_rsp_send(fd, &rsp);
return syserrno_set(-ENOSYS, "Invalid command id %d", id); return syserror_set(-ENOSYS, "Invalid command id %d", id);
} }
static int lxc_cmd_process(int fd, struct lxc_cmd_req *req, static int lxc_cmd_process(int fd, struct lxc_cmd_req *req,
......
...@@ -1825,10 +1825,10 @@ static int set_config_cgroup_dir(const char *key, const char *value, ...@@ -1825,10 +1825,10 @@ static int set_config_cgroup_dir(const char *key, const char *value,
return clr_config_cgroup_dir(key, lxc_conf, NULL); return clr_config_cgroup_dir(key, lxc_conf, NULL);
if (abspath(value)) if (abspath(value))
return syserrno_set(-EINVAL, "%s paths may not be absolute", key); return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value)) if (dotdot(value))
return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key); return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.dir, value); return set_config_path_item(&lxc_conf->cgroup_meta.dir, value);
} }
...@@ -1840,10 +1840,10 @@ static int set_config_cgroup_monitor_dir(const char *key, const char *value, ...@@ -1840,10 +1840,10 @@ static int set_config_cgroup_monitor_dir(const char *key, const char *value,
return clr_config_cgroup_monitor_dir(key, lxc_conf, NULL); return clr_config_cgroup_monitor_dir(key, lxc_conf, NULL);
if (abspath(value)) if (abspath(value))
return syserrno_set(-EINVAL, "%s paths may not be absolute", key); return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value)) if (dotdot(value))
return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key); return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.monitor_dir, value); return set_config_path_item(&lxc_conf->cgroup_meta.monitor_dir, value);
} }
...@@ -1855,10 +1855,10 @@ static int set_config_cgroup_monitor_pivot_dir(const char *key, const char *valu ...@@ -1855,10 +1855,10 @@ static int set_config_cgroup_monitor_pivot_dir(const char *key, const char *valu
return clr_config_cgroup_monitor_pivot_dir(key, lxc_conf, NULL); return clr_config_cgroup_monitor_pivot_dir(key, lxc_conf, NULL);
if (abspath(value)) if (abspath(value))
return syserrno_set(-EINVAL, "%s paths may not be absolute", key); return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value)) if (dotdot(value))
return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key); return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.monitor_pivot_dir, value); return set_config_path_item(&lxc_conf->cgroup_meta.monitor_pivot_dir, value);
} }
...@@ -1871,10 +1871,10 @@ static int set_config_cgroup_container_dir(const char *key, const char *value, ...@@ -1871,10 +1871,10 @@ static int set_config_cgroup_container_dir(const char *key, const char *value,
return clr_config_cgroup_container_dir(key, lxc_conf, NULL); return clr_config_cgroup_container_dir(key, lxc_conf, NULL);
if (abspath(value)) if (abspath(value))
return syserrno_set(-EINVAL, "%s paths may not be absolute", key); return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (dotdot(value)) if (dotdot(value))
return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key); return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
return set_config_path_item(&lxc_conf->cgroup_meta.container_dir, value); return set_config_path_item(&lxc_conf->cgroup_meta.container_dir, value);
} }
...@@ -1888,7 +1888,7 @@ static int set_config_cgroup_container_inner_dir(const char *key, ...@@ -1888,7 +1888,7 @@ static int set_config_cgroup_container_inner_dir(const char *key,
return clr_config_cgroup_container_inner_dir(key, lxc_conf, NULL); return clr_config_cgroup_container_inner_dir(key, lxc_conf, NULL);
if (abspath(value)) if (abspath(value))
return syserrno_set(-EINVAL, "%s paths may not be absolute", key); return syserror_set(-EINVAL, "%s paths may not be absolute", key);
if (strchr(value, '/') || strequal(value, ".") || strequal(value, "..")) if (strchr(value, '/') || strequal(value, ".") || strequal(value, ".."))
return log_error_errno(-EINVAL, EINVAL, "lxc.cgroup.dir.container.inner must be a single directory name"); return log_error_errno(-EINVAL, EINVAL, "lxc.cgroup.dir.container.inner must be a single directory name");
......
...@@ -522,14 +522,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ ...@@ -522,14 +522,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \ __internal_ret__; \
}) })
#define syserrno_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
errno = labs(__ret__); \
SYSERROR(format, ##__VA_ARGS__); \
__internal_ret__; \
})
#define syswarn_set(__ret__, format, ...) \ #define syswarn_set(__ret__, format, ...) \
({ \ ({ \
typeof(__ret__) __internal_ret__ = (__ret__); \ typeof(__ret__) __internal_ret__ = (__ret__); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment