* adfWriteFSHDblock * */
| 911 | * |
| 912 | */ |
| 913 | RETCODE |
| 914 | adfWriteFSHDblock(struct Device *dev, int32_t nSect, struct bFSHDblock* fshd) |
| 915 | { |
| 916 | uint8_t buf[LOGICAL_BLOCK_SIZE]; |
| 917 | uint32_t newSum; |
| 918 | struct nativeFunctions *nFct; |
| 919 | RETCODE rc = RC_OK; |
| 920 | |
| 921 | if (dev->readOnly) { |
| 922 | (*adfEnv.wFct)("adfWriteFSHDblock : can't write block, read only device"); |
| 923 | return RC_ERROR; |
| 924 | } |
| 925 | |
| 926 | memset(buf,0,LOGICAL_BLOCK_SIZE); |
| 927 | |
| 928 | strncpy(fshd->id,"FSHD",4); |
| 929 | fshd->size = sizeof(struct bFSHDblock)/sizeof(int32_t); |
| 930 | |
| 931 | memcpy(buf, fshd, sizeof(struct bFSHDblock)); |
| 932 | #ifdef LITT_ENDIAN |
| 933 | swapEndian(buf, SWBL_FSHD); |
| 934 | #endif |
| 935 | |
| 936 | newSum = adfNormalSum(buf, 8, LOGICAL_BLOCK_SIZE); |
| 937 | swLong(buf+8, newSum); |
| 938 | /* *(int32_t*)(buf+8) = swapLong((uint8_t*)&newSum);*/ |
| 939 | |
| 940 | nFct = adfEnv.nativeFct; |
| 941 | if (dev->isNativeDev) |
| 942 | rc=(*nFct->adfNativeWriteSector)(dev, nSect, LOGICAL_BLOCK_SIZE, buf); |
| 943 | else |
| 944 | rc=adfWriteDumpSector(dev, nSect, LOGICAL_BLOCK_SIZE, buf); |
| 945 | if (rc!=RC_OK) |
| 946 | return RC_ERROR; |
| 947 | |
| 948 | return RC_OK; |
| 949 | } |
| 950 | |
| 951 | |
| 952 | /* |
no test coverage detected