예제 #1
0
boolean fips_partition::split (fips_harddrive hd)
{
	if (read_boot_sector ())
		error ("Error reading boot sector");

	if (global.debug_mode)
	{
		fprintf
		(
			global.debugfile,
			"\nBoot sector drive %02Xh, partition %u:\n\n",
			hd.number,
			number + 1
		);

		hexwrite
		(
			boot_sector->data,
			512,
			global.debugfile
		);
	}

	get_bpb ();

	printx ("\nBoot sector:\n\n");
	print_bpb ();

	get_info ();
	if (global.debug_mode)
		write_info_debugfile ();

	check ();

	fat16 fat1 (this,1);
	fat16 fat2 (this,2);

	fat1.check_against (&fat2);

	dword new_part_min_cylinder =
		min_cylinder (fat2, hd.geometry);

	if (ask_if_save()) save_root_and_boot(&hd,this);

	dword new_start_cylinder =
		ask_for_new_start_cylinder
		(
			partition_info->start_cylinder,
			new_part_min_cylinder,
			partition_info->end_cylinder,
			hd.geometry.heads * hd.geometry.sectors
		);

	fat2.check_empty
	(
		new_start_cylinder
			* hd.geometry.heads
			* hd.geometry.sectors
		- partition_info->start_sector_abs
	);

	hd.calculate_new_root (new_start_cylinder, this);

	hd.put_partition_table();
	hd.get_partition_table();

	printx ("\nNew partition table:\n\n");
	hd.print_partition_table ();

	hd.check (FINAL_CHECK);

	if (ask_if_continue () == false)
	{
		return (false);
	}

	calculate_new_boot ();

	put_bpb ();
	get_bpb ();

	printx ("\nNew boot sector:\n\n");
	print_bpb ();

	get_info ();
	if (global.debug_mode)
		write_info_debugfile ();

	check();

	if (!global.test_mode)
	{
		ask_for_write_permission ();

		if (hd.write_root_sector ())
			error ("Error writing root sector");

		if (write_boot_sector ())
			error ("Error writing boot sector");

		printx ("Repartitioning complete\n");
	}

	return (true);
}
예제 #2
0
파일: main.c 프로젝트: martoo6/tp-so-fuse
int main(int argc, char *argv[])
{
	print_boot_sector(read_boot_sector(argv[argc-1]));

	return 0;
}