static int probe_viaraid(blkid_probe pr, const struct blkid_idmag *mag) { uint64_t off; struct via_metadata *v; if (pr->size < 0x10000) return -1; if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) return -1; off = ((pr->size / 0x200)-1) * 0x200; v = (struct via_metadata *) blkid_probe_get_buffer(pr, off, sizeof(struct via_metadata)); if (!v) return -1; if (le16_to_cpu(v->signature) != VIA_SIGNATURE) return -1; if (v->version_number > 2) return -1; if (!via_checksum(v)) return -1; if (blkid_probe_sprintf_version(pr, "%u", v->version_number) != 0) return -1; if (blkid_probe_set_magic(pr, off, sizeof(v->signature), (unsigned char *) &v->signature)) return -1; return 0; }
static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es) { struct blkid_chain *chn = blkid_probe_get_chain(pr); DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", le32_to_cpu(es->s_feature_compat), le32_to_cpu(es->s_feature_incompat), le32_to_cpu(es->s_feature_ro_compat))); if (strlen(es->s_volume_name)) blkid_probe_set_label(pr, (unsigned char *) es->s_volume_name, sizeof(es->s_volume_name)); blkid_probe_set_uuid(pr, es->s_uuid); if (le32_to_cpu(es->s_feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) blkid_probe_set_uuid_as(pr, es->s_journal_uuid, "EXT_JOURNAL"); if (ver != 2 && (chn->flags & BLKID_SUBLKS_SECTYPE) && ((le32_to_cpu(es->s_feature_incompat) & EXT2_FEATURE_INCOMPAT_UNSUPPORTED) == 0)) blkid_probe_set_value(pr, "SEC_TYPE", (unsigned char *) "ext2", sizeof("ext2")); blkid_probe_sprintf_version(pr, "%u.%u", le32_to_cpu(es->s_rev_level), le16_to_cpu(es->s_minor_rev_level)); }
static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) { struct exfat_super_block *sb; struct exfat_entry_label *label; sb = blkid_probe_get_sb(pr, mag, struct exfat_super_block); if (!sb || !CLUSTER_SIZE(sb)) return errno ? -errno : BLKID_PROBE_NONE; label = find_label(pr, sb); if (label) blkid_probe_set_utf8label(pr, label->name, min(label->length * 2, 30), BLKID_ENC_UTF16LE); else if (errno) return -errno; blkid_probe_sprintf_uuid(pr, sb->volume_serial, 4, "%02hhX%02hhX-%02hhX%02hhX", sb->volume_serial[3], sb->volume_serial[2], sb->volume_serial[1], sb->volume_serial[0]); blkid_probe_sprintf_version(pr, "%u.%u", sb->version.vermaj, sb->version.vermin); return BLKID_PROBE_OK; }
static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag) { unsigned char *ext; const unsigned char *data; int version = 0, swabme = 0; data = blkid_probe_get_buffer(pr, 1024, max(sizeof(struct minix_super_block), sizeof(struct minix3_super_block))); if (!data) return errno ? -errno : 1; version = get_minix_version(data, &swabme); if (version < 1) return 1; if (version <= 2) { struct minix_super_block *sb = (struct minix_super_block *) data; int zones, ninodes, imaps, zmaps, firstz; if (sb->s_imap_blocks == 0 || sb->s_zmap_blocks == 0 || sb->s_log_zone_size != 0) return 1; zones = version == 2 ? minix_swab32(swabme, sb->s_zones) : minix_swab16(swabme, sb->s_nzones); ninodes = minix_swab16(swabme, sb->s_ninodes); imaps = minix_swab16(swabme, sb->s_imap_blocks); zmaps = minix_swab16(swabme, sb->s_zmap_blocks); firstz = minix_swab16(swabme, sb->s_firstdatazone); /* sanity checks to be sure that the FS is really minix */ if (imaps * MINIX_BLOCK_SIZE * 8 < ninodes + 1) return 1; if (zmaps * MINIX_BLOCK_SIZE * 8 < zones - firstz + 1) return 1; } else if (version == 3) { struct minix3_super_block *sb = (struct minix3_super_block *) data; if (sb->s_imap_blocks == 0 || sb->s_zmap_blocks == 0) return 1; } /* unfortunately, some parts of ext3 is sometimes possible to * interpreted as minix superblock. So check for extN magic * string. (For extN magic string and offsets see ext.c.) */ ext = blkid_probe_get_buffer(pr, 0x400 + 0x38, 2); if (!ext) return errno ? -errno : 1; else if (memcmp(ext, "\123\357", 2) == 0) return 1; blkid_probe_sprintf_version(pr, "%d", version); return 0; }
static int probe_iswraid(blkid_probe pr, const struct blkid_idmag *mag) { uint64_t off; struct isw_metadata *isw; if (pr->size < 0x10000) return -1; off = ((pr->size / 0x200) - 2) * 0x200; isw = (struct isw_metadata *) blkid_probe_get_buffer(pr, off, sizeof(struct isw_metadata)); if (!isw) return -1; if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0) return -1; if (blkid_probe_sprintf_version(pr, "%6s", &isw->sig[sizeof(ISW_SIGNATURE)-1]) != 0) return -1; return 0; }
static int probe_nvraid(blkid_probe pr, const struct blkid_idmag *mag) { uint64_t off; struct nv_metadata *nv; if (pr->size < 0x10000) return -1; off = ((pr->size / 0x200) - 2) * 0x200; nv = (struct nv_metadata *) blkid_probe_get_buffer(pr, off, sizeof(struct nv_metadata)); if (!nv) return -1; if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0) return -1; if (blkid_probe_sprintf_version(pr, "%u", le16_to_cpu(nv->version)) != 0) return -1; return 0; }