]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
io-util: introduce loop_write_full that takes a timeout
authorMike Yuan <me@yhndnzj.com>
Tue, 5 Sep 2023 14:15:09 +0000 (22:15 +0800)
committerMike Yuan <me@yhndnzj.com>
Thu, 7 Sep 2023 12:30:44 +0000 (20:30 +0800)
Also drop do_poll as the use case is covered
by timeout.

34 files changed:
src/basic/compress.c
src/basic/efivars.c
src/basic/io-util.c
src/basic/io-util.h
src/basic/random-util.c
src/basic/terminal-util.c
src/battery-check/battery-check.c
src/boot/bootctl-random-seed.c
src/core/exec-credential.c
src/core/import-creds.c
src/import/import-raw.c
src/import/import-tar.c
src/import/pull-common.c
src/import/pull-job.c
src/journal/bsod.c
src/journal/journalctl.c
src/libsystemd/sd-id128/id128-util.c
src/libsystemd/sd-journal/journal-send.c
src/nspawn/nspawn.c
src/partition/repart.c
src/random-seed/random-seed.c
src/shared/ask-password-api.c
src/shared/creds-util.c
src/shared/data-fd-util.c
src/shared/dissect-image.c
src/shared/elf-util.c
src/shared/machine-id-setup.c
src/shared/pager.c
src/shared/tpm2-util.c
src/systemctl/systemctl-sysv-compat.c
src/test/test-copy.c
src/tmpfiles/tmpfiles.c
src/udev/udev-worker.c
src/vconsole/vconsole-setup.c

index 10e7aaec59d6227b042de6c74eaf5267171503e6..ac0bfdfcd5feccad2e80e1e26a899ee57692ef34 100644 (file)
@@ -614,7 +614,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_uncom
 
                         n = sizeof(out) - s.avail_out;
 
-                        k = loop_write(fdt, out, n, false);
+                        k = loop_write(fdt, out, n);
                         if (k < 0)
                                 return k;
 
@@ -693,7 +693,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_unco
                                                "Compressed stream longer than %" PRIu64 " bytes", max_bytes);
 
                 if (out_allocsize - offset < frame_size + 4) {
-                        k = loop_write(fdt, out_buff, offset, false);
+                        k = loop_write(fdt, out_buff, offset);
                         if (k < 0)
                                 return k;
                         offset = 0;
@@ -706,7 +706,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_unco
 
         offset += n;
         total_out += n;
-        r = loop_write(fdt, out_buff, offset, false);
+        r = loop_write(fdt, out_buff, offset);
         if (r < 0)
                 return r;
 
@@ -779,7 +779,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
                                 max_bytes -= n;
                         }
 
-                        k = loop_write(fdt, out, n, false);
+                        k = loop_write(fdt, out, n);
                         if (k < 0)
                                 return k;
 
@@ -845,7 +845,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
                         goto cleanup;
                 }
 
-                r = loop_write(out, buf, produced, false);
+                r = loop_write(out, buf, produced);
                 if (r < 0)
                         goto cleanup;
         }
