本文整理汇总了C++中reboot函数的典型用法代码示例。如果您正苦于以下问题:C++ reboot函数的具体用法?C++ reboot怎么用?C++ reboot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reboot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bootmgr_handle_key
uint8_t bootmgr_handle_key(int key)
{
if(sleep_mode)
{
bootmgr_do_sleep(0);
return 0;
}
switch(bootmgr_phase)
{
case BOOTMGR_MAIN:
{
switch(key)
{
case KEY_VOLUMEDOWN:
{
if(++bootmgr_selected == 4)
bootmgr_selected = 0;
break;
}
case KEY_VOLUMEUP:
{
if(--bootmgr_selected == -1)
bootmgr_selected = 3;
break;
}
case KEY_BACK:
bootmgr_printf(-1, 25, WHITE, "Rebooting...");
bootmgr_draw();
__reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery");
return 1;
case KEY_END:
{
bootmgr_do_sleep(!sleep_mode);
break;
}
case KEY_POWER:
{
reboot(RB_POWER_OFF);
return 1;
}
case KEY_MENU:
{
switch(bootmgr_selected)
{
case 0: bootmgr_boot_internal(); return 1;
case 1:
if(bootmgr_show_rom_list())
return 1;
break;
case 2: bootmgr_touch_ums(); break;
case 3: bootmgr_touch_misc(); break;
}
break;
}
case KEY_SEARCH:
{
bootmgr_charger_init();
break;
}
default: break;
}
break;
}
case BOOTMGR_SD_SEL:
{
switch(key)
{
case KEY_VOLUMEDOWN:
bootmgr_touch_sd_down();
break;
case KEY_VOLUMEUP:
bootmgr_touch_sd_up();
break;
case KEY_MENU:
return bootmgr_boot_sd();
case KEY_BACK:
bootmgr_touch_sd_exit();
break;
default:break;
}
break;
}
case BOOTMGR_TETRIS:
{
tetris_key(key);
break;
}
case BOOTMGR_UMS:
{
if(key != KEY_SEARCH)
break;
bootmgr_touch_exit_ums();
break;
}
case BOOTMGR_CHARGER: return bootmgr_charger_key(key);
case BOOTMGR_MISC: return bootmgr_misc_key(key);
}
return 0;
}
示例2: main
int main(int argc, char *argv[]) {
bool need_umount, need_swapoff, need_loop_detach, need_dm_detach;
bool in_container, use_watchdog = false;
_cleanup_free_ char *cgroup = NULL;
char *arguments[3];
unsigned retries;
int cmd, r;
static const char* const dirs[] = {SYSTEM_SHUTDOWN_PATH, NULL};
log_parse_environment();
r = parse_argv(argc, argv);
if (r < 0)
goto error;
/* journald will die if not gone yet. The log target defaults
* to console, but may have been changed by command line options. */
log_close_console(); /* force reopen of /dev/console */
log_open();
umask(0022);
if (getpid() != 1) {
log_error("Not executed by init (PID 1).");
r = -EPERM;
goto error;
}
if (streq(arg_verb, "reboot"))
cmd = RB_AUTOBOOT;
else if (streq(arg_verb, "poweroff"))
cmd = RB_POWER_OFF;
else if (streq(arg_verb, "halt"))
cmd = RB_HALT_SYSTEM;
else if (streq(arg_verb, "kexec"))
cmd = LINUX_REBOOT_CMD_KEXEC;
else if (streq(arg_verb, "exit"))
cmd = 0; /* ignored, just checking that arg_verb is valid */
else {
r = -EINVAL;
log_error("Unknown action '%s'.", arg_verb);
goto error;
}
cg_get_root_path(&cgroup);
use_watchdog = !!getenv("WATCHDOG_USEC");
/* lock us into memory */
mlockall(MCL_CURRENT|MCL_FUTURE);
log_info("Sending SIGTERM to remaining processes...");
broadcast_signal(SIGTERM, true, true);
log_info("Sending SIGKILL to remaining processes...");
broadcast_signal(SIGKILL, true, false);
in_container = detect_container() > 0;
need_umount = !in_container;
need_swapoff = !in_container;
need_loop_detach = !in_container;
need_dm_detach = !in_container;
/* Unmount all mountpoints, swaps, and loopback devices */
for (retries = 0; retries < FINALIZE_ATTEMPTS; retries++) {
bool changed = false;
if (use_watchdog)
watchdog_ping();
/* Let's trim the cgroup tree on each iteration so
that we leave an empty cgroup tree around, so that
container managers get a nice notify event when we
are down */
if (cgroup)
cg_trim(SYSTEMD_CGROUP_CONTROLLER, cgroup, false);
if (need_umount) {
log_info("Unmounting file systems.");
r = umount_all(&changed);
if (r == 0) {
need_umount = false;
log_info("All filesystems unmounted.");
} else if (r > 0)
log_info("Not all file systems unmounted, %d left.", r);
else
log_error_errno(r, "Failed to unmount file systems: %m");
}
if (need_swapoff) {
log_info("Deactivating swaps.");
r = swapoff_all(&changed);
if (r == 0) {
need_swapoff = false;
log_info("All swaps deactivated.");
} else if (r > 0)
log_info("Not all swaps deactivated, %d left.", r);
else
log_error_errno(r, "Failed to deactivate swaps: %m");
//.........这里部分代码省略.........
示例3: main
int main(void)
{
pid_t pid; /* pid of child process */
int fd; /* generally useful */
int linenr; /* loop variable */
int check; /* check if a new process must be spawned */
int sn; /* signal number */
struct slotent *slotp; /* slots[] pointer */
struct ttyent *ttyp; /* ttytab entry */
struct sigaction sa;
struct stat stb;
#define OPENFDS \
if (fstat(0, &stb) < 0) { \
/* Open standard input, output & error. */ \
(void) open("/dev/null", O_RDONLY); \
(void) open("/dev/log", O_WRONLY); \
dup(1); \
}
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
/* Default: Ignore every signal (except those that follow). */
sa.sa_handler = SIG_IGN;
for (sn = 1; sn < _NSIG; sn++) {
sigaction(sn, &sa, NULL);
}
/* Hangup: Reexamine /etc/ttytab for newly enabled terminal lines. */
sa.sa_handler = onhup;
sigaction(SIGHUP, &sa, NULL);
/* Terminate: Stop spawning login processes, shutdown is near. */
sa.sa_handler = onterm;
sigaction(SIGTERM, &sa, NULL);
/* Abort: Sent by the kernel on CTRL-ALT-DEL; shut the system down. */
sa.sa_handler = onabrt;
sigaction(SIGABRT, &sa, NULL);
/* Execute the /etc/rc file. */
if ((pid = fork()) != 0) {
/* Parent just waits. */
while (wait(NULL) != pid) {
if (gotabrt) reboot(RBT_HALT);
}
} else {
#if ! SYS_GETKENV
struct sysgetenv sysgetenv;
#endif
char bootopts[16];
static char *rc_command[] = { "sh", "/etc/rc", NULL, NULL, NULL };
char **rcp = rc_command + 2;
/* Get the boot options from the boot environment. */
sysgetenv.key = "bootopts";
sysgetenv.keylen = 8+1;
sysgetenv.val = bootopts;
sysgetenv.vallen = sizeof(bootopts);
if (svrctl(PMGETPARAM, &sysgetenv) == 0) *rcp++ = bootopts;
*rcp = "start";
execute(rc_command);
report(2, "sh /etc/rc");
_exit(1); /* impossible, we hope */
}
OPENFDS;
/* Clear /etc/utmp if it exists. */
if ((fd = open(PATH_UTMP, O_WRONLY | O_TRUNC)) >= 0) close(fd);
/* Log system reboot. */
wtmp(BOOT_TIME, 0, NULL, 0);
/* Main loop. If login processes have already been started up, wait for one
* to terminate, or for a HUP signal to arrive. Start up new login processes
* for all ttys which don't have them. Note that wait() also returns when
* somebody's orphan dies, in which case ignore it. If the TERM signal is
* sent then stop spawning processes, shutdown time is near.
*/
check = 1;
while (1) {
while ((pid = waitpid(-1, NULL, check ? WNOHANG : 0)) > 0) {
/* Search to see which line terminated. */
for (linenr = 0; linenr < PIDSLOTS; linenr++) {
slotp = &slots[linenr];
if (slotp->pid == pid) {
/* Record process exiting. */
wtmp(DEAD_PROCESS, linenr, NULL, pid);
slotp->pid = NO_PID;
check = 1;
}
}
}
/* If a signal 1 (SIGHUP) is received, simply reset error counts. */
if (gothup) {
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
}
printf("Recovery svn version:%d, Compile Time: %s %s\n",
SVN_VERSION,__DATE__, __TIME__);
sprintf(version_buf, "Recovery svn version:%d, Compile Time: %s %s",
SVN_VERSION,__TIME__, __DATE__);
int fd = 0;
fd = open("/dev/recovery",O_RDWR | O_CREAT | O_TRUNC);
if(fd < 0) {
printf("open recovery devices error\n");
return EXIT_SUCCESS;
}
int recovery_mode = 0;
ioctl(fd, RECOVERY_GET_VAL, &recovery_mode);
// recovery_mode = UPDATE_SYSTEM;
/* test_functions() */
//remove_logo_config_file();
if(recovery_mode == CLEAN_MODE) {
ui_set_cleanboot_background();
ui_set_cleanboot_system();
clean_boot();
while(system_cleanboot_end == 0) {
//printf("waiting thread is end");
usleep(50000);
}
sync();
ui_set_cleanboot_succ();
sleep(3);
close_backlight();
reboot(RB_AUTOBOOT);
printf("reboot end, it should never been output\n");
} else if (recovery_mode == UPDATE_RECOVERY){
ui_set_prepare_background();
sleep(1);
burning_recovery_image();
} else if (recovery_mode == UPDATE_SYSTEM || recovery_mode == BACKUP_MODE){
ui_set_burning_background(BURNING_MISC_UPDATING);
sleep(1);
overridekey_status = update_overridekey();
tractor_prop_status = update_tractorprop();
radio_status = update_radioCFG();
mpeg_status = mpeg_update();
update_status &= ~(0x03 << 2);
update_status |= mpeg_status << 2;
ui_set_burning_reflesh(update_status);
sleep(1);
printf("mcu_start\n");
mcu_status = mcu_update();
update_status &= ~(0x03 << 4);
update_status |= (mcu_status << 4);
ui_set_burning_reflesh(update_status);
sleep(1);
if(status == INSTALL_ERROR){
printf("++check auto Burning update.zip in data tractor...\n");
status = device_burn_data_if_exist();
if(status == INSTALL_SUCCESS) {
//burning_recovery_image();
}
ui_set_burning_status();
printf("--check auto Burning update.zip in data tractor: %d\n", status);
update_status &= ~(0x03);
update_status |= status;
示例5: main
int
main()
{
reboot(RB_POWEROFF);
return 0;
}
示例6: process_ctx_menu
/* Process menu context
* Return 0 to select, <0 to raise error, >0 to continue
*/
int process_ctx_menu(struct params_t *params, int action) {
static int rc;
static int menu_action;
static kx_menu *menu;
menu = params->menu;
#ifdef USE_NUMKEYS
/* Some hacks to allow menu items selection by keys 0-9 */
if ((action >= A_KEY0) && (action <= A_KEY9)) {
rc = action - A_KEY0;
if (-1 == menu_item_select_by_no(menu, rc)) {
/* There is no item with such number - do nothing */
return 1;
} else {
action = A_SELECT;
}
}
#endif
menu_action = (A_SELECT == action ? menu->current->current->id : action);
rc = 1;
switch (menu_action) {
case A_UP:
menu_item_select(menu, -1);
break;
case A_DOWN:
menu_item_select(menu, 1);
break;
case A_SUBMENU:
menu->current = menu->current->current->submenu;
break;
case A_PARENTMENU:
menu->current = menu->current->parent;
break;
case A_REBOOT:
#ifdef USE_FBMENU
gui_show_msg(params->gui, "Rebooting...");
#endif
#ifdef USE_TEXTUI
tui_show_msg(params->tui, "Rebooting...");
#endif
#ifdef USE_HOST_DEBUG
sleep(1);
#else
sync();
/* if ( -1 == reboot(LINUX_REBOOT_CMD_RESTART) ) { */
if ( -1 == reboot(RB_AUTOBOOT) ) {
log_msg(lg, "Can't initiate reboot: %s", ERRMSG);
}
#endif
break;
case A_SHUTDOWN:
#ifdef USE_FBMENU
gui_show_msg(params->gui, "Shutting down...");
#endif
#ifdef USE_TEXTUI
tui_show_msg(params->tui, "Shutting down...");
#endif
#ifdef USE_HOST_DEBUG
sleep(1);
#else
sync();
/* if ( -1 == reboot(LINUX_REBOOT_CMD_POWER_OFF) ) { */
if ( -1 == reboot(RB_POWER_OFF) ) {
log_msg(lg, "Can't initiate shutdown: %s", ERRMSG);
}
#endif
break;
case A_RESCAN:
#ifdef USE_FBMENU
gui_show_msg(params->gui, "Rescanning devices.\nPlease wait...");
#endif
#ifdef USE_TEXTUI
tui_show_msg(params->tui, "Rescanning devices.\nPlease wait...");
#endif
if (-1 == do_rescan(params)) {
log_msg(lg, "Rescan failed");
return -1;
}
menu = params->menu;
break;
case A_DEBUG:
params->context = KX_CTX_TEXTVIEW;
break;
case A_EXIT:
if (initmode) break; // don't exit if we are init
case A_ERROR:
rc = -1;
break;
#ifdef USE_TIMEOUT
case A_TIMEOUT: // timeout was reached - boot 1st kernel if exists
//.........这里部分代码省略.........
示例7: bus_inb
//.........这里部分代码省略.........
lock_state ^= KB_CAPS;
/*async_update();*/
break;
case KB_SCROLL:
if (shift_state & KB_SCROLL)
break;
shift_state |= KB_SCROLL;
lock_state ^= KB_SCROLL;
/*async_update();*/
break;
/* Special no locking keys */
case KB_SHIFT:
shift_state |= KB_SHIFT;
break;
case KB_ALT:
if (extended)
shift_state |= KB_ALTGR;
else
shift_state |= KB_ALT;
break;
case KB_CTL:
shift_state |= KB_CTL;
break;
/* Regular ASCII */
case KB_ASCII:
/* Control is pressed */
if (shift_state & KB_CTL)
capchar[0] = scan_codes[dt].ctl[0];
/* Right alt and right alt with shift */
else if (shift_state & KB_ALTGR) {
if (shift_state & KB_SHIFT)
capchar[0] = scan_codes[dt].shift_altgr[0];
else
capchar[0] = scan_codes[dt].altgr[0];
/* Shift */
} else {
if (shift_state & KB_SHIFT)
capchar[0] = scan_codes[dt].shift[0];
/* Only key without special keys */
else
capchar[0] = scan_codes[dt].unshift[0];
}
/* If CAPS is active capitalize letters */
if ((lock_state & KB_CAPS) && capchar[0] >= 'a' && capchar[0] <= 'z') {
capchar[0] -= ('a' - 'A');
}
/* Left ALT */
capchar[0] |= (shift_state & KB_ALT);
extended = 0;
return capchar;
/* Key without meaning */
case KB_NONE:
break;
/* Function key */
case KB_FUNC: {
char *more_chars;
if (shift_state & KB_SHIFT)
more_chars = scan_codes[dt].shift;
else if (shift_state & KB_CTL)
more_chars = scan_codes[dt].ctl;
else
more_chars = scan_codes[dt].unshift;
extended = 0;
return more_chars;
}
/* Keypad */
case KB_KP: {
char *more_chars;
/* Reboot sequence */
if ((shift_state & KB_ALT) && (shift_state & KB_CTL) && (dt == 83)) {
std_printf("Rebooting ...\n");
reboot();
return capchar;
}
if (shift_state & (KB_SHIFT | KB_CTL) || (lock_state & KB_NUM) == 0 || extended)
more_chars = scan_codes[dt].shift;
else
more_chars = scan_codes[dt].unshift;
extended = 0;
return more_chars;
}
}
}
extended = 0;
return capchar;
}
示例8: remount_ro
/* Remounting filesystems read-only is difficult when there are files
* opened for writing or pending deletes on the filesystem. There is
* no way to force the remount with the mount(2) syscall. The magic sysrq
* 'u' command does an emergency remount read-only on all writable filesystems
* that have a block device (i.e. not tmpfs filesystems) by calling
* emergency_remount(), which knows how to force the remount to read-only.
* Unfortunately, that is asynchronous, and just schedules the work and
* returns. The best way to determine if it is done is to read /proc/mounts
* repeatedly until there are no more writable filesystems mounted on
* block devices.
*/
static void remount_ro(void)
{
int fd, cnt = 0;
/* Trigger the remount of the filesystems as read-only,
* which also marks them clean.
*/
fd = open("/proc/sysrq-trigger", O_WRONLY);
if (fd < 0) {
return;
}
write(fd, "u", 1);
close(fd);
/* Now poll /proc/mounts till it's done */
#ifdef STE_HARDWARE
while (!remount_ro_done() && (cnt < 50)) {
#else
while (!remount_ro_done() && (cnt < 3600)) {
#endif
usleep(100000);
cnt++;
}
return;
}
int android_reboot(int cmd, int flags, char *arg)
{
int ret = 0;
int reason = -1;
#ifdef RECOVERY_PRE_COMMAND
if (cmd == (int) ANDROID_RB_RESTART2) {
if (arg && strlen(arg) > 0) {
char cmd[PATH_MAX];
sprintf(cmd, RECOVERY_PRE_COMMAND " %s", arg);
system(cmd);
}
}
#endif
sync();
remount_ro();
switch (cmd) {
case ANDROID_RB_RESTART:
reason = RB_AUTOBOOT;
break;
case ANDROID_RB_POWEROFF:
ret = reboot(RB_POWER_OFF);
return ret;
case ANDROID_RB_RESTART2:
// REBOOT_MAGIC
break;
default:
return -1;
}
#ifdef RECOVERY_PRE_COMMAND_CLEAR_REASON
reason = RB_AUTOBOOT;
#endif
if (reason != -1)
ret = reboot(reason);
else
ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_RESTART2, arg);
return ret;
}
示例9: bootloader
void bootloader(void)
{
BKPInit();
BKPWrite(STAY_IN_BOOTLOADER_MAGIC);
reboot();
}
示例10: main
int main(int argc, char *argv[]) {
int do_sync = 1;
int do_force = 0;
int opt;
action_type action = NOOP;
if (strcmp(__progname, "halt") == 0)
action = HALT;
else if (strcmp(__progname, "reboot") == 0)
action = REBOOT;
else if (strcmp(__progname, "poweroff") == 0)
action = POWEROFF;
else
warnx("no default behavior, needs to be called as halt/reboot/poweroff.");
while ((opt = getopt(argc, argv, "dfhinw")) != -1)
switch (opt) {
case 'n':
do_sync = 0;
break;
case 'w':
action = NOOP;
do_sync = 0;
break;
case 'd':
case 'h':
case 'i':
/* silently ignored. */
break;
case 'f':
do_force = 1;
break;
default:
errx(1, "Usage: %s [-n] [-f]", __progname);
}
if (do_sync)
sync();
switch (action) {
case HALT:
if (do_force)
reboot(RB_HALT_SYSTEM);
else
execl("/usr/bin/runit-init", "init", "0", (char*)0);
err(1, "halt failed");
break;
case POWEROFF:
if (do_force)
reboot(RB_POWER_OFF);
else
execl("/usr/bin/runit-init", "init", "0", (char*)0);
err(1, "poweroff failed");
break;
case REBOOT:
if (do_force)
reboot(RB_AUTOBOOT);
else
execl("/usr/bin/runit-init", "init", "6", (char*)0);
err(1, "reboot failed");
break;
case NOOP:
break;
}
return 0;
}
示例11: switch
//.........这里部分代码省略.........
AutoLock lock( &m_Lock );
for(int i=0;i<m_ProcessList.size();i++)
m_ProcessList[i].flags &= ~ProcessClient::PF_DISABLED;
saveProcessList();
jobDone = true;
LOG_STATUS( "ProcessServer", CharString().format("Start All, client = %u (%s)", client, clientAddress(client)) );
send( client, ProcessClient::CLIENT_JOB_DONE ) << job << jobDone;
}
break;
case ProcessClient::SERVER_RESTART_ALL:
if ( validateClient( client ) )
{
dword job;
input >> job;
bool jobDone = false;
AutoLock lock( &m_Lock );
for(int i=0;i<m_ProcessList.size();i++)
stopProcess( m_ProcessList[i].processId );
jobDone = true;
LOG_STATUS( "ProcessServer", CharString().format("Restart All, client = %u (%s)", client, clientAddress(client)) );
send( client, ProcessClient::CLIENT_JOB_DONE ) << job << jobDone;
}
break;
case ProcessClient::SERVER_REBOOT:
if ( validateClient( client ) )
{
dword job;
input >> job;
bool jobDone = reboot();
if ( jobDone )
LOG_STATUS( "ProcessServer", CharString().format("Server Rebooting, client = %u (%s)", client, clientAddress(client)) );
send( client, ProcessClient::CLIENT_JOB_DONE ) << job << jobDone;
}
break;
case ProcessClient::SERVER_EXIT:
if ( validateClient( client ) )
{
dword job;
input >> job;
// signal all running processes to stop
bool jobDone = shutdown();
if ( jobDone )
LOG_STATUS( "ProcessServer", CharString().format("Server Exiting, client = %u (%s)", client, clientAddress(client)) );
send( client, ProcessClient::CLIENT_JOB_DONE ) << job << jobDone;
}
break;
case ProcessClient::SERVER_TERMINATE_PROCESS:
if ( validateClient( client ) )
{
dword job;
input >> job;
dword processId;
input >> processId;
bool jobDone = false;
AutoLock lock( &m_Lock );
示例12: reboot
void RawControl::checkCan()
{
if(arm->GetP()!=ARM_P)
reboot(0x04);
}
示例13: conswrite
static long
conswrite(Chan *c, void *va, long n, vlong off)
{
char buf[256];
long l, bp;
char *a;
Mach *mp;
int id, fd;
Chan *swc;
ulong offset;
Cmdbuf *cb;
Cmdtab *ct;
a = va;
offset = off;
switch((ulong)c->qid.path){
case Qcons:
/*
* Can't page fault in putstrn, so copy the data locally.
*/
l = n;
while(l > 0){
bp = l;
if(bp > sizeof buf)
bp = sizeof buf;
memmove(buf, a, bp);
putstrn0(buf, bp, 1);
a += bp;
l -= bp;
}
break;
case Qconsctl:
error(Egreg);
case Qtime:
if(!iseve())
error(Eperm);
return writetime(a, n);
case Qbintime:
if(!iseve())
error(Eperm);
return writebintime(a, n);
case Qhostowner:
return hostownerwrite(a, n);
case Qhostdomain:
return hostdomainwrite(a, n);
case Quser:
return userwrite(a, n);
case Qnull:
break;
case Qconfig:
error(Eperm);
break;
case Qreboot:
if(!iseve())
error(Eperm);
cb = parsecmd(a, n);
if(waserror()) {
free(cb);
nexterror();
}
ct = lookupcmd(cb, rebootmsg, nelem(rebootmsg));
switch(ct->index) {
case CMhalt:
reboot(nil, 0, 0);
break;
case CMreboot:
rebootcmd(cb->nf-1, cb->f+1);
break;
case CMpanic:
*(ulong*)0=0;
panic("/dev/reboot");
case CMrdb:
if(consdebug == nil)
consdebug = rdb;
consdebug();
break;
}
poperror();
free(cb);
break;
case Qsysstat:
for(id = 0; id < 32; id++) {
if(active.machs & (1<<id)) {
mp = MACHP(id);
mp->cs = 0;
mp->intr = 0;
mp->syscall = 0;
mp->pfault = 0;
//.........这里部分代码省略.........
示例14: main
int
main(int argc, char **argv)
{
time_t start = time(NULL);
// If these fail, there's not really anywhere to complain...
freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL);
freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL);
fprintf(stderr, "Starting recovery on %s", ctime(&start));
ui_init();
ui_print("Android system recovery utility\n");
get_args(&argc, &argv);
int previous_runs = 0;
const char *send_intent = NULL;
const char *update_package = NULL;
int wipe_data = 0, wipe_cache = 0;
int arg;
while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) {
switch (arg) {
case 'p': previous_runs = atoi(optarg); break;
case 's': send_intent = optarg; break;
case 'u': update_package = optarg; break;
case 'w': wipe_data = wipe_cache = 1; break;
case 'c': wipe_cache = 1; break;
case '?':
LOGE("Invalid command argument\n");
continue;
}
}
fprintf(stderr, "Command:");
for (arg = 0; arg < argc; arg++) {
fprintf(stderr, " \"%s\"", argv[arg]);
}
fprintf(stderr, "\n\n");
property_list(print_property, NULL);
fprintf(stderr, "\n");
#if TEST_AMEND
test_amend();
#endif
RecoveryCommandContext ctx = { NULL };
if (register_update_commands(&ctx)) {
LOGE("Can't install update commands\n");
}
int status = INSTALL_SUCCESS;
if (update_package != NULL) {
status = install_package(update_package);
if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n");
} else if (wipe_data || wipe_cache) {
if (wipe_data && erase_root("DATA:")) status = INSTALL_ERROR;
if (wipe_cache && erase_root("CACHE:")) status = INSTALL_ERROR;
if (status != INSTALL_SUCCESS) ui_print("Data wipe failed.\n");
} else {
status = INSTALL_ERROR; // No command specified
}
if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR);
if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait();
// If there is a radio image pending, reboot now to install it.
maybe_install_firmware_update(send_intent);
// Otherwise, get ready to boot the main system...
finish_recovery(send_intent);
ui_print("Rebooting...\n");
sync();
reboot(RB_AUTOBOOT);
return EXIT_SUCCESS;
}
示例15: reboot
/*
result = reboot(["filename"])
returns false on failure, does not return on success
see lib/armutil/reboot.c for details
*/
static int luaCB_reboot( lua_State* L )
{
lua_pushboolean(L, reboot(luaL_optstring( L, 1, NULL )));
return 1;
}