From 2cf15cc0a95f1cbbfd13e6b6323e911c53e2c39e Mon Sep 17 00:00:00 2001 From: payton Date: Mon, 6 Nov 2023 10:32:31 +0800 Subject: [PATCH] =?UTF-8?q?1.sd=E5=8D=A1=E6=8C=82=E8=BD=BD=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sf_app/code/source/app/sf_service.c | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) 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 51c1d8de1..77cc2ef4d 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 @@ -2154,22 +2154,55 @@ void serach_gps_onkey_start(void) } pthread_attr_destroy(&attr); } +static int sf_is_sdc_mounted(void) +{ + char line[256]; + printf("%s:%d is_mounted:%d", __FUNCTION__, __LINE__); + + FILE *file = fopen("/proc/mounts", "r"); + if (file == NULL) { + perror("Error opening /proc/mounts"); + return 0; + } + + while (fgets(line, sizeof(line), file)) { + if (strstr(line, "/dev/mmcblk0p1") != NULL) { + fclose(file); + return 1; + } + } + + fclose(file); + return 1; +} int sf_check_sd(void) { UINT8 i = 0; int ret = SF_SUCCESS; if (sf_sd_status_get() != SF_SD_OK) { ret = SF_FAILURE; - for (i = 0; i < 20; i++) { + for (i = 0; i < 20; i++) + { ret = sf_sd_status_get(); - if (SF_SD_OK == ret) { + if (SF_SD_OK == ret) + { ret = SF_SUCCESS; MLOGI("SD\r\n"); sf_statistics_param_load(sf_statistics_param_get()); break; - } else { + } + else + { + if (1 == sf_is_sdc_mounted()) + { + ret = SF_SUCCESS; + MLOGI("mounted SD\r\n"); + sf_statistics_param_load(sf_statistics_param_get()); + break; + } sleep(1); + } } return ret;