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

Function adfWriteBootBlock

dep/adflib/src/adf_raw.c:220–250  ·  view source on GitHub ↗

* adfWriteBootBlock * * * write bootcode ? */

Source from the content-addressed store, hash-verified

218 * write bootcode ?
219 */
220RETCODE
221adfWriteBootBlock(struct Volume* vol, struct bBootBlock* boot)
222{
223 uint8_t buf[LOGICAL_BLOCK_SIZE*2];
224 uint32_t newSum;
225
226 boot->dosType[0] = 'D';
227 boot->dosType[1] = 'O';
228 boot->dosType[2] = 'S';
229 memcpy(buf, boot, LOGICAL_BLOCK_SIZE*2);
230#ifdef LITT_ENDIAN
231 swapEndian(buf, SWBL_BOOT);
232#endif
233
234 if (boot->rootBlock==880 || boot->data[0]!=0) {
235 newSum = adfBootSum(buf);
236/*fprintf(stderr,"sum %x %x\n",newSum,adfBootSum2(buf));*/
237 swLong(buf+4,newSum);
238/* *(uint32_t*)(buf+4) = swapLong((uint8_t*)&newSum);*/
239 }
240
241/* dumpBlock(buf);
242 dumpBlock(buf+512);
243*/
244 if (adfWriteBlock(vol, 0, buf)!=RC_OK)
245 return RC_ERROR;
246 if (adfWriteBlock(vol, 1, buf+512)!=RC_OK)
247 return RC_ERROR;
248/*puts("adfWriteBootBlock");*/
249 return RC_OK;
250}
251
252
253/*

Callers 2

adfInstallBootBlockFunction · 0.85
adfCreateVolFunction · 0.85

Calls 4

swapEndianFunction · 0.85
adfBootSumFunction · 0.85
swLongFunction · 0.85
adfWriteBlockFunction · 0.85

Tested by

no test coverage detected