• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef SANITIZERD_ZIPHELPER_H
17 #define SANITIZERD_ZIPHELPER_H
18 #include <algorithm>
19 #include <string>
20 #include <vector>
21 
22 #include "reporter.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 constexpr unsigned SL_BUF_LEN = 512;
27 constexpr unsigned GZ_BUF_SIZE = 4096;
28 constexpr char GZ_SUFFIX[] = ".gz";
29 constexpr unsigned BUF_SIZE = 1024;
30 constexpr unsigned MAX_PROCESS_PATH = 1024;
31 constexpr unsigned HASH_FACTOR = 16127;
32 constexpr unsigned MILLISEC_OF_PER_SEC = 1000;
33 constexpr unsigned MICROSEC_OF_PER_MILLISEC = 1000;
34 constexpr int MIN_APP_USERID = 10000;
35 constexpr uint32_t MAX_NAME_LENGTH = 4096;
36 constexpr int AID_ROOT   = 0;
37 constexpr int AID_SYSTEM = 1000;
38 constexpr mode_t DEFAULT_LOG_FILE_MODE = 0666;
39 constexpr mode_t DEFAULT_LOG_DIR_MODE = 0775;
40 constexpr char CUSTOM_SANITIZER_LOG_PATH[] = "/data/log/faultlog/faultlogger/";
41 constexpr char ROOT_FAULTLOG_LOG_PATH[] = "/data/log/faultlog/";
42 const std::string DEVICE_OHOS_VERSION_PARAM = "hw_sc.build.os.version";
43 const std::string EMPTY_PARAM = "";
44 
45 bool IsLinkFile(const std::string& filename);
46 bool GetRealPath(const std::string& fn, std::string& out);
47 bool ReadNormalFileToString(const std::string& path, std::string& content);
48 bool ReadFileToString(const std::string& path, std::string& out);
49 std::vector<std::string> SplitString(const std::string& input, const std::string& regex);
50 unsigned HashString(const std::string& input);
51 bool GetNameByPid(pid_t pid, const char procName[]);
52 bool IsModuleNameValid(const std::string& name);
53 bool GetNameByPid(pid_t pid, const char *procName);
54 std::string RegulateModuleNameIfNeed(const std::string& name);
55 std::string GetApplicationNameById(int32_t uid);
56 std::string GetApplicationVersion(int32_t uid, const std::string& bundleName);
57 void WriteCollectedData(T_SANITIZERD_PARAMS *params);
58 } // namespace HiviewDFX
59 } // namespace OHOS
60 
61 #endif // SANITIZERD_ZIPHELPER_H
62 
63