| 102 | } |
| 103 | |
| 104 | static std::vector<unsigned> expandSectorList( |
| 105 | const SectorListProto& sectorsProto) |
| 106 | { |
| 107 | std::vector<unsigned> sectors; |
| 108 | |
| 109 | if (sectorsProto.has_count()) |
| 110 | { |
| 111 | if (sectorsProto.sector_size() != 0) |
| 112 | error( |
| 113 | "LAYOUT: if you use a sector count, you can't use an " |
| 114 | "explicit sector list"); |
| 115 | |
| 116 | std::set<unsigned> sectorset; |
| 117 | int id = sectorsProto.start_sector(); |
| 118 | for (int i = 0; i < sectorsProto.count(); i++) |
| 119 | { |
| 120 | while (sectorset.find(id) != sectorset.end()) |
| 121 | { |
| 122 | id++; |
| 123 | if (id >= (sectorsProto.start_sector() + sectorsProto.count())) |
| 124 | id -= sectorsProto.count(); |
| 125 | } |
| 126 | |
| 127 | sectorset.insert(id); |
| 128 | sectors.push_back(id); |
| 129 | |
| 130 | id += sectorsProto.skew(); |
| 131 | if (id >= (sectorsProto.start_sector() + sectorsProto.count())) |
| 132 | id -= sectorsProto.count(); |
| 133 | } |
| 134 | } |
| 135 | else if (sectorsProto.sector_size() > 0) |
| 136 | { |
| 137 | for (int sectorId : sectorsProto.sector()) |
| 138 | sectors.push_back(sectorId); |
| 139 | } |
| 140 | else |
| 141 | error("LAYOUT: no sectors in sector definition!"); |
| 142 | |
| 143 | return sectors; |
| 144 | } |
| 145 | |
| 146 | static const LayoutProto::LayoutdataProto getLayoutData( |
| 147 | unsigned logicalCylinder, unsigned logicalHead, const ConfigProto& config) |