diff options
Diffstat (limited to 'src/examples/create.c')
| -rw-r--r-- | src/examples/create.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/examples/create.c b/src/examples/create.c new file mode 100644 index 0000000..65be47d --- /dev/null +++ b/src/examples/create.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <syscall.h> + +int +main (int argc, char *argv[]) +{ + if (create ("test", 1)) { + printf ("created file\n"); + } else { + printf ("couldn't create file\n"); + } + int fd = open ("test"); // open 2 + printf ("opened file with fd %d\n", fd); + int fd2 = open ("test"); // open 3 + printf ("opened file with fd %d\n", fd2); + close(fd); // close 2 + int fd3 = open ("test"); // open 2 + printf ("opened file with fd %d\n", fd3); + close(fd2); // close 3 + int fd4 = open ("test"); // open 3 + printf ("opened file with fd %d\n", fd4); + close(fd4); // close 3, valid + close(fd3); // close 2, valid + close(fd); // close closed 2, invalid + int fd5 = open ("test"); // open 2 + printf ("opened file with fd %d\n", fd5); + + halt (); +} |
