文件 write.c
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char boot_buf[512];
int floppy_desc,file_desc;
file_desc = open("./boot",O_RDONLY);
read(file_desc,boot_buf,510);
close(file_desc);
boot_buf[510] = 0x55;
boot_buf[511] = 0xaa;
floppy_desc = open("/dev/fh0",O_RDWR);
lseek(floppy_desc,0,SEEK_CUR);
write(floppy_desc,boot_buf,512);
close(floppy_desc);
}
用 cc write.c -o write 命令后显示如下
write.c: In function `main':
write.c:9: `O_RDONLY' undeclared (first use in this function)
write.c:9: (Each undeclared identifier is reported only once
write.c:9: for each function it appears in.)
write.c:14: `O_RDWR' undeclared (first use in this function)
write.c:18:2: warning: no newline at end of file
不知怎么解决? |