* adfReadBlock * * read logical block */
| 366 | * read logical block |
| 367 | */ |
| 368 | RETCODE |
| 369 | adfReadBlock(struct Volume* vol, int32_t nSect, uint8_t* buf) |
| 370 | { |
| 371 | /* char strBuf[80];*/ |
| 372 | int32_t pSect; |
| 373 | struct nativeFunctions *nFct; |
| 374 | RETCODE rc; |
| 375 | |
| 376 | if (!vol->mounted) { |
| 377 | (*adfEnv.eFct)("the volume isn't mounted, adfReadBlock not possible"); |
| 378 | return RC_ERROR; |
| 379 | } |
| 380 | |
| 381 | /* translate logical sect to physical sect */ |
| 382 | pSect = nSect+vol->firstBlock; |
| 383 | |
| 384 | if (adfEnv.useRWAccess) |
| 385 | (*adfEnv.rwhAccess)(pSect,nSect,FALSE); |
| 386 | |
| 387 | /*printf("psect=%ld nsect=%ld\n",pSect,nSect);*/ |
| 388 | /* sprintf(strBuf,"ReadBlock : accessing logical block #%ld", nSect); |
| 389 | (*adfEnv.vFct)(strBuf); |
| 390 | */ |
| 391 | if (pSect<vol->firstBlock || pSect>vol->lastBlock) { |
| 392 | (*adfEnv.wFct)("adfReadBlock : nSect out of range"); |
| 393 | |
| 394 | } |
| 395 | /*printf("pSect R =%ld\n",pSect);*/ |
| 396 | nFct = adfEnv.nativeFct; |
| 397 | if (vol->dev->isNativeDev) |
| 398 | rc = (*nFct->adfNativeReadSector)(vol->dev, pSect, 512, buf); |
| 399 | else |
| 400 | rc = adfReadDumpSector(vol->dev, pSect, 512, buf); |
| 401 | /*printf("rc=%ld\n",rc);*/ |
| 402 | if (rc!=RC_OK) |
| 403 | return RC_ERROR; |
| 404 | else |
| 405 | return RC_OK; |
| 406 | } |
| 407 | |
| 408 | |
| 409 | /* |
no test coverage detected