diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-05 17:39:42 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-05 17:39:42 +0100 |
| commit | 4423b73d2b76c169e3af9770e0b4ebde91168a8c (patch) | |
| tree | 4ff8b1fea3ae74c5c87c8551587b5fc2587aa3f0 /src/examples/read.c | |
| parent | ed2f31c5978911d8afe9276e55b3be22bdd0547b (diff) | |
| download | pintos-4423b73d2b76c169e3af9770e0b4ebde91168a8c.tar.gz | |
add test for read
Diffstat (limited to 'src/examples/read.c')
| -rw-r--r-- | src/examples/read.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/examples/read.c b/src/examples/read.c new file mode 100644 index 0000000..4b6e20b --- /dev/null +++ b/src/examples/read.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <syscall.h> + +int +main (int argc, char *argv[]) +{ + char read_buf[16] = {}; + + int fd = open ("readme"); + if (fd == -1) { + halt (); + } + printf("opened file with fd %d\n", fd); + + int n = read (fd, read_buf, 16); + printf("read %d bytes:\n", n); + + halt(); + return 0; +} |
