Chinaunix首页 | 论坛 | 博客
  • 博客访问: 570880
  • 博文数量: 169
  • 博客积分: 2656
  • 博客等级: 少校
  • 技术积分: 1685
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-30 13:03
文章分类

全部博文(169)

文章存档

2011年(1)

2010年(135)

2009年(33)

我的朋友

分类: 嵌入式

2010-05-14 13:19:54

下面的例子分为两个部分,第一部分是我注释掉的TFFS,第二部分是dosfs,这里主要的函数是usrFdiskPartCreate,它控制分区的个数和每个分区占用块设备的百分比,配置百分比的时候不配置最后一个,在例子中,我分了三个分区,前两个分别占用33%、33%,最后一个占用剩下的部分。
#include "private\cbioLibP.h"
#include "usrFdiskPartLib.h"
/* If use this function, you must modify usrTffsConfig()
    ...
    if ((pBlkDev = tffsDevCreate (drive, removable)) == NULL)
{
        printErr ("tffsDevCreate failed.\n");
        return (ERROR);
}
#if 0
    devSplit (fileName, devName);
    pCbio = cbioWrapBlkDev (pBlkDev);
    if (pCbio == (CBIO_DEV_ID)NULL)
return (ERROR);
    if (dosFsDevCreate (devName, pCbio, 0, NONE) != OK)
        return (ERROR);
#endif
    if (usrPartDiskFsInit(pBlkDev) != OK)
    {
        printf("\r\n Create diskpart failed!!!");
        return ERROR;
    }
    return (OK);
    }
    ...
*/
int usrPartDiskFsInit(void * blkDevId)
{
    const char * devNames[] = { "/sd0a", "/sd0b", "/sd0c" };
    int dcacheSize = 0x30000 ;
    CBIO_DEV_ID cbio, cbio1 ;
    /* create disk cache */
    if((cbio = dcacheDevCreate(blkDevId, NULL, dcacheSize, "/sd0")) == NULL )
        return ERROR ;
    /* create partitions */
    if((usrFdiskPartCreate (cbio, 3, 33, 33, 0)) == ERROR)
        return ERROR;
    /* create partition manager with FDISK style decoder, up to 3 parts */
    if((cbio1 = dpartDevCreate(cbio, 3, usrFdiskPartRead)) == NULL)
        return ERROR;
    /* create the 1st file system, 8 simult. open files, with CHKDSK */
    if(dosFsDevCreate(devNames[0], dpartPartGet(cbio1,0), 20, 0) == ERROR)
        return ERROR;
    /* create the 2nd file system, 6 simult. open files, with CHKDSK */
    if(dosFsDevCreate(devNames[1], dpartPartGet(cbio1,1), 20, 0) == ERROR)
        return ERROR;
    /* create the 3rd file system, 4 simultaneously open files, no CHKDSK */
    if(dosFsDevCreate(devNames[2], dpartPartGet(cbio1,2), 20, NONE) == ERROR)
        return ERROR;
    /* Formatting the first partition */
    if(dosFsVolFormat (devNames[0], 0, 0) == ERROR)
        return ERROR;
    /* Formatting the second partition */
    if(dosFsVolFormat (devNames[1], 0, 0) == ERROR)
        return ERROR;
    /* Formatting the third partition */
    if(dosFsVolFormat (devNames[2], 0, 0) == ERROR)
        return ERROR;
    return OK;
}
阅读(3162) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~