diff --git a/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h b/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h index 758e40df8..dee0bdacc 100755 --- a/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h +++ b/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h @@ -939,6 +939,8 @@ #define SF_HD_DIR SF_SEND_LIST_DIR"HD" #define SF_HD_DIR_CARDV "A:\\THUMB\\HD\\" +#define SF_EMMC_ROOT "/mnt/sd2/" + #define SF_FW_CFG_FILE_NAME "SPHOST_REVEAL.CFG" #define SF_FW_FILE_NAME "SPHOST_REVEAL.BRN" #define SF_FW_CFG_FILE_PATH "A:\\SPHOST_REVEAL.CFG" diff --git a/code/application/source/sf_app/code/include/sf_storeMng.h b/code/application/source/sf_app/code/include/sf_storeMng.h index 165789f57..7751ad5ab 100644 --- a/code/application/source/sf_app/code/include/sf_storeMng.h +++ b/code/application/source/sf_app/code/include/sf_storeMng.h @@ -56,6 +56,13 @@ typedef struct sf_STORE_ATTR_S { }SF_STORE_ATTR_S; +typedef enum +{ + MMC_DEV_SD = 0, + MMC_DEV_EMMC = 1, + MMC_DEV_NO = 2, +}MMC_DEV_TYPE; + SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs); diff --git a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c index df0fc9622..63228bf92 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c @@ -1366,6 +1366,11 @@ SINT32 sf_4g_module_ota_ftp(void) const UINT8 *password; // FtpConfig config; MLOGD("start\n"); + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } ssl_flag = FTP_SSL_FLAG_DISABLE; ftpIP = pPara->OtaFtpIp; @@ -1395,7 +1400,7 @@ SINT32 sf_4g_module_ota_ftp(void) ret = ftp_download_file(SF_MODULE_UP_FILE,SF_MODULE_UP_FILE_PATH,0); if(SUCCESS == ret){ system("sync"); - sprintf(Cmd, "tar -xjvf %s -C %s", SF_MODULE_UP_FILE_PATH, SF_SD_ROOT); + sprintf(Cmd, "tar -xjvf %s -C %s", SF_MODULE_UP_FILE_PATH, strg_path); MLOGD("%s\n", Cmd); ret = system(Cmd); if(SUCCESS == ret){ diff --git a/code/application/source/sf_app/code/source/app/sf_service.c b/code/application/source/sf_app/code/source/app/sf_service.c index 45b1401a8..c3e160cc7 100755 --- a/code/application/source/sf_app/code/source/app/sf_service.c +++ b/code/application/source/sf_app/code/source/app/sf_service.c @@ -871,6 +871,11 @@ SINT16 sf_thumb_file_creat(void) { SF_CHAR fileKeyStr[10] = {0}; SF_CHAR filePathStr[128] = {0}; SINT16 fileIndex = 0; + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } SF_SRCFILE_ATTR_S *fileCfg = sf_file_thumb_cfg_get(); for (fileIndex = 0; fileIndex < fileCfg->filecnt; fileIndex++) { @@ -879,7 +884,7 @@ SINT16 sf_thumb_file_creat(void) { strncpy(dirKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 1, 3); strncpy(fileKeyStr, fileCfg->stfileattr[fileIndex].thumbfileName + 4, 8); MLOGD("dirKeyStr:%s, fileKeyStr:%s\n", dirKeyStr, fileKeyStr); - sprintf(filePathStr, "%s%s/%s%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME, + sprintf(filePathStr, "%s%s/%s%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME, dirKeyStr, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX, fileKeyStr); MLOGD("fileKeyStr:%s\n", filePathStr); diff --git a/code/application/source/sf_app/code/source/fileMng/sf_file.c b/code/application/source/sf_app/code/source/fileMng/sf_file.c index 83874c1a1..a0d2f6f45 100755 --- a/code/application/source/sf_app/code/source/fileMng/sf_file.c +++ b/code/application/source/sf_app/code/source/fileMng/sf_file.c @@ -1452,7 +1452,14 @@ BOOL sf_is_4g_module_usb_update_file_exist(UINT8 *updateFname) struct dirent *ptr = NULL; UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); - if ((dirp=opendir((char *)SF_SD_ROOT)) != NULL) + + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return FALSE; + } + + if ((dirp=opendir((char *)strg_path)) != NULL) { while ((ptr=readdir(dirp)) != NULL) { @@ -1462,7 +1469,7 @@ BOOL sf_is_4g_module_usb_update_file_exist(UINT8 *updateFname) { if(SF_STRNCMP(ptr->d_name, puiPara->ModuleVer, 6) == 0) { - SF_SPRINTF(updateFname, "%s%s", SF_SD_ROOT, ptr->d_name); + SF_SPRINTF(updateFname, "%s%s", strg_path, ptr->d_name); closedir(dirp); printf("[%s:%d] updateFname:%s\n", __FUNCTION__, __LINE__, updateFname); return TRUE; diff --git a/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c b/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c index 61cf1f1b8..bc040ed91 100755 --- a/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c +++ b/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c @@ -310,7 +310,12 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName)); memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath)); - + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } + switch(pSubscribe->subscribeType) { case SF_SUBSCRIBE_VIDEO: @@ -345,7 +350,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S strncpy(fileName, pSubscribe->subscribeFileName + (strlen(pSubscribe->subscribeFileName) - 12), 12); fileKey = atoi(fileName+4); MLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); - sprintf(filePath, "%s%s/%03d%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); + sprintf(filePath, "%s%s/%03d%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); MLOGD("srcFile:%s\n", filePath); ret = sf_file_IsExsit((CHAR*)filePath); @@ -359,7 +364,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SUBSCRIBE_ATTR_S } break; case SF_SUBSCRIBE_SPEC_FILE: - sprintf(filePath, "%s%s", SF_SD_ROOT,"SF_GPS.TXT" ); + sprintf(filePath, "%s%s", strg_path,"SF_GPS.TXT" ); MLOGD("srcFile:%s\n", filePath); ret = sf_file_IsExsit((CHAR*)filePath); @@ -540,6 +545,11 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S* memset(pstfileAttr->txtfileName, '\0', sizeof(pstfileAttr->txtfileName)); memset(pstfileAttr->txtfilePath, '\0', sizeof(pstfileAttr->txtfilePath)); + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } switch(pSendFileAttr->enFileTye) { @@ -554,7 +564,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S* strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12); fileKey = atoi(fileName+4); SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); - sprintf(filePath, "%s%s/%03d%s/%s%04d.%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileKey,SF_DCF_EXT_MOV); + sprintf(filePath, "%s%s/%03d%s/%s%04d.%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileKey,SF_DCF_EXT_MOV); SLOGD("srcFile:%s\n", filePath); // strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 11), 8); @@ -583,7 +593,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S* strncpy(fileName, pSendFileAttr->SubFileName + (strlen(pSendFileAttr->SubFileName) - 12), 12); fileKey = atoi(fileName+4); SLOGD("FileName:%s, fileKey:%d\n", fileName, fileKey); - sprintf(filePath, "%s%s/%03d%s/%s%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); + sprintf(filePath, "%s%s/%03d%s/%s%s", strg_path, SF_DCF_ROOT_DIR_NAME,dirKey, SF_DCF_DIR_NAME_SUFFIX, SF_DCF_FILE_NAME_PREFIX,fileName+4); SLOGD("srcFile:%s\n", filePath); ret = sf_file_IsExsit((CHAR*)filePath); @@ -601,7 +611,7 @@ SINT32 sf_file_subscribe_check(SF_FILE_ATTR_S *pstfileAttr, SF_SEND_FILE_ATTR_S* break; case SF_FILE_TYPE_LOG_ERROR: - sprintf(filePath, "%s%s", SF_SD_ROOT,"SF_GPS.TXT" ); + sprintf(filePath, "%s%s", strg_path,"SF_GPS.TXT" ); SLOGD("srcFile:%s\n", filePath); ret = sf_file_IsExsit((CHAR*)filePath); diff --git a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c index 537c60a1e..b6d1286b1 100644 --- a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c +++ b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c @@ -37,6 +37,8 @@ UINT32 gnDirIdx = 0; static SF_SD_STATUS_E SdStatus = SF_SD_BUTT; +MMC_DEV_TYPE mmc_dev = MMC_DEV_NO; + static SINT32 sd_file_Isexsit(SF_CHAR *fileName) { return access(fileName, F_OK); @@ -76,16 +78,49 @@ static SINT32 sd_Isdirempty(char *dirname) return SF_SUCCESS; } +void sf_set_workable_strg_id(UINT32 strg_id) +{ + mmc_dev = strg_id; +} + +MMC_DEV_TYPE sf_get_workable_strg_id(void) +{ + return mmc_dev; +} + +char *sf_get_root_path(void) +{ + char *strg_path = NULL; + + if(mmc_dev == MMC_DEV_NO) + { + return NULL; + } + + if(sf_get_workable_strg_id() == MMC_DEV_SD){ + strg_path = SF_SD_ROOT; + }else if(sf_get_workable_strg_id() == MMC_DEV_EMMC){ + strg_path = SF_EMMC_ROOT; + } + return strg_path; +} + SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs) { SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE); + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } + SINT32 fd = -1; - fd = open(SF_SD_ROOT, O_RDONLY,0); + fd = open(strg_path, O_RDONLY,0); if(fd >= 0) { struct statfs diskInfo; - statfs(SF_SD_ROOT, &diskInfo); + statfs(strg_path, &diskInfo); if(diskInfo.f_bsize > 1024) { @@ -704,8 +739,13 @@ int sf_dcf_resort_min(void) char sTmp[SF_DCF_FILENAME_LEN_MAX] = {0}; int nmax_dirkey = 0; int nmin_dirkey = 0; + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } - strcpy(sRootPath, SF_SD_ROOT); // "/mnt/sd/" + strcpy(sRootPath, strg_path); // "/mnt/sd/" strcat(sRootPath, SF_DCF_ROOT_DIR_NAME); // ""/mnt/sd/DCIM/" trave_dir(sRootPath,0); @@ -776,10 +816,15 @@ int sf_app_sd_loop(void) nFileKey = gLastFileKey; MLOGD(" s\n"); + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } while((nloop) && (dircount < 5)) { - sprintf(cPathTmp,"%s%s/%03d%s", SF_SD_ROOT, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA" + sprintf(cPathTmp,"%s%s/%03d%s", strg_path, SF_DCF_ROOT_DIR_NAME, nDirKey, DCF_DIR_NAME); // ""/mnt/sd/DCIM/100MEDIA" //Not Empty,Record File Name sprintf(cFileTmp, "%s/%s%04d.%s",cPathTmp, DCF_FILE_NAME, nFileKey, SF_DCF_EXT_PHOTO); @@ -817,7 +862,7 @@ int sf_app_sd_loop(void) } } - sprintf(cFileTmp,"%s%s/W%03d%04d.JPG", SF_SD_ROOT, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); + sprintf(cFileTmp,"%s%s/W%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); //MLOGD("Thumb Filename:%s\n", cFileTmp); if(access(cFileTmp,R_OK) == 0) { @@ -825,7 +870,7 @@ int sf_app_sd_loop(void) remove(cFileTmp); } - sprintf(cFileTmp,"%s%s/S%03d%04d.JPG", SF_SD_ROOT, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); + sprintf(cFileTmp,"%s%s/S%03d%04d.JPG", strg_path, SF_DCF_THM_DIR_NAME, nDirKey, nFileKey); //MLOGD("Thumb Filename:%s\n", cFileTmp); if(access(cFileTmp,R_OK) == 0) { diff --git a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c index 0924259d5..c96234364 100755 --- a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c +++ b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c @@ -1110,6 +1110,13 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) SF_MESSAGE_BUF_S stMessageBuf = {0}; // HI_MESSAGE_S stMessage; + char *strg_path = sf_get_root_path(); + if(strg_path == NULL) + { + return SF_FAILURE; + } + + //printf("[sf_svr_packet_proc]dataLen: %d\n",dataLen); if(poweroff_mode == POWEROFF_COUNTDOWN) @@ -1324,7 +1331,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) strncpy((char *)tempbuf2, (char *)tempbuf, 3); tempbuf[8] = '\0'; sprintf((char *)gFileName, "%sDCIM/%s%s/%s%s%s", - SF_SD_ROOT, + strg_path, tempbuf2, DCF_DIR_NAME, DCF_FILE_NAME, @@ -1874,7 +1881,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) } else { - sprintf((char *)fileName, "%s%s",SF_SD_ROOT,pMsgStruct->msgBuf.ctrlFileTransfer.fileName); + sprintf((char *)fileName, "%s%s",strg_path,pMsgStruct->msgBuf.ctrlFileTransfer.fileName); } //MLOGI("rec file cmd:%s\n", fileName); }