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));
}
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);
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);
}
if (!op->autolog) {
/* Always show login prompt. */
- write_all(STDOUT_FILENO, LOGIN_PROMPT,
+ ul_write_all(STDOUT_FILENO, LOGIN_PROMPT,
sizeof(LOGIN_PROMPT) - 1);
}
}
/* 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 */
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 {
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;
{
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 ((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) {
}
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. */
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);
* 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)
};
int i;
for (i = 0; i < visual_count; i++)
- write_all(1, erase[cp->parity], 3);
+ ul_write_all(1, erase[cp->parity], 3);
}
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);
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"));
}
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);
}
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);
}
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
/*
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"),
} 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;
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,
/* 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,
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;
}
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;
}
#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;
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) {
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;
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;
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;
}
}
-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__)))
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;
}
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;
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;
/* 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++;
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;
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;
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;
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;
}
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;
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;
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);
if (fd < 0)
return -errno;
- rc = write_all(fd, str, strlen(str));
+ rc = ul_write_all(fd, str, strlen(str));
errsv = errno;
close(fd);
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);
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);
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:
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);
if (fd < 0)
return -EINVAL;
- sz = read_all(fd, buf, bufsz);
+ sz = ul_read_all(fd, buf, bufsz);
if (sz <= 0)
return sz;
{
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;
}
/* 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) {
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;
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;
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;
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
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;
}
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]",
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)
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)
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)) {
/*
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;
}
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;
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;
}
if (fd < 0)
goto err;
- rc = write_all(fd, buf, buf_size);
+ rc = ul_write_all(fd, buf, buf_size);
err:
if (fd >= 0)
_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);
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;
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);
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));
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);
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;
}
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);
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);
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");
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");
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)
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);
}
}
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"),
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);
}
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);
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);
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);
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");
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"));
}
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);
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);
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);
}
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);
{
uint64_t ch = PIPE_SYNC_BYTE;
- write_all(fd, &ch, sizeof(ch));
+ ul_write_all(fd, &ch, sizeof(ch));
close(fd);
waitchild(pid);
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);
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);
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);
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;
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;
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. */
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);
}
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);
}
}
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:
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;
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++;
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;
p))
!= '\0') {
pos = oldpos + (p - b);
- fwrite_all(&pos,
+ ul_fwrite_all(&pos,
sizeof pos,
1, find);
fline++;
sz = p - b;
makeprint(b, sz);
canjump = 1;
- write_all(STDOUT_FILENO, b, sz);
+ ul_write_all(STDOUT_FILENO, b, sz);
canjump = 0;
}
}
}
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;
p))
!= '\0') {
pos = oldpos + (p - b);
- fwrite_all(&pos,
+ ul_fwrite_all(&pos,
sizeof pos,
1, find);
fline++;
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;
} 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()) {
{
/* 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;
}
}
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)