AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
iobuf.h File Reference
#include <core/system.h>

Go to the source code of this file.

Data Structures

struct  iobuf_seg
 A piece of an iobuf's memory. More...
struct  iobuf
 An iobuf. More...

Functions

void iobuf_init (struct iobuf *io, void *buf, size_t len, int user)
 Sets up an iobuf for one buffer.
ssize_t iobuf_out (struct iobuf *io, const void *src, size_t n)
 Copies bytes from the kernel into the iobuf's buffer, and moves past them.
ssize_t iobuf_in (struct iobuf *io, void *dst, size_t n)
 Copies bytes from the iobuf's buffer into the kernel, and moves past them.
ssize_t iobuf_peek (struct iobuf *io, void *dst, size_t n)
 Copies bytes from the iobuf's buffer into the kernel, without moving past them.
ssize_t iobuf_zero (struct iobuf *io, size_t n)
 Fills bytes of the iobuf's buffer with zeros, and moves past them.
size_t iobuf_skip (struct iobuf *io, size_t n)
 Moves an iobuf past bytes, without copying them.
static size_t iobuf_limit (struct iobuf *io, size_t n)
 Cuts the buffer to n bytes for a while, so that what it's passed to moves no more.
static void iobuf_unlimit (struct iobuf *io, size_t cut)
 Gives back what iobuf_limit() cut.

Function Documentation

◆ iobuf_in()

ssize_t iobuf_in ( struct iobuf * io,
void * dst,
size_t n )

Copies bytes from the iobuf's buffer into the kernel, and moves past them.

Parameters
iothe iobuf
dstwhere they go
nhow many
Returns
how many were copied (fewer if a fault stopped it), or -EFAULT if a fault came first

Definition at line 135 of file iobuf.c.

References iobuf_copy(), iobuf_in(), and iobuf_skip().

Referenced by ext2_write(), fbdev_vesa_write(), iobuf_in(), kdev_blk_io(), kmsgdev_write(), minix_write(), ps2mouse_write(), randomdev_write(), ringbuf_write_iobuf(), and tmpfs_write().

◆ iobuf_init()

void iobuf_init ( struct iobuf * io,
void * buf,
size_t len,
int user )

Sets up an iobuf for one buffer.

Parameters
iothe iobuf
bufthe buffer
lenits length, in bytes
userwhether the buffer is in user memory (copies are checked)

Definition at line 19 of file iobuf.c.

References iobuf_seg::base, iobuf::fault, iobuf_init(), iobuf_seg::len, iobuf::nseg, iobuf::one, iobuf::resid, iobuf::seg, and iobuf::user.

Referenced by iobuf_init(), sys_read(), sys_recv(), sys_send(), sys_write(), vfs_read(), and vfs_write().

◆ iobuf_limit()

size_t iobuf_limit ( struct iobuf * io,
size_t n )
inlinestatic

Cuts the buffer to n bytes for a while, so that what it's passed to moves no more.

Returns how much was cut, which iobuf_unlimit() gives back.

Definition at line 72 of file iobuf.h.

References iobuf::resid.

◆ iobuf_out()

ssize_t iobuf_out ( struct iobuf * io,
const void * src,
size_t n )

Copies bytes from the kernel into the iobuf's buffer, and moves past them.

Parameters
iothe iobuf
srcthe bytes
nhow many
Returns
how many were copied (fewer if a fault stopped it), or -EFAULT if a fault came first

Definition at line 115 of file iobuf.c.

References iobuf_copy(), iobuf_out(), and iobuf_skip().

Referenced by ext2_read(), iobuf_out(), iobuf_zero(), kdev_blk_io(), kmsgdev_read(), minix_read(), procfs_read(), randomdev_read(), ring_to_iobuf(), ringbuf_read_iobuf(), socket_inet_recv(), socket_tcp_recv(), tmpfs_read(), and vcs_read().

◆ iobuf_peek()

ssize_t iobuf_peek ( struct iobuf * io,
void * dst,
size_t n )

Copies bytes from the iobuf's buffer into the kernel, without moving past them.

Parameters
iothe iobuf
dstwhere they go
nhow many
Returns
how many were copied, or -EFAULT

Definition at line 154 of file iobuf.c.

References iobuf_copy(), and iobuf_peek().

Referenced by iobuf_peek(), iobuf_to_ring(), and tty_write_iobuf().

◆ iobuf_skip()

size_t iobuf_skip ( struct iobuf * io,
size_t n )

Moves an iobuf past bytes, without copying them.

Parameters
iothe iobuf
nhow many bytes (no more than are left)
Returns
how many it moved past

Definition at line 81 of file iobuf.c.

References iobuf_seg::base, iobuf_skip(), iobuf_seg::len, MIN, iobuf::nseg, iobuf::resid, and iobuf::seg.

Referenced by iobuf_in(), iobuf_out(), iobuf_skip(), iobuf_to_ring(), nulldev_write(), tty_write_iobuf(), and zerodev_write().

◆ iobuf_unlimit()

void iobuf_unlimit ( struct iobuf * io,
size_t cut )
inlinestatic

Gives back what iobuf_limit() cut.

Definition at line 80 of file iobuf.h.

References iobuf::resid.

◆ iobuf_zero()

ssize_t iobuf_zero ( struct iobuf * io,
size_t n )

Fills bytes of the iobuf's buffer with zeros, and moves past them.

Parameters
iothe iobuf
nhow many
Returns
how many were zeroed (fewer if a fault stopped it), or -EFAULT if a fault came first

Definition at line 167 of file iobuf.c.

References iobuf_out(), iobuf_zero(), MIN, and iobuf::resid.

Referenced by iobuf_zero(), and zerodev_read().