VOS_UINT32 diag_AgentCnfFun(VOS_UINT8* pstCmdCnf,VOS_UINT32 ulCmdId,VOS_UINT32 ulDataSize )
{
    DIAG_CMD_AGENT_TO_FW_CNF_STRU* pstCnf = NULL;
    VOS_UINT32 ret = ERR_MSP_SUCCESS;
    VOS_UINT32 ulSendSize =0;

    ulSendSize = sizeof(DIAG_CMD_AGENT_TO_FW_CNF_STRU)+ ulDataSize;

    pstCnf = VOS_MemAlloc(diag_GetAgentPid(),DYNAMIC_MEM_PT,ulSendSize);

    if(NULL != pstCnf)
    {
        pstCnf->ulCmdId = ulCmdId;
        VOS_MemCpy(pstCnf->aucData, pstCmdCnf, ulDataSize);
        /*lint -save -e40*/
#if(VOS_OS_VER == VOS_LINUX)
        ret = diag_SendMsg(diag_GetAgentPid(),MSP_PID_DIAG_FW,ID_MSG_DIAG_CMD_CNF_APP_AGENT_TO_FW,\
                  (VOS_UINT8*)pstCnf,ulSendSize);
#else
        ret = diag_SendMsg(diag_GetAgentPid(),MSP_PID_DIAG_FW,ID_MSG_DIAG_CMD_CNF_AGENT_TO_FW,\
                  (VOS_UINT8*)pstCnf,ulSendSize);
#endif
        /*lint -restore  +e40*/
        VOS_MemFree(diag_GetAgentPid(), pstCnf);
        return ret;
	}
    else
    {
    	 diag_printf("[%s]: malloc fail!\n",__FUNCTION__);
         return ERR_MSP_MALLOC_FAILUE;
    }
}
VOS_UINT32 diag_SendPsTransMsg(VOS_UINT32 ulRecverId, VOS_UINT8* pDta, VOS_UINT32 dtaSize)
{
    VOS_UINT32 ret = ERR_MSP_UNKNOWN;

    DIAG_PS_MSG_STRU* pDataMsg = NULL;

	/*传进来的dtaSize已经包含了VOS HEADER,因此申请时需要-20*/
    /*lint -save -e740*/
    pDataMsg = (DIAG_PS_MSG_STRU*)VOS_AllocMsg(diag_GetAgentPid(),dtaSize -VOS_MSG_HEAD_LENGTH);
    /*lint -restore*/
    if (pDataMsg)
    {

        VOS_MemCpy(pDataMsg,pDta,dtaSize);
        pDataMsg->ulReceiverPid = ulRecverId;
        pDataMsg->ulSenderPid   = diag_GetAgentPid();
        /* coverity[overflow_const] */
        pDataMsg->ulLength      = dtaSize - VOS_MSG_HEAD_LENGTH;

        ret = VOS_SendMsg(diag_GetAgentPid(), pDataMsg);
        if (ret != VOS_OK)
        {
			diag_printf(" ulRecverId=%d,pDta=%p,dtaSize=%d!\n",ulRecverId,pDta,dtaSize);
        }
        else
        {
            ret = ERR_MSP_SUCCESS;
        }
    }
    return ret;
}
コード例 #3
0
/*****************************************************************************
 Function Name   : diag_FsScanProc
 Description     : 扫描所有文件或文件夹信息
 Input           :VOS_UINT8* pstReq
                VOS_UINT32 ulCmdId
 Output          : None
 Return          : VOS_UINT32

 History         :
    1.w00182550      2013-1-29  Draft Enact

*****************************************************************************/
VOS_UINT32 diag_FsScanProc(VOS_UINT8* pstReq,VOS_UINT32 ulCmdId)
{
    DIAG_CMD_FS_SCAN_DIR_REQ* pstFsReq = NULL;
    DIAG_CMD_FS_SCAN_DIR_CNF* pstFsCnf = NULL;
    VOS_UINT32 ret = ERR_MSP_SUCCESS;
    VOS_UINT32              ulTotalNum;
    VOS_UINT32              ulTotalSize;

    pstFsReq = (DIAG_CMD_FS_SCAN_DIR_REQ*)(DIAG_OFFSET_HEAD_GET_DATA(pstReq));

   /*得到目录内,文件和文件夹的总个数、总的名字长度*/
    if(VOS_OK != diag_FsGetDirInfo(pstFsReq->szDirectory,&ulTotalNum))
    {
        return VOS_ERR;
    }

    /*计算返回给工具侧消息包的长度*/
    ulTotalSize = (ulTotalNum* sizeof(DIAG_DIR_FILE_INFO_STRU)+ sizeof(DIAG_CMD_FS_SCAN_DIR_CNF));

    pstFsCnf = (DIAG_CMD_FS_SCAN_DIR_CNF*)VOS_MemAlloc(diag_GetAgentPid(), DYNAMIC_MEM_PT, ulTotalSize);
    if (VOS_NULL_PTR == pstFsCnf)
    {
        return VOS_ERR;
    }

    /*获取每个文件和文件夹的信息*/
    /*lint -save -e539*/
	if(ulTotalNum>0)
	{
    	ret = diag_FsGetItemInfo(pstFsReq->szDirectory,pstFsCnf->stDirInfo);
	}
    /*lint -restore*/

    pstFsCnf->ulRet = ret;
    pstFsCnf->ulDirNum= ulTotalNum;
    pstFsCnf->ulDirInfoLen= ulTotalNum * sizeof(DIAG_DIR_FILE_INFO_STRU);

    /*打包回复给FW*/
    ret = diag_AgentCnfFun((VOS_UINT8*)pstFsCnf,ulCmdId,ulTotalSize);
    /*lint -save -e50*/
    VOS_MemFree(diag_GetAgentPid(), pstFsCnf);
    /*lint -restore*/
    return ret;

}
コード例 #4
0
/*****************************************************************************
 Function Name   : diag_FsOpenProc
 Description     : 打开或创建文件
 Input           :VOS_UINT8* pstReq
                VOS_UINT32 ulCmdId
 Output          : None
 Return          : VOS_UINT32

 History         :
    1.w00182550      2013-1-29  Draft Enact

*****************************************************************************/
VOS_UINT32 diag_FsOpenProc(VOS_UINT8* pstReq,VOS_UINT32 ulCmdId)
{
    DIAG_CMD_FS_OPEN_REQ* pstFsReq = NULL;
    DIAG_CMD_FS_OPEN_CNF stFsCnf = {0};
    VOS_UINT32 ret = ERR_MSP_SUCCESS;

    pstFsReq = (DIAG_CMD_FS_OPEN_REQ*)(DIAG_OFFSET_HEAD_GET_DATA(pstReq));

    /*不支持操作文件的重入操作*/
    if (DIAG_FILE_NULL != g_stDiagFileInfo.lFile)
    {
        diag_printf("warning: last File import not finished\n");
        diag_FsClose();
    }
    /*lint -save -e539*/
	diag_fs_log();
    /*lint -restore*/
    g_stDiagFileInfo.lFile = diag_FsOpen(pstFsReq->szDirectory, (VOS_INT)(pstFsReq->ulMode));

    if (g_stDiagFileInfo.lFile < 0)
    {
    	g_stDiagFileInfo.lFile = DIAG_FILE_NULL;
        ret = VOS_ERR;
    }
	else
	{
	    /*启动定时器*/
	    g_stDiagFileInfo.hTimer = VOS_NULL_PTR;

	    ret = VOS_StartRelTimer(&g_stDiagFileInfo.hTimer, diag_GetAgentPid(), DIAG_CMD_FILE_OPS_TIME_OUT_LEN, 0, DIAG_TMR_FILE_OP_TIMEOUT_PARAM,VOS_RELTIMER_NOLOOP, VOS_TIMER_NO_PRECISION);
        if(ret != ERR_MSP_SUCCESS)
        {
            /*lint -save -e717*/
            diag_printf("VOS_StartRelTimer fail [%s]\n",__func__);
            /*lint -restore*/
        }
        diag_fs_log();
	}
    stFsCnf.ulRet = ret;

    /*打包回复给FW*/
    ret = diag_AgentCnfFun((VOS_UINT8*)&stFsCnf,ulCmdId,sizeof(DIAG_CMD_FS_OPEN_CNF));
	diag_fs_log();

    return ret;

}
VOS_UINT32  diag_FsGetDirInfo(VOS_CHAR *pDirName, VOS_UINT32 *pulTotalNum)
{
    VOS_INT32 				dir_handle =0;
	VOS_INT32				nRead =0;
	VOS_INT32				nCount =0;
	VOS_UINT32				i=0;
	VOS_UINT8*				buf =NULL;

    DIAG_DIRENT_STRU        *pstTmpDirent;
    mm_segment_t old_fs;

    old_fs = get_fs();
    set_fs(KERNEL_DS);

    /*打开目录*/
    if((dir_handle = DIAG_FS_OPENDIR((VOS_CHAR*)pDirName,DIAG_FS_RDONLY|DIAG_FS_DIRECTORY,0))< 0)
    {
        set_fs(old_fs);
		printk( "[%s]DIAG_FS_OPENDIR error!",__FUNCTION__);
        return VOS_ERR;
    }

	buf =(VOS_UINT8*)VOS_MemAlloc(diag_GetAgentPid(), DYNAMIC_MEM_PT,MSP_DF_DIR_BUF_LEN);
    if(NULL == buf)
    {
        printk( "[%s]Alloc mem error!",__FUNCTION__);
		DIAG_FS_CLOSEDIR(dir_handle);
		set_fs(old_fs);
        return VOS_ERR;
    }
	nRead = DIAG_FS_GETDENTS(dir_handle, (struct linux_dirent __user *)buf, MSP_DF_DIR_BUF_LEN);

	if(-1 == nRead)
	{
		printk("[%s]dents error,nRead=%d!\n",__FUNCTION__,(VOS_INT)nRead);
		*pulTotalNum =0;
		VOS_MemFree(diag_GetAgentPid(), buf);
		DIAG_FS_CLOSEDIR(dir_handle);
		set_fs(old_fs);
		return VOS_ERR;
	}

	if(0 == nRead)
	{
		diag_printf("[%s]dents zero!\n",__FUNCTION__);
		*pulTotalNum = 0;
		VOS_MemFree(diag_GetAgentPid(), buf);
		DIAG_FS_CLOSEDIR(dir_handle);
		set_fs(old_fs);
		return VOS_OK;
	}

	for(i=0; i<(VOS_UINT32)nRead;)
	{
	    pstTmpDirent = (DIAG_DIRENT_STRU*)(buf + i);
		i += pstTmpDirent->d_reclen;

		if((0 == VOS_StrCmp((char *) pstTmpDirent->d_name, "."))
			||(0 == VOS_StrCmp ((char *) pstTmpDirent->d_name, "..")))
        {
        	diag_printf("diag_FsGetDirInfo:d_name=%S!\n",pstTmpDirent->d_name);
            continue;
        }
#if 0
	    if (nCount>=FILENAME_NUM_MAX)
        {
        	DIAG_FS_CLOSEDIR(dir_handle);
	        set_fs(old_fs);
            return VOS_ERR;
        }
#endif
		nCount++;
	}

	*pulTotalNum = nCount;

     /*关闭目录*/
    if (DIAG_FS_ERROR == DIAG_FS_CLOSEDIR(dir_handle))
    {
        VOS_MemFree(diag_GetAgentPid(), buf);
    	printk("[%s]DIAG_FS_CLOSEDIR zero!\n",__FUNCTION__);
        set_fs(old_fs);
        return VOS_ERR;
    }

    VOS_MemFree(diag_GetAgentPid(), buf);

    set_fs(old_fs);
    return VOS_OK;
}
VOS_UINT32 diag_FsExportProc(VOS_UINT8* pstReq,VOS_UINT32 ulCmdId)
{
    //DIAG_CMD_FS_EXPORT_REQ* pstFsReq = NULL;
    DIAG_CMD_FS_EXPORT_CNF *pstFsCnf = NULL;
    VOS_UINT32 ret = ERR_MSP_SUCCESS;
    VOS_UINT32 ulReadSize = 0;
#if(VOS_OS_VER == VOS_LINUX)
    mm_segment_t old_fs;
#endif


    if (DIAG_FILE_NULL == g_stDiagFileInfo.lFile)
    {

		diag_fs_log();
         return ERR_MSP_FAILURE;
    }

    /*停止定时器*/
    VOS_StopRelTimer(&g_stDiagFileInfo.hTimer);
	diag_fs_log();

    pstFsCnf = (DIAG_CMD_FS_EXPORT_CNF*)VOS_MemAlloc(diag_GetAgentPid(), DYNAMIC_MEM_PT, sizeof(DIAG_CMD_FS_EXPORT_CNF)+DIAG_TRANSFER_BLOCK_MAX_SIZE);
    if (VOS_NULL_PTR == pstFsCnf)
    {

		diag_fs_log();
        diag_FsClose();
        return ERR_MSP_FAILURE;

    }

#if(VOS_OS_VER == VOS_LINUX)
    old_fs = get_fs();
    set_fs(KERNEL_DS);
#endif

#if(VOS_OS_VER == VOS_LINUX)
    ulReadSize = (VOS_UINT32)DIAG_FS_READ(g_stDiagFileInfo.lFile,(VOS_CHAR*)pstFsCnf + sizeof(DIAG_CMD_FS_EXPORT_CNF), DIAG_TRANSFER_BLOCK_MAX_SIZE);
#else
    ulReadSize = (VOS_UINT32)DIAG_FS_READ((FILE *)g_stDiagFileInfo.lFile,(VOS_CHAR*)pstFsCnf + sizeof(DIAG_CMD_FS_EXPORT_CNF), DIAG_TRANSFER_BLOCK_MAX_SIZE);
#endif

	diag_fs_log();

#if(VOS_OS_VER == VOS_LINUX)
    set_fs(old_fs);
#endif

    /*读取文件出现错误*/
    if (DIAG_FS_ERROR == (VOS_INT32)ulReadSize)
    {

		diag_fs_log();
        VOS_MemFree(diag_GetAgentPid(),pstFsCnf);
        diag_FsClose();
        return ERR_MSP_FAILURE;

    }

    /*表明已经没有内容可以读取,文件内容全部读完*/
    if (0 == ulReadSize)
    {

		diag_fs_log();
        diag_FsClose();
    }
    else
    {

		diag_fs_log();
        /*启动定时器*/
        g_stDiagFileInfo.hTimer = VOS_NULL_PTR;
        ret = VOS_StartRelTimer(&g_stDiagFileInfo.hTimer, diag_GetAgentPid(), DIAG_CMD_FILE_OPS_TIME_OUT_LEN, 0, DIAG_TMR_FILE_OP_TIMEOUT_PARAM, VOS_RELTIMER_NOLOOP, VOS_TIMER_NO_PRECISION);
        if(ret != ERR_MSP_SUCCESS)
        {
            diag_printf("VOS_StartRelTimer fail [%s]\n", __func__);
        }

	}

    pstFsCnf->ulRet = ret;
    pstFsCnf->ulSize = ulReadSize;

    /*打包回复给FW*/
    ret = diag_AgentCnfFun((VOS_UINT8*)pstFsCnf,ulCmdId,sizeof(DIAG_CMD_FS_EXPORT_CNF)+ulReadSize);
    VOS_MemFree(diag_GetAgentPid(),pstFsCnf);

	diag_fs_log();
    return ret;

}
VOS_UINT32 diag_FsImportProc(VOS_UINT8* pstReq,VOS_UINT32 ulCmdId)
{
    DIAG_CMD_FS_IMPORT_REQ* pstFsReq = NULL;
    DIAG_CMD_FS_IMPORT_CNF stFsCnf = {0};
    VOS_UINT32 ret = ERR_MSP_SUCCESS;
    VOS_INT32 lResult =0;
#if(VOS_OS_VER == VOS_LINUX)
    mm_segment_t old_fs;
#endif

    pstFsReq = (DIAG_CMD_FS_IMPORT_REQ*)(DIAG_OFFSET_HEAD_GET_DATA(pstReq));

    if (DIAG_FILE_NULL == g_stDiagFileInfo.lFile)
    {
        return ERR_MSP_FAILURE;
    }
    diag_fs_log();

    /*停止定时器*/
    VOS_StopRelTimer(&g_stDiagFileInfo.hTimer);

    /*写文件完毕,关闭文件*/
    if (0 == pstFsReq->ulSize)
    {

		diag_fs_log();
        diag_FsClose();
        /*打包回复给FW*/
        stFsCnf.ulRet = ERR_MSP_SUCCESS;
        ret = diag_AgentCnfFun((VOS_UINT8*)&stFsCnf,ulCmdId,sizeof(DIAG_CMD_FS_IMPORT_CNF));
        return ret;
    }

#if(VOS_OS_VER == VOS_LINUX)
    old_fs = get_fs();
    set_fs(KERNEL_DS);
#endif

#if(VOS_OS_VER == VOS_LINUX)
    lResult = DIAG_FS_WRITE(g_stDiagFileInfo.lFile, pstFsReq->acContent, pstFsReq->ulSize);
#else
    lResult = DIAG_FS_WRITE((FILE *)g_stDiagFileInfo.lFile, pstFsReq->acContent, pstFsReq->ulSize);
#endif

	diag_fs_log();

#if(VOS_OS_VER == VOS_LINUX)
    set_fs(old_fs);
#endif

    /*写文件操作失败或者写入长度不正确*/
    if ((DIAG_FS_ERROR == lResult)||(lResult != (VOS_INT32)(pstFsReq->ulSize)))
    {
		diag_fs_log();
		diag_printf("[%s]!,lResult=%d\n",__FUNCTION__,lResult);
		diag_FsClose();
        return VOS_ERR;
    }

    /*启动定时器*/
    ret = VOS_StartRelTimer(&g_stDiagFileInfo.hTimer, diag_GetAgentPid(),DIAG_CMD_FILE_OPS_TIME_OUT_LEN,0,DIAG_TMR_FILE_OP_TIMEOUT_PARAM,VOS_RELTIMER_NOLOOP, VOS_TIMER_NO_PRECISION);
    if(ret != ERR_MSP_SUCCESS)
    {
        diag_printf("VOS_StartRelTimer fail [%s]\n",__func__);
    }

    stFsCnf.ulRet = ret;

    /*打包回复给FW*/
    ret = diag_AgentCnfFun((VOS_UINT8*)&stFsCnf,ulCmdId,sizeof(DIAG_CMD_FS_IMPORT_CNF));
    return ret;

}
VOS_UINT32 diag_FsGetItemInfo(VOS_CHAR *pDirectory,DIAG_DIR_FILE_INFO_STRU *pstDirFileInfo)
{
    /*lint -save -e958*/
    DIAG_DIRENT_STRU        *pstTmpDirent;
    DIAG_STAT_STRU           stStat;
    VOS_UINT8              *pDirName;
    VOS_UINT16              usDirLen;
    VOS_UINT32              ultemp_len = 0;
    VOS_INT32 				dir_handle =0;
    /*lint -restore*/
    /*再次打开目录*/
    dir_handle = (VOS_INT32)DIAG_FS_OPENDIR(pDirectory,DIAG_FS_RDONLY|DIAG_FS_DIRECTORY,0);  /* [false alarm]:屏蔽Fortify */
    if(dir_handle < 0)
    {
        return VOS_ERR;
    }

    /*分配空间用来存放文件或文件夹的路径,加1是因为后面需要添加斜杠*/
    pDirName = (VOS_UINT8*)VOS_MemAlloc(diag_GetAgentPid(), DYNAMIC_MEM_PT,MSP_DF_DIR_MAX_LEN);
    if (VOS_NULL_PTR == pDirName)
    {
        DIAG_FS_CLOSEDIR(dir_handle);
        return VOS_ERR;

    }

    /*将目录路径拷贝进文件路径中*/
    usDirLen = (VOS_UINT16)VOS_StrLen((VOS_CHAR*)pDirectory);
    VOS_MemCpy(pDirName, pDirectory, usDirLen);

    /*由于目录路径是不以斜杠结束,在与文件名结合时,需要添加斜杠*/
    pDirName[usDirLen] = '/';
    usDirLen++;

    do
    {
        /*遍历整个pstDir指向路径中的所有文件和文件夹*/
        pstTmpDirent = (DIAG_DIRENT_STRU *)DIAG_FS_READDIR(dir_handle);

        /*readdir的返回值为空,表明目录浏览完毕*/
        /*lint -save -e830*/
        if (VOS_NULL_PTR != pstTmpDirent)
        /*lint -restore*/
        {
            /*得到文件或文件夹名的长度*/
            ultemp_len = (VOS_UINT16)VOS_StrLen(pstTmpDirent->d_name);  /* [false alarm]:屏蔽Fortify */

            /*由于文件或文件夹路径需要以'\0'作为结束,所以在Copy时,长度加1*/
            VOS_MemCpy(pDirName + usDirLen,pstTmpDirent->d_name, ultemp_len + 1);

            /*通过stat获取文件或文件夹的信息*/
            /*lint -save -e628*/
            if (DIAG_FS_ERROR == DIAG_FS_STAT((VOS_CHAR*)pDirName, &stStat))/*lint !e628*/
            {
            /*lint -restore*/
                pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FILE;
                pstDirFileInfo->st_size    = 0;
                pstDirFileInfo->st_mode    = 0;
                pstDirFileInfo->st_atime   = 0;
                pstDirFileInfo->st_mtime   = 0;
                pstDirFileInfo->st_ctime   = 0;
            }
            else
            {
                /*目录*/
                if (0 != (DIAG_IF_DIR&stStat.st_mode))
                {

                    pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FOLDER;
                }
                /*文件*/
                else
                {
                    pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FILE;
                }
                pstDirFileInfo->st_size   = (stStat.st_size & 0xFFFFFFFF);/* 目前文件大小不会超过32位大小 */
                pstDirFileInfo->st_atime  = (VOS_INT32)(stStat.st_atime);
                pstDirFileInfo->st_mtime  = (VOS_INT32)(stStat.st_mtime);
                pstDirFileInfo->st_ctime  = (VOS_INT32)(stStat.st_ctime);
                pstDirFileInfo->st_mode   = stStat.st_mode;
            }

            /*文件或文件夹名*/
            VOS_MemCpy(pstDirFileInfo->aucDirName, pstTmpDirent->d_name, ultemp_len +1);
            /* coverity[suspicious_pointer_arithmetic] */
            pstDirFileInfo = pstDirFileInfo + sizeof(DIAG_DIR_FILE_INFO_STRU );
        }
    }while(VOS_NULL_PTR != pstTmpDirent);

    VOS_MemFree(diag_GetAgentPid(), pDirName);
    DIAG_FS_CLOSEDIR(dir_handle);

    return VOS_OK;

}
VOS_UINT32 diag_FsGetItemInfo(VOS_CHAR *pDirectory,DIAG_DIR_FILE_INFO_STRU *pstDirFileInfo)
{
    DIAG_DIRENT_STRU        *pstTmpDirent;
    DIAG_STAT_STRU           stStat;
    VOS_UINT8               ucDirName[MSP_DF_DIR_MAX_LEN];
    VOS_INT32 				dir_handle =0;
	VOS_INT32				nRead =0;
	VOS_INT32				i=0;
	VOS_UINT8*				buf =NULL;
    mm_segment_t old_fs;

    old_fs = get_fs();
    set_fs(KERNEL_DS);

    /*再次打开目录*/
    if((dir_handle = DIAG_FS_OPENDIR(pDirectory,DIAG_FS_RDONLY|DIAG_FS_DIRECTORY,0))< 0)
    {
    	printk( "[%s]DIAG_FS_OPENDIR error!",__FUNCTION__);
        set_fs(old_fs);
        return VOS_ERR;

    }

	buf =(VOS_UINT8*)VOS_MemAlloc(diag_GetAgentPid(), DYNAMIC_MEM_PT,MSP_DF_DIR_BUF_LEN);
    if(NULL == buf)
    {
        printk( "[%s]Alloc mem error!",__FUNCTION__);
		DIAG_FS_CLOSEDIR(dir_handle);
		set_fs(old_fs);
        return VOS_ERR;
    }
	nRead = DIAG_FS_GETDENTS(dir_handle, (struct linux_dirent __user *)buf, MSP_DF_DIR_BUF_LEN);
	if((-1 == nRead)||(0 == nRead))
	{
		printk("[%s]dents error,nRead=%d!\n",__FUNCTION__,(VOS_INT)nRead);
		VOS_MemFree(diag_GetAgentPid(), buf);
		DIAG_FS_CLOSEDIR(dir_handle);
		set_fs(old_fs);
		return VOS_ERR;
	}

	/*轮询文件夹将所有文件名保存至全局变量*/
	for(i=0; i<nRead; )
	{
		pstTmpDirent = (DIAG_DIRENT_STRU*)(buf + i);
		i += pstTmpDirent->d_reclen;

		if((0 == VOS_StrCmp((char *) pstTmpDirent->d_name, "."))
			||(0 == VOS_StrCmp ((char *) pstTmpDirent->d_name, "..")))
		{
			diag_printf("[%s]:d_name=%S!\n",__FUNCTION__,pstTmpDirent->d_name);
			continue;
		}

		VOS_StrCpy((VOS_CHAR *)ucDirName, pDirectory);
		strncat((VOS_CHAR *)ucDirName, "/",sizeof(VOS_CHAR));
        strncat((VOS_CHAR *)ucDirName, pstTmpDirent->d_name,strlen(pstTmpDirent->d_name));

        /*通过stat获取文件或文件夹的信息*/
        if (DIAG_FS_ERROR == DIAG_FS_STAT((VOS_CHAR *)ucDirName, &stStat))
        {
        	printk("DIAG_FS_STAT: error!\n");
            pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FILE;
            pstDirFileInfo->st_size    = 0;
            pstDirFileInfo->st_mode    = 0;
            pstDirFileInfo->st_atime   = 0;
            pstDirFileInfo->st_mtime   = 0;
            pstDirFileInfo->st_ctime   = 0;
        }
        else
        {
            /*目录*/

            if (0 != (DIAG_IF_DIR&stStat.mode))
            {

                pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FOLDER;
            }
            /*文件*/
            else
            {
                pstDirFileInfo->ulItemType = DIAG_FS_ITEM_FILE;
            }
            pstDirFileInfo->st_size   = (stStat.size & 0xFFFFFFFF);/* 目前文件大小不会超过32位大小 */
            pstDirFileInfo->st_atime  = stStat.atime.tv_sec;
            pstDirFileInfo->st_mtime  = stStat.mtime.tv_sec;
            pstDirFileInfo->st_ctime  = stStat.ctime.tv_sec;
            pstDirFileInfo->st_mode   = stStat.mode;
        }

        /*文件或文件夹名*/
        VOS_MemSet(pstDirFileInfo->aucDirName, 0,DIAG_CMD_FILE_NAME_LEN);
        VOS_StrCpy(pstDirFileInfo->aucDirName, pstTmpDirent->d_name);

        pstDirFileInfo++;

 	}

    VOS_MemFree(diag_GetAgentPid(), buf);
    DIAG_FS_CLOSEDIR(dir_handle);
    set_fs(old_fs);

    return VOS_OK;

}
コード例 #10
0
VOS_UINT32 diag_BspSysviewProcEntry(VOS_UINT8* pstReq , VOS_UINT32 ulCmdId)
{
    VOS_UINT32  ret ;
    VOS_UINT32 cnf_data_len = 0;

    DIAG_BSP_SYVIEW_SWT_CFG_STRU *pstSysviewSet = VOS_NULL;
    DIAG_BSP_SYVIEW_SWT_CNF_STRU  *pstLogSysviewCnf  = {0};
    VOS_UINT8 *pstCnf = VOS_NULL;



    if((DIAG_CMD_BSP_SYSVIEW_SWT_ACORE == (MSP_STRU_ID_0_15_CMD_CATEGORY(ulCmdId)))
        ||(DIAG_CMD_BSP_CPU_SWT_ACORE == (MSP_STRU_ID_0_15_CMD_CATEGORY(ulCmdId))))
    {
        ret = ERR_MSP_SUCCESS;
    }
    else if((DIAG_CMD_BSP_SYSVIEW_SWT_CCORE == (MSP_STRU_ID_0_15_CMD_CATEGORY(ulCmdId)) )
                ||(DIAG_CMD_BSP_CPU_SWT_CCORE == (MSP_STRU_ID_0_15_CMD_CATEGORY(ulCmdId))))
    {

        pstSysviewSet = (DIAG_BSP_SYVIEW_SWT_CFG_STRU *)DIAG_OFFSET_HEAD_GET_DATA(pstReq);

         ret= DRV_SYSVIEW_SWT_SET(pstSysviewSet->trace_type,pstSysviewSet->trace_swt,pstSysviewSet->period);

        if(ret  == ERR_MSP_SUCCESS)
        {
            if((pstSysviewSet->trace_type ==SYSVIEW_TASK_INFO )&&(pstSysviewSet->trace_swt ==1 ))
            {
                cnf_data_len = sizeof(DIAG_BSP_SYVIEW_SWT_CNF_STRU)+sizeof(DIAG_BSP_TASK_INFO_STRU)*128;
                /* coverity[returned_null] */
                pstLogSysviewCnf =(DIAG_BSP_SYVIEW_SWT_CNF_STRU*)VOS_MemAlloc(MSP_PID_DIAG_AGENT, DYNAMIC_MEM_PT,cnf_data_len);
                /* coverity[dereference] */
                pstLogSysviewCnf->ullen = sizeof(DIAG_BSP_TASK_INFO_STRU)*128;
                DRV_GET_ALL_TASK_ID_NAME((pstLogSysviewCnf->st_task_info), sizeof(DIAG_BSP_TASK_INFO_STRU)*128);
            }
            else
            {
                cnf_data_len = sizeof(DIAG_BSP_SYVIEW_SWT_CNF_STRU);
                /* coverity[returned_null] */
                pstLogSysviewCnf =(DIAG_BSP_SYVIEW_SWT_CNF_STRU*)VOS_MemAlloc(MSP_PID_DIAG_AGENT, DYNAMIC_MEM_PT,cnf_data_len);
                /* coverity[dereference] */
                pstLogSysviewCnf->ullen  = 0;
            }
        }
        else
        {
            cnf_data_len = sizeof(DIAG_BSP_SYVIEW_SWT_CNF_STRU);
            /* coverity[returned_null] */
            pstLogSysviewCnf =(DIAG_BSP_SYVIEW_SWT_CNF_STRU*)VOS_MemAlloc(MSP_PID_DIAG_AGENT, DYNAMIC_MEM_PT,cnf_data_len);
            /* coverity[dereference] */
            pstLogSysviewCnf->ullen  = 0;

        }

        pstLogSysviewCnf->ulRet = ret;
        pstLogSysviewCnf->trace_type =pstSysviewSet->trace_type;
        pstCnf = (VOS_UINT8 *)pstLogSysviewCnf ;

    }
    else
    {
        ret = ERR_MSP_FAILURE;
    }

    if(VOS_NULL!=pstCnf)
    {
        ret = diag_AgentCnfFun(pstCnf,ulCmdId,cnf_data_len);

         VOS_MemFree(diag_GetAgentPid(), pstCnf);
    }

    return ret;
}
コード例 #11
0
ファイル: diag_cfg.c プロジェクト: printusrzero/hwp6s-kernel
/*****************************************************************************
 Function Name   : diag_ConnProc
 Description     : 该函数用于处理ConnProcEntry传进来的HSO连接命令
 Input           : pstReq 待处理数据
 Output          : None
 Return          : VOS_UINT32

 History         :
    1.y00228784      2012-11-22  Draft Enact

*****************************************************************************/
VOS_UINT32 diag_ConnProc(VOS_UINT8* pstReq,VOS_UINT32 ulCmdId)
{
    VOS_UINT32 ret      = ERR_MSP_SUCCESS;
    VOS_UINT32 ulCnfRst = ERR_MSP_UNAVAILABLE;
#if (VOS_OS_VER == VOS_LINUX)
    DIAG_CMD_HOST_CONNECT_CNF_STRU stCnf = {0};
    NV_ITEM_PWC_SWITCH_STRU stPwrctrlSwitch = {0};
    VOS_UINT32 ulPwrFlag = 0;
    LPS_SWITCH_PARA_STRU stDrxControlFlag = {0};
    UE_SW_BUILD_VER_INFO_STRU *pstBuildVer =NULL;
    DIAG_CMD_REPLAY_SET_REQ_STRU stReplay= {0};
#endif

    /*重置所有开关状态为未打开*/
    diag_CfgResetAllSwt();

    /*设置连接状态开关值*/
    ulCnfRst = diag_CfgSetGlobalBitValue(&g_ulDiagCfgInfo,DIAG_CFG_CONN_BIT,DIAG_CFG_SWT_OPEN);

    DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_CONN_CFG, ulCnfRst, 0, 0);

