[Feature][API-1495][API-1498] /data partition protection mechanism,data size qwarnvalue is 10M,modify uci order
Only Configure:No
Affected branch:no
Affected module:unknown
Is it affected on both ZXIC and MTK:only MTK
Self-test:Yes
Doc Update:No
Change-Id: I20ac6c35fc623cd48304d00cdb48ea236bf8d573
(cherry picked from commit cf7e5849d4e52dae89fb56f791a889f7a4fb7925)
diff --git a/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover b/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
old mode 100644
new mode 100755
index 97e16c4..209e2ed
--- a/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
+++ b/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
@@ -168,3 +168,39 @@
fi
fi
echo "$TAG === Initial: LYNQ MOUNT Abnomal End ===" > /dev/kmsg
+
+
+a_int=$(df | grep '/data$' | awk '{print $4}')
+b_int=1024
+
+ if [ $a_int -eq $b_int ];then
+ echo "$a_int = $b_int"
+ elif [ $a_int -lt $b_int ];then
+ find /data -name '*.pcap' | xargs rm -rf
+ sleep 0.02
+ find /data -name '*.cap' | xargs rm -rf
+ sleep 0.02
+ find /data -name '*.log' | xargs rm -rf
+ sleep 0.02
+ c_int=$(df | grep '/data$' | awk '{print $4}')
+
+ if [ $c_int -eq $b_int ];then
+ echo "$c_int = $b_int"
+ elif [ $c_int -lt $b_int ];then
+ echo '#/bin/sh' > /tmp/delete_partition.sh
+ echo 'cd /data' >> /tmp/delete_partition.sh
+ echo 'GLOBIGNORE=agps_sup1:.update_status:atsvc:ccci_cfg:core:gpio:gps_mnl:lynq-low-power.sh:mdlog:misc:mpe_mnl:nvram:ril:vendor:lynq-test.sh:wifi:delete_partition.sh' >> /tmp/delete_partition.sh
+
+ echo 'rm -rf *' >> /tmp/delete_partition.sh
+ cd /tmp
+ chmod 777 delete_partition.sh
+ /tmp/delete_partition.sh
+ rm -rf delete_partition.sh
+ else
+ echo "$c_int > $b_int"
+ fi
+
+ else
+ echo "userdata avalil size is $a_int"
+ fi
+
diff --git a/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp b/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
index 4d5c7ee..252a13f 100755
--- a/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
+++ b/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
@@ -14,15 +14,16 @@
#include <errno.h>
#include "lynq_timer.h"
#include <include/lynq_uci.h>
-
-
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <assert.h>
+
#define DEST_PORT 8088
#define DSET_IP_ADDRESS "127.0.0.1"
#define RIL_REQUEST_DEVICE_IDENTITY 98
#define MAX_LEN 1024
#define TIMER 30
-
-
#define LOG_UCI_FILE "lynq_uci"
#define LOG_UCI_MODULE "debug_mode"
@@ -97,6 +98,25 @@
return 0;
}
+/**
+ * @brief find partition zhengshu for exzample 5.7M,get value 5
+ *
+ * @param arg
+ * @return
+ */
+static void removeSpaces(char* str)
+{
+ char* dest = str;
+ while (*str) {
+ if (*str != ' ') {
+ *dest++ = *str;
+ }
+ str++;
+ }
+ *dest = '\0';
+ return ;
+}
+
/**
* @brief 30s request imei
*
@@ -105,6 +125,10 @@
*/
void * timer_request_imei(void * arg)
{
+ FILE *fp1 = NULL;
+ char buf[8] = {0};
+ int ucivalue = 0;
+ int nread = 0;
int sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (-1 == sock_fd)
{
@@ -245,7 +269,21 @@
/*judge the res_error*/
if(!res_error)
{
- system("uci set lynq_uci.sdk_ready='0'");
+ fp1 = popen("uci get lynq_uci.sdk_ready","r");
+ if(fp1 == NULL)
+ {
+ RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+ continue;
+ }
+ memset(buf, 0, sizeof(buf));
+ nread = fread(buf,1,8,fp1);
+ pclose(fp1);
+ ucivalue = atoi(buf);
+
+ if((0 != ucivalue)&&(5 != ucivalue)&&(6 != ucivalue))
+ {
+ system("uci set lynq_uci.sdk_ready='0'");
+ }
}
else
{
@@ -491,12 +529,140 @@
}
return NULL;
}
-
-
+
+static void *delete_partition(void *arg)
+{
+ char buf[64] = {0};
+ char tmp[64] = {0};
+ char ucibuf[8] = {0};
+ FILE *fp = NULL;
+ FILE *fp1 = NULL;
+ char *result1 = NULL;
+ int nread = 0;
+ int nnread = 0;
+ int count1 = 0;
+ int q = 22;
+ int qWarnValue = 10;
+ int ubisize = 0;
+ int uciValue = 0;
+
+ while(1)
+ {
+
+ sleep(300);
+
+ fp = popen("df -lh| grep '/data$' | awk '{print $3}'","r");
+
+ if(fp == NULL)
+ {
+ RLOGD("Failed to run command\n");
+ continue;
+ }
+
+ memset(buf, 0, sizeof(buf));
+ nread = fread(buf,1,64,fp);
+
+ if(nread != 64)
+ {
+ pclose(fp);
+ RLOGD("Read file failed!\n");
+ continue;
+ }
+ if (pclose(fp) == -1)
+ {
+ RLOGD("close fp file failed!\n");
+ continue;
+ }
+
+ removeSpaces(buf);
+
+ result1 = strchr(buf, 'M');
+
+ if(result1 != NULL)
+ {
+ count1 = result1 - buf;
+
+ memset(tmp,0,sizeof(tmp));
+
+ if(strncpy(tmp,buf,count1) == NULL)
+ {
+ RLOGD("copy buf failed!\n");
+ continue;
+ }
+ else
+ {
+ RLOGD("copy buf success!\n");
+ ubisize = atoi(tmp);
+ }
+
+ if((ubisize > qWarnValue)&&(ubisize < q))
+ {
+ fp1 = popen("uci get lynq_uci.sdk_ready","r");
+ if(fp1 == NULL)
+ {
+ RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+ continue;
+ }
+
+ memset(ucibuf, 0, sizeof(ucibuf));
+ nnread = fread(ucibuf,1,8,fp1);
+ pclose(fp1);
+ uciValue = atoi(ucibuf);
+
+ if(0x0 == uciValue)
+ {
+ system("uci set lynq_uci.sdk_ready='5'");
+ RLOGD(">set ready 5,userdata size is %d M\n",ubisize);
+ }
+ else
+ {
+ RLOGD("userdata size is %d M,uciValue is %d\n",ubisize,uciValue);
+ }
+ }
+ else if(ubisize >= q)
+ {
+ fp1 = popen("uci get lynq_uci.sdk_ready","r");
+ if(fp1 == NULL)
+ {
+ RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+ continue;
+ }
+
+ memset(ucibuf, 0, sizeof(ucibuf));
+ nnread = fread(ucibuf,1,8,fp1);
+ pclose(fp1);
+ uciValue = atoi(ucibuf);
+
+ if(0x0 == uciValue)
+ {
+ RLOGD(">set ready 6,userdata size is %d M\n",ubisize);
+ system("uci set lynq_uci.sdk_ready='6'");
+ }
+ else
+ {
+ RLOGD("userdata size is %d M,uciValue is %d\n",ubisize,uciValue);
+ }
+ }
+ else
+ {
+ RLOGD("userdata size is %d M\n",ubisize);
+ }
+
+ }
+ else
+ {
+ RLOGD("userdata partition size is kb!\n");
+ }
+
+
+ }
+
+return (void *)0;
+}
void start_timer_request(void)
{
- pthread_t thid,thid_1,thid_2;
+ pthread_t thid,thid_1,thid_2,thid_3;
pthread_attr_t a;
pthread_attr_init(&a);
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
@@ -504,6 +670,7 @@
char tmp[20];
int debug_mode;
int ret;
+ int ret3;
ret = pthread_create(&thid, &a, timer_request_imei, NULL);
if(ret != 0){
@@ -526,15 +693,23 @@
}
}
-
-
-
+
ret = pthread_create(&thid_2,NULL,check_uci,NULL);
if(ret != 0){
RLOGD("pthread_create error!!!");
return;
}
pthread_detach(thid_2);
+
+ sleep(1);
+
+ ret3 = pthread_create(&thid_3,NULL,delete_partition,NULL);
+ if(ret3 != 0)
+ {
+ RLOGD("pthread_create error!!!");
+ return;
+ }
+
return;
}