/*static char *SCCSID = "@(#)hldtolck.c	6.2 92/01/31";*/
#ifndef	 _BTXT
#define	 _BTXT _BTXT
#define	 _THISFILE "HLDTOLCK.C"
#include _THISFILE.C
#undef	 _BTXT
#endif

#ifndef HDRS
#define HDRS

#include <os2def.h>
#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "fnode.h"
#include "volume.h"
#include "tables.h"
#include "pb_ifs.h"
#include "superb.h"
#include "pbmacros.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "assert.h"
#include "log.h"

#endif

#include "pr_MISC.h"
#include "pr_FSSUB.h"
#include "pr_debug.h"

/*
 ***	HoldToLock - Convert a Hold to a Lock
 *
 *	HoldToLock converts a hold to a lock, if it can be done without
 *	yielding.  If a yield is necessary, the hold is released but
 *	the lock is not set.  The caller then has to check to see if
 *	the file has changed out from underneith him.
 *
 *	This routine is expanded inline in EFA and perhaps other places.
 *
 *	ENTRY	poft = OFT address
 *
 *	RETURNS TRUE  if locked without yield
 *		FALSE if unheld because we yielded
 */
BOOL
HoldToLock( poft,pfrm )
POFT poft;
PFRAME pfrm;
{
    DecrHoldsOFT (poft);

    ASSERT_OFT (poft);

    if (poft->cusHolds == 0 && (poft->bFlag == 0 ||
	poft->bFlag == (OTF_PND | OTF_PSO))) {

	    /* if no one waiting, or just a pending solo, then just lock it */
	    SetLockOFT(poft);
	    return TRUE;
    }
    LockOFT (poft,pfrm);
    IncrHoldsOFT (poft);
    UnHoldOFT (poft);
    return FALSE;
}
