AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
null.c
Go to the documentation of this file.
1
5
6
#include <
core/system.h
>
7
#include <
dev/dev.h
>
8
#include <
fs/posix.h
>
9
#include <aquila/errno.h>
10
11
#include <
memdev.h
>
12
13
struct
dev
nulldev
;
14
16
static
ssize_t
nulldev_read
(
struct
devid
*dd __unused,
off_t
offset __unused,
struct
iobuf
*io __unused)
17
{
18
return
0;
19
}
20
22
static
ssize_t
nulldev_write
(
struct
devid
*dd __unused,
off_t
offset __unused,
struct
iobuf
*io)
23
{
24
return
iobuf_skip
(io, io->
resid
);
25
}
26
27
struct
dev
nulldev
= {
28
.read =
nulldev_read
,
29
.write =
nulldev_write
,
30
31
.fops = {
32
.open =
posix_file_open
,
33
.read =
posix_file_read
,
34
.write =
posix_file_write
,
35
.close =
posix_file_close
,
36
37
.can_read = __vfs_can_always,
38
.can_write = __vfs_can_always,
39
.eof = __vfs_eof_always,
40
},
41
};
dev.h
system.h
iobuf_skip
size_t iobuf_skip(struct iobuf *io, size_t n)
Moves an iobuf past bytes, without copying them.
Definition
iobuf.c:81
memdev.h
nulldev
struct dev nulldev
Definition
null.c:27
nulldev_read
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
nulldev_write
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
posix_file_open
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
posix_file_close
int posix_file_close(struct file *file)
Closes an open file by dropping its reference to its vnode.
Definition
close.c:15
posix_file_read
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
posix_file_write
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
posix.h
dev
A device driver: its operations, any of which may be NULL.
Definition
dev.h:28
devid
Which device: its kind (S_IFCHR or S_IFBLK) and numbers.
Definition
dev.h:21
iobuf
An iobuf.
Definition
iobuf.h:35
iobuf::resid
size_t resid
Definition
iobuf.h:38
ssize_t
long int ssize_t
Definition
types.h:12
off_t
long int off_t
Definition
types.h:10
kernel
dev
mem
null.c
Generated by
1.18.0