1 #include "fs.h" 2 #include "buf.h" 3 #include "inode.h" 4 #include <string.h> 5 #include <minix/optset.h> 6 7 /* SEF functions and variables. */ 8 static void sef_local_startup(void); 9 static int sef_cb_init_fresh(int type, sef_init_info_t *info); 10 static void sef_cb_signal_handler(int signo); 11 12 EXTERN int env_argc; 13 EXTERN char **env_argv; 14 15 static struct optset optset_table[] = { 16 { "sb", OPT_INT, &opt.block_with_super, 0 }, 17 { "orlov", OPT_BOOL, &opt.use_orlov, TRUE }, 18 { "oldalloc", OPT_BOOL, &opt.use_orlov, FALSE }, 19 { "mfsalloc", OPT_BOOL, &opt.mfsalloc, TRUE }, 20 { "reserved", OPT_BOOL, &opt.use_reserved_blocks, TRUE }, 21 { "prealloc", OPT_BOOL, &opt.use_prealloc, TRUE }, 22 { "noprealloc", OPT_BOOL, &opt.use_prealloc, FALSE }, 23 { NULL, 0, NULL, 0 } 24 }; 25 26 /*===========================================================================* 27 * main * 28 *===========================================================================*/ 29 int main(int argc, char *argv[]) 30 { 31 /* This is the main routine of this service. */ 32 unsigned short test_endian = 1; 33 34 /* SEF local startup. */ 35 env_setargs(argc, argv); 36 sef_local_startup(); 37 38 le_CPU = (*(unsigned char *) &test_endian == 0 ? 0 : 1); 39 40 /* Server isn't tested on big endian CPU */ 41 ASSERT(le_CPU == 1); 42 43 /* The fsdriver library does the actual work here. */ 44 fsdriver_task(&ext2_table); 45 46 return 0; 47 } 48 49 /*===========================================================================* 50 * sef_local_startup * 51 *===========================================================================*/ 52 static void sef_local_startup() 53 { 54 /* Register init callbacks. */ 55 sef_setcb_init_fresh(sef_cb_init_fresh); 56 sef_setcb_init_restart(sef_cb_init_fail); 57 58 /* No live update support for now. */ 59 60 /* Register signal callbacks. */ 61 sef_setcb_signal_handler(sef_cb_signal_handler); 62 63 /* Let SEF perform startup. */ 64 sef_startup(); 65 } 66 67 /*===========================================================================* 68 * sef_cb_init_fresh * 69 *===========================================================================*/ 70 static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) 71 { 72 /* Initialize the Minix file server. */ 73 int i; 74 75 /* Defaults */ 76 opt.use_orlov = TRUE; 77 opt.mfsalloc = FALSE; 78 opt.use_reserved_blocks = FALSE; 79 opt.block_with_super = 0; 80 opt.use_prealloc = FALSE; 81 82 /* If we have been given an options string, parse options from there. */ 83 for (i = 1; i < env_argc - 1; i++) 84 if (!strcmp(env_argv[i], "-o")) 85 optset_parse(optset_table, env_argv[++i]); 86 87 lmfs_may_use_vmcache(1); 88 89 /* Init inode table */ 90 for (i = 0; i < NR_INODES; ++i) { 91 inode[i].i_count = 0; 92 cch[i] = 0; 93 } 94 95 init_inode_cache(); 96 97 /* just a small number before we find out the block size at mount time */ 98 lmfs_buf_pool(10); 99 100 return(OK); 101 } 102 103 /*===========================================================================* 104 * sef_cb_signal_handler * 105 *===========================================================================*/ 106 static void sef_cb_signal_handler(int signo) 107 { 108 /* Only check for termination signal, ignore anything else. */ 109 if (signo != SIGTERM) return; 110 111 fs_sync(); 112 113 fsdriver_terminate(); 114 } 115