示例#1
0
static int
pc98_probe (const PedDevice *dev)
{
	PC98RawTable		part_table;
	int			empty;
	const PC98RawPartition*	p;

	PED_ASSERT (dev != NULL);

        if (dev->sector_size != 512)
                return 0;

	if (!ped_device_read (dev, &part_table, 0, 2))
		return 0;

	/* check magic */
	if (!pc98_check_magic (&part_table))
		return 0;

	/* check consistency */
	empty = 1;
	for (p = part_table.partitions;
	     p < part_table.partitions + MAX_PART_COUNT;
	     p++)
	{
		if (p->mid == 0 && p->sid == 0)
			continue;
		empty = 0;
		if (!check_partition_consistency (dev, p))
			return 0;
	}

	/* check boot loader */
	if (pc98_check_ipl_signature (&part_table))
		return 1;
	else if (part_table.boot_code[0])	/* invalid boot loader */
		return 0;

	/* Not to mistake msdos disk map for PC-9800's empty disk map  */
	if (empty)
		return 0;

	return 1;
}
示例#2
0
文件: pc98.c 项目: Excito/parted
static int
pc98_probe (const PedDevice *dev)
{
	PC98RawTable		part_table;

	PED_ASSERT (dev != NULL);

        if (dev->sector_size != 512)
                return 0;

	if (!ped_device_read (dev, &part_table, 0, 2))
		return 0;

	/* check magic */
	if (!pc98_check_magic (&part_table))
		return 0;

	/* check for boot loader signatures */
	return pc98_check_ipl_signature (&part_table);
}
示例#3
0
文件: pc98.c 项目: Excito/parted
static int
pc98_write (const PedDisk* disk)
{
	PedPartition*		part;
	int			i;

	PED_ASSERT (disk != NULL);
	PED_ASSERT (disk->dev != NULL);

	void *s0;
	if (!ptt_read_sectors (disk->dev, 0, 2, &s0))
		return 0;
	PC98RawTable *table = s0;

	if (!pc98_check_ipl_signature (table)) {
		memset (table->boot_code, 0, sizeof(table->boot_code));
		memcpy (table->boot_code, MBR_BOOT_CODE, sizeof(MBR_BOOT_CODE));
	}

	memset (table->partitions, 0, sizeof (table->partitions));
	table->magic = PED_CPU_TO_LE16(PC9800_EXTFMT_MAGIC);

	for (i = 1; i <= MAX_PART_COUNT; i++) {
		part = ped_disk_get_partition (disk, i);
		if (!part)
			continue;

		if (!fill_raw_part (&table->partitions [i - 1], part))
			return 0;
	}

	int write_ok = ped_device_write (disk->dev, table, 0, 2);
	free (s0);
	if (!write_ok)
		return 0;
	return ped_device_sync (disk->dev);
}