/*static char *SCCSID = "@(#)queryea.c	6.2 92/01/31";*/
#define BSWAP0 BSWAP0
#include <os2.h>
#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "ea.h"
#include "fnode.h"
#include "volume.h"
#include "tables.h"
#include "pbmacros.h"
#include "superb.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "log.h"

#include "pr_debug.h"
#include "pr_dir.h"
#include "pr_ea.h"
#include "pr_cache.h"
#include "pr_fssub.h"
#include "pr_misc.h"
#include "pr_read.h"

/*
 ***	QueryEA - Query EAs from file handle
 *
 *	Obtain Extended Attributes for an opened file
 *	(DosQFileInfo levels 3 & 4)
 *
 *	Entry	pfht = file handle
 *		pgeal = ptr to GEA list (0 for level 4)
 *		pfeal = ptr to FEA buffer
 *
 *	Returns 0 iff OK
 *		else
 *		  returns error code
 *		  *poffGEA = offset in GEA list (level 3 only)
 *	USES	ALL
 */

USHORT far
QueryEA(PFHT pfht,PGEALIST pgeal,PFEALIST pfeal,PUSHORT poError, BOOL fLevel, PFRAME pfrm)
{
	USHORT	 usRet;

	 /*
	  * We've got to put a lock on this guy to prevent parallel EA updates.
	  * We don't really want to lock out data access, but thats too bad.
	  *
	  */

	HoldOFT (pfht->poft,pfrm);

	IncrHoldsOFT (pfht->poft);

	CHECKSWAP(&swapBSWAP0);
	usRet = GetEA(pfeal, pgeal, pfht->poft, poError, fLevel, pfrm);

	UnHoldOFT (pfht->poft);

	/*
	 * We're done.  Now we release the OFT and exit.
	 *
	 *   usRet (al) = error code or 0 if OK
	 *   pfeal (ebx) = FEA buffer pointer
	 *   pfht->poft (edi) = OFT address, locked
	 */

	return usRet;

}
