コード例 #1
0
ファイル: rbh_recov.c プロジェクト: fzago-cray/robinhood
static int recov_reset(int force)
{
    int rc;

    /* ask confirmation */
    if ( !force )
    {
        lmgr_recov_stat_t stats;
        char * buff = malloc(1024);
        size_t sz = 1024;

        rc = ListMgr_RecovStatus( &lmgr, &stats );
        if (rc)
        {
            if ( rc == DB_NOT_EXISTS )
                fprintf( stderr, "ERROR: There is no pending recovery\n" );
            return rc;
        }

        printf( "\nWARNING: you are about to abort the current recovery.\n" );
        printf( "All entries not yet recovered will be definitely lost!\n\n");

        printf( "Current recovery status:\n");
        print_recov_stats( FALSE, &stats );
        printf("\n");

        do {
            printf( "Do you really want to proceed [y/n]: " );
            if ( getline( &buff, &sz, stdin ) > 0 )
            {
                if ( !strcasecmp(buff, "y\n") || !strcasecmp(buff, "yes\n") )
                    break;
                else
                {
                    printf("Aborted\n");
                    free(buff);
                    return -ECANCELED;
                }
            }
        } while(1);
        free(buff);
    }
    return ListMgr_RecovReset( &lmgr );
}
コード例 #2
0
int ListMgr_RecovComplete( lmgr_t * p_mgr, lmgr_recov_stat_t * p_stats )
{
    long long int diff;
    int rc;

    /* Check there is no more unprocessed entries */
    rc = ListMgr_RecovStatus( p_mgr, p_stats );
    if (rc)
        return rc;

    diff = p_stats->total - p_stats->status_count[RS_FILE_OK] - p_stats->status_count[RS_FILE_DELTA]
            - p_stats->status_count[RS_FILE_EMPTY] - p_stats->status_count[RS_NON_FILE]
           - p_stats->status_count[RS_NOBACKUP] - p_stats->status_count[RS_ERROR];
    if (diff > 0)
    {
        DisplayLog( LVL_CRIT, LISTMGR_TAG, "Cannot complete recovery: there are still %lld unprocessed files",
                    diff );
        return DB_NOT_ALLOWED;
    }
    /* clear all */
    return ListMgr_RecovReset( p_mgr );
}