/*static char *SCCSID = "@(#)fs_ioctl.c	6.2 92/01/31";*/
#define _BTXT _BTXT
#define INCL_DOSERRORS
#include <os2def.h>
#include <bse.h>
#include <fsh.h>
#include "heap.h"
#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "volume.h"
#include "tables.h"
#include "pb_ifs.h"
#include "pbmacros.h"
#include "superb.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "shutdown.h"
#include "pr_fsd.h"
#include "pr_HEAP.h"
#include "pr_DEBUG.h"

/*
 *	HISTORY
 *	    22-May-1990 by JR (John Rogers, JohnRo@Microsoft)
 *		- DCR 853: Update FS_IOCTL parms (ifdef'ed out for now).
 *	    24-May-1989 by JR (John Rogers, JohnRo@Microsoft)
 *		- DCR 259.2: added counting of write threads for shutdown.
 */

/* put stand-alone fs_xxx functions in separate code segment */


int far pascal
FS_IOCTL (struct sffsi far * psffsi,
	  struct sffsd far * psffsd,
	  USHORT	     cat,
	  USHORT	     func,
	  PCHAR		     pParm,
	  USHORT	     lenMaxParm,
	  PUSHORT	     plenInOutParm,
	  PCHAR		     pData,
	  USHORT	     lenMaxData,
	  PUSHORT	     plenInOutData)
{
	struct vpfsi far   *pVPBfsi;
	struct vpfsd far   *pVPBfsd;
	SHUTDOWN_LOCAL_VARS;
	USHORT		   usRet;

	INCR_WRITE_THREADS;		/* Tell shutdown we're writing. */

	/* get volume parameters */
	usRet = FSH_GETVOLPARM (psffsi->sfi_hVPB,
				(struct vpfsi far * far *) &pVPBfsi,
				(struct vpfsd far * far *) &pVPBfsd);

	if (usRet == 0)
	    usRet = FSH_DOVOLIO2 (pVPBfsi->vpi_hDEV,
				  psffsi->sfi_selfsfn,
				  cat,
				  func,
				  pParm,
				  lenMaxParm,
				  pData,
				  lenMaxData);


	DECR_WRITE_THREADS;		/* Tell shutdown we're done. */

	/* Set output lengths as best we can. */

	if (plenInOutData != NULL) {
	   *plenInOutData = lenMaxData;
	} /* endif */

	if (plenInOutParm != NULL) {
	   *plenInOutParm = lenMaxParm;
	} /* endif */

	return (usRet);

	/* to prevent /W3 warning */
	psffsd;
}
