| 294 | }; |
| 295 | |
| 296 | static CombinationResult combineRecordAndSectors( |
| 297 | std::vector<std::shared_ptr<const Track>>& tracks, |
| 298 | Decoder& decoder, |
| 299 | const std::shared_ptr<const LogicalTrackLayout>& ltl) |
| 300 | { |
| 301 | CombinationResult cr = {HAS_NO_BAD_SECTORS}; |
| 302 | std::vector<std::shared_ptr<const Sector>> track_sectors; |
| 303 | |
| 304 | /* Add the sectors which were there. */ |
| 305 | |
| 306 | for (auto& track : tracks) |
| 307 | for (auto& sector : track->allSectors) |
| 308 | track_sectors.push_back(sector); |
| 309 | |
| 310 | /* Add the sectors which should be there. */ |
| 311 | |
| 312 | for (unsigned sectorId : ltl->diskSectorOrder) |
| 313 | { |
| 314 | auto sector = std::make_shared<Sector>( |
| 315 | LogicalLocation{ltl->logicalCylinder, ltl->logicalHead, sectorId}); |
| 316 | |
| 317 | sector->status = Sector::MISSING; |
| 318 | sector->physicalLocation = std::make_optional( |
| 319 | CylinderHead(ltl->physicalCylinder, ltl->physicalHead)); |
| 320 | track_sectors.push_back(sector); |
| 321 | } |
| 322 | |
| 323 | /* Deduplicate. */ |
| 324 | |
| 325 | cr.sectors = collectSectors(track_sectors); |
| 326 | if (cr.sectors.empty()) |
| 327 | cr.result = HAS_BAD_SECTORS; |
| 328 | for (const auto& sector : cr.sectors) |
| 329 | if (sector->status != Sector::OK) |
| 330 | cr.result = HAS_BAD_SECTORS; |
| 331 | |
| 332 | return cr; |
| 333 | } |
| 334 | |
| 335 | static void adjustTrackOnError(FluxSource& fluxSource, int baseTrack) |
| 336 | { |
no test coverage detected