MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ureadc

Function ureadc

freebsd/kern/subr_uio.c:307–344  ·  view source on GitHub ↗

* Give next character to user as result of read. */

Source from the content-addressed store, hash-verified

305 * Give next character to user as result of read.
306 */
307int
308ureadc(int c, struct uio *uio)
309{
310 struct iovec *iov;
311 char *iov_base;
312
313 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
314 "Calling ureadc()");
315
316again:
317 if (uio->uio_iovcnt == 0 || uio->uio_resid == 0)
318 panic("ureadc");
319 iov = uio->uio_iov;
320 if (iov->iov_len == 0) {
321 uio->uio_iovcnt--;
322 uio->uio_iov++;
323 goto again;
324 }
325 switch (uio->uio_segflg) {
326 case UIO_USERSPACE:
327 if (subyte(iov->iov_base, c) < 0)
328 return (EFAULT);
329 break;
330
331 case UIO_SYSSPACE:
332 iov_base = iov->iov_base;
333 *iov_base = c;
334 break;
335
336 case UIO_NOCOPY:
337 break;
338 }
339 iov->iov_base = (char *)iov->iov_base + 1;
340 iov->iov_len--;
341 uio->uio_resid--;
342 uio->uio_offset++;
343 return (0);
344}
345
346int
347copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error)

Callers 1

ptsdev_readFunction · 0.85

Calls 2

panicFunction · 0.70
subyteFunction · 0.50

Tested by

no test coverage detected