Lines Matching defs:header
223 cout << "\nProblem: The CRC for the main GPT header is invalid. The main GPT header may\n"
224 << "be corrupt. Consider loading the backup GPT header to rebuild the main GPT\n"
225 << "header ('b' on the recovery & transformation menu). This report may be a false\n"
237 cout << "\nProblem: The CRC for the backup GPT header is invalid. The backup GPT header\n"
238 << "may be corrupt. Consider using the main GPT header to rebuild the backup GPT\n"
239 << "header ('d' on the recovery & transformation menu). This report may be a false\n"
252 cout << "\nProblem: The main header's self-pointer doesn't point to itself. This problem\n"
259 cout << "\nProblem: The secondary header's self-pointer indicates that it doesn't reside\n"
261 << "option on the experts' menu to adjust the secondary header's and partition\n"
268 cout << "\nProblem: main GPT header's current LBA pointer (" << mainHeader.currentLBA
269 << ") doesn't\nmatch the backup GPT header's alternate LBA pointer("
274 cout << "\nProblem: main GPT header's backup LBA pointer (" << mainHeader.backupLBA
275 << ") doesn't\nmatch the backup GPT header's current LBA pointer ("
281 cout << "\nProblem: main GPT header's first usable LBA pointer (" << mainHeader.firstUsableLBA
282 << ") doesn't\nmatch the backup GPT header's first usable LBA pointer ("
287 cout << "\nProblem: main GPT header's last usable LBA pointer (" << mainHeader.lastUsableLBA
288 << ") doesn't\nmatch the backup GPT header's last usable LBA pointer ("
294 cout << "\nProblem: main header's disk GUID (" << mainHeader.diskGUID
295 << ") doesn't\nmatch the backup GPT header's disk GUID ("
298 << "select one or the other header.\n";
302 cout << "\nProblem: main GPT header's number of partitions (" << mainHeader.numParts
303 << ") doesn't\nmatch the backup GPT header's number of partitions ("
309 cout << "\nProblem: main GPT header's size of partition entries ("
311 << "match the backup GPT header's size of partition entries ("
314 << "select one or the other header.\n";
340 cout << "\nProblem: The backup partition table overlaps the backup header.\n"
376 << "sector is " << mainHeader.lastUsableLBA << ", but backup header is at\n"
504 // Check the validity of the GPT header. Returns 1 if the main header
505 // is valid, 2 if the backup header is valid, 3 if both are valid, and
520 cout << "Unsupported GPT version in main header; read 0x";
531 cout << "Unsupported GPT version in backup header; read 0x";
548 // Check the header CRC to see if it's OK...
549 // Note: Must be called with header in platform-ordered byte order.
550 // Returns 1 if header's computed CRC matches the stored value, 0 if the
552 int GPTData::CheckHeaderCRC(struct GPTHeader* header, int warn) {
556 // Back up old header CRC and then blank it, since it must be 0 for
558 oldCRC = header->headerCRC;
559 header->headerCRC = UINT32_C(0);
561 hSize = header->headerSize;
564 ReverseHeaderBytes(header);
569 cerr << "Setting the header size for CRC computation to " << HEADER_SIZE << "\n";
574 cout << "If stray data exists after the header on the header sector, it will be ignored,\n"
581 memcpy(temp, header, hSize);
583 memcpy(temp, header, sizeof(GPTHeader));
592 ReverseHeaderBytes(header);
593 header->headerCRC = oldCRC;
604 // If the header size is bigger than the GPT header data structure, reset it;
605 // otherwise, set both header sizes to whatever the main one is....
646 // Rebuild the main GPT header, using the secondary header as a model.
647 // Typically called when the main header has been found to be corrupt.
668 // Rebuild the secondary GPT header, using the main header as a model.
933 cout << "Warning! Disk size is smaller than the main header indicates! Loading\n"
934 << "secondary header from the last sector of the disk! You should use 'v' to\n"
941 // Return valid headers code: 0 = both headers bad; 1 = main header
942 // good, backup bad; 2 = backup header good, main header bad;
948 if (validHeaders > 0) { // if at least one header is OK....
955 if (validHeaders == 1) { // valid main header, invalid backup header
956 cerr << "\aCaution: invalid backup GPT header, but valid main header; regenerating\n"
957 << "backup header from main header.\n\n";
961 } else if (validHeaders == 2) { // valid backup header, invalid main header
962 cerr << "\aCaution: invalid main GPT header, but valid backup; regenerating main header\n"
970 // Load the main partition table, if its header's CRC is OK
974 } else { // bad main header CRC and backup header CRC is OK
978 cerr << "\aWarning: Invalid CRC on main header data; loaded backup partition table.\n";
979 } else { // backup table bad, bad main header CRC, but try main table in desperation....
1008 // Show detail status of header and table
1010 cerr << "Main header: OK\n";
1012 cerr << "Main header: ERROR\n";
1014 cerr << "Backup header: OK\n";
1016 cerr << "Backup header: ERROR\n";
1034 // Loads the partition table pointed to by the main GPT header. The
1035 // main GPT header in memory MUST be valid for this call to do anything
1050 // Load a single GPT header (main or backup) from the specified disk device and
1055 int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector, int *crcOk) {
1079 cerr << "Warning: Partition table header claims that the size of partition table\n";
1091 *header = tempHeader;
1096 // using header as a reference for what to load. If sector != 0 (the default
1098 // indicated in header.
1100 int GPTData::LoadPartitionTable(const struct GPTHeader & header, DiskIO & disk, uint64_t sector) {
1104 if (header.sizeOfPartitionEntries != sizeof(GPTPart)) {
1105 cerr << "Error! GPT header contains invalid partition entry size!\n";
1109 retval = disk.Seek(header.partitionEntriesLBA);
1114 retval = SetGPTSize(header.numParts, 0);
1116 sizeOfParts = header.numParts * header.sizeOfPartitionEntries;
1122 mainPartsCrcOk = secondPartsCrcOk = (newCRC == header.partitionEntriesCRC);
1139 // Check the partition table pointed to by header, but don't keep it
1143 int GPTData::CheckTable(struct GPTHeader *header) {
1152 if (myDisk.Seek(header->partitionEntriesLBA)) {
1153 partsToCheck = new GPTPart[header->numParts];
1154 sizeOfParts = header->numParts * header->sizeOfPartitionEntries;
1163 allOK = (newCRC == header->partitionEntriesCRC);
1164 if (header == &mainHeader)
1180 // header later on the disk without asking for permission, if necessary, and
1182 // before moving the second header and asks for final confirmation of any
1197 // Check that disk is really big enough to handle the second header...
1199 cerr << "Caution! Secondary header was placed beyond the disk's limits! Moving the\n"
1200 << "header, but other problems may occur!\n";
1210 // Check that second header is properly placed. Warn and ask if this should
1214 cout << "Warning! Secondary header is placed too early on the disk! Do you want to\n"
1218 cout << "Have moved second header and partition table to correct location.\n";
1233 cout << "Have adjusted the second header and last usable sector value.\n";
1282 // Now write the secondary GPT header...
1288 // Now write the main GPT header...
1328 // the main GPT header, the backup GPT header, and the main partition
1371 // Write a GPT header (main or backup) to the specified sector. Used by both
1373 // Should be passed an architecture-appropriate header (DO NOT call
1374 // ReverseHeaderBytes() on the header before calling this function)
1376 int GPTData::SaveHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector) {
1381 ReverseHeaderBytes(header);
1383 if (disk.Write(header, 512) == -1)
1387 ReverseHeaderBytes(header);
1393 // Should be passed an architecture-appropriate header (DO NOT call
1394 // ReverseHeaderBytes() on the header before calling this function)
1427 // Check backup file size and rebuild second header if file is right
1428 // size to be direct dd copy of MBR, main header, and main partition
1440 // Return valid headers code: 0 = both headers bad; 1 = main header
1441 // good, backup bad; 2 = backup header good, main header bad;
1446 if (val == 2) { // only backup header seems to be good
1448 } else { // main header is OK
1497 cerr << "Warning! GPT main header not overwritten! Error is " << errno << "\n";
1530 cerr << "Warning! GPT backup header not overwritten! Error is " << errno << "\n";
2064 // Copy main header to backup header
2079 // Set the location of the second GPT header data to the end of the disk.
2114 // Set the disk GUID to the specified value. Note that the header CRCs must
2557 void GPTData::ReverseHeaderBytes(struct GPTHeader* header) {
2558 ReverseBytes(&header->signature, 8);
2559 ReverseBytes(&header->revision, 4);
2560 ReverseBytes(&header->headerSize, 4);
2561 ReverseBytes(&header->headerCRC, 4);
2562 ReverseBytes(&header->reserved, 4);
2563 ReverseBytes(&header->currentLBA, 8);
2564 ReverseBytes(&header->backupLBA, 8);
2565 ReverseBytes(&header->firstUsableLBA, 8);
2566 ReverseBytes(&header->lastUsableLBA, 8);
2567 ReverseBytes(&header->partitionEntriesLBA, 8);
2568 ReverseBytes(&header->numParts, 4);
2569 ReverseBytes(&header->sizeOfPartitionEntries, 4);
2570 ReverseBytes(&header->partitionEntriesCRC, 4);
2571 ReverseBytes(header->reserved2, GPT_RESERVED);