* adfWritePARTblock * */
| 824 | * |
| 825 | */ |
| 826 | RETCODE |
| 827 | adfWritePARTblock(struct Device *dev, int32_t nSect, struct bPARTblock* part) |
| 828 | { |
| 829 | uint8_t buf[LOGICAL_BLOCK_SIZE]; |
| 830 | uint32_t newSum; |
| 831 | struct nativeFunctions *nFct; |
| 832 | RETCODE rc2, rc = RC_OK; |
| 833 | |
| 834 | if (dev->readOnly) { |
| 835 | (*adfEnv.wFct)("adfWritePARTblock : can't write block, read only device"); |
| 836 | return RC_ERROR; |
| 837 | } |
| 838 | |
| 839 | memset(buf,0,LOGICAL_BLOCK_SIZE); |
| 840 | |
| 841 | strncpy(part->id,"PART",4); |
| 842 | part->size = sizeof(struct bPARTblock)/sizeof(int32_t); |
| 843 | part->blockSize = LOGICAL_BLOCK_SIZE; |
| 844 | part->vectorSize = 16; |
| 845 | part->blockSize = 128; |
| 846 | part->sectorsPerBlock = 1; |
| 847 | part->dosReserved = 2; |
| 848 | |
| 849 | memcpy(buf, part, sizeof(struct bPARTblock)); |
| 850 | #ifdef LITT_ENDIAN |
| 851 | swapEndian(buf, SWBL_PART); |
| 852 | #endif |
| 853 | |
| 854 | newSum = adfNormalSum(buf, 8, LOGICAL_BLOCK_SIZE); |
| 855 | swLong(buf+8, newSum); |
| 856 | /* *(int32_t*)(buf+8) = swapLong((uint8_t*)&newSum);*/ |
| 857 | |
| 858 | nFct = adfEnv.nativeFct; |
| 859 | if (dev->isNativeDev) |
| 860 | rc2=(*nFct->adfNativeWriteSector)(dev, nSect, LOGICAL_BLOCK_SIZE, buf); |
| 861 | else |
| 862 | rc2=adfWriteDumpSector(dev, nSect, LOGICAL_BLOCK_SIZE, buf); |
| 863 | if (rc2!=RC_OK) |
| 864 | return RC_ERROR; |
| 865 | |
| 866 | return rc; |
| 867 | } |
| 868 | |
| 869 | /* |
| 870 | * ReadFSHDblock |
no test coverage detected