* adfMountHdFile * */
| 147 | * |
| 148 | */ |
| 149 | RETCODE adfMountHdFile(struct Device *dev) |
| 150 | { |
| 151 | struct Volume* vol; |
| 152 | uint8_t buf[512]; |
| 153 | int32_t size; |
| 154 | BOOL found; |
| 155 | |
| 156 | dev->devType = DEVTYPE_HARDFILE; |
| 157 | dev->nVol = 0; |
| 158 | dev->volList = (struct Volume**)malloc(sizeof(struct Volume*)); |
| 159 | if (!dev->volList) { |
| 160 | (*adfEnv.eFct)("adfMountHdFile : malloc"); |
| 161 | return RC_ERROR; |
| 162 | } |
| 163 | |
| 164 | vol=(struct Volume*)malloc(sizeof(struct Volume)); |
| 165 | if (!vol) { |
| 166 | (*adfEnv.eFct)("adfMountHdFile : malloc"); |
| 167 | return RC_ERROR; |
| 168 | } |
| 169 | dev->volList[0] = vol; |
| 170 | dev->nVol++; /* fixed by Dan, ... and by Gary */ |
| 171 | |
| 172 | vol->volName=NULL; |
| 173 | |
| 174 | dev->cylinders = dev->size/512; |
| 175 | dev->heads = 1; |
| 176 | dev->sectors = 1; |
| 177 | |
| 178 | vol->firstBlock = 0; |
| 179 | |
| 180 | size = dev->size + 512-(dev->size%512); |
| 181 | /*printf("size=%ld\n",size);*/ |
| 182 | vol->rootBlock = (size/512)/2; |
| 183 | /*printf("root=%ld\n",vol->rootBlock);*/ |
| 184 | do { |
| 185 | adfReadDumpSector(dev, vol->rootBlock, 512, buf); |
| 186 | found = swapLong(buf)==T_HEADER && swapLong(buf+508)==ST_ROOT; |
| 187 | if (!found) |
| 188 | (vol->rootBlock)--; |
| 189 | }while (vol->rootBlock>1 && !found); |
| 190 | |
| 191 | if (vol->rootBlock==1) { |
| 192 | (*adfEnv.eFct)("adfMountHdFile : rootblock not found"); |
| 193 | return RC_ERROR; |
| 194 | } |
| 195 | vol->lastBlock = vol->rootBlock*2 - 1 ; |
| 196 | |
| 197 | return RC_OK; |
| 198 | } |
| 199 | |
| 200 | |
| 201 | /* |
no test coverage detected