/* ----------------------------------------------------- */ int main(int argc,char* argv[]) { signal(SIGINT, fs_sigint_handler); fs_set_limit_attr(); if (mpinit(0, 50)) return -1; voolefs.tc = 10; voolefs.tpool = threadpool_init(voolefs.tc ,10); voolefs.cinc = 8; voolefs.phost = mpcalloc(sizeof(struct host)); voolefs.phost->host = inet_addr("123.125.149.11"); voolefs.phost->port = htons(4869); voolefs.hostc = 1; voolefs.semc = 20; char* pmpoint = fs_create_mountpoint(); struct fuse_args args = FUSE_ARGS_INIT(argc, argv); char *fsname =(char*)mpcalloc(256); sprintf(fsname,"-osubtype=%s,fsname=%s",argv[0],pmpoint); mpfree(pmpoint); int ret = fuse_opt_parse(&args, NULL,NULL,NULL /*&voolefs, voolefs_opts, fs_opt_proc*/); int multithreaded = 0; int foreground = 0; ret = fuse_opt_insert_arg(&args,1,fsname); /* if (fuse_is_lib_option("ac_attr_timeout=")) fuse_opt_insert_arg(&args, 1, "-oauto_cache,ac_attr_timeout=0"); */ ret = fuse_parse_cmdline(&args, &voolefs.mountpoint, &multithreaded, &foreground); voolefs.ch = fuse_mount(voolefs.mountpoint, &args); // event_reinit(voolefs.ev_base); if(voolefs.ch) { ret = fcntl(fuse_chan_fd(voolefs.ch), F_SETFD, FD_CLOEXEC); voolefs.fuse = fuse_new(voolefs.ch,&args,&oper,sizeof(struct fuse_operations),NULL); if (voolefs.fuse == NULL) { fs_cleanup(); abort(); } fs_daemonize(0); voole_net_create(); /* if( multithreaded) ret = fuse_loop_mt(voolefs.fuse); else */ ret = fuse_loop(voolefs.fuse); } if( voolefs.fuse ) fuse_remove_signal_handlers(fuse_get_session(voolefs.fuse)); mpfree(fsname); if( voolefs.peventbase ) { event_base_free(voolefs.peventbase); voolefs.peventbase = NULL; } return ret; }
static void free_fdinfo(struct fd_info *fdi) { fs_cleanup(fdi); if (fdi->filename) { free(fdi->filename); fdi->filename = NULL; } if (fdi->fs_type) { free(fdi->fs_type); fdi->fs_type = NULL; } if (fdi->device) { free(fdi->device); fdi->device = NULL; } }
// init_main - the second kernel thread used to create kswapd_main & user_main kernel threads static int init_main(void *arg) { int pid; #ifndef CONFIG_NO_SWAP if ((pid = kernel_thread(kswapd_main, NULL, 0)) <= 0) { panic("kswapd init failed.\n"); } kswapd = find_proc(pid); set_proc_name(kswapd, "kswapd"); #else #warning swapping disabled #endif int ret; char root[] = "disk0:"; if ((ret = vfs_set_bootfs(root)) != 0) { panic("set boot fs failed: %e.\n", ret); } size_t nr_used_pages_store = nr_used_pages(); size_t slab_allocated_store = slab_allocated(); unsigned int nr_process_store = nr_process; pid = kernel_thread(user_main, NULL, 0); if (pid <= 0) { panic("create user_main failed.\n"); } while (do_wait(0, NULL) == 0) { if (nr_process_store == nr_process) { break; } schedule(); } #ifndef CONFIG_NO_SWAP assert(kswapd != NULL); int i; for (i = 0; i < 10; i ++) { if (kswapd->wait_state == WT_TIMER) { wakeup_proc(kswapd); } schedule(); } #endif mbox_cleanup(); fs_cleanup(); kprintf("all user-mode processes have quit, no /bin/sh?.\n"); #ifndef CONFIG_NO_SWAP assert(initproc->cptr == kswapd && initproc->yptr == NULL && initproc->optr == NULL); assert(kswapd->cptr == NULL && kswapd->yptr == NULL && kswapd->optr == NULL); assert(nr_process == 2 + pls_read(lcpu_count)); #else assert(nr_process == 1 + pls_read(lcpu_count)); #endif assert(nr_used_pages_store == nr_used_pages()); assert(slab_allocated_store == slab_allocated()); kprintf("init check memory pass.\n"); return 0; }