예제 #1
0
void CgptFind(CgptFindParams *params) {
  if (params == NULL)
    return;

  if (params->drive_name != NULL)
    do_search(params, params->drive_name);
  else
    scan_real_devs(params);
}
예제 #2
0
int CgptNext(CgptNextParams *params) {
  struct drive drive;
  GptEntry *entry;
  char tmp[64];
  int tries;
  next_index = -1;
  int gpt_retval;

  if (params == NULL)
    return CGPT_FAILED;

  if (params->drive_name) {
    do_search(params);
  } else {
    scan_real_devs(params);
  }

  if (strlen(next_file_name) < 0) {
    return CGPT_FAILED;
  }

  if (DriveOpen(next_file_name, &drive, 0, O_RDWR) == CGPT_OK) {
    if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) {
      Error("GptSanityCheck() returned %d: %s\n",
            gpt_retval, GptError(gpt_retval));
      return CGPT_FAILED;
    }

    // Decrement tries if we selected on that criteria
    tries = GetTries(&drive, PRIMARY, next_index);
    if (tries > 0) {
      tries--;
    }
    SetTries(&drive, PRIMARY, next_index, tries);

    // Print out the next disk to go!
    entry = GetEntry(&drive.gpt, ANY_VALID, next_index);
    GuidToStrLower(&entry->unique, tmp, sizeof(tmp));
    printf("%s\n", tmp);

    // Write it all out
    UpdateAllEntries(&drive);
    return DriveClose(&drive, 1);
  }

  return 1;
}