summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_prf.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-07-10 15:42:16 +0000
committerphk <phk@FreeBSD.org>2004-07-10 15:42:16 +0000
commitb9f13e4266e1a358f8e0f5ee3542e657eabb8a19 (patch)
treede46976e3a829fc81580355aafed8ed3f3fcdb8e /sys/kern/subr_prf.c
parentafe21b6175db45f3406c5cd8c0d1516078e4e32c (diff)
downloadFreeBSD-src-b9f13e4266e1a358f8e0f5ee3542e657eabb8a19.zip
FreeBSD-src-b9f13e4266e1a358f8e0f5ee3542e657eabb8a19.tar.gz
Clean up and wash struct iovec and struct uio handling.
Add copyiniov() which copies a struct iovec array in from userland into a malloc'ed struct iovec. Caller frees. Change uiofromiov() to malloc the uio (caller frees) and name it copyinuio() which is more appropriate. Add cloneuio() which returns a malloc'ed copy. Caller frees. Use them throughout.
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r--sys/kern/subr_prf.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 9f4bedd..3650ca1 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -243,9 +243,7 @@ log(int level, const char *fmt, ...)
void
log_console(struct uio *uio)
{
- int c, i, error, iovlen, nl;
- struct uio muio;
- struct iovec *miov = NULL;
+ int c, i, error, nl;
char *consbuffer;
int pri;
@@ -253,13 +251,8 @@ log_console(struct uio *uio)
return;
pri = LOG_INFO | LOG_CONSOLE;
- muio = *uio;
- iovlen = uio->uio_iovcnt * sizeof (struct iovec);
- MALLOC(miov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
- MALLOC(consbuffer, char *, CONSCHUNK, M_TEMP, M_WAITOK);
- bcopy(muio.uio_iov, miov, iovlen);
- muio.uio_iov = miov;
- uio = &muio;
+ uio = cloneuio(uio);
+ consbuffer = malloc(CONSCHUNK, M_TEMP, M_WAITOK);
nl = 0;
while (uio->uio_resid > 0) {
@@ -278,8 +271,8 @@ log_console(struct uio *uio)
if (!nl)
msglogchar('\n', pri);
msgbuftrigger = 1;
- FREE(miov, M_TEMP);
- FREE(consbuffer, M_TEMP);
+ free(uio, M_IOV);
+ free(consbuffer, M_TEMP);
return;
}
OpenPOWER on IntegriCloud