From 042f192d623f35e92f97a7df48a0bb3183adef67 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 30 Jun 2026 13:27:59 +0200 Subject: [PATCH] all-io: rename read_all/write_all to ul_read_all/ul_write_all MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add ul_ namespace prefix to all helper functions in all-io.h: write_all() → ul_write_all() read_all() → ul_read_all() read_all_alloc() → ul_read_all_alloc() fwrite_all() → ul_fwrite_all() sendfile_all() → ul_sendfile_all() This is a mechanical rename with no logic changes, preparing for the VFS I/O abstraction layer. Addresses: https://github.com/util-linux/util-linux/issues/4308 Signed-off-by: Karel Zak --- agetty-cmd/agetty.c | 16 ++++++++-------- agetty-cmd/issuefile.c | 10 +++++----- agetty-cmd/tty.c | 4 ++-- disk-utils/fdisk.c | 2 +- disk-utils/fsck.minix.c | 6 +++--- disk-utils/mkfs.minix.c | 12 ++++++------ disk-utils/mkswap.c | 4 ++-- disk-utils/sfdisk.c | 8 ++++---- disk-utils/swaplabel.c | 4 ++-- include/all-io.h | 12 ++++++------ lib/blkdev.c | 2 +- lib/env.c | 2 +- lib/fileeq.c | 6 +++--- lib/fileutils.c | 16 ++++++++-------- lib/path.c | 8 ++++---- lib/plymouth-ctrl.c | 6 +++--- lib/procfs.c | 2 +- lib/pty-session.c | 2 +- lib/sysfs.c | 2 +- libblkid/src/probe.c | 2 +- libfdisk/src/bsd.c | 8 ++++---- libfdisk/src/gpt.c | 4 ++-- libfdisk/src/script.c | 2 +- libfdisk/src/sgi.c | 4 ++-- libfdisk/src/sun.c | 2 +- libmount/src/hook_idmap.c | 12 ++++++------ libuuid/src/gen_uuid.c | 4 ++-- login-utils/last.c | 2 +- misc-utils/enosys.c | 2 +- misc-utils/lsclocks.c | 2 +- misc-utils/mcookie.c | 2 +- misc-utils/uuidd.c | 14 +++++++------- misc-utils/wipefs.c | 2 +- sys-utils/ldattach.c | 2 +- sys-utils/lscpu-virt.c | 2 +- sys-utils/nsenter.c | 4 ++-- sys-utils/rfkill.c | 2 +- sys-utils/setpriv.c | 2 +- sys-utils/unshare.c | 12 ++++++------ term-utils/script.c | 2 +- term-utils/setterm.c | 2 +- text-utils/pg.c | 38 +++++++++++++++++++------------------- 42 files changed, 126 insertions(+), 126 deletions(-) diff --git a/agetty-cmd/agetty.c b/agetty-cmd/agetty.c index 8974a9af7..541d03e19 100644 --- a/agetty-cmd/agetty.c +++ b/agetty-cmd/agetty.c @@ -513,7 +513,7 @@ int main(int argc, char **argv) if (options.flags & F_INITSTRING && options.initstring && *options.initstring != '\0') { debug("writing init string\n"); - write_all(STDOUT_FILENO, options.initstring, + ul_write_all(STDOUT_FILENO, options.initstring, strlen(options.initstring)); } @@ -601,7 +601,7 @@ int main(int argc, char **argv) agetty_reset_vc(&options, &termios, 1); /* Now the newline character should be properly written. */ - write_all(STDOUT_FILENO, "\r\n", 2); + ul_write_all(STDOUT_FILENO, "\r\n", 2); sigaction(SIGQUIT, &sa_quit, NULL); sigaction(SIGINT, &sa_int, NULL); @@ -745,8 +745,8 @@ again: cn = res->ai_canonname; } - write_all(STDOUT_FILENO, cn, strlen(cn)); - write_all(STDOUT_FILENO, " ", 1); + ul_write_all(STDOUT_FILENO, cn, strlen(cn)); + ul_write_all(STDOUT_FILENO, " ", 1); if (res) freeaddrinfo(res); @@ -755,7 +755,7 @@ again: } if (!op->autolog) { /* Always show login prompt. */ - write_all(STDOUT_FILENO, LOGIN_PROMPT, + ul_write_all(STDOUT_FILENO, LOGIN_PROMPT, sizeof(LOGIN_PROMPT) - 1); } } @@ -924,7 +924,7 @@ static char *get_logname(struct agetty_issue *ie, struct agetty_options *op, str /* Ideally it should be "\xe2\x90\x9b" * if (op->flags & (F_UTF8)), * but only some fonts contain it */ - write_all(1, "^[", 2); + ul_write_all(1, "^[", 2); *visual_bp = 2; /* ESC shows as ^[ (2 chars) */ } else if (ascval == '\t') { /* Tab expands to spaces */ @@ -932,10 +932,10 @@ static char *get_logname(struct agetty_issue *ie, struct agetty_options *op, str int spaces = 8 - (pos % 8); int i; for (i = 0; i < spaces; i++) - write_all(1, " ", 1); + ul_write_all(1, " ", 1); *visual_bp = spaces; } else { - write_all(1, &c, 1); /* echo the character */ + ul_write_all(1, &c, 1); /* echo the character */ *visual_bp = 1; /* normal char shows as 1 */ } } else { diff --git a/agetty-cmd/issuefile.c b/agetty-cmd/issuefile.c index c314f3903..104ccef81 100644 --- a/agetty-cmd/issuefile.c +++ b/agetty-cmd/issuefile.c @@ -69,7 +69,7 @@ static char *read_os_release(struct agetty_options *op, const char *varname) op->osrelease = malloc(st.st_size + 1); if (!op->osrelease) agetty_log_err(_("failed to allocate memory: %m")); - if (read_all(fd, op->osrelease, st.st_size) != (ssize_t) st.st_size) { + if (ul_read_all(fd, op->osrelease, st.st_size) != (ssize_t) st.st_size) { free(op->osrelease); op->osrelease = NULL; goto done; @@ -210,7 +210,7 @@ void agetty_print_issue_file(struct agetty_issue *ie __attribute__((__unused__)) { if ((op->flags & F_NONL) == 0) { /* Issue not in use, start with a new line. */ - write_all(STDOUT_FILENO, "\r\n", 2); + ul_write_all(STDOUT_FILENO, "\r\n", 2); } } @@ -292,7 +292,7 @@ void agetty_print_issue_file(struct agetty_issue *ie, if ((op->flags & F_NONL) == 0) { /* Issue not in use, start with a new line. */ - write_all(STDOUT_FILENO, "\r\n", 2); + ul_write_all(STDOUT_FILENO, "\r\n", 2); } if (ie->do_tcsetattr) { @@ -304,7 +304,7 @@ void agetty_print_issue_file(struct agetty_issue *ie, } if (ie->mem_sz && ie->mem) - write_all(STDOUT_FILENO, ie->mem, ie->mem_sz); + ul_write_all(STDOUT_FILENO, ie->mem, ie->mem_sz); if (ie->do_tcrestore) { /* Restore settings. */ @@ -446,7 +446,7 @@ void agetty_show_issue(struct agetty_options *op) agetty_eval_issue_file(&ie, op, &tp); if (ie.mem_sz) - write_all(STDOUT_FILENO, ie.mem, ie.mem_sz); + ul_write_all(STDOUT_FILENO, ie.mem, ie.mem_sz); if (ie.output) fclose(ie.output); free(ie.mem); diff --git a/agetty-cmd/tty.c b/agetty-cmd/tty.c index c60430d24..e56e5f1bb 100644 --- a/agetty-cmd/tty.c +++ b/agetty-cmd/tty.c @@ -168,7 +168,7 @@ void agetty_termio_clear(int fd) * erase everything below the cursor (ESC [ J), and set the * scrolling region to the full window (ESC [ r) */ - write_all(fd, "\033[r\033[H\033[J", 9); + ul_write_all(fd, "\033[r\033[H\033[J", 9); } void agetty_reset_vc(const struct agetty_options *op, struct termios *tp, int canon) @@ -685,5 +685,5 @@ void agetty_erase_char(int visual_count, struct chardata *cp) }; int i; for (i = 0; i < visual_count; i++) - write_all(1, erase[cp->parity], 3); + ul_write_all(1, erase[cp->parity], 3); } diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 30481544a..02ffb964a 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -1006,7 +1006,7 @@ static void dump_blkdev(struct fdisk_context *cxt, const char *name, else { unsigned char *buf = xmalloc(size); - if (read_all(fd, (char *) buf, size) != (ssize_t) size) + if (ul_read_all(fd, (char *) buf, size) != (ssize_t) size) fdisk_warn(cxt, _("cannot read")); else dump_buffer(offset, buf, size); diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index 304b25cb4..0dc814f58 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -526,13 +526,13 @@ write_tables(void) { write_super_block(); - if (write_all(device_fd, inode_map, imaps * MINIX_BLOCK_SIZE)) + if (ul_write_all(device_fd, inode_map, imaps * MINIX_BLOCK_SIZE)) die(_("Unable to write inode map")); - if (write_all(device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE)) + if (ul_write_all(device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE)) die(_("Unable to write zone map")); - if (write_all(device_fd, inode_buffer, buffsz)) + if (ul_write_all(device_fd, inode_buffer, buffsz)) die(_("Unable to write inodes")); } diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 6a9c7ba81..4e69712fd 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -196,21 +196,21 @@ static void write_tables(const struct fs_control *ctl) if (lseek(ctl->device_fd, 0, SEEK_SET)) err(MKFS_EX_ERROR, _("%s: seek to boot block failed " "in write_tables"), ctl->device_name); - if (write_all(ctl->device_fd, boot_block_buffer, 512)) + if (ul_write_all(ctl->device_fd, boot_block_buffer, 512)) err(MKFS_EX_ERROR, _("%s: unable to clear boot sector"), ctl->device_name); if (MINIX_BLOCK_SIZE != lseek(ctl->device_fd, MINIX_BLOCK_SIZE, SEEK_SET)) err(MKFS_EX_ERROR, _("%s: seek failed in write_tables"), ctl->device_name); - if (write_all(ctl->device_fd, super_block_buffer, MINIX_BLOCK_SIZE)) + if (ul_write_all(ctl->device_fd, super_block_buffer, MINIX_BLOCK_SIZE)) err(MKFS_EX_ERROR, _("%s: unable to write super-block"), ctl->device_name); - if (write_all(ctl->device_fd, inode_map, imaps * MINIX_BLOCK_SIZE)) + if (ul_write_all(ctl->device_fd, inode_map, imaps * MINIX_BLOCK_SIZE)) err(MKFS_EX_ERROR, _("%s: unable to write inode map"), ctl->device_name); - if (write_all(ctl->device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE)) + if (ul_write_all(ctl->device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE)) err(MKFS_EX_ERROR, _("%s: unable to write zone map"), ctl->device_name); - if (write_all(ctl->device_fd, inode_buffer, buffsz)) + if (ul_write_all(ctl->device_fd, inode_buffer, buffsz)) err(MKFS_EX_ERROR, _("%s: unable to write inodes"), ctl->device_name); } @@ -219,7 +219,7 @@ static void write_block(const struct fs_control *ctl, int blk, char * buffer) if (blk * MINIX_BLOCK_SIZE != lseek(ctl->device_fd, blk * MINIX_BLOCK_SIZE, SEEK_SET)) errx(MKFS_EX_ERROR, _("%s: seek failed in write_block"), ctl->device_name); - if (write_all(ctl->device_fd, buffer, MINIX_BLOCK_SIZE)) + if (ul_write_all(ctl->device_fd, buffer, MINIX_BLOCK_SIZE)) errx(MKFS_EX_ERROR, _("%s: write failed in write_block"), ctl->device_name); } diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index d220d8f8c..a820a8815 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -492,7 +492,7 @@ static void wipe_device(struct mkswap_control *ctl) if (lseek(ctl->fd, 0, SEEK_SET) != 0) errx(EXIT_FAILURE, _("unable to rewind swap-device")); - if (write_all(ctl->fd, buf, sizeof(buf))) + if (ul_write_all(ctl->fd, buf, sizeof(buf))) errx(EXIT_FAILURE, _("unable to erase bootbits sectors")); #ifdef HAVE_LIBBLKID /* @@ -544,7 +544,7 @@ static void write_header_to_device(struct mkswap_control *ctl) if (lseek(ctl->fd, offset, SEEK_SET) != offset) errx(EXIT_FAILURE, _("unable to rewind swap-device")); - if (write_all(ctl->fd, (char *) ctl->signature_page + SIGNATURE_OFFSET, + if (ul_write_all(ctl->fd, (char *) ctl->signature_page + SIGNATURE_OFFSET, ctl->pagesize - SIGNATURE_OFFSET) == -1) err(EXIT_FAILURE, _("%s: unable to write signature page"), diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index c4037efff..431b87aed 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -305,12 +305,12 @@ static void backup_sectors(struct sfdisk *sf, } else { unsigned char *buf = xmalloc(size); - if (read_all(devfd, (char *) buf, size) != (ssize_t) size) { + if (ul_read_all(devfd, (char *) buf, size) != (ssize_t) size) { fdisk_warn(sf->cxt, _("cannot read %s"), devname); free(buf); goto fail; } - if (write_all(fd, buf, size) != 0) { + if (ul_write_all(fd, buf, size) != 0) { fdisk_warn(sf->cxt, _("cannot write %s"), fname); free(buf); goto fail; @@ -548,7 +548,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa if (!sf->noact) { /* read source */ if (lseek(fd, src, SEEK_SET) == (off_t) -1 || - read_all(fd, buf, step_bytes) != (ssize_t) step_bytes) { + ul_read_all(fd, buf, step_bytes) != (ssize_t) step_bytes) { if (f) fprintf(f, "%05zu: read error %12ju %12ju\n", cc, src, dst); fdisk_warn(sf->cxt, @@ -559,7 +559,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa /* write target */ if (lseek(fd, dst, SEEK_SET) == (off_t) -1 || - write_all(fd, buf, step_bytes) != 0) { + ul_write_all(fd, buf, step_bytes) != 0) { if (f) fprintf(f, "%05zu: write error %12ju %12ju\n", cc, src, dst); fdisk_warn(sf->cxt, diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c index 29484ffe5..37cf5d5b1 100644 --- a/disk-utils/swaplabel.c +++ b/disk-utils/swaplabel.c @@ -79,7 +79,7 @@ static int change_info(const char *devname, const char *label, warn(_("%s: failed to seek to swap UUID"), devname); goto err; - } else if (write_all(fd, newuuid, sizeof(newuuid))) { + } else if (ul_write_all(fd, newuuid, sizeof(newuuid))) { warn(_("%s: failed to write UUID"), devname); goto err; } @@ -100,7 +100,7 @@ static int change_info(const char *devname, const char *label, if (strlen(label) > strlen(newlabel)) warnx(_("label is too long. Truncating it to '%s'"), newlabel); - if (write_all(fd, newlabel, sizeof(newlabel))) { + if (ul_write_all(fd, newlabel, sizeof(newlabel))) { warn(_("%s: failed to write label"), devname); goto err; } diff --git a/include/all-io.h b/include/all-io.h index 65eae6025..f83688c0a 100644 --- a/include/all-io.h +++ b/include/all-io.h @@ -19,7 +19,7 @@ #include "c.h" -static inline int write_all(int fd, const void *buf, size_t count) +static inline int ul_write_all(int fd, const void *buf, size_t count) { while (count) { ssize_t tmp; @@ -38,7 +38,7 @@ static inline int write_all(int fd, const void *buf, size_t count) return 0; } -static inline int fwrite_all(const void *ptr, size_t size, +static inline int ul_fwrite_all(const void *ptr, size_t size, size_t nmemb, FILE *stream) { while (nmemb) { @@ -58,7 +58,7 @@ static inline int fwrite_all(const void *ptr, size_t size, return 0; } -static inline ssize_t read_all(int fd, char *buf, size_t count) +static inline ssize_t ul_read_all(int fd, char *buf, size_t count) { ssize_t ret; ssize_t c = 0; @@ -84,7 +84,7 @@ static inline ssize_t read_all(int fd, char *buf, size_t count) return c; } -static inline ssize_t read_all_alloc(int fd, char **buf) +static inline ssize_t ul_read_all_alloc(int fd, char **buf) { size_t size = 1024, c = 0; ssize_t ret; @@ -94,7 +94,7 @@ static inline ssize_t read_all_alloc(int fd, char **buf) return -1; while (1) { - ret = read_all(fd, *buf + c, size - c); + ret = ul_read_all(fd, *buf + c, size - c); if (ret < 0) { free(*buf); *buf = NULL; @@ -114,7 +114,7 @@ static inline ssize_t read_all_alloc(int fd, char **buf) } } -static inline ssize_t sendfile_all(int out __attribute__((__unused__)), +static inline ssize_t ul_sendfile_all(int out __attribute__((__unused__)), int in __attribute__((__unused__)), off_t *off __attribute__((__unused__)), size_t count __attribute__((__unused__))) diff --git a/lib/blkdev.c b/lib/blkdev.c index b3b343441..cd40c41e8 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -46,7 +46,7 @@ blkdev_valid_offset (int fd, off_t offset) { if (lseek (fd, offset, 0) < 0) return 0; - if (read_all (fd, &ch, 1) < 1) + if (ul_read_all (fd, &ch, 1) < 1) return 0; return 1; } diff --git a/lib/env.c b/lib/env.c index e459959e0..2ea46254b 100644 --- a/lib/env.c +++ b/lib/env.c @@ -173,7 +173,7 @@ struct ul_env_list *env_list_from_fd(int fd) struct ul_env_list *ls = NULL; errno = 0; - if ((rc = read_all_alloc(fd, &buf)) < 1) + if ((rc = ul_read_all_alloc(fd, &buf)) < 1) return NULL; buf[rc] = '\0'; p = buf; diff --git a/lib/fileeq.c b/lib/fileeq.c index 92c0c2c4b..4717bcfcf 100644 --- a/lib/fileeq.c +++ b/lib/fileeq.c @@ -394,7 +394,7 @@ static ssize_t read_block(struct ul_fileeq *eq, struct ul_fileeq_data *data, if (!*block) return -ENOMEM; - rsz = read_all(data->fd, (char *) *block, eq->readsiz); + rsz = ul_read_all(data->fd, (char *) *block, eq->readsiz); if (rsz < 0) { DBG_OBJ(DATA, data, ul_debug(" read failed")); return rsz; @@ -462,7 +462,7 @@ static ssize_t get_digest(struct ul_fileeq *eq, struct ul_fileeq_data *data, /* get block digest (note 1st block is data->intro) */ *block = data->blocks + (n * eq->method->digsiz); - rsz = read_all(eq->fd_cip, (char *) *block, sz); + rsz = ul_read_all(eq->fd_cip, (char *) *block, sz); if (rsz > 0) data->nblocks++; @@ -484,7 +484,7 @@ static ssize_t get_intro(struct ul_fileeq *eq, struct ul_fileeq_data *data, if (fd < 0) return -1; - rsz = read_all(fd, (char *) data->intro, sizeof(data->intro)); + rsz = ul_read_all(fd, (char *) data->intro, sizeof(data->intro)); DBG_OBJ(DATA, data, ul_debug(" read %zd bytes [%zu wanted] intro", rsz, sizeof(data->intro))); if (rsz < 0) return -1; diff --git a/lib/fileutils.c b/lib/fileutils.c index 447a342e7..8ae02efd5 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -221,9 +221,9 @@ char *ul_restricted_path_oper(const char *path, errno ? -errno : -EINVAL; /* send length or errno */ - write_all(pipes[1], (char *) &len, sizeof(len)); + ul_write_all(pipes[1], (char *) &len, sizeof(len)); if (result) - write_all(pipes[1], result, len); + ul_write_all(pipes[1], result, len); _exit(0); default: break; @@ -233,7 +233,7 @@ char *ul_restricted_path_oper(const char *path, pipes[1] = -1; /* read size or -errno */ - if (read_all(pipes[0], (char *) &len, sizeof(len)) != sizeof(len)) + if (ul_read_all(pipes[0], (char *) &len, sizeof(len)) != sizeof(len)) goto done; if (len < 0) { errsv = -len; @@ -246,7 +246,7 @@ char *ul_restricted_path_oper(const char *path, goto done; } /* read path */ - if (read_all(pipes[0], result, len) != len) { + if (ul_read_all(pipes[0], result, len) != len) { errsv = errno; goto done; } @@ -355,8 +355,8 @@ static int copy_file_simple(int from, int to) ssize_t nr; char buf[BUFSIZ]; - while ((nr = read_all(from, buf, sizeof(buf))) > 0) - if (write_all(to, buf, nr) == -1) + while ((nr = ul_read_all(from, buf, sizeof(buf))) > 0) + if (ul_write_all(to, buf, nr) == -1) return UL_COPY_WRITE_ERROR; if (nr < 0) return UL_COPY_READ_ERROR; @@ -377,10 +377,10 @@ int ul_copy_file(int from, int to) return UL_COPY_READ_ERROR; if (!S_ISREG(st.st_mode)) return copy_file_simple(from, to); - if (sendfile_all(to, from, NULL, st.st_size) < 0) + if (ul_sendfile_all(to, from, NULL, st.st_size) < 0) return copy_file_simple(from, to); /* ensure we either get an EOF or an error */ - while ((nw = sendfile_all(to, from, NULL, 16*1024*1024)) != 0) + while ((nw = ul_sendfile_all(to, from, NULL, 16*1024*1024)) != 0) if (nw < 0) return copy_file_simple(from, to); return 0; diff --git a/lib/path.c b/lib/path.c index ec37f4439..2a30bf9e7 100644 --- a/lib/path.c +++ b/lib/path.c @@ -677,7 +677,7 @@ int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path) return -errno; DBG(CXT, ul_debug(" reading '%s'", path)); - rc = read_all(fd, buf, len); + rc = ul_read_all(fd, buf, len); errsv = errno; close(fd); @@ -954,7 +954,7 @@ int ul_path_write_string(struct path_cxt *pc, const char *str, const char *path) if (fd < 0) return -errno; - rc = write_all(fd, str, strlen(str)); + rc = ul_write_all(fd, str, strlen(str)); errsv = errno; close(fd); @@ -988,7 +988,7 @@ int ul_path_write_s64(struct path_cxt *pc, int64_t num, const char *path) if (len < 0 || (size_t) len >= sizeof(buf)) rc = len < 0 ? -errno : -E2BIG; else - rc = write_all(fd, buf, len); + rc = ul_write_all(fd, buf, len); errsv = errno; close(fd); @@ -1010,7 +1010,7 @@ int ul_path_write_u64(struct path_cxt *pc, uint64_t num, const char *path) if (len < 0 || (size_t) len >= sizeof(buf)) rc = len < 0 ? -errno : -E2BIG; else - rc = write_all(fd, buf, len); + rc = ul_write_all(fd, buf, len); errsv = errno; close(fd); diff --git a/lib/plymouth-ctrl.c b/lib/plymouth-ctrl.c index 81f9c9f7d..fc8a25aba 100644 --- a/lib/plymouth-ctrl.c +++ b/lib/plymouth-ctrl.c @@ -112,14 +112,14 @@ int plymouth_command(int cmd, ...) fdsock = open_un_socket_and_connect(); if (fdsock >= 0) { command[0] = cmd; - write_all(fdsock, command, sizeof(command)); + ul_write_all(fdsock, command, sizeof(command)); } break; case MAGIC_QUIT: fdsock = open_un_socket_and_connect(); if (fdsock >= 0) { command[0] = cmd; - write_all(fdsock, command, sizeof(command)); + ul_write_all(fdsock, command, sizeof(command)); } break; default: @@ -131,7 +131,7 @@ int plymouth_command(int cmd, ...) answer[0] = '\0'; if (fdsock >= 0) { if (can_read(fdsock, 1000)) - read_all(fdsock, (char *) &answer[0], sizeof(answer)); + ul_read_all(fdsock, (char *) &answer[0], sizeof(answer)); close(fdsock); } sigaction(SIGPIPE, &op, NULL); diff --git a/lib/procfs.c b/lib/procfs.c index 66e1eedcc..1f760a144 100644 --- a/lib/procfs.c +++ b/lib/procfs.c @@ -127,7 +127,7 @@ static ssize_t read_procfs_file(int fd, char *buf, size_t bufsz) if (fd < 0) return -EINVAL; - sz = read_all(fd, buf, bufsz); + sz = ul_read_all(fd, buf, bufsz); if (sz <= 0) return sz; diff --git a/lib/pty-session.c b/lib/pty-session.c index adbbef979..ba46ba243 100644 --- a/lib/pty-session.c +++ b/lib/pty-session.c @@ -312,7 +312,7 @@ static int write_output(char *obuf, ssize_t bytes) { DBG(IO, ul_debug(" writing output")); - if (write_all(STDOUT_FILENO, obuf, bytes)) { + if (ul_write_all(STDOUT_FILENO, obuf, bytes)) { DBG(IO, ul_debug(" writing output *failed*")); return -errno; } diff --git a/lib/sysfs.c b/lib/sysfs.c index a856854bd..ad8a88ed0 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -474,7 +474,7 @@ static int sysfs_devchain_is_removable(char *chain) /* try to read it */ fd = open(chain, O_RDONLY); if (fd != -1) { - rc = read_all(fd, buf, sizeof(buf)); + rc = ul_read_all(fd, buf, sizeof(buf)); close(fd); if (rc > 0) { diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c index bbe6d8c46..45691f4ad 100644 --- a/libblkid/src/probe.c +++ b/libblkid/src/probe.c @@ -1622,7 +1622,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun) memset(buf, 0, len); /* wipen on device */ - if (write_all(fd, buf, len)) + if (ul_write_all(fd, buf, len)) return BLKID_PROBE_ERROR; if (fsync(fd) != 0) return BLKID_PROBE_ERROR; diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c index cb988f041..6ecbdef60 100644 --- a/libfdisk/src/bsd.c +++ b/libfdisk/src/bsd.c @@ -643,7 +643,7 @@ static int bsd_get_bootstrap(struct fdisk_context *cxt, return -errno; } - if (read_all(fd, ptr, size) != size) { + if (ul_read_all(fd, ptr, size) != size) { fdisk_warn(cxt, _("cannot read %s"), path); close(fd); return -errno; @@ -720,7 +720,7 @@ int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt) rc = -errno; goto done; } - if (write_all(cxt->dev_fd, l->bsdbuffer, BSD_BBSIZE)) { + if (ul_write_all(cxt->dev_fd, l->bsdbuffer, BSD_BBSIZE)) { fdisk_warn(cxt, _("cannot write %s"), cxt->dev_path); rc = -errno; goto done; @@ -839,7 +839,7 @@ static int bsd_readlabel(struct fdisk_context *cxt) if (lseek(cxt->dev_fd, offset, SEEK_SET) == -1) return -1; - if (read_all(cxt->dev_fd, l->bsdbuffer, sizeof(l->bsdbuffer)) < 0) + if (ul_read_all(cxt->dev_fd, l->bsdbuffer, sizeof(l->bsdbuffer)) < 0) return errno ? -errno : -1; /* The offset to begin of the disk label. Note that BSD uses @@ -903,7 +903,7 @@ static int bsd_write_disklabel(struct fdisk_context *cxt) fdisk_warn(cxt, _("seek on %s failed"), cxt->dev_path); return -errno; } - if (write_all(cxt->dev_fd, l->bsdbuffer, sizeof(l->bsdbuffer))) { + if (ul_write_all(cxt->dev_fd, l->bsdbuffer, sizeof(l->bsdbuffer))) { fdisk_warn(cxt, _("cannot write %s"), cxt->dev_path); return -errno; } diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index a2a9314c3..9f0139cf2 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -2067,7 +2067,7 @@ static int gpt_read(struct fdisk_context *cxt, off_t offset, void *buf, size_t c if (offset != lseek(cxt->dev_fd, offset, SEEK_SET)) return -errno; - if (read_all(cxt->dev_fd, buf, count)) + if (ul_read_all(cxt->dev_fd, buf, count)) return -errno; DBG(GPT, ul_debug(" read OK [offset=%zu, size=%zu]", @@ -2080,7 +2080,7 @@ static int gpt_write(struct fdisk_context *cxt, off_t offset, void *buf, size_t if (offset != lseek(cxt->dev_fd, offset, SEEK_SET)) return -errno; - if (write_all(cxt->dev_fd, buf, count)) + if (ul_write_all(cxt->dev_fd, buf, count)) return -errno; if (fsync(cxt->dev_fd) != 0) diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c index a01e98c25..4b72ca70a 100644 --- a/libfdisk/src/script.c +++ b/libfdisk/src/script.c @@ -1712,7 +1712,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) fd = mkstemp_cloexec(name); if (fd < 0) err(EXIT_FAILURE, "mkstemp() failed"); - if (write_all(fd, data, size) != 0) + if (ul_write_all(fd, data, size) != 0) err(EXIT_FAILURE, "write() failed"); f = fopen(name, "r"); if (!f) diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index 4ddf8924d..1ec14f0e0 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -484,7 +484,7 @@ static int sgi_write_disklabel(struct fdisk_context *cxt) if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0) goto err; - if (write_all(cxt->dev_fd, sgilabel, DEFAULT_SECTOR_SIZE)) + if (ul_write_all(cxt->dev_fd, sgilabel, DEFAULT_SECTOR_SIZE)) goto err; if (!strncmp((char *) sgilabel->volume[0].name, "sgilabel", 8)) { /* @@ -500,7 +500,7 @@ static int sgi_write_disklabel(struct fdisk_context *cxt) info = sgi_new_info(); if (!info) goto err; - if (write_all(cxt->dev_fd, info, sizeof(*info))) + if (ul_write_all(cxt->dev_fd, info, sizeof(*info))) goto err; } diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index b55d0e291..2328b03ec 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -1026,7 +1026,7 @@ static int sun_write_disklabel(struct fdisk_context *cxt) if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0) return -errno; - if (write_all(cxt->dev_fd, sunlabel, sz) != 0) + if (ul_write_all(cxt->dev_fd, sunlabel, sz) != 0) return -errno; return 0; diff --git a/libmount/src/hook_idmap.c b/libmount/src/hook_idmap.c index 88c04e14c..8be6cdc1e 100644 --- a/libmount/src/hook_idmap.c +++ b/libmount/src/hook_idmap.c @@ -100,7 +100,7 @@ static int write_id_mapping(idmap_type_t map_type, pid_t pid, const char *buf, goto err; if (setgroups_fd >= 0) { - rc = write_all(setgroups_fd, "deny\n", strlen("deny\n")); + rc = ul_write_all(setgroups_fd, "deny\n", strlen("deny\n")); if (rc) goto err; } @@ -113,7 +113,7 @@ static int write_id_mapping(idmap_type_t map_type, pid_t pid, const char *buf, if (fd < 0) goto err; - rc = write_all(fd, buf, buf_size); + rc = ul_write_all(fd, buf, buf_size); err: if (fd >= 0) @@ -213,12 +213,12 @@ static int get_userns_fd_from_idmap(struct list_head *idmap) _exit(EXIT_FAILURE); /* Let parent know we're ready to have the idmapping written. */ - rc = write_all(sock_fds[0], &c, 1); + rc = ul_write_all(sock_fds[0], &c, 1); if (rc) _exit(EXIT_FAILURE); /* Hang around until the parent has persisted our namespace. */ - rc = read_all(sock_fds[0], &c, 1); + rc = ul_read_all(sock_fds[0], &c, 1); if (rc != 1) _exit(EXIT_FAILURE); @@ -230,7 +230,7 @@ static int get_userns_fd_from_idmap(struct list_head *idmap) sock_fds[0] = -1; /* Wait for child to set up a new namespace. */ - rc = read_all(sock_fds[1], &c, 1); + rc = ul_read_all(sock_fds[1], &c, 1); if (rc != 1) { kill(pid, SIGKILL); goto err_wait; @@ -246,7 +246,7 @@ static int get_userns_fd_from_idmap(struct list_head *idmap) fd_userns = open(path, O_RDONLY | O_CLOEXEC | O_NOCTTY); /* Let child know we've persisted its namespace. */ - (void)write_all(sock_fds[1], &c, 1); + (void)ul_write_all(sock_fds[1], &c, 1); err_wait: rc = wait_for_pid(pid); diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 4cc32e964..9eae92299 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -509,14 +509,14 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num) if (ret < 1) goto fail; - ret = read_all(s, (char *) &reply_len, sizeof(reply_len)); + ret = ul_read_all(s, (char *) &reply_len, sizeof(reply_len)); if (ret < 0) goto fail; if (reply_len != expected) goto fail; - ret = read_all(s, op_buf, reply_len); + ret = ul_read_all(s, op_buf, reply_len); if (op == UUIDD_OP_BULK_TIME_UUID) memcpy(op_buf+16, num, sizeof(int)); diff --git a/login-utils/last.c b/login-utils/last.c index 1f5b800c8..0292bb8e7 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -964,7 +964,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) fd = mkstemp_cloexec(name); if (fd < 0) err(EXIT_FAILURE, "mkstemp() failed"); - if (write_all(fd, data, size) != 0) + if (ul_write_all(fd, data, size) != 0) err(EXIT_FAILURE, "write() failed"); process_wtmp_file(&ctl, name); diff --git a/misc-utils/enosys.c b/misc-utils/enosys.c index f1438b8e8..008842da0 100644 --- a/misc-utils/enosys.c +++ b/misc-utils/enosys.c @@ -282,7 +282,7 @@ int main(int argc, char **argv) INSTR(BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW)); if (dump) { - if (fwrite_all(filter, (f - filter) * sizeof(filter[0]), 1, dump)) + if (ul_fwrite_all(filter, (f - filter) * sizeof(filter[0]), 1, dump)) err(EXIT_FAILURE, _("Could not dump seccomp filter")); return EXIT_SUCCESS; } diff --git a/misc-utils/lsclocks.c b/misc-utils/lsclocks.c index 4d2029d55..96981a762 100644 --- a/misc-utils/lsclocks.c +++ b/misc-utils/lsclocks.c @@ -283,7 +283,7 @@ static int64_t get_namespace_offset(const char *name) if (fd == -1) err(EXIT_FAILURE, _("Could not open %s"), _PATH_PROC_TIMENS_OFF); - read_all_alloc(fd, &buf); + ul_read_all_alloc(fd, &buf); for (tokstr = buf; ; tokstr = NULL) { line = strtok_r(tokstr, "\n", &saveptr); diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c index 38b17d394..176168ba0 100644 --- a/misc-utils/mcookie.c +++ b/misc-utils/mcookie.c @@ -69,7 +69,7 @@ static uint64_t hash_file(struct mcookie_control *ctl, int fd) if (wanted - count < rdsz) rdsz = wanted - count; - r = read_all(fd, (char *) buf, rdsz); + r = ul_read_all(fd, (char *) buf, rdsz); if (r <= 0) break; ul_MD5Update(&ctl->ctx, buf, r); diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c index 91e305344..10890428f 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -178,7 +178,7 @@ static int call_daemon(const char *socket_path, uuidd_prot_op_t op, char *buf, op_len += sizeof(*num); } - ret = write_all(s, op_buf, op_len); + ret = ul_write_all(s, op_buf, op_len); if (ret < 0) { if (err_context) *err_context = _("write"); @@ -186,7 +186,7 @@ static int call_daemon(const char *socket_path, uuidd_prot_op_t op, char *buf, return -1; } - ret = read_all(s, (char *) &reply_len, sizeof(reply_len)); + ret = ul_read_all(s, (char *) &reply_len, sizeof(reply_len)); if (ret < 0) { if (err_context) *err_context = _("read count"); @@ -199,7 +199,7 @@ static int call_daemon(const char *socket_path, uuidd_prot_op_t op, char *buf, close(s); return -1; } - ret = read_all(s, (char *) buf, reply_len); + ret = ul_read_all(s, (char *) buf, reply_len); if ((ret > 0) && (op == UUIDD_OP_BULK_TIME_UUID)) { if ((sizeof(uuid_t) + sizeof(*num)) <= (size_t) reply_len) @@ -402,7 +402,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, snprintf(reply_buf, sizeof(reply_buf), "%8d\n", getpid()); if (ftruncate(fd_pidfile, 0)) err(EXIT_FAILURE, _("could not truncate file: %s"), pidfile_path); - write_all(fd_pidfile, reply_buf, strlen(reply_buf)); + ul_write_all(fd_pidfile, reply_buf, strlen(reply_buf)); if (fd_pidfile > 1 && close_fd(fd_pidfile) != 0) err(EXIT_FAILURE, _("write failed: %s"), pidfile_path); } @@ -479,7 +479,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, } if ((op == UUIDD_OP_BULK_TIME_UUID) || (op == UUIDD_OP_BULK_RANDOM_UUID)) { - if (read_all(ns, (char *) &num, sizeof(num)) != sizeof(num)) + if (ul_read_all(ns, (char *) &num, sizeof(num)) != sizeof(num)) goto shutdown_socket; if (uuidd_cxt->debug) fprintf(stderr, _("operation %d, incoming num = %d\n"), @@ -560,8 +560,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path, fprintf(stderr, _("Invalid operation %d\n"), op); goto shutdown_socket; } - write_all(ns, (char *) &reply_len, sizeof(num)); - write_all(ns, reply_buf, reply_len); + ul_write_all(ns, (char *) &reply_len, sizeof(num)); + ul_write_all(ns, reply_buf, reply_len); shutdown_socket: close(ns); } diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 8020c26b0..dad1ad277 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -478,7 +478,7 @@ static void do_backup(struct wipe_desc *wp, const char *base) fd = open(fname, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); if (fd < 0) goto err; - if (write_all(fd, wp->magic, wp->len) != 0) + if (ul_write_all(fd, wp->magic, wp->len) != 0) goto err; close(fd); free(fname); diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index eba8da126..de3b87b23 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -463,7 +463,7 @@ int main(int argc, char **argv) if (introparm && *introparm) { dbg("intro command is '%s'", introparm); - if (write_all(tty_fd, introparm, strlen(introparm)) != 0) + if (ul_write_all(tty_fd, introparm, strlen(introparm)) != 0) err(EXIT_FAILURE, _("cannot write intro command to %s"), dev); diff --git a/sys-utils/lscpu-virt.c b/sys-utils/lscpu-virt.c index 5cdb4834b..e8ed36d2c 100644 --- a/sys-utils/lscpu-virt.c +++ b/sys-utils/lscpu-virt.c @@ -75,7 +75,7 @@ void *get_mem_chunk(size_t base, size_t len, const char *devmem) goto nothing; if (lseek(fd, base, SEEK_SET) == -1) goto nothing; - if (read_all(fd, p, len) == -1) + if (ul_read_all(fd, p, len) == -1) goto nothing; close(fd); diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index c1706cef9..5fbef8746 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -475,7 +475,7 @@ static void open_cgroup_procs(void) open_target_fd(&cgroup_fd, "cgroup", optarg); - if (read_all_alloc(cgroup_fd, &buf) < 1) + if (ul_read_all_alloc(cgroup_fd, &buf) < 1) err(EXIT_FAILURE, _("failed to get cgroup path")); p = strtok(buf, "\n"); @@ -512,7 +512,7 @@ static void join_into_cgroup(void) pid = getpid(); len = snprintf(buf, sizeof(buf), "%zu", (size_t) pid); - if (write_all(cgroup_procs_fd, buf, len)) + if (ul_write_all(cgroup_procs_fd, buf, len)) err(EXIT_FAILURE, _("write cgroup.procs failed")); } diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c index e718328a8..989c8ee96 100644 --- a/sys-utils/rfkill.c +++ b/sys-utils/rfkill.c @@ -562,7 +562,7 @@ static int __rfkill_block(int fd, struct rfkill_id *id, uint8_t block, const cha abort(); } - if (write_all(fd, &event, sizeof(event)) != 0) + if (ul_write_all(fd, &event, sizeof(event)) != 0) warn(_("write failed: %s"), _PATH_DEV_RFKILL); else { openlog("rfkill", 0, LOG_USER); diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 9ec3ed96a..8ec571c50 100644 --- a/sys-utils/setpriv.c +++ b/sys-utils/setpriv.c @@ -742,7 +742,7 @@ static void do_seccomp_filter(const char *file) err(SETPRIV_EXIT_PRIVERR, _("cannot open %s"), file); - s = read_all_alloc(fd, &filter); + s = ul_read_all_alloc(fd, &filter); if (s < 0) err(SETPRIV_EXIT_PRIVERR, _("cannot read %s"), file); diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index 1e96ba478..4c4901a20 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -122,7 +122,7 @@ static void setgroups_control(int action) err(EXIT_FAILURE, _("cannot open %s"), file); } - if (write_all(fd, cmd, strlen(cmd))) + if (ul_write_all(fd, cmd, strlen(cmd))) err(EXIT_FAILURE, _("write failed %s"), file); close(fd); } @@ -137,7 +137,7 @@ static void map_id(const char *file, uint32_t from, uint32_t to) err(EXIT_FAILURE, _("cannot open %s"), file); xasprintf(&buf, "%u %u 1", from, to); - if (write_all(fd, buf, strlen(buf))) + if (ul_write_all(fd, buf, strlen(buf))) err(EXIT_FAILURE, _("write failed %s"), file); free(buf); close(fd); @@ -273,7 +273,7 @@ static void sync_with_child(pid_t pid, int fd) { uint64_t ch = PIPE_SYNC_BYTE; - write_all(fd, &ch, sizeof(ch)); + ul_write_all(fd, &ch, sizeof(ch)); close(fd); waitchild(pid); @@ -307,7 +307,7 @@ static pid_t fork_and_wait(int *fd) if (!pid) { /* wait for the our parent to tell us to continue */ - if (read_all(*fd, (char *)&ch, sizeof(ch)) != sizeof(ch) || + if (ul_read_all(*fd, (char *)&ch, sizeof(ch)) != sizeof(ch) || ch != PIPE_SYNC_BYTE) err(EXIT_FAILURE, _("failed to read eventfd")); close(*fd); @@ -660,7 +660,7 @@ static void map_ids_internal(const char *type, int ppid, struct map_range *chain fd = open(path, O_WRONLY | O_CLOEXEC | O_NOCTTY); if (fd < 0) err(EXIT_FAILURE, _("failed to open %s"), path); - if (write_all(fd, buffer, length) < 0) + if (ul_write_all(fd, buffer, length) < 0) err(EXIT_FAILURE, _("failed to write %s"), path); close(fd); free(path); @@ -733,7 +733,7 @@ static void load_interp(const char *binfmt_mnt, const char *interp) if (fd < 0) err(EXIT_FAILURE, _("cannot open %s/register"), binfmt_mnt); - if (write_all(fd, interp, strlen(interp))) + if (ul_write_all(fd, interp, strlen(interp))) err(EXIT_FAILURE, _("write failed %s/register"), binfmt_mnt); close(fd); diff --git a/term-utils/script.c b/term-utils/script.c index d7c885c71..3991ea646 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -499,7 +499,7 @@ static ssize_t log_write(struct script_control *ctl, switch (log->format) { case SCRIPT_FMT_RAW: DBG(IO, ul_debug(" log raw data")); - rc = fwrite_all(obuf, 1, bytes, log->fp); + rc = ul_fwrite_all(obuf, 1, bytes, log->fp); if (rc) { warn(_("cannot write %s"), log->filename); return rc; diff --git a/term-utils/setterm.c b/term-utils/setterm.c index a9df5cb60..8ec0668bf 100644 --- a/term-utils/setterm.c +++ b/term-utils/setterm.c @@ -896,7 +896,7 @@ static int resizetty(void) errx(EXIT_FAILURE, _("stdin does not refer to a terminal")); tty_raw(&saved_attributes, &saved_fl); - if (write_all(STDIN_FILENO, getpos, strlen(getpos)) < 0) { + if (ul_write_all(STDIN_FILENO, getpos, strlen(getpos)) < 0) { warn(_("write failed")); tty_restore(&saved_attributes, &saved_fl); return 1; diff --git a/text-utils/pg.c b/text-utils/pg.c index 939086bc8..2e3a03981 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -296,7 +296,7 @@ static size_t xmbstowcs(wchar_t * pwcs, const char *s, size_t nwcs) static int outcap(int i) { char c = i; - return write_all(STDOUT_FILENO, &c, 1) == 0 ? 1 : -1; + return ul_write_all(STDOUT_FILENO, &c, 1) == 0 ? 1 : -1; } /* Write messages to terminal. */ @@ -306,7 +306,7 @@ static void mesg(const char *message) return; if (*message != '\n' && sflag) vidputs(A_STANDOUT, outcap); - write_all(STDOUT_FILENO, message, strlen(message)); + ul_write_all(STDOUT_FILENO, message, strlen(message)); if (*message != '\n' && sflag) vidputs(A_NORMAL, outcap); } @@ -518,7 +518,7 @@ static void cline(void) memset(buf, ' ', ttycols + 2); buf[0] = '\r'; buf[ttycols + 1] = '\r'; - write_all(STDOUT_FILENO, buf, ttycols + 2); + ul_write_all(STDOUT_FILENO, buf, ttycols + 2); free(buf); } @@ -646,7 +646,7 @@ static void prompt(long long pageno) } if (key == tio.c_cc[VERASE]) { if (cmd.cmdlen) { - write_all(STDOUT_FILENO, "\b \b", 3); + ul_write_all(STDOUT_FILENO, "\b \b", 3); cmd.cmdline[--cmd.cmdlen] = '\0'; switch (state) { case ADDON_FIN: @@ -748,7 +748,7 @@ static void prompt(long long pageno) cmd.key = key; } } - write_all(STDOUT_FILENO, &key, 1); + ul_write_all(STDOUT_FILENO, &key, 1); if (cmd.cmdlen + 1 >= sizeof(cmd.cmdline)) goto endprompt; @@ -935,7 +935,7 @@ static void pgfile(FILE *f, const char *name) if (ontty == 0) { /* Just copy stdin to stdout. */ while ((sz = fread(b, sizeof *b, READBUF, f)) != 0) - write_all(STDOUT_FILENO, b, sz); + ul_write_all(STDOUT_FILENO, b, sz); if (ferror(f)) { warn("%s", name); exitstatus++; @@ -1012,7 +1012,7 @@ static void pgfile(FILE *f, const char *name) if (!nobuf) fputs(b, fbuf); - fwrite_all(&pos, sizeof pos, 1, find); + ul_fwrite_all(&pos, sizeof pos, 1, find); if (!fflag) { oldpos = pos; p = b; @@ -1020,7 +1020,7 @@ static void pgfile(FILE *f, const char *name) p)) != '\0') { pos = oldpos + (p - b); - fwrite_all(&pos, + ul_fwrite_all(&pos, sizeof pos, 1, find); fline++; @@ -1090,7 +1090,7 @@ static void pgfile(FILE *f, const char *name) sz = p - b; makeprint(b, sz); canjump = 1; - write_all(STDOUT_FILENO, b, sz); + ul_write_all(STDOUT_FILENO, b, sz); canjump = 0; } } @@ -1234,7 +1234,7 @@ static void pgfile(FILE *f, const char *name) } if (!nobuf) fputs(b, fbuf); - fwrite_all(&pos, sizeof pos, 1, find); + ul_fwrite_all(&pos, sizeof pos, 1, find); if (!fflag) { oldpos = pos; p = b; @@ -1242,7 +1242,7 @@ static void pgfile(FILE *f, const char *name) p)) != '\0') { pos = oldpos + (p - b); - fwrite_all(&pos, + ul_fwrite_all(&pos, sizeof pos, 1, find); fline++; @@ -1256,7 +1256,7 @@ static void pgfile(FILE *f, const char *name) while ((sz = fread(b, sizeof *b, READBUF, fbuf)) != 0) { /* No error check for compat. */ - fwrite_all(b, sizeof *b, sz, save); + ul_fwrite_all(b, sizeof *b, sz, save); } if (close_stream(save) != 0) { cmd.count = errno; @@ -1362,9 +1362,9 @@ static void pgfile(FILE *f, const char *name) } else { pid_t cpid; - write_all(STDOUT_FILENO, cmd.cmdline, + ul_write_all(STDOUT_FILENO, cmd.cmdline, strlen(cmd.cmdline)); - write_all(STDOUT_FILENO, "\n", 1); + ul_write_all(STDOUT_FILENO, "\n", 1); my_sigset(SIGINT, SIG_IGN); my_sigset(SIGQUIT, SIG_IGN); switch (cpid = fork()) { @@ -1406,9 +1406,9 @@ static void pgfile(FILE *f, const char *name) { /* Help! */ const char *help = _(helpscreen); - write_all(STDOUT_FILENO, copyright, + ul_write_all(STDOUT_FILENO, copyright, strlen(copyright)); - write_all(STDOUT_FILENO, help, + ul_write_all(STDOUT_FILENO, help, strlen(help)); goto newcmd; } @@ -1528,9 +1528,9 @@ static int parse_arguments(int arg, int argc, char **argv) } if (ontty == 0 && argc > 2) { /* Use the prefix as specified by SUSv2. */ - write_all(STDOUT_FILENO, "::::::::::::::\n", 15); - write_all(STDOUT_FILENO, argv[arg], strlen(argv[arg])); - write_all(STDOUT_FILENO, "\n::::::::::::::\n", 16); + ul_write_all(STDOUT_FILENO, "::::::::::::::\n", 15); + ul_write_all(STDOUT_FILENO, argv[arg], strlen(argv[arg])); + ul_write_all(STDOUT_FILENO, "\n::::::::::::::\n", 16); } pgfile(input, argv[arg]); if (input != stdin) -- 2.47.3