X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/77e7b21f117eecd04bb31257ee68dfc1f425a47e..6fefc6f5af83f316e18b0cb9dbbde1cea0b98add:/lunaix-os/kernel/demos/iotest.c?ds=sidebyside diff --git a/lunaix-os/kernel/demos/iotest.c b/lunaix-os/kernel/demos/iotest.c new file mode 100644 index 0000000..3fc8914 --- /dev/null +++ b/lunaix-os/kernel/demos/iotest.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +LOG_MODULE("IOTEST") + +void +_iotest_main() +{ + char test_sequence[] = "Once upon a time, in a magical land of Equestria. " + "There were two regal sisters who ruled together " + "and created harmony for all the land."; + int fd = open("/dev/block/bd0", 0); + + if (fd < 0) { + kprintf(KERROR "fail to open (%d)\n", geterrno()); + return; + } + + lseek(fd, 1, FSEEK_SET); + write(fd, test_sequence, sizeof(test_sequence)); + + lseek(fd, -1, FSEEK_CUR); + char read_out[256]; + read(fd, read_out, sizeof(read_out)); + + kprintf("%s", read_out); +} \ No newline at end of file