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

#include "chain.h"
#include "const.h"
#include "misc.h"
#include "buf.h"
#include "dir.h"
#include "volume.h"
#include "storage.h"
#include "tables.h"
#include "frame.h"
#include "pr_FSINI.h"

#ifdef DEBUG
#include "pr_debug.h"
#endif

/*
 ***	Init2 - Performs the second stage of initialization
 *
 *	This routine calls FixInMem, InitCP & CacheInit;
 *
 *	ENTRY	(none)
 *
 *	EXIT	Returns an error code
 *
 *	HISTORY
 *	    27-Feb-1990 by JR (John Rogers, JohnRo@Microsoft)
 *		- PTR B788315: init swap lock area sooner.
 *	    01-Nov-89 by JR (John Rogers, JohnRo@Microsoft)
 *		- PTR B786561: handle failed mem realloc (CacheInit).
 */

BOOL fCacheInit = FALSE;	/* Set by MFS_INIT, FS_MOUNT, ReopenFiles. */

INT far
Init2 (PFRAME pfrm)
{
    USHORT usRet;

	usRet = CacheInit(pfrm);
	if (usRet != NO_ERROR) {
#ifdef DEBUG
	    dprintf ("Init2: bad return from CacheInit=%d\n", usRet);
#endif
	    return (usRet);
	}

	if ((usRet = FixInMem ()) != NO_ERROR) {
#ifdef DEBUG
	    dprintf ("Init2: bad return from FixInMemory=%d\n", usRet);
#endif
	    return (usRet);
	}

	usRet = InitCP(pfrm);
	if (usRet != NO_ERROR) {
#ifdef DEBUG
	    dprintf ("Init2: bad return from InitCP=%d\n", usRet);
#endif
	    return (usRet);
	}


	return (NO_ERROR);

}
