• 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     InitUpdaterLogger("UPDATER_BINARY", TMP_LOG, TMP_STAGE_LOG, TMP_ERROR_CODE_PATH);
31     if (argc < MINIMAL_ARGC_LIMIT) {
32         LOG(ERROR) << "Invalid arguments.";
33         return EXIT_INVALID_ARGS;
34     }
35     bool retry = false;
36     int pipeFd = static_cast<int>(std::strtol(argv[1], nullptr, DECIMAL));
37     if (argc >= BINARY_MAX_ARGS && strcmp(argv[BINARY_SECOND_ARG], "retry") == 0) {
38         retry = true;
39     }
40     // Re-load fstab to child process.
41     LoadFstab();
42     std::string packagePath = argv[0];
43     return ProcessUpdater(retry, pipeFd, packagePath, utils::GetCertName());
44 }
45 #endif
46