static int wrap_fs_mountfs(struct _reent *r, const char *pathname) { if (fs) { r->_errno = EBUSY; return -1; } lfile = malloc(sizeof(*lfile)); if (if_initInterface(lfile,"mci0:")) { free(lfile); r->_errno = EACCES; return -1; } ioman = malloc(sizeof(*ioman)); disc = malloc(sizeof(*disc)); part = malloc(sizeof(*part)); ioman_init(ioman,lfile,0); disc_initDisc(disc,ioman); memClr(disc->partitions,sizeof(PartitionField)*4); disc->partitions[0].type=0x0B; disc->partitions[0].LBA_begin=0; disc->partitions[0].numSectors=lfile->sectorCount; part_initPartition(part,disc); fs = malloc(sizeof(*fs)); if( (fs_initFs(fs,part)) != 0) { printf("Unable to init the filesystem\n"); return(-1); } return 0; }
/** * This function will set a hook function, which will be invoked when a memory * block is allocated from heap memory. * * @param hook the hook function */ int efs_mount(struct dfs_filesystem* fs) { efsl_fs* efsfs; int result; /* allocate an EFS filesystem entry */ efsfs = (efsl_fs*) rt_malloc (sizeof(efsl_fs)); /* init efs filesystem struct */ efsfs->partition.ioman = rt_malloc(sizeof(IOManager)); efsfs->partition.ioman->device = fs->dev_id; part_initPartition(&efsfs->partition); ioman_init(efsfs->partition.ioman); result = fs_initFs(&efsfs->filesystem ,&efsfs->partition); /* set to DFS filesystem user data */ fs->data = efsfs; return result; }
/* **************************************************************************** * esint8 efs_init(EmbeddedFileSystem * efs,eint8* opts) * Description: This function initialises all subelements of a filesystem. * It sets the pointerchain and verifies each step. * Return value: 0 on success and -1 on failure. */ esint8 efs_init(EmbeddedFileSystem * efs,eint8* opts) { if(if_initInterface(&efs->myCard, opts)==0) { ioman_init(&efs->myIOman,&efs->myCard,0); disc_initDisc(&efs->myDisc, &efs->myIOman); part_initPartition(&efs->myPart, &efs->myDisc); if(efs->myPart.activePartition==-1){ efs->myDisc.partitions[0].type=0x0B; efs->myDisc.partitions[0].LBA_begin=0; efs->myDisc.partitions[0].numSectors=efs->myCard.sectorCount; /*efs->myPart.activePartition = 0;*/ /*efs->myPart.disc = &(efs->myDisc);*/ part_initPartition(&efs->myPart, &efs->myDisc); } /*part_initPartition(&efs->myPart, &efs->myDisc);*/ if(fs_initFs(&efs->myFs, &efs->myPart)) return(-2); return(0); } return(-1); }