12.07.2015 Views

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DOFILEREAD (9) <strong>NetBSD</strong> <strong>Kernel</strong> Developer’s <strong>Manual</strong> DOFILEREAD (9)<strong>NAME</strong>dofileread, dofilereadv, dofilewrite, dofilewritev —high-level file operationsSYNOPSIS#include intdofileread(struct lwp ∗l , int fd , struct file ∗fp , void ∗buf , size_t nbyte ,off_t ∗offset , int flags , register_t ∗retval);intdofilewrite(struct lwp ∗l , int fd , struct file ∗fp , const void ∗buf ,size_t nbyte , off_t ∗offset , int flags , register_t ∗retval);intdofilereadv(struct lwp ∗l , int fd , struct file ∗fp ,const struct iovec ∗iovp , int iovcnt , off_t ∗offset , int flags ,register_t ∗retval);intdofilewritev(struct lwp ∗l , int fd , struct file ∗fp ,const struct iovec ∗iovp , int iovcnt , off_t ∗offset , int flags ,register_t ∗retval);DESCRIPTIONThe functions implement the underlying functionality of the read(2), write(2), readv(2), andwritev(2) system calls. They are also used throughout the kernel as high-level access routines for file I/O.The dofileread() function attempts to read nbytes of data from the object referenced by file entry fpinto the buffer pointed to by buf. The dofilewrite() function attempts to write nbytes of data to theobject referenced by file entry fp from the buffer pointed to by buf.The dofilereadv() and dofilewritev() functions perform the same operations, but scatter the datawith the iovcnt buffers specified by the members of the iov array.The offset of the file operations is explicitly specified by ∗offset. The new file offset after the file operationis returned in ∗offset. Ifthe FOF_UPDATE_OFFSET flag is specified in the flags argument, thefile offset in the file entry fp is updated to reflect the new file offset, otherwise it remains unchanged afterthe operation.The file descriptor fd is largely unused except for use by the ktrace framework for reporting to userlevel theprocess’s file descriptor.Upon successful completion the number of bytes which were transferred is returned in ∗retval.RETURN VALUESUpon successful completion zero is returned, otherwise an appropriate error is returned.CODE REFERENCESThis section describes places within the <strong>NetBSD</strong> source tree where actual code implementing or using thesefile operations can be found. All pathnames are relative to /usr/src.The framework for these file operations is implemented within the file sys/kern/sys_generic.c.<strong>NetBSD</strong> 3.0 December 20, 2005 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!