@@ -931,7 +931,7 @@ int compress_stream_zstd(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_unc
                         if (left < output.pos)
                                 return -EFBIG;
 
-                        wrote = loop_write(fdt, output.dst, output.pos, 1);
+                        wrote = loop_write_full(fdt, output.dst, output.pos, USEC_INFINITY);
                         if (wrote < 0)
                                 return wrote;
 
@@ -1041,7 +1041,7 @@ int decompress_stream_zstd(int fdf, int fdt, uint64_t max_bytes) {
                         if (left < output.pos)
                                 return -EFBIG;
 
-                        wrote = loop_write(fdt, output.dst, output.pos, 1);
+                        wrote = loop_write_full(fdt, output.dst, output.pos, USEC_INFINITY);
                         if (wrote < 0)
                                 return wrote;
 
index cb239bdf18c61fede5c53d72bd1ce10cce0af68b..9011ae29a3a82d8bebf2b1f28a799e07c5a927de 100644 (file)
@@ -232,7 +232,7 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
         buf->attr = attr;
         memcpy(buf->buf, value, size);
 
-        r = loop_write(fd, buf, sizeof(uint32_t) + size, false);
+        r = loop_write(fd, buf, sizeof(uint32_t) + size);
         if (r < 0)
                 goto finish;
 
index 7f3b092f59d60b63826cb1d1559ca38907771958..25831e47dc1fbc4316b5c1b8bd77b1a71d6f3898 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#include "errno-util.h"
 #include "io-util.h"
 #include "string-util.h"
 #include "time-util.h"
@@ -105,18 +106,19 @@ int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll) {
         return 0;
 }
 
-int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
+int loop_write_full(int fd, const void *buf, size_t nbytes, usec_t timeout) {
         const uint8_t *p;
+        usec_t end;
+        int r;
 
         assert(fd >= 0);
+        assert(buf || nbytes == 0);
 
         if (nbytes == 0) {
                 static const dummy_t dummy[0];
                 assert_cc(sizeof(dummy) == 0);
                 p = (const void*) dummy; /* Some valid pointer, in case NULL was specified */
         } else {
-                assert(buf);
-
                 if (nbytes == SIZE_MAX)
                         nbytes = strlen(buf);
                 else if (_unlikely_(nbytes > (size_t) SSIZE_MAX))
@@ -125,6 +127,9 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
                 p = buf;
         }
 
+        /* When timeout is 0 or USEC_INFINITY this is not used. But we initialize it to a sensible value. */
+        end = timestamp_is_set(timeout) ? usec_add(now(CLOCK_MONOTONIC), timeout) : USEC_INFINITY;
+
         do {
                 ssize_t k;
 
@@ -133,16 +138,30 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
                         if (errno == EINTR)
                                 continue;
 
-                        if (errno == EAGAIN && do_poll) {
-                                /* We knowingly ignore any return value here,
-                                 * and expect that any error/EOF is reported
-                                 * via write() */
+                        if (errno != EAGAIN || timeout == 0)
+                                return -errno;
 
-                                (void) fd_wait_for_event(fd, POLLOUT, USEC_INFINITY);
-                                continue;
+                        usec_t wait_for;
+
+                        if (timeout == USEC_INFINITY)
+                                wait_for = USEC_INFINITY;
+                        else {
+                                usec_t t = now(CLOCK_MONOTONIC);
+                                if (t >= end)
+                                        return -ETIME;
+
+                                wait_for = usec_sub_unsigned(end, t);
                         }
 
-                        return -errno;
+                        r = fd_wait_for_event(fd, POLLOUT, wait_for);
+                        if (timeout == USEC_INFINITY || ERRNO_IS_NEG_TRANSIENT(r))
+                                /* If timeout == USEC_INFINITY we knowingly ignore any return value
+                                 * here, and expect that any error/EOF is reported via write() */
+                                continue;
+                        if (r < 0)
+                                return r;
+                        if (r == 0)
+                                return -ETIME;
                 }
 
                 if (_unlikely_(nbytes > 0 && k == 0)) /* Can't really happen */
index 336c9ce79b06e8be78e5ab3bb522f1b5405626ff..2a1b2fe5da53e33916a6965561cbf9e2374d6581 100644 (file)
@@ -15,7 +15,11 @@ int flush_fd(int fd);
 
 ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
 int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll);
-int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
+
+int loop_write_full(int fd, const void *buf, size_t nbytes, usec_t timeout);
+static inline int loop_write(int fd, const void *buf, size_t nbytes) {
+        return loop_write_full(fd, buf, nbytes, 0);
+}
 
 int pipe_eof(int fd);
 
index d4a3c9ca5c976612364506be72372bc1d4a15a7d..c7277ad01ee18a7441efd8a379198f11afac101b 100644 (file)
@@ -223,7 +223,7 @@ int random_write_entropy(int fd, const void *seed, size_t size, bool credit) {
                 if (ioctl(fd, RNDADDENTROPY, info) < 0)
                         return -errno;
         } else {
-                r = loop_write(fd, seed, size, false);
+                r = loop_write(fd, seed, size);
                 if (r < 0)
                         return r;
         }
index 2575a658b16065c41d809c8475a757ab152ec81b..63594f07cf0449c1a4482c4b2c21cf87bebe4ac5 100644 (file)
@@ -569,7 +569,7 @@ int vt_disallocate(const char *name) {
                           "\033[r"   /* clear scrolling region */
                           "\033[H"   /* move home */
                           "\033[3J", /* clear screen including scrollback, requires Linux 2.6.40 */
-                          10, false);
+                          10);
         return 0;
 }
 
