本文整理汇总了C++中PED_BE32_TO_CPU函数的典型用法代码示例。如果您正苦于以下问题:C++ PED_BE32_TO_CPU函数的具体用法?C++ PED_BE32_TO_CPU怎么用?C++ PED_BE32_TO_CPU使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PED_BE32_TO_CPU函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hfs_extent_key_cmp
/* in this function */
static int
hfs_extent_key_cmp(HfsPrivateGenericKey* a, HfsPrivateGenericKey* b)
{
HfsExtentKey* key1 = (HfsExtentKey*) a;
HfsExtentKey* key2 = (HfsExtentKey*) b;
/* do NOT use a substraction, because */
/* 0xFFFFFFFF - 1 = 0xFFFFFFFE so this */
/* would return -2, despite the fact */
/* 0xFFFFFFFF > 1 !!! (this is the 2.4 bug) */
if (key1->file_ID != key2->file_ID)
return PED_BE32_TO_CPU(key1->file_ID) <
PED_BE32_TO_CPU(key2->file_ID) ?
-1 : +1;
if (key1->type != key2->type)
return (int)(key1->type - key2->type);
if (key1->start == key2->start)
return 0;
/* the whole thing wont work with 16 bits ints */
/* anyway */
return (int)( PED_BE16_TO_CPU(key1->start) -
PED_BE16_TO_CPU(key2->start) );
}
示例2: xfs_probe
static PedGeometry*
xfs_probe (PedGeometry* geom)
{
PedSector block_size;
PedSector block_count;
union {
struct xfs_sb sb;
char bytes [512];
} buf;
if (geom->length < XFS_SB_DADDR + 1)
return NULL;
if (!ped_geometry_read (geom, &buf, XFS_SB_DADDR, 1))
return NULL;
if (PED_LE32_TO_CPU (buf.sb.sb_magicnum) == XFS_SB_MAGIC) {
block_size = PED_LE32_TO_CPU (buf.sb.sb_blocksize) / 512;
block_count = PED_LE64_TO_CPU (buf.sb.sb_dblocks);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
if (PED_BE32_TO_CPU (buf.sb.sb_magicnum) == XFS_SB_MAGIC) {
block_size = PED_BE32_TO_CPU (buf.sb.sb_blocksize) / 512;
block_count = PED_BE64_TO_CPU (buf.sb.sb_dblocks);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
return NULL;
}
示例3: hfs_file_write_sector
/* return 0 on error */
int
hfs_file_write_sector (HfsPrivateFile* file, void *buf, PedSector sector)
{
PedSector abs_sector;
if (sector >= file->sect_nb) {
ped_exception_throw (
PED_EXCEPTION_ERROR,
PED_EXCEPTION_CANCEL,
_("Trying to write HFS file with CNID %X behind EOF."),
PED_BE32_TO_CPU(file->CNID));
return 0;
}
abs_sector = hfs_file_find_sector (file, sector);
if (!abs_sector) {
ped_exception_throw (
PED_EXCEPTION_ERROR,
PED_EXCEPTION_CANCEL,
_("Could not find sector %lli of HFS file with "
"CNID %X."),
sector, PED_BE32_TO_CPU(file->CNID));
return 0;
}
return ped_geometry_write (file->fs->geom, buf, abs_sector, 1);
}
示例4: _amiga_read_block
static struct AmigaBlock *
_amiga_read_block (const PedDevice *dev, struct AmigaBlock *blk,
PedSector block, struct AmigaIds *ids)
{
if (!ped_device_read (dev, blk, block, 1))
return NULL;
if (ids && !_amiga_id_in_list(PED_BE32_TO_CPU(blk->amiga_ID), ids))
return NULL;
if (_amiga_checksum (blk) != 0) {
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE | PED_EXCEPTION_CANCEL,
_("%s : Bad checksum on block %llu of type %s."),
__func__, block, _amiga_block_id(PED_BE32_TO_CPU(blk->amiga_ID))))
{
case PED_EXCEPTION_CANCEL :
return NULL;
case PED_EXCEPTION_FIX :
_amiga_calculate_checksum(AMIGA(blk));
if (!ped_device_write ((PedDevice*)dev, blk, block, 1))
return NULL;
case PED_EXCEPTION_IGNORE :
case PED_EXCEPTION_UNHANDLED :
default :
return blk;
}
}
return blk;
}
示例5: ufs_probe_sun
static PedGeometry*
ufs_probe_sun (PedGeometry* geom)
{
int8_t buf[512 * 3];
struct ufs_super_block *sb;
if (geom->length < 5)
return 0;
if (!ped_geometry_read (geom, buf, 16, 3))
return 0;
sb = (struct ufs_super_block *)buf;
if (PED_BE32_TO_CPU(sb->fs_magic) == UFS_MAGIC) {
PedSector block_size = PED_BE32_TO_CPU(sb->fs_bsize) / 512;
PedSector block_count = PED_BE32_TO_CPU(sb->fs_size);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
if (PED_LE32_TO_CPU(sb->fs_magic) == UFS_MAGIC) {
PedSector block_size = PED_LE32_TO_CPU(sb->fs_bsize) / 512;
PedSector block_count = PED_LE32_TO_CPU(sb->fs_size);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
return NULL;
}
示例6: _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;
}
示例7: _amiga_find_free_blocks
static int
_amiga_find_free_blocks(const PedDisk *disk, uint32_t *table,
struct LinkedBlock *block, uint32_t first, uint32_t type)
{
PedSector next;
PED_ASSERT(disk != NULL);
PED_ASSERT(disk->dev != NULL);
for (next = first; next != LINK_END; next = PED_BE32_TO_CPU(block->lk_Next)) {
if (table[next] != IDNAME_FREE) {
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE | PED_EXCEPTION_CANCEL,
_("%s : Loop detected at block %d."), __func__, next))
{
case PED_EXCEPTION_CANCEL :
return 0;
case PED_EXCEPTION_FIX :
/* TODO : Need to add fixing code */
case PED_EXCEPTION_IGNORE :
case PED_EXCEPTION_UNHANDLED :
default :
return 1;
}
}
if (!_amiga_read_block (disk->dev, AMIGA(block), next, NULL)) {
return 0;
}
if (PED_BE32_TO_CPU(block->lk_ID) != type) {
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
PED_EXCEPTION_CANCEL,
_("%s : The %s list seems bad at block %s."),
__func__, _amiga_block_id(PED_BE32_TO_CPU(block->lk_ID)), next))
{
/* TODO : to more subtile things here */
case PED_EXCEPTION_CANCEL :
case PED_EXCEPTION_UNHANDLED :
default :
return 0;
}
}
table[next] = type;
if (PED_BE32_TO_CPU(block->lk_ID) == IDNAME_FILESYSHEADER) {
if (_amiga_find_free_blocks(disk, table, block,
PED_BE32_TO_CPU(LNK2(block)->lk2_Linked),
IDNAME_LOADSEG) == 0) return 0;
}
}
return 1;
}
示例8: _amiga_checksum
static int
_amiga_checksum (struct AmigaBlock *blk) {
uint32_t *rdb = (uint32_t *) blk;
uint32_t sum;
int i, end;
sum = PED_BE32_TO_CPU (rdb[0]);
end = PED_BE32_TO_CPU (rdb[1]);
if (end > PED_SECTOR_SIZE_DEFAULT) end = PED_SECTOR_SIZE_DEFAULT;
for (i = 1; i < end; i++) sum += PED_BE32_TO_CPU (rdb[i]);
return sum;
}
示例9: hfsplus_clobber
static int
hfsplus_clobber (PedGeometry* geom)
{
unsigned int i = 1;
uint8_t buf[PED_SECTOR_SIZE_DEFAULT];
HfsMasterDirectoryBlock *mdb;
mdb = (HfsMasterDirectoryBlock *) buf;
if (!ped_geometry_read (geom, buf, 2, 1))
return 0;
if (PED_BE16_TO_CPU (mdb->signature) == HFS_SIGNATURE) {
/* embedded hfs+ */
PedGeometry *embedded;
i = PED_BE32_TO_CPU(mdb->block_size) / PED_SECTOR_SIZE_DEFAULT;
embedded = ped_geometry_new (
geom->dev,
(PedSector) geom->start
+ PED_BE16_TO_CPU (mdb->start_block)
+ (PedSector) PED_BE16_TO_CPU (
mdb->old_new.embedded.location.start_block ) * i,
(PedSector) PED_BE16_TO_CPU (
mdb->old_new.embedded.location.block_count ) * i );
if (!embedded) i = 0;
else {
i = hfs_clobber (embedded);
ped_geometry_destroy (embedded);
}
}
/* non-embedded or envelop destroy as hfs */
return ( hfs_clobber (geom) && i );
}
示例10: hfsj_update_jl
int
hfsj_update_jl(PedFileSystem* fs, uint32_t block)
{
uint8_t buf[PED_SECTOR_SIZE_DEFAULT];
PedSector sector;
uint64_t offset;
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
fs->type_specific;
HfsJJournalInfoBlock* jib;
int binsect;
binsect = PED_BE32_TO_CPU(priv_data->vh->block_size) / PED_SECTOR_SIZE_DEFAULT;
sector = (PedSector) priv_data->jib_start_block * binsect;
if (!ped_geometry_read(priv_data->plus_geom, buf, sector, 1))
return 0;
jib = (HfsJJournalInfoBlock*) buf;
offset = (uint64_t)block * PED_SECTOR_SIZE_DEFAULT * binsect;
jib->offset = PED_CPU_TO_BE64(offset);
if (!ped_geometry_write(priv_data->plus_geom, buf, sector, 1)
|| !ped_geometry_sync(priv_data->plus_geom))
return 0;
priv_data->jl_start_block = block;
return 1;
}
示例11: _amiga_calculate_checksum
static void
_amiga_calculate_checksum (struct AmigaBlock *blk) {
blk->amiga_ChkSum = PED_CPU_TO_BE32(
PED_BE32_TO_CPU(blk->amiga_ChkSum) -
_amiga_checksum((struct AmigaBlock *) blk));
return;
}
示例12: _parse_boot_file
static PedPartition*
_parse_boot_file (PedDisk* disk, struct volume_directory* vd)
{
PedPartition* part;
DVHPartData* dvh_part_data;
PedSector start = PED_BE32_TO_CPU (vd->vd_lbn);
int length = PED_BE32_TO_CPU (vd->vd_nbytes);
part = ped_partition_new (disk, PED_PARTITION_LOGICAL, NULL,
start, start + length/512 - 1);
if (!part)
return NULL;
dvh_part_data = part->disk_specific;
dvh_part_data->real_file_size = length;
strncpy (dvh_part_data->name, vd->vd_name, VDNAMESIZE);
dvh_part_data->name[VDNAMESIZE] = 0;
return part;
}
示例13: _checksum
/* two's complement 32-bit checksum */
static uint32_t _GL_ATTRIBUTE_PURE
_checksum (const uint32_t* base, size_t size)
{
uint32_t sum = 0;
size_t i;
for (i = 0; i < size / sizeof (uint32_t); i++)
sum = sum - PED_BE32_TO_CPU (base[i]);
return sum;
}
示例14: _parse_partition
static PedPartition*
_parse_partition (PedDisk* disk, struct partition_table* pt)
{
PedPartition* part;
DVHPartData* dvh_part_data;
PedSector start = PED_BE32_TO_CPU (pt->pt_firstlbn);
PedSector length = PED_BE32_TO_CPU (pt->pt_nblks);
part = ped_partition_new (disk,
pt->pt_type ? 0 : PED_PARTITION_EXTENDED,
NULL,
start, start + length - 1);
if (!part)
return NULL;
dvh_part_data = part->disk_specific;
dvh_part_data->type = PED_BE32_TO_CPU (pt->pt_type);
strcpy (dvh_part_data->name, "");
return part;
}
示例15: ufs_probe_hp
static PedGeometry*
ufs_probe_hp (PedGeometry* geom)
{
int8_t buf[1536];
struct ufs_super_block *sb;
PedSector block_size;
PedSector block_count;
if (geom->length < 5)
return 0;
if (!ped_geometry_read (geom, buf, 16, 3))
return 0;
sb = (struct ufs_super_block *)buf;
/* Try sane bytesex */
switch (PED_BE32_TO_CPU(sb->fs_magic)) {
case UFS_MAGIC_LFN:
case UFS_MAGIC_FEA:
case UFS_MAGIC_4GB:
block_size = PED_BE32_TO_CPU(sb->fs_bsize) / 512;
block_count = PED_BE32_TO_CPU(sb->fs_size);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
/* Try perverted bytesex */
switch (PED_LE32_TO_CPU(sb->fs_magic)) {
case UFS_MAGIC_LFN:
case UFS_MAGIC_FEA:
case UFS_MAGIC_4GB:
block_size = PED_LE32_TO_CPU(sb->fs_bsize) / 512;
block_count = PED_LE32_TO_CPU(sb->fs_size);
return ped_geometry_new (geom->dev, geom->start,
block_size * block_count);
}
return NULL;
}