1 #include "fs.h" 2 #include "buf.h" 3 #include "inode.h" 4 5 6 /* SEF functions and variables. */ 7 static void sef_local_startup(void); 8 static int sef_cb_init_fresh(int type, sef_init_info_t *info); 9 static void sef_cb_signal_handler(int signo); 10 11 /*===========================================================================* 12 * main * 13 *===========================================================================*/ 14 int main(int argc, char *argv[]) 15 { 16 /* This is the main routine of this service. */ 17 18 /* SEF local startup. */ 19 env_setargs(argc, argv); 20 sef_local_startup(); 21 22 /* The fsdriver library does the actual work here. */ 23 fsdriver_task(&mfs_table); 24 25 return(0); 26 } 27 28 /*===========================================================================* 29 * sef_local_startup * 30 *===========================================================================*/ 31 static void sef_local_startup() 32 { 33 /* Register init callbacks. */ 34 sef_setcb_init_fresh(sef_cb_init_fresh); 35 sef_setcb_init_restart(sef_cb_init_fail); 36 37 /* No live update support for now. */ 38 39 /* Register signal callbacks. */ 40 sef_setcb_signal_handler(sef_cb_signal_handler); 41 42 /* Let SEF perform startup. */ 43 sef_startup(); 44 } 45 46 /*===========================================================================* 47 * sef_cb_init_fresh * 48 *===========================================================================*/ 49 static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) 50 { 51 /* Initialize the Minix file server. */ 52 int i; 53 54 lmfs_may_use_vmcache(1); 55 56 /* Init inode table */ 57 for (i = 0; i < NR_INODES; ++i) { 58 inode[i].i_count = 0; 59 cch[i] = 0; 60 } 61 62 init_inode_cache(); 63 64 lmfs_buf_pool(DEFAULT_NR_BUFS); 65 66 return(OK); 67 } 68 69 /*===========================================================================* 70 * sef_cb_signal_handler * 71 *===========================================================================*/ 72 static void sef_cb_signal_handler(int signo) 73 { 74 /* Only check for termination signal, ignore anything else. */ 75 if (signo != SIGTERM) return; 76 77 fs_sync(); 78 79 fsdriver_terminate(); 80 } 81 82 83 #if 0 84 /*===========================================================================* 85 * cch_check * 86 *===========================================================================*/ 87 static void cch_check(void) 88 { 89 int i; 90 91 for (i = 0; i < NR_INODES; ++i) { 92 if (inode[i].i_count != cch[i] && req_nr != REQ_GETNODE && 93 req_nr != REQ_PUTNODE && req_nr != REQ_READSUPER && 94 req_nr != REQ_MOUNTPOINT && req_nr != REQ_UNMOUNT && 95 req_nr != REQ_SYNC && req_nr != REQ_LOOKUP) { 96 printf("MFS(%d) inode(%lu) cc: %d req_nr: %d\n", sef_self(), 97 inode[i].i_num, inode[i].i_count - cch[i], req_nr); 98 } 99 100 cch[i] = inode[i].i_count; 101 } 102 } 103 #endif 104 105