diff options
Diffstat (limited to 'usr.sbin')
91 files changed, 742 insertions, 739 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index d4446660287..c8c7803a08c 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.308 2024/11/21 13:08:32 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.309 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -176,7 +176,7 @@ main(int argc, char *argv[]) if ((imsgbuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(imsgbuf, fd); + imsgbuf_init(imsgbuf, fd); done = 0; switch (res->action) { @@ -418,7 +418,7 @@ main(int argc, char *argv[]) output->head(res); again: - if (imsg_flush(imsgbuf) == -1) + if (imsgbuf_flush(imsgbuf) == -1) err(1, "write error"); while (!done) { @@ -435,8 +435,8 @@ main(int argc, char *argv[]) if (done) break; - if ((n = imsg_read(imsgbuf)) == -1) - err(1, "imsg_read error"); + if ((n = imsgbuf_read(imsgbuf)) == -1) + err(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); @@ -1383,7 +1383,7 @@ network_mrt_dump(struct mrt_rib *mr, struct mrt_peer *mp, void *arg) mre->attrs[j].attr, mre->attrs[j].attr_len); imsg_compose(imsgbuf, IMSG_NETWORK_DONE, 0, 0, -1, NULL, 0); - if (imsg_flush(imsgbuf) == -1) + if (imsgbuf_flush(imsgbuf) == -1) err(1, "write error"); } } diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 9d92a18ca36..2ad5102274a 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.272 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.273 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -276,9 +276,9 @@ main(int argc, char *argv[]) (ibuf_rde = malloc(sizeof(struct imsgbuf))) == NULL || (ibuf_rtr = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_se, pipe_m2s[0]); - imsg_init(ibuf_rde, pipe_m2r[0]); - imsg_init(ibuf_rtr, pipe_m2roa[0]); + imsgbuf_init(ibuf_se, pipe_m2s[0]); + imsgbuf_init(ibuf_rde, pipe_m2r[0]); + imsgbuf_init(ibuf_rtr, pipe_m2roa[0]); mrt_init(ibuf_rde, ibuf_se); if (kr_init(&rfd, conf->fib_priority) == -1) quit = 1; @@ -1273,7 +1273,7 @@ handle_pollfd(struct pollfd *pfd, struct imsgbuf *i) return (0); if (pfd->revents & POLLOUT) - if (imsg_write(i) == -1) { + if (imsgbuf_write(i) == -1) { log_warn("imsg write error"); close(i->fd); i->fd = -1; @@ -1281,7 +1281,7 @@ handle_pollfd(struct pollfd *pfd, struct imsgbuf *i) } if (pfd->revents & POLLIN) { - if ((n = imsg_read(i)) == -1 && errno != EAGAIN) { + if ((n = imsgbuf_read(i)) == -1 && errno != EAGAIN) { log_warn("imsg read error"); close(i->fd); i->fd = -1; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 5bd1464cd98..55927ead3ec 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.123 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.124 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -37,7 +37,7 @@ struct ctl_conn *control_connbyfd(int); struct ctl_conn *control_connbypid(pid_t); int control_close(struct ctl_conn *); void control_result(struct ctl_conn *, u_int); -ssize_t imsg_read_nofd(struct imsgbuf *); +ssize_t imsgbuf_read_nofd(struct imsgbuf *); int control_check(char *path) @@ -181,7 +181,7 @@ control_accept(int listenfd, int restricted) return (0); } - imsg_init(&ctl_conn->imsgbuf, connfd); + imsgbuf_init(&ctl_conn->imsgbuf, connfd); ctl_conn->restricted = restricted; TAILQ_INSERT_TAIL(&ctl_conns, ctl_conn, entry); @@ -249,7 +249,7 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers) } if (pfd->revents & POLLOUT) { - if (imsg_write(&c->imsgbuf) == -1) + if (imsgbuf_write(&c->imsgbuf) == -1) return control_close(c); if (c->throttled && c->imsgbuf.w.queued < CTL_MSG_LOW_MARK) { if (imsg_ctl_rde_msg(IMSG_XON, 0, c->imsgbuf.pid) != -1) @@ -260,7 +260,7 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers) if (!(pfd->revents & POLLIN)) return (0); - if (((n = imsg_read_nofd(&c->imsgbuf)) == -1 && errno != EAGAIN) || + if (((n = imsgbuf_read_nofd(&c->imsgbuf)) == -1 && errno != EAGAIN) || n == 0) return control_close(c); @@ -595,7 +595,7 @@ control_result(struct ctl_conn *c, u_int code) /* This should go into libutil, from smtpd/mproc.c */ ssize_t -imsg_read_nofd(struct imsgbuf *imsgbuf) +imsgbuf_read_nofd(struct imsgbuf *imsgbuf) { ssize_t n; char *buf; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 65d2744611f..e3beebbff20 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.634 2024/09/25 14:46:51 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.635 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -201,7 +201,7 @@ rde_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_main, 3); + imsgbuf_init(ibuf_main, 3); /* initialize the RIB structures */ if ((out_rules = calloc(1, sizeof(struct filter_head))) == NULL) @@ -843,7 +843,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *imsgbuf) } if ((i = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(i, fd); + imsgbuf_init(i, fd); switch (imsg_get_type(&imsg)) { case IMSG_SOCKET_CONN: if (ibuf_se) { diff --git a/usr.sbin/bgpd/rtr.c b/usr.sbin/bgpd/rtr.c index 630c42396c6..95bd485a6d0 100644 --- a/usr.sbin/bgpd/rtr.c +++ b/usr.sbin/bgpd/rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtr.c,v 1.24 2024/10/08 12:28:09 claudio Exp $ */ +/* $OpenBSD: rtr.c,v 1.25 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> @@ -219,7 +219,7 @@ rtr_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_main, 3); + imsgbuf_init(ibuf_main, 3); conf = new_config(); log_info("rtr engine ready"); @@ -336,7 +336,7 @@ rtr_dispatch_imsg_parent(struct imsgbuf *imsgbuf) } if ((ibuf_rde = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_rde, fd); + imsgbuf_init(ibuf_rde, fd); break; case IMSG_SOCKET_SETUP: if ((fd = imsg_get_fd(&imsg)) == -1) { diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index b33419a77f3..334b1028a49 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.487 2024/11/21 13:13:37 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.488 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -240,7 +240,7 @@ session_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_main, 3); + imsgbuf_init(ibuf_main, 3); LIST_INIT(&mrthead); listener_cnt = 0; @@ -539,7 +539,7 @@ session_main(int debug, int verbose) /* close pipes */ if (ibuf_rde) { - imsg_write(ibuf_rde); + imsgbuf_write(ibuf_rde); msgbuf_clear(&ibuf_rde->w); close(ibuf_rde->fd); free(ibuf_rde); @@ -549,7 +549,7 @@ session_main(int debug, int verbose) close(ibuf_rde_ctl->fd); free(ibuf_rde_ctl); } - imsg_write(ibuf_main); + imsgbuf_write(ibuf_main); msgbuf_clear(&ibuf_main->w); close(ibuf_main->fd); free(ibuf_main); @@ -2957,7 +2957,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt) } if ((i = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(i, fd); + imsgbuf_init(i, fd); if (imsg_get_type(&imsg) == IMSG_SOCKET_CONN) { if (ibuf_rde) { log_warnx("Unexpected imsg connection " diff --git a/usr.sbin/dhcp6leasectl/dhcp6leasectl.c b/usr.sbin/dhcp6leasectl/dhcp6leasectl.c index a30cf64ae37..5926be2923e 100644 --- a/usr.sbin/dhcp6leasectl/dhcp6leasectl.c +++ b/usr.sbin/dhcp6leasectl/dhcp6leasectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp6leasectl.c,v 1.2 2024/11/21 13:08:34 claudio Exp $ */ +/* $OpenBSD: dhcp6leasectl.c,v 1.3 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2021, 2024 Florian Obser <florian@openbsd.org> @@ -122,12 +122,12 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); if (!lFlag) { imsg_compose(ibuf, IMSG_CTL_SEND_REQUEST, 0, 0, -1, &if_index, sizeof(if_index)); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); } @@ -136,11 +136,11 @@ main(int argc, char *argv[]) imsg_compose(ibuf, IMSG_CTL_SHOW_INTERFACE_INFO, 0, 0, -1, &if_index, sizeof(if_index)); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/dhcpleasectl/dhcpleasectl.c b/usr.sbin/dhcpleasectl/dhcpleasectl.c index 8ca05e62b97..91a766d89d2 100644 --- a/usr.sbin/dhcpleasectl/dhcpleasectl.c +++ b/usr.sbin/dhcpleasectl/dhcpleasectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpleasectl.c,v 1.9 2024/11/21 13:08:48 claudio Exp $ */ +/* $OpenBSD: dhcpleasectl.c,v 1.10 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2021 Florian Obser <florian@openbsd.org> @@ -156,12 +156,12 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); if (!lFlag) { imsg_compose(ibuf, IMSG_CTL_SEND_REQUEST, 0, 0, -1, &if_index, sizeof(if_index)); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); } @@ -170,11 +170,11 @@ main(int argc, char *argv[]) imsg_compose(ibuf, IMSG_CTL_SHOW_INTERFACE_INFO, 0, 0, -1, &if_index, sizeof(if_index)); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/dvmrpctl/dvmrpctl.c b/usr.sbin/dvmrpctl/dvmrpctl.c index fd8f3390d5b..f7fa58e3bf1 100644 --- a/usr.sbin/dvmrpctl/dvmrpctl.c +++ b/usr.sbin/dvmrpctl/dvmrpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpctl.c,v 1.17 2024/11/21 13:08:50 claudio Exp $ */ +/* $OpenBSD: dvmrpctl.c,v 1.18 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -100,7 +100,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -173,12 +173,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/dvmrpd/control.c b/usr.sbin/dvmrpd/control.c index 6adfd68cc6e..618b9af31cd 100644 --- a/usr.sbin/dvmrpd/control.c +++ b/usr.sbin/dvmrpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.27 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.28 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -152,7 +152,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -228,14 +228,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c index 6c2ae720c5e..205d1fe4ffd 100644 --- a/usr.sbin/dvmrpd/dvmrpd.c +++ b/usr.sbin/dvmrpd/dvmrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.c,v 1.29 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: dvmrpd.c,v 1.30 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -234,8 +234,8 @@ main(int argc, char *argv[]) if ((iev_dvmrpe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_dvmrpe->ibuf, pipe_parent2dvmrpe[0]); - imsg_init(&iev_rde->ibuf, pipe_parent2rde[0]); + imsgbuf_init(&iev_dvmrpe->ibuf, pipe_parent2dvmrpe[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); iev_dvmrpe->handler = main_dispatch_dvmrpe; iev_rde->handler = main_dispatch_rde; @@ -317,17 +317,17 @@ main_dispatch_dvmrpe(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -381,17 +381,17 @@ main_dispatch_rde(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c index bab04ab92e7..13ecd1074ac 100644 --- a/usr.sbin/dvmrpd/dvmrpe.c +++ b/usr.sbin/dvmrpd/dvmrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.c,v 1.26 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: dvmrpe.c,v 1.27 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -143,10 +143,10 @@ dvmrpe(struct dvmrpd_conf *xconf, int pipe_parent2dvmrpe[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_rde->ibuf, pipe_dvmrpe2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_dvmrpe2rde[0]); iev_rde->handler = dvmrpe_dispatch_rde; - imsg_init(&iev_main->ibuf, pipe_parent2dvmrpe[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2dvmrpe[1]); iev_main->handler = dvmrpe_dispatch_main; /* setup event handler */ @@ -191,10 +191,10 @@ dvmrpe_shutdown(void) struct iface *iface; /* close pipes */ - imsg_write(&iev_rde->ibuf); + imsgbuf_write(&iev_rde->ibuf); msgbuf_clear(&iev_rde->ibuf.w); close(iev_rde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -241,23 +241,23 @@ dvmrpe_dispatch_main(int fd, short event, void *bula) int shut = 0, link_ok; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) - fatal("dvmrpe_dispatch_main: imsg_read error"); + fatal("dvmrpe_dispatch_main: imsgbuf_read error"); if (n == 0) break; @@ -317,23 +317,23 @@ dvmrpe_dispatch_rde(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) - fatal("dvmrpe_dispatch_rde: imsg_read error"); + fatal("dvmrpe_dispatch_rde: imsgbuf_read error"); if (n == 0) break; diff --git a/usr.sbin/dvmrpd/rde.c b/usr.sbin/dvmrpd/rde.c index 25820487abc..01140177d22 100644 --- a/usr.sbin/dvmrpd/rde.c +++ b/usr.sbin/dvmrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.35 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.36 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -123,10 +123,10 @@ rde(struct dvmrpd_conf *xconf, int pipe_parent2rde[2], int pipe_dvmrpe2rde[2], (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_dvmrpe->ibuf, pipe_dvmrpe2rde[1]); + imsgbuf_init(&iev_dvmrpe->ibuf, pipe_dvmrpe2rde[1]); iev_dvmrpe->handler = rde_dispatch_imsg; - imsg_init(&iev_main->ibuf, pipe_parent2rde[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); iev_main->handler = rde_dispatch_imsg; /* setup event handler */ @@ -206,17 +206,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct iface *iface; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/eigrpctl/eigrpctl.c b/usr.sbin/eigrpctl/eigrpctl.c index 80b6fde9e56..99201698ec0 100644 --- a/usr.sbin/eigrpctl/eigrpctl.c +++ b/usr.sbin/eigrpctl/eigrpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpctl.c,v 1.10 2024/11/21 13:08:51 claudio Exp $ */ +/* $OpenBSD: eigrpctl.c,v 1.11 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -121,7 +121,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -217,12 +217,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/eigrpd/control.c b/usr.sbin/eigrpd/control.c index 4c732a29f22..bc5667064c6 100644 --- a/usr.sbin/eigrpd/control.c +++ b/usr.sbin/eigrpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.12 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.13 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -144,7 +144,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -220,14 +220,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c index c80b704fea2..85d022ea395 100644 --- a/usr.sbin/eigrpd/eigrpd.c +++ b/usr.sbin/eigrpd/eigrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.c,v 1.31 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: eigrpd.c,v 1.32 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -240,9 +240,9 @@ main(int argc, char *argv[]) if ((iev_eigrpe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_eigrpe->ibuf, pipe_parent2eigrpe[0]); + imsgbuf_init(&iev_eigrpe->ibuf, pipe_parent2eigrpe[0]); iev_eigrpe->handler = main_dispatch_eigrpe; - imsg_init(&iev_rde->ibuf, pipe_parent2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); iev_rde->handler = main_dispatch_rde; /* setup event handler */ @@ -373,17 +373,17 @@ main_dispatch_eigrpe(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -451,17 +451,17 @@ main_dispatch_rde(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c index 30f385b6a17..381badd1c56 100644 --- a/usr.sbin/eigrpd/eigrpe.c +++ b/usr.sbin/eigrpd/eigrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpe.c,v 1.43 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: eigrpe.c,v 1.44 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -146,7 +146,7 @@ eigrpe(int debug, int verbose, char *sockname) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = eigrpe_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -173,10 +173,10 @@ static __dead void eigrpe_shutdown(void) { /* close pipes */ - imsg_write(&iev_rde->ibuf); + imsgbuf_write(&iev_rde->ibuf); msgbuf_clear(&iev_rde->ibuf.w); close(iev_rde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -226,17 +226,17 @@ eigrpe_dispatch_main(int fd, short event, void *bula) int n, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -300,7 +300,7 @@ eigrpe_dispatch_main(int fd, short event, void *bula) iev_rde = malloc(sizeof(struct imsgev)); if (iev_rde == NULL) fatal(NULL); - imsg_init(&iev_rde->ibuf, fd); + imsgbuf_init(&iev_rde->ibuf, fd); iev_rde->handler = eigrpe_dispatch_rde; iev_rde->events = EV_READ; event_set(&iev_rde->ev, iev_rde->ibuf.fd, @@ -398,17 +398,17 @@ eigrpe_dispatch_rde(int fd, short event, void *bula) int n, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index 5c8d8c53527..2dfee83a7e8 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.28 2024/11/21 13:16:06 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.29 2024/11/21 13:17:01 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -112,7 +112,7 @@ rde(int debug, int verbose) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = rde_dispatch_parent; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -175,17 +175,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -312,17 +312,17 @@ rde_dispatch_parent(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -367,7 +367,7 @@ rde_dispatch_parent(int fd, short event, void *bula) iev_eigrpe = malloc(sizeof(struct imsgev)); if (iev_eigrpe == NULL) fatal(NULL); - imsg_init(&iev_eigrpe->ibuf, fd); + imsgbuf_init(&iev_eigrpe->ibuf, fd); iev_eigrpe->handler = rde_dispatch_imsg; iev_eigrpe->events = EV_READ; event_set(&iev_eigrpe->ev, iev_eigrpe->ibuf.fd, diff --git a/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c index 5c4ddf7a18b..9ed1af59022 100644 --- a/usr.sbin/httpd/control.c +++ b/usr.sbin/httpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.17 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.18 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -164,7 +164,7 @@ control_accept(int listenfd, short event, void *arg) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; c->iev.data = cs; /* proc.c cheats (reuses the handler) */ @@ -229,15 +229,15 @@ control_dispatch_imsg(int fd, short event, void *arg) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd, cs); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd, cs); return; } diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c index 49fc73e7f63..3e2d4ce0e8c 100644 --- a/usr.sbin/httpd/proc.c +++ b/usr.sbin/httpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.48 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.49 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,7 +155,8 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsg_init(&iev->ibuf, ps->ps_pp->pp_pipes[dst][inst]); + imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -264,7 +265,7 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } @@ -294,7 +295,7 @@ proc_setup(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc) sizeof(struct imsgev))) == NULL) fatal("%s: calloc", __func__); - /* With this set up, we are ready to call imsg_init(). */ + /* With this set up, we are ready to call imsgbuf_init(). */ for (i = 0; i < ps->ps_instances[id]; i++) { ps->ps_ievs[id][i].handler = proc_dispatch; ps->ps_ievs[id][i].events = EV_READ; @@ -427,7 +428,7 @@ proc_open(struct privsep *ps, int src, int dst) */ if (proc_flush_imsg(ps, src, i) == -1 || proc_flush_imsg(ps, dst, j) == -1) - fatal("%s: imsg_flush", __func__); + fatal("%s: imsgbuf_flush", __func__); } } } @@ -453,7 +454,7 @@ proc_close(struct privsep *ps) /* Cancel the fd, close and invalidate the fd */ event_del(&(ps->ps_ievs[dst][n].ev)); - imsg_clear(&(ps->ps_ievs[dst][n].ibuf)); + imsgbuf_clear(&(ps->ps_ievs[dst][n].ibuf)); close(pp->pp_pipes[dst][n]); pp->pp_pipes[dst][n] = -1; } @@ -600,8 +601,8 @@ proc_dispatch(int fd, short event, void *arg) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ event_del(&iev->ev); @@ -611,14 +612,14 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* connection closed */ /* remove the event handler */ event_del(&iev->ev); event_loopexit(NULL); return; } else - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -684,7 +685,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } @@ -818,7 +819,7 @@ proc_flush_imsg(struct privsep *ps, enum privsep_procid id, int n) for (; n < m; n++) { if ((ibuf = proc_ibuf(ps, id, n)) == NULL) return (-1); - if ((ret = imsg_flush(ibuf)) == -1) + if ((ret = imsgbuf_flush(ibuf)) == -1) break; imsg_event_add(&ps->ps_ievs[id][n]); } diff --git a/usr.sbin/ikectl/ikectl.c b/usr.sbin/ikectl/ikectl.c index 785372fc6c6..99fa755ff35 100644 --- a/usr.sbin/ikectl/ikectl.c +++ b/usr.sbin/ikectl/ikectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikectl.c,v 1.32 2024/11/21 13:08:52 claudio Exp $ */ +/* $OpenBSD: ikectl.c,v 1.33 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2007-2013 Reyk Floeter <reyk@openbsd.org> @@ -250,7 +250,7 @@ main(int argc, char *argv[]) else if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, "malloc"); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); /* process user request */ switch (res->action) { @@ -339,12 +339,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ldapctl/ldapctl.c b/usr.sbin/ldapctl/ldapctl.c index 8c2271e3153..a18db60a939 100644 --- a/usr.sbin/ldapctl/ldapctl.c +++ b/usr.sbin/ldapctl/ldapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapctl.c,v 1.17 2024/11/21 13:08:53 claudio Exp $ */ +/* $OpenBSD: ldapctl.c,v 1.18 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -328,7 +328,7 @@ main(int argc, char *argv[]) if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) err(1, "connect: %s", sock); - imsg_init(&ibuf, ctl_sock); + imsgbuf_init(&ibuf, ctl_sock); done = 0; if (pledge("stdio", NULL) == -1) @@ -355,12 +355,12 @@ main(int argc, char *argv[]) fatal("internal error"); } - if (imsg_flush(&ibuf) == -1) + if (imsgbuf_flush(&ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(&ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(&ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ldapd/imsgev.c b/usr.sbin/ldapd/imsgev.c index ed95415036b..7a4805e9933 100644 --- a/usr.sbin/ldapd/imsgev.c +++ b/usr.sbin/ldapd/imsgev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsgev.c,v 1.8 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: imsgev.c,v 1.9 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2009 Eric Faurot <eric@openbsd.org> @@ -37,7 +37,7 @@ imsgev_init(struct imsgev *iev, int fd, void *data, void (*callback)(struct imsgev *, int, struct imsg *), void (*needfd)(struct imsgev *)) { - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); iev->terminate = 0; iev->data = data; @@ -109,11 +109,11 @@ imsgev_dispatch(int fd, short ev, void *humppa) iev->events = 0; if (ev & EV_READ) { - if ((n = imsg_read(ibuf)) == -1) { + if ((n = imsgbuf_read(ibuf)) == -1) { /* if we don't have enough fds, free one up and retry */ if (errno == EAGAIN) { iev->needfd(iev); - n = imsg_read(ibuf); + n = imsgbuf_read(ibuf); } if (n == -1) { @@ -139,7 +139,7 @@ imsgev_dispatch(int fd, short ev, void *humppa) * closed, or some error occured. Both case are not recoverable * from the imsg perspective, so we treat it as a WRITE error. */ - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { imsgev_disconnect(iev, IMSGEV_EWRITE); return; } diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c index 2d17f931ffd..48974cc583a 100644 --- a/usr.sbin/ldpctl/ldpctl.c +++ b/usr.sbin/ldpctl/ldpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpctl.c,v 1.33 2024/11/21 13:08:54 claudio Exp $ +/* $OpenBSD: ldpctl.c,v 1.34 2024/11/21 13:17:02 claudio Exp $ * * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -101,7 +101,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -206,12 +206,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c index 9ad6eb58f55..4a2ce22ae52 100644 --- a/usr.sbin/ldpd/control.c +++ b/usr.sbin/ldpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.34 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.35 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -133,7 +133,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -203,14 +203,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index 97bfc2c3920..2b5940f3455 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.80 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: lde.c,v 1.81 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -128,7 +128,7 @@ lde(int debug, int verbose) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = lde_dispatch_parent; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -198,17 +198,17 @@ lde_dispatch_imsg(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -395,17 +395,17 @@ lde_dispatch_parent(int fd, short event, void *bula) struct fec fec; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -464,7 +464,7 @@ lde_dispatch_parent(int fd, short event, void *bula) if ((iev_ldpe = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ldpe->ibuf, fd); + imsgbuf_init(&iev_ldpe->ibuf, fd); iev_ldpe->handler = lde_dispatch_imsg; iev_ldpe->events = EV_READ; event_set(&iev_ldpe->ev, iev_ldpe->ibuf.fd, diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index f51d4886934..64cbde25732 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.71 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ldpd.c,v 1.72 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -242,9 +242,9 @@ main(int argc, char *argv[]) if ((iev_ldpe = malloc(sizeof(struct imsgev))) == NULL || (iev_lde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]); + imsgbuf_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]); iev_ldpe->handler = main_dispatch_ldpe; - imsg_init(&iev_lde->ibuf, pipe_parent2lde[0]); + imsgbuf_init(&iev_lde->ibuf, pipe_parent2lde[0]); iev_lde->handler = main_dispatch_lde; /* setup event handler */ @@ -379,17 +379,17 @@ main_dispatch_ldpe(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -460,17 +460,17 @@ main_dispatch_lde(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index be154d0bb83..3705b0cef70 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.84 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ldpe.c,v 1.85 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -123,7 +123,7 @@ ldpe(int debug, int verbose, char *sockname) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = ldpe_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -159,10 +159,10 @@ ldpe_shutdown(void) struct adj *adj; /* close pipes */ - imsg_write(&iev_lde->ibuf); + imsgbuf_write(&iev_lde->ibuf); msgbuf_clear(&iev_lde->ibuf.w); close(iev_lde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -231,17 +231,17 @@ ldpe_dispatch_main(int fd, short event, void *bula) int n, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -306,7 +306,7 @@ ldpe_dispatch_main(int fd, short event, void *bula) if ((iev_lde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_lde->ibuf, fd); + imsgbuf_init(&iev_lde->ibuf, fd); iev_lde->handler = ldpe_dispatch_lde; iev_lde->events = EV_READ; event_set(&iev_lde->ev, iev_lde->ibuf.fd, @@ -497,17 +497,17 @@ ldpe_dispatch_lde(int fd, short event, void *bula) struct nbr *nbr = NULL; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/lpd/proc.c b/usr.sbin/lpd/proc.c index 39e8d7be54e..e726ef63107 100644 --- a/usr.sbin/lpd/proc.c +++ b/usr.sbin/lpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.4 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.5 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2017 Eric Faurot <eric@openbsd.org> @@ -203,7 +203,7 @@ proc_free(struct imsgproc *p) if (event_initialized(&p->ev)) event_del(&p->ev); close(p->imsgbuf.fd); - imsg_clear(&p->imsgbuf); + imsgbuf_clear(&p->imsgbuf); free(p->title); free(p); } @@ -220,7 +220,7 @@ proc_new(int type) p->type = type; p->instance = -1; p->pid = -1; - imsg_init(&p->imsgbuf, -1); + imsgbuf_init(&p->imsgbuf, -1); TAILQ_INSERT_TAIL(&procs, p, tqe); @@ -278,12 +278,12 @@ proc_dispatch(int fd, short event, void *arg) p->events = 0; if (event & EV_READ) { - n = imsg_read(&p->imsgbuf); + n = imsgbuf_read(&p->imsgbuf); switch (n) { case -1: if (errno == EAGAIN) break; - log_warn("%s: imsg_read", __func__); + log_warn("%s: imsgbuf_read", __func__); proc_callback(p, NULL); return; case 0: @@ -296,9 +296,9 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(&p->imsgbuf) == -1) { + if (imsgbuf_write(&p->imsgbuf) == -1) { if (errno != EPIPE) - log_warn("%s: imsg_write", __func__); + log_warn("%s: imsgbuf_write", __func__); proc_callback(p, NULL); return; } diff --git a/usr.sbin/npppctl/npppctl.c b/usr.sbin/npppctl/npppctl.c index 5860ddd9168..c7d5ce5a0dc 100644 --- a/usr.sbin/npppctl/npppctl.c +++ b/usr.sbin/npppctl/npppctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppctl.c,v 1.12 2024/11/21 13:08:55 claudio Exp $ */ +/* $OpenBSD: npppctl.c,v 1.13 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2012 Internet Initiative Japan Inc. @@ -108,7 +108,7 @@ main(int argc, char *argv[]) if (connect(ctlsock, (struct sockaddr *)&sun, sizeof(sun)) == -1) err(EXIT_FAILURE, "connect"); - imsg_init(&ctl_ibuf, ctlsock); + imsgbuf_init(&ctl_ibuf, ctlsock); switch (result->action) { case SESSION_BRIEF: @@ -509,14 +509,14 @@ imsg_wait_command_completion(void) { int n; - if (imsg_flush(&ctl_ibuf) == -1) + if (imsgbuf_flush(&ctl_ibuf) == -1) return (-1); do { if ((n = imsg_get(&ctl_ibuf, &ctl_imsg)) == -1) return (-1); if (n != 0) break; - if (((n = imsg_read(&ctl_ibuf)) == -1 && errno != EAGAIN) || + if (((n = imsgbuf_read(&ctl_ibuf)) == -1 && errno != EAGAIN) || n == 0) return (-1); } while (1); diff --git a/usr.sbin/npppd/npppd/control.c b/usr.sbin/npppd/npppd/control.c index 68651fd8b5f..bd375cdbacd 100644 --- a/usr.sbin/npppd/npppd/control.c +++ b/usr.sbin/npppd/npppd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.11 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -187,7 +187,7 @@ control_accept(int listenfd, short event, void *arg) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; c->iev.data = cs; @@ -252,7 +252,7 @@ control_dispatch_imsg(int fd, short event, void *arg) if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd, cs); return; } @@ -263,8 +263,8 @@ control_dispatch_imsg(int fd, short event, void *arg) return; } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd, cs); return; } diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 43ec8a4ce7e..7e7f586a381 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.26 2024/08/22 07:56:47 florian Exp $ */ +/* $OpenBSD: privsep.c,v 1.27 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org> @@ -191,7 +191,7 @@ privsep_init(void) close(pairsock[0]); privsep_sock = pairsock[1]; privsep_pid = pid; - imsg_init(&privsep_ibuf, privsep_sock); + imsgbuf_init(&privsep_ibuf, privsep_sock); return (0); /* NOTREACHED */ @@ -207,7 +207,7 @@ fail: void privsep_fini(void) { - imsg_clear(&privsep_ibuf); + imsgbuf_clear(&privsep_ibuf); if (privsep_sock >= 0) { close(privsep_sock); privsep_sock = -1; @@ -240,7 +240,7 @@ priv_bind(int sock, const struct sockaddr *name, socklen_t namelen) (void)imsg_compose(&privsep_ibuf, PRIVSEP_BIND, 0, 0, sock, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -255,7 +255,7 @@ priv_socket(int domain, int type, int protocol) a.protocol = protocol; (void)imsg_compose(&privsep_ibuf, PRIVSEP_SOCKET, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_recvfd()); } @@ -269,7 +269,7 @@ priv_open(const char *path, int flags) a.flags = flags; (void)imsg_compose(&privsep_ibuf, PRIVSEP_OPEN, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_recvfd()); } @@ -316,7 +316,7 @@ priv_sendto(int s, const void *msg, int len, int flags, (void)imsg_composev(&privsep_ibuf, PRIVSEP_SENDTO, 0, 0, s, iov, nitems(iov)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -335,7 +335,7 @@ priv_unlink(const char *path) strlcpy(a.path, path, sizeof(a.path)); (void)imsg_compose(&privsep_ibuf, PRIVSEP_UNLINK, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -357,7 +357,7 @@ priv_get_user_info(const char *path, const char *username, (void)imsg_compose(&privsep_ibuf, PRIVSEP_GET_USER_INFO, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); if ((n = imsg_read_and_get(&privsep_ibuf, &imsg)) == -1) return (-1); @@ -416,7 +416,7 @@ priv_get_if_addr(const char *ifname, struct in_addr *addr) (void)imsg_compose(&privsep_ibuf, PRIVSEP_GET_IF_ADDR, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); if (imsg_read_and_get(&privsep_ibuf, &imsg) == -1) return (-1); @@ -444,7 +444,7 @@ priv_delete_if_addr(const char *ifname) strlcpy(a.ifname, ifname, sizeof(a.ifname)); (void)imsg_compose(&privsep_ibuf, PRIVSEP_DEL_IF_ADDR, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -458,7 +458,7 @@ priv_set_if_addr(const char *ifname, struct in_addr *addr) a.addr = *addr; (void)imsg_compose(&privsep_ibuf, PRIVSEP_SET_IF_ADDR, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -476,7 +476,7 @@ priv_get_if_flags(const char *ifname, int *pflags) (void)imsg_compose(&privsep_ibuf, PRIVSEP_GET_IF_FLAGS, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); if (imsg_read_and_get(&privsep_ibuf, &imsg) == -1) return (-1); @@ -504,7 +504,7 @@ priv_set_if_flags(const char *ifname, int flags) (void)imsg_compose(&privsep_ibuf, PRIVSEP_SET_IF_FLAGS, 0, 0, -1, &a, sizeof(a)); - imsg_flush(&privsep_ibuf); + imsgbuf_flush(&privsep_ibuf); return (privsep_common_resp()); } @@ -565,9 +565,9 @@ privsep_priv_main(int sock) { struct imsgbuf ibuf; - imsg_init(&ibuf, sock); + imsgbuf_init(&ibuf, sock); privsep_priv_dispatch_imsg(&ibuf); - imsg_clear(&ibuf); + imsgbuf_clear(&ibuf); close(sock); exit(EXIT_SUCCESS); @@ -601,7 +601,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, f, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_SOCKET: { @@ -622,7 +622,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, s, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_UNLINK: { @@ -640,7 +640,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_BIND: { @@ -662,7 +662,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_GET_USER_INFO: { @@ -739,7 +739,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_SENDTO: { @@ -771,7 +771,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_GET_IF_ADDR: { @@ -804,7 +804,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_SET_IF_ADDR: { @@ -850,7 +850,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_DEL_IF_ADDR: { @@ -878,7 +878,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_GET_IF_FLAGS: { @@ -911,7 +911,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; case PRIVSEP_SET_IF_FLAGS: { @@ -940,7 +940,7 @@ on_broken_entry: } (void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1, &r, sizeof(r)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); } break; } @@ -954,7 +954,7 @@ imsg_read_and_get(struct imsgbuf *ibuf, struct imsg *imsg) ssize_t n; for (;;) { - if ((n = imsg_read(ibuf)) <= 0) { + if ((n = imsgbuf_read(ibuf)) <= 0) { if (n == -1 && (errno == EAGAIN || errno == EINTR)) continue; return (-1); diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c index 8f916067e43..4241b70cc83 100644 --- a/usr.sbin/ntpd/constraint.c +++ b/usr.sbin/ntpd/constraint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: constraint.c,v 1.56 2023/12/20 15:36:36 otto Exp $ */ +/* $OpenBSD: constraint.c,v 1.57 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -235,7 +235,6 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc, struct ntp_addr *h; struct constraint *cstr; int pipes[2]; - int rv; if ((cstr = constraint_byid(id)) != NULL) { log_warnx("IMSG_CONSTRAINT_QUERY repeated for id %d", id); @@ -271,15 +270,12 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc, /* Prepare and send constraint data to child. */ cstr->fd = pipes[0]; - imsg_init(&cstr->ibuf, cstr->fd); + imsgbuf_init(&cstr->ibuf, cstr->fd); if (imsg_compose(&cstr->ibuf, IMSG_CONSTRAINT_QUERY, id, 0, -1, data, len) == -1) fatal("%s: imsg_compose", __func__); - do { - rv = imsg_flush(&cstr->ibuf); - } while (rv == -1 && errno == EAGAIN); - if (rv == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&cstr->ibuf) == -1) + fatal("imsgbuf_flush"); /* * Fork child handlers and make sure to do any sensitive work in the @@ -300,8 +296,9 @@ priv_constraint_readquery(struct constraint *cstr, struct ntp_addr_msg *am, size_t mlen; /* Read the message our parent left us. */ - if (((n = imsg_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || n == 0) - fatal("%s: imsg_read", __func__); + if (((n = imsgbuf_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || + n == 0) + fatal("%s: imsgbuf_read", __func__); if (((n = imsg_get(&cstr->ibuf, &imsg)) == -1) || n == 0) fatal("%s: imsg_get", __func__); if (imsg.hdr.type != IMSG_CONSTRAINT_QUERY) @@ -347,7 +344,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) struct sigaction sa; void *ctx; struct iovec iov[2]; - int i, rv; + int i; log_procinit("constraint"); @@ -381,7 +378,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) fatal("pledge"); cstr.fd = CONSTRAINT_PASSFD; - imsg_init(&cstr.ibuf, cstr.fd); + imsgbuf_init(&cstr.ibuf, cstr.fd); priv_constraint_readquery(&cstr, &am, &data); /* @@ -436,9 +433,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) iov[1].iov_len = sizeof(xmttv); imsg_composev(&cstr.ibuf, IMSG_CONSTRAINT_RESULT, 0, 0, -1, iov, 2); - do { - rv = imsg_flush(&cstr.ibuf); - } while (rv == -1 && errno == EAGAIN); + imsgbuf_flush(&cstr.ibuf); /* Tear down the TLS connection after sending the result */ httpsdate_free(ctx); @@ -618,7 +613,8 @@ priv_constraint_dispatch(struct pollfd *pfd) if (!(pfd->revents & POLLIN)) return (0); - if (((n = imsg_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || n == 0) { + if (((n = imsgbuf_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || + n == 0) { /* there's a race between SIGCHLD delivery and reading imsg but if we've seen the reply, we're good */ priv_constraint_close(pfd->fd, cstr->state != diff --git a/usr.sbin/ntpd/control.c b/usr.sbin/ntpd/control.c index 634ab902d29..3ecb251c5a0 100644 --- a/usr.sbin/ntpd/control.c +++ b/usr.sbin/ntpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.23 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.24 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -149,7 +149,7 @@ control_accept(int listenfd) return (0); } - imsg_init(&ctl_conn->ibuf, connfd); + imsgbuf_init(&ctl_conn->ibuf, connfd); TAILQ_INSERT_TAIL(&ctl_conns, ctl_conn, entry); @@ -207,7 +207,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) } if (pfd->revents & POLLOUT) - if (imsg_write(&c->ibuf) == -1) { + if (imsgbuf_write(&c->ibuf) == -1) { *ctl_cnt -= control_close(pfd->fd); return (1); } @@ -215,7 +215,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) if (!(pfd->revents & POLLIN)) return (0); - if (((n = imsg_read(&c->ibuf)) == -1 && errno != EAGAIN) || n == 0) { + if (((n = imsgbuf_read(&c->ibuf)) == -1 && errno != EAGAIN) || n == 0) { *ctl_cnt -= control_close(pfd->fd); return (1); } diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index cfbb7543d57..078f5876311 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.176 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ntp.c,v 1.177 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -159,10 +159,10 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_main, PARENT_SOCK_FILENO); + imsgbuf_init(ibuf_main, PARENT_SOCK_FILENO); if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_dns, pipe_dns[0]); + imsgbuf_init(ibuf_dns, pipe_dns[0]); constraint_cnt = 0; conf->constraint_median = 0; @@ -365,7 +365,7 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv) } if (nfds > 0 && (pfd[PFD_PIPE_MAIN].revents & POLLOUT)) - if (imsg_write(ibuf_main) == -1) { + if (imsgbuf_write(ibuf_main) == -1) { log_warn("pipe write error (to parent)"); ntp_quit = 1; } @@ -379,7 +379,7 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv) } if (nfds > 0 && (pfd[PFD_PIPE_DNS].revents & POLLOUT)) - if (imsg_write(ibuf_dns) == -1) { + if (imsgbuf_write(ibuf_dns) == -1) { log_warn("pipe write error (to dns engine)"); ntp_quit = 1; } @@ -460,10 +460,10 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv) } } - imsg_write(ibuf_main); + imsgbuf_write(ibuf_main); msgbuf_clear(&ibuf_main->w); free(ibuf_main); - imsg_write(ibuf_dns); + imsgbuf_write(ibuf_dns); msgbuf_clear(&ibuf_dns->w); free(ibuf_dns); @@ -477,7 +477,7 @@ ntp_dispatch_imsg(void) struct imsg imsg; int n; - if (((n = imsg_read(ibuf_main)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(ibuf_main)) == -1 && errno != EAGAIN) || n == 0) return (-1); for (;;) { @@ -551,7 +551,7 @@ ntp_dispatch_imsg_dns(void) size_t addrcount, peercount; int n; - if (((n = imsg_read(ibuf_dns)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(ibuf_dns)) == -1 && errno != EAGAIN) || n == 0) return (-1); for (;;) { diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c index 3f9813b644e..0e56a0fa5b1 100644 --- a/usr.sbin/ntpd/ntp_dns.c +++ b/usr.sbin/ntpd/ntp_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp_dns.c,v 1.31 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ntp_dns.c,v 1.32 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> @@ -94,7 +94,7 @@ ntp_dns(struct ntpd_conf *nconf, struct passwd *pw) if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf_dns, PARENT_SOCK_FILENO); + imsgbuf_init(ibuf_dns, PARENT_SOCK_FILENO); if (pledge("stdio dns", NULL) == -1) err(1, "pledge"); @@ -117,7 +117,7 @@ ntp_dns(struct ntpd_conf *nconf, struct passwd *pw) } if (nfds > 0 && (pfd[0].revents & POLLOUT)) - if (imsg_write(ibuf_dns) == -1) { + if (imsgbuf_write(ibuf_dns) == -1) { log_warn("pipe write error (to ntp engine)"); quit_dns = 1; } @@ -145,7 +145,7 @@ dns_dispatch_imsg(struct ntpd_conf *nconf) const char *str; size_t len; - if (((n = imsg_read(ibuf_dns)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(ibuf_dns)) == -1 && errno != EAGAIN) || n == 0) return (-1); for (;;) { diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index 33a7fe049b3..103fff3331b 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.136 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ntpd.c,v 1.137 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -274,7 +274,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsg_init(ibuf, pipe_chld[0]); + imsgbuf_init(ibuf, pipe_chld[0]); constraint_cnt = 0; @@ -333,7 +333,7 @@ main(int argc, char *argv[]) } if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT)) - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { log_warn("pipe write error (to child)"); quit = 1; } @@ -393,7 +393,7 @@ dispatch_imsg(struct ntpd_conf *lconf, int argc, char **argv) int n; double d; - if (((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) || n == 0) return (-1); for (;;) { @@ -670,7 +670,7 @@ ctl_main(int argc, char *argv[]) if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf_ctl, fd); + imsgbuf_init(ibuf_ctl, fd); switch (action) { case CTL_SHOW_STATUS: @@ -694,13 +694,13 @@ ctl_main(int argc, char *argv[]) break; /* NOTREACHED */ } - if (imsg_flush(ibuf_ctl) == -1) - err(1, "ibuf_ctl: imsg_flush error"); + if (imsgbuf_flush(ibuf_ctl) == -1) + err(1, "ibuf_ctl: imsgbuf_flush error"); done = 0; while (!done) { - if ((n = imsg_read(ibuf_ctl)) == -1 && errno != EAGAIN) - err(1, "ibuf_ctl: imsg_read error"); + if ((n = imsgbuf_read(ibuf_ctl)) == -1 && errno != EAGAIN) + err(1, "ibuf_ctl: imsgbuf_read error"); if (n == 0) errx(1, "ntpctl: pipe closed"); diff --git a/usr.sbin/ospf6ctl/ospf6ctl.c b/usr.sbin/ospf6ctl/ospf6ctl.c index 36bd6767076..ea7cd609f1c 100644 --- a/usr.sbin/ospf6ctl/ospf6ctl.c +++ b/usr.sbin/ospf6ctl/ospf6ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6ctl.c,v 1.55 2024/11/21 13:08:57 claudio Exp $ */ +/* $OpenBSD: ospf6ctl.c,v 1.56 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -132,7 +132,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -250,12 +250,12 @@ main(int argc, char *argv[]) #endif } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c index 49810f2bffc..2df6321ff0e 100644 --- a/usr.sbin/ospf6d/control.c +++ b/usr.sbin/ospf6d/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.34 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.35 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -176,7 +176,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -252,14 +252,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c index 5dbe20abf80..76e4830472c 100644 --- a/usr.sbin/ospf6d/ospf6d.c +++ b/usr.sbin/ospf6d/ospf6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.c,v 1.56 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ospf6d.c,v 1.57 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -254,9 +254,9 @@ main(int argc, char *argv[]) if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); + imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); iev_ospfe->handler = main_dispatch_ospfe; - imsg_init(&iev_rde->ibuf, pipe_parent2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); iev_rde->handler = main_dispatch_rde; /* setup event handler */ @@ -340,17 +340,17 @@ main_dispatch_ospfe(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -418,17 +418,17 @@ main_dispatch_rde(int fd, short event, void *bula) int count, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c index 2c1f92a06c4..4700131d80b 100644 --- a/usr.sbin/ospf6d/ospfe.c +++ b/usr.sbin/ospf6d/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.74 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.75 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -155,9 +155,9 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); iev_rde->handler = ospfe_dispatch_rde; - imsg_init(&iev_main->ibuf, pipe_parent2ospfe[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]); iev_main->handler = ospfe_dispatch_main; /* setup event handler */ @@ -199,10 +199,10 @@ ospfe_shutdown(void) struct iface *iface; /* close pipes */ - imsg_write(&iev_rde->ibuf); + imsgbuf_write(&iev_rde->ibuf); msgbuf_clear(&iev_rde->ibuf.w); close(iev_rde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -258,17 +258,17 @@ ospfe_dispatch_main(int fd, short event, void *bula) int n, stub_changed, shut = 0, isvalid, wasvalid; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -451,17 +451,17 @@ ospfe_dispatch_rde(int fd, short event, void *bula) u_int16_t l, age; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index badb021e1a3..bbdf77df3fa 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.93 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.94 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -179,9 +179,9 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2], if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); + imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); iev_ospfe->handler = rde_dispatch_imsg; - imsg_init(&iev_main->ibuf, pipe_parent2rde[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); iev_main->handler = rde_dispatch_parent; /* setup event handler */ @@ -276,17 +276,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) u_int16_t l; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -652,17 +652,17 @@ rde_dispatch_parent(int fd, short event, void *bula) int shut = 0, link_ok, prev_link_ok, orig_lsa; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index 8d947e0313a..d30683de03e 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.69 2024/11/21 13:08:58 claudio Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.70 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -106,7 +106,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -213,7 +213,7 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); /* no output for certain commands such as log verbose */ @@ -221,8 +221,8 @@ main(int argc, char *argv[]) output->head(res); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index 75f639fca4c..d325c17b452 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.50 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.51 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -176,7 +176,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -252,14 +252,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index e2d9567f1eb..84489f26132 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.119 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ospfd.c,v 1.120 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -260,9 +260,9 @@ main(int argc, char *argv[]) if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); + imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); iev_ospfe->handler = main_dispatch_ospfe; - imsg_init(&iev_rde->ibuf, pipe_parent2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); iev_rde->handler = main_dispatch_rde; /* setup event handler */ @@ -358,17 +358,17 @@ main_dispatch_ospfe(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -446,17 +446,17 @@ main_dispatch_rde(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index 6ee806c4000..68ad5c02d9b 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.116 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.117 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -155,9 +155,9 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); iev_rde->handler = ospfe_dispatch_rde; - imsg_init(&iev_main->ibuf, pipe_parent2ospfe[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]); iev_main->handler = ospfe_dispatch_main; /* setup event handler */ @@ -210,10 +210,10 @@ ospfe_shutdown(void) struct iface *iface; /* close pipes */ - imsg_write(&iev_rde->ibuf); + imsgbuf_write(&iev_rde->ibuf); msgbuf_clear(&iev_rde->ibuf.w); close(iev_rde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -272,17 +272,17 @@ ospfe_dispatch_main(int fd, short event, void *bula) int n, link_ok, stub_changed, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -496,17 +496,17 @@ ospfe_dispatch_rde(int fd, short event, void *bula) u_int16_t l, age; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index dc995cbd730..5ec05f2d079 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.114 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.115 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -161,9 +161,9 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2], if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); + imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); iev_ospfe->handler = rde_dispatch_imsg; - imsg_init(&iev_main->ibuf, pipe_parent2rde[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); iev_main->handler = rde_dispatch_parent; /* setup event handler */ @@ -266,17 +266,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -651,17 +651,17 @@ rde_dispatch_parent(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ractl/ractl.c b/usr.sbin/ractl/ractl.c index 146d44408be..588f265958f 100644 --- a/usr.sbin/ractl/ractl.c +++ b/usr.sbin/ractl/ractl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ractl.c,v 1.4 2024/11/21 13:08:59 claudio Exp $ */ +/* $OpenBSD: ractl.c,v 1.5 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -100,7 +100,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* Process user request. */ @@ -123,12 +123,12 @@ main(int argc, char *argv[]) usage(); } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/rad/control.c b/usr.sbin/rad/control.c index cfa7f1433c2..fa84bdd0aef 100644 --- a/usr.sbin/rad/control.c +++ b/usr.sbin/rad/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.11 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -155,7 +155,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -230,14 +230,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/rad/engine.c b/usr.sbin/rad/engine.c index f2549e78b1d..b8af4004541 100644 --- a/usr.sbin/rad/engine.c +++ b/usr.sbin/rad/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.24 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: engine.c,v 1.25 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -134,7 +134,7 @@ engine(int debug, int verbose) if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = engine_dispatch_main; /* Setup event handlers. */ @@ -194,17 +194,17 @@ engine_dispatch_frontend(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -278,17 +278,17 @@ engine_dispatch_main(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -316,7 +316,7 @@ engine_dispatch_main(int fd, short event, void *bula) if (iev_frontend == NULL) fatal(NULL); - imsg_init(&iev_frontend->ibuf, fd); + imsgbuf_init(&iev_frontend->ibuf, fd); iev_frontend->handler = engine_dispatch_frontend; iev_frontend->events = EV_READ; diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c index 8384b8d09b2..3536cf8baa0 100644 --- a/usr.sbin/rad/frontend.c +++ b/usr.sbin/rad/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.51 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: frontend.c,v 1.52 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -240,7 +240,7 @@ frontend(int debug, int verbose) /* Setup pipe and event handler to the parent process. */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsgbuf_init(&iev_main->ibuf, 3); iev_main->handler = frontend_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -273,10 +273,10 @@ __dead void frontend_shutdown(void) { /* Close pipes. */ - imsg_write(&iev_engine->ibuf); + imsgbuf_write(&iev_engine->ibuf); msgbuf_clear(&iev_engine->ibuf.w); close(iev_engine->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -319,17 +319,17 @@ frontend_dispatch_main(int fd, short event, void *bula) int n, shut = 0, icmp6sock, rdomain; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -357,7 +357,7 @@ frontend_dispatch_main(int fd, short event, void *bula) if (iev_engine == NULL) fatal(NULL); - imsg_init(&iev_engine->ibuf, fd); + imsgbuf_init(&iev_engine->ibuf, fd); iev_engine->handler = frontend_dispatch_engine; iev_engine->events = EV_READ; @@ -534,17 +534,17 @@ frontend_dispatch_engine(int fd, short event, void *bula) int n, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c index b5f5bdc7d18..b4d39b08896 100644 --- a/usr.sbin/rad/rad.c +++ b/usr.sbin/rad/rad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rad.c,v 1.33 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: rad.c,v 1.34 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -240,9 +240,9 @@ main(int argc, char *argv[]) if ((iev_frontend = malloc(sizeof(struct imsgev))) == NULL || (iev_engine = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_frontend->ibuf, pipe_main2frontend[0]); + imsgbuf_init(&iev_frontend->ibuf, pipe_main2frontend[0]); iev_frontend->handler = main_dispatch_frontend; - imsg_init(&iev_engine->ibuf, pipe_main2engine[0]); + imsgbuf_init(&iev_engine->ibuf, pipe_main2engine[0]); iev_engine->handler = main_dispatch_engine; /* Setup event handlers for pipes to engine & frontend. */ @@ -381,17 +381,17 @@ main_dispatch_frontend(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -451,17 +451,17 @@ main_dispatch_engine(int fd, short event, void *bula) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* Connection closed. */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/radiusctl/radiusctl.c b/usr.sbin/radiusctl/radiusctl.c index 8285db51f22..a1a3c5471c3 100644 --- a/usr.sbin/radiusctl/radiusctl.c +++ b/usr.sbin/radiusctl/radiusctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusctl.c,v 1.14 2024/11/21 13:09:00 claudio Exp $ */ +/* $OpenBSD: radiusctl.c,v 1.15 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> * @@ -147,7 +147,7 @@ main(int argc, char *argv[]) err(EX_OSERR, "socket"); if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) err(EX_OSERR, "connect"); - imsg_init(&ibuf, sock); + imsgbuf_init(&ibuf, sock); res = parse(argc, argv); if (res == NULL) @@ -185,10 +185,11 @@ main(int argc, char *argv[]) : IMSG_RADIUSD_MODULE_IPCP_DISCONNECT, 0, 0, -1, iov, niov); break; } - if (imsg_flush(&ibuf) == -1) - err(1, "ibuf_ctl: imsg_flush error"); + if (imsgbuf_flush(&ibuf) == -1) + err(1, "ibuf_ctl: imsgbuf_flush error"); while (!done) { - if (((n = imsg_read(&ibuf)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(&ibuf)) == -1 && errno != EAGAIN) || + n == 0) break; for (;;) { if ((n = imsg_get(&ibuf, &imsg)) <= 0) { diff --git a/usr.sbin/radiusd/control.c b/usr.sbin/radiusd/control.c index 422c5a21508..ead8f494baa 100644 --- a/usr.sbin/radiusd/control.c +++ b/usr.sbin/radiusd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.3 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.4 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -168,7 +168,7 @@ control_accept(int listenfd, short event, void *bula) if (idseq == 0) /* don't use zero. See radiusd_module_imsg */ ++idseq; c->id = idseq++; - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, c->iev.handler, c); @@ -252,14 +252,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/radiusd/imsg_subr.c b/usr.sbin/radiusd/imsg_subr.c index 2ed467dad52..c04ecbbe4d7 100644 --- a/usr.sbin/radiusd/imsg_subr.c +++ b/usr.sbin/radiusd/imsg_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg_subr.c,v 1.1 2015/07/21 04:06:04 yasuoka Exp $ */ +/* $OpenBSD: imsg_subr.c,v 1.2 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -29,8 +29,8 @@ #include "imsg_subr.h" /* - * Check readability not to spin before calling imsg_read(3). Wait 'millisec' - * until it becomes readable. + * Check readability not to spin before calling imsgbuf_read(3). + * Wait 'millisec' until it becomes readable. */ int imsg_sync_read(struct imsgbuf *ibuf, int millisec) @@ -46,14 +46,14 @@ imsg_sync_read(struct imsgbuf *ibuf, int millisec) return (-1); } if (retval > 0 && (fds[0].revents & POLLIN) != 0) - return imsg_read(ibuf); + return imsgbuf_read(ibuf); return (-1); } /* - * Check writability not to spin before calling imsg_flush(3). Wait 'millisec' - * until it becomes writable. + * Check writability not to spin before calling imsgbuf_flush(3). + * Wait 'millisec' until it becomes writable. */ int imsg_sync_flush(struct imsgbuf *ibuf, int millisec) @@ -72,7 +72,7 @@ imsg_sync_flush(struct imsgbuf *ibuf, int millisec) return (-1); } if (retval > 0 && (fds[0].revents & POLLOUT) != 0) - return imsg_flush(ibuf); + return imsgbuf_flush(ibuf); return (-1); } diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index db8795d890b..98e7033777f 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.57 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: radiusd.c,v 1.58 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013, 2023 Internet Initiative Japan Inc. @@ -1200,7 +1200,7 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) } strlcpy(module->name, name, sizeof(module->name)); module->pid = pid; - imsg_init(&module->ibuf, module->fd); + imsgbuf_init(&module->ibuf, module->fd); if (imsg_sync_read(&module->ibuf, MODULE_IO_TIMEOUT) <= 0 || (n = imsg_get(&module->ibuf, &imsg)) <= 0) { @@ -1301,7 +1301,7 @@ radiusd_module_close(struct radiusd_module *module) { if (module->fd >= 0) { event_del(&module->ev); - imsg_clear(&module->ibuf); + imsgbuf_clear(&module->ibuf); close(module->fd); module->fd = -1; } @@ -1322,9 +1322,9 @@ radiusd_module_on_imsg_io(int fd, short evmask, void *ctx) if (evmask & EV_WRITE) { module->writeready = true; - if (imsg_write(&module->ibuf) == -1) { - log_warn("Failed to write to module `%s': imsg_write()", - module->name); + if (imsgbuf_write(&module->ibuf) == -1) { + log_warn("Failed to write to module `%s': " + "imsgbuf_write()", module->name); goto on_error; } module->writeready = false; @@ -1381,12 +1381,12 @@ radiusd_module_imsg_read(struct radiusd_module *module) int n; struct imsg imsg; - if ((n = imsg_read(&module->ibuf)) == -1 || n == 0) { + if ((n = imsgbuf_read(&module->ibuf)) == -1 || n == 0) { if (n == -1 && errno == EAGAIN) return (0); if (n == -1) log_warn("Receiving a message from module `%s' " - "failed: imsg_read", module->name); + "failed: imsgbuf_read", module->name); /* else closed */ radiusd_module_close(module); return (-1); diff --git a/usr.sbin/radiusd/radiusd_bsdauth.c b/usr.sbin/radiusd/radiusd_bsdauth.c index 9f37ffa74dd..55bf47a9681 100644 --- a/usr.sbin/radiusd/radiusd_bsdauth.c +++ b/usr.sbin/radiusd/radiusd_bsdauth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_bsdauth.c,v 1.16 2024/02/09 07:41:32 yasuoka Exp $ */ +/* $OpenBSD: radiusd_bsdauth.c,v 1.17 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -113,13 +113,13 @@ main(int argc, char *argv[]) * Privileged process */ setproctitle("[priv]"); - imsg_init(&ibuf, pairsock[0]); + imsgbuf_init(&ibuf, pairsock[0]); if (pledge("stdio getpw rpath proc exec", NULL) == -1) err(EXIT_FAILURE, "pledge"); for (;;) { - if ((n = imsg_read(&ibuf)) <= 0 && errno != EAGAIN) + if ((n = imsgbuf_read(&ibuf)) <= 0 && errno != EAGAIN) break; for (;;) { if ((n = imsg_get(&ibuf, &imsg)) == -1) @@ -218,11 +218,11 @@ invalid: } } imsg_free(&imsg); - imsg_flush(&ibuf); + imsgbuf_flush(&ibuf); } - imsg_flush(&ibuf); + imsgbuf_flush(&ibuf); } - imsg_clear(&ibuf); + imsgbuf_clear(&ibuf); while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR) @@ -250,7 +250,7 @@ module_bsdauth_main(void) module_drop_privilege(module_bsdauth.base, 0); module_load(module_bsdauth.base); - imsg_init(&module_bsdauth.ibuf, 3); + imsgbuf_init(&module_bsdauth.ibuf, 3); if (pledge("stdio proc", NULL) == -1) err(EXIT_FAILURE, "pledge"); @@ -259,7 +259,7 @@ module_bsdauth_main(void) ; module_destroy(module_bsdauth.base); - imsg_clear(&module_bsdauth.ibuf); + imsgbuf_clear(&module_bsdauth.ibuf); if (module_bsdauth.okgroups) { for (i = 0; module_bsdauth.okgroups[i] != NULL; i++) @@ -346,9 +346,9 @@ module_bsdauth_userpass(void *ctx, u_int q_id, const char *user, iov[2].iov_len = usercheck.passlen; imsg_composev(&module->ibuf, IMSG_BSDAUTH_USERCHECK, 0, 0, -1, iov, 3); - imsg_flush(&module->ibuf); - if ((n = imsg_read(&module->ibuf)) == -1 || n == 0) - fatal("imsg_read() failed in module_bsdauth_userpass()"); + imsgbuf_flush(&module->ibuf); + if ((n = imsgbuf_read(&module->ibuf)) == -1 || n == 0) + fatal("imsgbuf_read() failed in module_bsdauth_userpass()"); if ((n = imsg_get(&module->ibuf, &imsg)) <= 0) fatal("imsg_get() failed in module_bsdauth_userpass()"); @@ -371,9 +371,9 @@ module_bsdauth_userpass(void *ctx, u_int q_id, const char *user, iov[2].iov_len = groupcheck.grouplen; imsg_composev(&module->ibuf, IMSG_BSDAUTH_GROUPCHECK, 0, 0, -1, iov, 3); - imsg_flush(&module->ibuf); - if ((n = imsg_read(&module->ibuf)) == -1 || n == 0) - fatal("imsg_read() failed in " + imsgbuf_flush(&module->ibuf); + if ((n = imsgbuf_read(&module->ibuf)) == -1 || n == 0) + fatal("imsgbuf_read() failed in " "module_bsdauth_userpass()"); if ((n = imsg_get(&module->ibuf, &imsg)) <= 0) fatal("imsg_get() failed in " diff --git a/usr.sbin/radiusd/radiusd_file.c b/usr.sbin/radiusd/radiusd_file.c index 550638b53bd..895c3ed767e 100644 --- a/usr.sbin/radiusd/radiusd_file.c +++ b/usr.sbin/radiusd/radiusd_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_file.c,v 1.5 2024/07/18 22:40:09 yasuoka Exp $ */ +/* $OpenBSD: radiusd_file.c,v 1.6 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2024 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -128,7 +128,7 @@ main(int argc, char *argv[]) if (pledge("stdio rpath unveil", NULL) == -1) err(EXIT_FAILURE, "pledge"); setproctitle("[priv]"); - imsg_init(&ibuf, pairsock[0]); + imsgbuf_init(&ibuf, pairsock[0]); /* Receive parameters from the main process. */ if (imsg_sync_read(&ibuf, 2000) <= 0 || @@ -158,7 +158,7 @@ main(int argc, char *argv[]) memcpy(¶ms, paramsp, sizeof(params)); for (;;) { - if ((n = imsg_read(&ibuf)) <= 0 && errno != EAGAIN) + if ((n = imsgbuf_read(&ibuf)) <= 0 && errno != EAGAIN) break; for (;;) { if ((n = imsg_get(&ibuf, &imsg)) == -1) @@ -167,11 +167,11 @@ main(int argc, char *argv[]) break; parent_dispatch_main(¶ms, &ibuf, &imsg); imsg_free(&imsg); - imsg_flush(&ibuf); + imsgbuf_flush(&ibuf); } - imsg_flush(&ibuf); + imsgbuf_flush(&ibuf); } - imsg_clear(&ibuf); + imsgbuf_clear(&ibuf); while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR) @@ -244,7 +244,7 @@ module_file_main(void) module_drop_privilege(module_file.base, 0); module_load(module_file.base); - imsg_init(&module_file.ibuf, 3); + imsgbuf_init(&module_file.ibuf, 3); if (pledge("stdio", NULL) == -1) err(EXIT_FAILURE, "pledge"); @@ -331,7 +331,7 @@ module_file_start(void *ctx) } imsg_compose(&module->ibuf, IMSG_RADIUSD_FILE_PARAMS, 0, -1, -1, &module->params, sizeof(module->params)); - imsg_flush(&module->ibuf); + imsgbuf_flush(&module->ibuf); module_send_message(module->base, IMSG_OK, NULL); } @@ -359,9 +359,9 @@ module_file_access_request(void *ctx, u_int query_id, const u_char *pkt, imsg_compose(&self->ibuf, IMSG_RADIUSD_FILE_USERINFO, 0, -1, -1, username, strlen(username) + 1); - imsg_flush(&self->ibuf); - if ((n = imsg_read(&self->ibuf)) == -1 || n == 0) { - log_warn("%s: imsg_read()", __func__); + imsgbuf_flush(&self->ibuf); + if ((n = imsgbuf_read(&self->ibuf)) == -1 || n == 0) { + log_warn("%s: imsgbuf_read()", __func__); goto out; } if ((n = imsg_get(&self->ibuf, &imsg)) <= 0) { diff --git a/usr.sbin/radiusd/radiusd_module.c b/usr.sbin/radiusd/radiusd_module.c index b64d6b3e865..063f1b024df 100644 --- a/usr.sbin/radiusd/radiusd_module.c +++ b/usr.sbin/radiusd/radiusd_module.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_module.c,v 1.22 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: radiusd_module.c,v 1.23 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -95,7 +95,7 @@ module_create(int sock, void *ctx, struct module_handlers *handler) if ((base = calloc(1, sizeof(struct module_base))) == NULL) return (NULL); - imsg_init(&base->ibuf, sock); + imsgbuf_init(&base->ibuf, sock); base->ctx = ctx; module_userpass = handler->userpass; @@ -134,7 +134,7 @@ module_run(struct module_base *base) ret = module_recv_imsg(base); if (ret == 0) - imsg_flush(&base->ibuf); + imsgbuf_flush(&base->ibuf); return (ret); } @@ -145,7 +145,7 @@ module_destroy(struct module_base *base) if (base != NULL) { free(base->radpkt); free(base->radpkt2); - imsg_clear(&base->ibuf); + imsgbuf_clear(&base->ibuf); } free(base); } @@ -172,7 +172,7 @@ module_load(struct module_base *base) load.cap |= RADIUSD_MODULE_CAP_CONTROL; imsg_compose(&base->ibuf, IMSG_RADIUSD_MODULE_LOAD, 0, 0, -1, &load, sizeof(load)); - imsg_flush(&base->ibuf); + imsgbuf_flush(&base->ibuf); } void @@ -356,9 +356,10 @@ module_recv_imsg(struct module_base *base) ssize_t n; struct imsg imsg; - if (((n = imsg_read(&base->ibuf)) == -1 && errno != EAGAIN) || n == 0) { + if (((n = imsgbuf_read(&base->ibuf)) == -1 && errno != EAGAIN) || + n == 0) { if (n != 0) - syslog(LOG_ERR, "%s: imsg_read(): %m", __func__); + syslog(LOG_ERR, "%s: imsgbuf_read(): %m", __func__); module_stop(base); return (-1); } @@ -633,8 +634,8 @@ module_on_event(int fd, short evmask, void *ctx) base->ev_onhandler = true; if (evmask & EV_WRITE) { base->writeready = true; - if (imsg_write(&base->ibuf) == -1) { - syslog(LOG_ERR, "%s: imsg_write: %m", __func__); + if (imsgbuf_write(&base->ibuf) == -1) { + syslog(LOG_ERR, "%s: imsgbuf_write: %m", __func__); module_stop(base); return; } diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 69bc5595305..e751407e7ec 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.59 2024/11/21 13:09:01 claudio Exp $ */ +/* $OpenBSD: relayctl.c,v 1.60 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org> @@ -148,7 +148,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -221,12 +221,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/relayd/ca.c b/usr.sbin/relayd/ca.c index ea57b93e31e..864ee775fd5 100644 --- a/usr.sbin/relayd/ca.c +++ b/usr.sbin/relayd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.43 2023/07/16 09:23:33 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.44 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -337,8 +337,8 @@ rsae_send_imsg(int flen, const u_char *from, u_char *to, RSA *rsa, */ if (imsg_composev(ibuf, cmd, 0, 0, -1, iov, cnt) == -1) log_warn("%s: imsg_composev", __func__); - if (imsg_flush(ibuf) == -1) - log_warn("%s: imsg_flush", __func__); + if (imsgbuf_flush(ibuf) == -1) + log_warn("%s: imsgbuf_flush", __func__); pfd[0].fd = ibuf->fd; pfd[0].events = POLLIN; @@ -357,8 +357,8 @@ rsae_send_imsg(int flen, const u_char *from, u_char *to, RSA *rsa, default: break; } - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatalx("imsg_read"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatalx("imsgbuf_read"); if (n == 0) fatalx("pipe closed"); diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index f7203294850..aa3cd0f938f 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.60 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.61 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -164,7 +164,7 @@ control_accept(int listenfd, short event, void *arg) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; c->iev.data = cs; /* proc.c cheats (reuses the handler) */ @@ -231,15 +231,15 @@ control_dispatch_imsg(int fd, short event, void *arg) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd, cs); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd, cs); return; } diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 3424f878da5..fe3089220fa 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.48 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.49 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,7 +155,8 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsg_init(&iev->ibuf, ps->ps_pp->pp_pipes[dst][inst]); + imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -264,7 +265,7 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } @@ -294,7 +295,7 @@ proc_setup(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc) sizeof(struct imsgev))) == NULL) fatal("%s: calloc", __func__); - /* With this set up, we are ready to call imsg_init(). */ + /* With this set up, we are ready to call imsgbuf_init(). */ for (i = 0; i < ps->ps_instances[id]; i++) { ps->ps_ievs[id][i].handler = proc_dispatch; ps->ps_ievs[id][i].events = EV_READ; @@ -428,7 +429,7 @@ proc_open(struct privsep *ps, int src, int dst) */ if (proc_flush_imsg(ps, src, i) == -1 || proc_flush_imsg(ps, dst, j) == -1) - fatal("%s: imsg_flush", __func__); + fatal("%s: proc_flush_imsg", __func__); } } } @@ -454,7 +455,7 @@ proc_close(struct privsep *ps) /* Cancel the fd, close and invalidate the fd */ event_del(&(ps->ps_ievs[dst][n].ev)); - imsg_clear(&(ps->ps_ievs[dst][n].ibuf)); + imsgbuf_clear(&(ps->ps_ievs[dst][n].ibuf)); close(pp->pp_pipes[dst][n]); pp->pp_pipes[dst][n] = -1; } @@ -601,8 +602,8 @@ proc_dispatch(int fd, short event, void *arg) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ event_del(&iev->ev); @@ -612,14 +613,14 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ event_del(&iev->ev); event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -685,7 +686,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } @@ -819,7 +820,7 @@ proc_flush_imsg(struct privsep *ps, enum privsep_procid id, int n) for (; n < m; n++) { if ((ibuf = proc_ibuf(ps, id, n)) == NULL) return (-1); - if ((ret = imsg_flush(ibuf)) == -1) + if ((ret = imsgbuf_flush(ibuf)) == -1) break; imsg_event_add(&ps->ps_ievs[id][n]); } diff --git a/usr.sbin/ripctl/ripctl.c b/usr.sbin/ripctl/ripctl.c index ab97ae2dfe0..085bea62326 100644 --- a/usr.sbin/ripctl/ripctl.c +++ b/usr.sbin/ripctl/ripctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripctl.c,v 1.18 2024/11/21 13:09:02 claudio Exp $ +/* $OpenBSD: ripctl.c,v 1.19 2024/11/21 13:17:02 claudio Exp $ * * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -110,7 +110,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* process user request */ @@ -187,12 +187,12 @@ main(int argc, char *argv[]) break; } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/ripd/control.c b/usr.sbin/ripd/control.c index 3cea757485e..f48d9c29d50 100644 --- a/usr.sbin/ripd/control.c +++ b/usr.sbin/ripd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.30 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.31 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -143,7 +143,7 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, @@ -219,14 +219,14 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd); return; } diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c index c27debabbd3..2310c175a9b 100644 --- a/usr.sbin/ripd/rde.c +++ b/usr.sbin/ripd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.27 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.28 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -129,9 +129,9 @@ rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2], if ((iev_ripe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ripe->ibuf, pipe_ripe2rde[1]); + imsgbuf_init(&iev_ripe->ibuf, pipe_ripe2rde[1]); iev_ripe->handler = rde_dispatch_imsg; - imsg_init(&iev_main->ibuf, pipe_parent2rde[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); iev_main->handler = rde_dispatch_parent; /* setup event handler */ @@ -197,17 +197,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -300,17 +300,17 @@ rde_dispatch_parent(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c index 83f4a713a9b..251a7bf2e33 100644 --- a/usr.sbin/ripd/ripd.c +++ b/usr.sbin/ripd/ripd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripd.c,v 1.39 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ripd.c,v 1.40 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -235,9 +235,9 @@ main(int argc, char *argv[]) if ((iev_ripe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_ripe->ibuf, pipe_parent2ripe[0]); + imsgbuf_init(&iev_ripe->ibuf, pipe_parent2ripe[0]); iev_ripe->handler = main_dispatch_ripe; - imsg_init(&iev_rde->ibuf, pipe_parent2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); iev_rde->handler = main_dispatch_rde; /* setup event handler */ @@ -314,17 +314,17 @@ main_dispatch_ripe(int fd, short event, void *bula) int shut = 0, verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -394,17 +394,17 @@ main_dispatch_rde(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -526,7 +526,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c index 3008edd90d5..61afe95d5de 100644 --- a/usr.sbin/ripd/ripe.c +++ b/usr.sbin/ripd/ripe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripe.c,v 1.33 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ripe.c,v 1.34 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -153,9 +153,9 @@ ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_rde->ibuf, pipe_ripe2rde[0]); + imsgbuf_init(&iev_rde->ibuf, pipe_ripe2rde[0]); iev_rde->handler = ripe_dispatch_rde; - imsg_init(&iev_main->ibuf, pipe_parent2ripe[1]); + imsgbuf_init(&iev_main->ibuf, pipe_parent2ripe[1]); iev_main->handler = ripe_dispatch_main; /* setup event handler */ @@ -231,17 +231,17 @@ ripe_dispatch_main(int fd, short event, void *bula) int link_ok, shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -312,17 +312,17 @@ ripe_dispatch_rde(int fd, short event, void *bula) int shut = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) /* connection closed */ shut = 1; } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -456,10 +456,10 @@ ripe_shutdown(void) struct iface *iface; /* close pipes */ - imsg_write(&iev_rde->ibuf); + imsgbuf_write(&iev_rde->ibuf); msgbuf_clear(&iev_rde->ibuf.w); close(iev_rde->ibuf.fd); - imsg_write(&iev_main->ibuf); + imsgbuf_write(&iev_main->ibuf); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); diff --git a/usr.sbin/sasyncd/monitor.c b/usr.sbin/sasyncd/monitor.c index 60b11e33360..94642b34f7e 100644 --- a/usr.sbin/sasyncd/monitor.c +++ b/usr.sbin/sasyncd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.22 2017/05/21 02:37:52 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.23 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -487,19 +487,19 @@ m_priv_iked_imsg(u_int cmd) goto out; } - imsg_init(&ibuf, fd); + imsgbuf_init(&ibuf, fd); if (imsg_compose(&ibuf, cmd, 0, 0, -1, NULL, 0) == -1) { log_err("m_priv_iked_imsg: compose"); goto err; } - if (imsg_flush(&ibuf) == -1) { + if (imsgbuf_flush(&ibuf) == -1) { log_err("m_priv_iked_imsg: flush"); goto err; } ret = 0; err: - imsg_clear(&ibuf); + imsgbuf_clear(&ibuf); out: if (fd != -1) close(fd); diff --git a/usr.sbin/slaacctl/slaacctl.c b/usr.sbin/slaacctl/slaacctl.c index 15904fb1409..a0f72fcc429 100644 --- a/usr.sbin/slaacctl/slaacctl.c +++ b/usr.sbin/slaacctl/slaacctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacctl.c,v 1.24 2024/11/21 13:09:03 claudio Exp $ */ +/* $OpenBSD: slaacctl.c,v 1.25 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -109,7 +109,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* Process user request. */ @@ -136,12 +136,12 @@ main(int argc, char *argv[]) usage(); } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/smtpd/ca.c b/usr.sbin/smtpd/ca.c index 3476ae2b049..214312b865c 100644 --- a/usr.sbin/smtpd/ca.c +++ b/usr.sbin/smtpd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.47 2023/07/11 16:40:22 op Exp $ */ +/* $OpenBSD: ca.c,v 1.48 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -323,8 +323,8 @@ rsae_send_imsg(int flen, const unsigned char *from, unsigned char *to, ibuf = &p_ca->imsgbuf; while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatalx("imsg_read"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatalx("imsgbuf_read"); if (n == 0) fatalx("pipe closed"); @@ -431,8 +431,8 @@ ecdsae_send_enc_imsg(const unsigned char *dgst, int dgst_len, ibuf = &p_ca->imsgbuf; while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatalx("imsg_read"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatalx("imsgbuf_read"); if (n == 0) fatalx("pipe closed"); while (!done) { diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index d15838d2e62..a8e003fae5d 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.123 2024/11/21 13:09:04 claudio Exp $ */ +/* $OpenBSD: enqueue.c,v 1.124 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Henning Brauer <henning@bulabula.org> @@ -784,12 +784,12 @@ open_connection(void) imsg_compose(ibuf, IMSG_CTL_SMTP_SESSION, IMSG_VERSION, 0, -1, NULL, 0); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (1) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c index 3f61f7b1aae..016cd413ce5 100644 --- a/usr.sbin/smtpd/mproc.c +++ b/usr.sbin/smtpd/mproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mproc.c,v 1.42 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: mproc.c,v 1.43 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@faurot.net> @@ -26,7 +26,7 @@ static void mproc_dispatch(int, short, void *); -static ssize_t imsg_read_nofd(struct imsgbuf *); +static ssize_t imsgbuf_read_nofd(struct imsgbuf *); int mproc_fork(struct mproc *p, const char *path, char *argv[]) @@ -67,7 +67,7 @@ err: void mproc_init(struct mproc *p, int fd) { - imsg_init(&p->imsgbuf, fd); + imsgbuf_init(&p->imsgbuf, fd); } void @@ -78,7 +78,7 @@ mproc_clear(struct mproc *p) if (p->events) event_del(&p->ev); close(p->imsgbuf.fd); - imsg_clear(&p->imsgbuf); + imsgbuf_clear(&p->imsgbuf); } void @@ -140,15 +140,15 @@ mproc_dispatch(int fd, short event, void *arg) if (event & EV_READ) { if (p->proc == PROC_CLIENT) - n = imsg_read_nofd(&p->imsgbuf); + n = imsgbuf_read_nofd(&p->imsgbuf); else - n = imsg_read(&p->imsgbuf); + n = imsgbuf_read(&p->imsgbuf); switch (n) { case -1: if (errno == EAGAIN) break; - log_warn("warn: %s -> %s: imsg_read", + log_warn("warn: %s -> %s: imsgbuf_read", proc_name(smtpd_process), p->name); fatal("exiting"); /* NOTREACHED */ @@ -164,7 +164,7 @@ mproc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(&p->imsgbuf) == -1) { + if (imsgbuf_write(&p->imsgbuf) == -1) { /* this pipe is dead, so remove the event handler */ log_debug("debug: %s -> %s: pipe closed", proc_name(smtpd_process), p->name); @@ -200,7 +200,7 @@ mproc_dispatch(int fd, short event, void *arg) /* This should go into libutil */ static ssize_t -imsg_read_nofd(struct imsgbuf *ibuf) +imsgbuf_read_nofd(struct imsgbuf *ibuf) { ssize_t n; char *buf; @@ -350,8 +350,8 @@ m_flush(struct mproc *p) p->m_pos = 0; - if (imsg_flush(&p->imsgbuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&p->imsgbuf) == -1) + fatal("imsgbuf_flush"); } static struct imsg * current; diff --git a/usr.sbin/smtpd/queue_proc.c b/usr.sbin/smtpd/queue_proc.c index ff8fe779bd7..81530f5128a 100644 --- a/usr.sbin/smtpd/queue_proc.c +++ b/usr.sbin/smtpd/queue_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_proc.c,v 1.11 2024/05/07 12:10:06 op Exp $ */ +/* $OpenBSD: queue_proc.c,v 1.12 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -33,8 +33,8 @@ queue_proc_call(void) { ssize_t n; - if (imsg_flush(&ibuf) == -1) { - log_warn("warn: queue-proc: imsg_flush"); + if (imsgbuf_flush(&ibuf) == -1) { + log_warn("warn: queue-proc: imsgbuf_flush"); fatalx("queue-proc: exiting"); } @@ -54,8 +54,8 @@ queue_proc_call(void) return; } - if ((n = imsg_read(&ibuf)) == -1 && errno != EAGAIN) { - log_warn("warn: queue-proc: imsg_read"); + if ((n = imsgbuf_read(&ibuf)) == -1 && errno != EAGAIN) { + log_warn("warn: queue-proc: imsgbuf_read"); break; } @@ -291,7 +291,7 @@ queue_proc_init(struct passwd *pw, int server, const char *conf) if (fd == -1) fatalx("queue-proc: exiting"); - imsg_init(&ibuf, fd); + imsgbuf_init(&ibuf, fd); version = PROC_QUEUE_API_VERSION; imsg_compose(&ibuf, PROC_QUEUE_INIT, 0, 0, -1, diff --git a/usr.sbin/smtpd/scheduler_proc.c b/usr.sbin/smtpd/scheduler_proc.c index b601b905e4a..ba815c46ec2 100644 --- a/usr.sbin/smtpd/scheduler_proc.c +++ b/usr.sbin/smtpd/scheduler_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler_proc.c,v 1.10 2024/05/07 12:10:06 op Exp $ */ +/* $OpenBSD: scheduler_proc.c,v 1.11 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -32,8 +32,8 @@ scheduler_proc_call(void) { ssize_t n; - if (imsg_flush(&ibuf) == -1) { - log_warn("warn: scheduler-proc: imsg_flush"); + if (imsgbuf_flush(&ibuf) == -1) { + log_warn("warn: scheduler-proc: imsgbuf_flush"); fatalx("scheduler-proc: exiting"); } @@ -53,8 +53,8 @@ scheduler_proc_call(void) return; } - if ((n = imsg_read(&ibuf)) == -1 && errno != EAGAIN) { - log_warn("warn: scheduler-proc: imsg_read"); + if ((n = imsgbuf_read(&ibuf)) == -1 && errno != EAGAIN) { + log_warn("warn: scheduler-proc: imsgbuf_read"); break; } @@ -104,7 +104,7 @@ scheduler_proc_init(const char *conf) if (fd == -1) fatalx("scheduler-proc: exiting"); - imsg_init(&ibuf, fd); + imsgbuf_init(&ibuf, fd); version = PROC_SCHEDULER_API_VERSION; imsg_compose(&ibuf, PROC_SCHEDULER_INIT, 0, 0, -1, diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 8881c3e54cd..9293a704532 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.172 2023/05/31 16:51:46 op Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.173 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -118,7 +118,7 @@ srv_connect(void) } ibuf = xcalloc(1, sizeof(struct imsgbuf)); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); return (1); } @@ -158,7 +158,7 @@ offline_file(void) static void srv_flush(void) { - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); } @@ -192,8 +192,8 @@ srv_recv(int type) break; } - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); } diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index bde5a35ee7c..40ffc6c35f2 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.352 2024/09/03 18:27:04 op Exp $ */ +/* $OpenBSD: smtpd.c,v 1.353 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -706,8 +706,8 @@ main(int argc, char *argv[]) 0, -1, env->sc_queue_key, strlen(env->sc_queue_key) + 1) == -1) fatal("imsg_compose"); - if (imsg_flush(&p_queue->imsgbuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&p_queue->imsgbuf) == -1) + fatal("imsgbuf_flush"); } setup_done(p_ca); @@ -857,14 +857,14 @@ setup_peers(struct mproc *a, struct mproc *b) if (imsg_compose(&a->imsgbuf, IMSG_SETUP_PEER, b->proc, b->pid, sp[0], NULL, 0) == -1) fatal("imsg_compose"); - if (imsg_flush(&a->imsgbuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&a->imsgbuf) == -1) + fatal("imsgbuf_flush"); if (imsg_compose(&b->imsgbuf, IMSG_SETUP_PEER, a->proc, a->pid, sp[1], NULL, 0) == -1) fatal("imsg_compose"); - if (imsg_flush(&b->imsgbuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&b->imsgbuf) == -1) + fatal("imsgbuf_flush"); } static void @@ -874,8 +874,8 @@ setup_done(struct mproc *p) if (imsg_compose(&p->imsgbuf, IMSG_SETUP_DONE, 0, 0, -1, NULL, 0) == -1) fatal("imsg_compose"); - if (imsg_flush(&p->imsgbuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&p->imsgbuf) == -1) + fatal("imsgbuf_flush"); if (imsg_wait(&p->imsgbuf, &imsg, 10000) == -1) fatal("imsg_wait"); @@ -932,8 +932,8 @@ setup_proc(void) if (imsg_compose(ibuf, IMSG_SETUP_DONE, 0, 0, -1, NULL, 0) == -1) fatal("imsg_compose"); - if (imsg_flush(ibuf) == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(ibuf) == -1) + fatal("imsgbuf_flush"); log_debug("setup_proc: %s done", proc_title(smtpd_process)); } @@ -1013,7 +1013,8 @@ imsg_wait(struct imsgbuf *ibuf, struct imsg *imsg, int timeout) return -1; } - if (((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) || n == 0) + if (((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) || + n == 0) return -1; } } diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c index 5557555319d..a9efedc85e3 100644 --- a/usr.sbin/snmpd/proc.c +++ b/usr.sbin/snmpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.35 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.36 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,7 +155,8 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsg_init(&iev->ibuf, ps->ps_pp->pp_pipes[dst][inst]); + imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -264,7 +265,7 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } @@ -294,7 +295,7 @@ proc_setup(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc) sizeof(struct imsgev))) == NULL) fatal("%s: calloc", __func__); - /* With this set up, we are ready to call imsg_init(). */ + /* With this set up, we are ready to call imsgbuf_init(). */ for (i = 0; i < ps->ps_instances[id]; i++) { ps->ps_ievs[id][i].handler = proc_dispatch; ps->ps_ievs[id][i].events = EV_READ; @@ -423,7 +424,7 @@ proc_open(struct privsep *ps, int src, int dst) */ if (proc_flush_imsg(ps, src, i) == -1 || proc_flush_imsg(ps, dst, j) == -1) - fatal("%s: imsg_flush", __func__); + fatal("%s: proc_flush_imsg", __func__); } } } @@ -449,7 +450,7 @@ proc_close(struct privsep *ps) /* Cancel the fd, close and invalidate the fd */ event_del(&(ps->ps_ievs[dst][n].ev)); - imsg_clear(&(ps->ps_ievs[dst][n].ibuf)); + imsgbuf_clear(&(ps->ps_ievs[dst][n].ibuf)); close(pp->pp_pipes[dst][n]); pp->pp_pipes[dst][n] = -1; } @@ -576,8 +577,8 @@ proc_dispatch(int fd, short event, void *arg) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ event_del(&iev->ev); @@ -587,14 +588,14 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ event_del(&iev->ev); event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -660,7 +661,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } @@ -786,7 +787,7 @@ proc_flush_imsg(struct privsep *ps, enum privsep_procid id, int n) for (; n < m; n++) { if ((ibuf = proc_ibuf(ps, id, n)) == NULL) return (-1); - if ((ret = imsg_flush(ibuf)) == -1) + if ((ret = imsgbuf_flush(ibuf)) == -1) break; imsg_event_add(&ps->ps_ievs[id][n]); } diff --git a/usr.sbin/unwindctl/unwindctl.c b/usr.sbin/unwindctl/unwindctl.c index b6d5a919c9f..8200552a2bc 100644 --- a/usr.sbin/unwindctl/unwindctl.c +++ b/usr.sbin/unwindctl/unwindctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwindctl.c,v 1.30 2024/11/21 13:09:05 claudio Exp $ */ +/* $OpenBSD: unwindctl.c,v 1.31 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -129,7 +129,7 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); done = 0; /* Check for root-only actions */ @@ -177,12 +177,12 @@ main(int argc, char *argv[]) usage(); } - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index 7f13b033448..6b22ea3b9e6 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.80 2024/11/21 13:09:06 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.81 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -209,7 +209,7 @@ vmmaction(struct parse_result *res) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, "malloc"); - imsg_init(ibuf, ctl_sock); + imsgbuf_init(ibuf, ctl_sock); } switch (res->action) { @@ -273,12 +273,12 @@ vmmaction(struct parse_result *res) flags = res->flags; parse_free(res); - if (imsg_flush(ibuf) == -1) + if (imsgbuf_flush(ibuf) == -1) err(1, "write error"); while (!done) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - errx(1, "imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + errx(1, "imsgbuf_read error"); if (n == 0) errx(1, "pipe closed"); diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c index 50135adc4e8..07ac51fe572 100644 --- a/usr.sbin/vmctl/vmctl.c +++ b/usr.sbin/vmctl/vmctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.c,v 1.91 2024/07/09 15:51:11 mlarkin Exp $ */ +/* $OpenBSD: vmctl.c,v 1.92 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> @@ -310,7 +310,7 @@ send_vm(uint32_t id, const char *name) } else { imsg_compose(ibuf, IMSG_VMDOP_SEND_VM_REQUEST, 0, 0, fds[0], &vid, sizeof(vid)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); while (1) { readn = atomicio(read, fds[1], buf, pagesz); if (!readn) @@ -350,7 +350,7 @@ vm_receive(uint32_t id, const char *name) } else { imsg_compose(ibuf, IMSG_VMDOP_RECEIVE_VM_REQUEST, 0, 0, fds[0], &vid, sizeof(vid)); - imsg_flush(ibuf); + imsgbuf_flush(ibuf); while (1) { readn = atomicio(read, STDIN_FILENO, buf, pagesz); if (!readn) { diff --git a/usr.sbin/vmd/control.c b/usr.sbin/vmd/control.c index 709c5f69c15..390940e95ee 100644 --- a/usr.sbin/vmd/control.c +++ b/usr.sbin/vmd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.45 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.46 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org> @@ -305,7 +305,7 @@ control_accept(int listenfd, short event, void *arg) return; } - imsg_init(&c->iev.ibuf, connfd); + imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; c->iev.data = cs; @@ -381,14 +381,14 @@ control_dispatch_imsg(int fd, short event, void *arg) } if (event & EV_READ) { - if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || - n == 0) { + if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 && + errno != EAGAIN) || n == 0) { control_close(fd, cs); return; } } if (event & EV_WRITE) { - if (imsg_write(&c->iev.ibuf) == -1) { + if (imsgbuf_write(&c->iev.ibuf) == -1) { control_close(fd, cs); return; } @@ -524,6 +524,6 @@ control_dispatch_imsg(int fd, short event, void *arg) ret = EINVAL; imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, &ret, sizeof(ret)); - imsg_flush(&c->iev.ibuf); + imsgbuf_flush(&c->iev.ibuf); control_close(fd, cs); } diff --git a/usr.sbin/vmd/proc.c b/usr.sbin/vmd/proc.c index 6bb5a905310..c864eb57a66 100644 --- a/usr.sbin/vmd/proc.c +++ b/usr.sbin/vmd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.29 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.30 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -154,7 +154,8 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsg_init(&iev->ibuf, ps->ps_pp->pp_pipes[dst][inst]); + imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -263,7 +264,7 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } @@ -293,7 +294,7 @@ proc_setup(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc) sizeof(struct imsgev))) == NULL) fatal("%s: calloc", __func__); - /* With this set up, we are ready to call imsg_init(). */ + /* With this set up, we are ready to call imsgbuf_init(). */ for (i = 0; i < ps->ps_instances[id]; i++) { ps->ps_ievs[id][i].handler = proc_dispatch; ps->ps_ievs[id][i].events = EV_READ; @@ -422,7 +423,7 @@ proc_open(struct privsep *ps, int src, int dst) */ if (proc_flush_imsg(ps, src, i) == -1 || proc_flush_imsg(ps, dst, j) == -1) - fatal("%s: imsg_flush", __func__); + fatal("%s: proc_flush_imsg", __func__); } } } @@ -448,7 +449,7 @@ proc_close(struct privsep *ps) /* Cancel the fd, close and invalidate the fd */ event_del(&(ps->ps_ievs[dst][n].ev)); - imsg_clear(&(ps->ps_ievs[dst][n].ibuf)); + imsgbuf_clear(&(ps->ps_ievs[dst][n].ibuf)); close(pp->pp_pipes[dst][n]); pp->pp_pipes[dst][n] = -1; } @@ -592,8 +593,8 @@ proc_dispatch(int fd, short event, void *arg) ibuf = &iev->ibuf; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ event_del(&iev->ev); @@ -603,14 +604,14 @@ proc_dispatch(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ event_del(&iev->ev); event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -681,7 +682,7 @@ void imsg_event_add2(struct imsgev *iev, struct event_base *ev_base) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } @@ -826,7 +827,7 @@ proc_flush_imsg(struct privsep *ps, enum privsep_procid id, int n) for (; n < m; n++) { if ((ibuf = proc_ibuf(ps, id, n)) == NULL) return (-1); - if ((ret = imsg_flush(ibuf)) == -1) + if ((ret = imsgbuf_flush(ibuf)) == -1) break; imsg_event_add(&ps->ps_ievs[id][n]); } diff --git a/usr.sbin/vmd/vioblk.c b/usr.sbin/vmd/vioblk.c index 952fdd840e6..aa64d464c50 100644 --- a/usr.sbin/vmd/vioblk.c +++ b/usr.sbin/vmd/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.17 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: vioblk.c,v 1.18 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2023 Dave Voutila <dv@openbsd.org> @@ -174,7 +174,7 @@ vioblk_main(int fd, int fd_vmm) /* Configure our sync channel event handler. */ log_debug("%s: wiring in sync channel handler (fd=%d)", __func__, dev.sync_fd); - imsg_init(&dev.sync_iev.ibuf, dev.sync_fd); + imsgbuf_init(&dev.sync_iev.ibuf, dev.sync_fd); dev.sync_iev.handler = handle_sync_io; dev.sync_iev.data = &dev; dev.sync_iev.events = EV_READ; @@ -216,7 +216,7 @@ fail: msg.data = ret; imsg_compose(&dev.sync_iev.ibuf, IMSG_DEVOP_MSG, 0, 0, -1, &msg, sizeof(msg)); - imsg_flush(&dev.sync_iev.ibuf); + imsgbuf_flush(&dev.sync_iev.ibuf); close_fd(dev.sync_fd); close_fd(dev.async_fd); @@ -432,8 +432,8 @@ dev_dispatch_vm(int fd, short event, void *arg) int verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ log_debug("%s: pipe dead (EV_READ)", __func__); @@ -444,7 +444,7 @@ dev_dispatch_vm(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ log_debug("%s: pipe dead (EV_WRITE)", __func__); @@ -452,7 +452,7 @@ dev_dispatch_vm(int fd, short event, void *arg) event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -500,8 +500,8 @@ handle_sync_io(int fd, short event, void *arg) int8_t intr = INTR_STATE_NOOP; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ log_debug("%s: vioblk pipe dead (EV_READ)", __func__); @@ -512,7 +512,7 @@ handle_sync_io(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ log_debug("%s: pipe dead (EV_WRITE)", __func__); @@ -520,7 +520,7 @@ handle_sync_io(int fd, short event, void *arg) event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } diff --git a/usr.sbin/vmd/vionet.c b/usr.sbin/vmd/vionet.c index 76a12c60e06..7a4f61bda68 100644 --- a/usr.sbin/vmd/vionet.c +++ b/usr.sbin/vmd/vionet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vionet.c,v 1.19 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: vionet.c,v 1.20 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2023 Dave Voutila <dv@openbsd.org> @@ -241,7 +241,7 @@ vionet_main(int fd, int fd_vmm) /* Configure our sync channel event handler. */ log_debug("%s: wiring in sync channel handler (fd=%d)", __func__, dev.sync_fd); - imsg_init(&dev.sync_iev.ibuf, dev.sync_fd); + imsgbuf_init(&dev.sync_iev.ibuf, dev.sync_fd); dev.sync_iev.handler = handle_sync_io; dev.sync_iev.data = &dev; dev.sync_iev.events = EV_READ; @@ -297,7 +297,7 @@ fail: msg.data = ret; imsg_compose(&dev.sync_iev.ibuf, IMSG_DEVOP_MSG, 0, 0, -1, &msg, sizeof(msg)); - imsg_flush(&dev.sync_iev.ibuf); + imsgbuf_flush(&dev.sync_iev.ibuf); close_fd(dev.sync_fd); close_fd(dev.async_fd); @@ -903,8 +903,8 @@ dev_dispatch_vm(int fd, short event, void *arg) fatalx("%s: missing vionet pointer", __func__); if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ log_debug("%s: pipe dead (EV_READ)", __func__); @@ -915,7 +915,7 @@ dev_dispatch_vm(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ log_debug("%s: pipe dead (EV_WRITE)", __func__); @@ -923,7 +923,7 @@ dev_dispatch_vm(int fd, short event, void *arg) event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -976,8 +976,8 @@ handle_sync_io(int fd, short event, void *arg) int8_t intr = INTR_STATE_NOOP; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ log_debug("%s: pipe dead (EV_READ)", __func__); @@ -988,7 +988,7 @@ handle_sync_io(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ log_debug("%s: pipe dead (EV_WRITE)", __func__); @@ -996,7 +996,7 @@ handle_sync_io(int fd, short event, void *arg) event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index f4a3d4c2ac0..68424980968 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.119 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: virtio.c,v 1.120 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -820,8 +820,8 @@ virtio_shutdown(struct vmd_vm *vm) if (ret == -1) fatalx("%s: failed to send shutdown to device", __func__); - if (imsg_flush(ibuf) == -1) - fatalx("%s: imsg_flush", __func__); + if (imsgbuf_flush(ibuf) == -1) + fatalx("%s: imsgbuf_flush", __func__); } /* @@ -1127,8 +1127,8 @@ vionet_dump(int fd) __func__, dev->vionet.idx); return (-1); } - if (imsg_flush(ibuf) == -1) { - log_warnx("%s: imsg_flush", __func__); + if (imsgbuf_flush(ibuf) == -1) { + log_warnx("%s: imsgbuf_flush", __func__); return (-1); } @@ -1185,8 +1185,8 @@ vioblk_dump(int fd) __func__, dev->vioblk.idx); return (-1); } - if (imsg_flush(ibuf) == -1) { - log_warnx("%s: imsg_flush", __func__); + if (imsgbuf_flush(ibuf) == -1) { + log_warnx("%s: imsgbuf_flush", __func__); return (-1); } @@ -1381,9 +1381,9 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) * communication will be synchronous. We expect the child to * report itself "ready" to confirm the launch was a success. */ - imsg_init(&iev->ibuf, sync_fds[0]); + imsgbuf_init(&iev->ibuf, sync_fds[0]); do - ret = imsg_read(&iev->ibuf); + ret = imsgbuf_read(&iev->ibuf); while (ret == -1 && errno == EAGAIN); if (ret == 0 || ret == -1) { log_warnx("%s: failed to receive ready message from " @@ -1504,7 +1504,7 @@ vm_device_pipe(struct virtio_dev *dev, void (*cb)(int, short, void *), log_debug("%s: initializing '%c' device pipe (fd=%d)", __func__, dev->dev_type, fd); - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); iev->handler = cb; iev->data = dev; iev->events = EV_READ; @@ -1524,8 +1524,8 @@ virtio_dispatch_dev(int fd, short event, void *arg) ssize_t n = 0; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* this pipe is dead, so remove the event handler */ log_debug("%s: pipe dead (EV_READ)", __func__); @@ -1536,7 +1536,7 @@ virtio_dispatch_dev(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* this pipe is dead, remove the handler */ log_debug("%s: pipe dead (EV_WRITE)", __func__); @@ -1544,7 +1544,7 @@ virtio_dispatch_dev(int fd, short event, void *arg) event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -1644,8 +1644,8 @@ virtio_pci_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr, " device", __func__); return (ret); } - if (imsg_flush(ibuf) == -1) { - log_warnx("%s: imsg_flush (write)", __func__); + if (imsgbuf_flush(ibuf) == -1) { + log_warnx("%s: imsgbuf_flush (write)", __func__); return (-1); } } else { @@ -1659,17 +1659,17 @@ virtio_pci_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr, " device", __func__); return (ret); } - if (imsg_flush(ibuf) == -1) { - log_warnx("%s: imsg_flush (read)", __func__); + if (imsgbuf_flush(ibuf) == -1) { + log_warnx("%s: imsgbuf_flush (read)", __func__); return (-1); } /* Read our reply. */ do - n = imsg_read(ibuf); + n = imsgbuf_read(ibuf); while (n == -1 && errno == EAGAIN); if (n == 0 || n == -1) { - log_warn("%s: imsg_read (n=%ld)", __func__, n); + log_warn("%s: imsgbuf_read (n=%ld)", __func__, n); return (-1); } if ((n = imsg_get(ibuf, &imsg)) == -1) { diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 2a38ca4e105..0ed1aba1ce7 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.108 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: vm.c,v 1.109 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -347,17 +347,17 @@ vm_dispatch_vmm(int fd, short event, void *arg) int verbose; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) _exit(0); } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) _exit(0); - fatal("%s: imsg_write fd %d", __func__, ibuf->fd); + fatal("%s: imsgbuf_write fd %d", __func__, ibuf->fd); } } @@ -415,7 +415,7 @@ vm_dispatch_vmm(int fd, short event, void *arg) imsg.hdr.peerid, imsg.hdr.pid, -1, &vmr, sizeof(vmr)); if (!vmr.vmr_result) { - imsg_flush(¤t_vm->vm_iev.ibuf); + imsgbuf_flush(¤t_vm->vm_iev.ibuf); _exit(0); } break; @@ -460,7 +460,7 @@ vm_shutdown(unsigned int cmd) default: fatalx("invalid vm ctl command: %d", cmd); } - imsg_flush(¤t_vm->vm_iev.ibuf); + imsgbuf_flush(¤t_vm->vm_iev.ibuf); if (sev_shutdown(current_vm)) log_warnx("%s: could not shutdown SEV", __func__); diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index d32b7a8367b..700eeb92d44 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.127 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: vmm.c,v 1.128 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -470,7 +470,7 @@ vmm_pipe(struct vmd_vm *vm, int fd, void (*cb)(int, short, void *)) return (-1); } - imsg_init(&iev->ibuf, fd); + imsgbuf_init(&iev->ibuf, fd); iev->handler = cb; iev->data = vm; imsg_event_add(iev); @@ -495,8 +495,8 @@ vmm_dispatch_vm(int fd, short event, void *arg) unsigned int i; if (event & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("%s: imsg_read", __func__); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("%s: imsgbuf_read", __func__); if (n == 0) { /* This pipe is dead, so remove the event handler */ event_del(&iev->ev); @@ -505,13 +505,13 @@ vmm_dispatch_vm(int fd, short event, void *arg) } if (event & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) { /* This pipe is dead, remove the handler */ event_del(&iev->ev); return; } - fatal("%s: imsg_write fd %d", __func__, ibuf->fd); + fatal("%s: imsgbuf_write fd %d", __func__, ibuf->fd); } } diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index dc8c1b172d9..b48b6198b06 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.52 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.53 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -141,17 +141,17 @@ client_dispatch_dns(int fd, short events, void *p) fatalx("unknown event"); if (events & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) shut = 1; } if (events & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -241,17 +241,17 @@ client_dispatch_parent(int fd, short events, void *p) fatalx("unknown event"); if (events & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) shut = 1; } if (events & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -393,7 +393,7 @@ ldapclient(int pipe_main2client[2]) env.sc_iev->events = EV_READ; env.sc_iev->data = &env; - imsg_init(&env.sc_iev->ibuf, pipe_main2client[1]); + imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[1]); env.sc_iev->handler = client_dispatch_parent; event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, env.sc_iev->handler, &env); @@ -401,7 +401,7 @@ ldapclient(int pipe_main2client[2]) env.sc_iev_dns->events = EV_READ; env.sc_iev_dns->data = &env; - imsg_init(&env.sc_iev_dns->ibuf, pipe_dns[0]); + imsgbuf_init(&env.sc_iev_dns->ibuf, pipe_dns[0]); env.sc_iev_dns->handler = client_dispatch_dns; event_set(&env.sc_iev_dns->ev, env.sc_iev_dns->ibuf.fd, env.sc_iev_dns->events, env.sc_iev_dns->handler, &env); diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index 6ff15ae9b44..8dac177f8fb 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.c,v 1.27 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ypldap.c,v 1.28 2024/11/21 13:17:03 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -361,17 +361,17 @@ main_dispatch_client(int fd, short events, void *p) fatalx("unknown event"); if (events & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) shut = 1; } if (events & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } @@ -589,7 +589,7 @@ main(int argc, char *argv[]) close(pipe_main2client[1]); if ((env.sc_iev = calloc(1, sizeof(*env.sc_iev))) == NULL) fatal(NULL); - imsg_init(&env.sc_iev->ibuf, pipe_main2client[0]); + imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[0]); env.sc_iev->handler = main_dispatch_client; env.sc_iev->events = EV_READ; @@ -630,7 +630,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c index 0238b5e0296..1ab6f0bb5ef 100644 --- a/usr.sbin/ypldap/ypldap_dns.c +++ b/usr.sbin/ypldap/ypldap_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap_dns.c,v 1.18 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: ypldap_dns.c,v 1.19 2024/11/21 13:17:03 claudio Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> @@ -115,7 +115,7 @@ ypldap_dns(int pipe_ntp[2], struct passwd *pw) env.sc_iev->events = EV_READ; env.sc_iev->data = &env; - imsg_init(&env.sc_iev->ibuf, pipe_ntp[1]); + imsgbuf_init(&env.sc_iev->ibuf, pipe_ntp[1]); env.sc_iev->handler = dns_dispatch_imsg; event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, env.sc_iev->handler, &env); @@ -146,17 +146,17 @@ dns_dispatch_imsg(int fd, short events, void *p) fatalx("unknown event"); if (events & EV_READ) { - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatal("imsg_read error"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatal("imsgbuf_read error"); if (n == 0) shut = 1; } if (events & EV_WRITE) { - if (imsg_write(ibuf) == -1) { + if (imsgbuf_write(ibuf) == -1) { if (errno == EPIPE) /* connection closed */ shut = 1; else - fatal("imsg_write"); + fatal("imsgbuf_write"); } } |