103 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#include "fs.h"
 | 
						|
#include "buf.h"
 | 
						|
#include "inode.h"
 | 
						|
 | 
						|
 | 
						|
/* SEF functions and variables. */
 | 
						|
static void sef_local_startup(void);
 | 
						|
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
 | 
						|
static void sef_cb_signal_handler(int signo);
 | 
						|
 | 
						|
/*===========================================================================*
 | 
						|
 *				main                                         *
 | 
						|
 *===========================================================================*/
 | 
						|
int main(int argc, char *argv[])
 | 
						|
{
 | 
						|
/* This is the main routine of this service. */
 | 
						|
 | 
						|
  /* SEF local startup. */
 | 
						|
  env_setargs(argc, argv);
 | 
						|
  sef_local_startup();
 | 
						|
 | 
						|
  /* The fsdriver library does the actual work here. */
 | 
						|
  fsdriver_task(&mfs_table);
 | 
						|
 | 
						|
  return(0);
 | 
						|
}
 | 
						|
 | 
						|
/*===========================================================================*
 | 
						|
 *			       sef_local_startup			     *
 | 
						|
 *===========================================================================*/
 | 
						|
static void sef_local_startup()
 | 
						|
{
 | 
						|
  /* Register init callbacks. */
 | 
						|
  sef_setcb_init_fresh(sef_cb_init_fresh);
 | 
						|
  sef_setcb_init_restart(SEF_CB_INIT_RESTART_STATEFUL);
 | 
						|
 | 
						|
  /* Register signal callbacks. */
 | 
						|
  sef_setcb_signal_handler(sef_cb_signal_handler);
 | 
						|
 | 
						|
  /* Let SEF perform startup. */
 | 
						|
  sef_startup();
 | 
						|
}
 | 
						|
 | 
						|
/*===========================================================================*
 | 
						|
 *		            sef_cb_init_fresh                                *
 | 
						|
 *===========================================================================*/
 | 
						|
static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
 | 
						|
{
 | 
						|
/* Initialize the Minix file server. */
 | 
						|
  int i;
 | 
						|
 | 
						|
  lmfs_may_use_vmcache(1);
 | 
						|
 | 
						|
  /* Init inode table */
 | 
						|
  for (i = 0; i < NR_INODES; ++i) {
 | 
						|
	inode[i].i_count = 0;
 | 
						|
	cch[i] = 0;
 | 
						|
  }
 | 
						|
	
 | 
						|
  init_inode_cache();
 | 
						|
 | 
						|
  lmfs_buf_pool(DEFAULT_NR_BUFS);
 | 
						|
 | 
						|
  return(OK);
 | 
						|
}
 | 
						|
 | 
						|
/*===========================================================================*
 | 
						|
 *		           sef_cb_signal_handler                             *
 | 
						|
 *===========================================================================*/
 | 
						|
static void sef_cb_signal_handler(int signo)
 | 
						|
{
 | 
						|
  /* Only check for termination signal, ignore anything else. */
 | 
						|
  if (signo != SIGTERM) return;
 | 
						|
 | 
						|
  fs_sync();
 | 
						|
 | 
						|
  fsdriver_terminate();
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
#if 0
 | 
						|
/*===========================================================================*
 | 
						|
 *				cch_check				     *	
 | 
						|
 *===========================================================================*/
 | 
						|
static void cch_check(void) 
 | 
						|
{
 | 
						|
  int i;
 | 
						|
 | 
						|
  for (i = 0; i < NR_INODES; ++i) {
 | 
						|
	if (inode[i].i_count != cch[i] && req_nr != REQ_GETNODE &&
 | 
						|
	    req_nr != REQ_PUTNODE && req_nr != REQ_READSUPER &&
 | 
						|
	    req_nr != REQ_MOUNTPOINT && req_nr != REQ_UNMOUNT &&
 | 
						|
	    req_nr != REQ_SYNC && req_nr != REQ_LOOKUP) {
 | 
						|
		printf("MFS(%d) inode(%lu) cc: %d req_nr: %d\n", sef_self(),
 | 
						|
			inode[i].i_num, inode[i].i_count - cch[i], req_nr);
 | 
						|
	}
 | 
						|
	  
 | 
						|
	cch[i] = inode[i].i_count;
 | 
						|
  }
 | 
						|
}
 | 
						|
#endif
 | 
						|
 |