这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » x86下如何读取目标机硬盘文件系统?

共3条 1/1 1 跳转至

x86下如何读取目标机硬盘文件系统?

菜鸟
2004-11-03 05:44:36     打赏

vxworks已经进入运行状态,想download下自己的模块,用于对目标机硬盘文件系统操作。

#include <dirent.h>

int mytask(char * dirname)

{

DIR * pdir;

strunct dirent * de;

pdir = open......

}

不知道一般要进行些那方面的操作才能得到目录?

另外,如何由errorno得到error information啊?程序中pinrtErrno好多没有定义,如何查找这些error code的含义,帮助系统中有么?谢谢啦




关键词: 如何     读取     目标机     硬盘     文件     系统    

菜鸟
2004-11-04 02:41:00     打赏
2楼

查看了半天帮助,总算找到解决的捷径了。

如果在build vxorks image的时候include了ata,那么直接可以使用如下函数将ata硬盘mount上: usrAtaConfig(); 例如:usrAtaConfig(0, 0, "/ata0"); 以后就可以使用目录"/ata0"了。 比如 #include <stdio.h> #include <dirent.h> int mydir(char * rootdir) { int i = 0; DIR * pDir; struct dirent * pde; pDir = opendir(rootdir); if (pDir == NULL) { printf("Error! error code is %d.\n", errno); printf("Cann't open dir.\n"); return -1; } pde = readdir(pDir); while(pde) { i ++; printf("%s\n", pde->d_name); pde = readdir(pDir); } printf("Total %d files and directories.\n", i); closedir(pDir); return 0; } 当键入mydir("/ata0")的时候就会显示硬盘上的文件与目录。


菜鸟
2004-11-04 02:42:00     打赏
3楼

但是依靠下面的解决方法却无法解决,不知道那位大侠能够提供帮助,非常感谢!

目标机平台:vxworks5.4, x86 pentium, floppy disk, hard disk @ ide 0,0. 目标机上硬盘在第一个ide通道的primary接口上,已经存在了dos文件系统(FAT)。在dos中运行的vxload bootrom.sys引导的vxworks。 目的:希望能够访问目标机硬盘上的文件。 目前的状态:能够通过ataShow得到硬盘的相关信息:(通过shell得到) -> ataShow(0,0) ATA-LOCAL intCount =7 intStatus =0x58 ataTypes cylinders =208 heads =16 sectorsTrack =63 bytesSector =512 precomp =0xff ataParams cylinders =209 heads =16 sectorsTrack =63 bytesSector =0 config =0x427a removcyl =0x0 bytesTrack =0x0 bytesGap =0x0 bytesSync =0x0 vendstat =0x0 serial =00000000000000000001 type =0x0 size =0x40 bytesEcc =0x0 rev =00000001 model =VMware Virtual IDE Hard Drive multiSecs =0x8040 capabilty =0x2f00 pioMode =0x200 dmaMode =0x0 valid =0x7 curr-cyl =209 curr-head =16 curr-sector =63 capacity0 =0x36f0 capacity1 =0x3 multiSet =0x110 sectors0 =0x36f0 sectors1 =0x3 singleDma =0x0 multiDma =0x7 advancedPio =0x3 cycleDma =120 cycleMulti =120 cyclePio-wo =160 cyclePio-w =120 Capability MULTI: TRUE, IORDY: TRUE, DMA: TRUE, LBA: TRUE multiSectors =0x40 pioMode =0x4 singleDma =0x0 multiDma =0x2 Configuration rwMode =PIO_4 rwBits =16BITS rwPio =MULTI rwDma =MULTI value = 0 = 0x0 编写的代码: int MountAtaDisk(void) { int maxfd = 20; int ctrl = 0; int drive = 0; int blocks = 0; int offset = 0; char pDevName[] = "/ata0/"; /* int vector = 14; int level = 0; */ DOS_VOL_CONFIG VolConf; BLK_DEV * pBlkDev; DOS_VOL_DESC * pVolDesc; /* Initialize dosFs Library */ if (dosFsInit(maxfd) == ERROR) { printf("Error! error code is %d.\n", errno); printf("Cann't initialize dosFs library.\n"); return -1; } /* Initialize ata driver */ /* if (ataDrv(ctrl, 1, vector, level, 0, 0, 0) == ERROR) { printf("Error! error code is %d.\n", errno); printf("Cann't load ata driver.\n"); return -1; }*/ /* Create ata device */ pBlkDev = ataDevCreate(ctrl, drive, blocks, offset); if (pBlkDev == NULL) { printf("Error! error code is %d.\n", errno); printf("Cann't create ata device.\n"); return -1; } /* Initialize ata/ide device */ pVolDesc = dosFsDevInit(pDevName, pBlkDev, NULL); if (pVolDesc == NULL) { printf("Error! error code is %d.\n", errno); printf("Cann't initialize dosFs Device.\n"); return -1; } return 0; } 出现的问题: 当运行MountAtaDisk时,在调用函数dosFsDevInit()处出现错误,返回: -> MountAtaDisk Error! error code is 3670017. Cann't initialize dosFs Device. value = -1 = 0xffffffff 运行printErrno(3670017)得到错误提示: -> printErrno(3670017) 0x380001 = S_dosFsLib_VOLUME_NOT_AVAILABLE value = 0 = 0x0 这应该如何解决呢。在vxworks映像中已经define了ATA的支持。


共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]