AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
null.c File Reference

/dev/null (character device 1, 3): reading it gives nothing, the end of the file at once, and what is written to it is thrown away. More...

#include <core/system.h>
#include <dev/dev.h>
#include <fs/posix.h>
#include <aquila/errno.h>
#include <memdev.h>

Go to the source code of this file.

Functions

static ssize_t nulldev_read (struct devid *dd, off_t offset, struct iobuf *io)
 Reads nothing: /dev/null is always at its end.
static ssize_t nulldev_write (struct devid *dd, off_t offset, struct iobuf *io)
 Takes all that is written, and throws it away.

Variables

struct dev nulldev

Detailed Description

/dev/null (character device 1, 3): reading it gives nothing, the end of the file at once, and what is written to it is thrown away.

Definition in file null.c.

Function Documentation

◆ nulldev_read()

ssize_t nulldev_read ( struct devid * dd,
off_t offset,
struct iobuf * io )
static

Reads nothing: /dev/null is always at its end.

Definition at line 16 of file null.c.

References nulldev_read().

Referenced by nulldev_read().

◆ nulldev_write()

ssize_t nulldev_write ( struct devid * dd,
off_t offset,
struct iobuf * io )
static

Takes all that is written, and throws it away.

Definition at line 22 of file null.c.

References iobuf_skip(), nulldev_write(), and iobuf::resid.

Referenced by nulldev_write().

Variable Documentation

◆ nulldev

struct dev nulldev
Initial value:
= {
.read = nulldev_read,
.write = nulldev_write,
.fops = {
.open = posix_file_open,
.read = posix_file_read,
.write = posix_file_write,
.close = posix_file_close,
.can_read = __vfs_can_always,
.can_write = __vfs_can_always,
.eof = __vfs_eof_always,
},
}
static ssize_t nulldev_read(struct devid *dd, off_t offset, struct iobuf *io)
Reads nothing: /dev/null is always at its end.
Definition null.c:16
static ssize_t nulldev_write(struct devid *dd, off_t offset, struct iobuf *io)
Takes all that is written, and throws it away.
Definition null.c:22
int posix_file_open(struct file *file)
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
Definition open.c:17
int posix_file_close(struct file *file)
Closes an open file by dropping its reference to its vnode.
Definition close.c:15
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.
Definition read.c:29
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.
Definition write.c:25

Definition at line 13 of file null.c.

Referenced by memdev_mux().