#if (VOS_OS_VER == VOS_LINUX)
    VOS_MemSet(&(stCnf.stBuildVersion), 0, sizeof(DIAG_CMD_UE_BUILD_VER_STRU));

    /*获取版本信息*/
    pstBuildVer = BSP_GetBuildVersion();
    if(pstBuildVer!=NULL)
    {
        pstBuildVer->ulProductNo = BSP_HwGetVerMain();
        stCnf.stBuildVersion.usVVerNo        = pstBuildVer->ulVVerNo;
        stCnf.stBuildVersion.usRVerNo        = pstBuildVer->ulRVerNo;
        stCnf.stBuildVersion.usCVerNo        = pstBuildVer->ulCVerNo;
        stCnf.stBuildVersion.usBVerNo        = pstBuildVer->ulBVerNo;
        stCnf.stBuildVersion.usSpcNo         = pstBuildVer->ulSpcNo;
        stCnf.stBuildVersion.usHardwareVerNo = pstBuildVer->ulCustomVer;
        stCnf.stBuildVersion.ulProductNo     = pstBuildVer->ulProductNo;
    }

    /*获取IMEI号*/
    ret = diag_GetImei(stCnf.szImei);
    if(ret)
    {
    }

    /*获取软件版本号*/
    VOS_MemSet(&stCnf.stUeSoftVersion,0,sizeof(DIAG_CMD_UE_SOFT_VERSION_STRU));

    /*获取数采基地址*/
    stCnf.ulChipBaseAddr = (VOS_UINT32)BSP_OM_GetChipType();
    //stCnf.ulChipBaseAddr = (VOS_UINT32)V7R1_PILOT_CHIP;

    /*路测信息获取*/
    ret = NVM_Read(EN_NV_ID_AGENT_FLAG,&(stCnf.stAgentFlag),sizeof(NV_ITEM_AGENT_FLAG_STRU));
    if(ret)
    {
    }

    /*低功耗开关获取*/
    ret = NVM_Read(EN_NV_ID_PWC_SWITCH,&stPwrctrlSwitch,sizeof(NV_ITEM_PWC_SWITCH_STRU));
    if(ret)
    {
    }
    ulPwrFlag = stPwrctrlSwitch.drxLBbpPd;

    ret = NVM_Read(EN_NV_ID_SWITCH_PARA,&stDrxControlFlag,sizeof(stDrxControlFlag));
    if(ret)
    {
    }
    stCnf.ulDrxControlFlag = stDrxControlFlag.ulDrxControlFlag & ulPwrFlag;
    /*lint -save -e40*/

    ulCnfRst |= diag_SendMsg(diag_GetAgentPid(),PS_PID_MM,ID_MSG_DIAG_CMD_REPLAY_TO_PS,(VOS_UINT8*)&stReplay,\
                             sizeof(DIAG_CMD_REPLAY_SET_REQ_STRU));
    /*lint -restore  +e40*/
    /*获取当前存取模式*/
    stCnf.ulLpdMode = diag_GetLogSendType();

    /*处理结果*/
    stCnf.ulRc = ulCnfRst;

    /*组包给FW回复*/
    ret = diag_AgentCnfFun((VOS_UINT8*)&stCnf,ulCmdId,sizeof(DIAG_CMD_HOST_CONNECT_CNF_STRU));
#else
    /*lint -e18 -e718 -e628 -e830 -e746*/
    diag_EnableSocpChan();
    /*lint +e18 +e718 +e628 +e830 +e746*/
#endif
    return ret;
}