Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dofileread(9) [netbsd man page]

DOFILEREAD(9)						   BSD Kernel Developer's Manual					     DOFILEREAD(9)

NAME
dofileread, dofilereadv, dofilewrite, dofilewritev -- high-level file operations SYNOPSIS
#include <sys/file.h> int dofileread(struct lwp *l, int fd, struct file *fp, void *buf, size_t nbyte, off_t *offset, int flags, register_t *retval); int dofilewrite(struct lwp *l, int fd, struct file *fp, const void *buf, size_t nbyte, off_t *offset, int flags, register_t *retval); int dofilereadv(struct lwp *l, int fd, struct file *fp, const struct iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval); int dofilewritev(struct lwp *l, int fd, struct file *fp, const struct iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval); DESCRIPTION
The functions implement the underlying functionality of the read(2), write(2), readv(2), and writev(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 fp into the buffer pointed to by buf. The dofilewrite() function attempts to write nbytes of data to the object referenced by file entry fp from the buffer pointed to by buf. The dofilereadv() and dofilewritev() functions perform the same operations, but scatter the data with 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 operation is returned in *offset. If the FOF_UPDATE_OFFSET flag is specified in the flags argument, the file offset in the file entry fp is updated to reflect the new file offset, otherwise it remains unchanged after the operation. The file descriptor fd is largely unused except for use by the ktrace framework for reporting to userlevel the process's file descriptor. Upon successful completion the number of bytes which were transferred is returned in *retval. RETURN VALUES
Upon successful completion zero is returned, otherwise an appropriate error is returned. CODE REFERENCES
The framework for these file operations is implemented within the file sys/kern/sys_generic.c. SEE ALSO
file(9) BSD
December 20, 2005 BSD

Check Out this Related Man Page

VNFILEOPS(9)						   BSD Kernel Developer's Manual					      VNFILEOPS(9)

NAME
vnfileops, vn_closefile, vn_fcntl, vn_ioctl, vn_read, vn_poll, vn_statfile, vn_write -- vnode file descriptor operations SYNOPSIS
#include <sys/param.h> #include <sys/file.h> #include <sys/vnode.h> int vn_closefile(file_t *fp); int vn_fcntl(file_t *fp, u_int com, void *data); int vn_ioctl(file_t *fp, u_long com, void *data); int vn_read(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred, int flags); int vn_poll(file_t *fp, int events); int vn_statfile(file_t *fp, struct stat *sb); int vn_write(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred, int flags); DESCRIPTION
The functions described in this page are the vnode-specific file descriptor operations. They should only be accessed through the opaque function pointers in the file entries (see file(9)). They are described here only for completeness. FUNCTIONS
vn_closefile(fp, l) Common code for a file table vnode close operation. The file is described by fp and l is the calling lwp. vn_closefile() simply calls vn_close(9) with the appropriate arguments. vn_fcntl(fp, com, data, l) Common code for a file table vnode fcntl(2) operation. The file is specified by fp. The argument l is the calling lwp. vn_fcntl() simply locks the vnode and invokes the vnode operation VOP_FCNTL(9) with the command com and buffer data. The vnode is unlocked on return. If the operation is successful zero is returned, otherwise an appropriate error is returned. vn_ioctl(fp, com, data, l) Common code for a file table vnode ioctl operation. The file is specified by fp. The argument l is the calling lwp vn_ioctl() sim- ply locks the vnode and invokes the vnode operation VOP_IOCTL(9) with the command com and buffer data. The vnode is unlocked on return. If the operation is successful zero is returned, otherwise an appropriate error is returned. vn_read(fp, offset, uio, cred, flags) Common code for a file table vnode read. The argument fp is the file structure, The argument offset is the offset into the file. The argument uio is the uio structure describing the memory to read into. The caller's credentials are specified in cred. The flags argument can define FOF_UPDATE_OFFSET to update the read position in the file. If the operation is successful zero is returned, otherwise an appropriate error is returned. vn_poll(fp, events, l) Common code for a file table vnode poll operation. vn_poll() simply calls VOP_POLL(9) with the events events and the calling lwp l. The function returns a bitmask of available events. vn_statfile(fp, sb, l) Common code for a stat operation. The file descriptor is specified by the argument fp and sb is the buffer to return the stat information. The argument l is the calling lwp. vn_statfile() basically calls the vnode operation VOP_GETATTR(9) and transfer the contents of a vattr structure into a struct stat. If the operation is successful zero is returned, otherwise an appropriate error code is returned. vn_write(fp, offset, uio, cred, flags) Common code for a file table vnode write. The argument fp is the file structure, The argument offset is the offset into the file. The argument uio is the uio structure describing the memory to read from. The caller's credentials are specified in cred. The flags argument can define FOF_UPDATE_OFFSET to update the read position in the file. If the operation is successful zero is returned, otherwise an appropriate error is returned. CODE REFERENCES
The high-level convenience functions are implemented within the file sys/kern/vfs_vnops.c. SEE ALSO
file(9), intro(9), vnode(9), vnodeops(9), vnsubr(9) BSD
April 9, 2008 BSD
Man Page