end = (offset + size) >> 9;
start = offset >> 9;
+ /* check if the partition table fits into the device */
+ for (i = 0; i < nparts; i++) {
+ blkid_partition par = &ls->parts[i];
+
+ if (par->start + par->size > pr->size) {
+ DBG(DEBUG_LOWPROBE, printf("partition #%d overflows "
+ "device (off=%lu size=%lu)\n",
+ par->partno, par->start, par->size));
+ goto done;
+ }
+ }
+
+ /* check if the requested area is covered by PT */
for (i = 0; i < nparts; i++) {
blkid_partition par = &ls->parts[i];
uint32_t ints[4];
uint8_t bytes[16];
} uuid;
+ uint32_t ma, mi, pa;
if (pr->size < 0x10000)
return -1;
uuid.ints[2] = swab32(mdp0->set_uuid2);
uuid.ints[3] = swab32(mdp0->set_uuid3);
}
- if (blkid_probe_sprintf_version(pr, "%u.%u.%u",
- le32_to_cpu(mdp0->major_version),
- le32_to_cpu(mdp0->minor_version),
- le32_to_cpu(mdp0->patch_version)) != 0)
- return -1;
+ ma = le32_to_cpu(mdp0->major_version);
+ mi = le32_to_cpu(mdp0->minor_version);
+ pa = le32_to_cpu(mdp0->patch_version);
} else if (be32_to_cpu(mdp0->md_magic) == MD_SB_MAGIC) {
uuid.ints[0] = mdp0->set_uuid0;
uuid.ints[2] = mdp0->set_uuid2;
uuid.ints[3] = mdp0->set_uuid3;
}
- if (blkid_probe_sprintf_version(pr, "%u.%u.%u",
- be32_to_cpu(mdp0->major_version),
- be32_to_cpu(mdp0->minor_version),
- be32_to_cpu(mdp0->patch_version)) != 0)
- return -1;
+ ma = be32_to_cpu(mdp0->major_version);
+ mi = be32_to_cpu(mdp0->minor_version);
+ pa = be32_to_cpu(mdp0->patch_version);
} else
- return -1;
+ return 1;
+ /*
+ * Check for collisions between RAID and partition table
+ */
+ if ((S_ISREG(pr->mode) || blkid_probe_is_wholedisk(pr)) &&
+ blkid_probe_is_covered_by_pt(pr, off, 0x200)) {
+ /* ignore this superblock, it's within any partition and
+ * we are working with whole-disk now */
+ return 1;
+ }
+
+ if (blkid_probe_sprintf_version(pr, "%u.%u.%u", ma, mi, pa) != 0)
+ return -1;
if (blkid_probe_set_uuid(pr, (unsigned char *) uuid.bytes) != 0)
return -1;
if (blkid_probe_set_magic(pr, off, sizeof(mdp0->md_magic),
superblocks_copy_data(chn->data, sb);
chn->idx = idx;
- /*
- * Check for collisions between RAID and partition table
- */
- if (sb && sb->usage == BLKID_USAGE_RAID &&
- sb->magic_off > pr->size / 2 &&
- (S_ISREG(pr->mode) || blkid_probe_is_wholedisk(pr)) &&
- blkid_probe_is_covered_by_pt(pr, sb->magic_off, 0x200)) {
- /*
- * Ignore the result if the detected RAID superblock is
- * within some existing partition (for example RAID on
- * the last partition).
- */
- blkid_probe_chain_reset_vals(pr, chn);
- return 1;
- }
-
/*
* The RAID device could be partitioned. The problem are RAID1 devices
* where the partition table is visible from underlaying devices. We