• 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 #include <cstdio>
17 #include <string>
18 #include <unistd.h>
19 #include <vector>
20 #include "fs_manager/mount.h"
21 #include "log.h"
22 #include "updater/updater_const.h"
23 #include "update_processor.h"
24 #include "utils.h"
25 
26 using namespace Updater;
27 #ifndef UPDATER_UT
main(int argc,char ** argv)28 int main(int argc, char **argv)
29 {
30     if (Utils::IsUpdaterMode()) {
31         InitUpdaterLogger("UPDATER_BINARY", TMP_LOG, TMP_STAGE_LOG, TMP_ERROR_CODE_PATH);
32     } else {
33         InitUpdaterLogger("UPDATER_BINARY", UPDATER_LOG, UPDATER_STAGE_LOG, ERROR_CODE_PATH);
34     }
35     if (argc < MINIMAL_ARGC_LIMIT) {
36         LOG(ERROR) << "Invalid arguments.";
37         return EXIT_INVALID_ARGS;
38     }
39     bool retry = false;
40     int pipeFd = static_cast<int>(std::strtol(argv[1], nullptr, DECIMAL));
41     if (argc >= BINARY_MAX_ARGS && strcmp(argv[BINARY_SECOND_ARG], "retry") == 0) {
42         retry = true;
43     }
44     // Re-load fstab to child process.
45     LoadFstab();
46     std::string packagePath = argv[0];
47     return ProcessUpdater(retry, pipeFd, packagePath, Utils::GetCertName());
48 }
49 #endif
50