Example #1
0
/*==========================================
 * 傭兵データファイルの読み込み
 *------------------------------------------
 */
static bool mercdb_txt_read(void)
{
	FILE *fp;
	bool ret = true;

	merc_db = numdb_init();

	if((fp = fopen(merc_txt, "r")) == NULL) {
		printf("mercdb_txt_read: open [%s] failed !\n", merc_txt);
		ret = false;
	} else {
		int count = 0;
		char line[8192];

		while(fgets(line, sizeof(line), fp)) {
			struct mmo_mercstatus *m = (struct mmo_mercstatus *)aCalloc(1, sizeof(struct mmo_mercstatus));
			if(merc_fromstr(line, m) == 0 && m->merc_id > 0) {
				if(m->merc_id >= merc_newid)
					merc_newid = m->merc_id + 1;
				numdb_insert(merc_db, m->merc_id, m);
			} else {
				printf("int_merc: broken data [%s] line %d\n", merc_txt, count);
				aFree(m);
			}
			count++;
		}
		fclose(fp);
	}

#ifdef TXT_JOURNAL
	if( merc_journal_enable )
	{
		// ジャーナルデータのロールフォワード
		if( journal_load( &merc_journal, sizeof(struct mmo_mercstatus), merc_journal_file ) )
		{
			int c = journal_rollforward( &merc_journal, merc_journal_rollforward );

			printf("int_merc: journal: roll-forward (%d)\n", c );

			// ロールフォワードしたので、txt データを保存する ( journal も新規作成される)
			mercdb_txt_sync();
		}
		else
		{
			// ジャーナルを新規作成する
			journal_final( &merc_journal );
			journal_create( &merc_journal, sizeof(struct mmo_mercstatus), merc_journal_cache, merc_journal_file );
		}
	}
#endif

	return ret;
}
Example #2
0
/*==========================================
 * アカウント変数の読み込み
 *------------------------------------------
 */
static bool accregdb_txt_read(void)
{
	FILE *fp;
	bool ret = true;

	accreg_db = numdb_init();

	if((fp = fopen(accreg_txt, "r")) == NULL) {
		printf("accregdb_txt_read: open [%s] failed !\n", accreg_txt);
		ret = false;
	} else {
		int count = 0;
		char line[8192];

		while(fgets(line, sizeof(line), fp)) {
			struct accreg *reg = (struct accreg *)aCalloc(1, sizeof(struct accreg));

			if(accregdb_fromstr(line, reg) == 0 && reg->account_id > 0) {
				numdb_insert(accreg_db, reg->account_id, reg);
			} else {
				printf("inter: accreg: broken data [%s] line %d\n", accreg_txt, count);
				aFree(reg);
			}
			count++;
		}
		fclose(fp);
	}

#ifdef TXT_JOURNAL
	if( accreg_journal_enable )
	{
		// ジャーナルデータのロールフォワード
		if( journal_load( &accreg_journal, sizeof(struct accreg), accreg_journal_file ) )
		{
			int c = journal_rollforward( &accreg_journal, accregdb_journal_rollforward );

			printf("inter: accreg_journal: roll-forward (%d)\n", c );

			// ロールフォワードしたので、txt データを保存する ( journal も新規作成される)
			accregdb_txt_sync();
		}
		else
		{
			// ジャーナルを新規作成する
			journal_final( &accreg_journal );
			journal_create( &accreg_journal, sizeof(struct accreg), accreg_journal_cache, accreg_journal_file );
		}
	}
#endif

	return ret;
}
Example #3
0
int ocfs2_journal_load(struct ocfs2_journal *journal, int local)
{
	int status = 0;
	struct ocfs2_super *osb;

	mlog_entry_void();

	BUG_ON(!journal);

	osb = journal->j_osb;

	status = journal_load(journal->j_journal);
	if (status < 0) {
		mlog(ML_ERROR, "Failed to load journal!\n");
		goto done;
	}

	ocfs2_clear_journal_error(osb->sb, journal->j_journal, osb->slot_num);

	status = ocfs2_journal_toggle_dirty(osb, 1);
	if (status < 0) {
		mlog_errno(status);
		goto done;
	}

	/* Launch the commit thread */
	if (!local) {
		osb->commit_task = kthread_run(ocfs2_commit_thread, osb,
					       "ocfs2cmt");
		if (IS_ERR(osb->commit_task)) {
			status = PTR_ERR(osb->commit_task);
			osb->commit_task = NULL;
			mlog(ML_ERROR, "unable to launch ocfs2commit thread, "
			     "error=%d", status);
			goto done;
		}
	} else
		osb->commit_task = NULL;

done:
	mlog_exit(status);
	return status;
}
Example #4
0
INT
Ext2RecoverJournal(
    PEXT2_IRP_CONTEXT  IrpContext,
    PEXT2_VCB          Vcb
)
{
    INT rc = 0;
    ULONG                   jNo = 0;
    PEXT2_MCB               jcb = NULL;
    struct block_device *   bd = &Vcb->bd;
#ifndef __REACTOS__
    struct super_block *    sb = &Vcb->sb;
#endif
    struct inode *          ji = NULL;
    journal_t *             journal = NULL;
    struct ext3_super_block *esb;

    /* check journal inode number */
    if (!Ext2CheckJournal(Vcb, &jNo)) {
        return -1;
    }

    /* allocate journal Mcb */
    jcb =  Ext2LoadInternalJournal(Vcb, jNo);
    if (!jcb) {
        rc = -6;
        goto errorout;
    }

    /* allocate journal inode */
    ji = &jcb->Inode;

    /* initialize journal file from inode */
    journal = journal_init_inode(ji);

    /* initialzation succeeds ? */
    if (!journal) {
        iput(ji);
        rc = -8;
        goto errorout;
    }

    /* start journal recovery */
    rc = journal_load(journal);
    if (0 != rc) {
        rc = -9;
        DbgPrint("Ext2Fsd: recover_journal: failed "
                 "to recover journal data.\n");
    }

    /* reload super_block and group_description */
    Ext2RefreshSuper(IrpContext, Vcb);
    Ext2RefreshGroup(IrpContext, Vcb);

    /* wipe journal data and clear recover flag in sb */
    if (rc == 0) {
        journal_wipe_recovery(journal);
        ClearLongFlag(
            Vcb->SuperBlock->s_feature_incompat,
            EXT3_FEATURE_INCOMPAT_RECOVER );
        Ext2SaveSuper(IrpContext, Vcb);
        sync_blockdev(bd);
        ClearLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER);
    }

errorout:

    /* destroy journal structure */
    if (journal) {
        journal_destroy(journal);
    }

    /* destory journal Mcb */
    if (jcb) {
        Ext2FreeMcb(Vcb, jcb);
    }

    return rc;
}