/*static char *SCCSID = "@(#)getfnode.c	6.2 92/01/31";*/
#define _BTXT _BTXT
#define INCL_DOSERRORS
#include <os2def.h>
#include <bse.h>
#include <fsd.h>
#include <fsh.h>

#include "const.h"
#include "chain.h"
#include "misc.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "volume.h"
#include "tables.h"
#include "pbmacros.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"

#include "pr_MISC.h"
#include "pr_DEBUG.h"

int near
GetFNode (POFT	  poft,
	  PCHAR	  pcData,
	  USHORT  usLenData,
	  PUSHORT pusLenDataOut,
	  PFRAME  pfrm)
{
    USHORT usRet;

    /* Return the FNODE number for a file */

    /* Make sure the parameter and data lengths are correct */

    if (usLenData == sizeof (LSN)) {

	/* make sure we have enough room for the returned lsn */
	MAYBLOCK (
	    usRet = FSH_PROBEBUF (PB_OPWRITE, pcData, sizeof (LSN));
	);

	if (usRet != NO_ERROR) {
	    return usRet;
	}

	/*
	 * Okay return the lsn of the fnode.
	 *
	 * Get rid of vol bits first.
	 */
	*((PLSN) pcData) = poft->scpFNode.lsn & SECMASK;

	/* set size of returned data */
	*pusLenDataOut = sizeof (LSN);

    } else {
	usRet = ERROR_INVALID_FUNCTION;
    }

    return usRet;
}
