| @@ -0,0 +1,20 @@ | |||
| 1 | + | #include <unistd.h> | |
| 2 | + | #include <fcntl.h> | |
| 3 | + | ||
| 4 | + | int main(void) { | |
| 5 | + | int fd = open("meow.txt", O_WRONLY|O_CREAT, 0640); | |
| 6 | + | if (fd != -1) { | |
| 7 | + | write(fd, "meow :3\n", 8); | |
| 8 | + | write(1, "written\n", 8); | |
| 9 | + | close(fd); | |
| 10 | + | } | |
| 11 | + | fd = open("meow.txt", O_RDONLY); | |
| 12 | + | if (fd != -1) { | |
| 13 | + | char meow[8]; | |
| 14 | + | read(fd, meow, 8); | |
| 15 | + | write(1, "read\n", 5); | |
| 16 | + | write(1, meow, 8); | |
| 17 | + | close(fd); | |
| 18 | + | } | |
| 19 | + | return 0; | |
| 20 | + | } | |
swee / silly syscall chaos
Last active 5 days ago
swee revised this gist 5 days ago · 9ca640a
1 file changed, 20 insertions