本文整理汇总了C++中BSWAP_64函数的典型用法代码示例。如果您正苦于以下问题:C++ BSWAP_64函数的具体用法?C++ BSWAP_64怎么用?C++ BSWAP_64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BSWAP_64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: zap_leaf_byteswap
void
zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
{
int i;
zap_leaf_t l;
dmu_buf_t l_dbuf;
l_dbuf.db_data = buf;
l.l_bs = highbit64(size) - 1;
l.l_dbuf = &l_dbuf;
buf->l_hdr.lh_block_type = BSWAP_64(buf->l_hdr.lh_block_type);
buf->l_hdr.lh_prefix = BSWAP_64(buf->l_hdr.lh_prefix);
buf->l_hdr.lh_magic = BSWAP_32(buf->l_hdr.lh_magic);
buf->l_hdr.lh_nfree = BSWAP_16(buf->l_hdr.lh_nfree);
buf->l_hdr.lh_nentries = BSWAP_16(buf->l_hdr.lh_nentries);
buf->l_hdr.lh_prefix_len = BSWAP_16(buf->l_hdr.lh_prefix_len);
buf->l_hdr.lh_freelist = BSWAP_16(buf->l_hdr.lh_freelist);
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++)
buf->l_hash[i] = BSWAP_16(buf->l_hash[i]);
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(&l); i++) {
zap_leaf_chunk_t *lc = &ZAP_LEAF_CHUNK(&l, i);
struct zap_leaf_entry *le;
switch (lc->l_free.lf_type) {
case ZAP_CHUNK_ENTRY:
le = &lc->l_entry;
le->le_type = BSWAP_8(le->le_type);
le->le_value_intlen = BSWAP_8(le->le_value_intlen);
le->le_next = BSWAP_16(le->le_next);
le->le_name_chunk = BSWAP_16(le->le_name_chunk);
le->le_name_numints = BSWAP_16(le->le_name_numints);
le->le_value_chunk = BSWAP_16(le->le_value_chunk);
le->le_value_numints = BSWAP_16(le->le_value_numints);
le->le_cd = BSWAP_32(le->le_cd);
le->le_hash = BSWAP_64(le->le_hash);
break;
case ZAP_CHUNK_FREE:
lc->l_free.lf_type = BSWAP_8(lc->l_free.lf_type);
lc->l_free.lf_next = BSWAP_16(lc->l_free.lf_next);
break;
case ZAP_CHUNK_ARRAY:
lc->l_array.la_type = BSWAP_8(lc->l_array.la_type);
lc->l_array.la_next = BSWAP_16(lc->l_array.la_next);
/* la_array doesn't need swapping */
break;
default:
cmn_err(CE_PANIC, "bad leaf type %d",
lc->l_free.lf_type);
}
}
}
开发者ID:gcracker,项目名称:zfs,代码行数:55,代码来源:zap_leaf.c
示例2: zio_checksum_edonr_byteswap
/*
* Byteswapped zio_checksum interface for the Edon-R hash function.
*/
static void
zio_checksum_edonr_byteswap(const void *buf, uint64_t size,
const void *ctx_template, zio_cksum_t *zcp)
{
zio_cksum_t tmp;
zio_checksum_edonr_native(buf, size, ctx_template, &tmp);
zcp->zc_word[0] = BSWAP_64(zcp->zc_word[0]);
zcp->zc_word[1] = BSWAP_64(zcp->zc_word[1]);
zcp->zc_word[2] = BSWAP_64(zcp->zc_word[2]);
zcp->zc_word[3] = BSWAP_64(zcp->zc_word[3]);
}
开发者ID:allanjude,项目名称:illumos-gate,代码行数:15,代码来源:edonr_zfs.c
示例3: abd_checksum_edonr_byteswap
/*
* Byteswapped zio_checksum interface for the Edon-R hash function.
*/
void
abd_checksum_edonr_byteswap(abd_t *abd, uint64_t size,
const void *ctx_template, zio_cksum_t *zcp)
{
zio_cksum_t tmp;
abd_checksum_edonr_native(abd, size, ctx_template, &tmp);
zcp->zc_word[0] = BSWAP_64(zcp->zc_word[0]);
zcp->zc_word[1] = BSWAP_64(zcp->zc_word[1]);
zcp->zc_word[2] = BSWAP_64(zcp->zc_word[2]);
zcp->zc_word[3] = BSWAP_64(zcp->zc_word[3]);
}
开发者ID:ColinIanKing,项目名称:zfs,代码行数:15,代码来源:edonr_zfs.c
示例4: mzap_byteswap
static void
mzap_byteswap(mzap_phys_t *buf, size_t size)
{
int i, maximum;
buf->mz_block_type = BSWAP_64(buf->mz_block_type);
buf->mz_salt = BSWAP_64(buf->mz_salt);
maximum = (size / MZAP_ENT_LEN) - 1;
for (i = 0; i < maximum; i++) {
buf->mz_chunk[i].mze_value =
BSWAP_64(buf->mz_chunk[i].mze_value);
buf->mz_chunk[i].mze_cd =
BSWAP_32(buf->mz_chunk[i].mze_cd);
}
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:14,代码来源:zap_micro.c
示例5: dmu_objset_byteswap
void
dmu_objset_byteswap(void *buf, size_t size)
{
objset_phys_t *osp = buf;
ASSERT(size == OBJSET_OLD_PHYS_SIZE || size == sizeof (objset_phys_t));
dnode_byteswap(&osp->os_meta_dnode);
byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t));
osp->os_type = BSWAP_64(osp->os_type);
osp->os_flags = BSWAP_64(osp->os_flags);
if (size == sizeof (objset_phys_t)) {
dnode_byteswap(&osp->os_userused_dnode);
dnode_byteswap(&osp->os_groupused_dnode);
}
}
开发者ID:ngkaho1234,项目名称:freebsd,代码行数:15,代码来源:dmu_objset.c
示例6: fletcher_2_byteswap
void
fletcher_2_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
{
const uint64_t *ip = buf;
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
uint64_t a0, b0, a1, b1;
for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
a0 += BSWAP_64(ip[0]);
a1 += BSWAP_64(ip[1]);
b0 += a0;
b1 += a1;
}
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
}
开发者ID:glycerine,项目名称:zfs,代码行数:16,代码来源:fletcher.c
示例7: test_bo
// 测试位操作
void test_bo(uint64_t i) {
uint64_t r;
uint32_t count;
count = OP_COUNT;
while (count--) {
r = BSWAP_64(i);
}
printf("bo result is %llu\n", r);
}
开发者ID:DavidFeng,项目名称:lovely_codes,代码行数:10,代码来源:main.c
示例8: dmu_objset_byteswap
void
dmu_objset_byteswap(void *buf, size_t size)
{
objset_phys_t *osp = buf;
ASSERT(size == sizeof (objset_phys_t));
dnode_byteswap(&osp->os_meta_dnode);
byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t));
osp->os_type = BSWAP_64(osp->os_type);
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:10,代码来源:dmu_objset.c
示例9: uberblock_verify
int
uberblock_verify(uberblock_t *ub)
{
if (ub->ub_magic == BSWAP_64((uint64_t)UBERBLOCK_MAGIC))
byteswap_uint64_array(ub, sizeof (uberblock_t));
if (ub->ub_magic != UBERBLOCK_MAGIC)
return (SET_ERROR(EINVAL));
return (0);
}
开发者ID:LLNL,项目名称:zfs,代码行数:11,代码来源:uberblock.c
示例10: fzap_byteswap
void
fzap_byteswap(void *vbuf, size_t size)
{
uint64_t block_type = *(uint64_t *)vbuf;
if (block_type == ZBT_LEAF || block_type == BSWAP_64(ZBT_LEAF))
zap_leaf_byteswap(vbuf, size);
else {
/* it's a ptrtbl block */
byteswap_uint64_array(vbuf, size);
}
}
开发者ID:openzfsonosx,项目名称:zfs,代码行数:12,代码来源:zap.c
示例11: zap_byteswap
void
zap_byteswap(void *buf, size_t size)
{
uint64_t block_type;
block_type = *(uint64_t *)buf;
if (block_type == ZBT_MICRO || block_type == BSWAP_64(ZBT_MICRO)) {
/* ASSERT(magic == ZAP_LEAF_MAGIC); */
mzap_byteswap(buf, size);
} else {
fzap_byteswap(buf, size);
}
}
开发者ID:unofficial-opensource-apple,项目名称:zfs,代码行数:14,代码来源:zap_micro.c
示例12: fletcher_2_incremental_byteswap
int
fletcher_2_incremental_byteswap(void *buf, size_t size, void *data)
{
zio_cksum_t *zcp = data;
const uint64_t *ip = buf;
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
uint64_t a0, b0, a1, b1;
a0 = zcp->zc_word[0];
a1 = zcp->zc_word[1];
b0 = zcp->zc_word[2];
b1 = zcp->zc_word[3];
for (; ip < ipend; ip += 2) {
a0 += BSWAP_64(ip[0]);
a1 += BSWAP_64(ip[1]);
b0 += a0;
b1 += a1;
}
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
return (0);
}
开发者ID:Ramzec,项目名称:zfs,代码行数:24,代码来源:zfs_fletcher.c
示例13: test_swap_double
static void test_swap_double() {
union {
double d;
uint64_t u;
} ud = {
.u = 0x7856341283C0F33F
};
double x = 1.2344999991522893623141499119810760021209716796875;
ud.u = BSWAP_64(ud.u);
double r = ud.d;
if (r == x) {
printf("%.64f\n", ud.d);
printf("swap okay\n");
} else {
printf("swap failed\n");
printf("%.64f\n", ud.d);
}
double td = 1.2344999991522893623141499119810760021209716796875;
if (memcmp(&td, "\x78\x56\x34\x12\x83\xC0\xF3\x3F", 8) == 0) {
printf("little endian double\n");
} else if (memcmp(&td, "\x3F\xF3\xC0\x83\x12\x34\x56\x78", 8) == 0) {
printf("big endian double\n");
} else {
printf("not support number format to dump!");
}
}
int main(int argc, char const* argv[]) {
test_swap_double();
test_b32();
union_test();
uint64_t i = 0x123456789abcdeff;
measure_time(test_mc, i, "memory copy");
measure_time(test_mc2, i, "memory copy 2");
measure_time(test_bo, i, "bitwise operation");
return 0;
}
开发者ID:DavidFeng,项目名称:lovely_codes,代码行数:39,代码来源:main.c
示例14: zio_checksum_error
int
zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
{
blkptr_t *bp = zio->io_bp;
uint_t checksum = (bp == NULL ? zio->io_prop.zp_checksum :
(BP_IS_GANG(bp) ? ZIO_CHECKSUM_GANG_HEADER : BP_GET_CHECKSUM(bp)));
int byteswap;
int error;
uint64_t size = (bp == NULL ? zio->io_size :
(BP_IS_GANG(bp) ? SPA_GANGBLOCKSIZE : BP_GET_PSIZE(bp)));
uint64_t offset = zio->io_offset;
void *data = zio->io_data;
zio_checksum_info_t *ci = &zio_checksum_table[checksum];
zio_cksum_t actual_cksum, expected_cksum, verifier;
if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
return (EINVAL);
if (ci->ci_eck) {
zio_eck_t *eck;
if (checksum == ZIO_CHECKSUM_ZILOG2) {
zil_chain_t *zilc = data;
uint64_t nused;
eck = &zilc->zc_eck;
if (eck->zec_magic == ZEC_MAGIC)
nused = zilc->zc_nused;
else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC))
nused = BSWAP_64(zilc->zc_nused);
else
return (ECKSUM);
if (nused > size)
return (ECKSUM);
size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t);
} else {
eck = (zio_eck_t *)((char *)data + size) - 1;
}
if (checksum == ZIO_CHECKSUM_GANG_HEADER)
zio_checksum_gang_verifier(&verifier, bp);
else if (checksum == ZIO_CHECKSUM_LABEL)
zio_checksum_label_verifier(&verifier, offset);
else
verifier = bp->blk_cksum;
byteswap = (eck->zec_magic == BSWAP_64(ZEC_MAGIC));
if (byteswap)
byteswap_uint64_array(&verifier, sizeof (zio_cksum_t));
expected_cksum = eck->zec_cksum;
eck->zec_cksum = verifier;
ci->ci_func[byteswap](data, size, &actual_cksum);
eck->zec_cksum = expected_cksum;
if (byteswap)
byteswap_uint64_array(&expected_cksum,
sizeof (zio_cksum_t));
} else {
ASSERT(!BP_IS_GANG(bp));
byteswap = BP_SHOULD_BYTESWAP(bp);
expected_cksum = bp->blk_cksum;
ci->ci_func[byteswap](data, size, &actual_cksum);
}
info->zbc_expected = expected_cksum;
info->zbc_actual = actual_cksum;
info->zbc_checksum_name = ci->ci_name;
info->zbc_byteswapped = byteswap;
info->zbc_injected = 0;
info->zbc_has_cksum = 1;
if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) {
return (ECKSUM);
}
if (zio_injection_enabled && !zio->io_error &&
(error = zio_handle_fault_injection(zio, ECKSUM)) != 0) {
info->zbc_injected = 1;
return (error);
}
return (0);
}
开发者ID:BjoKaSH,项目名称:zfs-osx,代码行数:88,代码来源:zio_checksum.c
示例15: zfs_ace_byteswap
/*
* swap ace_t and ace_oject_t
*/
void
zfs_ace_byteswap(void *buf, size_t size, boolean_t zfs_layout)
{
#ifdef TODO
caddr_t end;
caddr_t ptr;
zfs_ace_t *zacep;
ace_t *acep;
uint16_t entry_type;
size_t entry_size;
int ace_type;
end = (caddr_t)buf + size;
ptr = buf;
while (ptr < end) {
if (zfs_layout) {
zacep = (zfs_ace_t *)ptr;
zacep->z_hdr.z_access_mask =
BSWAP_32(zacep->z_hdr.z_access_mask);
zacep->z_hdr.z_flags = BSWAP_16(zacep->z_hdr.z_flags);
ace_type = zacep->z_hdr.z_type =
BSWAP_16(zacep->z_hdr.z_type);
entry_type = zacep->z_hdr.z_flags & ACE_TYPE_FLAGS;
} else {
acep = (ace_t *)ptr;
acep->a_access_mask = BSWAP_32(acep->a_access_mask);
acep->a_flags = BSWAP_16(acep->a_flags);
ace_type = acep->a_type = BSWAP_16(acep->a_type);
acep->a_who = BSWAP_32(acep->a_who);
entry_type = acep->a_flags & ACE_TYPE_FLAGS;
}
switch (entry_type) {
case ACE_OWNER:
case ACE_EVERYONE:
case (ACE_IDENTIFIER_GROUP | ACE_GROUP):
entry_size = zfs_layout ?
sizeof (zfs_ace_hdr_t) : sizeof (ace_t);
break;
case ACE_IDENTIFIER_GROUP:
default:
if (zfs_layout) {
zacep->z_fuid = BSWAP_64(zacep->z_fuid);
}
switch (ace_type) {
case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
case ACE_ACCESS_DENIED_OBJECT_ACE_TYPE:
case ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE:
case ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE:
entry_size = zfs_layout ?
sizeof (zfs_object_ace_t) :
sizeof (ace_object_t);
break;
default:
entry_size = zfs_layout ? sizeof (zfs_ace_t) :
sizeof (ace_t);
break;
}
}
ptr = ptr + entry_size;
}
#else /* TODO */
panic("%s:%u: TODO", __func__, __LINE__);
#endif /* TODO */
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:68,代码来源:zfs_byteswap.c
示例16: zfs_znode_byteswap
void
zfs_znode_byteswap(void *buf, size_t size)
{
znode_phys_t *zp = buf;
ASSERT(size >= sizeof (znode_phys_t));
zp->zp_crtime[0] = BSWAP_64(zp->zp_crtime[0]);
zp->zp_crtime[1] = BSWAP_64(zp->zp_crtime[1]);
zp->zp_atime[0] = BSWAP_64(zp->zp_atime[0]);
zp->zp_atime[1] = BSWAP_64(zp->zp_atime[1]);
zp->zp_mtime[0] = BSWAP_64(zp->zp_mtime[0]);
zp->zp_mtime[1] = BSWAP_64(zp->zp_mtime[1]);
zp->zp_ctime[0] = BSWAP_64(zp->zp_ctime[0]);
zp->zp_ctime[1] = BSWAP_64(zp->zp_ctime[1]);
zp->zp_gen = BSWAP_64(zp->zp_gen);
zp->zp_mode = BSWAP_64(zp->zp_mode);
zp->zp_size = BSWAP_64(zp->zp_size);
zp->zp_parent = BSWAP_64(zp->zp_parent);
zp->zp_links = BSWAP_64(zp->zp_links);
zp->zp_xattr = BSWAP_64(zp->zp_xattr);
zp->zp_rdev = BSWAP_64(zp->zp_rdev);
zp->zp_flags = BSWAP_64(zp->zp_flags);
zp->zp_uid = BSWAP_64(zp->zp_uid);
zp->zp_gid = BSWAP_64(zp->zp_gid);
zp->zp_zap = BSWAP_64(zp->zp_zap);
zp->zp_pad[0] = BSWAP_64(zp->zp_pad[0]);
zp->zp_pad[1] = BSWAP_64(zp->zp_pad[1]);
zp->zp_pad[2] = BSWAP_64(zp->zp_pad[2]);
zp->zp_acl.z_acl_extern_obj = BSWAP_64(zp->zp_acl.z_acl_extern_obj);
zp->zp_acl.z_acl_size = BSWAP_32(zp->zp_acl.z_acl_size);
zp->zp_acl.z_acl_version = BSWAP_16(zp->zp_acl.z_acl_version);
zp->zp_acl.z_acl_count = BSWAP_16(zp->zp_acl.z_acl_count);
if (zp->zp_acl.z_acl_version == ZFS_ACL_VERSION) {
zfs_acl_byteswap((void *)&zp->zp_acl.z_ace_data[0],
ZFS_ACE_SPACE);
} else
zfs_oldace_byteswap((ace_t *)&zp->zp_acl.z_ace_data[0],
ACE_SLOT_CNT);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:41,代码来源:zfs_byteswap.c
示例17: main
int
main(int argc, char *argv[])
{
char *buf = malloc(INITIAL_BUFLEN);
dmu_replay_record_t thedrr;
dmu_replay_record_t *drr = &thedrr;
struct drr_begin *drrb = &thedrr.drr_u.drr_begin;
struct drr_end *drre = &thedrr.drr_u.drr_end;
struct drr_object *drro = &thedrr.drr_u.drr_object;
struct drr_freeobjects *drrfo = &thedrr.drr_u.drr_freeobjects;
struct drr_write *drrw = &thedrr.drr_u.drr_write;
struct drr_write_byref *drrwbr = &thedrr.drr_u.drr_write_byref;
struct drr_free *drrf = &thedrr.drr_u.drr_free;
struct drr_spill *drrs = &thedrr.drr_u.drr_spill;
char c;
boolean_t verbose = B_FALSE;
boolean_t first = B_TRUE;
int err;
zio_cksum_t zc = { 0 };
zio_cksum_t pcksum = { 0 };
while ((c = getopt(argc, argv, ":vC")) != -1) {
switch (c) {
case 'C':
do_cksum = B_FALSE;
break;
case 'v':
verbose = B_TRUE;
break;
case ':':
(void) fprintf(stderr,
"missing argument for '%c' option\n", optopt);
usage();
break;
case '?':
(void) fprintf(stderr, "invalid option '%c'\n",
optopt);
usage();
}
}
if (isatty(STDIN_FILENO)) {
(void) fprintf(stderr,
"Error: Backup stream can not be read "
"from a terminal.\n"
"You must redirect standard input.\n");
exit(1);
}
send_stream = stdin;
pcksum = zc;
while (ssread(drr, sizeof (dmu_replay_record_t), &zc)) {
if (first) {
if (drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) {
do_byteswap = B_TRUE;
if (do_cksum) {
ZIO_SET_CHECKSUM(&zc, 0, 0, 0, 0);
/*
* recalculate header checksum now
* that we know it needs to be
* byteswapped.
*/
fletcher_4_incremental_byteswap(drr,
sizeof (dmu_replay_record_t), &zc);
}
} else if (drrb->drr_magic != DMU_BACKUP_MAGIC) {
(void) fprintf(stderr, "Invalid stream "
"(bad magic number)\n");
exit(1);
}
first = B_FALSE;
}
if (do_byteswap) {
drr->drr_type = BSWAP_32(drr->drr_type);
drr->drr_payloadlen =
BSWAP_32(drr->drr_payloadlen);
}
/*
* At this point, the leading fields of the replay record
* (drr_type and drr_payloadlen) have been byte-swapped if
* necessary, but the rest of the data structure (the
* union of type-specific structures) is still in its
* original state.
*/
if (drr->drr_type >= DRR_NUMTYPES) {
(void) printf("INVALID record found: type 0x%x\n",
drr->drr_type);
(void) printf("Aborting.\n");
exit(1);
}
drr_record_count[drr->drr_type]++;
switch (drr->drr_type) {
case DRR_BEGIN:
if (do_byteswap) {
drrb->drr_magic = BSWAP_64(drrb->drr_magic);
drrb->drr_versioninfo =
//.........这里部分代码省略.........
开发者ID:ElCoyote27,项目名称:zfs-fuse,代码行数:101,代码来源:zstreamdump.c
示例18: zfs_space_delta_cb
static int
zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
uint64_t *userp, uint64_t *groupp)
{
/*
* Is it a valid type of object to track?
*/
if (bonustype != DMU_OT_ZNODE && bonustype != DMU_OT_SA)
return (SET_ERROR(ENOENT));
/*
* If we have a NULL data pointer
* then assume the id's aren't changing and
* return EEXIST to the dmu to let it know to
* use the same ids
*/
if (data == NULL)
return (SET_ERROR(EEXIST));
if (bonustype == DMU_OT_ZNODE) {
znode_phys_t *znp = data;
*userp = znp->zp_uid;
*groupp = znp->zp_gid;
} else {
int hdrsize;
sa_hdr_phys_t *sap = data;
sa_hdr_phys_t sa = *sap;
boolean_t swap = B_FALSE;
ASSERT(bonustype == DMU_OT_SA);
if (sa.sa_magic == 0) {
/*
* This should only happen for newly created
* files that haven't had the znode data filled
* in yet.
*/
*userp = 0;
*groupp = 0;
return (0);
}
if (sa.sa_magic == BSWAP_32(SA_MAGIC)) {
sa.sa_magic = SA_MAGIC;
sa.sa_layout_info = BSWAP_16(sa.sa_layout_info);
swap = B_TRUE;
} else {
VERIFY3U(sa.sa_magic, ==, SA_MAGIC);
}
hdrsize = sa_hdrsize(&sa);
VERIFY3U(hdrsize, >=, sizeof (sa_hdr_phys_t));
*userp = *((uint64_t *)((uintptr_t)data + hdrsize +
SA_UID_OFFSET));
*groupp = *((uint64_t *)((uintptr_t)data + hdrsize +
SA_GID_OFFSET));
if (swap) {
*userp = BSWAP_64(*userp);
*groupp = BSWAP_64(*groupp);
}
}
return (0);
}
开发者ID:nwf,项目名称:zfs,代码行数:62,代码来源:zfs_vfsops.c
示例19: zio_checksum_error_impl
int
zio_checksum_error_impl(spa_t *spa, blkptr_t *bp, enum zio_checksum checksum,
abd_t *abd, uint64_t size, uint64_t offset, zio_bad_cksum_t *info)
{
zio_checksum_info_t *ci = &zio_checksum_table[checksum];
int byteswap;
zio_cksum_t actual_cksum, expected_cksum;
if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
return (SET_ERROR(EINVAL));
zio_checksum_template_init(checksum, spa);
if (ci->ci_flags & ZCHECKSUM_FLAG_EMBEDDED) {
zio_eck_t *eck;
zio_cksum_t verifier;
size_t eck_offset;
uint64_t data_size = size;
void *data = abd_borrow_buf_copy(abd, data_size);
if (checksum == ZIO_CHECKSUM_ZILOG2) {
zil_chain_t *zilc = data;
uint64_t nused;
eck = &zilc->zc_eck;
if (eck->zec_magic == ZEC_MAGIC) {
nused = zilc->zc_nused;
} else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC)) {
nused = BSWAP_64(zilc->zc_nused);
} else {
abd_return_buf(abd, data, data_size);
return (SET_ERROR(ECKSUM));
}
if (nused > data_size) {
abd_return_buf(abd, data, data_size);
return (SET_ERROR(ECKSUM));
}
size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t);
} else {
eck = (zio_eck_t *)((char *)data + data_size) - 1;
}
if (checksum == ZIO_CHECKSUM_GANG_HEADER)
zio_checksum_gang_verifier(&verifier, bp);
else if (checksum == ZIO_CHECKSUM_LABEL)
zio_checksum_label_verifier(&verifier, offset);
else
verifier = bp->blk_cksum;
byteswap = (eck->zec_magic == BSWAP_64(ZEC_MAGIC));
if (byteswap)
byteswap_uint64_array(&verifier, sizeof (zio_cksum_t));
eck_offset = (size_t)(&eck->zec_cksum) - (size_t)data;
expected_cksum = eck->zec_cksum;
eck->zec_cksum = verifier;
abd_return_buf_copy(abd, data, data_size);
ci->ci_func[byteswap](abd, size,
spa->spa_cksum_tmpls[checksum], &actual_cksum);
abd_copy_from_buf_off(abd, &expected_cksum,
eck_offset, sizeof (zio_cksum_t));
if (byteswap) {
byteswap_uint64_array(&expected_cksum,
sizeof (zio_cksum_t));
}
} else {
byteswap = BP_SHOULD_BYTESWAP(bp);
expected_cksum = bp->blk_cksum;
ci->ci_func[byteswap](abd, size,
spa->spa_cksum_tmpls[checksum], &actual_cksum);
}
if (info != NULL) {
info->zbc_expected = expected_cksum;
info->zbc_actual = actual_cksum;
info->zbc_checksum_name = ci->ci_name;
info->zbc_byteswapped = byteswap;
info->zbc_injected = 0;
info->zbc_has_cksum = 1;
}
if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum))
return (SET_ERROR(ECKSUM));
return (0);
}
开发者ID:clefru,项目名称:zfs,代码行数:91,代码来源:zio_checksum.c
示例20: zfs_ace_byteswap
/*
* swap ace_t and ace_oject_t
*/
void
zfs_ace_byteswap(void *buf, size_t size, boolean_t zfs_layout)
{
caddr_t end;
caddr_t ptr;
zfs_ace_t *zacep;
ace_t *acep;
uint16_t entry_type;
size_t entry_size;
int ace_type;
end = (caddr_t)buf + size;
ptr = buf;
while (ptr < end) {
if (zfs_layout) {
/*
* Avoid overrun. Embedded aces can have one
* of several sizes. We don't know exactly
* how many our present, only the size of the
* buffer containing them. That size may be
* larger than needed to hold the aces
* present. As long as we do not do any
* swapping beyond the end of our block we are
* okay. It it safe to swap any non-ace data
* within the block since it is just zeros.
*/
if (ptr + sizeof (zfs_ace_hdr_t) > end) {
break;
}
zacep = (zfs_ace_t *)ptr;
zacep->z_hdr.z_access_mask =
BSWAP_32(zacep->z_hdr.z_access_mask);
zacep->z_hdr.z_flags = BSWAP_16(zacep->z_hdr.z_flags);
ace_type = zacep->z_hdr.z_type =
BSWAP_16(zacep->z_hdr.z_type);
entry_type = zacep->z_hdr.z_flags & ACE_TYPE_FLAGS;
} else {
/* Overrun avoidance */
if (ptr + sizeof (ace_t) > end) {
break;
}
acep = (ace_t *)ptr;
acep->a_access_mask = BSWAP_32(acep->a_access_mask);
acep->a_flags = BSWAP_16(acep->a_flags);
ace_type = acep->a_type = BSWAP_16(acep->a_type);
acep->a_who = BSWAP_32(acep->a_who);
entry_type = acep->a_flags & ACE_TYPE_FLAGS;
}
switch (entry_type) {
case ACE_OWNER:
case ACE_EVERYONE:
case (ACE_IDENTIFIER_GROUP | ACE_GROUP):
entry_size = zfs_layout ?
sizeof (zfs_ace_hdr_t) : sizeof (ace_t);
break;
case ACE_IDENTIFIER_GROUP:
default:
/* Overrun avoidance */
if (zfs_layout) {
if (ptr + sizeof (zfs_ace_t) <= end) {
zacep->z_fuid = BSWAP_64(zacep->z_fuid);
} else {
entry_size = sizeof (zfs_ace_t);
break;
}
}
switch (ace_type) {
case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
case ACE_ACCESS_DENIED_OBJECT_ACE_TYPE:
case ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE:
case ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE:
entry_size = zfs_layout ?
sizeof (zfs_object_ace_t) :
sizeof (ace_object_t);
break;
default:
entry_size = zfs_layout ? sizeof (zfs_ace_t) :
sizeof (ace_t);
break;
}
}
ptr = ptr + entry_size;
}
}
开发者ID:pscedu,项目名称:slash2-stable,代码行数:88,代码来源:zfs_byteswap.c
注:本文中的BSWAP_64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论