1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #include <libconfig.h>
33 #include <sys/types.h>
34 #include <sys/reboot.h>
36 #include <vconf/vconf-keys.h>
37 #include <asm-generic/setup.h> // for COMMAND_LINE_SIZE
39 #include "system-recovery.h"
41 void sys_power_reboot(void)
46 #define KERNEL_CMDLINE_KEY "tizen.recovery"
48 // looks for tizen.recovery= key in kernel command line
49 char *get_action_from_cmdline(void)
52 char cmdline[COMMAND_LINE_SIZE];
55 fp = fopen("/proc/cmdline", "r");
59 char *p = fgets(cmdline, sizeof cmdline, fp);
64 const char *prefix = KERNEL_CMDLINE_KEY "=";
65 p = strstr(cmdline, prefix);
70 for (len = 0; *(p + len) != 0 && !isspace(*(p + len)); ++len)
73 return strndup(p, len);
82 LOGD("[main] recovery started.\n");
85 ret = config_read_file(&cfg, SYSTEM_RECOVERY_CONFIG_FILE);
86 if (ret == CONFIG_FALSE) {
87 LOGD("Can't read config file");
92 ret = recovery_gui(&cfg);
94 ret = recovery_headless(&cfg);
97 LOGD("[main] recovery finished.\n");