コード例 #1
0
int check_dos_label(struct fdisk_context *cxt)
{
	int i;

	if (!valid_part_table_flag(cxt->mbr))
		return 0;

	dos_init(cxt);

	for (i = 0; i < 4; i++) {
		struct pte *pe = &ptes[i];

		if (IS_EXTENDED (pe->part_table->sys_ind)) {
			if (partitions != 4)
				fprintf(stderr, _("Ignoring extra extended "
					"partition %d\n"), i + 1);
			else
				read_extended(cxt, i);
		}
	}

	for (i = 3; i < partitions; i++) {
		struct pte *pe = &ptes[i];

		if (!valid_part_table_flag(pe->sectorbuffer)) {
			fprintf(stderr,
				_("Warning: invalid flag 0x%04x of partition "
				"table %d will be corrected by w(rite)\n"),
				part_table_flag(pe->sectorbuffer), i + 1);
			pe->changed = 1;
		}
	}

	return 1;
}
コード例 #2
0
ファイル: asr.c プロジェクト: Distrotech/dmraid
/*
 * Attempt to interpret ASR metadata from a block device.  This function
 * returns either NULL (not an ASR) or a pointer to a descriptor struct.
 * Note that the struct should be fully converted to the correct endianness
 * by the time this function returns.
 *
 * WARNING: If you take disks out of an ASR HostRAID array and plug them in
 * to a normal SCSI controller, the array will still show up!  Even if you
 * scribble over the disks!  I assume that the a320raid binary driver only
 * does its HostRAID magic if your controller is in RAID mode... but dmraid
 * lacks this sort of visibility as to where its block devices come from.
 * This is EXTREMELY DANGEROUS if you aren't careful!
 */
static void *
read_metadata_areas(struct lib_context *lc, struct dev_info *di,
		    size_t * sz, uint64_t * offset, union read_info *info)
{
	size_t size = ASR_DISK_BLOCK_SIZE;
	uint64_t asr_sboffset = ASR_CONFIGOFFSET;
	struct asr *asr;
	struct asr_raid_configline *cl;

	/*
	 * Read the ASR reserved block on each disk.  This is the very
	 * last sector of the disk, and we're really only interested in
	 * the two magic numbers, the version, and the pointer to the
	 * RAID table.  Everything else appears to be unused in v8.
	 */
	if (!(asr = alloc_private(lc, handler, sizeof(*asr))))
		goto bad0;

	if (!(asr->rt = alloc_private(lc, handler, sizeof(*asr->rt))))
		goto bad1;

	if (!read_file(lc, handler, di->path, &asr->rb, size, asr_sboffset))
		goto bad2;

	/*
	 * Convert metadata and read in 
	 */
	to_cpu(asr, ASR_BLOCK);

	/* Check Signature and read optional extended metadata. */
	if (!is_asr(lc, di, asr) || !read_extended(lc, di, asr))
		goto bad2;

	/*
	 * Now that we made sure that we have all the metadata, we exit.
	 */
	cl = this_disk(asr);
	if (cl->raidstate == LSU_COMPONENT_STATE_FAILED)
		goto bad2;

	goto out;

      bad2:
	dbg_free(asr->rt);
      bad1:
	asr->rt = NULL;
	dbg_free(asr);
      bad0:
	asr = NULL;

      out:
	return asr;
}