Skip to content

Commit

Permalink
Make /dev/null seekable
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jun 20, 2020
1 parent 88bf091 commit 3858957
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ static ssize_t null_read(struct fd *UNUSED(fd), void *UNUSED(buf), size_t UNUSED
static ssize_t null_write(struct fd *UNUSED(fd), const void *UNUSED(buf), size_t bufsize) {
return bufsize;
}
static off_t_ null_lseek(struct fd *fd, off_t_ off, int whence) {
return 0;
}
struct dev_ops null_dev = {
.open = null_open,
.fd.read = null_read,
.fd.write = null_write,
.fd.lseek = null_lseek,
.fd.poll = ready_poll,
};

Expand All @@ -75,6 +79,7 @@ struct dev_ops zero_dev = {
.open = null_open,
.fd.read = zero_read,
.fd.write = zero_write,
.fd.lseek = null_lseek,
.fd.poll = ready_poll,
};

Expand All @@ -85,6 +90,7 @@ struct dev_ops full_dev = {
.open = null_open,
.fd.read = zero_read,
.fd.write = full_write,
.fd.lseek = null_lseek,
.fd.poll = ready_poll,
};

Expand All @@ -96,5 +102,6 @@ struct dev_ops random_dev = {
.open = null_open,
.fd.read = random_read,
.fd.write = null_write,
.fd.lseek = null_lseek,
.fd.poll = ready_poll,
};

0 comments on commit 3858957

Please sign in to comment.