* adfCreateVol * * */
| 236 | * |
| 237 | */ |
| 238 | struct Volume* adfCreateVol( struct Device* dev, int32_t start, int32_t len, |
| 239 | char* volName, int volType ) |
| 240 | { |
| 241 | struct bBootBlock boot; |
| 242 | struct bRootBlock root; |
| 243 | /* struct bDirCacheBlock dirc;*/ |
| 244 | SECTNUM blkList[2]; |
| 245 | struct Volume* vol; |
| 246 | int nlen; |
| 247 | |
| 248 | if (adfEnv.useProgressBar) |
| 249 | (*adfEnv.progressBar)(0); |
| 250 | |
| 251 | vol=(struct Volume*)malloc(sizeof(struct Volume)); |
| 252 | if (!vol) { |
| 253 | (*adfEnv.eFct)("adfCreateVol : malloc vol"); |
| 254 | return NULL; |
| 255 | } |
| 256 | |
| 257 | vol->dev = dev; |
| 258 | vol->firstBlock = (dev->heads * dev->sectors)*start; |
| 259 | vol->lastBlock = (vol->firstBlock + (dev->heads * dev->sectors)*len)-1; |
| 260 | vol->rootBlock = (vol->lastBlock - vol->firstBlock+1)/2; |
| 261 | /*printf("first=%ld last=%ld root=%ld\n",vol->firstBlock, |
| 262 | vol->lastBlock, vol->rootBlock); |
| 263 | */ |
| 264 | vol->curDirPtr = vol->rootBlock; |
| 265 | |
| 266 | vol->readOnly = dev->readOnly; |
| 267 | |
| 268 | vol->mounted = TRUE; |
| 269 | |
| 270 | nlen = min( MAXNAMELEN, strlen(volName) ); |
| 271 | vol->volName = (char*)malloc(nlen+1); |
| 272 | if (!vol->volName) { |
| 273 | (*adfEnv.eFct)("adfCreateVol : malloc"); |
| 274 | free(vol); return NULL; |
| 275 | } |
| 276 | memcpy(vol->volName, volName, nlen); |
| 277 | vol->volName[nlen]='\0'; |
| 278 | |
| 279 | if (adfEnv.useProgressBar) |
| 280 | (*adfEnv.progressBar)(25); |
| 281 | |
| 282 | memset(&boot, 0, 1024); |
| 283 | boot.dosType[3] = volType; |
| 284 | /*printf("first=%d last=%d\n", vol->firstBlock, vol->lastBlock); |
| 285 | printf("name=%s root=%d\n", vol->volName, vol->rootBlock); |
| 286 | */ |
| 287 | if (adfWriteBootBlock(vol, &boot)!=RC_OK) { |
| 288 | free(vol->volName); free(vol); |
| 289 | return NULL; |
| 290 | } |
| 291 | |
| 292 | if (adfEnv.useProgressBar) |
| 293 | (*adfEnv.progressBar)(20); |
| 294 | |
| 295 | if (adfCreateBitmap( vol )!=RC_OK) { |
no test coverage detected