UINTN showpart(VOID) { UINTN status = 0; UINTN status_gpt, status_mbr; // get full information from disk status_gpt = read_gpt(); status_mbr = read_mbr(); if (status_gpt != 0 || status_mbr != 0) return (status_gpt || status_mbr); // analyze all partitions status = analyze_parts(); if (status != 0) return status; return status; }
static int read_partitions(struct biosdisk *d) { int error; error = -1; #ifndef NO_GPT error = read_gpt(d); if (error == 0) return 0; #endif #ifndef NO_DISKLABEL error = read_label(d); #endif return error; }
UINTN gptsync(VOID) { UINTN status = 0; UINTN status_gpt, status_mbr; BOOLEAN proceed = FALSE; Print(L"gptsync version %s\ncopyright (c) 2006-2007 Christoph Pfisterer & 2013 Roderick W. Smith\n", VERSION); // get full information from disk status_gpt = read_gpt(); status_mbr = read_mbr(); if (status_gpt != 0 || status_mbr != 0) return (status_gpt || status_mbr); // cross-check current situation Print(L"\n"); status = check_gpt(); // check GPT for consistency if (status != 0) return status; status = check_mbr(); // check MBR for consistency if (status != 0) return status; status = analyze(); // analyze the situation & compose new MBR table if (status != 0) return status; if (new_mbr_part_count == 0) return status; // offer user the choice what to do status = input_boolean(STR("\nMay I update the MBR as printed above? [y/N] "), &proceed); if (status != 0 || proceed != TRUE) return status; // adjust the MBR and write it back status = write_mbr(); if (status != 0) return status; return status; }
UINTN gptsync(int optind, int argc, char **argv) { UINTN status = 0; UINTN status_gpt, status_mbr; BOOLEAN proceed = FALSE; // get full information from disk status_gpt = read_gpt(); status_mbr = read_mbr(); if (status_gpt != 0 || status_mbr != 0) return (status_gpt || status_mbr); // cross-check current situation Print(L"\n"); status = check_gpt(); // check GPT for consistency if (status != 0) return status; status = check_mbr(); // check MBR for consistency if (status != 0) return status; status = analyze(optind, argc, argv); // analyze the situation & compose new MBR table if (status != 0) return status; // offer user the choice what to do status = input_boolean(STR("\nMay I update the MBR as printed above? [y/N] "), &proceed); if (status != 0 || proceed != TRUE) return status; // adjust the MBR and write it back status = write_mbr(); if (status != 0) return status; return status; }