Esempio n. 1
0
File: pc98.c Progetto: Excito/parted
static PedPartition*
pc98_partition_new (
	const PedDisk* disk, PedPartitionType part_type,
	const PedFileSystemType* fs_type, PedSector start, PedSector end)
{
	PedPartition*		part;
	PC98PartitionData*	pc98_data;

	part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
	if (!part)
		goto error;

	if (ped_partition_is_active (part)) {
		part->disk_specific
			= pc98_data = ped_malloc (sizeof (PC98PartitionData));
		if (!pc98_data)
			goto error_free_part;
		pc98_data->ipl_sector = 0;
		pc98_data->hidden = 0;
		pc98_data->boot = 0;
		strcpy (pc98_data->name, "");
	} else {
		part->disk_specific = NULL;
	}
	return part;

error_free_part:
	free (part);
error:
	return 0;
}
Esempio n. 2
0
static PedPartition*
dvh_partition_duplicate (const PedPartition* part)
{
	PedPartition* result;
	DVHPartData* part_data = part->disk_specific;
	DVHPartData* result_data;

	result = _ped_partition_alloc (part->disk, part->type, part->fs_type,
				       part->geom.start, part->geom.end);
	if (!result)
		goto error;
	result->num = part->num;

	if (!ped_partition_is_active (part)) {
		result->disk_specific = NULL;
		return result;
	}

	result_data = result->disk_specific =
		ped_malloc (sizeof (DVHPartData));
	if (!result_data)
		goto error_free_part;

	result_data->type = part_data->type;
	strcpy (result_data->name, part_data->name);
	result_data->real_file_size = part_data->real_file_size;
	return result;

error_free_part:
	_ped_partition_free (result);
error:
	return NULL;
}
Esempio n. 3
0
static PedPartition*
dvh_partition_new (const PedDisk* disk, PedPartitionType part_type,
		    const PedFileSystemType* fs_type,
		    PedSector start, PedSector end)
{
	PedPartition* part;
	DVHPartData* dvh_part_data;

	part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
	if (!part)
		goto error;

	if (!ped_partition_is_active (part)) {
		part->disk_specific = NULL;
		return part;
	}

	dvh_part_data = part->disk_specific =
		ped_malloc (sizeof (DVHPartData));
	if (!dvh_part_data)
		goto error_free_part;

	dvh_part_data->type = (part_type == PED_PARTITION_EXTENDED)
					? PTYPE_VOLHDR
					: PTYPE_RAW;
	strcpy (dvh_part_data->name, "");
	dvh_part_data->real_file_size = part->geom.length * 512;
	return part;

error_free_part:
	_ped_partition_free (part);
error:
	return NULL;
}
Esempio n. 4
0
static PedPartition*
bsd_partition_new (const PedDisk* disk, PedPartitionType part_type,
		   const PedFileSystemType* fs_type,
		   PedSector start, PedSector end)
{
	PedPartition*		part;
	BSDPartitionData*	bsd_data;

	part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
	if (!part)
		goto error;

	if (ped_partition_is_active (part)) {
		part->disk_specific
		       	= bsd_data = ped_malloc (sizeof (BSDPartitionData));
		if (!bsd_data)
			goto error_free_part;
		bsd_data->type = 0;
		bsd_data->boot = 0;
		bsd_data->raid = 0;
		bsd_data->lvm  = 0;
	} else {
		part->disk_specific = NULL;
	}
	return part;

error_free_part:
	free (part);
error:
	return 0;
}
Esempio n. 5
0
File: loop.c Progetto: Excito/parted
static PedPartition*
loop_partition_new (const PedDisk* disk, PedPartitionType part_type,
		    const PedFileSystemType* fs_type,
		    PedSector start, PedSector end)
{
	PedPartition*	part;

	part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
	if (!part)
		return NULL;
	part->disk_specific = NULL;
	return part;
}
Esempio n. 6
0
File: dasd.c Progetto: bcl/parted
static PedPartition*
dasd_partition_new (const PedDisk* disk, PedPartitionType part_type,
                    const PedFileSystemType* fs_type,
                    PedSector start, PedSector end)
{
	PedPartition* part;

	part = _ped_partition_alloc(disk, part_type, fs_type, start, end);
	if (!part)
		goto error;

	part->disk_specific = ped_calloc (sizeof (DasdPartitionData));
	return part;

error:
	return 0;
}
Esempio n. 7
0
static PedPartition*
amiga_partition_new (const PedDisk* disk, PedPartitionType part_type,
		   const PedFileSystemType* fs_type,
		   PedSector start, PedSector end)
{
	PedPartition *part;
	PedDevice *dev;
	PedSector cyl;
	struct PartitionBlock *partition;
	struct RigidDiskBlock *rdb;

	PED_ASSERT(disk != NULL);
	PED_ASSERT(disk->dev != NULL);
	PED_ASSERT(disk->disk_specific != NULL);
	dev = disk->dev;
	cyl = (PedSector) (dev->hw_geom.sectors * dev->hw_geom.heads);
	rdb = RDSK(disk->disk_specific);

	if (!(part = _ped_partition_alloc (disk, part_type, fs_type, start, end)))
		return NULL;

	if (ped_partition_is_active (part)) {
		if (!(part->disk_specific = ped_malloc (disk->dev->sector_size))) {
			free (part);
			return NULL;
		}
		partition = PART(part->disk_specific);
		memset(partition, 0, sizeof(struct PartitionBlock));

		partition->pb_ID = PED_CPU_TO_BE32(IDNAME_PARTITION);
		partition->pb_SummedLongs = PED_CPU_TO_BE32(64);
		partition->pb_HostID = rdb->rdb_HostID;
		partition->pb_Flags = PED_CPU_TO_BE32(0);
		/* TODO : use a scheme including the device name and the
		 * partition number, if it is possible */
		_amiga_set_bstr("dhx", partition->pb_DriveName, 32);

		partition->de_TableSize = PED_CPU_TO_BE32(19);
		partition->de_SizeBlock = PED_CPU_TO_BE32(128);
		partition->de_SecOrg = PED_CPU_TO_BE32(0);
		partition->de_Surfaces = PED_CPU_TO_BE32(dev->hw_geom.heads);
		partition->de_SectorPerBlock = PED_CPU_TO_BE32(1);
		partition->de_BlocksPerTrack
			= PED_CPU_TO_BE32(dev->hw_geom.sectors);
		partition->de_Reserved = PED_CPU_TO_BE32(2);
		partition->de_PreAlloc = PED_CPU_TO_BE32(0);
		partition->de_Interleave = PED_CPU_TO_BE32(0);
		partition->de_LowCyl = PED_CPU_TO_BE32(start/cyl);
		partition->de_HighCyl = PED_CPU_TO_BE32((end+1)/cyl-1);
		partition->de_NumBuffers = PED_CPU_TO_BE32(30);
		partition->de_BufMemType = PED_CPU_TO_BE32(0);
		partition->de_MaxTransfer = PED_CPU_TO_BE32(0x7fffffff);
		partition->de_Mask = PED_CPU_TO_BE32(0xffffffff);
		partition->de_BootPri = PED_CPU_TO_BE32(0);
		partition->de_DosType = PED_CPU_TO_BE32(0x4c4e5800);
		partition->de_Baud = PED_CPU_TO_BE32(0);
		partition->de_Control = PED_CPU_TO_BE32(0);
		partition->de_BootBlocks = PED_CPU_TO_BE32(0);

	} else {
		part->disk_specific = NULL;
	}
	return part;
}