@@ -1544,7 +1544,7 @@ int set_terminal_cursor_position(int fd, unsigned int row, unsigned int column)
 
         xsprintf(cursor_position, "\x1B[%u;%uH", row, column);
 
-        r = loop_write(fd, cursor_position, SIZE_MAX, /* do_poll = */false);
+        r = loop_write(fd, cursor_position, SIZE_MAX);
         if (r < 0)
                 return log_warning_errno(r, "Failed to set cursor position, ignoring: %m");
 
index 940885b3a3fdb26dc331a61792afe5a23a113d0f..5d7c6a58ae53a2ae765cac444d5eb0cea69971bb 100644 (file)
@@ -82,7 +82,7 @@ static int plymouth_send_message(const char *mode, const char *message) {
                 return log_full_errno(ERRNO_IS_NO_PLYMOUTH(errno) ? LOG_DEBUG : LOG_WARNING, errno,
                                       "Failed to connect to plymouth: %m");
 
-        r = loop_write(fd, plymouth_message, c, /* do_poll = */ false);
+        r = loop_write(fd, plymouth_message, c);
         if (r < 0)
                 return log_full_errno(ERRNO_IS_NO_PLYMOUTH(r) ? LOG_DEBUG : LOG_WARNING, r,
                                       "Failed to write to plymouth: %m");
index 95ff73cc875bdb840d2005c7bbc2c8eb92cd3b6b..cfe10c4115e3809ebb37dd567b3fc34c8b9be4e6 100644 (file)
@@ -184,7 +184,7 @@ int install_random_seed(const char *esp) {
         if (!warned) /* only warn once per seed file */
                 (void) random_seed_verify_permissions(fd, S_IFREG);
 
-        r = loop_write(fd, buffer, sizeof(buffer), /* do_poll= */ false);
+        r = loop_write(fd, buffer, sizeof(buffer));
         if (r < 0) {
                 log_error_errno(r, "Failed to write random seed file: %m");
                 goto fail;
index 2a72f1c39615198146afdd97ea3647a458883ea0..4d4dadca90de1c5e4bd6cc1bc172fac8993d0359 100644 (file)
@@ -182,7 +182,7 @@ static int write_credential(
                 return -errno;
         }
 
-        r = loop_write(fd, data, size, /* do_poll = */ false);
+        r = loop_write(fd, data, size);
         if (r < 0)
                 return r;
 
index 0e0bb06dc476de7efbdc495306ba98da94170920..48f31609231e761a93328f2e90df948ca921024f 100644 (file)
@@ -339,7 +339,7 @@ static int proc_cmdline_callback(const char *key, const char *value, void *data)
         if (nfd < 0)
                 return nfd;
 
-        r = loop_write(nfd, d, l, /* do_poll= */ false);
+        r = loop_write(nfd, d, l);
         if (r < 0) {
                 (void) unlinkat(c->target_dir_fd, n, 0);
                 return log_error_errno(r, "Failed to write credential: %m");
@@ -551,7 +551,7 @@ static int parse_smbios_strings(ImportCredentialContext *c, const char *data, si
                 if (nfd < 0)
                         return nfd;
 
-                r = loop_write(nfd, cdata, cdata_len, /* do_poll= */ false);
+                r = loop_write(nfd, cdata, cdata_len);
                 if (r < 0) {
                         (void) unlinkat(c->target_dir_fd, cn, 0);
                         return log_error_errno(r, "Failed to write credential: %m");
index 4c9a30292b2521ab73196a30faefad434681a93f..feb6ac1bdda024302868dc09747a8399f72fd07a 100644 (file)
@@ -378,7 +378,7 @@ static int raw_import_write(const void *p, size_t sz, void *userdata) {
                 if ((size_t) n < sz)
                         return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write");
         } else {
-                r = loop_write(i->output_fd, p, sz, false);
+                r = loop_write(i->output_fd, p, sz);
                 if (r < 0)
                         return log_error_errno(r, "Failed to write file: %m");
         }
index ff32ae4e5920ea8559b9112ac7fcc89119686e07..8c1845781692372d5e584ff6492defb1cd9829b2 100644 (file)
@@ -250,7 +250,7 @@ static int tar_import_write(const void *p, size_t sz, void *userdata) {
         TarImport *i = userdata;
         int r;
 
-        r = loop_write(i->tar_fd, p, sz, false);
+        r = loop_write(i->tar_fd, p, sz);
         if (r < 0)
                 return r;
 
index 3b80e64b3283d7ea609a54336a2ec396b01aa1d6..a3d4bc8433a11159533e287da07fbabdab0c994a 100644 (file)
@@ -400,7 +400,7 @@ static int verify_gpg(
                 if (sig_file < 0)
                         return log_error_errno(errno, "Failed to create temporary file: %m");
 
-                r = loop_write(sig_file, signature, signature_size, false);
+                r = loop_write(sig_file, signature, signature_size);
                 if (r < 0) {
                         log_error_errno(r, "Failed to write to temporary file: %m");
                         goto finish;
@@ -465,7 +465,7 @@ static int verify_gpg(
 
         gpg_pipe[0] = safe_close(gpg_pipe[0]);
 
-        r = loop_write(gpg_pipe[1], payload, payload_size, false);
+        r = loop_write(gpg_pipe[1], payload, payload_size);
         if (r < 0) {
                 log_error_errno(r, "Failed to write to pipe: %m");
                 goto finish;
index 8dd8ac091586a8a63a791c13158fe260c633a6b7..d05bf3cd4974081cb19ed846b7d4308c9d55c20b 100644 (file)
@@ -336,7 +336,7 @@ static int pull_job_write_uncompressed(const void *p, size_t sz, void *userdata)
                         if ((size_t) n < sz)
                                 return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write");
                 } else {
-                        r = loop_write(j->disk_fd, p, sz, false);
+                        r = loop_write(j->disk_fd, p, sz);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to write file: %m");
                 }
index 4e7090cda93fd5fe7db536e645466a3cba837315..512536412d4a7ca6787e64935b22ecd56839d45d 100644 (file)
@@ -166,7 +166,7 @@ static int display_emergency_message_fullscreen(const char *message) {
         if (ioctl(fd, VT_ACTIVATE, free_vt + 1) < 0)
                 return log_error_errno(errno, "Failed to activate tty: %m");
 
-        r = loop_write(fd, ANSI_BACKGROUND_BLUE ANSI_HOME_CLEAR, SIZE_MAX, /* do_poll = */ false);
+        r = loop_write(fd, ANSI_BACKGROUND_BLUE ANSI_HOME_CLEAR, SIZE_MAX);
         if (r < 0)
                 log_warning_errno(r, "Failed to clear terminal, ignoring: %m");
 
@@ -174,7 +174,7 @@ static int display_emergency_message_fullscreen(const char *message) {
         if (r < 0)
                 log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
 
-        r = loop_write(fd, "The current boot has failed!", SIZE_MAX, /* do_poll = */false);
+        r = loop_write(fd, "The current boot has failed!", SIZE_MAX);
         if (r < 0)
                 return log_warning_errno(r, "Failed to write to terminal: %m");
 
@@ -184,7 +184,7 @@ static int display_emergency_message_fullscreen(const char *message) {
         if (r < 0)
                 log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
 
-        r = loop_write(fd, message, SIZE_MAX, /* do_poll = */false);
+        r = loop_write(fd, message, SIZE_MAX);
         if (r < 0)
                 return log_warning_errno(r, "Failed to write emergency message to terminal: %m");
 
@@ -200,7 +200,7 @@ static int display_emergency_message_fullscreen(const char *message) {
         if (r < 0)
                 log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
 
-        r = loop_write(fd, "Press any key to exit...", SIZE_MAX, /* do_poll = */false);
+        r = loop_write(fd, "Press any key to exit...", SIZE_MAX);
         if (r < 0)
                 return log_warning_errno(r, "Failed to write to terminal: %m");
 
index 48747929bebd36c8d89be6f600270cd1618c0cd7..9a1bfc1e7dc8abd9ab7df071916ba679c873abd2 100644 (file)
@@ -1914,11 +1914,11 @@ static int setup_keys(void) {
                 .fsprg_state_size = htole64(state_size),
         };
 
-        r = loop_write(fd, &h, sizeof(h), false);
+        r = loop_write(fd, &h, sizeof(h));
         if (r < 0)
                 return log_error_errno(r, "Failed to write header: %m");
 
-        r = loop_write(fd, state, state_size, false);
+        r = loop_write(fd, state, state_size);
         if (r < 0)
                 return log_error_errno(r, "Failed to write state: %m");
 
index 9d391de1664278623a14bfb66eb348acdf32a348..596b8786bf6627f9683e91288e6b9b2bf09acc18 100644 (file)
@@ -163,7 +163,7 @@ int id128_write_fd(int fd, Id128Flag f, sd_id128_t id) {
         }
 
         buffer[sz - 1] = '\n';
-        r = loop_write(fd, buffer, sz, false);
+        r = loop_write(fd, buffer, sz);
         if (r < 0)
                 return r;
 
index 4380a21f7d0faee55a3d735a0425a42fbc372aab..784c7e5fb1aa5d37790b14044075557a6e4c61b9 100644 (file)
@@ -438,7 +438,7 @@ _public_ int sd_journal_stream_fd(const char *identifier, int priority, int leve
         header[l++] = '0';
         header[l++] = '\n';
 
-        r = loop_write(fd, header, l, false);
+        r = loop_write(fd, header, l);
         if (r < 0)
                 return r;
 
index 9e74ead8d58191db0614ce405d2874ad9a0b8855..3674f6b023b64da931968e1b8490640955015af0 100644 (file)
@@ -2478,7 +2478,7 @@ static int setup_credentials(const char *root) {
                 if (fd < 0)
                         return log_error_errno(errno, "Failed to create credential file %s: %m", j);
 
-                r = loop_write(fd, arg_credentials[i].data, arg_credentials[i].size, /* do_poll= */ false);
+                r = loop_write(fd, arg_credentials[i].data, arg_credentials[i].size);
                 if (r < 0)
                         return log_error_errno(r, "Failed to write credential to file %s: %m", j);
 
index b6fe9ef79eeeba8a04c7bea6b261be028a428a21..9325b3210053c8fef62896f1e423509226331132 100644 (file)
@@ -4166,7 +4166,7 @@ static int partition_format_verity_sig(Context *context, Partition *p) {
         if (lseek(whole_fd, p->offset, SEEK_SET) == (off_t) -1)
                 return log_error_errno(errno, "Failed to seek to partition %s offset: %m", strna(hint));
 
-        r = loop_write(whole_fd, text, p->new_size, /*do_poll=*/ false);
+        r = loop_write(whole_fd, text, p->new_size);
         if (r < 0)
                 return log_error_errno(r, "Failed to write verity signature to partition %s: %m", strna(hint));
 
index 242fc190f9aff2e14ecd2835fe9c5d354dff01ab..25d4d3f584c5cfce7fcf80b154a79789294ab6ab 100644 (file)
@@ -286,7 +286,7 @@ static int save_seed_file(
                 memcpy((uint8_t *)buf + k - l, hash, l);
         }
 
-        r = loop_write(seed_fd, buf, (size_t) k, false);
+        r = loop_write(seed_fd, buf, (size_t) k);
         if (r < 0)
                 return log_error_errno(r, "Failed to write new random seed file: %m");
 
index 92a191ee60b3d508577aadcb928f70709f60beff..416130b9cc68846ee3c3a55b9e348f213be161dc 100644 (file)
@@ -181,7 +181,7 @@ static int backspace_chars(int ttyfd, size_t p) {
         for (size_t i = 0; i < p; i++)
                 memcpy(buf + 3 * i, "\b \b", 3);
 
-        return loop_write(ttyfd, buf, 3*p, false);
+        return loop_write(ttyfd, buf, 3 * p);
 }
 
 static int backspace_string(int ttyfd, const char *str) {
@@ -252,7 +252,7 @@ int ask_password_plymouth(
         if (!packet)
                 return -ENOMEM;
 
-        r = loop_write(fd, packet, n + 1, true);
+        r = loop_write_full(fd, packet, n + 1, USEC_INFINITY);
         if (r < 0)
                 return r;
 
@@ -311,7 +311,7 @@ int ask_password_plymouth(
                                 if (asprintf(&packet, "*\002%c%s%n", (int) (strlen(message) + 1), message, &n) < 0)
                                         return -ENOMEM;
 
-                                r = loop_write(fd, packet, n+1, true);
+                                r = loop_write_full(fd, packet, n + 1, USEC_INFINITY);
                                 if (r < 0)
                                         return r;
 
@@ -429,20 +429,21 @@ int ask_password_tty(
                         use_color = colors_enabled();
 
                 if (use_color)
-                        (void) loop_write(ttyfd, ANSI_HIGHLIGHT, SIZE_MAX, false);
+                        (void) loop_write(ttyfd, ANSI_HIGHLIGHT, SIZE_MAX);
 
-                (void) loop_write(ttyfd, message, SIZE_MAX, false);
-                (void) loop_write(ttyfd, " ", 1, false);
+                (void) loop_write(ttyfd, message, SIZE_MAX);
+                (void) loop_write(ttyfd, " ", 1);
 
                 if (!FLAGS_SET(flags, ASK_PASSWORD_SILENT) && !FLAGS_SET(flags, ASK_PASSWORD_ECHO)) {
                         if (use_color)
-                                (void) loop_write(ttyfd, ansi_grey(), SIZE_MAX, false);
-                        (void) loop_write(ttyfd, PRESS_TAB, SIZE_MAX, false);
+                                (void) loop_write(ttyfd, ansi_grey(), SIZE_MAX);
+
+                        (void) loop_write(ttyfd, PRESS_TAB, SIZE_MAX);
                         press_tab_visible = true;
                 }
 
                 if (use_color)
-                        (void) loop_write(ttyfd, ANSI_NORMAL, SIZE_MAX, false);
+                        (void) loop_write(ttyfd, ANSI_NORMAL, SIZE_MAX);
 
                 new_termios = old_termios;
                 new_termios.c_lflag &= ~(ICANON|ECHO);
@@ -527,7 +528,7 @@ int ask_password_tty(
 
                 if (c == 4) { /* C-d also known as EOT */
                         if (ttyfd >= 0)
-                                (void) loop_write(ttyfd, SKIPPED, SIZE_MAX, false);
+                                (void) loop_write(ttyfd, SKIPPED, SIZE_MAX);
 
                         goto skipped;
                 }
@@ -577,10 +578,10 @@ int ask_password_tty(
                                  * first key (and only as first key), or ... */
 
                                 if (ttyfd >= 0)
-                                        (void) loop_write(ttyfd, NO_ECHO, SIZE_MAX, false);
+                                        (void) loop_write(ttyfd, NO_ECHO, SIZE_MAX);
 
                         } else if (ttyfd >= 0)
-                                (void) loop_write(ttyfd, "\a", 1, false);
+                                (void) loop_write(ttyfd, "\a", 1);
 
                 } else if (c == '\t' && !FLAGS_SET(flags, ASK_PASSWORD_SILENT)) {
 
@@ -590,13 +591,13 @@ int ask_password_tty(
                         /* ... or by pressing TAB at any time. */
 
                         if (ttyfd >= 0)
-                                (void) loop_write(ttyfd, NO_ECHO, SIZE_MAX, false);
+                                (void) loop_write(ttyfd, NO_ECHO, SIZE_MAX);
 
                 } else if (p >= sizeof(passphrase)-1) {
 
                         /* Reached the size limit */
                         if (ttyfd >= 0)
-                                (void) loop_write(ttyfd, "\a", 1, false);
+                                (void) loop_write(ttyfd, "\a", 1);
 
                 } else {
                         passphrase[p++] = c;
@@ -606,13 +607,11 @@ int ask_password_tty(
                                 n = utf8_encoded_valid_unichar(passphrase + codepoint, SIZE_MAX);
                                 if (n >= 0) {
                                         if (FLAGS_SET(flags, ASK_PASSWORD_ECHO))
-                                                (void) loop_write(ttyfd, passphrase + codepoint, n, false);
+                                                (void) loop_write(ttyfd, passphrase + codepoint, n);
                                         else
-                                                (void) loop_write(
-                                                                ttyfd,
-                                                                special_glyph(SPECIAL_GLYPH_BULLET),
-                                                                SIZE_MAX,
-                                                                false);
+                                                (void) loop_write(ttyfd,
+                                                                  special_glyph(SPECIAL_GLYPH_BULLET),
+                                                                  SIZE_MAX);
                                         codepoint = p;
                                 }
                         }
@@ -644,7 +643,7 @@ skipped:
 
 finish:
         if (ttyfd >= 0 && reset_tty) {
-                (void) loop_write(ttyfd, "\n", 1, false);
+                (void) loop_write(ttyfd, "\n", 1);
                 (void) tcsetattr(ttyfd, TCSADRAIN, &old_termios);
         }
 
index 8a5240e5f19022a4e9f1b12fb490a94616a2d9b0..0941826970b99ea26d142c21caa69d80f7336368 100644 (file)
@@ -382,7 +382,7 @@ static int make_credential_host_secret(
         if (r < 0)
                 goto fail;
 
-        r = loop_write(fd, &buf, sizeof(buf), false);
+        r = loop_write(fd, &buf, sizeof(buf));
         if (r < 0)
                 goto fail;
 
index 86baf9bfa1a56de479709442861a8065238b49b9..2fac0a9f44615267f9f2b513587e9be832119cc0 100644 (file)
@@ -275,7 +275,7 @@ int copy_data_fd(int fd) {
                         /* If there were remaining bytes (i.e. read into memory, but not written out yet) from the
                          * failed copy operation, let's flush them out next. */
 
-                        r = loop_write(tmp_fd, remains, remains_size, false);
+                        r = loop_write(tmp_fd, remains, remains_size);
                         if (r < 0)
                                 return r;
                 }
@@ -318,7 +318,7 @@ int copy_data_fd(int fd) {
 
         if (remains_size > 0) {
                 /* Then, copy in any read but not yet written bytes. */
-                r = loop_write(tmp_fd, remains, remains_size, false);
+                r = loop_write(tmp_fd, remains, remains_size);
                 if (r < 0)
                         return r;
         }
index 2d1952de798876ce08950ade6379a71bcd4251e0..4e0d61fbc2f62ec399f2e6f51e4c79b242a03fdf 100644 (file)
@@ -3348,7 +3348,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
                                 if (r < 0)
                                         fd = r;
                                 else {
-                                        r = loop_write(fds[2*k+1], &class, sizeof(class), false);
+                                        r = loop_write(fds[2*k+1], &class, sizeof(class));
                                         if (r < 0)
                                                 goto inner_fail; /* Propagate the error to the parent */
                                 }
@@ -3374,7 +3374,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
                                         }
                                 }
 
-                                r = loop_write(fds[2*k+1], &found, sizeof(found), false);
+                                r = loop_write(fds[2*k+1], &found, sizeof(found));
                                 if (r < 0)
                                         goto inner_fail;
 
index 7428152faa3f635b01d95d7333aa250eb8510230..57a1bb9daa0564c7237b5ab91d1933433f59ee64 100644 (file)
@@ -826,7 +826,7 @@ int parse_elf_object(int fd, const char *executable, bool fork_disable_dump, cha
                          * Failure is ignored, because partial output is still useful. */
                         (void) fcntl(return_pipe[1], F_SETPIPE_SZ, len);
 
-                        r = loop_write(return_pipe[1], buf, len, false);
+                        r = loop_write(return_pipe[1], buf, len);
                         if (r == -EAGAIN)
                                 log_warning("Write failed, backtrace will be truncated.");
                         else if (r < 0)
index 6090231374ec39d1ad6f3c803776e445df48977f..7263b6a204e0970131b480b8bb5e8b260b951b59 100644 (file)
@@ -162,7 +162,7 @@ int machine_id_setup(const char *root, bool force_transient, sd_id128_t machine_
                  *
                  * Otherwise write the machine-id directly to disk. */
                 if (force_transient) {
-                        r = loop_write(fd, "uninitialized\n", SIZE_MAX, false);
+                        r = loop_write(fd, "uninitialized\n", SIZE_MAX);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to write uninitialized %s: %m", etc_machine_id);
 
index 7bede85752f26a086c911ba47e49d49daff60281..2cd9a353e33d8b67d500dbae952c3b0a2b3c6c87 100644 (file)
@@ -204,7 +204,7 @@ void pager_open(PagerFlags flags) {
                                                   * secure mode. Thus, start the pager specified through
                                                   * envvars only when $SYSTEMD_PAGERSECURE was explicitly set
                                                   * as well. */
-                        r = loop_write(exe_name_pipe[1], pager_args[0], strlen(pager_args[0]) + 1, false);
+                        r = loop_write(exe_name_pipe[1], pager_args[0], strlen(pager_args[0]) + 1);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to write pager name to socket: %m");
                                 _exit(EXIT_FAILURE);
@@ -225,7 +225,7 @@ void pager_open(PagerFlags flags) {
                         if (use_secure_mode && !STR_IN_SET(pagers[i], "less", "(built-in)"))
                                 continue;
 
-                        r = loop_write(exe_name_pipe[1], pagers[i], strlen(pagers[i]) + 1, false);
+                        r = loop_write(exe_name_pipe[1], pagers[i], strlen(pagers[i]) + 1);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to write pager name to socket: %m");
                                 _exit(EXIT_FAILURE);
index a57841fab4bb1aeece4b0a8d3400b404c35ed8fd..1181d73743b3c3a3f76c905945480f77adc59b2c 100644 (file)
@@ -4433,7 +4433,7 @@ static int tpm2_userspace_log(
         if (lseek(fd, 0, SEEK_END) == (off_t) -1)
                 return log_error_errno(errno, "Failed to seek to end of JSON log: %m");
 
-        r = loop_write(fd, f, SIZE_MAX, /* do_poll= */ false);
+        r = loop_write(fd, f, SIZE_MAX);
         if (r < 0)
                 return log_error_errno(r, "Failed to write JSON data to log: %m");
 
index d55525943ebed7d8cffb73a75b425d073e326fbe..37fc6347fe44b9aa391f8eaa802230f0d740a62c 100644 (file)
@@ -47,7 +47,7 @@ int talk_initctl(char rl) {
                 .runlevel = rl,
         };
 
-        r = loop_write(fd, &request, sizeof(request), false);
+        r = loop_write(fd, &request, sizeof(request));
         if (r < 0)
                 return log_error_errno(r, "Failed to write to %s: %m", path);
 
index 06fa05d8fae1fc89988715540f34ba9de1378b0b..a46dd309bdfba57c5b0840dc26f191379944ceb3 100644 (file)
@@ -470,10 +470,10 @@ TEST_RET(copy_holes_with_gaps) {
                 return log_tests_skipped("Filesystem doesn't support hole punching");
 
         assert_se(lseek(fd, blksz, SEEK_CUR) >= 0);
-        assert_se(loop_write(fd, buf, blksz, 0) >= 0);
-        assert_se(loop_write(fd, buf, blksz, 0) >= 0);
+        assert_se(loop_write(fd, buf, blksz) >= 0);
+        assert_se(loop_write(fd, buf, blksz) >= 0);
         assert_se(lseek(fd, 2 * blksz, SEEK_CUR) >= 0);
-        assert_se(loop_write(fd, buf, blksz, 0) >= 0);
+        assert_se(loop_write(fd, buf, blksz) >= 0);
         assert_se(lseek(fd, 0, SEEK_SET) >= 0);
         assert_se(fsync(fd) >= 0);
 
index db2d61dbda9231ede576a8fafa35d3f05e6d17cf..564b505e76b6891408fdf193dce33ef1de8daa4c 100644 (file)
@@ -1625,7 +1625,7 @@ static int write_argument_data(Item *i, int fd, const char *path) {
 
         log_debug("Writing to \"%s\".", path);
 
-        r = loop_write(fd, item_binary_argument(i), item_binary_argument_size(i), /* do_poll= */ false);
+        r = loop_write(fd, item_binary_argument(i), item_binary_argument_size(i));
         if (r < 0)
                 return log_error_errno(r, "Failed to write file \"%s\": %m", path);
 
index 996406a142d48c40d0b440eccec87687fd5487e0..53722b21bd6dc156a3e91b5e066c6e0255c871d0 100644 (file)
@@ -277,7 +277,7 @@ static int worker_send_result(UdevWorker *worker, EventResult result) {
         assert(worker);
         assert(worker->pipe_fd >= 0);
 
-        return loop_write(worker->pipe_fd, &result, sizeof(result), /* do_poll = */ false);
+        return loop_write(worker->pipe_fd, &result, sizeof(result));
 }
 
 static int worker_device_monitor_handler(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
index 17b0f9abfadd49c4e07096990b591a96ca6ac319..4aed1b5872cad08c929743a53ffeedc435fcfea1 100644 (file)
@@ -242,7 +242,7 @@ static int toggle_utf8_vc(const char *name, int fd, bool utf8) {
         if (r < 0)
                 return log_warning_errno(errno, "Failed to %s UTF-8 kbdmode on %s: %m", enable_disable(utf8), name);
 
-        r = loop_write(fd, utf8 ? "\033%G" : "\033%@", SIZE_MAX, false);
+        r = loop_write(fd, utf8 ? "\033%G" : "\033%@", SIZE_MAX);
         if (r < 0)
                 return log_warning_errno(r, "Failed to %s UTF-8 term processing on %s: %m", enable_disable(utf8), name);