Ejemplo n.º 1
0
/*************************************************************************
 函 数 名   : rfile_test_001_01
 功能描述   : 删除文件-->删除目录
*************************************************************************/
s32 rfile_test_001_01(void)
{
    s32 ret;
    s8 *dirpar = "/rfiletest001";
    s8 *filepath = "/rfiletest001/rfile001.txt";

    rfile_print_info("[%s] start =======================================.\n\n", __FUNCTION__);
    rfile_print_info("test for : remove-->rmdir.\n\n");

    ret = bsp_remove(filepath);
    if(BSP_OK != ret)
    {
        rfile_print_info("!!!!!!!! bsp_remove failed.\n");

        goto rfile_test_001_01_fail_1;
    }

    ret = bsp_rmdir(dirpar);
    if(BSP_OK != ret)
    {
        rfile_print_info("!!!!!!!! bsp_rmdir failed.\n");

        goto rfile_test_001_01_fail_1;
    }

    rfile_print_info("[%s] success.\n", __FUNCTION__);

    rfile_print_info("[%s] end =======================================.\n", __FUNCTION__);

    return 0;

rfile_test_001_01_fail_1:

    rfile_print_info("[%s] end =======================================.\n", __FUNCTION__);

    return -1;
}
Ejemplo n.º 2
0
s32 ltcov_hutaf_save_ccore_data(void)
{	
	s32 fp;	       /* stream to read from*/
	u32 len = 0;
	s8* p_buffer = NULL;
	s8* filepath = "/data/ltcov_ccore.bin";
    s32 ret = 0;
	
    /* 判断文件是否存在,如果存在则删除 */
    ret = bsp_access(filepath, 0);
    if(BSP_OK == ret)
    {
        bsp_remove(filepath);
    }

	fp = bsp_open(filepath, (RFILE_CREAT|RFILE_RDWR), 0755);
	if (fp < 0)
	{
		printf("ltcov_hutaf_save_ccore_data:open file ERROR!\n");
		return -1;
	}
	
	/* len以字节为单位 */
	len = HLLT_Agent_GetCovDataSize();
	if (0 == len)
	{
		printf("ltcov_hutaf_save_ccore_data:HLLT_Agent_GetCovDataSize ERROR!\n");
        fclose(fp);
		return -1;
	}
	
	p_buffer = malloc(len);
	if(NULL == p_buffer)
    {
        printf("ltcov_hutaf_save_ccore_data:malloc failed\n");
        fclose(fp);
		return -1;
    }

	/* 将覆盖率数据写到Buffer中 */
	if(1 != HLLT_Coverage_GetCoverageData(p_buffer, len))
	{
		printf("ltcov_hutaf_save_ccore_data:HLLT_Coverage_GetCoverageData failed\n");
	    free(p_buffer);
        fclose(fp);
		return -1;
	}

    /*ret = bsp_lseek(fp, 0, SEEK_SET);
    if(BSP_OK != ret)
    {
        printf("!!!!!!!! bsp_fseek 1 failed .\n");

        return;
    }*/

	/* 写文件 */
    ret = bsp_write(fp, p_buffer, len);
    if(len != ret)
    {
        printf("ltcov_hutaf_save_ccore_data:bsp_write 1 failed.\n");

        return -1;
    }
    bsp_close(fp);
	fp = NULL;
	
	free(p_buffer);

	printf("ltcov_hutaf_save_ccore_data: success\n"); 
	return 0;
}
Ejemplo n.º 3
0
/*
* Function   : sc_opt_comm
* Discription: c core nv init,this phase build upon the a core kernel init,
*              this phase after icc init,this phase ensure to use all nv api normal
*              start at this phase ,ops global ddr need spinlock
* Parameter  : none
* Output     : result
* History    : 
*/
s32 sc_opt_comm(MISC_SC_OPT_ENUM sc_enum, u8* pRamAddr, u32 len)
{
    s32 write_len   = 0;
    s32 sc_fp       = 0;
    s8* sc_path     = (s8*)SC_PACKET_TRANS_FILE;
    sc_icc_stru     sc_send_msg = {MISC_SC_OPT_BUTT};
    
    /* judge para */
    if(sc_enum >= MISC_SC_OPT_BUTT)
    {
        sc_error_printf("para wrong, sc_enum is %d!\n",sc_enum); /* [false alarm]: fortify 误报*/
        return BSP_ERR_SC_INVALID_PARAM;
    }

    if((NULL == pRamAddr)||( len >= SC_MTD_PTABLE_OFFSET))
    {
        sc_error_printf("para wrong, addr is 0x%x, len is 0x%x!\n",(unsigned long)pRamAddr,len);
        return BSP_ERR_SC_INVALID_PARAM;
    }
    
    g_sc_stat.sc_ram_addr   = pRamAddr;
    g_sc_stat.sc_ram_len    = len;
    g_sc_stat.sc_opt_type   = sc_enum;

    if(bsp_access(sc_path,0))
    {
        bsp_remove(sc_path);
    }

    if(MISC_SC_OPT_WRITE == sc_enum)
    {
        sc_fp = bsp_open(sc_path, (RFILE_CREAT|RFILE_RDWR), 0660); /* [false alarm]: fortify 误报*/
        if(sc_fp < 0)
        {
            sc_error_printf("open file %s failed!\n",sc_path);
            return BSP_ERR_SC_NO_FILE;
        }
        
        write_len = bsp_write((u32)sc_fp, (const s8*)pRamAddr, len); /* [false alarm]: fortify 误报*/
        if(write_len != (s32)len)
        {
            sc_error_printf("write %s fail, write len is 0x%x, given len is 0x%x!\n",sc_path,write_len,len);
            bsp_close((u32)sc_fp);
            return BSP_ERR_SC_WRITE_FILE_FAIL;
        }
        
        bsp_close((u32)sc_fp);
    }

    /* send handshake packet */
    sc_send_msg.sc_opt_type     = sc_enum;
    sc_send_msg.sc_total_len    = len;
    write_len = bsp_icc_send(ICC_CPU_APP, SC_ICC_CHAN_ID, (u8*)&sc_send_msg, sizeof(sc_icc_stru));
    if((u32)write_len != sizeof(sc_icc_stru))
    {
        sc_error_printf("send to app filed, write_len is 0x%x!\n",write_len);
        return BSP_ERR_SC_ICC_SEND;
    }
    else
    {
        sc_debug_printf("send to app ok!\n");
    }
    
    /* wait recv sem */
    if(osl_sem_downtimeout(&g_sc_stat.sc_api_sem, 1000))
    {
        sc_error_printf("get result from acore timeout failed!\n");
        return BSP_ERR_SC_SEM_TIMEOUT;
    }
    else
    {
        if((g_sc_stat.sc_opt_type != sc_enum)||(SC_OK != g_sc_stat.sc_opt_ret) )
        {
            sc_error_printf("recv wrong result,sc_icc_type is %d, sc_ret is %d!\n",g_sc_stat.sc_opt_type,g_sc_stat.sc_opt_ret);
            return BSP_ERR_SC_CNF_ABNORMAL;
        }
    }

    if(bsp_access(sc_path, 0))
    {
        bsp_remove(sc_path);
    }

    sc_debug_printf("api opterate %d success !\n",g_sc_stat.sc_opt_type);
    
    return SC_OK;
}