/*static char *SCCSID = "@(#)bldeaat.c	6.2 92/01/31";*/
#define BSWAP0 BSWAP0
#include <os2.h>

#include "const.h"
#include "misc.h"
#include "storage.h"

#include "buf.h"
#include "fnode.h"
#include "chain.h"
#include "dir.h"
#include "volume.h"
#include "tables.h"
#include "frame.h"
#include "ea.h"

#include "pr_ea.h"

/*
 ***	BuildEAAT - Build an EAAT Record
 *
 *	The allocation B+TREE routines work from a root ALBLK
 *	record, but we store the denser EAAT form.  BuildEAAT
 *	updates an EAAT record to reflect the ALBLK record.  Note
 *	that the ALBLK record is a special one which has at most
 *	one extent or down pointer in it.
 *
 *	Note that only the sector part of the record is updated; the
 *	length part is not since the ALBLK record has no length info.
 *
 *	WARNING - BuildEAAT is called pointing to an EAAT or an AUXINFO
 *		record.  The relevant fields in each must line up.
 *
 *
 *	ENTRY	pstp = address of STP structure in AUXINFO or EAAT structure
 *		palb = address of ALBLK record
 *
 *	RETURNS (USHORT)
 *		FF_DAT iff it's a multi level tree
 *		0      otherwise
 */

USHORT
BuildEAAT (psptr, palb)
PSPTR psptr;
PALBLK palb;

{
    if ((palb->bFlag & ABF_NODE) == 0) {
	PALLEAF pall;

	pall = PALLFROMPALB (palb);
	psptr->lsn = pall->lsnPhys;
	return 0;
    }

    {
	PALNODE paln;

	paln = PALNFROMPALB (palb);
	psptr->lsn = paln->lsnPhys;
	return (FF_DAT);
    }
}
