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

Function adfCreateHdHeader

dep/adflib/src/adf_hd.c:479–555  ·  view source on GitHub ↗

* adfCreateHdHeader * * create PARTIALLY the sectors of the header of one harddisk : can not be mounted * back on a real Amiga ! It's because some device dependant values can't be guessed... * * do not use dev->volList[], but partList for partitions information : start and len are cylinders, * not blocks * do not fill dev->volList[] * called by adfCreateHd() */

Source from the content-addressed store, hash-verified

477 * called by adfCreateHd()
478 */
479RETCODE adfCreateHdHeader(struct Device* dev, int n, struct Partition** partList )
480{
481 int i;
482 struct bRDSKblock rdsk;
483 struct bPARTblock part;
484 struct bFSHDblock fshd;
485 struct bLSEGblock lseg;
486 SECTNUM j;
487 int len;
488
489
490 /* RDSK */
491
492 memset((uint8_t*)&rdsk,0,sizeof(struct bRDSKblock));
493
494 rdsk.rdbBlockLo = 0;
495 rdsk.rdbBlockHi = (dev->sectors*dev->heads*2)-1;
496 rdsk.loCylinder = 2;
497 rdsk.hiCylinder = dev->cylinders-1;
498 rdsk.cylBlocks = dev->sectors*dev->heads;
499
500 rdsk.cylinders = dev->cylinders;
501 rdsk.sectors = dev->sectors;
502 rdsk.heads = dev->heads;
503
504 rdsk.badBlockList = -1;
505 rdsk.partitionList = 1;
506 rdsk.fileSysHdrList = 1 + dev->nVol;
507
508 if (adfWriteRDSKblock(dev, &rdsk)!=RC_OK)
509 return RC_ERROR;
510
511 /* PART */
512
513 j=1;
514 for(i=0; i<dev->nVol; i++) {
515 memset(&part, 0, sizeof(struct bPARTblock));
516
517 if (i<dev->nVol-1)
518 part.next = j+1;
519 else
520 part.next = -1;
521
522 len = min(MAXNAMELEN,strlen(partList[i]->volName));
523 part.nameLen = len;
524 strncpy(part.name, partList[i]->volName, len);
525
526 part.surfaces = dev->heads;
527 part.blocksPerTrack = dev->sectors;
528 part.lowCyl = partList[i]->startCyl;
529 part.highCyl = partList[i]->startCyl + partList[i]->lenCyl -1;
530 strncpy(part.dosType, "DOS", 3);
531
532 part.dosType[3] = partList[i]->volType & 0x01;
533
534 if (adfWritePARTblock(dev, j, &part))
535 return RC_ERROR;
536 j++;

Callers 1

adfCreateHdFunction · 0.85

Calls 4

adfWriteRDSKblockFunction · 0.85
adfWritePARTblockFunction · 0.85
adfWriteFSHDblockFunction · 0.85
adfWriteLSEGblockFunction · 0.85

Tested by

no test coverage detected