static int snplwrite(struct tty *tp, struct uio *uio, int flag) { struct iovec iov; struct uio uio2; struct snoop *snp; int error, ilen; char *ibuf; lwkt_gettoken(&tty_token); error = 0; ibuf = NULL; snp = tp->t_sc; while (uio->uio_resid > 0) { ilen = (int)szmin(512, uio->uio_resid); ibuf = kmalloc(ilen, M_SNP, M_WAITOK); error = uiomove(ibuf, (size_t)ilen, uio); if (error != 0) break; snp_in(snp, ibuf, ilen); /* Hackish, but probably the least of all evils. */ iov.iov_base = ibuf; iov.iov_len = ilen; uio2.uio_iov = &iov; uio2.uio_iovcnt = 1; uio2.uio_offset = 0; uio2.uio_resid = ilen; uio2.uio_segflg = UIO_SYSSPACE; uio2.uio_rw = UIO_WRITE; uio2.uio_td = uio->uio_td; error = ttwrite(tp, &uio2, flag); if (error != 0) break; kfree(ibuf, M_SNP); ibuf = NULL; } if (ibuf != NULL) kfree(ibuf, M_SNP); lwkt_reltoken(&tty_token); return (error); }
void cc_output_phase(char *buffer, struct cc **output, int bufsize) { int i; struct cc *p, *p1; for (i = 0; i < bufsize;) { if ((p = output[i]) == 0) { ttputc(buffer[i]); i++; } else if (p->code >= 0) { if (--p->ccount == 0) qinsert(p, &cc_q0a); (*tt.tt_put_token)(p->code, p->string, p->length); wwntokuse++; wwntoksave += put_token_score(p->length); i += p->length; } else if ((p1 = cc_q0a.qback) != &cc_q0a) { p->code = p1->code; p1->code = -1; qinsert(p1, &cc_q1a); if (--p->ccount == 0) qinsert(p, &cc_q0a); else qinsert(p, &cc_q0b); (*tt.tt_set_token)(p->code, p->string, p->length); wwntokdef++; wwntoksave -= tt.tt_set_token_cost; i += p->length; } else { p->ccount--; ttwrite(p->string, p->length); wwntokbad++; i += p->length; } } wwntokc += bufsize; }
void trmWrite(dev_t dev) { ttwrite(&terminal[minor(dev)]); }