1 #include <lunaix/fctrl.h>
2 #include <lunaix/foptions.h>
3 #include <lunaix/lunistd.h>
4 #include <lunaix/proc.h>
5 #include <lunaix/syslog.h>
12 char test_sequence[] = "Once upon a time, in a magical land of Equestria. "
13 "There were two regal sisters who ruled together "
14 "and created harmony for all the land.";
16 int fd = open("/dev/sda", 0); // bd0 设备 - 硬盘
17 int tty = open("/dev/tty", 0); // tty 设备 - 控制台
19 if (fd < 0 || tty < 0) {
20 kprintf(KERROR "fail to open (%d)\n", geterrno());
24 // 移动指针至第二个逻辑扇区(LBA=1),并写入
25 lseek(fd, 1, FSEEK_SET);
26 write(fd, test_sequence, sizeof(test_sequence));
30 lseek(fd, -1, FSEEK_CUR);
31 read(fd, read_out, sizeof(read_out));
33 write(tty, read_out, sizeof(read_out));
38 kprint_hex(read_out, sizeof(read_out));