27 size_t size = io->
resid, done = 0;
30 size_t len = ringbuf_read_noconsume(
kmsg, offset + done,
MIN(size - done,
sizeof(tmp)), tmp);
38 return done ? (
ssize_t) done : r;
55 size_t size = io->
resid, done = 0;
61 return done ? (
ssize_t) done : len;
91 .can_read = __vfs_can_always,
92 .can_write = __vfs_can_always,
93 .eof = __vfs_eof_never,
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.
static ssize_t kmsgdev_read(struct devid *dd, off_t offset, struct iobuf *io)
Reads the kernel's messages from offset on, a piece at a time through a small buffer.
static int kmsg_file_open(struct file *file)
Opens /dev/kmsg: its readers wait on the kernel's message queue.
static ssize_t kmsgdev_write(struct devid *dd, off_t offset, struct iobuf *io)
Prints what is written as a kernel message.
int posix_file_open(struct file *file)
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
int posix_file_close(struct file *file)
Closes an open file by dropping its reference to its vnode.
ssize_t posix_file_read(struct file *file, struct iobuf *io)
Reads from an open file at its offset, and moves the offset past what was read.
ssize_t posix_file_write(struct file *file, struct iobuf *io)
Writes to an open file at its offset, and moves the offset past what was written.
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
A device driver: its operations, any of which may be NULL.
Which device: its kind (S_IFCHR or S_IFBLK) and numbers.
An open file (POSIX's "open file description", fs/file.c).