Function: Create a ram disk device Parameters: name -> device name, such as "ramdisk0:". size -> block device size. Returned: The actualy disk size. Or ERROR.
// 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 ; }
Function: Delete a ram disk device Parameters: name -> device name, such as "ramdisk0:". Returned: Return OK if the device is removed successfuly. Otherwise return ERROR.
Function: Create a ram disk device & set is as default path. Parameters: name -> device name, such as "ramdisk0:". size -> block device size. Returned: The actualy disk size. Or ERROR.
文章评论(0条评论)
登录后参与讨论