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

Function adfReadPARTblock

dep/adflib/src/adf_hd.c:780–819  ·  view source on GitHub ↗

* ReadPARTblock * */

Source from the content-addressed store, hash-verified

778 *
779 */
780 RETCODE
781adfReadPARTblock( struct Device* dev, int32_t nSect, struct bPARTblock* blk )
782{
783 UCHAR buf[ sizeof(struct bPARTblock) ];
784 struct nativeFunctions *nFct;
785 RETCODE rc2, rc = RC_OK;
786
787 nFct = adfEnv.nativeFct;
788 if (dev->isNativeDev)
789 rc2=(*nFct->adfNativeReadSector)(dev, nSect, sizeof(struct bPARTblock), buf);
790 else
791 rc2=adfReadDumpSector(dev, nSect, sizeof(struct bPARTblock), buf);
792
793 if (rc2!=RC_OK)
794 return RC_ERROR;
795
796 memcpy(blk, buf, sizeof(struct bPARTblock));
797#ifdef LITT_ENDIAN
798 /* big to little = 68000 to x86 */
799 swapEndian((uint8_t*)blk, SWBL_PART);
800#endif
801
802 if ( strncmp(blk->id,"PART",4)!=0 ) {
803 (*adfEnv.eFct)("ReadPARTblock : PART id not found");
804 return RC_ERROR;
805 }
806
807 if ( blk->size != 64 )
808 (*adfEnv.wFct)("ReadPARTBlock : size != 64");
809
810 if ( blk->blockSize!=128 ) {
811 (*adfEnv.eFct)("ReadPARTblock : blockSize!=512, not supported (yet)");
812 return RC_ERROR;
813 }
814
815 if ( blk->checksum != adfNormalSum(buf,8,256) )
816 (*adfEnv.wFct)( "ReadPARTBlock : incorrect checksum");
817
818 return rc;
819}
820
821
822/*

Callers 1

adfMountHdFunction · 0.85

Calls 3

adfReadDumpSectorFunction · 0.85
swapEndianFunction · 0.85
adfNormalSumFunction · 0.85

Tested by

no test coverage detected