tree-wide: start replacing instances of syserrno() with syserror()

parent 060aaa39
...@@ -198,7 +198,7 @@ again: ...@@ -198,7 +198,7 @@ again:
if (errno == EINTR) if (errno == EINTR)
goto again; goto again;
return syserrno(-errno, "Failed to receive response"); return syserror("Failed to receive response");
} }
if (ret == 0) if (ret == 0)
return 0; return 0;
......
...@@ -512,7 +512,7 @@ static int same_ns(int dfd_pid1, int dfd_pid2, const char *ns_path) ...@@ -512,7 +512,7 @@ static int same_ns(int dfd_pid1, int dfd_pid2, const char *ns_path)
if (ns_fd2 < 0) { if (ns_fd2 < 0) {
if (errno == ENOENT) if (errno == ENOENT)
return -ENOENT; return -ENOENT;
return syserrno(-errno, "Failed to open %d(%s)", dfd_pid2, ns_path); return syserror("Failed to open %d(%s)", dfd_pid2, ns_path);
} }
ret = same_nsfd(dfd_pid1, dfd_pid2, ns_path); ret = same_nsfd(dfd_pid1, dfd_pid2, ns_path);
...@@ -551,7 +551,7 @@ static int __prepare_namespaces_pidfd(struct attach_context *ctx) ...@@ -551,7 +551,7 @@ static int __prepare_namespaces_pidfd(struct attach_context *ctx)
break; break;
} }
return syserrno(-errno, "Failed to determine whether %s namespace is shared", return syserror("Failed to determine whether %s namespace is shared",
ns_info[i].proc_name); ns_info[i].proc_name);
} }
......
...@@ -744,7 +744,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode, ...@@ -744,7 +744,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
ret = mkdirat(dfd_cur, cur, mode); ret = mkdirat(dfd_cur, cur, mode);
if (ret < 0) { if (ret < 0) {
if (errno != EEXIST) if (errno != EEXIST)
return syserrno(-errno, "Failed to create %d(%s)", dfd_cur, cur); return syserror("Failed to create %d(%s)", dfd_cur, cur);
ret = -EEXIST; ret = -EEXIST;
} }
...@@ -752,12 +752,12 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode, ...@@ -752,12 +752,12 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
dfd_final = open_at(dfd_cur, cur, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH, 0); dfd_final = open_at(dfd_cur, cur, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH, 0);
if (dfd_final < 0) if (dfd_final < 0)
return syserrno(-errno, "Fail to open%s directory %d(%s)", return syserror("Fail to open%s directory %d(%s)",
!ret ? " newly created" : "", dfd_base, cur); !ret ? " newly created" : "", dfd_base, cur);
if (dfd_cur != dfd_base) if (dfd_cur != dfd_base)
close(dfd_cur); close(dfd_cur);
else if (cpuset_v1 && !cpuset1_initialize(dfd_base, dfd_final)) else if (cpuset_v1 && !cpuset1_initialize(dfd_base, dfd_final))
return syserrno(-EINVAL, "Failed to initialize cpuset controller in the legacy hierarchy"); return syserror_set(-EINVAL, "Failed to initialize cpuset controller in the legacy hierarchy");
/* /*
* Leave dfd_final pointing to the last fd we opened so * Leave dfd_final pointing to the last fd we opened so
* it will be automatically zapped if we return early. * it will be automatically zapped if we return early.
...@@ -1695,7 +1695,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1695,7 +1695,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
dfd_mnt_unified = open_at(rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE, dfd_mnt_unified = open_at(rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE,
PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_mnt_unified < 0) if (dfd_mnt_unified < 0)
return syserrno(-errno, "Failed to open %d(%s)", rootfs->dfd_mnt, return syserrno(false, "Failed to open %d(%s)", rootfs->dfd_mnt,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
/* /*
* If cgroup namespaces are supported but the container will * If cgroup namespaces are supported but the container will
...@@ -1798,7 +1798,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1798,7 +1798,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
dfd_mnt_tmpfs = open_at(rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE, dfd_mnt_tmpfs = open_at(rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE,
PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_mnt_tmpfs < 0) if (dfd_mnt_tmpfs < 0)
return syserrno(-errno, "Failed to open %d(%s)", rootfs->dfd_mnt, return syserrno(false, "Failed to open %d(%s)", rootfs->dfd_mnt,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
for (int i = 0; ops->hierarchies[i]; i++) { for (int i = 0; ops->hierarchies[i]; i++) {
...@@ -2937,13 +2937,13 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg ...@@ -2937,13 +2937,13 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
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)
return syserrno(-errno, "Could not enable \"%s\" controllers in the unified cgroup %d", add_controllers, dfd_cur); return syserror("Could not enable \"%s\" controllers in the unified cgroup %d", add_controllers, dfd_cur);
TRACE("Enabled \"%s\" controllers in the unified cgroup %d", add_controllers, dfd_cur); TRACE("Enabled \"%s\" controllers in the unified cgroup %d", add_controllers, dfd_cur);
dfd_final = open_at(dfd_cur, cur, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH, 0); dfd_final = open_at(dfd_cur, cur, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH, 0);
if (dfd_final < 0) if (dfd_final < 0)
return syserrno(-errno, "Fail to open directory %d(%s)", dfd_cur, cur); return syserror("Fail to open directory %d(%s)", dfd_cur, cur);
if (dfd_cur != unified->dfd_base) if (dfd_cur != unified->dfd_base)
close(dfd_cur); close(dfd_cur);
/* /*
...@@ -3126,7 +3126,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3126,7 +3126,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
} }
if (dfd_mnt < 0) { if (dfd_mnt < 0) {
if (errno != ENOENT) if (errno != ENOENT)
return syserrno(-errno, "Failed to open %d/unified", ops->dfd_mnt); return syserror("Failed to open %d/unified", ops->dfd_mnt);
SYSTRACE("Unified cgroup not mounted"); SYSTRACE("Unified cgroup not mounted");
continue; continue;
...@@ -3138,7 +3138,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3138,7 +3138,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_base < 0) if (dfd_base < 0)
return syserrno(-errno, "Failed to open %d/%s", dfd_mnt, current_cgroup); return syserror("Failed to open %d/%s", dfd_mnt, current_cgroup);
dfd = dfd_base; dfd = dfd_base;
} }
...@@ -3150,7 +3150,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3150,7 +3150,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
TRACE("No controllers are enabled for delegation in the unified hierarchy"); TRACE("No controllers are enabled for delegation in the unified hierarchy");
controller_list = list_new(); controller_list = list_new();
if (!controller_list) if (!controller_list)
return syserrno(-ENOMEM, "Failed to create empty controller list"); return syserror_set(-ENOMEM, "Failed to create empty controller list");
} }
controllers = strdup(unified_mnt); controllers = strdup(unified_mnt);
...@@ -3181,7 +3181,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3181,7 +3181,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
if (dfd_mnt < 0) { if (dfd_mnt < 0) {
if (errno != ENOENT) if (errno != ENOENT)
return syserrno(-errno, "Failed to open %d/%s", return syserror("Failed to open %d/%s",
ops->dfd_mnt, controllers); ops->dfd_mnt, controllers);
SYSTRACE("%s not mounted", controllers); SYSTRACE("%s not mounted", controllers);
...@@ -3208,7 +3208,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3208,7 +3208,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH_XDEV, 0); PROTECT_LOOKUP_BENEATH_XDEV, 0);
if (dfd_base < 0) if (dfd_base < 0)
return syserrno(-errno, "Failed to open %d/%s", return syserror("Failed to open %d/%s",
dfd_mnt, current_cgroup); dfd_mnt, current_cgroup);
dfd = dfd_base; dfd = dfd_base;
} }
...@@ -3223,7 +3223,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3223,7 +3223,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
*/ */
controller_list = list_add_controllers(__controllers); controller_list = list_add_controllers(__controllers);
if (!controller_list) if (!controller_list)
return syserrno(-ENOMEM, "Failed to create controller list from %s", __controllers); return syserror_set(-ENOMEM, "Failed to create controller list from %s", __controllers);
if (skip_hierarchy(ops, controller_list)) if (skip_hierarchy(ops, controller_list))
continue; continue;
...@@ -3280,7 +3280,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf) ...@@ -3280,7 +3280,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf)
dfd = open_at(-EBADF, DEFAULT_CGROUP_MOUNTPOINT, dfd = open_at(-EBADF, DEFAULT_CGROUP_MOUNTPOINT,
PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
if (dfd < 0) if (dfd < 0)
return syserrno(-errno, "Failed to open " DEFAULT_CGROUP_MOUNTPOINT); return syserror("Failed to open " DEFAULT_CGROUP_MOUNTPOINT);
controllers_use = lxc_global_config_value("lxc.cgroup.use"); controllers_use = lxc_global_config_value("lxc.cgroup.use");
if (controllers_use) { if (controllers_use) {
......
...@@ -369,7 +369,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type, ...@@ -369,7 +369,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
ret = bpf_program_load_kernel(prog); ret = bpf_program_load_kernel(prog);
if (ret < 0) if (ret < 0)
return syserrno(-errno, "Failed to load bpf program"); return syserror("Failed to load bpf program");
attr = &(union bpf_attr){ attr = &(union bpf_attr){
.attach_type = type, .attach_type = type,
...@@ -380,7 +380,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type, ...@@ -380,7 +380,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
ret = bpf(BPF_PROG_ATTACH, attr, sizeof(*attr)); ret = bpf(BPF_PROG_ATTACH, attr, sizeof(*attr));
if (ret < 0) if (ret < 0)
return syserrno(-errno, "Failed to attach bpf program"); return syserror("Failed to attach bpf program");
prog->fd_cgroup = move_fd(fd_attach); prog->fd_cgroup = move_fd(fd_attach);
prog->attached_type = type; prog->attached_type = type;
...@@ -414,7 +414,7 @@ int bpf_program_cgroup_detach(struct bpf_program *prog) ...@@ -414,7 +414,7 @@ int bpf_program_cgroup_detach(struct bpf_program *prog)
ret = bpf(BPF_PROG_DETACH, attr, sizeof(*attr)); ret = bpf(BPF_PROG_DETACH, attr, sizeof(*attr));
if (ret < 0) if (ret < 0)
return syserrno(-errno, "Failed to detach bpf program from cgroup %d", fd_cgroup); return syserror("Failed to detach bpf program from cgroup %d", fd_cgroup);
TRACE("Detached bpf program from cgroup %d", fd_cgroup); TRACE("Detached bpf program from cgroup %d", fd_cgroup);
......
...@@ -310,7 +310,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd) ...@@ -310,7 +310,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0); bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0);
if (bytes_recv != rsp->datalen) if (bytes_recv != rsp->datalen)
return syserrno(-errno, "Failed to receive response data for command \"%s\": %zd != %d", return syserror("Failed to receive response data for command \"%s\": %zd != %d",
cur_cmdstr, bytes_recv, rsp->datalen); cur_cmdstr, bytes_recv, rsp->datalen);
switch (cur_cmd) { switch (cur_cmd) {
...@@ -347,7 +347,7 @@ static int __lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp) ...@@ -347,7 +347,7 @@ static int __lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
ret = lxc_send_nointr(fd, rsp, sizeof(*rsp), MSG_NOSIGNAL); ret = lxc_send_nointr(fd, rsp, sizeof(*rsp), MSG_NOSIGNAL);
if (ret < 0 || (size_t)ret != sizeof(*rsp)) if (ret < 0 || (size_t)ret != sizeof(*rsp))
return syserrno(-errno, "Failed to send command response %zd", ret); return syserror("Failed to send command response %zd", ret);
if (!rsp->data || rsp->datalen <= 0) if (!rsp->data || rsp->datalen <= 0)
return 0; return 0;
......
...@@ -1842,7 +1842,7 @@ static int lxc_setup_console(const struct lxc_handler *handler, ...@@ -1842,7 +1842,7 @@ static int lxc_setup_console(const struct lxc_handler *handler,
else else
ret = lxc_terminal_set_stdfds(fd_pty); ret = lxc_terminal_set_stdfds(fd_pty);
if (ret < 0) if (ret < 0)
return syserrno(-errno, "Failed to redirect std{in,out,err} to pty file descriptor %d", fd_pty); return syserror("Failed to redirect std{in,out,err} to pty file descriptor %d", fd_pty);
} }
return ret; return ret;
......
...@@ -654,7 +654,7 @@ int set_config_path_item(char **conf_item, const char *value) ...@@ -654,7 +654,7 @@ int set_config_path_item(char **conf_item, const char *value)
normalized = lxc_deslashify(value); normalized = lxc_deslashify(value);
if (!normalized) if (!normalized)
return syserrno(-errno, "Failed to normalize path config item"); return syserror_set(-ENOMEM, "Failed to normalize path config item");
return set_config_string_item_max(conf_item, normalized, PATH_MAX); return set_config_string_item_max(conf_item, normalized, PATH_MAX);
} }
......
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