eBPF-based security platform
util: Rename write_all() to write_complete()
Michi Mutsuzakib845c7df1b8a
diff --git a/builtin-attest.c b/builtin-attest.cindex 86657b23..58616e6b 100644--- a/builtin-attest.c+++ b/builtin-attest.c@@ -677,8 +677,8 @@ static int cmd_attest_challenge(int argc, const char **argv)int fd = open(out_path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,0600);- if (fd < 0 || write_all(fd, doc, len) ||- write_all(fd, "\n", 1) || close(fd)) {+ if (fd < 0 || write_complete(fd, doc, len) ||+ write_complete(fd, "\n", 1) || close(fd)) {pr_err("attest challenge: write %s: %s", out_path,strerror(errno));if (fd >= 0)@@ -770,8 +770,8 @@ static int cmd_attest_evidence(int argc, const char **argv)int fd = open(out_path,O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);- if (fd < 0 || write_all(fd, doc, len) ||- write_all(fd, "\n", 1) || close(fd)) {+ if (fd < 0 || write_complete(fd, doc, len) ||+ write_complete(fd, "\n", 1) || close(fd)) {pr_err("attest: write %s: %s", out_path,strerror(errno));if (fd >= 0)diff --git a/builtin-bpm.c b/builtin-bpm.cindex 8735bf38..492fa28d 100644--- a/builtin-bpm.c+++ b/builtin-bpm.c@@ -240,7 +240,7 @@ static int copy_file_ex(const char *src, const char *dst, mode_t mode,return out;}while ((n = read(in, buf, sizeof(buf))) > 0) {- rc = write_all(out, buf, (size_t)n);+ rc = write_complete(out, buf, (size_t)n);if (rc)break;}@@ -414,7 +414,7 @@ static int print_package_readme(const char *source)pr_err("bpm info: package %s does not include README.md", source);goto out;}- rc = write_all(STDOUT_FILENO, readme, readme_len);+ rc = write_complete(STDOUT_FILENO, readme, readme_len);out:xfree(beefile, beefile_len + 1);xfree(readme, readme_len + 1);@@ -520,7 +520,7 @@ static int extract_package_cert(const char *archive, char *out, size_t out_sz)xfree(body, len + 1);return -errno;}- rc = write_all(fd, body, len);+ rc = write_complete(fd, body, len);if (close(fd) && !rc)rc = -errno;xfree(body, len + 1);diff --git a/builtin-upatch.c b/builtin-upatch.cindex 6e26fc17..3acea912 100644--- a/builtin-upatch.c+++ b/builtin-upatch.c@@ -2135,12 +2135,12 @@ static int append_json_record(const char *path, const char *json, size_t len)goto out_unlock;}if (last != '\n')- rc = write_all(fd, "\n", 1);+ rc = write_complete(fd, "\n", 1);}if (!rc)- rc = write_all(fd, json, len);+ rc = write_complete(fd, json, len);if (!rc)- rc = write_all(fd, "\n", 1);+ rc = write_complete(fd, "\n", 1);if (!rc && fsync(fd) != 0)rc = -errno;if (rc && ftruncate(fd, original_size) != 0)@@ -2158,9 +2158,9 @@ static int print_json_record(const char *json, size_t len){int rc;- rc = write_all(STDOUT_FILENO, json, len);+ rc = write_complete(STDOUT_FILENO, json, len);if (!rc)- rc = write_all(STDOUT_FILENO, "\n", 1);+ rc = write_complete(STDOUT_FILENO, "\n", 1);return rc;}@@ -2187,7 +2187,7 @@ static int copy_file_atomic(const char *src, const char *dst)return out;}while ((r = read(in, buf, sizeof(buf))) > 0) {- rc = write_all(out, buf, (size_t)r);+ rc = write_complete(out, buf, (size_t)r);if (rc)break;}diff --git a/testing/helper/test-config.c b/testing/helper/test-config.cindex 041741fd..bd02fe3f 100644--- a/testing/helper/test-config.c+++ b/testing/helper/test-config.c@@ -23,7 +23,7 @@ static int write_config(const char *path, const char *contents)fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);if (fd < 0)return -errno;- rc = write_all(fd, contents, strlen(contents));+ rc = write_complete(fd, contents, strlen(contents));if (rc) {close(fd);return rc;diff --git a/testing/helper/test-exec-churn.c b/testing/helper/test-exec-churn.cindex d058185f..be18961a 100644--- a/testing/helper/test-exec-churn.c+++ b/testing/helper/test-exec-churn.c@@ -69,7 +69,7 @@ static int worker(__u64 deadline, int fd)completed++;}- if (write_all(fd, &completed, sizeof(completed)))+ if (write_complete(fd, &completed, sizeof(completed)))return 1;return 0;}diff --git a/testing/helper/test-otel-map.c b/testing/helper/test-otel-map.cindex 61df26dd..17585cd8 100644--- a/testing/helper/test-otel-map.c+++ b/testing/helper/test-otel-map.c@@ -137,7 +137,7 @@ static int make_decoder(bool metric, bool counter, bool snapshot,trailer.decoder_len = htole32(decoder_len);memcpy(file + data_off + decoder_len, &trailer, sizeof(trailer));- rc = write_all(fd, file, file_len);+ rc = write_complete(fd, file, file_len);if (close(fd) != 0 && rc == 0)rc = -errno;xfree(file, file_len);diff --git a/testing/helper/test-seal.c b/testing/helper/test-seal.cindex eb5d6ed7..1ee7b648 100644--- a/testing/helper/test-seal.c+++ b/testing/helper/test-seal.c@@ -24,7 +24,7 @@ static int append(const char *path, const char *text)fd = seal_open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);if (fd < 0)return fd;- rc = write_all(fd, text, strlen(text));+ rc = write_complete(fd, text, strlen(text));if (close(fd) && !rc)rc = -errno;return rc;diff --git a/tools/shirudo-build/bpm-publish.c b/tools/shirudo-build/bpm-publish.cindex c1f12e61..687a2b7c 100644--- a/tools/shirudo-build/bpm-publish.c+++ b/tools/shirudo-build/bpm-publish.c@@ -546,7 +546,7 @@ static int tree_push_artifact(struct bpm_oci_client *c, const char *repository,fd = mkstemp(temporary);if (fd < 0)return -errno;- rc = write_all(fd, body, len);+ rc = write_complete(fd, body, len);close(fd);if (!rc)rc = upatch_open(temporary, &u);diff --git a/tools/shirudo-build/package.c b/tools/shirudo-build/package.cindex ed395aff..5c964d2f 100644--- a/tools/shirudo-build/package.c+++ b/tools/shirudo-build/package.c@@ -1200,15 +1200,15 @@ static int finalize_object(struct bpf_object *obj, const char *out_path,pr_err("open %s: %s", out_path, strerror(errno));goto out;}- err = write_all(fd, &hdr, sizeof(hdr));+ err = write_complete(fd, &hdr, sizeof(hdr));if (!err)- err = write_all(fd, opts.insns, opts.insns_sz);+ err = write_complete(fd, opts.insns, opts.insns_sz);if (!err)- err = write_all(fd, sig_buf, sio.signature_sz);+ err = write_complete(fd, sig_buf, sio.signature_sz);if (!err && data_len)- err = write_all(fd, signed_data, data_len);+ err = write_complete(fd, signed_data, data_len);if (!err && write_meta_len)- err = write_all(fd, write_meta, write_meta_len);+ err = write_complete(fd, write_meta, write_meta_len);if (!err && fsync(fd) != 0)err = -errno;close(fd);diff --git a/tools/shirudo-build/vouch.c b/tools/shirudo-build/vouch.cindex e8aa92d2..1dcb191a 100644--- a/tools/shirudo-build/vouch.c+++ b/tools/shirudo-build/vouch.c@@ -69,7 +69,7 @@ static int write_file(const char *path, const void *data, size_t len)fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);if (fd < 0)return -errno;- rc = write_all(fd, data, len);+ rc = write_complete(fd, data, len);if (close(fd) && !rc)rc = -errno;if (rc)diff --git a/util/bpm_tree_state.c b/util/bpm_tree_state.cindex dbf67b25..9c96c007 100644--- a/util/bpm_tree_state.c+++ b/util/bpm_tree_state.c@@ -566,9 +566,9 @@ int tree_event_append(__s64 seq, const char *operation_digest,rc = -errno;goto out;}- rc = write_all(fd, buf, e.len);+ rc = write_complete(fd, buf, e.len);if (!rc)- rc = write_all(fd, "\n", 1);+ rc = write_complete(fd, "\n", 1);if (!rc && fsync(fd))rc = -errno;if (rc && ftruncate(fd, st.st_size))diff --git a/util/eventlog.c b/util/eventlog.cindex 27716001..82c31e05 100644--- a/util/eventlog.c+++ b/util/eventlog.c@@ -86,9 +86,9 @@ int eventlog_append_to(const char *path, const char *json_line)goto out;}- rc = write_all(fd, json_line, len);+ rc = write_complete(fd, json_line, len);if (!rc && (len == 0 || json_line[len - 1] != '\n'))- rc = write_all(fd, "\n", 1);+ rc = write_complete(fd, "\n", 1);if (!rc && fsync(fd) != 0)rc = -errno;if (rc && ftruncate(fd, st.st_size) != 0)diff --git a/util/io.c b/util/io.cindex b660d9ea..398666ed 100644--- a/util/io.c+++ b/util/io.c@@ -17,7 +17,7 @@#include "malloc.h"#include "paths.h"-int write_all(int fd, const void *buf, size_t len)+int write_complete(int fd, const void *buf, size_t len){const __u8 *p = buf;diff --git a/util/io.h b/util/io.hindex 6ab6cd28..a646ac9f 100644--- a/util/io.h+++ b/util/io.h@@ -7,7 +7,7 @@#include <stdbool.h>#include <stddef.h>-int write_all(int fd, const void *buf, size_t len);+int write_complete(int fd, const void *buf, size_t len);/** A regular file of at most max bytes, into *out xmalloc'd to *len + 1diff --git a/util/seal.c b/util/seal.cindex c972bcbd..c6912b88 100644--- a/util/seal.c+++ b/util/seal.c@@ -257,7 +257,7 @@ int seal_write_file(const char *path, const void *data, size_t len,}rc = seal_inherit(dfd, fd);if (!rc)- rc = write_all(fd, data, len);+ rc = write_complete(fd, data, len);if (!rc && fsync(fd))rc = -errno;if (close(fd) && !rc)