• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /* This file contains ohos config */
17 
18 #include "libunwind_i.h"
19 
20 #define CONF_LINE_SIZE 1024
21 #define NUMBER_SIXTEEN 16
22 
config_unwi_debug_level(void)23 int config_unwi_debug_level(void)
24 {
25   int ret = 0;
26   do {
27     FILE *fp = NULL;
28     fp = fopen("/system/etc/faultlogger.conf", "r");
29     if (fp == NULL) {
30       break;
31     }
32 
33     while (!feof(fp)) {
34       char line[CONF_LINE_SIZE] = {0};
35       if (fgets(line, CONF_LINE_SIZE - 1, fp) == NULL) {
36         continue;
37       }
38 
39       if (!strncmp("faultlogLogPersist=true", line, strlen("faultlogLogPersist=true"))) {
40         ret = NUMBER_SIXTEEN;
41       } else if (!strncmp("faultlogLogPersist=false", line, strlen("faultlogLogPersist=false"))) {
42         ret = 0;
43       }
44     }
45     fclose(fp);
46   } while (0);
47   return ret;
48 }
49