STATUS usrFdConfig ( int drive, /* drive number of floppy disk (0 - 3) */ int type, /* type of floppy disk */ char * fileName /* mount point */ ) { BLK_DEV *pBootDev; CBIO_DEV_ID cbio ; char bootDir [BOOT_FILE_LEN]; if( type == NONE) return OK; if ((UINT)drive >= FD_MAX_DRIVES) { printErr ("drive is out of range (0-%d).\n", FD_MAX_DRIVES - 1); return (ERROR); } /* create a block device spanning entire disk (non-distructive!) */ if ((pBootDev = fdDevCreate (drive, type, 0, 0)) == NULL) { printErr ("fdDevCreate failed.\n"); return (ERROR); } /* create a disk cache to speed up Floppy operation */ cbio = dcacheDevCreate( (CBIO_DEV_ID) pBootDev, NULL, FD_CACHE_SIZE, bootDir ); if( cbio == NULL ) { /* insufficient memory, will avoid the cache */ cbio = cbioWrapBlkDev (pBootDev); } /* split off boot device from boot file */ devSplit (fileName, bootDir); /* initialize device as a dosFs device named <bootDir> */ if (dosFsDevCreate (bootDir, cbio, 20, NONE) == ERROR) { printErr ("dosFsDevCreate failed.\n"); return (ERROR); } return (OK); }
STATUS usrCFConfig ( int drive, /* drive number of hard disk (0 or 1) */ char * fileName /* mount point */ ) { BLK_DEV *pBlkDev; char bootDir [BOOT_FILE_LEN]; char buffer [1024]; int offset = 0; DATAFLASH_RAW cfRaw; char *pSys; DOS_PART_TBL *pPart; if ((UINT)drive >= DATAFLASH_MAX_DRIVES) { printErr ("drive is out of range (0-%d).\n", DATAFLASH_MAX_DRIVES - 1); return (ERROR); } /* split off boot device from boot file */ devSplit (fileName, bootDir); strcpy(mountpoint,bootDir); /* read the boot sector */ cfRaw.cylinder = 0; cfRaw.head = 0; cfRaw.sector = 1; cfRaw.pBuf = buffer; cfRaw.nSecs = 1; cfRaw.direction = 0; cfcRawio (drive, &cfRaw); /* get an offset if it is formated by MSDOS */ pSys = &buffer[DOS_BOOT_SYS_ID]; pPart = (DOS_PART_TBL *)&buffer[DOS_BOOT_PART_TBL]; if ((strncmp(pSys, VXDOS, strlen(VXDOS)) != 0) && (strncmp(pSys, VXEXT, strlen(VXEXT)) != 0)) { offset = usrCFPartition (drive, pPart); } if ((pBlkDev = cfcDevCreate(drive, 0, offset)) == (BLK_DEV *)NULL) { printErr ("Error during cfDevCreate: %x\n", errno); return (ERROR); } /* Make DOS file system */ #if 0 if (dosFsDevInit(bootDir, pBlkDev, NULL) == (DOS_VOL_DESC *)NULL) { printErr ("Error during dosFsDevInit: %x\n", errno); return (ERROR); } #endif if (dosFsDevCreate(bootDir, pBlkDev, 20,0) == (DOS_VOL_DESC *)NULL) { printErr ("Error during dosFsDevInit: %x\n", errno); return (ERROR); } return (OK); }