Exemplo n.º 1
0
/**
 * Swap headers only if the byte order is little endian
 */
static void
_ffdb_swap_header (ffdb_htab_t* hashp)
{
  ffdb_hashhdr_t *hdrp;
  int i;

  hdrp = &hashp->hdr;

  M_32_SWAP(hdrp->magic);
  M_32_SWAP(hdrp->version);
  M_32_SWAP(hdrp->lorder);
  M_32_SWAP(hdrp->bsize);
  M_32_SWAP(hdrp->bshift);
  M_32_SWAP(hdrp->ovfl_point);
  M_32_SWAP(hdrp->max_bucket);
  M_32_SWAP(hdrp->high_mask);
  M_32_SWAP(hdrp->low_mask);
  M_32_SWAP(hdrp->ffactor);
  M_32_SWAP(hdrp->nkeys);
  M_32_SWAP(hdrp->hdrpages);
  M_32_SWAP(hdrp->uinfolen);
  M_16_SWAP(hdrp->uinfo_page);
  M_16_SWAP(hdrp->uinfo_npages);
  M_16_SWAP(hdrp->cfig_page);
  M_16_SWAP(hdrp->cfig_npages);
  M_32_SWAP(hdrp->num_cfigs);
  M_32_SWAP(hdrp->h_charkey);
  M_32_SWAP(hdrp->num_moved_pages);
  for (i = 0; i < NCACHED; i++) 
    M_32_SWAP(hdrp->spares[i]);
  for (i = 0; i < NCACHED; i++) 
    M_32_SWAP(hdrp->free_pages[i]);
  M_32_SWAP(hdrp->chksum);
}
Exemplo n.º 2
0
static void
swap_header(HTAB *hashp)
{
	HASHHDR *hdrp;
	int i;

	hdrp = &hashp->hdr;

	M_32_SWAP(hdrp->magic);
	M_32_SWAP(hdrp->version);
	M_32_SWAP(hdrp->lorder);
	M_32_SWAP(hdrp->bsize);
	M_32_SWAP(hdrp->bshift);
	M_32_SWAP(hdrp->dsize);
	M_32_SWAP(hdrp->ssize);
	M_32_SWAP(hdrp->sshift);
	M_32_SWAP(hdrp->ovfl_point);
	M_32_SWAP(hdrp->last_freed);
	M_32_SWAP(hdrp->max_bucket);
	M_32_SWAP(hdrp->high_mask);
	M_32_SWAP(hdrp->low_mask);
	M_32_SWAP(hdrp->ffactor);
	M_32_SWAP(hdrp->nkeys);
	M_32_SWAP(hdrp->hdrpages);
	M_32_SWAP(hdrp->h_charkey);
	for (i = 0; i < NCACHED; i++) {
		M_32_SWAP(hdrp->spares[i]);
		M_16_SWAP(hdrp->bitmaps[i]);
	}
}
Exemplo n.º 3
0
static void
swabvid(struct cpu_disklabel *pcpul)
{
	M_32_SWAP(pcpul->vid_oss);
	M_16_SWAP(pcpul->vid_osl);
	/*
	M_16_SWAP(pcpul->vid_osa_u);
	M_16_SWAP(pcpul->vid_osa_l);
	*/
	M_32_SWAP(pcpul->vid_cas);
}
Exemplo n.º 4
0
/*
 * __BT_BPGIN, __BT_BPGOUT --
 *	Convert host-specific number layout to/from the host-independent
 *	format stored on disk.
 *
 * Parameters:
 *	t:	tree
 *	pg:	page number
 *	h:	page to convert
 */
void
__bt_pgin(void *t, pgno_t pg, void *pp)
{
    PAGE *h;
    indx_t i, top;
    u_char flags;
    char *p;

    if (!F_ISSET(((BTREE *)t), B_NEEDSWAP))
        return;
    if (pg == P_META) {
        mswap(pp);
        return;
    }

    h = pp;
    M_32_SWAP(h->pgno);
    M_32_SWAP(h->prevpg);
    M_32_SWAP(h->nextpg);
    M_32_SWAP(h->flags);
    M_16_SWAP(h->lower);
    M_16_SWAP(h->upper);

    top = NEXTINDEX(h);
    if ((h->flags & P_TYPE) == P_BINTERNAL)
        for (i = 0; i < top; i++) {
            M_16_SWAP(h->linp[i]);
            p = (char *)GETBINTERNAL(h, i);
            P_32_SWAP(p);
            p += sizeof(u_int32_t);
            P_32_SWAP(p);
            p += sizeof(pgno_t);
            if (*(u_char *)p & P_BIGKEY) {
                p += sizeof(u_char);
                P_32_SWAP(p);
                p += sizeof(pgno_t);
                P_32_SWAP(p);
            }
        }
    else if ((h->flags & P_TYPE) == P_BLEAF)
        for (i = 0; i < top; i++) {
            M_16_SWAP(h->linp[i]);
            p = (char *)GETBLEAF(h, i);
            P_32_SWAP(p);
            p += sizeof(u_int32_t);
            P_32_SWAP(p);
            p += sizeof(u_int32_t);
            flags = *(u_char *)p;
            if (flags & (P_BIGKEY | P_BIGDATA)) {
                p += sizeof(u_char);
                if (flags & P_BIGKEY) {
                    P_32_SWAP(p);
                    p += sizeof(pgno_t);
                    P_32_SWAP(p);
                }
                if (flags & P_BIGDATA) {
                    p += sizeof(u_int32_t);
                    P_32_SWAP(p);
                    p += sizeof(pgno_t);
                    P_32_SWAP(p);
                }
            }
        }
}
Exemplo n.º 5
0
static void
swabcfg(struct cpu_disklabel *pcpul)
{
	M_16_SWAP(pcpul->cfg_atm);
	M_16_SWAP(pcpul->cfg_prm);
	M_16_SWAP(pcpul->cfg_atm);
	M_16_SWAP(pcpul->cfg_rec);
	M_16_SWAP(pcpul->cfg_trk);
	M_16_SWAP(pcpul->cfg_psm);
	M_16_SWAP(pcpul->cfg_shd);
	M_16_SWAP(pcpul->cfg_pcom);
	M_16_SWAP(pcpul->cfg_rwcc);
	M_16_SWAP(pcpul->cfg_ecc);
	M_16_SWAP(pcpul->cfg_eatm);
	M_16_SWAP(pcpul->cfg_eprm);
	M_16_SWAP(pcpul->cfg_eatw);
	M_16_SWAP(pcpul->cfg_rsvc1);
	M_16_SWAP(pcpul->cfg_rsvc2);
}