MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / adfReadRDSKblock

Function adfReadRDSKblock

dep/adflib/src/adf_hd.c:679–724  ·  view source on GitHub ↗

* ReadRDSKblock * */

Source from the content-addressed store, hash-verified

677 *
678 */
679 RETCODE
680adfReadRDSKblock( struct Device* dev, struct bRDSKblock* blk )
681{
682
683 UCHAR buf[256];
684 struct nativeFunctions *nFct;
685 RETCODE rc2;
686 RETCODE rc = RC_OK;
687
688 nFct = adfEnv.nativeFct;
689 if (dev->isNativeDev)
690 rc2 =(*nFct->adfNativeReadSector)(dev, 0, 256, buf);
691 else
692 rc2 = adfReadDumpSector(dev, 0, 256, buf);
693
694 if (rc2!=RC_OK)
695 return(RC_ERROR);
696
697 memcpy(blk, buf, 256);
698#ifdef LITT_ENDIAN
699 /* big to little = 68000 to x86 */
700 swapEndian((uint8_t*)blk, SWBL_RDSK);
701#endif
702
703 if ( strncmp(blk->id,"RDSK",4)!=0 ) {
704 (*adfEnv.eFct)("ReadRDSKblock : RDSK id not found");
705 return RC_ERROR;
706 }
707
708 if ( blk->size != 64 )
709 (*adfEnv.wFct)("ReadRDSKBlock : size != 64"); /* BV */
710
711 if ( blk->checksum != adfNormalSum(buf,8,256) ) {
712 (*adfEnv.wFct)("ReadRDSKBlock : incorrect checksum");
713 /* BV FIX: Due to malicious Win98 write to sector
714 rc|=RC_BLOCKSUM;*/
715 }
716
717 if ( blk->blockSize != 512 )
718 (*adfEnv.wFct)("ReadRDSKBlock : blockSize != 512"); /* BV */
719
720 if ( blk->cylBlocks != blk->sectors*blk->heads )
721 (*adfEnv.wFct)( "ReadRDSKBlock : cylBlocks != sectors*heads");
722
723 return rc;
724}
725
726
727/*

Callers 1

adfMountHdFunction · 0.85

Calls 3

adfReadDumpSectorFunction · 0.85
swapEndianFunction · 0.85
adfNormalSumFunction · 0.85

Tested by

no test coverage detected