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