cgpt/cgpt_find.c
// check partition data content. return true for match, 0 for no match or error
check partition data content. return true for match, 0 for no match or error
check partition data content . return true for match 0 for no match or error
static int match_content(CgptFindParams *params, struct drive *drive,
                             GptEntry *entry) {
  uint64_t part_size;
  if (!params->matchlen)
    return 1;
  part_size = drive->gpt.sector_bytes *
    (entry->ending_lba - entry->starting_lba + 1);
  if (params->matchoffset + params->matchlen > part_size) {
    return 0;
  }
  if (!FillBuffer(params, drive->fd,
    (drive->gpt.sector_bytes * entry->starting_lba) + params->matchoffset,
                  params->matchlen)) {
    Error("unable to read partition data\n");
    return 0;
  }
  if (0 == memcmp(params->matchbuf, params->comparebuf, params->matchlen)) {
    return 1;
  }
  return 0;
}
static int match_content ( CgptFindParams * params , struct drive * drive , GptEntry * entry ) { uint64_t part_size ; if ( ! params -> matchlen ) return 1 ; part_size = drive -> gpt . sector_bytes * ( entry -> ending_lba - entry -> starting_lba + 1 ) ; if ( params -> matchoffset + params -> matchlen > part_size ) { return 0 ; } if ( ! FillBuffer ( params , drive -> fd , ( drive -> gpt . sector_bytes * entry -> starting_lba ) + params -> matchoffset , params -> matchlen ) ) { Error ( " \n " ) ; return 0 ; } if ( 0 == memcmp ( params -> matchbuf , params -> comparebuf , params -> matchlen ) ) { return 1 ; } return 0 ; }
check partition data content.
check partition data content .
// Ensure that the region we want to match against is inside the partition. // Read the partition data. // Compare it // Nope.