iSulad/0137-2172-remove-unneccessary-strerror.patch
openeuler-sync-bot bc22968026 !624 [sync] PR-623: upgrade from upstream
* upgrade from upstream
2023-09-19 02:54:09 +00:00

2375 lines
100 KiB
Diff

From 4cf70f7ceba532c7b8ad9142744fdb21baf390f2 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 5 Sep 2023 11:38:58 +0000
Subject: [PATCH 137/145] !2172 remove unneccessary strerror * remove
unneccessary strerror
---
src/cmd/isula/base/start.c | 2 +-
src/cmd/isula/images/images.c | 2 +-
src/cmd/isula/isula_host_spec.c | 2 +-
src/cmd/isula/stream/exec.c | 4 +-
src/cmd/isulad/main.c | 22 ++--
src/daemon/common/sysinfo.c | 10 +-
src/daemon/entry/connect/grpc/grpc_service.cc | 2 +-
src/daemon/entry/connect/rest/rest_service.c | 4 +-
.../cri_pod_sandbox_manager_service_impl.cc | 2 +-
.../entry/cri/websocket/service/ws_server.cc | 8 +-
src/daemon/executor/container_cb/execution.c | 8 +-
.../executor/container_cb/execution_stream.c | 20 +--
.../container/container_gc/containers_gc.c | 4 +-
src/daemon/modules/container/container_unix.c | 2 +-
.../container/leftover_cleanup/cleanup.c | 2 +-
.../modules/container/supervisor/supervisor.c | 6 +-
src/daemon/modules/events/monitord.c | 8 +-
.../modules/events_sender/event_sender.c | 2 +-
.../modules/image/embedded/db/sqlite_common.c | 2 +-
src/daemon/modules/image/external/ext_image.c | 2 +-
.../modules/image/image_rootfs_handler.c | 4 +-
src/daemon/modules/image/oci/oci_load.c | 2 +-
.../modules/image/oci/registry/registry.c | 11 +-
.../graphdriver/devmapper/deviceset.c | 10 +-
.../graphdriver/devmapper/wrapper_devmapper.c | 4 +-
.../oci/storage/layer_store/layer_store.c | 10 +-
.../modules/image/oci/storage/storage.c | 2 +-
src/daemon/modules/image/oci/utils_images.c | 6 +-
src/daemon/modules/log/log_gather.c | 4 +-
.../modules/runtime/engines/lcr/lcr_rt_ops.c | 6 +-
.../modules/runtime/isula/isula_rt_ops.c | 10 +-
src/daemon/modules/runtime/shim/shim_rt_ops.c | 4 +-
src/daemon/modules/service/io_handler.c | 4 +-
.../modules/service/network_namespace_api.c | 2 +-
.../modules/service/service_container.c | 15 ++-
src/daemon/modules/spec/specs.c | 2 +-
src/daemon/modules/spec/specs_mount.c | 4 +-
src/daemon/modules/spec/verify.c | 6 +-
src/daemon/modules/volume/local.c | 12 +-
src/utils/console/console.c | 14 +--
src/utils/cutils/path.c | 4 +-
src/utils/cutils/utils.c | 10 +-
src/utils/cutils/utils_aes.c | 16 +--
src/utils/cutils/utils_base64.c | 4 +-
src/utils/cutils/utils_file.c | 84 ++++++-------
src/utils/cutils/utils_fs.c | 12 +-
src/utils/cutils/utils_verify.c | 2 +-
src/utils/http/http.c | 2 +-
src/utils/sha256/sha256.c | 8 +-
src/utils/tar/isulad_tar.c | 12 +-
src/utils/tar/util_archive.c | 118 ++++++++----------
src/utils/tar/util_gzip.c | 12 +-
52 files changed, 256 insertions(+), 274 deletions(-)
diff --git a/src/cmd/isula/base/start.c b/src/cmd/isula/base/start.c
index ca3634e1..1d0f1256 100644
--- a/src/cmd/isula/base/start.c
+++ b/src/cmd/isula/base/start.c
@@ -200,7 +200,7 @@ void client_wait_fifo_exit(const struct client_arguments *args)
void client_restore_console(bool reset_tty, const struct termios *oldtios, struct command_fifo_config *console_fifos)
{
if (reset_tty && tcsetattr(0, TCSAFLUSH, oldtios) < 0) {
- WARN("Failed to reset terminal properties: %s.", strerror(errno));
+ SYSWARN("Failed to reset terminal properties.");
}
free_command_fifo_config(console_fifos);
sem_destroy(&g_console_waitopen_sem);
diff --git a/src/cmd/isula/images/images.c b/src/cmd/isula/images/images.c
index bff07f76..bd9dc18b 100644
--- a/src/cmd/isula/images/images.c
+++ b/src/cmd/isula/images/images.c
@@ -65,7 +65,7 @@ static char *trans_time(int64_t created)
time_t created_time = (time_t)created;
if (!localtime_r(&created_time, &t)) {
- ERROR("translate time for created failed: %s", strerror(errno));
+ SYSERROR("translate time for created failed.");
return NULL;
}
diff --git a/src/cmd/isula/isula_host_spec.c b/src/cmd/isula/isula_host_spec.c
index 7304130d..bbcf50de 100644
--- a/src/cmd/isula/isula_host_spec.c
+++ b/src/cmd/isula/isula_host_spec.c
@@ -753,7 +753,7 @@ uint64_t get_proc_mem_size(const char *item)
fp = util_fopen("/proc/meminfo", "r");
if (fp == NULL) {
- ERROR("Failed to open /proc/meminfo: %s", strerror(errno));
+ SYSERROR("Failed to open /proc/meminfo");
return sysmem_limit;
}
diff --git a/src/cmd/isula/stream/exec.c b/src/cmd/isula/stream/exec.c
index bd8bd49a..209610be 100644
--- a/src/cmd/isula/stream/exec.c
+++ b/src/cmd/isula/stream/exec.c
@@ -356,7 +356,7 @@ static int remote_cmd_exec(const struct client_arguments *args, uint32_t *exit_c
out:
if (reset_tty && tcsetattr(0, TCSAFLUSH, &oldtios) < 0) {
- WARN("Failed to reset terminal properties: %s.", strerror(errno));
+ SYSWARN("Failed to reset terminal properties.");
}
if (response->exit_code != 0) {
*exit_code = response->exit_code;
@@ -387,7 +387,7 @@ out:
sem_destroy(&g_command_waitopen_sem);
sem_destroy(&g_command_waitexit_sem);
if (reset_tty && tcsetattr(0, TCSAFLUSH, &oldtios) < 0) {
- WARN("Failed to reset terminal properties: %s.", strerror(errno));
+ SYSWARN("Failed to reset terminal properties.");
}
return ret;
}
diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c
index 961a3912..f2a25a84 100644
--- a/src/cmd/isulad/main.c
+++ b/src/cmd/isulad/main.c
@@ -179,7 +179,7 @@ static int mount_rootfs_mnt_dir(const char *mountdir)
if (info == NULL) {
ret = mount(rootfsdir, rootfsdir, "bind", MS_BIND | MS_REC, NULL);
if (ret < 0) {
- ERROR("Failed to mount parent directory %s:%s", rootfsdir, strerror(errno));
+ SYSERROR("Failed to mount parent directory %s.", rootfsdir);
goto out;
}
}
@@ -212,7 +212,7 @@ static int umount_rootfs_mnt_dir(const char *mntdir)
ret = umount(dir);
if (ret < 0 && errno != EINVAL) {
- WARN("Failed to umount parent directory %s:%s", dir, strerror(errno));
+ SYSWARN("Failed to umount parent directory %s.", dir);
goto out;
}
@@ -252,7 +252,7 @@ static void clean_residual_files()
if (checked_flag == NULL) {
ERROR("Failed to get image checked flag file path");
} else if (unlink_ignore_enoent(checked_flag)) {
- ERROR("Unlink file: %s error: %s", checked_flag, strerror(errno));
+ SYSERROR("Unlink file: %s.", checked_flag);
}
free(checked_flag);
@@ -261,7 +261,7 @@ static void clean_residual_files()
if (fname == NULL) {
ERROR("Failed to get isulad pid file path");
} else if (unlink(fname) && errno != ENOENT) {
- WARN("Unlink file: %s error: %s", fname, strerror(errno));
+ SYSWARN("Unlink file: %s.", fname);
}
free(fname);
}
@@ -467,7 +467,7 @@ int check_and_save_pid(const char *fn)
ret = ftruncate(fd, 0);
if (ret != 0) {
- ERROR("Failed to truncate pid file:%s to 0: %s", fn, strerror(errno));
+ SYSERROR("Failed to truncate pid file:%s to 0.", fn);
ret = -1;
goto out;
}
@@ -481,7 +481,7 @@ int check_and_save_pid(const char *fn)
len = util_write_nointr(fd, pidbuf, strlen(pidbuf));
if (len < 0 || (size_t)len != strlen(pidbuf)) {
- ERROR("Failed to write pid to file:%s: %s", fn, strerror(errno));
+ SYSERROR("Failed to write pid to file:%s.", fn);
ret = -1;
}
out:
@@ -522,7 +522,7 @@ static int check_hook_spec_file(const char *hook_spec)
return -1;
}
if (stat(hook_spec, &hookstat)) {
- ERROR("Stat hook spec file failed: %s", strerror(errno));
+ SYSERROR("Stat hook spec file failed.");
return -1;
}
if ((hookstat.st_mode & S_IFMT) != S_IFREG) {
@@ -575,16 +575,16 @@ static void update_isulad_rlimits()
limit.rlim_cur = __ULIMIT_CONFIG_VAL_;
limit.rlim_max = __ULIMIT_CONFIG_VAL_;
if (setrlimit(RLIMIT_NOFILE, &limit)) {
- WARN("Can not set ulimit of RLIMIT_NOFILE: %s", strerror(errno));
+ SYSWARN("Can not set ulimit of RLIMIT_NOFILE.");
}
if (setrlimit(RLIMIT_NPROC, &limit)) {
- WARN("Can not set ulimit of RLIMIT_NPROC: %s", strerror(errno));
+ SYSWARN("Can not set ulimit of RLIMIT_NPROC.");
}
limit.rlim_cur = RLIM_INFINITY;
limit.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &limit)) {
- WARN("Can not set ulimit of RLIMIT_CORE: %s", strerror(errno));
+ SYSWARN("Can not set ulimit of RLIMIT_CORE.");
}
}
@@ -808,7 +808,7 @@ static int overlay_supports_selinux(bool *supported)
*supported = false;
fp = fopen("/proc/kallsyms", "re");
if (fp == NULL) {
- ERROR("Failed to open /proc/kallsyms: %s", strerror(errno));
+ SYSERROR("Failed to open /proc/kallsyms.");
return -1;
}
__fsetlocking(fp, FSETLOCKING_BYCALLER);
diff --git a/src/daemon/common/sysinfo.c b/src/daemon/common/sysinfo.c
index fbdea4e8..0e3c31e1 100644
--- a/src/daemon/common/sysinfo.c
+++ b/src/daemon/common/sysinfo.c
@@ -644,7 +644,7 @@ uint64_t get_default_total_mem_size(void)
fp = util_fopen("/proc/meminfo", "r");
if (fp == NULL) {
- ERROR("Failed to open /proc/meminfo: %s", strerror(errno));
+ SYSERROR("Failed to open /proc/meminfo.");
return sysmem_limit;
}
@@ -684,10 +684,10 @@ char *get_operating_system(void)
fp = fopen(etcOsRelease, "r");
if (fp == NULL) {
- INFO("Failed to open %s :%s", etcOsRelease, strerror(errno));
+ SYSINFO("Failed to open %s.", etcOsRelease);
fp = fopen(altOsRelease, "r");
if (fp == NULL) {
- ERROR("Failed to open %s :%s", altOsRelease, strerror(errno));
+ SYSERROR("Failed to open %s.", altOsRelease);
goto out;
}
}
@@ -1021,7 +1021,7 @@ static int get_cgroup_version()
struct statfs fs = { 0 };
if (statfs(CGROUP_MOUNTPOINT, &fs) != 0) {
- ERROR("failed to statfs %s: %s", CGROUP_MOUNTPOINT, strerror(errno));
+ SYSERROR("failed to statfs %s.", CGROUP_MOUNTPOINT);
return -1;
}
@@ -1299,7 +1299,7 @@ static int cgroup2_enable_all()
ret = util_write_file(CGROUP2_SUBTREE_CONTROLLER_PATH, enable_controllers, strlen(enable_controllers),
DEFAULT_CGROUP_FILE_MODE);
if (ret != 0) {
- ERROR("write %s to %s failed: %s", enable_controllers, CGROUP2_SUBTREE_CONTROLLER_PATH, strerror(errno));
+ SYSERROR("write %s to %s failed.", enable_controllers, CGROUP2_SUBTREE_CONTROLLER_PATH);
goto out;
}
diff --git a/src/daemon/entry/connect/grpc/grpc_service.cc b/src/daemon/entry/connect/grpc/grpc_service.cc
index 050a43f8..e37117ae 100644
--- a/src/daemon/entry/connect/grpc/grpc_service.cc
+++ b/src/daemon/entry/connect/grpc/grpc_service.cc
@@ -106,7 +106,7 @@ public:
for (const auto &address : m_socketPath) {
if (address.find(UNIX_SOCKET_PREFIX) == 0) {
if (unlink(address.c_str() + strlen(UNIX_SOCKET_PREFIX)) < 0 && errno != ENOENT) {
- WARN("Failed to remove '%s':%s", address.c_str(), strerror(errno));
+ SYSWARN("Failed to remove '%s'.", address.c_str());
}
}
}
diff --git a/src/daemon/entry/connect/rest/rest_service.c b/src/daemon/entry/connect/rest/rest_service.c
index 77dee8aa..956932db 100644
--- a/src/daemon/entry/connect/rest/rest_service.c
+++ b/src/daemon/entry/connect/rest/rest_service.c
@@ -98,7 +98,7 @@ int rest_server_init(const char *socket)
}
if (unlink(g_socketpath + strlen(UNIX_SOCKET_PREFIX)) < 0 && errno != ENOENT) {
- ERROR("Failed to remove '%s':%s, abort", strerror(errno), g_socketpath);
+ SYSERROR("Failed to remove '%s', abort", g_socketpath);
goto error_out;
}
@@ -139,7 +139,7 @@ void rest_server_shutdown(void)
if (g_socketpath != NULL) {
if (unlink(g_socketpath + strlen(UNIX_SOCKET_PREFIX)) < 0 && errno != ENOENT) {
- ERROR("Failed to remove '%s':%s", g_socketpath, strerror(errno));
+ SYSERROR("Failed to remove '%s'.", g_socketpath);
}
}
}
diff --git a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
index 91ca2735..c9b5527c 100644
--- a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
+++ b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
@@ -824,7 +824,7 @@ auto PodSandboxManagerServiceImpl::ClearCniNetwork(const std::string &realSandbo
// umount netns when cni removed network successfully
if (inspect_data != nullptr && namespace_is_file(inspect_data->host_config->network_mode) &&
util_umount_namespace(netnsPath) != 0) {
- ERROR("Failed to umount directory %s:%s", netnsPath, strerror(errno));
+ SYSERROR("Failed to umount directory %s.", netnsPath);
}
out:
diff --git a/src/daemon/entry/cri/websocket/service/ws_server.cc b/src/daemon/entry/cri/websocket/service/ws_server.cc
index 6c379d9d..d439dd96 100644
--- a/src/daemon/entry/cri/websocket/service/ws_server.cc
+++ b/src/daemon/entry/cri/websocket/service/ws_server.cc
@@ -255,7 +255,7 @@ int WebsocketServer::CreateContext()
newLimit.rlim_max = WS_ULIMIT_FDS;
int limited = prlimit(0, RLIMIT_NOFILE, &newLimit, &oldLimit);
if (limited != 0) {
- WARN("Can not set ulimit of RLIMIT_NOFILE: %s", strerror(errno));
+ SYSWARN("Can not set ulimit of RLIMIT_NOFILE");
}
m_context = lws_create_context(&info);
if (m_context == nullptr) {
@@ -264,7 +264,7 @@ int WebsocketServer::CreateContext()
}
if (limited == 0) {
if (setrlimit(static_cast<int>(RLIMIT_NOFILE), &oldLimit) != 0) {
- WARN("Can not set ulimit of RLIMIT_NOFILE: %s", strerror(errno));
+ SYSWARN("Can not set ulimit of RLIMIT_NOFILE");
}
}
@@ -563,7 +563,7 @@ void WebsocketServer::Receive(int socketID, void *in, size_t len, bool complete)
DEBUG("Receive remaning stdin data with length %zu", len);
// Too much data may cause error 'resource temporarily unavaliable' by using 'write'
if (util_write_nointr_in_total(m_wsis[socketID]->pipes.at(1), static_cast<char *>(in), len) < 0) {
- ERROR("Sub write over! err msg: %s", strerror(errno));
+ SYSERROR("Sub write over!");
}
goto out;
}
@@ -580,7 +580,7 @@ void WebsocketServer::Receive(int socketID, void *in, size_t len, bool complete)
if (*static_cast<char *>(in) == WebsocketChannel::STDINCHANNEL) {
if (util_write_nointr_in_total(m_wsis[socketID]->pipes.at(1), static_cast<char *>(in) + 1, len - 1) < 0) {
- ERROR("Sub write over! err msg: %s", strerror(errno));
+ SYSERROR("Sub write over!");
}
goto out;
}
diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c
index f78965df..c5f7a853 100644
--- a/src/daemon/executor/container_cb/execution.c
+++ b/src/daemon/executor/container_cb/execution.c
@@ -271,7 +271,7 @@ static int prepare_start_io(container_t *cont, const container_start_request *re
*sync_fd = eventfd(0, EFD_CLOEXEC);
if (*sync_fd < 0) {
- ERROR("Failed to create eventfd: %s", strerror(errno));
+ SYSERROR("Failed to create eventfd.");
ret = -1;
goto out;
}
@@ -338,13 +338,13 @@ static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const
fd = util_open(fpath, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0700);
if (fd < 0) {
- ERROR("Failed to open file: %s: %s", fpath, strerror(errno));
+ SYSERROR("Failed to open file: %s.", fpath);
isulad_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno));
return -1;
}
nwrite = util_write_nointr(fd, buf, strlen(buf));
if (nwrite < 0 || (size_t)nwrite != strlen(buf)) {
- ERROR("Failed to write %s to %s: %s", buf, fpath, strerror(errno));
+ SYSERROR("Failed to write %s to %s.", buf, fpath);
isulad_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno));
close(fd);
return -1;
@@ -499,7 +499,7 @@ static void handle_start_io_thread_by_cc(uint32_t cc, int sync_fd, pthread_t thr
} else {
if (sync_fd >= 0) {
if (eventfd_write(sync_fd, 1) < 0) {
- ERROR("Failed to write eventfd: %s", strerror(errno));
+ SYSERROR("Failed to write eventfd.");
}
}
if (thread_id > 0) {
diff --git a/src/daemon/executor/container_cb/execution_stream.c b/src/daemon/executor/container_cb/execution_stream.c
index 244ec6a0..7e84cca3 100644
--- a/src/daemon/executor/container_cb/execution_stream.c
+++ b/src/daemon/executor/container_cb/execution_stream.c
@@ -265,7 +265,7 @@ static int attach_prepare_console(const container_t *cont, const container_attac
*sync_fd = eventfd(0, EFD_CLOEXEC);
if (*sync_fd < 0) {
- ERROR("Failed to create eventfd: %s", strerror(errno));
+ SYSERROR("Failed to create eventfd.");
ret = -1;
goto out;
}
@@ -295,7 +295,7 @@ static void handle_attach_io_thread_by_cc(uint32_t cc, int sync_fd, pthread_t th
} else {
if (sync_fd >= 0) {
if (eventfd_write(sync_fd, 1) < 0) {
- ERROR("Failed to write eventfd: %s", strerror(errno));
+ SYSERROR("Failed to write eventfd.");
}
}
if (thread_id > 0) {
@@ -535,7 +535,7 @@ static container_path_stat *do_container_stat_path(const char *rootpath, const c
nret = lstat(resolvedpath, &st);
if (nret < 0) {
- ERROR("lstat %s: %s", resolvedpath, strerror(errno));
+ SYSERROR("lstat %s failed.", resolvedpath);
isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno));
goto cleanup;
}
@@ -921,7 +921,7 @@ static int copy_to_container_check_path_valid(const container_t *cont, const cha
nret = lstat(resolvedpath, &st);
if (nret < 0) {
- ERROR("lstat %s: %s", resolvedpath, strerror(errno));
+ SYSERROR("lstat %s failed", resolvedpath);
isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno));
goto cleanup;
}
@@ -1092,11 +1092,11 @@ static int64_t do_read_log_file(const char *path, int64_t require_line, long pos
util_usleep_nointerupt(1000);
}
if (fp == NULL) {
- ERROR("open file: %s failed: %s", path, strerror(errno));
+ SYSERROR("open file: %s failed.", path);
return -1;
}
if (pos > 0 && fseek(fp, pos, SEEK_SET) != 0) {
- ERROR("fseek to %ld failed: %s", pos, strerror(errno));
+ SYSERROR("fseek to %ld failed.", pos);
read_lines = -1;
goto out;
}
@@ -1211,12 +1211,12 @@ static int do_tail_find(FILE *fp, int64_t require_line, int64_t *get_line, long
int ret = -1;
if (fseek(fp, 0L, SEEK_END) != 0) {
- ERROR("Fseek failed: %s", strerror(errno));
+ SYSERROR("Fseek failed");
goto out;
}
len = ftell(fp);
if (len < 0) {
- ERROR("Ftell failed: %s", strerror(errno));
+ SYSERROR("Ftell failed");
goto out;
}
if (len < SECTION_SIZE) {
@@ -1228,7 +1228,7 @@ static int do_tail_find(FILE *fp, int64_t require_line, int64_t *get_line, long
}
while (true) {
if (fseek(fp, pos, SEEK_SET) != 0) {
- ERROR("Fseek failed: %s", strerror(errno));
+ SYSERROR("Fseek failed");
goto out;
}
read_size = fread(buffer, sizeof(char), (size_t)step_size, fp);
@@ -1275,7 +1275,7 @@ static int util_find_tail_position(const char *file_name, int64_t require_line,
fp = util_fopen(file_name, "rb");
if (fp == NULL) {
- ERROR("open file: %s failed: %s", file_name, strerror(errno));
+ SYSERROR("open file: %s failed.", file_name);
return -1;
}
diff --git a/src/daemon/modules/container/container_gc/containers_gc.c b/src/daemon/modules/container/container_gc/containers_gc.c
index 9feb6d3c..8d0647ab 100644
--- a/src/daemon/modules/container/container_gc/containers_gc.c
+++ b/src/daemon/modules/container/container_gc/containers_gc.c
@@ -83,14 +83,14 @@ static int save_gc_config(const char *json_gc_config)
fd = util_open(filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
if (fd == -1) {
- ERROR("Create file %s failed: %s", filename, strerror(errno));
+ SYSERROR("Create file %s failed.", filename);
ret = -1;
goto out;
}
nret = util_write_nointr(fd, json_gc_config, strlen(json_gc_config));
if (nret < 0 || (size_t)nret != strlen(json_gc_config)) {
- ERROR("write %s failed: %s", filename, strerror(errno));
+ SYSERROR("write %s failed.", filename);
ret = -1;
}
close(fd);
diff --git a/src/daemon/modules/container/container_unix.c b/src/daemon/modules/container/container_unix.c
index 224be958..f85e8237 100644
--- a/src/daemon/modules/container/container_unix.c
+++ b/src/daemon/modules/container/container_unix.c
@@ -479,7 +479,7 @@ static int save_json_config_file(const char *id, const char *rootpath, const cha
nret = util_atomic_write_file(filename, json_data, strlen(json_data), CONFIG_FILE_MODE, false);
if (nret != 0) {
- ERROR("Write file %s failed: %s", filename, strerror(errno));
+ SYSERROR("Write file %s failed.", filename);
isulad_set_error_message("Write file '%s' failed: %s", filename, strerror(errno));
ret = -1;
}
diff --git a/src/daemon/modules/container/leftover_cleanup/cleanup.c b/src/daemon/modules/container/leftover_cleanup/cleanup.c
index c86e3db9..9a38ffc2 100644
--- a/src/daemon/modules/container/leftover_cleanup/cleanup.c
+++ b/src/daemon/modules/container/leftover_cleanup/cleanup.c
@@ -158,7 +158,7 @@ static bool walk_isulad_tmpdir_cb(const char *path_name, const struct dirent *su
if (util_detect_mounted(tmpdir)) {
if (umount(tmpdir) != 0) {
- ERROR("Failed to umount target %s, error: %s", tmpdir, strerror(errno));
+ SYSERROR("Failed to umount target %s", tmpdir);
}
}
diff --git a/src/daemon/modules/container/supervisor/supervisor.c b/src/daemon/modules/container/supervisor/supervisor.c
index 3ce4ec1e..829e48b1 100644
--- a/src/daemon/modules/container/supervisor/supervisor.c
+++ b/src/daemon/modules/container/supervisor/supervisor.c
@@ -104,7 +104,7 @@ char *container_exit_fifo_create(const char *cont_state_path)
ret = mknod(fifo_path, S_IFIFO | S_IRUSR | S_IWUSR, (dev_t)0);
if (ret < 0 && errno != EEXIST) {
- ERROR("Failed to mknod exit monitor fifo %s: %s.", fifo_path, strerror(errno));
+ SYSERROR("Failed to mknod exit monitor fifo %s.", fifo_path);
return NULL;
}
@@ -128,7 +128,7 @@ int container_exit_fifo_open(const char *cont_exit_fifo)
ret = util_open(cont_exit_fifo, O_RDONLY | O_NONBLOCK, 0);
if (ret < 0) {
- ERROR("Failed to open exit monitor FIFO %s: %s.", cont_exit_fifo, strerror(errno));
+ SYSERROR("Failed to open exit monitor FIFO %s.", cont_exit_fifo);
ret = -1;
goto out;
}
@@ -324,7 +324,7 @@ restart:
if (ret == 0) {
goto restart;
}
- ERROR("Mainloop returned an error: %s", strerror(errno));
+ SYSERROR("Mainloop returned an error");
epoll_loop_close(&g_supervisor_descr);
diff --git a/src/daemon/modules/events/monitord.c b/src/daemon/modules/events/monitord.c
index 775fb9ab..9edded7a 100644
--- a/src/daemon/modules/events/monitord.c
+++ b/src/daemon/modules/events/monitord.c
@@ -113,18 +113,18 @@ static void *monitored(void *arg)
mhandler.fifo_path = fifo_file_path;
if (mknod(fifo_file_path, S_IFIFO | S_IRUSR | S_IWUSR, (dev_t)0) && errno != EEXIST) {
- ERROR("Create monitored fifo file failed: %s", strerror(errno));
+ SYSERROR("Create monitored fifo file failed");
goto err;
}
mhandler.fifo_fd = util_open(fifo_file_path, O_RDWR | O_NONBLOCK | O_CLOEXEC, 0);
if (mhandler.fifo_fd == -1) {
- ERROR("Open monitored fifo file failed: %s", strerror(errno));
+ SYSERROR("Open monitored fifo file failed");
goto err;
}
if (fcntl(mhandler.fifo_fd, F_SETPIPE_SZ, EVENTS_FIFO_SIZE) == -1) {
- ERROR("Set events fifo buffer size failed: %s\n", strerror(errno));
+ SYSERROR("Set events fifo buffer size failed");
goto err;
}
@@ -150,7 +150,7 @@ static void *monitored(void *arg)
ret = epoll_loop(&descr, -1);
} while (ret == 0);
- ERROR("Mainloop returned an error: %s", strerror(errno));
+ SYSERROR("Mainloop returned an error");
goto err2;
err:
diff --git a/src/daemon/modules/events_sender/event_sender.c b/src/daemon/modules/events_sender/event_sender.c
index a3903f3e..13f3c3e3 100644
--- a/src/daemon/modules/events_sender/event_sender.c
+++ b/src/daemon/modules/events_sender/event_sender.c
@@ -52,7 +52,7 @@ static void isulad_monitor_fifo_send(const struct monitord_msg *msg)
goto out;
}
- ERROR("Failed to open fifo to send message: %s.", strerror(errno));
+ SYSERROR("Failed to open fifo to send message.");
goto out;
}
diff --git a/src/daemon/modules/image/embedded/db/sqlite_common.c b/src/daemon/modules/image/embedded/db/sqlite_common.c
index 42fdf6d9..89f834a0 100644
--- a/src/daemon/modules/image/embedded/db/sqlite_common.c
+++ b/src/daemon/modules/image/embedded/db/sqlite_common.c
@@ -49,7 +49,7 @@ int db_sqlite_init(const char *dbpath)
goto cleanup;
}
if (chmod(dbpath, DEFAULT_SECURE_FILE_MODE) != 0) {
- ERROR("Change mode of db file failed: %s", strerror(errno));
+ SYSERROR("Change mode of db file failed.");
goto cleanup;
}
return 0;
diff --git a/src/daemon/modules/image/external/ext_image.c b/src/daemon/modules/image/external/ext_image.c
index 0d34d5d1..598299ea 100644
--- a/src/daemon/modules/image/external/ext_image.c
+++ b/src/daemon/modules/image/external/ext_image.c
@@ -65,7 +65,7 @@ int ext_prepare_rf(const im_prepare_request *request, char **real_rootfs)
return -1;
}
if (realpath(request->rootfs, real_path) == NULL) {
- ERROR("Failed to clean rootfs path '%s': %s", request->rootfs, strerror(errno));
+ SYSERROR("Failed to clean rootfs path '%s'", request->rootfs);
isulad_set_error_message("Failed to clean rootfs path '%s': %s", request->rootfs, strerror(errno));
return -1;
}
diff --git a/src/daemon/modules/image/image_rootfs_handler.c b/src/daemon/modules/image/image_rootfs_handler.c
index 915c8a33..ceea4f5b 100644
--- a/src/daemon/modules/image/image_rootfs_handler.c
+++ b/src/daemon/modules/image/image_rootfs_handler.c
@@ -439,7 +439,7 @@ static int read_user_file(const char *basefs, const char *user_path, FILE **stre
*stream = util_fopen(real_path, "r");
if (*stream == NULL) {
- WARN("Failed to open %s: %s", real_path, strerror(errno));
+ SYSWARN("Failed to open %s.", real_path);
ret = 0;
goto out;
}
@@ -460,7 +460,7 @@ static int resolve_basefs(const char *basefs, char **resolved_basefs)
}
if (stat(real_path, &s) < 0) {
- ERROR("stat failed, error: %s", strerror(errno));
+ SYSERROR("stat failed.");
return -1;
}
diff --git a/src/daemon/modules/image/oci/oci_load.c b/src/daemon/modules/image/oci/oci_load.c
index 0d450bb6..2a920c22 100644
--- a/src/daemon/modules/image/oci/oci_load.c
+++ b/src/daemon/modules/image/oci/oci_load.c
@@ -1028,7 +1028,7 @@ static char *oci_load_path_create()
}
if (mkdtemp(tmp_dir) == NULL) {
- ERROR("make temporary dir failed: %s", strerror(errno));
+ SYSERROR("make temporary dir failed");
isulad_try_set_error_message("make temporary dir failed: %s", strerror(errno));
ret = -1;
goto out;
diff --git a/src/daemon/modules/image/oci/registry/registry.c b/src/daemon/modules/image/oci/registry/registry.c
index 717f48b5..2cf79fb9 100644
--- a/src/daemon/modules/image/oci/registry/registry.c
+++ b/src/daemon/modules/image/oci/registry/registry.c
@@ -439,7 +439,7 @@ static int add_cached_layer(char *blob_digest, char *file, thread_fetch_info *in
}
if (link(src_file, file) != 0) {
- ERROR("link %s to %s failed: %s", src_file, file, strerror(errno));
+ SYSERROR("link %s to %s failed", src_file, file);
ret = -1;
goto out;
}
@@ -1149,7 +1149,7 @@ static void set_cached_layers_info(char *blob_digest, char *diffid, int result,
continue;
}
if (link(src_file, elem->file) != 0) {
- ERROR("link %s to %s failed: %s", src_file, elem->file, strerror(errno));
+ SYSERROR("link %s to %s failed", src_file, elem->file);
info->desc->cancel = true;
continue;
}
@@ -1431,8 +1431,7 @@ static void *register_layers_in_thread(void *arg)
// here we can't just break and cleanup resources because threads are running.
// desc is freed if we break and then isulad crash. sleep some time
// instead to avoid cpu full running and then retry.
- ERROR("condition wait for layer %zu to complete failed, ret %d, error: %s", i, cond_ret,
- strerror(errno));
+ SYSERROR("condition wait for layer %zu to complete failed, ret %d", i, cond_ret);
sleep(10);
continue;
}
@@ -1617,7 +1616,7 @@ static int fetch_all(pull_descriptor *desc)
// here we can't just break and cleanup resources because threads are running.
// desc is freed if we break and then isulad crash. sleep some time
// instead to avoid cpu full running and then retry.
- ERROR("condition wait for all layers to complete failed, ret %d, error: %s", cond_ret, strerror(errno));
+ SYSERROR("condition wait for all layers to complete failed, ret %d", cond_ret);
sleep(10);
continue;
}
@@ -1911,7 +1910,7 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio
}
if (mkdtemp(blobpath) == NULL) {
- ERROR("make temporary direcory failed: %s", strerror(errno));
+ SYSERROR("make temporary direcory failed");
ret = -1;
goto out;
}
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
index 046dd333..ee82e32c 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
@@ -782,7 +782,7 @@ static int device_file_walk(struct device_set *devset)
}
if (stat(fname, &st) != 0) {
- ERROR("devmapper: get %s stat error:%s", fname, strerror(errno));
+ SYSERROR("devmapper: get %s stat failed", fname);
ret = -1;
goto out;
}
@@ -2204,7 +2204,7 @@ static int grow_fs(struct device_set *devset, image_devmapper_device_info *info)
clean_mount:
if (umount2(FS_MOUNT_POINT, MNT_DETACH) < 0 && errno != EINVAL) {
- WARN("Failed to umount directory %s:%s", FS_MOUNT_POINT, strerror(errno));
+ SYSWARN("Failed to umount directory %s", FS_MOUNT_POINT);
}
out:
@@ -3148,7 +3148,7 @@ int unmount_device(const char *hash, const char *mount_path, struct device_set *
}
if (umount2(mount_path, MNT_DETACH) < 0 && errno != EINVAL) {
- ERROR("Failed to umount directory %s:%s", mount_path, strerror(errno));
+ SYSERROR("Failed to umount directory %s", mount_path);
ret = -1;
goto free_out;
}
@@ -3405,7 +3405,7 @@ static int umount_deactivate_dev_all(const struct device_set *devset)
}
if (stat(fname, &st) != 0) {
- ERROR("devmapper: get %s stat error:%s", fname, strerror(errno));
+ SYSERROR("devmapper: get %s stat failed", fname);
continue;
}
@@ -3415,7 +3415,7 @@ static int umount_deactivate_dev_all(const struct device_set *devset)
}
if (umount2(fname, MNT_DETACH) < 0 && errno != EINVAL) {
- ERROR("Failed to umount directory %s:%s", fname, strerror(errno));
+ SYSERROR("Failed to umount directory %s", fname);
}
device_info = lookup_device(devset, entry->d_name);
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
index 9b7e6b17..3a4e1a69 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
@@ -450,7 +450,7 @@ void dev_udev_wait(uint32_t cookie)
}
if (pthread_create(&tid, NULL, udev_wait_process, uwait) != 0) {
- ERROR("devmapper: create udev wait process thread error:%s", strerror(errno));
+ SYSERROR("devmapper: create udev wait process thread error");
free_udev_wait_pth_t(uwait);
return;
}
@@ -1195,7 +1195,7 @@ void dev_check_sem_set_stat(int *semusz, int *semmni)
}
if (semctl(0, 0, SEM_INFO, &sinfo) != 0) {
- WARN("Get devmapper library version err:%s", strerror(errno));
+ SYSWARN("Get devmapper library version err");
return;
}
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
index 87df8160..64022d89 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
@@ -2044,7 +2044,7 @@ static int file_crc64(char *file, uint64_t *crc, uint64_t policy)
fd = util_open(file, O_RDONLY, 0);
if (fd < 0) {
- ERROR("Open file: %s, failed: %s", file, strerror(errno));
+ SYSERROR("Open file: %s, failed", file);
return -1;
}
@@ -2066,7 +2066,7 @@ static int file_crc64(char *file, uint64_t *crc, uint64_t policy)
while (true) {
size = util_read_nointr(fd, buffer, BLKSIZE);
if (size < 0) {
- ERROR("read file %s failed: %s", file, strerror(errno));
+ SYSERROR("read file %s failed", file);
ret = -1;
break;
} else if (size == 0) {
@@ -2114,7 +2114,7 @@ static int valid_crc64(storage_entry *entry, char *rootfs)
if (fname != NULL && util_has_prefix(fname, ".wh.")) {
goto out;
}
- ERROR("stat file or dir: %s, failed: %s", file, strerror(errno));
+ SYSERROR("stat file or dir: %s, failed", file);
ret = -1;
} else {
if (strlen(entry->payload) != PAYLOAD_CRC_LEN) {
@@ -2181,7 +2181,7 @@ static tar_split *new_tar_split(layer_t *l, const char *tspath)
ts->tmp_file = fopen(path, "w+");
if (ts->tmp_file == NULL) {
- ERROR("create tmpfile failed: %s", strerror(errno));
+ SYSERROR("create tmpfile failed");
ret = -1;
goto out;
}
@@ -2219,7 +2219,7 @@ static int next_tar_split_entry(tar_split *ts, storage_entry **entry)
if (errno == 0) {
*entry = NULL;
} else {
- ERROR("error read line from tar split: %s", strerror(errno));
+ SYSERROR("error read line from tar split");
ret = -1;
}
goto out;
diff --git a/src/daemon/modules/image/oci/storage/storage.c b/src/daemon/modules/image/oci/storage/storage.c
index 5f9dea51..fbaae3fc 100644
--- a/src/daemon/modules/image/oci/storage/storage.c
+++ b/src/daemon/modules/image/oci/storage/storage.c
@@ -1464,7 +1464,7 @@ static int do_add_checked_layer(const char *lid, int fd, map_t *checked_layers)
// save checked layer ids into file
nret = util_write_nointr(fd, buf, strlen(lid) + 1);
if (nret < 0 || (size_t)nret != strlen(lid) + 1) {
- ERROR("Write checked layer data failed: %s", strerror(errno));
+ SYSERROR("Write checked layer data failed");
ret = -1;
goto out;
}
diff --git a/src/daemon/modules/image/oci/utils_images.c b/src/daemon/modules/image/oci/utils_images.c
index e7131351..736bbf0e 100644
--- a/src/daemon/modules/image/oci/utils_images.c
+++ b/src/daemon/modules/image/oci/utils_images.c
@@ -565,7 +565,7 @@ static int makesure_path_is_dir(char *path)
if (errno == ENOENT) {
return util_mkdir_p(path, TEMP_DIRECTORY_MODE);
}
- ERROR("lstat %s failed: %s", path, strerror(errno));
+ SYSERROR("lstat %s failed.", path);
return -1;
}
@@ -625,7 +625,7 @@ int makesure_isulad_tmpdir_perm_right(const char *root_dir)
}
if (lstat(isulad_tmpdir, &st) != 0) {
- ERROR("lstat %s failed: %s", isulad_tmpdir, strerror(errno));
+ SYSERROR("lstat %s failed.", isulad_tmpdir);
ret = -1;
goto out;
}
@@ -646,7 +646,7 @@ int makesure_isulad_tmpdir_perm_right(const char *root_dir)
ret = 0;
goto out;
} else {
- ERROR("lchown %s failed: %s", isulad_tmpdir, strerror(errno));
+ SYSERROR("lchown %s failed", isulad_tmpdir);
}
out:
diff --git a/src/daemon/modules/log/log_gather.c b/src/daemon/modules/log/log_gather.c
index 9b400f00..780034ee 100644
--- a/src/daemon/modules/log/log_gather.c
+++ b/src/daemon/modules/log/log_gather.c
@@ -66,7 +66,7 @@ static int file_rotate_gz(const char *file_name, int i)
}
if (rename(from_path, to_path) < 0 && errno != ENOENT) {
- WARN("Rename file: %s error: %s", from_path, strerror(errno));
+ SYSWARN("Rename file: %s failed", from_path);
return -1;
}
@@ -85,7 +85,7 @@ static int file_rotate_me(const char *file_name)
}
if (rename(file_name, tmp_path) < 0 && errno != ENOENT) {
- WARN("Rename file: %s error: %s", file_name, strerror(errno));
+ SYSWARN("Rename file: %s failed", file_name);
return -1;
}
diff --git a/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c b/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
index 2b9cf39c..e985cfc1 100644
--- a/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
+++ b/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
@@ -88,7 +88,7 @@ static int parse_container_pid(const char *S, pid_ppid_info_t *pid_info)
num = sscanf(S, "%d %Lu %d %Lu", &pid_info->pid, &pid_info->start_time, &pid_info->ppid, &pid_info->pstart_time);
if (num != 4) { // args num to read is 4
- ERROR("Call sscanf error: %s", errno ? strerror(errno) : "");
+ SYSERROR("Call sscanf failed.");
return -1;
}
@@ -210,7 +210,7 @@ static int remove_container_rootpath(const char *id, const char *root_path)
ret = util_recursive_rmdir(cont_root_path, 0);
if (ret != 0) {
const char *tmp_err = (errno != 0) ? strerror(errno) : "error";
- ERROR("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err);
+ SYSERROR("Failed to delete container's root directory %s.", cont_root_path);
isulad_set_error_message("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err);
ret = -1;
goto out;
@@ -750,7 +750,7 @@ int rt_lcr_kill(const char *id, const char *runtime, const rt_kill_params_t *par
} else {
int ret = kill(params->pid, (int)params->signal);
if (ret < 0) {
- ERROR("Can not kill process (pid=%d) with signal %u: %s", params->pid, params->signal, strerror(errno));
+ SYSERROR("Can not kill process (pid=%d) with signal %u.", params->pid, params->signal);
return -1;
}
}
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index a218519a..d35e2351 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -388,7 +388,7 @@ static bool shim_alive(const char *workdir)
ret = kill(pid, 0);
if (ret != 0) {
- INFO("kill 0 shim-pid with error: %s", strerror(errno));
+ SYSINFO("kill 0 shim-pid with error.");
}
return ret == 0;
}
@@ -775,7 +775,7 @@ static int shim_create(bool fg, const char *id, const char *workdir, const char
pid = fork();
if (pid < 0) {
- ERROR("Failed fork for shim parent %s", strerror(errno));
+ SYSERROR("Failed fork for shim parent");
close(shim_stderr_pipe[0]);
close(shim_stderr_pipe[1]);
close(shim_stdout_pipe[0]);
@@ -851,7 +851,7 @@ realexec:
status = util_wait_for_pid_status(pid);
if (status < 0) {
- ERROR("Failed wait shim-parent %d exit %s", pid, strerror(errno));
+ SYSERROR("Failed wait shim-parent %d exit", pid);
ret = -1;
goto out;
}
@@ -1683,7 +1683,7 @@ int rt_isula_exec_resize(const char *id, const char *runtime, const rt_exec_resi
}
if (kill(pid, SIGWINCH) < 0) {
- ERROR("can't kill process (pid=%d) with signal %u: %s", pid, SIGWINCH, strerror(errno));
+ SYSERROR("can't kill process (pid=%d) with signal %u", pid, SIGWINCH);
ret = -1;
goto out;
}
@@ -1711,7 +1711,7 @@ int rt_isula_kill(const char *id, const char *runtime, const rt_kill_params_t *p
} else {
int ret = kill(params->pid, (int)params->signal);
if (ret < 0) {
- ERROR("Can not kill process (pid=%d) with signal %u: %s", params->pid, params->signal, strerror(errno));
+ SYSERROR("Can not kill process (pid=%d) with signal %u", params->pid, params->signal);
return -1;
}
}
diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c
index d86418b0..fccdf634 100644
--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c
+++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c
@@ -145,7 +145,7 @@ static int shim_bin_v2_create(const char *runtime, const char *id, const char *w
pid = fork();
if (pid < 0) {
- ERROR("Failed to fork for shim parent %s", strerror(errno));
+ SYSERROR("Failed to fork for shim parent");
ret = -1;
goto out;
}
@@ -199,7 +199,7 @@ static int shim_bin_v2_create(const char *runtime, const char *id, const char *w
status = util_wait_for_pid_status(pid);
if (status < 0) {
- ERROR("failed to wait shim-parent %d exit %s", pid, strerror(errno));
+ SYSERROR("failed to wait shim-parent %d exit", pid);
ret = -1;
goto out;
}
diff --git a/src/daemon/modules/service/io_handler.c b/src/daemon/modules/service/io_handler.c
index 0cb9fda9..474fa650 100644
--- a/src/daemon/modules/service/io_handler.c
+++ b/src/daemon/modules/service/io_handler.c
@@ -330,7 +330,7 @@ static ssize_t write_to_fifo(void *context, const void *data, size_t len)
fd = *(int *)context;
ret = util_write_nointr_in_total(fd, data, len);
if ((ret <= 0) || (ret != (ssize_t)len)) {
- ERROR("Failed to write %d: %s", fd, strerror(errno));
+ SYSERROR("Failed to write %d", fd);
return -1;
}
return ret;
@@ -341,7 +341,7 @@ static ssize_t write_to_fd(void *context, const void *data, size_t len)
ssize_t ret;
ret = util_write_nointr(*(int *)context, data, len);
if (ret < 0 || (size_t)ret != len) {
- ERROR("Failed to write: %s", strerror(errno));
+ SYSERROR("Failed to write");
return -1;
}
return ret;
diff --git a/src/daemon/modules/service/network_namespace_api.c b/src/daemon/modules/service/network_namespace_api.c
index 4cf44b6a..11246ffb 100644
--- a/src/daemon/modules/service/network_namespace_api.c
+++ b/src/daemon/modules/service/network_namespace_api.c
@@ -50,7 +50,7 @@ int remove_network_namespace(const char *netns_path)
}
if (umount2(netns_path, MNT_DETACH) != 0 && errno != EINVAL) {
- ERROR("Failed to umount directory %s:%s", netns_path, strerror(errno));
+ SYSERROR("Failed to umount directory %s", netns_path);
return -1;
}
diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c
index 5d8fdf6c..c776e53f 100644
--- a/src/daemon/modules/service/service_container.c
+++ b/src/daemon/modules/service/service_container.c
@@ -565,7 +565,7 @@ static int umount_dev_tmpfs_for_system_container(const container_t *cont)
return -1;
}
if (umount(rootfs_dev_path) < 0 && errno != ENOENT) {
- WARN("Failed to umount dev tmpfs: %s, error: %s", rootfs_dev_path, strerror(errno));
+ SYSWARN("Failed to umount dev tmpfs: %s", rootfs_dev_path);
}
}
return 0;
@@ -585,7 +585,7 @@ static int valid_mount_point(container_config_v2_common_config_mount_points_elem
}
if (lstat(mp->source, &st) != 0) {
- ERROR("lstat %s: %s", mp->source, strerror(errno));
+ SYSERROR("lstat %s failed", mp->source);
isulad_set_error_message("lstat %s: %s", mp->source, strerror(errno));
return -1;
}
@@ -669,8 +669,7 @@ static void wait_exit_fifo(const char *id, const int exit_fifo_fd)
descr.timeout_cbdata = container_id;
nret = epoll_loop(&descr, WAIT_TIMEOUT);
if (nret != 0) {
- ERROR("Wait container %s 's monitor on fd %d error: %s", id, exit_fifo_fd,
- errno ? strerror(errno) : "");
+ SYSERROR("Wait container %s 's monitor on fd %d failed", id, exit_fifo_fd);
goto out;
}
@@ -1160,7 +1159,7 @@ static int do_delete_container(container_t *cont)
}
ret = util_recursive_rmdir(container_state, 0);
if (ret != 0) {
- ERROR("Failed to delete container's state directory %s: %s", container_state, strerror(errno));
+ SYSERROR("Failed to delete container's state directory %s", container_state);
ret = -1;
goto out;
}
@@ -1289,7 +1288,7 @@ static int send_signal_to_process(pid_t pid, unsigned long long start_time, uint
} else {
int ret = kill(pid, (int)signal);
if (ret < 0) {
- ERROR("Can not kill process (pid=%d) with signal %u: %s", pid, signal, strerror(errno));
+ SYSERROR("Can not kill process (pid=%d) with signal %u", pid, signal);
return -1;
}
}
@@ -1957,7 +1956,7 @@ static int exec_prepare_console(const container_t *cont, const container_exec_re
*sync_fd = eventfd(0, EFD_CLOEXEC);
if (*sync_fd < 0) {
- ERROR("Failed to create eventfd: %s", strerror(errno));
+ SYSERROR("Failed to create eventfd");
ret = -1;
goto out;
}
@@ -1984,7 +1983,7 @@ static void exec_container_end(container_exec_response *response, uint32_t cc, i
}
if (sync_fd >= 0 && cc != ISULAD_SUCCESS) {
if (eventfd_write(sync_fd, 1) < 0) {
- ERROR("Failed to write eventfd: %s", strerror(errno));
+ SYSERROR("Failed to write eventfd");
}
}
if (thread_id > 0) {
diff --git a/src/daemon/modules/spec/specs.c b/src/daemon/modules/spec/specs.c
index 9fec586e..0c7d58b3 100644
--- a/src/daemon/modules/spec/specs.c
+++ b/src/daemon/modules/spec/specs.c
@@ -2318,7 +2318,7 @@ int save_oci_config(const char *id, const char *rootpath, const oci_runtime_spec
if (util_atomic_write_file(file_path, json_container, strlen(json_container), DEFAULT_SECURE_FILE_MODE, false) !=
0) {
- ERROR("write json container failed: %s", strerror(errno));
+ SYSERROR("write json container failed");
ret = -1;
goto out_free;
}
diff --git a/src/daemon/modules/spec/specs_mount.c b/src/daemon/modules/spec/specs_mount.c
index 3b26e091..cd3a5c9d 100644
--- a/src/daemon/modules/spec/specs_mount.c
+++ b/src/daemon/modules/spec/specs_mount.c
@@ -1430,7 +1430,7 @@ static int copy_data_to_volume(char *base_fs, defs_mount *mnt)
if (errno == ENOENT) {
goto out;
}
- ERROR("stat for copy data to volume failed: %s", strerror(errno));
+ SYSERROR("stat for copy data to volume failed");
ret = -1;
goto out;
}
@@ -2727,7 +2727,7 @@ static int create_shm_path(const char *spath, const int64_t shm_size)
nret = mount("shm", spath, "tmpfs", MS_NOEXEC | MS_NODEV | MS_NOSUID, shmproperty);
if (nret < 0) {
- ERROR("Mount %s failed: %s", spath, strerror(errno));
+ SYSERROR("Mount %s failed", spath);
return -1;
}
diff --git a/src/daemon/modules/spec/verify.c b/src/daemon/modules/spec/verify.c
index 64cf7f18..5b6f298f 100644
--- a/src/daemon/modules/spec/verify.c
+++ b/src/daemon/modules/spec/verify.c
@@ -248,7 +248,7 @@ static bool check_kernel_version_ge4()
ret = uname(&uts);
if (ret < 0) {
- WARN("Can not get kernel version: %s", strerror(errno));
+ SYSWARN("Can not get kernel version");
} else {
/* greater or equal than 4.0.0, check first part is enough */
return atoi(uts.release) >= 4;
@@ -1306,7 +1306,7 @@ static int get_source_mount(const char *src, char **srcpath, char **optional)
char *dname = NULL;
if (realpath(src, real_path) == NULL) {
- ERROR("Failed to get real path for %s : %s", src, strerror(errno));
+ SYSERROR("Failed to get real path for %s", src);
return -1;
}
@@ -1509,7 +1509,7 @@ static int verify_custom_mount(defs_mount **mounts, size_t len)
#else
if (!util_file_exists(iter->source) && util_mkdir_p(iter->source, mode)) {
#endif
- ERROR("Failed to create directory '%s': %s", iter->source, strerror(errno));
+ SYSERROR("Failed to create directory '%s'", iter->source);
isulad_try_set_error_message("Failed to create directory '%s': %s", iter->source, strerror(errno));
ret = -1;
goto out;
diff --git a/src/daemon/modules/volume/local.c b/src/daemon/modules/volume/local.c
index c46d4de0..f14025e4 100644
--- a/src/daemon/modules/volume/local.c
+++ b/src/daemon/modules/volume/local.c
@@ -165,7 +165,7 @@ static int init_volume_root_dir(struct volumes_info *vols_info, char *root_dir)
ret = util_mkdir_p(root_dir, LOCAL_VOLUME_ROOT_DIR_MODE);
if (ret != 0) {
- ERROR("create volume directory %s failed: %s", root_dir, strerror(errno));
+ SYSERROR("create volume directory %s failed", root_dir);
goto out;
}
@@ -229,7 +229,7 @@ static char *build_and_valid_data_dir(const char *root_dir, const char *name)
}
if (lstat(tmp_dir, &st) != 0) {
- ERROR("lstat %s: %s", tmp_dir, strerror(errno));
+ SYSERROR("lstat %s failed", tmp_dir);
ret = -1;
goto out;
}
@@ -388,7 +388,7 @@ static struct volume *volume_create_nolock(char *name)
ret = util_mkdir_p(v->path, LOCAL_VOLUME_DIR_MODE);
if (ret != 0) {
- ERROR("failed to create %s for volume %s: %s", v->path, v->name, strerror(errno));
+ SYSERROR("failed to create %s for volume %s", v->path, v->name);
goto out;
}
@@ -556,14 +556,14 @@ static int remove_volume_dir(char *path)
// remain untouched if we remove the data directory failed.
ret = util_recursive_rmdir(path, 0);
if (ret != 0) {
- ERROR("failed to remove volume data dir %s: %s", path, strerror(errno));
+ SYSERROR("failed to remove volume data dir %s", path);
isulad_try_set_error_message("failed to remove volume data dir %s: %s", path, strerror(errno));
goto out;
}
ret = util_recursive_rmdir(vol_dir, 0);
if (ret != 0) {
- ERROR("failed to remove volume dir %s: %s", vol_dir, strerror(errno));
+ SYSERROR("failed to remove volume dir %s", vol_dir);
isulad_try_set_error_message("failed to remove volume dir %s: %s", vol_dir, strerror(errno));
goto out;
}
@@ -586,7 +586,7 @@ static int volume_remove_nolock(char *name)
}
if (remove_volume_dir(v->path) != 0) {
- ERROR("failed to remove volume dir %s: %s", v->path, strerror(errno));
+ SYSERROR("failed to remove volume dir %s", v->path);
return -1;
}
diff --git a/src/utils/console/console.c b/src/utils/console/console.c
index a160d685..3ef88564 100644
--- a/src/utils/console/console.c
+++ b/src/utils/console/console.c
@@ -36,7 +36,7 @@ static ssize_t fd_write_function(void *context, const void *data, size_t len)
ret = util_write_nointr_in_total(*(int *)context, data, len);
if ((ret <= 0) || (ret != (ssize_t)len)) {
- ERROR("Failed to write: %s", strerror(errno));
+ SYSERROR("Failed to write");
return -1;
}
return ret;
@@ -100,7 +100,7 @@ static int console_writer_write_data(const struct io_write_wrapper *writer, cons
}
ret = writer->write_func(writer->context, buf, (size_t)len);
if (ret <= 0 || ret != len) {
- ERROR("Failed to write, type: %d, expect: %zd, wrote: %zd, error: %s!", writer->io_type, len, ret, strerror(errno));
+ SYSERROR("Failed to write, type: %d, expect: %zd, wrote: %zd!", writer->io_type, len, ret);
return -1;
}
return 0;
@@ -215,7 +215,7 @@ int console_fifo_create(const char *fifo_path)
ret = mknod(fifo_path, S_IFIFO | S_IRUSR | S_IWUSR, (dev_t)0);
if (ret < 0 && errno != EEXIST) {
- ERROR("Failed to mknod monitor fifo %s: %s.", fifo_path, strerror(errno));
+ SYSERROR("Failed to mknod monitor fifo %s.", fifo_path);
return -1;
}
@@ -265,7 +265,7 @@ int console_fifo_open(const char *fifo_path, int *fdout, int flags)
fd = util_open(fifo_path, flags, (mode_t)0);
if (fd < 0) {
- ERROR("Failed to open fifo %s to send message: %s.", fifo_path, strerror(errno));
+ SYSERROR("Failed to open fifo %s to send message.", fifo_path);
return -1;
}
@@ -281,7 +281,7 @@ int console_fifo_open_withlock(const char *fifo_path, int *fdout, int flags)
fd = util_open(fifo_path, flags, 0);
if (fd < 0) {
- WARN("Failed to open fifo %s to send message: %s.", fifo_path, strerror(errno));
+ SYSWARN("Failed to open fifo %s to send message.", fifo_path);
return -1;
}
@@ -411,12 +411,12 @@ int console_loop_with_std_fd(int stdinfd, int stdoutfd, int stderrfd, int fifoin
if (tty) {
ret = epoll_loop_add_handler(&descr, ts.stdin_reader, console_cb_tty_stdin_with_escape, &ts);
if (ret) {
- INFO("Add handler for stdinfd faied. with error %s", strerror(errno));
+ SYSINFO("Add handler for stdinfd faied.");
}
} else {
ret = epoll_loop_add_handler(&descr, ts.stdin_reader, console_cb_stdio_copy, &ts);
if (ret) {
- INFO("Add handler for stdinfd faied. with error %s", strerror(errno));
+ SYSINFO("Add handler for stdinfd faied.");
}
}
}
diff --git a/src/utils/cutils/path.c b/src/utils/cutils/path.c
index d586e981..51d73445 100644
--- a/src/utils/cutils/path.c
+++ b/src/utils/cutils/path.c
@@ -698,7 +698,7 @@ static char *find_realpath(const char *path)
ret = (int)readlink(iter_path, target, PATH_MAX - 1);
if (ret < 0) {
- ERROR("Failed to read link of %s: %s", iter_path, strerror(errno));
+ SYSERROR("Failed to read link of %s.", iter_path);
goto out;
}
// is not absolutely path
@@ -745,7 +745,7 @@ int util_realpath_in_scope(const char *rootfs, const char *path, char **real_pat
int nret = snprintf(full_path, sizeof(full_path), "%s%s", rootfs, path);
if (nret < 0 || (size_t)nret >= sizeof(full_path)) {
- ERROR("sprintf error: %s", strerror(errno));
+ SYSERROR("sprintf failed");
ret = -1;
goto out;
}
diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c
index d628e1f6..a994731d 100644
--- a/src/utils/cutils/utils.c
+++ b/src/utils/cutils/utils.c
@@ -474,7 +474,7 @@ proc_t *util_stat2proc(const char *s, size_t len)
num = sscanf(s, "%d (%15c", &p->pid, p->cmd);
#endif
if (num != 2) {
- ERROR("Call sscanf error: %s", errno ? strerror(errno) : "");
+ SYSERROR("Call sscanf error");
free(p);
return NULL;
}
@@ -489,7 +489,7 @@ proc_t *util_stat2proc(const char *s, size_t len)
&p->maj_flt, &p->cmaj_flt, &p->utime, &p->stime, &p->cutime, &p->cstime, &p->priority, &p->nice,
&p->timeout, &p->it_real_value, &p->start_time);
if (num != 20) { // max arg to read
- ERROR("Call sscanf error: %s", errno ? strerror(errno) : "");
+ SYSERROR("Call sscanf error");
free(p);
return NULL;
}
@@ -1137,7 +1137,7 @@ static int set_echo_back(bool echo_back)
struct termios old, new;
if (tcgetattr(STDIN_FILENO, &old)) {
- ERROR("get tc attribute failed: %s\n", strerror(errno));
+ SYSERROR("get tc attribute failed");
return -1;
}
@@ -1150,7 +1150,7 @@ static int set_echo_back(bool echo_back)
}
if (tcsetattr(STDIN_FILENO, TCSANOW, &new)) {
- ERROR("set tc attribute failed: %s\n", strerror(errno));
+ SYSERROR("set tc attribute failed");
return -1;
}
@@ -1413,7 +1413,7 @@ int util_normalized_host_os_arch(char **host_os, char **host_arch, char **host_v
}
if (uname(&uts) < 0) {
- ERROR("Failed to read host arch and os: %s", strerror(errno));
+ SYSERROR("Failed to read host arch and os");
ret = -1;
goto out;
}
diff --git a/src/utils/cutils/utils_aes.c b/src/utils/cutils/utils_aes.c
index 055a9538..2eecf2d6 100644
--- a/src/utils/cutils/utils_aes.c
+++ b/src/utils/cutils/utils_aes.c
@@ -72,13 +72,13 @@ int util_aes_key(const char *key_file, bool create, unsigned char *aeskey)
} else {
fd = open(key_file, O_RDONLY);
if (fd < 0) {
- ERROR("open key file %s failed: %s", key_file, strerror(errno));
+ SYSERROR("open key file %s failed", key_file);
ret = -1;
goto out;
}
if (util_read_nointr(fd, aeskey, AES_256_CFB_KEY_LEN) != AES_256_CFB_KEY_LEN) {
- ERROR("read key file %s failed: %s", key_file, strerror(errno));
+ SYSERROR("read key file %s failed", key_file);
ret = -1;
goto out;
}
@@ -163,14 +163,14 @@ int util_aes_encode(unsigned char *aeskey, unsigned char *bytes, size_t len, uns
evp_ret = EVP_EncryptInit(ctx, cipher, aeskey, iv);
#endif
if (evp_ret != 1) {
- ERROR("init evp decrypt failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("init evp decrypt failed, result %d", evp_ret);
ret = -1;
goto out;
}
evp_ret = EVP_EncryptUpdate(ctx, (*out) + AES_256_CFB_IV_LEN, &tmp_out_len, bytes, len);
if (evp_ret != 1) {
- ERROR("evp encrypt update failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("evp encrypt update failed, result %d", evp_ret);
ret = -1;
goto out;
}
@@ -182,7 +182,7 @@ int util_aes_encode(unsigned char *aeskey, unsigned char *bytes, size_t len, uns
evp_ret = EVP_EncryptFinal(ctx, (*out) + AES_256_CFB_IV_LEN + tmp_out_len, &tmp_out_len);
#endif
if (evp_ret != 1) {
- ERROR("evp encrypt final failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("evp encrypt final failed, result %d", evp_ret);
ret = -1;
goto out;
}
@@ -256,7 +256,7 @@ int util_aes_decode(unsigned char *aeskey, unsigned char *bytes, size_t len, uns
evp_ret = EVP_DecryptInit(ctx, cipher, aeskey, iv);
#endif
if (evp_ret != 1) {
- ERROR("init evp decrypt failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("init evp decrypt failed, result %d", evp_ret);
ret = -1;
goto out;
}
@@ -264,7 +264,7 @@ int util_aes_decode(unsigned char *aeskey, unsigned char *bytes, size_t len, uns
expected_size = len - AES_256_CFB_IV_LEN;
evp_ret = EVP_DecryptUpdate(ctx, *out, &tmp_out_len, bytes + AES_256_CFB_IV_LEN, expected_size);
if (evp_ret != 1) {
- ERROR("evp decrypt update failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("evp decrypt update failed, result %d", evp_ret);
ret = -1;
goto out;
}
@@ -276,7 +276,7 @@ int util_aes_decode(unsigned char *aeskey, unsigned char *bytes, size_t len, uns
evp_ret = EVP_DecryptFinal(ctx, (*out) + tmp_out_len, &tmp_out_len);
#endif
if (evp_ret != 1) {
- ERROR("evp decrypt final failed, result %d: %s", evp_ret, strerror(errno));
+ SYSERROR("evp decrypt final failed, result %d", evp_ret);
ret = -1;
goto out;
}
diff --git a/src/utils/cutils/utils_base64.c b/src/utils/cutils/utils_base64.c
index 3871140e..78e5ae0d 100644
--- a/src/utils/cutils/utils_base64.c
+++ b/src/utils/cutils/utils_base64.c
@@ -47,7 +47,7 @@ int util_base64_encode(unsigned char *bytes, size_t len, char **out)
}
if (EVP_EncodeBlock((uint8_t *)(*out), (const uint8_t *)bytes, len) == 0) {
- ERROR("Encode base64 failed: %s", strerror(errno));
+ SYSERROR("Encode base64 failed");
free(encoded);
return -1;
}
@@ -78,7 +78,7 @@ int util_base64_decode(const char *input, size_t len, unsigned char **out, size_
}
if (EVP_DecodeBase64((uint8_t *)decoded, &decoded_size, decoded_size, (const uint8_t *)input, len) == 0) {
- ERROR("Decode base64 failed: %s", strerror(errno));
+ SYSERROR("Decode base64 failed");
free(decoded);
return -1;
}
diff --git a/src/utils/cutils/utils_file.c b/src/utils/cutils/utils_file.c
index 0b73e652..749cdb16 100644
--- a/src/utils/cutils/utils_file.c
+++ b/src/utils/cutils/utils_file.c
@@ -227,7 +227,7 @@ int util_mkdir_p_userns_remap(const char *dir, mode_t mode, const char *userns_r
if (*cur_dir) {
ret = mkdir(cur_dir, mode);
if (ret != 0 && (errno != EEXIST || !util_dir_exists(cur_dir))) {
- ERROR("failed to create directory '%s': %s", cur_dir, strerror(errno));
+ SYSERROR("failed to create directory '%s'", cur_dir);
goto err_out;
}
if (ret == 0 && userns_remap != NULL && chown(cur_dir, host_uid, host_gid) != 0) {
@@ -314,14 +314,14 @@ bool util_force_remove_file(const char *fname, int *saved_errno)
if (saved_errno != NULL && *saved_errno == 0) {
*saved_errno = errno;
}
- WARN("Failed to delete %s: %s", fname, strerror(errno));
+ SYSWARN("Failed to delete %s", fname);
if (mark_file_mutable(fname) != 0) {
WARN("Failed to mark file mutable");
}
if (unlink(fname) != 0) {
- ERROR("Failed to delete \"%s\": %s", fname, strerror(errno));
+ SYSERROR("Failed to delete \"%s\"", fname);
return false;
}
@@ -337,7 +337,7 @@ static int recursive_rmdir_next_depth(struct stat fstat, const char *fname, int
}
} else {
if (unlink(fname) < 0) {
- ERROR("Failed to delete %s: %s", fname, strerror(errno));
+ SYSERROR("Failed to delete %s", fname);
if (*saved_errno == 0) {
*saved_errno = errno;
}
@@ -347,7 +347,7 @@ static int recursive_rmdir_next_depth(struct stat fstat, const char *fname, int
}
if (unlink(fname) < 0) {
- ERROR("Failed to delete \"%s\": %s", fname, strerror(errno));
+ SYSERROR("Failed to delete \"%s\"", fname);
failure = 1;
}
}
@@ -721,7 +721,7 @@ int util_gzip_compressed(const char *filename, bool *gzip)
f = fopen(filename, "rb");
if (f == NULL) {
- ERROR("Failed to open file %s: %s", filename, strerror(errno));
+ SYSERROR("Failed to open file %s", filename);
return -1;
}
@@ -897,7 +897,7 @@ char *util_read_text_file(const char *path)
readlen = fread(buf, 1, (size_t)len, filp);
if (((readlen < (size_t)len) && (!feof(filp))) || (readlen > (size_t)len)) {
- ERROR("Failed to read file %s, error: %s\n", path, strerror(errno));
+ SYSERROR("Failed to read file %s.", path);
UTIL_FREE_AND_SET_NULL(buf);
goto err_out;
}
@@ -923,7 +923,7 @@ int64_t util_file_size(const char *filename)
}
if (stat(filename, &st)) {
- WARN("stat file %s failed: %s", filename, strerror(errno));
+ SYSWARN("stat file %s failed", filename);
return -1;
}
@@ -942,7 +942,7 @@ int util_scan_subdirs(const char *directory, subdir_callback_t cb, void *context
dir = opendir(directory);
if (dir == NULL) {
- ERROR("Failed to open directory: %s error:%s", directory, strerror(errno));
+ SYSERROR("Failed to open directory: %s", directory);
return -1;
}
@@ -977,7 +977,7 @@ int util_list_all_subdir(const char *directory, char ***out)
dir = opendir(directory);
if (dir == NULL) {
- ERROR("Failed to open directory: %s error:%s", directory, strerror(errno));
+ SYSERROR("Failed to open directory: %s", directory);
return -1;
}
direntp = readdir(dir);
@@ -1125,14 +1125,14 @@ int util_write_file(const char *fname, const char *content, size_t content_len,
}
dst_fd = util_open(fname, O_WRONLY | O_CREAT | O_TRUNC, mode);
if (dst_fd < 0) {
- ERROR("Creat file: %s, failed: %s", fname, strerror(errno));
+ SYSERROR("Creat file: %s, failed", fname);
ret = -1;
goto free_out;
}
len = util_write_nointr(dst_fd, content, content_len);
if (len < 0 || ((size_t)len) != content_len) {
ret = -1;
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
goto free_out;
}
free_out:
@@ -1151,7 +1151,7 @@ char *verify_file_and_get_real_path(const char *file)
return NULL;
}
if (realpath(file, resolved_path) == NULL) {
- ERROR("Failed to get realpath: %s , %s", resolved_path, strerror(errno));
+ SYSERROR("Failed to get realpath: %s.", resolved_path);
return NULL;
}
@@ -1181,33 +1181,33 @@ int util_copy_file(const char *src_file, const char *dst_file, mode_t mode)
}
nret = realpath(src_file, real_src_file);
if (nret == NULL) {
- ERROR("real path: %s, return: %s", src_file, strerror(errno));
+ SYSERROR("real path: %s failed.", src_file);
ret = -1;
return ret;
}
src_fd = util_open(real_src_file, O_RDONLY, CONFIG_FILE_MODE);
if (src_fd < 0) {
- ERROR("Open src file: %s, failed: %s", real_src_file, strerror(errno));
+ SYSERROR("Open src file: %s, failed", real_src_file);
ret = -1;
goto free_out;
}
dst_fd = util_open(dst_file, O_WRONLY | O_CREAT | O_TRUNC, mode);
if (dst_fd < 0) {
- ERROR("Creat file: %s, failed: %s", dst_file, strerror(errno));
+ SYSERROR("Creat file: %s, failed", dst_file);
ret = -1;
goto free_out;
}
while (true) {
ssize_t len = util_read_nointr(src_fd, buf, BUFSIZE);
if (len < 0) {
- ERROR("Read src file failed: %s", strerror(errno));
+ SYSERROR("Read src file failed");
ret = -1;
goto free_out;
} else if (len == 0) {
break;
}
if (util_write_nointr(dst_fd, buf, (size_t)len) != len) {
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
ret = -1;
goto free_out;
}
@@ -1499,7 +1499,7 @@ static int do_atomic_write_file(const char *fname, const char *content, size_t c
dst_fd = util_open(fname, O_WRONLY | O_CREAT | O_TRUNC, mode);
if (dst_fd < 0) {
- ERROR("Creat file: %s, failed: %s", fname, strerror(errno));
+ SYSERROR("Creat file: %s, failed", fname);
ret = -1;
goto free_out;
}
@@ -1507,7 +1507,7 @@ static int do_atomic_write_file(const char *fname, const char *content, size_t c
len = util_write_nointr(dst_fd, content, content_len);
if (len < 0 || ((size_t)len) != content_len) {
ret = -1;
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
goto free_out;
}
@@ -1683,7 +1683,7 @@ int util_proc_file_line_by_line(FILE *fp, read_line_callback_t cb, void *context
// end of file
if (errno != 0) {
ret = -1;
- ERROR("read line failed: %s", strerror(errno));
+ SYSERROR("read line failed");
}
goto out;
}
@@ -1771,7 +1771,7 @@ static int copy_own(char *copy_dst, struct stat *src_stat)
struct stat dst_stat = { 0 };
if (lstat(copy_dst, &dst_stat) != 0) {
- ERROR("lstat %s failed: %s", copy_dst, strerror(errno));
+ SYSERROR("lstat %s failed", copy_dst);
return -1;
}
@@ -1780,7 +1780,7 @@ static int copy_own(char *copy_dst, struct stat *src_stat)
return 0;
}
- ERROR("lchown %s failed: %s", copy_dst, strerror(errno));
+ SYSERROR("lchown %s failed", copy_dst);
return ret;
}
@@ -1792,7 +1792,7 @@ static int copy_mode(char *copy_dst, struct stat *src_stat)
}
if (chmod(copy_dst, src_stat->st_mode) != 0) {
- ERROR("chmod %s failed: %s", copy_dst, strerror(errno));
+ SYSERROR("chmod %s failed", copy_dst);
return -1;
}
@@ -1805,7 +1805,7 @@ static int copy_time(char *copy_dst, struct stat *src_stat)
// copy_dst is absolute path, so first argment is ignored.
if (utimensat(0, copy_dst, tm, AT_SYMLINK_NOFOLLOW) != 0) {
- ERROR("failed to set time of %s: %s", copy_dst, strerror(errno));
+ SYSERROR("failed to set time of %s", copy_dst);
return -1;
}
@@ -1816,10 +1816,10 @@ static int set_one_xattr(char *copy_dst, char *key, char *value, ssize_t size)
{
if (lsetxattr(copy_dst, key, value, size, 0) != 0) {
if (errno == ENOTSUP) {
- DEBUG("ignore copy xattr %s of %s: %s", key, copy_dst, strerror(errno));
+ SYSDEBUG("ignore copy xattr %s of %s", key, copy_dst);
return 0;
}
- ERROR("failed to set xattr %s of %s: %s", key, copy_dst, strerror(errno));
+ SYSERROR("failed to set xattr %s of %s", key, copy_dst);
return -1;
}
@@ -1841,10 +1841,10 @@ static int do_copy_xattrs(char *copy_dst, char *copy_src, char *xattrs, ssize_t
size = lgetxattr(copy_src, key, NULL, 0);
if (size < 0) {
if (errno == ENOTSUP) {
- DEBUG("ignore copy xattr %s of %s: %s", key, copy_src, strerror(errno));
+ SYSDEBUG("ignore copy xattr %s of %s", key, copy_src);
continue;
}
- ERROR("failed to get xattr %s of %s: %s", key, copy_src, strerror(errno));
+ SYSERROR("failed to get xattr %s of %s", key, copy_src);
ret = -1;
goto out;
}
@@ -1865,10 +1865,10 @@ static int do_copy_xattrs(char *copy_dst, char *copy_src, char *xattrs, ssize_t
if (lgetxattr(copy_src, key, value, size) < 0) {
if (errno == ENOTSUP) {
- DEBUG("ignore copy xattr %s of %s: %s", key, copy_src, strerror(errno));
+ SYSDEBUG("ignore copy xattr %s of %s", key, copy_src);
continue;
}
- ERROR("failed to get xattr %s of %s: %s", key, copy_src, strerror(errno));
+ SYSERROR("failed to get xattr %s of %s", key, copy_src);
ret = -1;
goto out;
}
@@ -1894,10 +1894,10 @@ static int copy_xattrs(char *copy_dst, char *copy_src)
xattrs_len = llistxattr(copy_src, NULL, 0);
if (xattrs_len < 0) {
if (errno == ENOTSUP) {
- DEBUG("ignore copy xattrs of %s: %s", copy_src, strerror(errno));
+ SYSDEBUG("ignore copy xattrs of %s", copy_src);
return 0;
}
- ERROR("failed to get xattrs length of %s: %s", copy_src, strerror(errno));
+ SYSERROR("failed to get xattrs length of %s", copy_src);
return -1;
}
@@ -1914,10 +1914,10 @@ static int copy_xattrs(char *copy_dst, char *copy_src)
if (llistxattr(copy_src, xattrs, xattrs_len) < 0) {
if (errno == ENOTSUP) {
- DEBUG("ignore copy xattrs of %s: %s", copy_src, strerror(errno));
+ SYSDEBUG("ignore copy xattrs of %s", copy_src);
goto out;
}
- ERROR("failed to list xattrs of %s: %s", copy_src, strerror(errno));
+ SYSERROR("failed to list xattrs of %s", copy_src);
ret = -1;
goto out;
}
@@ -1963,7 +1963,7 @@ static int copy_folder(char *copy_dst, char *copy_src)
struct stat dst_stat = { 0 };
if (lstat(copy_src, &src_stat) != 0) {
- ERROR("stat %s failed: %s", copy_src, strerror(errno));
+ SYSERROR("stat %s failed", copy_src);
return -1;
}
if (!S_ISDIR(src_stat.st_mode)) {
@@ -1973,7 +1973,7 @@ static int copy_folder(char *copy_dst, char *copy_src)
if (lstat(copy_dst, &dst_stat) != 0) {
if (mkdir(copy_dst, src_stat.st_mode) != 0) {
- ERROR("failed to mkdir %s: %s", copy_dst, strerror(errno));
+ SYSERROR("failed to mkdir %s", copy_dst);
return -1;
}
} else if (!S_ISDIR(dst_stat.st_mode)) {
@@ -1981,7 +1981,7 @@ static int copy_folder(char *copy_dst, char *copy_src)
return -1;
} else {
if (chmod(copy_dst, src_stat.st_mode) != 0) {
- ERROR("failed to chmod %s: %s", copy_dst, strerror(errno));
+ SYSERROR("failed to chmod %s.", copy_dst);
return -1;
}
}
@@ -1998,7 +1998,7 @@ static int copy_regular(char *copy_dst, char *copy_src, struct stat *src_stat, m
target = map_search(inodes, (void *)(&(src_stat->st_ino)));
if (target != NULL) {
if (link(target, copy_dst) != 0) {
- ERROR("failed to link %s to %s: %s", target, copy_dst, strerror(errno));
+ SYSERROR("failed to link %s to %s", target, copy_dst);
return -1;
}
return 0;
@@ -2018,12 +2018,12 @@ static int copy_symbolic(char *copy_dst, char *copy_src)
char link[PATH_MAX] = { 0 };
if (readlink(copy_src, link, sizeof(link)) < 0) {
- ERROR("readlink of %s failed: %s", copy_src, strerror(errno));
+ SYSERROR("readlink of %s failed", copy_src);
return -1;
}
if (symlink(link, copy_dst) != 0) {
- ERROR("create symbolic %s failed: %s", copy_dst, strerror(errno));
+ SYSERROR("create symbolic %s failed", copy_dst);
return -1;
}
@@ -2033,7 +2033,7 @@ static int copy_symbolic(char *copy_dst, char *copy_src)
static int copy_device(char *copy_dst, char *copy_src, struct stat *src_stat)
{
if (mknod(copy_dst, src_stat->st_mode, src_stat->st_dev) != 0) {
- ERROR("mknod %s failed: %s", copy_dst, strerror(errno));
+ SYSERROR("mknod %s failed", copy_dst);
return -1;
}
return 0;
diff --git a/src/utils/cutils/utils_fs.c b/src/utils/cutils/utils_fs.c
index ae71f3ba..63f6d2aa 100644
--- a/src/utils/cutils/utils_fs.c
+++ b/src/utils/cutils/utils_fs.c
@@ -449,7 +449,7 @@ static int do_real_mount(const char *src, const char *dst, const char *mtype, un
if (!is_remount(src, mntflags) || (mntdata != NULL && strcmp(mntdata, "") != 0)) {
ret = mount(src, dst, mtype, oflags, mntdata);
if (ret < 0) {
- ERROR("Failed to mount from %s to %s:%s", src, dst, strerror(errno));
+ SYSERROR("Failed to mount from %s to %s", src, dst);
goto out;
}
}
@@ -458,7 +458,7 @@ static int do_real_mount(const char *src, const char *dst, const char *mtype, un
// Change the propagation type.
ret = mount("", dst, "", mntflags & PROPAGATION_FLAGS, "");
if (ret < 0) {
- ERROR("Failed to change the propagation type of dst %s:%s", dst, strerror(errno));
+ SYSERROR("Failed to change the propagation type of dst %s.", dst);
goto out;
}
}
@@ -467,7 +467,7 @@ static int do_real_mount(const char *src, const char *dst, const char *mtype, un
// Remount the bind to apply read only.
ret = mount("", dst, "", oflags | MS_REMOUNT, "");
if (ret < 0) {
- ERROR("Failed to remount the bind to apply read only of dst %s:%s", dst, strerror(errno));
+ SYSERROR("Failed to remount the bind to apply read only of dst %s.", dst);
goto out;
}
}
@@ -576,7 +576,7 @@ static int util_mount_from_handler(const char *src, const char *dst, const char
ret = mount(src, dst, mtype, mntflags, mntdata);
if (ret < 0) {
- ERROR("Failed to mount from %s to %s:%s", src, dst, strerror(errno));
+ SYSERROR("Failed to mount from %s to %s.", src, dst);
goto out;
}
out:
@@ -596,7 +596,7 @@ int util_mount_from(const char *base, const char *src, const char *dst, const ch
pid = fork();
if (pid == (pid_t) -1) {
- ERROR("Failed to fork: %s", strerror(errno));
+ SYSERROR("Failed to fork");
goto cleanup;
}
@@ -652,7 +652,7 @@ bool util_check_readonly_fs(const char *path)
continue;
}
- ERROR("Stat fs failed: %s", strerror(errno));
+ SYSERROR("Stat fs failed");
return false;
}
diff --git a/src/utils/cutils/utils_verify.c b/src/utils/cutils/utils_verify.c
index 6fec2c9a..d4c46199 100644
--- a/src/utils/cutils/utils_verify.c
+++ b/src/utils/cutils/utils_verify.c
@@ -474,7 +474,7 @@ bool util_valid_file(const char *path, uint32_t fmod)
nret = stat(path, &s);
if (nret < 0) {
- ERROR("stat failed, error: %s", strerror(errno));
+ SYSERROR("stat failed");
return false;
}
diff --git a/src/utils/http/http.c b/src/utils/http/http.c
index 1b0ba5be..52b05fa3 100644
--- a/src/utils/http/http.c
+++ b/src/utils/http/http.c
@@ -323,7 +323,7 @@ static int ensure_path_file(char **rpath, void *output, bool resume, FILE **page
if (resume) {
mode = "a";
if (stat(*rpath, &st) < 0) {
- ERROR("stat %s failed: %s", *rpath, strerror(errno));
+ SYSERROR("stat %s failed", *rpath);
return -1;
}
*fsize = (size_t)st.st_size;
diff --git a/src/utils/sha256/sha256.c b/src/utils/sha256/sha256.c
index 674c3289..4e692355 100644
--- a/src/utils/sha256/sha256.c
+++ b/src/utils/sha256/sha256.c
@@ -124,7 +124,7 @@ char *sha256_digest_file(const char *filename, bool isgzip)
stream = (void *)fopen(filename, "r");
}
if (stream == NULL) {
- ERROR("open file %s failed: %s", filename, strerror(errno));
+ SYSERROR("open file %s failed", filename);
return NULL;
}
@@ -259,13 +259,13 @@ static char *cal_file_digest(const char *filename)
fp = util_fopen(filename, "r");
if (fp == NULL) {
- ERROR("failed to open file %s: %s", filename, strerror(errno));
+ SYSERROR("failed to open file %s.", filename);
return NULL;
}
digest = sha256_digest_file(filename, false);
if (digest == NULL) {
- ERROR("calc digest for file %s failed: %s", filename, strerror(errno));
+ SYSERROR("calc digest for file %s failed", filename);
goto err_out;
}
@@ -299,7 +299,7 @@ static char *cal_gzip_digest(const char *filename)
digest = sha256_digest_file(filename, true);
if (digest == NULL) {
- ERROR("calc digest for file %s failed: %s", filename, strerror(errno));
+ SYSERROR("calc digest for file %s failed", filename);
goto err_out;
}
diff --git a/src/utils/tar/isulad_tar.c b/src/utils/tar/isulad_tar.c
index 751616e7..fa844919 100644
--- a/src/utils/tar/isulad_tar.c
+++ b/src/utils/tar/isulad_tar.c
@@ -114,7 +114,7 @@ static int resolve_host_source_path(const char *path, bool follow_link, char **r
if (follow_link) {
if (realpath(path, real_path) == NULL) {
- ERROR("Can not get real path of %s: %s", real_path, strerror(errno));
+ SYSERROR("Can not get real path of %s.", real_path);
format_errorf(err, "Can not get real path of %s: %s", real_path, strerror(errno));
return -1;
}
@@ -131,7 +131,7 @@ static int resolve_host_source_path(const char *path, bool follow_link, char **r
goto cleanup;
}
if (realpath(dirpath, real_path) == NULL) {
- ERROR("Can not get real path of %s: %s", dirpath, strerror(errno));
+ SYSERROR("Can not get real path of %s.", dirpath);
format_errorf(err, "Can not get real path of %s: %s", dirpath, strerror(errno));
goto cleanup;
}
@@ -192,7 +192,7 @@ struct archive_copy_info *copy_info_source_path(const char *path, bool follow_li
nret = lstat(resolved_path, &st);
if (nret < 0) {
- ERROR("lstat %s: %s", resolved_path, strerror(errno));
+ SYSERROR("lstat %s failed", resolved_path);
format_errorf(err, "lstat %s: %s", resolved_path, strerror(errno));
goto cleanup;
}
@@ -226,7 +226,7 @@ static int copy_info_destination_path_ret(struct archive_copy_info *info, struct
ret = (int)readlink(iter_path, target, PATH_MAX);
if (ret < 0) {
- ERROR("Failed to read link of %s: %s", iter_path, strerror(errno));
+ SYSERROR("Failed to read link of %s", iter_path);
format_errorf(err, "Failed to read link of %s: %s", iter_path, strerror(errno));
goto cleanup;
}
@@ -259,7 +259,7 @@ static int copy_info_destination_path_ret(struct archive_copy_info *info, struct
if (ret != 0) {
char *dst_parent = NULL;
if (errno != ENOENT) {
- ERROR("Can not stat %s: %s", iter_path, strerror(errno));
+ SYSERROR("Can not stat %s", iter_path);
format_errorf(err, "Can not stat %s: %s", iter_path, strerror(errno));
goto cleanup;
}
@@ -429,7 +429,7 @@ static int tar_resource_rebase(const char *path, const char *rebase, const char
char *srcbase = NULL;
if (lstat(path, &st) < 0) {
- ERROR("lstat %s: %s", path, strerror(errno));
+ SYSERROR("lstat %s failed", path);
format_errorf(err, "lstat %s: %s", path, strerror(errno));
return -1;
}
diff --git a/src/utils/tar/util_archive.c b/src/utils/tar/util_archive.c
index 46621cc1..89b075d3 100644
--- a/src/utils/tar/util_archive.c
+++ b/src/utils/tar/util_archive.c
@@ -340,7 +340,7 @@ static int copy_data(struct archive *ar, struct archive *aw)
}
r = archive_write_data_block(aw, buff, size, offset);
if (r < ARCHIVE_OK) {
- ERROR("tar extraction error: %s, %s", archive_error_string(aw), strerror(archive_errno(aw)));
+ ERROR("tar extraction error: %s", archive_error_string(aw));
return r;
}
}
@@ -669,7 +669,7 @@ int archive_unpack_handler(const struct io_read_wrapper *content, const struct a
ret = archive_read_open(a, mydata, NULL, read_content, NULL);
if (ret != 0) {
ERROR("Failed to open archive: %s", archive_error_string(a));
- fprintf(stderr, "Failed to open archive: %s", strerror(errno));
+ fprintf(stderr, "Failed to open archive: %s", archive_error_string(a));
ret = -1;
goto out;
}
@@ -685,9 +685,8 @@ int archive_unpack_handler(const struct io_read_wrapper *content, const struct a
}
if (ret != ARCHIVE_OK) {
- ERROR("Warning reading tar header: %s, %s", archive_error_string(a), strerror(archive_errno(a)));
- (void)fprintf(stderr, "Warning reading tar header: %s, %s", archive_error_string(a),
- strerror(archive_errno(a)));
+ ERROR("Warning reading tar header: %s", archive_error_string(a));
+ (void)fprintf(stderr, "Warning reading tar header: %s", archive_error_string(a));
ret = -1;
goto out;
}
@@ -721,26 +720,23 @@ int archive_unpack_handler(const struct io_read_wrapper *content, const struct a
ret = archive_write_header(ext, entry);
if (ret != ARCHIVE_OK) {
- ERROR("Fail to handle tar header: %s, %s", archive_error_string(ext), strerror(archive_errno(ext)));
- (void)fprintf(stderr, "Fail to handle tar header: %s, %s", archive_error_string(ext),
- strerror(archive_errno(ext)));
+ ERROR("Fail to handle tar header: %s", archive_error_string(ext));
+ (void)fprintf(stderr, "Fail to handle tar header: %s", archive_error_string(ext));
ret = -1;
goto out;
} else if (archive_entry_size(entry) > 0) {
ret = copy_data(a, ext);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to do copy tar data: %s, %s", archive_error_string(ext), strerror(archive_errno(ext)));
- (void)fprintf(stderr, "Failed to do copy tar data: %s, %s", archive_error_string(ext),
- strerror(archive_errno(ext)));
+ ERROR("Failed to do copy tar data: %s", archive_error_string(ext));
+ (void)fprintf(stderr, "Failed to do copy tar data: %s", archive_error_string(ext));
ret = -1;
goto out;
}
}
ret = archive_write_finish_entry(ext);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to freeing archive entry: %s, %s", archive_error_string(ext), strerror(archive_errno(ext)));
- (void)fprintf(stderr, "Failed to freeing archive entry: %s, %s", archive_error_string(ext),
- strerror(archive_errno(ext)));
+ ERROR("Failed to freeing archive entry: %s", archive_error_string(ext));
+ (void)fprintf(stderr, "Failed to freeing archive entry: %s", archive_error_string(ext));
ret = -1;
goto out;
}
@@ -821,7 +817,7 @@ int archive_unpack(const struct io_read_wrapper *content, const char *dstdir, co
pid = fork();
if (pid == (pid_t) -1) {
- ERROR("Failed to fork: %s", strerror(errno));
+ SYSERROR("Failed to fork");
goto cleanup;
}
@@ -841,7 +837,7 @@ int archive_unpack(const struct io_read_wrapper *content, const char *dstdir, co
// child process, dup2 pipe_for_read[1] to stderr,
if (dup2(pipe_stderr[1], 2) < 0) {
- ERROR("Dup fd error: %s", strerror(errno));
+ SYSERROR("Dup fd error");
ret = -1;
goto child_out;
}
@@ -873,7 +869,7 @@ child_out:
ret = util_wait_for_pid(pid);
if (ret != 0) {
- ERROR("Wait archive_untar_handler failed with error:%s", strerror(errno));
+ SYSERROR("Wait archive_untar_handler failed");
fcntl(pipe_stderr[0], F_SETFL, O_NONBLOCK);
if (util_read_nointr(pipe_stderr[0], errbuf, BUFSIZ) < 0) {
ERROR("read error message from child failed");
@@ -915,22 +911,21 @@ bool valid_archive_format(const char *file)
ret = archive_read_support_filter_all(read_archive);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to set archive read support filter all, result is %d, errmsg: %s, %s", ret,
- archive_error_string(read_archive), strerror(archive_errno(read_archive)));
+ ERROR("Failed to set archive read support filter all, result is %d, errmsg: %s", ret,
+ archive_error_string(read_archive));
goto out;
}
ret = archive_read_support_format_all(read_archive);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to set archive read support format all, result is %d, errmsg: %s, %s", ret,
- archive_error_string(read_archive), strerror(archive_errno(read_archive)));
+ ERROR("Failed to set archive read support format all, result is %d, errmsg: %s", ret,
+ archive_error_string(read_archive));
goto out;
}
ret = archive_read_open_filename(read_archive, file, ARCHIVE_READ_BUFFER_SIZE);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to open archive %s: %s, %s", file, archive_error_string(read_archive),
- strerror(archive_errno(read_archive)));
+ ERROR("Failed to open archive %s: %s", file, archive_error_string(read_archive));
goto out;
}
@@ -941,15 +936,13 @@ bool valid_archive_format(const char *file)
goto out;
}
if (ret != ARCHIVE_OK) {
- ERROR("Failed to read next header for file %s: %s, %s", file, archive_error_string(read_archive),
- strerror(archive_errno(read_archive)));
+ ERROR("Failed to read next header for file %s: %s", file, archive_error_string(read_archive));
goto out;
}
out:
if (archive_read_free(read_archive) != ARCHIVE_OK) {
- ERROR("Failed to free archive %s: %s, %s", file, archive_error_string(read_archive),
- strerror(archive_errno(read_archive)));
+ ERROR("Failed to free archive %s: %s", file, archive_error_string(read_archive));
}
read_archive = NULL;
@@ -976,19 +969,15 @@ static int copy_data_between_archives(struct archive *ar, struct archive *aw)
goto out;
}
if (size < 0) {
- ERROR("tar archive read result %d, error: %s, %s", ret, archive_error_string(ar),
- strerror(archive_errno(ar)));
- (void)fprintf(stderr, "tar archive read result %d, error: %s, %s", ret, archive_error_string(ar),
- strerror(archive_errno(ar)));
+ ERROR("tar archive read result %d, error: %s", ret, archive_error_string(ar));
+ (void)fprintf(stderr, "tar archive read result %d, error: %s", ret, archive_error_string(ar));
ret = ARCHIVE_FAILED;
goto out;
}
ret = archive_write_data(aw, buff, size);
if (ret < ARCHIVE_OK) {
- ERROR("tar archive write result %d, error: %s, %s", ret, archive_error_string(aw),
- strerror(archive_errno(aw)));
- (void)fprintf(stderr, "tar archive write result %d, error: %s, %s", ret, archive_error_string(aw),
- strerror(archive_errno(aw)));
+ ERROR("tar archive write result %d, error: %s", ret, archive_error_string(aw));
+ (void)fprintf(stderr, "tar archive write result %d, error: %s", ret, archive_error_string(aw));
goto out;
}
}
@@ -1061,8 +1050,8 @@ int tar_handler(struct archive *r, struct archive *w, const char *src_base, cons
}
if (ret != ARCHIVE_OK) {
- ERROR("read from disk failed: %s, %s", archive_error_string(r), strerror(archive_errno(r)));
- (void)fprintf(stderr, "read from disk failed: %s, %s", archive_error_string(r), strerror(archive_errno(r)));
+ ERROR("read from disk failed: %s", archive_error_string(r));
+ (void)fprintf(stderr, "read from disk failed: %s", archive_error_string(r));
break;
}
@@ -1080,37 +1069,34 @@ int tar_handler(struct archive *r, struct archive *w, const char *src_base, cons
}
ret = archive_write_header(w, entry);
if (ret != ARCHIVE_OK) {
- ERROR("Fail to write tar header: %s, %s\nlink:%s target:%s", archive_error_string(w),
- strerror(archive_errno(w)), archive_entry_pathname(entry), archive_entry_hardlink(entry));
- (void)fprintf(stderr, "Fail to write tar header: %s, %s\nlink:%s target:%s\n", archive_error_string(w),
- strerror(archive_errno(w)), archive_entry_pathname(entry), archive_entry_hardlink(entry));
+ ERROR("Fail to write tar header: %s.\nlink:%s target:%s", archive_error_string(w),
+ archive_entry_pathname(entry), archive_entry_hardlink(entry));
+ (void)fprintf(stderr, "Fail to write tar header: %s.\nlink:%s target:%s\n", archive_error_string(w),
+ archive_entry_pathname(entry), archive_entry_hardlink(entry));
break;
}
if (archive_entry_size(entry) > 0) {
ret = copy_data_between_archives(r, w);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to do copy data: %s, %s", archive_error_string(w), strerror(archive_errno(w)));
- (void)fprintf(stderr, "Failed to do copy data: %s, %s\n", archive_error_string(w),
- strerror(archive_errno(w)));
+ ERROR("Failed to do copy data: %s", archive_error_string(w));
+ (void)fprintf(stderr, "Failed to do copy data: %s\n", archive_error_string(w));
break;
}
}
ret = archive_write_finish_entry(w);
if (ret != ARCHIVE_OK) {
- ERROR("Failed to freeing archive entry: %s, %s", archive_error_string(w), strerror(archive_errno(w)));
- (void)fprintf(stderr, "Failed to freeing archive entry: %s, %s\n", archive_error_string(w),
- strerror(archive_errno(w)));
+ ERROR("Failed to freeing archive entry: %s", archive_error_string(w));
+ (void)fprintf(stderr, "Failed to freeing archive entry: %s\n", archive_error_string(w));
break;
}
if (archive_entry_filetype(entry) == AE_IFDIR) {
ret = archive_read_disk_descend(r);
if (ret != ARCHIVE_OK) {
- ERROR("read disk descend failed: %s, %s", archive_error_string(w), strerror(archive_errno(w)));
- (void)fprintf(stderr, "read disk descend failed: %s, %s\n", archive_error_string(w),
- strerror(archive_errno(w)));
+ ERROR("read disk descend failed: %s", archive_error_string(w));
+ (void)fprintf(stderr, "read disk descend failed: %s\n", archive_error_string(w));
break;
}
}
@@ -1166,9 +1152,8 @@ static int tar_all(const struct io_write_wrapper *writer, const char *tar_dir, c
archive_read_disk_set_behavior(r, ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS);
ret = archive_read_disk_open(r, tar_dir);
if (ret != ARCHIVE_OK) {
- ERROR("open archive read failed: %s, %s", archive_error_string(r), strerror(archive_errno(r)));
- (void)fprintf(stderr, "open archive read failed: %s, %s\n", archive_error_string(r),
- strerror(archive_errno(r)));
+ ERROR("open archive read failed: %s", archive_error_string(r));
+ (void)fprintf(stderr, "open archive read failed: %s\n", archive_error_string(r));
goto out;
}
@@ -1183,9 +1168,8 @@ static int tar_all(const struct io_write_wrapper *writer, const char *tar_dir, c
archive_write_set_options(w, "xattrheader=SCHILY");
ret = archive_write_open(w, (void *)writer, NULL, stream_write_data, NULL);
if (ret != ARCHIVE_OK) {
- ERROR("open archive write failed: %s, %s", archive_error_string(w), strerror(archive_errno(w)));
- (void)fprintf(stderr, "open archive write failed: %s, %s\n", archive_error_string(w),
- strerror(archive_errno(w)));
+ ERROR("open archive write failed: %s", archive_error_string(w));
+ (void)fprintf(stderr, "open archive write failed: %s\n", archive_error_string(w));
goto out;
}
@@ -1258,14 +1242,14 @@ int archive_chroot_tar(const char *path, const char *file, const char *root_dir,
// child process, dup2 pipe_for_read[1] to stderr,
if (dup2(pipe_for_read[1], 2) < 0) {
- ERROR("Dup fd error: %s", strerror(errno));
+ SYSERROR("Dup fd failed");
ret = -1;
goto child_out;
}
fd = open(file, TAR_DEFAULT_FLAG, TAR_DEFAULT_MODE);
if (fd < 0) {
- ERROR("Failed to open file %s for export: %s", file, strerror(errno));
+ SYSERROR("Failed to open file %s for export", file);
fprintf(stderr, "Failed to open file %s for export: %s\n", file, strerror(errno));
ret = -1;
goto child_out;
@@ -1474,17 +1458,17 @@ int archive_chroot_untar_stream(const struct io_read_wrapper *context, const cha
}
if (pipe(pipe_stderr) != 0) {
- ERROR("Failed to create pipe: %s", strerror(errno));
+ SYSERROR("Failed to create pipe");
goto cleanup;
}
if (pipe(pipe_stream) != 0) {
- ERROR("Failed to create pipe: %s", strerror(errno));
+ SYSERROR("Failed to create pipe");
goto cleanup;
}
pid = fork();
if (pid == (pid_t) -1) {
- ERROR("Failed to fork: %s", strerror(errno));
+ SYSERROR("Failed to fork");
goto cleanup;
}
@@ -1503,7 +1487,7 @@ int archive_chroot_untar_stream(const struct io_read_wrapper *context, const cha
// child process, dup2 pipe_stderr[1] to stderr,
if (dup2(pipe_stderr[1], 2) < 0) {
- ERROR("Dup fd error: %s", strerror(errno));
+ SYSERROR("Dup fd error");
ret = -1;
goto child_out;
}
@@ -1559,7 +1543,7 @@ child_out:
while (read_len > 0) {
ssize_t writed_len = archive_context_write(ctx, buf, (size_t)read_len);
if (writed_len < 0) {
- DEBUG("Tar may exited: %s", strerror(errno));
+ SYSDEBUG("Tar may exited");
break;
}
read_len = context->read(context->context, buf, buf_len);
@@ -1610,17 +1594,17 @@ int archive_chroot_tar_stream(const char *chroot_dir, const char *tar_path, cons
}
if (pipe(pipe_stderr) != 0) {
- ERROR("Failed to create pipe: %s", strerror(errno));
+ SYSERROR("Failed to create pipe");
goto free_out;
}
if (pipe(pipe_stream) != 0) {
- ERROR("Failed to create pipe: %s", strerror(errno));
+ SYSERROR("Failed to create pipe");
goto free_out;
}
pid = fork();
if (pid == (pid_t) -1) {
- ERROR("Failed to fork: %s", strerror(errno));
+ SYSERROR("Failed to fork");
goto free_out;
}
@@ -1642,7 +1626,7 @@ int archive_chroot_tar_stream(const char *chroot_dir, const char *tar_path, cons
// child process, dup2 pipe_stderr[1] to stderr,
if (dup2(pipe_stderr[1], 2) < 0) {
- ERROR("Dup fd error: %s", strerror(errno));
+ SYSERROR("Dup fd error");
ret = -1;
goto child_out;
}
diff --git a/src/utils/tar/util_gzip.c b/src/utils/tar/util_gzip.c
index bf649300..0c8c8372 100644
--- a/src/utils/tar/util_gzip.c
+++ b/src/utils/tar/util_gzip.c
@@ -42,13 +42,13 @@ int util_gzip_z(const char *srcfile, const char *dstfile, const mode_t mode)
srcfd = util_open(srcfile, O_RDONLY, SECURE_CONFIG_FILE_MODE);
if (srcfd < 0) {
- ERROR("Open src file: %s, failed: %s", srcfile, strerror(errno));
+ SYSERROR("Open src file: %s, failed", srcfile);
return -1;
}
stream = gzopen(dstfile, "w");
if (stream == NULL) {
- ERROR("gzopen %s error: %s", dstfile, strerror(errno));
+ SYSERROR("gzopen %s failed", dstfile);
close(srcfd);
return -1;
}
@@ -64,7 +64,7 @@ int util_gzip_z(const char *srcfile, const char *dstfile, const mode_t mode)
int n;
size = util_read_nointr(srcfd, buffer, BLKSIZE);
if (size < 0) {
- ERROR("read file %s failed: %s", srcfile, strerror(errno));
+ SYSERROR("read file %s failed", srcfile);
ret = -1;
break;
} else if (size == 0) {
@@ -92,7 +92,7 @@ out:
free(buffer);
if (ret != 0) {
if (util_path_remove(dstfile) != 0) {
- ERROR("Remove file %s failed: %s", dstfile, strerror(errno));
+ SYSERROR("Remove file %s failed", dstfile);
}
}
@@ -115,7 +115,7 @@ int util_gzip_d(const char *srcfile, const FILE *dstfp)
stream = gzopen(srcfile, "r");
if (stream == NULL) {
- ERROR("gzopen %s failed: %s", srcfile, strerror(errno));
+ SYSERROR("gzopen %s failed", srcfile);
return -1;
}
@@ -142,7 +142,7 @@ int util_gzip_d(const char *srcfile, const FILE *dstfp)
size = fwrite(buffer, 1, n, (FILE *)dstfp);
if (size != n) {
ret = -1;
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
break;
}
}
--
2.40.1