这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 关于ram disk的问题!

共1条 1/1 1 跳转至

关于ram disk的问题!

菜鸟
2006-05-30 00:34:38     打赏

采用铁峰的方法:

/**********************************************************************

Function: Create a ram disk device
Parameters:
name -> device name, such as "ramdisk0:".
size -> block device size.
Returned:
The actualy disk size. Or ERROR.

**********************************************************************/

STATUS CreateRamDisk(char * name,int size)
{
int nBlock = NULL ;
BLK_DEV * pBlkDev = NULL ;
DOS_VOL_DESC * pVolDesc = NULL ;

// the disksize should be integral multiple of the blocksize.

size = size - size%512 ;
nBlock = size/512 ;

// You can simultaneously open 20 files

dosFsInit(20) ;

// Create a ram-disk.
// The base address is the return value of alloc.
// The block size is 512.
// nBlock blocks per track
// Total nBlock blocks.
// The base address offset is 0.

pBlkDev = ramDevCreate(0,512,nBlock,nBlock,0) ;
if (NULL==pBlkDev)
{
fprintf(stderr,"Can not create ram block device.\n") ;
return ERROR ;
}

// Make DOSFS by a ram block device.

pVolDesc = dosFsMkfs(name,pBlkDev) ;
if (NULL==pVolDesc)
{
fprintf(stderr,"Can not create ram-dos-fs.\n") ;
return ERROR ;
}

// The size is actualy disk size.

return size ;
}

在程序启动后运行,出现如下提示:
Retrieved old volume params with %70 confidence:
Volume Parameters: FAT type: FAT16, sectors per cluster 248
72 FAT copies, 0 clusters, 13312 sectors per FAT
Sectors reserved 24848, hidden 490930504, FAT sectors 958464
Root dir entries 0, sysId (null) , serial number 9f8018
Label:"8 K " ...
Disk with 2048 sectors of 512 bytes will be formatted with:
Volume Parameters: FAT type: FAT12, sectors per cluster 1
2 FAT copies, 2028 clusters, 6 sectors per FAT
Sectors reserved 1, hidden 0, FAT sectors 12
Root dir entries 112, sysId VXDOS12 , serial number 9f8018
Label:"8 K " ...
value = 1048576 = 0x100000

这是什么意思?好像ram disk还是可以用的,但是不知道可靠不可靠?

请教高手指点!

[align=right][color=#000066][此贴子已经被作者于2006-5-29 16:36:58编辑过][/color][/align]



关键词: 关于     问题    

共1条 1/1 1 跳转至

回复

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