- 论坛徽章:
- 0
|
另外请教,你是用的img软盘映像文件吗,如何将生成的bin代码写入其中的?
我在linux下用那本书的附带win软件写入的,有linux下的更好的方法吗?
用dd做的软盘映像
自己写一个工具写入img
在FreeBSD上编译通过 linux应该也没问题的
- 1 #include <stdio.h>
- 2 #include <sys/types.h>
- 3 #include <sys/uio.h>
- 4 #include <unistd.h>
- 5 #include <fcntl.h>
- 6 #include <sys/stat.h>
- 7 int
- 8 main(int argc,char *argv[])
- 9 {
- 10 struct stat img_file;
- 11
- 12 char boot_buf[512];
- 13 int i;
- 14 for(i=0;i<511;i++){
- 15 boot_buf[i]=0x00;
- 16 }
- 17 int img_fd, boot_fd;
- 18
- 19 if(argc!=3){
- 20 printf("USAGE:./write boot_file img_file\n");
- 21 }
- 22
- 23 boot_fd = open(argv[1], O_RDONLY);
- 24 img_fd = open(argv[2], O_RDWR);
- 25 fstat(img_fd,&img_file);
- 26 if((argc==3)&&(img_file.st_size!=1474560))
- 27 {
- 28 printf("WARNING:floppy image size is NOT 1474560 \n");
- 29 }
- 30 read(boot_fd, boot_buf, 510);
- 31 close(boot_fd);
- 32 boot_buf[510] = 0x55;
- 33 boot_buf[511] = 0xaa;
- 34 lseek(img_fd, 0, SEEK_CUR);
- 35 write(img_fd, boot_buf, 512);
- 36 close(img_fd);
- 37
- 38 exit(0);
- 39 }
复制代码
[ 本帖最后由 坏坏小少 于 2007-5-13 12:08 编辑 ] |
|