/* * Protective (legacy) MBR. * * This MBR contains standard DOS partition table with a single partition, type * of 0xEE. The partition usually encompassing the entire GPT drive - or 2TiB * for large disks. * * Note that Apple uses GPT/MBR hybrid disks, where the DOS partition table is * synchronized with GPT. This synchronization has many restriction of course * (due DOS PT limitations). * * Note that the PMBR detection is optional (enabled by default) and could be * disabled by BLKID_PARTS_FOPCE_GPT flag (see also blkid_partitions_set_flags()). */ static int is_pmbr_valid(blkid_probe pr, int *has) { int flags = blkid_partitions_get_flags(pr); unsigned char *data; struct dos_partition *p; int i; if (has) *has = 0; if (flags & BLKID_PARTS_FORCE_GPT) goto ok; /* skip PMBR check */ data = blkid_probe_get_sector(pr, 0); if (!data) { if (errno) return -errno; goto failed; } if (!mbr_is_valid_magic(data)) goto failed; for (i = 0, p = mbr_get_partition(data, 0); i < 4; i++, p++) { if (p->sys_ind == MBR_GPT_PARTITION) goto ok; } failed: return 0; ok: if (has) *has = 1; return 1; }
/* * Protective (legacy) MBR. * * This MBR contains standard DOS partition table with a single partition, type * of 0xEE. The partition usually encompassing the entire GPT drive - or 2TiB * for large disks. * * Note that Apple uses GPT/MBR hybrid disks, where the DOS partition table is * synchronized with GPT. This synchronization has many restriction of course * (due DOS PT limitations). * * Note that the PMBR detection is optional (enabled by default) and could be * disabled by BLKID_PARTS_FOPCE_GPT flag (see also blkid_paertitions_set_flags()). */ static int is_pmbr_valid(blkid_probe pr) { int flags = blkid_partitions_get_flags(pr); unsigned char *data; struct dos_partition *p; int i; if (flags & BLKID_PARTS_FORCE_GPT) goto ok; /* skip PMBR check */ data = blkid_probe_get_sector(pr, 0); if (!data) goto failed; if (!is_valid_mbr_signature(data)) goto failed; p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET); for (i = 0; i < 4; i++, p++) { if (p->sys_type == BLKID_GPT_PARTITION) goto ok; } failed: return 0; ok: return 1; }