本文整理汇总了C++中PED_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ PED_ASSERT函数的具体用法?C++ PED_ASSERT怎么用?C++ PED_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PED_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sa_sigsegv_handler
/* Signal handler for SIGSEGV using 'sigaction'. */
static void
sa_sigsegv_handler (int signum, siginfo_t* info, void* ucontext)
{
fprintf (stderr, bug_msg, VERSION);
_dump_history ();
if (!info)
abort ();
sigaction (SIGSEGV, &sig_segv, NULL);
switch (info->si_code) {
case SEGV_MAPERR:
fputs(_("\nError: SEGV_MAPERR (Address not mapped "
"to object)\n"), stdout);
PED_ASSERT(0); /* Force a backtrace */
break;
case SEGV_ACCERR:
fputs(_("\nError: SEGV_ACCERR (Invalid permissions "
"for mapped object)\n"), stdout);
break;
default:
fputs(_("\nError: A general SIGSEGV signal was "
"encountered.\n"), stdout);
PED_ASSERT(0); /* Force a backtrace */
break;
}
abort ();
}
示例2: free_root_dir
/* when converting FAT32 -> FAT16
* fat_duplicate clusters() duplicated the root directory unnecessarily.
* Let's free it.
*
* This must be called AFTER fat_construct_new_fat(). (otherwise, our
* changes just get overwritten)
*/
static int
free_root_dir (FatOpContext* ctx)
{
FatSpecific* old_fs_info = FAT_SPECIFIC (ctx->old_fs);
FatSpecific* new_fs_info = FAT_SPECIFIC (ctx->new_fs);
FatCluster old_cluster;
FatFragment i;
PED_ASSERT (old_fs_info->fat_type == FAT_TYPE_FAT32);
PED_ASSERT (new_fs_info->fat_type == FAT_TYPE_FAT16);
for (old_cluster = old_fs_info->root_cluster;
!fat_table_is_eof (old_fs_info->fat, old_cluster);
old_cluster = fat_table_get (old_fs_info->fat, old_cluster)) {
FatFragment old_frag;
old_frag = fat_cluster_to_frag (ctx->old_fs, old_cluster);
for (i = 0; i < new_fs_info->cluster_frags; i++) {
FatFragment new_frag;
FatCluster new_clst;
new_frag = fat_op_context_map_fragment (ctx,
old_frag + i);
new_clst = fat_frag_to_cluster (ctx->old_fs, new_frag);
if (!fat_table_set_avail (new_fs_info->fat, new_clst))
return 0;
}
}
return 1;
}
示例3: amiga_partition_set_flag
static int
amiga_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
{
struct PartitionBlock *partition;
PED_ASSERT (part != NULL);
PED_ASSERT (part->disk_specific != NULL);
partition = PART(part->disk_specific);
switch (flag) {
case PED_PARTITION_BOOT:
if (state) partition->pb_Flags |= PED_CPU_TO_BE32(PBFF_BOOTABLE);
else partition->pb_Flags &= ~(PED_CPU_TO_BE32(PBFF_BOOTABLE));
return 1;
case PED_PARTITION_HIDDEN:
if (state) partition->pb_Flags |= PED_CPU_TO_BE32(PBFF_NOMOUNT);
else partition->pb_Flags &= ~(PED_CPU_TO_BE32(PBFF_NOMOUNT));
return 1;
case PED_PARTITION_RAID:
if (state) partition->pb_Flags |= PED_CPU_TO_BE32(PBFF_RAID);
else partition->pb_Flags &= ~(PED_CPU_TO_BE32(PBFF_RAID));
return 1;
case PED_PARTITION_LVM:
if (state) partition->pb_Flags |= PED_CPU_TO_BE32(PBFF_LVM);
else partition->pb_Flags &= ~(PED_CPU_TO_BE32(PBFF_LVM));
return 1;
default:
return 0;
}
}
示例4: pc98_alloc_metadata
static int
pc98_alloc_metadata (PedDisk* disk)
{
PedPartition* new_part;
PedConstraint* constraint_any = NULL;
PedSector cyl_size;
PED_ASSERT (disk != NULL);
PED_ASSERT (disk->dev != NULL);
constraint_any = ped_constraint_any (disk->dev);
cyl_size = disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
new_part = ped_partition_new (disk, PED_PARTITION_METADATA, NULL,
0, cyl_size - 1);
if (!new_part)
goto error;
if (!ped_disk_add_partition (disk, new_part, constraint_any)) {
ped_partition_destroy (new_part);
goto error;
}
ped_constraint_destroy (constraint_any);
return 1;
error:
ped_constraint_destroy (constraint_any);
return 0;
}
示例5: amiga_alloc_metadata
static int
amiga_alloc_metadata (PedDisk* disk)
{
PedPartition* new_part;
PedConstraint* constraint_any = NULL;
PED_ASSERT (disk != NULL);
PED_ASSERT (disk->dev != NULL);
constraint_any = ped_constraint_any (disk->dev);
/* Allocate space for the RDB */
new_part = ped_partition_new (disk, PED_PARTITION_METADATA, NULL,
0, MAX_RDB_BLOCK);
if (!new_part)
goto error;
if (!ped_disk_add_partition (disk, new_part, constraint_any)) {
ped_partition_destroy (new_part);
goto error;
}
ped_constraint_destroy (constraint_any);
return 1;
error:
ped_constraint_destroy (constraint_any);
return 0;
}
示例6: amiga_partition_enumerate
static int
amiga_partition_enumerate (PedPartition* part)
{
int i;
PedPartition* p;
PED_ASSERT (part != NULL);
PED_ASSERT (part->disk != NULL);
/* never change the partition numbers */
if (part->num != -1)
return 1;
for (i = 1; i <= AMIGA_MAX_PARTITIONS; i++) {
p = ped_disk_get_partition (part->disk, i);
if (!p) {
part->num = i;
return 1;
}
}
/* failed to allocate a number */
#ifndef DISCOVER_ONLY
ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
_("Unable to allocate a partition number."));
#endif
return 0;
}
示例7: _generic_apfs_probe
static PedGeometry*
_generic_apfs_probe (PedGeometry* geom, uint32_t kind)
{
uint32_t *block;
PedSector root;
struct PartitionBlock * part;
uint32_t blocksize = 1, reserved = 2;
PED_ASSERT (geom != NULL);
PED_ASSERT (geom->dev != NULL);
if (geom->dev->sector_size != 512)
return NULL;
/* Finds the blocksize and reserved values of the partition block */
if (!(part = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
_("%s : Failed to allocate partition block\n"), __func__);
goto error_part;
}
if (amiga_find_part(geom, part) != NULL) {
reserved = PED_BE32_TO_CPU (part->de_Reserved);
blocksize = PED_BE32_TO_CPU (part->de_SizeBlock)
* PED_BE32_TO_CPU (part->de_SectorPerBlock) / 128;
}
free (part);
/* Test boot block */
if (!(block = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
_("%s : Failed to allocate block\n"), __func__);
goto error_block;
}
if (!ped_device_read (geom->dev, block, geom->start, blocksize)) {
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
_("%s : Couldn't read boot block %llu\n"), __func__, geom->start);
goto error;
}
if (PED_BE32_TO_CPU (block[0]) != kind) {
goto error;
}
/* Find and test the root block */
root = geom->start+reserved*blocksize;
if (!ped_device_read (geom->dev, block, root, blocksize)) {
ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
_("%s : Couldn't read root block %llu\n"), __func__, root);
goto error;
}
if (_apfs_probe_root(block, blocksize, kind) == 1) {
free(block);
return ped_geometry_duplicate (geom);
}
error:
free (block);
error_block:
error_part:
return NULL;
}
示例8: pc98_read
static int
pc98_read (PedDisk* disk)
{
PED_ASSERT (disk != NULL);
PED_ASSERT (disk->dev != NULL);
ped_disk_delete_all (disk);
return read_table (disk);
}
示例9: legacy_start
static PedSector _GL_ATTRIBUTE_PURE
legacy_start (const PedDisk* disk, const PC98RawPartition* raw_part)
{
PED_ASSERT (disk != NULL);
PED_ASSERT (raw_part != NULL);
return chs_to_sector (disk->dev, PED_LE16_TO_CPU(raw_part->cyl),
raw_part->head, raw_part->sector);
}
示例10: amiga_free
static void
amiga_free (PedDisk* disk)
{
PED_ASSERT(disk != NULL);
PED_ASSERT(disk->disk_specific != NULL);
free (disk->disk_specific);
_ped_disk_free (disk);
}
示例11: amiga_partition_destroy
static void
amiga_partition_destroy (PedPartition* part)
{
PED_ASSERT (part != NULL);
if (ped_partition_is_active (part)) {
PED_ASSERT (part->disk_specific != NULL);
free (part->disk_specific);
}
_ped_partition_free (part);
}
示例12: ped_disk_amiga_init
void
ped_disk_amiga_init ()
{
PED_ASSERT (sizeof (struct AmigaBlock) != 3);
PED_ASSERT (sizeof (struct RigidDiskBlock) != 64);
PED_ASSERT (sizeof (struct PartitionBlock) != 64);
PED_ASSERT (sizeof (struct LinkedBlock) != 5);
PED_ASSERT (sizeof (struct Linked2Block) != 18);
ped_disk_type_register (&amiga_disk_type);
}
示例13: pc98_partition_get_name
static const char* _GL_ATTRIBUTE_PURE
pc98_partition_get_name (const PedPartition* part)
{
PC98PartitionData* pc98_data;
PED_ASSERT (part != NULL);
PED_ASSERT (part->disk_specific != NULL);
pc98_data = part->disk_specific;
return pc98_data->name;
}
示例14: amiga_partition_set_name
static void
amiga_partition_set_name (PedPartition* part, const char* name)
{
struct PartitionBlock *partition;
PED_ASSERT (part != NULL);
PED_ASSERT (part->disk_specific != NULL);
partition = PART(part->disk_specific);
_amiga_set_bstr(name, partition->pb_DriveName, 32);
}
示例15: amiga_partition_get_name
static const char*
amiga_partition_get_name (const PedPartition* part)
{
struct PartitionBlock *partition;
PED_ASSERT (part != NULL);
PED_ASSERT (part->disk_specific != NULL);
partition = PART(part->disk_specific);
return _amiga_get_bstr(partition->pb_DriveName);
}