X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/0e1309c02f0703c050df09b71346dab60fc6df87..5ea8e2ba737f903db81d49b56778e883634512a5:/lunaix-os/kernel/demos/iotest.c diff --git a/lunaix-os/kernel/demos/iotest.c b/lunaix-os/kernel/demos/iotest.c index 5e17b02..0ebe696 100644 --- a/lunaix-os/kernel/demos/iotest.c +++ b/lunaix-os/kernel/demos/iotest.c @@ -15,11 +15,25 @@ _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."; + char read_out[256]; + + // 切换工作目录至 /dev + int errno = chdir("/dev"); + if (errno) { + write(STDOUT, "fail to chdir", 15); + return; + } + + if (getcwd(read_out, sizeof(read_out))) { + write(STDOUT, "current working dir: ", 22); + write(STDOUT, read_out, 256); + write(STDOUT, "\n", 2); + } // sda 设备 - 硬盘 // sda设备属于容积设备(Volumetric Device), // Lunaix会尽可能缓存任何对此设备的上层读写,并使用延迟写入策略。(FO_DIRECT可用于屏蔽该功能) - int fd = open("/dev/sda", 0); + int fd = open("./sda", 0); if (fd < 0) { kprintf(KERROR "fail to open (%d)\n", geterrno()); @@ -38,7 +52,6 @@ _iotest_main() lseek(fd, 4 * 4096, FSEEK_SET); write(fd, test_sequence, sizeof(test_sequence)); - char read_out[256]; write(STDOUT, "input: ", 8); int size = read(STDIN, read_out, 256);