int main(int argc, char *argv[])
{
	int ret;

	ret = init_uffs_fs();

	if (ret != 0) {
		printf ("Init file system fail: %d\n", ret);
		return -1;
	}

	cli_add_commandset(get_helper_cmds());
	cli_add_commandset(get_test_cmds());
	cliMain();

	release_uffs_fs();

	return 0;
}
int main(int argc, char *argv[])
{
	int ret;

#ifdef UNIX
	signal(SIGSEGV, crash_handler);
#endif

	uffs_SetupDebugOutput(); 	// setup debug output as early as possible

	if (parse_options(argc, argv) < 0) {
		return -1;
	}
	
	if (conf_verbose_mode) {
		#if 1
		MSGLN("Internal data structure size:");
		MSGLN("  TreeNode: %d", sizeof(TreeNode));
		MSGLN("  struct BlockListSt: %d", sizeof(struct BlockListSt));
		MSGLN("  struct DirhSt: %d", sizeof(struct DirhSt));
		MSGLN("  struct FilehSt: %d", sizeof(struct FilehSt));
		MSGLN("  struct FdataSt: %d", sizeof(struct FdataSt));
		MSGLN("  struct uffs_TagStoreSt: %d", sizeof(struct uffs_TagStoreSt));
		MSGLN("  uffs_Buf: %d", sizeof(uffs_Buf));
		MSGLN("  struct uffs_BlockInfoSt: %d", sizeof(struct uffs_BlockInfoSt));
		MSGLN("");
		#endif
		print_params();
		print_mount_points();
	}

	// setup file emulator storage with parameters from command line
	setup_storage(femu_GetStorage());

	// setup file emulator private data
	setup_emu_private(femu_GetPrivate());

	ret = init_uffs_fs();
	if (ret != 0) {
		MSGLN ("Init file system fail: %d", ret);
		return -1;
	}

	cli_add_commandset(get_helper_cmds());
	cli_add_commandset(get_test_cmds());
	if (conf_command_line_mode) {
		if (conf_exec_script) {
			cli_interpret(script_command);
		}
		cli_main_entry();
	}
	else {
		if (conf_exec_script) {
			cli_interpret(script_command);
		}
		else {
			cli_main_entry();
		}
	}

	release_uffs_fs();

	return 0;
}