int _start( int argc, char *argv[]) { printf("USB HDD FileSystem Driver v%d.%d\n", MAJOR_VER, MINOR_VER); if (RegisterLibraryEntries(&_exp_usbmass) != 0) { printf("USBHDFSD: Already registered.\n"); return MODULE_NO_RESIDENT_END; } // initialize the FAT driver if(InitFAT() != 0) { printf("USBHDFSD: Error initializing FAT driver!\n"); return MODULE_NO_RESIDENT_END; } // initialize the USB driver if(InitUSB() != 0) { printf("USBHDFSD: Error initializing USB driver!\n"); return MODULE_NO_RESIDENT_END; } // initialize the file system driver if(InitFS() != 0) { printf("USBHDFSD: Error initializing FS driver!\n"); return MODULE_NO_RESIDENT_END; } // return resident return MODULE_RESIDENT_END; }
int main(void) { char cmd[MAX_CMD]; ShellCmds *c; bzero(CWD, MAX_CMD); strcpy(CWD, "/"); if (InitFS(512*1024)) { puts("Failed to initialize the RAM file system\n"); return(-1); } puts("Welcome to the cgcfs shell!"); puts("Type help for a list of available commands."); printf("% "); bzero(cmd, MAX_CMD); while (readUntil(cmd, MAX_CMD-1, '\n') != -1) { ParseArgs(cmd); // parse failure if (ARGC == 0) { FreeArgs(); bzero(cmd, MAX_CMD); printf("% "); continue; } // find the command being requested if (ARGV[0] != NULL) { c = cmds; while (c->command != NULL) { if (!strcmp(c->command, ARGV[0])) { // run the command c->handler(); break; } c++; } } if (c == NULL) { puts("Invalid command"); } if (c->command == NULL) { puts("Invalid command"); } FreeArgs(); bzero(cmd, MAX_CMD); printf("% "); } if (DestroyFS()) { puts("Failed to destroy the RAM file system\n"); return(-1); } return(0); }
u32 InitializeD9() { u32 errorlevel = 0; // 0 -> none, 1 -> autopause, 2 -> critical ClearScreenFull(true, true); DebugClear(); #ifndef BUILD_NAME Debug("-- Decrypt9 --"); #else Debug("-- %s --", BUILD_NAME); #endif // a little bit of information about the current menu if (sizeof(menu)) { u32 n_submenus = 0; u32 n_features = 0; for (u32 m = 0; menu[m].n_entries; m++) { n_submenus = m; for (u32 e = 0; e < menu[m].n_entries; e++) n_features += (menu[m].entries[e].function) ? 1 : 0; } Debug("Counting %u submenus and %u features", n_submenus, n_features); } Debug("Initializing, hold L+R to pause"); Debug(""); if (InitFS()) { Debug("Initializing SD card... success"); FileGetData("d9logo.bin", BOT_SCREEN0, 320 * 240 * 3, 0); memcpy(BOT_SCREEN1, BOT_SCREEN0, 320 * 240 * 3); if (SetupTwlKey0x03() != 0) // TWL KeyX / KeyY errorlevel = 2; if ((GetUnitPlatform() == PLATFORM_N3DS) && (LoadKeyFromFile(0x05, 'Y', NULL) != 0)) errorlevel = (((*(vu32*) 0x101401C0) == 0) || (errorlevel > 1)) ? 2 : 1; // N3DS CTRNAND KeyY if (LoadKeyFromFile(0x25, 'X', NULL)) // NCCH 7x KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; if (LoadKeyFromFile(0x18, 'X', NULL)) // NCCH Secure3 KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; if (LoadKeyFromFile(0x1B, 'X', NULL)) // NCCH Secure4 KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; Debug("Finalizing Initialization..."); RemainingStorageSpace(); } else { Debug("Initializing SD card... failed"); errorlevel = 2; } Debug(""); Debug("Initialization: %s", (errorlevel == 0) ? "success!" : (errorlevel == 1) ? "partially failed" : "failed!"); if (((~HID_STATE & BUTTON_L1) && (~HID_STATE & BUTTON_R1)) || (errorlevel > 1)) { Debug("(A to %s)", (errorlevel > 1) ? "exit" : "continue"); while (!(InputWait() & BUTTON_A)); } return errorlevel; }
int main() { ClearScreenFull(true, true); InitFS(); u32 menu_exit = ProcessMenu(menu, SUBMENU_START); DeinitFS(); (menu_exit == MENU_EXIT_REBOOT) ? Reboot() : PowerOff(); return 0; }
int main() { THREAD_ID ptid; long res; if ((res = InitFS()) != NO_ERROR) return res; InitPart(); KCreateThread((void(*)(void*))CacheProc, 0x40000, (void*)PROC_INTERVAL, &ptid); /*启动后台定时缓冲保存线程*/ for (;;) { DWORD data[MSG_DATA_LEN + 1]; if ((res = KRecvMsg((THREAD_ID*)&data[PTID_ID], data, INVALID)) != NO_ERROR) /*等待消息*/ break; if ((data[MSG_ATTR_ID] & MSG_ATTR_MASK) == MSG_ATTR_THEDEXIT) /*子线程退出*/ SubthCou--; else if ((data[MSG_ATTR_ID] & MSG_ATTR_MASK) == MSG_ATTR_PROCEXIT) data[MSG_ATTR_ID] = MSG_ATTR_FS | FS_API_PROCEXIT; if ((data[MSG_ATTR_ID] & MSG_MAP_MASK) == MSG_ATTR_ROMAP || (data[MSG_ATTR_ID] & MSG_ATTR_MASK) == MSG_ATTR_FS) { DWORD *buf; if ((data[MSG_API_ID] & MSG_API_MASK) >= sizeof(ApiTable) / sizeof(void*)) { data[MSG_RES_ID] = FS_ERR_WRONG_ARGS; if (data[MSG_ATTR_ID] < MSG_ATTR_USER) KUnmapProcAddr((void*)data[MSG_ADDR_ID], data); else KSendMsg((THREAD_ID*)&data[PTID_ID], data, 0); } else if ((buf = (DWORD*)malloc(sizeof(DWORD) * (MSG_DATA_LEN + 1))) == NULL) { data[MSG_RES_ID] = FS_ERR_HAVENO_MEMORY; if (data[MSG_ATTR_ID] < MSG_ATTR_USER) KUnmapProcAddr((void*)data[MSG_ADDR_ID], data); else KSendMsg((THREAD_ID*)&data[PTID_ID], data, 0); } else { memcpy32(buf, data, MSG_DATA_LEN + 1); KCreateThread((void(*)(void*))ApiProc, 0x40000, buf, &ptid); SubthCou++; } } else if (data[MSG_ATTR_ID] == MSG_ATTR_EXTPROCREQ) break; } CloseFS(); return NO_ERROR; }
int _start(int argc, char** argv) { if(InitFAT() != 0) { printf("Error initializing FAT driver!\n"); return MODULE_NO_RESIDENT_END; } init_ieee1394DiskDriver(); InitFS(); return MODULE_RESIDENT_END; }
u32 UnmountSd() { u32 pad_state; DebugClear(); Debug("Unmounting SD card..."); DeinitFS(); Debug("SD is unmounted, you may remove it now."); Debug("Put the SD card back in before pressing B!"); Debug(""); Debug("(B to return, START to reboot)"); while (true) { pad_state = InputWait(); if (((pad_state & BUTTON_B) && InitFS()) || (pad_state & BUTTON_START)) break; } return pad_state; }
static void open_log_file(struct logging_status *ls) { pr_info("Logging: Opening log file\r\n"); ls->writing_status = WRITING_INACTIVE; const int rc = InitFS(); if (0 != rc) { pr_error_int_msg("Logging: FS init error: ", rc); return; } pr_debug("Logging: FS init success. Opening file...\r\n"); // Open a file if one is set, else create a new one. ls->writing_status = ls->name[0] ? open_existing_log_file(ls) : open_new_log_file(ls); if (WRITING_INACTIVE == ls->writing_status) { pr_warning_str_msg("Logging: Failed to open: ", ls->name); return; } pr_info_str_msg("Logging: Opened " , ls->name); ls->flush_tick = xTaskGetTickCount(); }
u32 UnmountSd() { u32 pad_state; #ifdef USE_THEME LoadThemeGfx(GFX_UNMOUNT, false); DeinitFS(); #else DebugClear(); Debug("Unmounting SD card..."); DeinitFS(); Debug("SD is unmounted, you may remove it now."); Debug("Put the SD card back in before pressing B!"); Debug(""); Debug("(B to return, START to reboot)"); #endif while (true) { pad_state = InputWait(); if (((pad_state & BUTTON_B) && InitFS()) || (pad_state & BUTTON_START)) break; } return pad_state; }
u32 UnmountSd() { u32 pad_state; #ifdef USE_THEME LoadThemeGfx(GFX_UNMOUNT, false); DeinitFS(); #else DebugClear(); Debug("Desmonatando la tarjeta SD..."); DeinitFS(); Debug("La tarjeta SD ha sido desmontada, puedes removerla ahora."); Debug("¡Inserta la tarjeta SD antes de pulsar B!"); Debug(""); Debug("(B para volver, START para reiniciar)"); #endif while (true) { pad_state = InputWait(); if (((pad_state & BUTTON_B) && InitFS()) || (pad_state & BUTTON_START)) break; } return pad_state; }
/** * Main daemon routine */ int main(int argc, char **argv) { int c, option_index = 0; const char *bin; char config_file[MAX_OPT_LEN] = ""; bool do_start = false; bool do_reset = false; bool do_resume = false; bool do_complete = false; bool do_status = false; int list_state = -1; int local_flags = 0; int rc; char err_msg[4096]; robinhood_config_t config; struct sigaction act_sigterm; int chgd = 0; char badcfg[RBH_PATH_MAX]; bin = rh_basename(argv[0]); /* supports NULL argument */ /* parse command line options */ while ((c = getopt_long(argc, argv, SHORT_OPT_STRING, option_tab, &option_index)) != -1) { switch (c) { case 'S': do_start = true; break; case 's': do_status = true; break; case 'Z': do_reset = true; break; case 'c': do_complete = true; break; case 'r': do_resume = true; break; case 'L': if (!strcasecmp(optarg, "all")) list_state = RT_ALL; else if (!strcasecmp(optarg, "done")) list_state = RT_DONE; else if (!strcasecmp(optarg, "failed")) list_state = RT_FAILED; else if (!strcasecmp(optarg, "todo")) list_state = RT_TODO; else { fprintf(stderr, "Invalid parameter for option --list: all, done, failed or todo expected.\n"); exit(1); } break; case 'e': local_flags |= RETRY_ERRORS; break; case 'y': local_flags |= NO_CONFIRM; break; case 'f': rh_strncpy(config_file, optarg, MAX_OPT_LEN); break; case 'D': if (!optarg) { fprintf(stderr, "Missing mandatory argument <path> for --dir\n"); exit(1); } else { rh_strncpy(path_buff, optarg, MAX_OPT_LEN); path_filter = path_buff; } break; case 'o': if (!optarg) { fprintf(stderr, "Missing mandatory argument <ost_index> for --ost\n"); exit(1); } /* parse it as a set */ if (lmgr_range2list(optarg, DB_UINT, &ost_list)) { fprintf(stderr, "Invalid value '%s' for --ost option: integer or set expected (e.g. 2 or 3,5-8,10-12).\n", optarg); exit(1); } /* copy arg to display it */ rh_strncpy(ost_range_str, optarg, sizeof(ost_range_str)); break; case 'b': if (!optarg) { fprintf(stderr, "Missing mandatory argument <date_time> for --since\n"); exit(1); } since_time = str2date(optarg); if (since_time == (time_t)-1) { fprintf(stderr, "Invalid date format: yyyymmdd[HH[MM[SS]]] expected\n"); exit(1); } break; case 'l': { int log_level = str2debuglevel(optarg); if (log_level == -1) { fprintf(stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg); exit(1); } force_debug_level(log_level); break; } case 'h': display_help(bin); exit(0); break; case 'V': display_version(bin); exit(0); break; case ':': case '?': default: display_help(bin); exit(1); break; } } /* check there is no extra arguments */ if (optind != argc) { fprintf(stderr, "Error: unexpected argument on command line: %s\n", argv[optind]); exit(1); } rc = rbh_init_internals(); if (rc != 0) exit(rc); /* get default config file, if not specified */ if (SearchConfig(config_file, config_file, &chgd, badcfg, MAX_OPT_LEN) != 0) { fprintf(stderr, "No config file (or too many) found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", config_file); } /* only read ListMgr config */ if (ReadRobinhoodConfig(0, config_file, err_msg, &config, false)) { fprintf(stderr, "Error reading configuration file '%s': %s\n", config_file, err_msg); exit(1); } /* XXX HOOK: Set logging to stderr */ strcpy(config.log_config.log_file, "stderr"); strcpy(config.log_config.report_file, "stderr"); strcpy(config.log_config.alert_file, "stderr"); /* Initialize logging */ rc = InitializeLogs(bin, &config.log_config); if (rc) { fprintf(stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror(errno)); exit(rc); } /* Initialize filesystem access */ rc = InitFS(); if (rc) exit(rc); /* Initialize status managers (XXX all or just the one used for * recovery?) */ rc = smi_init_all(options.flags); if (rc) exit(rc); /* Initialize list manager */ rc = ListMgr_Init(0); if (rc) { DisplayLog(LVL_CRIT, RECOV_TAG, "Error initializing list manager: %s (%d)", lmgr_err2str(rc), rc); exit(rc); } else DisplayLog(LVL_DEBUG, RECOV_TAG, "ListManager successfully initialized"); if (CheckLastFS() != 0) exit(1); /* Create database access */ rc = ListMgr_InitAccess(&lmgr); if (rc) { DisplayLog(LVL_CRIT, RECOV_TAG, "Error %d: cannot connect to database", rc); exit(rc); } #ifdef _HSM_LITE rc = Backend_Start(&config.backend_config, 0); if (rc) { DisplayLog(LVL_CRIT, RECOV_TAG, "Error initializing backend"); exit(1); } #endif /* create signal handlers */ memset(&act_sigterm, 0, sizeof(act_sigterm)); act_sigterm.sa_flags = 0; act_sigterm.sa_handler = terminate_handler; if (sigaction(SIGTERM, &act_sigterm, NULL) == -1 || sigaction(SIGINT, &act_sigterm, NULL) == -1) { DisplayLog(LVL_CRIT, RECOV_TAG, "Error while setting signal handlers for SIGTERM and SIGINT: %s", strerror(errno)); exit(1); } else DisplayLog(LVL_VERB, RECOV_TAG, "Signals SIGTERM and SIGINT (abort command) are ready to be used"); if (do_status) rc = recov_status(); else if (list_state != -1) rc = recov_list(list_state); else if (do_start) rc = recov_start(); else if (do_reset) rc = recov_reset(local_flags & NO_CONFIRM); else if (do_resume) rc = recov_resume(local_flags & RETRY_ERRORS); else if (do_complete) rc = recov_complete(); else { display_help(bin); rc = 1; } ListMgr_CloseAccess(&lmgr); return rc; }
bool COLLADA_Viewer::onInit(int argc, char **ppArgv) { FWGLApplication::onInit(argc, ppArgv); glClearColor(0.3f,0.3f,0.7f, 0.0f); glClearDepthf(1.0f); glEnable(GL_DEPTH_TEST); FWDebugFont::setColor(1.f, 1.f, 1.f, 1.f); InitFS(); Browser.Init(); psglLoadShaderLibrary("/app_home/shaders.bin"); // Initialize the renderer _CrtRender.Init(); _CrtRender.SetUsingVBOs(CrtTrue); _CrtRender.SetShowHiearchy(CrtTrue); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 1.0f, 0.5f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); cgRTCgcInit(); ParseDir("/app_home/"); // Load the target file Browser.onUpdate(); if (argc > 0) { char path_name[1024]; mCurrentFile = ppArgv[0]; sprintf(path_name, "%s%s", "/app_home/", ppArgv[0]); printf(path_name); load_ok = _CrtRender.Load(path_name, NULL); if ( !load_ok ) return false; } else if (Browser.GetSize() > 0) { mCurrentFile = Browser.GetThumbnail(0)->GetDocument(); load_ok = _CrtRender.Load(mCurrentFile, NULL); if ( !load_ok ) return false; } // Get the gamepad so we can read it later mpPad = FWInput::getDevice(FWInput::DeviceType_Pad,0); if(mpPad==NULL) { printf("Error, couldn't get a pad\n"); exit(0); } mpInputX0 = mpPad->bindFilter(); mpInputX0->setChannel(FWInput::Channel_XAxis_0); mpInputX0->setGain( 1.0f ); mpInputX0->setDeadzone( 0.3f ); mpInputY0 = mpPad->bindFilter(); mpInputY0->setChannel(FWInput::Channel_YAxis_0); mpInputY0->setGain( 1.0f ); mpInputY0->setDeadzone( 0.3f ); mpInputX1 = mpPad->bindFilter(); mpInputX1->setChannel(FWInput::Channel_XAxis_1); mpInputX1->setGain( 1.0f ); mpInputX1->setDeadzone( 0.3f ); mpInputY1 = mpPad->bindFilter(); mpInputY1->setChannel(FWInput::Channel_YAxis_1); mpInputY1->setGain( 1.0f ); mpInputY1->setDeadzone( 0.3f ); // initialize debug font library, then open console. int ret; CellDbgFontConfig cfg; memset(&cfg, 0, sizeof(CellDbgFontConfig)); cfg.bufSize = 512; cfg.screenWidth = mDispInfo.mWidth; cfg.screenHeight = mDispInfo.mHeight; ret = cellDbgFontInit(&cfg); if (ret != CELL_OK) { printf("cellDbgFontInit() failed %x\n", ret); return true; } CellDbgFontConsoleConfig ccfg; memset(&ccfg, 0, sizeof(CellDbgFontConsoleConfig)); ccfg.posLeft = 0.1f; ccfg.posTop = 0.6f; ccfg.cnsWidth = 16; ccfg.cnsHeight = 4; ccfg.scale = 1.5f; ccfg.color = 0xffffffff; mDbgFontID = cellDbgFontConsoleOpen(&ccfg); if (mDbgFontID < 0) { printf("cellDbgFontConsoleOpen() failed %x\n", mDbgFontID); return true; } return true; }
/** * Main daemon routine */ int main(int argc, char **argv) { int c, option_index = 0; const char *bin; char config_file[MAX_OPT_LEN] = ""; int rc; char err_msg[4096]; robinhood_config_t config; int chgd = 0; char badcfg[RBH_PATH_MAX]; bin = rh_basename(argv[0]); /* parse command line options */ while ((c = getopt_long(argc, argv, SHORT_OPT_STRING, option_tab, &option_index)) != -1) { switch (c) { case 'f': rh_strncpy(config_file, optarg, MAX_OPT_LEN); break; case 'l': { int log_level = str2debuglevel(optarg); if (log_level == -1) { fprintf(stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg); exit(1); } force_debug_level(log_level); break; } case 'h': display_help(bin); exit(0); break; case 'V': display_version(bin); exit(0); break; case ':': case '?': default: display_help(bin); exit(1); break; } } /* 2 expected argument: old backend path, new path is FS */ if (optind > argc - 2) { fprintf(stderr, "Error: missing arguments on command line.\n"); display_help(bin); exit(1); } else if (optind < argc - 3) { fprintf(stderr, "Error: too many arguments on command line.\n"); display_help(bin); exit(1); } /* get default config file, if not specified */ if (SearchConfig(config_file, config_file, &chgd, badcfg, MAX_OPT_LEN) != 0) { fprintf(stderr, "No config file (or too many) found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", config_file); } rc = rbh_init_internals(); if (rc != 0) exit(rc); /* only read ListMgr config */ if (ReadRobinhoodConfig(0, config_file, err_msg, &config, false)) { fprintf(stderr, "Error reading configuration file '%s': %s\n", config_file, err_msg); exit(1); } /* XXX HOOK: Set logging to stderr */ strcpy(config.log_config.log_file, "stderr"); strcpy(config.log_config.report_file, "stderr"); strcpy(config.log_config.alert_file, "stderr"); /* Initialize logging */ rc = InitializeLogs(bin, &config.log_config); if (rc) { fprintf(stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror(errno)); exit(rc); } /* Initialize Filesystem access */ rc = InitFS(); if (rc) exit(rc); /* Initialize status managers (XXX all or just the one used for rebind?) */ rc = smi_init_all(options.flags); if (rc) exit(rc); #ifdef _HSM_LITE rc = Backend_Start(&config.backend_config, 0); if (rc) { DisplayLog(LVL_CRIT, LOGTAG, "Error initializing backend"); exit(1); } #endif if (optind == argc - 2) rc = rebind_helper(argv[optind], argv[optind + 1], NULL); else if (optind == argc - 3) rc = rebind_helper(argv[optind], argv[optind + 1], argv[optind + 2]); return rc; }
/** * Main daemon routine */ int main( int argc, char **argv ) { int c, option_index = 0; char *bin = basename( argv[0] ); char config_file[MAX_OPT_LEN] = ""; enum { ACTION_NONE, ACTION_LIST, ACTION_RESTORE } action = ACTION_NONE; int force_log_level = FALSE; int log_level = 0; int rc; char err_msg[4096]; robinhood_config_t config; int chgd = 0; char badcfg[RBH_PATH_MAX]; /* parse command line options */ while ( ( c = getopt_long( argc, argv, SHORT_OPT_STRING, option_tab, &option_index ) ) != -1 ) { switch ( c ) { case 'L': if ( (action != ACTION_NONE) && (action != ACTION_LIST) ) fprintf( stderr, "WARNING: only a single action (--list or --restore) is expected\n" "on command line. '--restore' will be ignored.\n" ); action = ACTION_LIST; break; case 'R': if ( (action != ACTION_NONE) && (action != ACTION_RESTORE) ) fprintf( stderr, "WARNING: only a single action (--list or --restore) is expected\n" "on command line. '--list' will be ignored.\n" ); action = ACTION_RESTORE; break; case 'f': strncpy( config_file, optarg, MAX_OPT_LEN ); break; case 'l': force_log_level = TRUE; log_level = str2debuglevel( optarg ); if ( log_level == -1 ) { fprintf( stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg ); exit( 1 ); } break; case 'h': display_help( bin ); exit( 0 ); break; case 'V': display_version( bin ); exit( 0 ); break; case ':': case '?': default: display_help( bin ); exit( 1 ); break; } } /* 1 expected argument: path */ if ( optind != argc - 1 ) { fprintf( stderr, "Error: missing mandatory argument on command line: <path|fid>\n" ); exit( 1 ); } strncpy( path_filter, argv[optind], RBH_PATH_MAX ); /* get default config file, if not specified */ if ( SearchConfig( config_file, config_file, &chgd, badcfg ) != 0 ) { fprintf(stderr, "No config file found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", config_file ); } /* only read ListMgr config */ if ( ReadRobinhoodConfig( 0, config_file, err_msg, &config, FALSE ) ) { fprintf( stderr, "Error reading configuration file '%s': %s\n", config_file, err_msg ); exit( 1 ); } process_config_file = config_file; /* set global configuration */ global_config = config.global_config; /* set policies info */ policies = config.policies; if ( force_log_level ) config.log_config.debug_level = log_level; /* XXX HOOK: Set logging to stderr */ strcpy( config.log_config.log_file, "stderr" ); strcpy( config.log_config.report_file, "stderr" ); strcpy( config.log_config.alert_file, "stderr" ); /* Initialize logging */ rc = InitializeLogs( bin, &config.log_config ); if ( rc ) { fprintf( stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror( errno ) ); exit( rc ); } /* Initialize Filesystem access */ rc = InitFS(); if (rc) exit(rc); /* Initialize list manager */ rc = ListMgr_Init( &config.lmgr_config, FALSE ); if ( rc ) { DisplayLog( LVL_CRIT, LOGTAG, "Error %d initializing list manager", rc ); exit( rc ); } else DisplayLog( LVL_DEBUG, LOGTAG, "ListManager successfully initialized" ); if ( CheckLastFS( ) != 0 ) exit( 1 ); /* Create database access */ rc = ListMgr_InitAccess( &lmgr ); if ( rc ) { DisplayLog( LVL_CRIT, LOGTAG, "Error %d: cannot connect to database", rc ); exit( rc ); } #ifdef _HSM_LITE rc = Backend_Start( &config.backend_config, 0 ); if ( rc ) { DisplayLog( LVL_CRIT, LOGTAG, "Error initializing backend" ); exit( 1 ); } #endif /* perform the action */ switch( action ) { case ACTION_LIST: rc= list_rm(); break; case ACTION_RESTORE: rc = undo_rm(); break; case ACTION_NONE: display_help( bin ); rc = 1; break; default: fprintf(stderr, "Unexpected action (action code=%#x)\n", action ); display_help( bin ); rc = EINVAL; break; } ListMgr_CloseAccess( &lmgr ); return rc; }
/** * Main daemon routine */ int main(int argc, char **argv) { int c, option_index = 0; const char *bin; char config_file[MAX_OPT_LEN] = ""; int rc; char err_msg[4096]; bool chgd = false; char badcfg[RBH_PATH_MAX]; char sm_name[SM_NAME_MAX + 1] = ""; bin = rh_basename(argv[0]); /* parse command line options */ while ((c = getopt_long(argc, argv, SHORT_OPT_STRING, option_tab, &option_index)) != -1) { switch (c) { case 'f': rh_strncpy(config_file, optarg, MAX_OPT_LEN); break; case 'l': { int log_level = str2debuglevel(optarg); if (log_level == -1) { fprintf(stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg); exit(1); } force_debug_level(log_level); break; } case 's': if (!EMPTY_STRING(sm_name)) fprintf(stderr, "WARNING: only a single status manager is expected " "on command line. '%s' ignored.\n", optarg); else rh_strncpy(sm_name, optarg, sizeof(sm_name)); break; case 'h': display_help(bin); exit(EXIT_SUCCESS); break; case 'V': display_version(bin); exit(EXIT_SUCCESS); break; case ':': case '?': default: display_help(bin); exit(1); break; } } /* 2 expected argument: old backend path, new path is FS */ if (optind > argc - 3) { fprintf(stderr, "Error: missing arguments on command line.\n"); display_help(bin); exit(1); } else if (optind < argc - 4) { fprintf(stderr, "Error: too many arguments on command line.\n"); display_help(bin); exit(1); } rc = rbh_init_internals(); if (rc != 0) exit(EXIT_FAILURE); /* get default config file, if not specified */ if (SearchConfig(config_file, config_file, &chgd, badcfg, MAX_OPT_LEN) != 0) { fprintf(stderr, "No config file (or too many) found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", config_file); } /* only read common config (listmgr, ...) (mask=0) */ if (rbh_cfg_load(0, config_file, err_msg)) { fprintf(stderr, "Error reading configuration file '%s': %s\n", config_file, err_msg); exit(1); } if (!log_config.force_debug_level) log_config.debug_level = LVL_MAJOR; /* no event message */ /* Set logging to stderr */ strcpy(log_config.log_file, "stderr"); strcpy(log_config.report_file, "stderr"); strcpy(log_config.alert_file, "stderr"); /* Initialize logging */ rc = InitializeLogs(bin); if (rc) { fprintf(stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror(errno)); exit(EXIT_FAILURE); } /* Initialize Filesystem access */ rc = InitFS(); if (rc) exit(EXIT_FAILURE); /* Initialize status managers (XXX all or just the one used for undelete?) */ rc = smi_init_all(0); if (rc) exit(EXIT_FAILURE); /* load the status manager */ if (!EMPTY_STRING(sm_name)) { rc = load_smi(sm_name, &smi); if (rc) exit(EXIT_FAILURE); } else { /* if there is a single smi that allows undelete, use it */ rc = load_single_smi(&smi); if (rc) exit(EXIT_FAILURE); } if (optind == argc - 3) rc = rebind_helper(argv[optind], argv[optind + 1], argv[optind + 2], NULL); else if (optind == argc - 4) rc = rebind_helper(argv[optind], argv[optind + 1], argv[optind + 2], argv[optind + 3]); exit(rc ? EXIT_FAILURE: EXIT_SUCCESS); }
/** * Main daemon routine */ int main( int argc, char **argv ) { int c, option_index = 0; char *bin = basename( argv[0] ); char config_file[MAX_OPT_LEN] = ""; int force_log_level = FALSE; int log_level = 0; int rc; int chgd = 0; char err_msg[4096]; int neg = 0; char badcfg[RBH_PATH_MAX]; /* parse command line options */ while ((c = getopt_long_only(argc, argv, SHORT_OPT_STRING, option_tab, &option_index )) != -1) { switch ( c ) { case '!': neg = 1; break; case 'u': toggle_option(match_user, "user"); prog_options.user = optarg; prog_options.userneg = neg; neg = 0; break; case 'g': toggle_option(match_group, "group"); prog_options.group = optarg; prog_options.groupneg = neg; neg = 0; break; case 'U': /* match numerical (non resolved) users */ toggle_option(match_user, "user"); prog_options.user = "******"; prog_options.userneg = neg; neg = 0; break; case 'G': /* match numerical (non resolved) groups */ toggle_option(match_group, "group"); prog_options.group = "[0-9]*"; prog_options.groupneg = neg; neg = 0; break; case 'n': toggle_option(match_name, "name"); prog_options.name = optarg; prog_options.nameneg = neg; neg = 0; break; #ifdef _LUSTRE case 'o': toggle_option(match_ost, "ost"); prog_options.ost_idx = str2int(optarg); if (prog_options.ost_idx == (unsigned int)-1) { fprintf(stderr, "invalid ost index '%s': unsigned integer expected\n", optarg); exit(1); } if (neg) { fprintf(stderr, "! () is not supported for ost criteria\n"); exit(1); } break; case 'P': toggle_option(match_pool, "pool"); prog_options.pool = optarg; break; case 'O': prog_options.lsost = 1; prog_options.print = 0; disp_mask |= LSOST_DISPLAY_MASK; if (neg) { fprintf(stderr, "! (-not) unexpected before -lsost option\n"); exit(1); } break; #endif case 't': toggle_option(match_type, "type"); prog_options.type = opt2type(optarg); if (prog_options.type == NULL) { fprintf(stderr, "invalid type '%s': expected types: "TYPE_HELP".\n", optarg); exit(1); } if (neg) { fprintf(stderr, "! (-not) is not supported for type criteria\n"); exit(1); } break; case 's': toggle_option(match_size, "size"); if (set_size_filter(optarg)) exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for size criteria\n"); exit(1); } break; case 'A': toggle_option(match_atime, "atime/amin"); if (set_time_filter(optarg, 0, TRUE, atime)) exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; case 'a': toggle_option(match_atime, "atime/amin"); if (set_time_filter(optarg, 60, TRUE, atime)) exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; case 'C': toggle_option(match_crtime, "crtime"); if (set_time_filter(optarg, 0, TRUE, rh_crtime)) exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; case 'M': toggle_option(match_mtime, "mtime/mmin/msec"); if (set_time_filter(optarg, 0, TRUE, mtime)) exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; case 'm': toggle_option(match_mtime, "mtime/mmin/msec"); if (set_time_filter(optarg, 60, FALSE, mtime)) /* don't allow suffix (multiplier is 1min) */ exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; case 'z': toggle_option(match_mtime, "mtime/mmin/msec"); if (set_time_filter(optarg, 1, FALSE, mtime)) /* don't allow suffix (multiplier is 1sec) */ exit(1); if (neg) { fprintf(stderr, "! (-not) is not supported for time criteria\n"); exit(1); } break; #ifdef ATTR_INDEX_status case 'S': toggle_option(match_status, "status"); prog_options.status = status2dbval(optarg); if ( prog_options.status == (file_status_t)-1 ) { fprintf(stderr, "Unknown status '%s'. Allowed status: %s.\n", optarg, allowed_status()); exit(1); } prog_options.statusneg = neg; neg = 0; break; #endif case 'l': prog_options.ls = 1; prog_options.print = 0; disp_mask |= LS_DISPLAY_MASK; if (neg) { fprintf(stderr, "! (-not) unexpected before -ls option\n"); exit(1); } break; case 'p': prog_options.print = 1; disp_mask |= LS_DISPLAY_MASK; if (neg) { fprintf(stderr, "! (-not) unexpected before -ls option\n"); exit(1); } break; case 'E': toggle_option(exec, "exec"); prog_options.exec_cmd = optarg; prog_options.print = 0; break; case 'f': rh_strncpy(config_file, optarg, MAX_OPT_LEN); if (neg) { fprintf(stderr, "! (-not) unexpected before -f option\n"); exit(1); } break; case 'd': force_log_level = TRUE; log_level = str2debuglevel( optarg ); if ( log_level == -1 ) { fprintf(stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg); exit(1); } if (neg) { fprintf(stderr, "! (-not) unexpected before -d option\n"); exit(1); } break; case 'b': prog_options.bulk = force_nobulk; break; case 'h': display_help( bin ); exit( 0 ); break; case 'V': display_version( bin ); exit( 0 ); break; case ':': case '?': default: display_help( bin ); exit( 1 ); break; } } /* get default config file, if not specified */ if (SearchConfig(config_file, config_file, &chgd, badcfg, MAX_OPT_LEN) != 0) { fprintf(stderr, "No config file (or too many) found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", config_file ); } /* only read ListMgr config */ if ( ReadRobinhoodConfig( 0, config_file, err_msg, &config, FALSE ) ) { fprintf( stderr, "Error reading configuration file '%s': %s\n", config_file, err_msg ); exit( 1 ); } process_config_file = config_file; /* set global configuration */ global_config = config.global_config; /* set policies info */ policies = config.policies; if ( force_log_level ) config.log_config.debug_level = log_level; else config.log_config.debug_level = LVL_MAJOR; /* no event message */ /* Set logging to stderr */ strcpy( config.log_config.log_file, "stderr" ); strcpy( config.log_config.report_file, "stderr" ); strcpy( config.log_config.alert_file, "stderr" ); /* Initialize logging */ rc = InitializeLogs( bin, &config.log_config ); if ( rc ) { fprintf( stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror( errno ) ); exit( rc ); } /* Initialize filesystem access */ rc = InitFS(); if (rc) exit(rc); /* Initialize list manager */ rc = ListMgr_Init( &config.lmgr_config, TRUE ); if ( rc ) { DisplayLog( LVL_CRIT, FIND_TAG, "Error %d initializing list manager", rc ); exit( rc ); } else DisplayLog( LVL_DEBUG, FIND_TAG, "ListManager successfully initialized" ); if (CheckLastFS( ) != 0) exit(1); /* Create database access */ rc = ListMgr_InitAccess(&lmgr); if (rc) { DisplayLog( LVL_CRIT, FIND_TAG, "Error %d: cannot connect to database", rc ); exit(rc); } if (argc == optind) { /* no argument: default is root * => switch to bulk mode (unless nobulk is specified) */ if (prog_options.bulk != force_nobulk) { DisplayLog(LVL_DEBUG, FIND_TAG, "Optimization: switching to bulk DB request mode"); mkfilters(FALSE); /* keep dirs */ return list_bulk(); } else { char *id = config.global_config.fs_path; mkfilters(TRUE); /* exclude dirs */ /* no path specified, list all entries */ rc = list_contents(&id, 1); } } else { mkfilters(TRUE); /* exclude dirs */ rc = list_contents(argv+optind, argc-optind); } ListMgr_CloseAccess( &lmgr ); return rc; }
int main() { u32 pad_state; u32 num_calls = 0; InitFS(); while (true) { ClearTop(); Debug(" ALBERTOSONIC'S CFW "); Debug(""); Debug("Getting system version..."); getSystemVersion(); Debug(""); Debug("Your system is %s", systemVersion); Debug(""); if (type == 0) { Debug("Press any key to reboot."); pad_state = InputWait(); break; } else { //Let's continue our patch Debug(""); Debug("Patching..."); if (type == 1){ u8 patch[] = { 0x00, 0x20, 0x3B, 0xE0 }; u32 *dest = 0x080549C4; memcpy(dest, patch, 4); u8 patch1[] = { 0x00, 0x20, 0x08, 0xE0 }; u32 *dest1 = 0x0804239C; memcpy(dest1, patch1, 4); } if (type == 2){ u8 patch[] = { 0x00, 0x20, 0x3B, 0xE0 }; u32 *dest = 0x080523C4; memcpy(dest, patch, 4); u8 patch1[] = { 0x00, 0x20, 0x08, 0xE0 }; u32 *dest1 = 0x08058098; memcpy(dest1, patch1, 4); } if (type == 3){ u8 patch[] = { 0x00, 0x20, 0x3B, 0xE0 }; u32 *dest = 0x0805235C; memcpy(dest, patch, 4); u8 patch1[] = { 0x00, 0x20, 0x08, 0xE0 }; u32 *dest1 = 0x08058100; memcpy(dest1, patch1, 4); } if (type == 4){ u8 patch[] = { 0x6D, 0x20, 0xCE, 0x77 }; u32 *dest = 0x08052FD8; memcpy(dest, patch, 4); u8 patch1[] = { 0x5A, 0xC5, 0x73, 0xC1 }; u32 *dest1 = 0x08058804; memcpy(dest1, patch1, 4); } break; } } // return control to FIRM ARM9 code (performs firmlaunch) return 0; }
/** * Main daemon routine */ int main( int argc, char **argv ) { int c, i, option_index = 0; char *bin = basename( argv[0] ); int rc; char err_msg[4096]; robinhood_config_t rh_config; int chgd = 0; char badcfg[RBH_PATH_MAX]; char tag_name[256] = ""; start_time = time( NULL ); zero_options( &options ); /* parse command line options */ while ( ( c = getopt_long( argc, argv, SHORT_OPT_STRING, option_tab, &option_index ) ) != -1 ) { switch ( c ) { case 's': options.partial_scan = TRUE; rh_strncpy(options.partial_scan_path, optarg, RBH_PATH_MAX); /* clean final slash */ if (FINAL_SLASH(options.partial_scan_path)) REMOVE_FINAL_SLASH(options.partial_scan_path); break; case 'd': if (parse_diff_mask(optarg, &options.diff_mask, err_msg)) { fprintf(stderr, "Invalid argument for --diff: %s\n", err_msg); exit( 1 ); } break; case 'a': if (optarg) { if (!strcasecmp(optarg,"fs")) options.diff_arg.apply = APPLY_FS; else if (!strcasecmp(optarg,"db")) options.diff_arg.apply = APPLY_DB; else { fprintf(stderr, "Invalid argument for --apply: '%s' (fs or db expected)\n", optarg); exit( 1 ); } } else options.diff_arg.apply = APPLY_DB; break; case 'D': options.flags |= FLAG_DRY_RUN; break; case 'f': rh_strncpy(options.config_file, optarg, MAX_OPT_LEN); break; #ifdef _HSM_LITE case 'b': options.diff_arg.recov_from_backend = 1; break; #endif #ifdef _HAVE_FID /* only for lustre 2.x */ case 'o': rh_strncpy(options.output_dir, optarg, MAX_OPT_LEN); break; #endif case 'l': options.force_log_level = TRUE; options.log_level = str2debuglevel( optarg ); if ( options.log_level == -1 ) { fprintf( stderr, "Unsupported log level '%s'. CRIT, MAJOR, EVENT, VERB, DEBUG or FULL expected.\n", optarg ); exit( 1 ); } break; case 'h': display_help( bin ); exit( 0 ); break; case 'V': display_version( bin ); exit( 0 ); break; case ':': case '?': default: fprintf(stderr,"Run '%s --help' for more details.\n", bin); exit( 1 ); break; } } /* check there is no extra arguments */ if ( optind != argc ) { fprintf( stderr, "Error: unexpected argument on command line: %s\n", argv[optind] ); exit( 1 ); } /* Initialize global tools */ #ifdef _LUSTRE if ( ( rc = Lustre_Init( ) ) ) { fprintf( stderr, "Error %d initializing liblustreapi\n", rc ); exit( 1 ); } #endif /* Initilize uidgid cache */ if ( InitUidGid_Cache( ) ) { fprintf( stderr, "Error initializing uid/gid cache\n" ); exit( 1 ); } /* get default config file, if not specified */ if (SearchConfig(options.config_file, options.config_file, &chgd, badcfg, MAX_OPT_LEN) != 0) { fprintf(stderr, "No config file (or too many) found matching %s\n", badcfg); exit(2); } else if (chgd) { fprintf(stderr, "Using config file '%s'.\n", options.config_file ); } if ( ReadRobinhoodConfig( MODULE_MASK_FS_SCAN | MODULE_MASK_ENTRY_PROCESSOR, options.config_file, err_msg, &rh_config, FALSE ) ) { fprintf( stderr, "Error reading configuration file '%s': %s\n", options.config_file, err_msg ); exit( 1 ); } process_config_file = options.config_file; /* set global configuration */ global_config = rh_config.global_config; /* set policies info */ policies = rh_config.policies; if (options.force_log_level) rh_config.log_config.debug_level = options.log_level; else rh_config.log_config.debug_level = LVL_CRIT; /* no event message */ /* Set logging to stderr */ strcpy( rh_config.log_config.log_file, "stderr" ); strcpy( rh_config.log_config.report_file, "stderr" ); strcpy( rh_config.log_config.alert_file, "stderr" ); /* Initialize logging */ rc = InitializeLogs( bin, &rh_config.log_config ); if ( rc ) { fprintf( stderr, "Error opening log files: rc=%d, errno=%d: %s\n", rc, errno, strerror( errno ) ); exit( rc ); } /* Initialize filesystem access */ rc = InitFS(); if (rc) exit(rc); #ifdef _HSM_LITE rc = Backend_Start( &rh_config.backend_config, options.flags ); if ( rc ) { DisplayLog( LVL_CRIT, DIFF_TAG, "Error initializing backend" ); exit( 1 ); } #endif /* Initialize list manager */ rc = ListMgr_Init( &rh_config.lmgr_config, FALSE ); if ( rc ) { DisplayLog( LVL_CRIT, DIFF_TAG, "Error %d initializing list manager", rc ); exit( rc ); } else DisplayLog( LVL_VERB, DIFF_TAG, "ListManager successfully initialized" ); if ( CheckLastFS( ) != 0 ) exit( 1 ); if (options.diff_mask) rh_config.entry_proc_config.diff_mask = options.diff_mask; else { /* parse "all" */ char tmpstr[] = "all"; if (parse_diff_mask(tmpstr, &rh_config.entry_proc_config.diff_mask, err_msg)) { DisplayLog(LVL_CRIT, DIFF_TAG, "unexpected error parsing diff mask: %s", err_msg); exit(1); } } #ifdef LUSTRE_DUMP_FILES if (options.diff_arg.apply == APPLY_FS && !(options.flags & FLAG_DRY_RUN)) { /* open the file to write LOV EA and FID remapping */ if (!EMPTY_STRING(options.output_dir)) { char fname[RBH_PATH_MAX]; if (mkdir(options.output_dir, 0700) && (errno != EEXIST)) { DisplayLog(LVL_CRIT, DIFF_TAG, "Failed to create directory %s: %s", options.output_dir, strerror(errno)); exit(1); } snprintf(fname, RBH_PATH_MAX-1, "%s/"LOVEA_FNAME, options.output_dir); options.diff_arg.lovea_file = fopen(fname, "w"); if (options.diff_arg.lovea_file == NULL) { DisplayLog(LVL_CRIT, DIFF_TAG, "Failed to open %s for writting: %s", fname, strerror(errno)); exit(1); } snprintf(fname, RBH_PATH_MAX-1, "%s/"FIDREMAP_FNAME, options.output_dir); options.diff_arg.fid_remap_file = fopen(fname, "w"); if (options.diff_arg.fid_remap_file == NULL) { DisplayLog(LVL_CRIT, DIFF_TAG, "Failed to open %s for writting: %s", fname, strerror(errno)); exit(1); } } } #endif /* if no DB apply action is specified, can't use md_update field for checking * removed entries. So, create a special tag for that. */ if ((options.diff_arg.apply != APPLY_DB) || (options.flags & FLAG_DRY_RUN)) { fprintf(stderr, "Preparing diff table...\n"); /* create a connexion to the DB. this is safe to use the global lmgr var * as statistics thread is not running */ if (!ensure_db_access()) exit(1); /* create a tag to clear entries after the scan */ /* There could be several diff running in parallel, * so set a suffix to avoid conflicts */ sprintf(tag_name, "DIFF_%u", (unsigned int) getpid()); options.diff_arg.db_tag = tag_name; /* add filter for partial scan */ if (options.partial_scan) { lmgr_filter_t filter; filter_value_t val; lmgr_simple_filter_init( &filter ); char tmp[RBH_PATH_MAX]; strcpy(tmp, options.partial_scan_path); strcat(tmp, "/*"); val.value.val_str = tmp; lmgr_simple_filter_add(&filter, ATTR_INDEX_fullpath, LIKE, val, 0); rc = ListMgr_CreateTag(&lmgr, tag_name, &filter, FALSE); lmgr_simple_filter_free(&filter); } else rc = ListMgr_CreateTag(&lmgr, tag_name, NULL, FALSE); if (rc) exit(rc); } /* Initialise Pipeline */ rc = EntryProcessor_Init(&rh_config.entry_proc_config, DIFF_PIPELINE, options.flags, &options.diff_arg); if ( rc ) { DisplayLog( LVL_CRIT, DIFF_TAG, "Error %d initializing EntryProcessor pipeline", rc ); goto clean_tag; } else DisplayLog( LVL_VERB, DIFF_TAG, "EntryProcessor successfully initialized" ); fprintf(stderr, "Starting scan\n"); /* print header to indicate the content of diff * #<diff cmd> * ---fs[=/subdir] * +++db */ for (i = 0; i < argc; i++) printf("%s%s", i==0?"# ":" ", argv[i]); printf("\n"); if (options.diff_arg.apply == APPLY_FS) { if (options.partial_scan) printf("---fs=%s\n",options.partial_scan_path); else printf("---fs\n"); printf("+++db\n"); } else { printf("---db\n"); if (options.partial_scan) printf("+++fs=%s\n",options.partial_scan_path); else printf("+++fs\n"); } /* Start FS scan */ if (options.partial_scan) rc = FSScan_Start(&rh_config.fs_scan_config, options.flags, options.partial_scan_path); else rc = FSScan_Start(&rh_config.fs_scan_config, options.flags, NULL); if ( rc ) { DisplayLog( LVL_CRIT, DIFF_TAG, "Error %d initializing FS Scan module", rc ); goto clean_tag; } else DisplayLog( LVL_VERB, DIFF_TAG, "FS Scan module successfully initialized" ); /* Flush logs now, to have a trace in the logs */ FlushLogs( ); /* both pipeline and scan are now running, can now trap events and display stats */ /* create signal handling thread */ rc = pthread_create( &sig_thr, NULL, signal_handler_thr, NULL ); if ( rc ) { DisplayLog( LVL_CRIT, DIFF_TAG, "Error starting signal handler thread: %s", strerror( errno ) ); goto clean_tag; } else DisplayLog( LVL_VERB, DIFF_TAG, "Signal handler thread started successfully" ); pthread_create(&stat_thread, NULL, stats_thr, NULL); /* wait for FS scan to end */ FSScan_Wait( ); DisplayLog( LVL_MAJOR, DIFF_TAG, "FS Scan finished" ); /* Pipeline must be flushed */ EntryProcessor_Terminate( TRUE ); #ifdef LUSTRE_DUMP_FILES /* flush the lovea file */ if (options.diff_arg.lovea_file) { fprintf(stderr, " > LOV EA information written to %s/"LOVEA_FNAME"\n", options.output_dir); fclose(options.diff_arg.lovea_file); } if (options.diff_arg.fid_remap_file) { fprintf(stderr, " > FID remapping written to %s/"FIDREMAP_FNAME"\n", options.output_dir); fclose(options.diff_arg.fid_remap_file); } #endif fprintf(stderr, "End of scan\n"); DisplayLog( LVL_MAJOR, DIFF_TAG, "All tasks done! Exiting." ); rc = 0; clean_tag: /* destroy the tag before exit */ if (options.diff_arg.db_tag != NULL && ensure_db_access()) { fprintf(stderr, "Cleaning diff table...\n"); ListMgr_DestroyTag(&lmgr, options.diff_arg.db_tag); } exit(rc); return rc; /* for compiler */ }
int main ( int argc, char** argv) { InitFS(); ExecuteCommand(); return 0; }