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

Function dofileread

freebsd/kern/sys_generic.c:344–383  ·  view source on GitHub ↗

* Common code for readv and preadv that reads data in * from a file using the passed in uio, offset, and flags. */

Source from the content-addressed store, hash-verified

342 * from a file using the passed in uio, offset, and flags.
343 */
344static int
345dofileread(struct thread *td, int fd, struct file *fp, struct uio *auio,
346 off_t offset, int flags)
347{
348 ssize_t cnt;
349 int error;
350#ifdef KTRACE
351 struct uio *ktruio = NULL;
352#endif
353
354 AUDIT_ARG_FD(fd);
355
356 /* Finish zero length reads right here */
357 if (auio->uio_resid == 0) {
358 td->td_retval[0] = 0;
359 return (0);
360 }
361 auio->uio_rw = UIO_READ;
362 auio->uio_offset = offset;
363 auio->uio_td = td;
364#ifdef KTRACE
365 if (KTRPOINT(td, KTR_GENIO))
366 ktruio = cloneuio(auio);
367#endif
368 cnt = auio->uio_resid;
369 if ((error = fo_read(fp, auio, td->td_ucred, flags, td))) {
370 if (auio->uio_resid != cnt && (error == ERESTART ||
371 error == EINTR || error == EWOULDBLOCK))
372 error = 0;
373 }
374 cnt -= auio->uio_resid;
375#ifdef KTRACE
376 if (ktruio != NULL) {
377 ktruio->uio_resid = cnt;
378 ktrgenio(fd, UIO_READ, ktruio, error);
379 }
380#endif
381 td->td_retval[0] = cnt;
382 return (error);
383}
384
385#ifndef _SYS_SYSPROTO_H_
386struct write_args {

Callers 2

kern_readvFunction · 0.85
kern_preadvFunction · 0.85

Calls 3

cloneuioFunction · 0.85
fo_readFunction · 0.85
ktrgenioFunction · 0.85

Tested by

no test coverage detected