• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_bootloader_message函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中set_bootloader_message函数的典型用法代码示例。如果您正苦于以下问题:C++ set_bootloader_message函数的具体用法?C++ set_bootloader_message怎么用?C++ set_bootloader_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_bootloader_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: maybe_install_firmware_update

int maybe_install_firmware_update(const char *send_intent) {
    if (update_data == NULL || update_length == 0) return 0;

    /* We destroy the cache partition to pass the update image to the
     * bootloader, so all we can really do afterwards is wipe cache and reboot.
     * Set up this instruction now, in case we're interrupted while writing.
     */

    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n--wipe_cache\n", sizeof(boot.command));
    if (send_intent != NULL) {
        strlcat(boot.recovery, "--send_intent=", sizeof(boot.recovery));
        strlcat(boot.recovery, send_intent, sizeof(boot.recovery));
        strlcat(boot.recovery, "\n", sizeof(boot.recovery));
    }
    if (set_bootloader_message(&boot)) return -1;

    int width = 0, height = 0, bpp = 0;
    char *busy_image = ui_copy_image(
        BACKGROUND_ICON_FIRMWARE_INSTALLING, &width, &height, &bpp);
    char *fail_image = ui_copy_image(
        BACKGROUND_ICON_FIRMWARE_ERROR, &width, &height, &bpp);

    ui_print("Writing %s image...\n", update_type);
    if (write_update_for_bootloader(
            update_data, update_length,
            width, height, bpp, busy_image, fail_image)) {
        LOGE("Can't write %s image\n(%s)\n", update_type, strerror(errno));
        format_volume("/cache");  // Attempt to clean cache up, at least.
        return -1;
    }

    free(busy_image);
    free(fail_image);

    /* The update image is fully written, so now we can instruct the bootloader
     * to install it.  (After doing so, it will come back here, and we will
     * wipe the cache and reboot into the system.)
     */
    snprintf(boot.command, sizeof(boot.command), "update-%s", update_type);
    if (set_bootloader_message(&boot)) {
        format_volume("/cache");
        return -1;
    }

    reboot(RB_AUTOBOOT);

    // Can't reboot?  WTF?
    LOGE("Can't reboot\n");
    return -1;
}
开发者ID:HyperToxic,项目名称:CWM_REC_6.0.3.2_CHN,代码行数:53,代码来源:firmware.c


示例2: LOGINFO

void TWFunc::Update_Log_File(void) {
	// Copy logs to cache so the system can find out what happened.
	if (PartitionManager.Mount_By_Path("/cache", false)) {
		if (!TWFunc::Path_Exists("/cache/recovery/.")) {
			LOGINFO("Recreating /cache/recovery folder.\n");
			if (mkdir("/cache/recovery", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0)
				LOGINFO("Unable to create /cache/recovery folder.\n");
		}
		Copy_Log(TMP_LOG_FILE, "/cache/recovery/log");
		copy_file("/cache/recovery/log", "/cache/recovery/last_log", 600);
		chown("/cache/recovery/log", 1000, 1000);
		chmod("/cache/recovery/log", 0600);
		chmod("/cache/recovery/last_log", 0640);
	} else {
		LOGINFO("Failed to mount /cache for TWFunc::Update_Log_File\n");
	}

	// Reset bootloader message
	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
	if (Part != NULL) {
		struct bootloader_message boot;
		memset(&boot, 0, sizeof(boot));
		if (set_bootloader_message(&boot) != 0)
			LOGERR("Unable to set bootloader message.\n");
	}

	if (PartitionManager.Mount_By_Path("/cache", true)) {
		if (unlink("/cache/recovery/command") && errno != ENOENT) {
			LOGINFO("Can't unlink %s\n", "/cache/recovery/command");
		}
	}

	sync();
}
开发者ID:marignygrisgris,项目名称:TWRP-Homebuild,代码行数:34,代码来源:twrp-functions.cpp


示例3: wipe_item_show

STATUS wipe_item_show(menuUnit *p)
{
/* OPPO 2013-01-17 jizhengkang azx Add begin for reason */
	struct bootloader_message boot;
/* OPPO 2013-01-17 jizhengkang Add end */
    int wipe_result;
    
    oppo_debug("start .....\n");
    if (RET_YES == oppo_confirm(3, p->name, p->desc, p->icon)) {
		wipe_result = oppo_wipe_items(p->result);
/* OPPO 2013-01-17 jizhengkang azx Add begin for reason */
		if (!(wipe_result%2)) {
			memset(&boot, 0, sizeof(boot));
			set_bootloader_message(&boot);
			strncpy(p->title_name, "<~wipe.result.success.title>", MENU_LEN);
		} else {
			strncpy(p->title_name, "<~wipe.result.failed.title>", MENU_LEN);
		}
/* OPPO 2013-01-17 jizhengkang Add end */
		wipe_result_confirm(p, wipe_result);
		wipe_item_show_end = 1;
		selectedCount--;
    }
/* OPPO 2013-02-18 jizhengkang azx Add begin for reason */
	selectedCount--;
/* OPPO 2013-02-18 jizhengkang azx Add end */
    oppo_debug("end...\n");
    return MENU_BACK;

}
开发者ID:Jiangyi,项目名称:12055,代码行数:30,代码来源:wipe_ui.c


示例4: mt_set_bootloader_message

/* Write bootloader paramenter block */
int mt_set_bootloader_message(const char *command, const char *status, const char *stage,
    const char *fmt, ...)
{
    int ret;
    int i;
    struct bootloader_message boot;
    va_list vl;

    memset(&boot, 0, sizeof(boot));

    if (command)
        strlcpy(boot.command, command, sizeof(boot.command));
    if (status)
        strlcpy(boot.status, status, sizeof(boot.status));
    if (stage)
        strlcpy(boot.stage, stage, sizeof(boot.stage));
    if (fmt)    {
        va_start(vl, fmt);
        ret = vsprintf(boot.recovery, fmt, vl);
        va_end(vl);
    }

    ret = set_bootloader_message(&boot);
    sync();

    return ret;
}
开发者ID:bju2000,项目名称:MT6797,代码行数:28,代码来源:mt_bootloader.cpp


示例5: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Copy logs to cache so the system can find out what happened.
    copy_log_file(LOG_FILE, true);
    copy_log_file(LAST_LOG_FILE, false);
    chmod(LAST_LOG_FILE, 0640);

    // Reset to normal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);

    // Remove the command file, so recovery won't repeat indefinitely.
    if (ensure_path_mounted(COMMAND_FILE) != 0 ||
        (unlink(COMMAND_FILE) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    sync();  // For good measure.
}
开发者ID:xiangxin19960319,项目名称:android_bootable_recovery_cn_ics,代码行数:35,代码来源:recovery.c


示例6: reset_mark_block

static void reset_mark_block(void)
{
    // Reset the bootloader message to revert to a normal main system boot.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);
    sync();
}
开发者ID:Besik13,项目名称:iq450_H2_mt6589,代码行数:8,代码来源:install.cpp


示例7: set_sdcard_update_bootloader_message

static void
set_sdcard_update_bootloader_message() {
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    set_bootloader_message(&boot);
}
开发者ID:JCROM-Android,项目名称:jcrom_bootable_recovery_,代码行数:8,代码来源:recovery.cpp


示例8: install_firmware_update

int install_firmware_update(const char *update_type,
                            const char *update_data,
                            size_t update_length,
                            int width, int height, int bpp,
                            const char* busy_image,
                            const char* fail_image,
                            const char *log_filename) {
    if (update_data == NULL || update_length == 0) return 0;

    mtd_scan_partitions();

    /* We destroy the cache partition to pass the update image to the
     * bootloader, so all we can really do afterwards is wipe cache and reboot.
     * Set up this instruction now, in case we're interrupted while writing.
     */

    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n--wipe_cache\n", sizeof(boot.command));
    if (set_bootloader_message(&boot)) return -1;

    if (write_update_for_bootloader(
            update_data, update_length,
            width, height, bpp, busy_image, fail_image, log_filename)) {
        LOGE("Can't write %s image\n(%s)\n", update_type, strerror(errno));
        return -1;
    }

    /* The update image is fully written, so now we can instruct the bootloader
     * to install it.  (After doing so, it will come back here, and we will
     * wipe the cache and reboot into the system.)
     */
    snprintf(boot.command, sizeof(boot.command), "update-%s", update_type);
    if (set_bootloader_message(&boot)) {
        return -1;
    }

    reboot(RB_AUTOBOOT);

    // Can't reboot?  WTF?
    LOGE("Can't reboot\n");
    return -1;
}
开发者ID:longlinht,项目名称:android_source,代码行数:44,代码来源:firmware.c


示例9: get_args

static void
get_args(int *argc, char ***argv) 
{
  struct bootloader_message boot;
  memset(&boot, 0, sizeof(boot));
  get_bootloader_message(&boot);  // this may fail, leaving a zeroed structure

  if (boot.command[0] != 0 && boot.command[0] != 255) 
    LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
  

  if (boot.status[0] != 0 && boot.status[0] != 255) 
    LOGI("Boot status: %.*s\n", sizeof(boot.status), boot.status);
  

  // --- if arguments weren't supplied, look in the bootloader control block
  if (*argc <= 1) 
  {
    boot.recovery[sizeof(boot.recovery) - 1] = '\0';  // Ensure termination
    const char *arg = strtok(boot.recovery, "\n");
    if (arg != NULL && !strcmp(arg, "recovery")) 
    {
      *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
      (*argv)[0] = strdup(arg);
      for (*argc = 1; *argc < MAX_ARGS; ++*argc) 
      {
        if ((arg = strtok(NULL, "\n")) == NULL) 
        	break;
        (*argv)[*argc] = strdup(arg);
      }
      LOGI("Got arguments from boot message\n");
    } 
    else if (boot.recovery[0] != 0 && boot.recovery[0] != 255) 
      LOGE("Bad boot message\n\"%.20s\"\n", boot.recovery);
    
  }

  // --- if that doesn't work, try the command file
  if (*argc <= 1) 
 		get_cmd_file_args(argc, argv);

  // --> write the arguments we have back into the bootloader control block
  // always boot into recovery after this (until finish_recovery() is called)
  strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
  strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
  int i;
  for (i = 1; i < *argc; ++i) 
  {
		strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
		strlcat(boot.recovery, "\n", sizeof(boot.recovery));
  }
  set_bootloader_message(&boot);
}
开发者ID:Mioze7Ae,项目名称:openrecovery,代码行数:53,代码来源:recovery.c


示例10: reset_deltaupdate_recovery_bootmessage

static void reset_deltaupdate_recovery_bootmessage(void)
{
    struct bootloader_message boot;

    memset(&boot, 0, sizeof(boot));

    LOGI("Resetting recovery boot...\n");

    set_bootloader_message(&boot);

    LOGI("boot.command=%s\n",boot.command);
    LOGI("boot.recovery=%s\n",boot.recovery);
}
开发者ID:ebmajor,项目名称:msm7627a_2038_recovery,代码行数:13,代码来源:recovery.c


示例11: get_args

// command line args come from, in decreasing precedence:
//   - the actual command line
//   - the bootloader control block (one per line, after "recovery")
//   - the contents of COMMAND_FILE (one per line)
static void
get_args(int *argc, char ***argv) {
    if (*argc > 1) return;  // actual command line arguments take priority
    char *argv0 = (*argv)[0];

    struct bootloader_message boot;
    if (!get_bootloader_message(&boot)) {
        if (boot.command[0] != 0 && boot.command[0] != 255) {
            LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
        }

        if (boot.status[0] != 0 && boot.status[0] != 255) {
            LOGI("Boot status: %.*s\n", sizeof(boot.status), boot.status);
        }

        // Ensure that from here on, a reboot goes back into recovery
        strcpy(boot.command, "boot-recovery");
        set_bootloader_message(&boot);

        boot.recovery[sizeof(boot.recovery) - 1] = '\0';  // Ensure termination
        const char *arg = strtok(boot.recovery, "\n");
        if (arg != NULL && !strcmp(arg, "recovery")) {
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;
            for (*argc = 1; *argc < MAX_ARGS; ++*argc) {
                if ((arg = strtok(NULL, "\n")) == NULL) break;
                (*argv)[*argc] = strdup(arg);
            }
            LOGI("Got arguments from boot message\n");
            return;
        } else if (boot.recovery[0] != 0 && boot.recovery[0] != 255) {
            LOGE("Bad boot message\n\"%.20s\"\n", boot.recovery);
        }
    }

    FILE *fp = fopen_root_path(COMMAND_FILE, "r");
    if (fp == NULL) return;

    *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
    (*argv)[0] = argv0;  // use the same program name

    char buf[MAX_ARG_LENGTH];
    for (*argc = 1; *argc < MAX_ARGS && fgets(buf, sizeof(buf), fp); ++*argc) {
        (*argv)[*argc] = strdup(strtok(buf, "\r\n"));  // Strip newline.
    }

    check_and_fclose(fp, COMMAND_FILE);
    LOGI("Got arguments from %s\n", COMMAND_FILE);
}
开发者ID:Jib-BAOSP,项目名称:platform_recovery,代码行数:53,代码来源:recovery.c


示例12: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_root_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Copy logs to cache so the system can find out what happened.
    FILE *log = fopen_root_path(LOG_FILE, "a");
    if (log == NULL) {
        LOGE("Can't open %s\n", LOG_FILE);
    } else {
        FILE *tmplog = fopen(TEMPORARY_LOG_FILE, "r");
        if (tmplog == NULL) {
            LOGE("Can't open %s\n", TEMPORARY_LOG_FILE);
        } else {
            static long tmplog_offset = 0;
            fseek(tmplog, tmplog_offset, SEEK_SET);  // Since last write
            char buf[4096];
            while (fgets(buf, sizeof(buf), tmplog)) fputs(buf, log);
            tmplog_offset = ftell(tmplog);
            check_and_fclose(tmplog, TEMPORARY_LOG_FILE);
        }
        check_and_fclose(log, LOG_FILE);
    }

#ifndef BOARD_HAS_NO_MISC_PARTITION
    // Reset to mormal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);
#endif

    // Remove the command file, so recovery won't repeat indefinitely.
    char path[PATH_MAX] = "";
    if (ensure_root_path_mounted(COMMAND_FILE) != 0 ||
        translate_root_path(COMMAND_FILE, path, sizeof(path)) == NULL ||
        (unlink(path) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    sync();  // For good measure.
}
开发者ID:bandroidx,项目名称:bravo_recovery,代码行数:53,代码来源:recovery.c


示例13: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Save the locale to cache, so if recovery is next started up
    // without a --locale argument (eg, directly from the bootloader)
    // it will use the last-known locale.
    if (locale != NULL) {
        LOGI("Saving locale \"%s\"\n", locale);
        FILE* fp = fopen_path(LOCALE_FILE, "w");
        fwrite(locale, 1, strlen(locale), fp);
        fflush(fp);
        fsync(fileno(fp));
        check_and_fclose(fp, LOCALE_FILE);
    }

    // Copy logs to cache so the system can find out what happened.
    copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
    copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
    copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false);
    chmod(LOG_FILE, 0600);
    chown(LOG_FILE, 1000, 1000);   // system user
    chmod(LAST_LOG_FILE, 0640);
    chmod(LAST_INSTALL_FILE, 0644);

    // Reset to normal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);

    // Remove the command file, so recovery won't repeat indefinitely.
    if (ensure_path_mounted(COMMAND_FILE) != 0 ||
        (unlink(COMMAND_FILE) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    ensure_path_unmounted(CACHE_ROOT);
    sync();  // For good measure.
}
开发者ID:menghang,项目名称:a31_422_v33_android,代码行数:52,代码来源:recovery.cpp


示例14: main

int main(int argc, char *argv[])
{
	struct bootloader_message boot;
	const char *command = 0, *status = 0, *recovery = 0;
	int opt, write = 0;

	while ((opt = getopt(argc, argv, "c:s:r:wh")) != -1) {
		switch (opt) {
		case 'c':
			command = strdup(optarg);
			break;
		case 's':
			status = strdup(optarg);
			break;
		case 'r':
			recovery = strdup(optarg);
			break;
		case 'w':
			write = 1;
			break;
        case 'h':
            usage();
            return 0;
        default:
            usage();
            return -1;
		}
	}

	memset(&boot, 0, sizeof(boot));
	get_bootloader_message(&boot);
	if (write) {
		if (command)
			strncpy(boot.command, command, sizeof(boot.command));
		if (status)
			strncpy(boot.status, status, sizeof(boot.status));
		if (recovery)
			strncpy(boot.recovery, recovery, sizeof(boot.recovery));
		set_bootloader_message(&boot);
	} else {
		fprintf(stdout, "command=%s\nstatus=%s\nrecovery=%s\n",
				boot.command, boot.status, boot.recovery);
	}

	return 0;
}
开发者ID:liangxiaoju,项目名称:codes,代码行数:46,代码来源:blmessage.c


示例15: set_deltaupdate_recovery_bootmessage

static void set_deltaupdate_recovery_bootmessage(void)
{
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));

    LOGI("Setting recovery boot...\n");

    if(MAX_NUM_UPDATE_RECOVERY > get_deltaupdate_recoverycount())
    {
       strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
       strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    }
    else
    {
       LOGI("Recovery mode reached maximum retry. Clear boot message.\n");
    }
    set_bootloader_message(&boot);

    LOGI("boot.command=%s\n",boot.command);
    LOGI("boot.recovery=%s\n",boot.recovery);
}
开发者ID:ebmajor,项目名称:msm7627a_2038_recovery,代码行数:21,代码来源:recovery.c


示例16: set_recovery

MOTOBOX_CONFIG_ERR_T set_recovery()
{
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));

    if(get_bootloader_message(&boot))  {
        return MOTOBOX_CONFIG_ERR_SET_RECOVERY;
    }

    if (boot.command[0] != 0 && boot.command[0] != 255) {
        LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);

        if( !strcmp(boot.command,"boot-recovery")){
            /* already been set to boot-recovery to the command file */
            if(set_cache_command() != MOTOBOX_CONFIG_ERR_NONE) {
                return MOTOBOX_CONFIG_ERR_SET_RECOVERY;
            }
        } else {
            /* not boot-recovery command, we quit it */
            LOGE("Busy, try setconfig later");
            return MOTOBOX_CONFIG_ERR_SET_RECOVERY;
        }

    } else {
        /* misc is clean , set the boot-recovery command */
        char command_buf[255];
        memset(command_buf, 0, sizeof(command_buf));
        strncpy(command_buf, RECOVERY_COMMAND, sizeof(command_buf)-1);

        memset(&boot, 0, sizeof(boot));
        strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
        strlcpy(boot.recovery, command_buf, sizeof(boot.recovery));
        if (set_bootloader_message(&boot)) {
            return MOTOBOX_CONFIG_ERR_SET_RECOVERY;
        }

    }

    return MOTOBOX_CONFIG_ERR_NONE;
}
开发者ID:CarbonDev,项目名称:android_device_motorola_omap4-common,代码行数:40,代码来源:setconfig.c


示例17: start_firmware_update

int start_firmware_update(char *update_type, char *part_type)
{
    int result;
    struct bootloader_message boot;

    memset(&boot, 0, sizeof(boot));

    if(!strcmp(part_type, "mtd"))
    {
        mtd_scan_partitions();

        strlcpy(boot.recovery, "recovery\n--radio_status\n", sizeof(boot.command));
        snprintf(boot.command, sizeof(boot.command), "update-%s", update_type);
        if (set_bootloader_message(&boot)) {
            return -1;
        }
    }
    else if(!strcmp(part_type, "emmc"))
    {
        Volume *v = NULL;

        load_volume_table();

        v = volume_for_path("/sys_boot");
        if (strcmp(v->fs_type, "vfat"))
        {
            LOGE("Error in fs_type for sys_boot partition\n");
            return -1;
        }

        mkdir("/sys_boot", 777);

        /* Try mounting device first */
        result = mount(v->device, v->mount_point, v->fs_type,
                       MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
        if(result)
        {
            /* Try mounting device2 next */
            result = mount(v->device2, v->mount_point, v->fs_type,
                           MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
        }
        if(result == 0)
        {
             /* Creating cookie file for radio update */
             FILE *fp = fopen("/sys_boot/upcookie.txt", "w");
             fclose(fp);

             /* Unmount the sdcard now */
             if(umount(v->mount_point))
             {
                 LOGE("Error in unmounting  %s\n",v->mount_point);
                 return -1;
             }
             else
                 LOGI("Created cookie file for eMMC radio update\n");
        }
        else
        {
             LOGE("Error in mounting  %s\n",v->mount_point);
             return -1;
        }
		memset(&boot, 0, sizeof(boot));
        v = volume_for_path("/misc");
        if (set_bootloader_message_emmc(&boot, v)) {
            return -1;
        }
    }
    else
    {
        LOGE("Error in part_type %s\n",part_type);
        return -1;
    }

    sync();
    reboot(RB_AUTOBOOT);

    // Can't reboot?  WTF?
    LOGE("Can't reboot\n");
    return -1;
}
开发者ID:Wawan999,项目名称:unknown_device_samsung,代码行数:80,代码来源:firmware.c


示例18: get_args

// command line args come from, in decreasing precedence:
//   - the actual command line
//   - the bootloader control block (one per line, after "recovery")
//   - the contents of COMMAND_FILE (one per line)
static void
get_args(int *argc, char ***argv) {
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    get_bootloader_message(&boot);  // this may fail, leaving a zeroed structure
    stage = strndup(boot.stage, sizeof(boot.stage));

    if (boot.command[0] != 0 && boot.command[0] != 255) {
        LOGI("Boot command: %.*s\n", (int)sizeof(boot.command), boot.command);
    }

    if (boot.status[0] != 0 && boot.status[0] != 255) {
        LOGI("Boot status: %.*s\n", (int)sizeof(boot.status), boot.status);
    }

    // --- if arguments weren't supplied, look in the bootloader control block
    if (*argc <= 1) {
        boot.recovery[sizeof(boot.recovery) - 1] = '\0';  // Ensure termination
        const char *arg = strtok(boot.recovery, "\n");
        if (arg != NULL && !strcmp(arg, "recovery")) {
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = strdup(arg);
            for (*argc = 1; *argc < MAX_ARGS; ++*argc) {
                if ((arg = strtok(NULL, "\n")) == NULL) break;
                (*argv)[*argc] = strdup(arg);
            }
            LOGI("Got arguments from boot message\n");
        } else if (boot.recovery[0] != 0 && boot.recovery[0] != 255) {
            LOGE("Bad boot message\n\"%.20s\"\n", boot.recovery);
        }
    }

    // --- if that doesn't work, try the command file
    if (*argc <= 1) {
        FILE *fp = fopen_path(COMMAND_FILE, "r");
        if (fp != NULL) {
            char *token;
            char *argv0 = (*argv)[0];
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;  // use the same program name

            char buf[MAX_ARG_LENGTH];
            for (*argc = 1; *argc < MAX_ARGS; ++*argc) {
                if (!fgets(buf, sizeof(buf), fp)) break;
                token = strtok(buf, "\r\n");
                if (token != NULL) {
                    (*argv)[*argc] = strdup(token);  // Strip newline.
                } else {
                    --*argc;
                }
            }

            check_and_fclose(fp, COMMAND_FILE);
            LOGI("Got arguments from %s\n", COMMAND_FILE);
        }
    }

    // --> write the arguments we have back into the bootloader control block
    // always boot into recovery after this (until finish_recovery() is called)
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    int i;
    for (i = 1; i < *argc; ++i) {
        strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
        strlcat(boot.recovery, "\n", sizeof(boot.recovery));
    }
    set_bootloader_message(&boot);
}
开发者ID:JCROM-Android,项目名称:jcrom_bootable_recovery_,代码行数:72,代码来源:recovery.cpp


示例19: get_args


//.........这里部分代码省略.........
					}
            	}
            	LOGI("Got arguments from bootloader\n");
			}
            
        } else {
            LOGE("Bad bootloader arguments\n\"%.20s\"\n", recovery_command);
        }
    }
	
    // --- if that doesn't work, try the command file
    char * temp_args =NULL;
    if (*argc <= 1) {
        FILE *fp = fopen_path(COMMAND_FILE, "r");
        if (fp != NULL) {
            char *argv0 = (*argv)[0];
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;  // use the same program name

            char buf[MAX_ARG_LENGTH];
            for (*argc = 1; *argc < MAX_ARGS; ) {
                if (!fgets(buf, sizeof(buf), fp)) break;
			temp_args = strtok(buf, "\r\n");
			if(temp_args == NULL)  continue;
	       		(*argv)[*argc]  = strdup(temp_args);   // Strip newline.      
                		++*argc;
            }

            check_and_fclose(fp, COMMAND_FILE);
            LOGI("Got arguments from %s\n", COMMAND_FILE);
        }
    }

    // -- sleep 1 second to ensure SD card initialization complete
    usleep(1000000);

    // --- if that doesn't work, try the sdcard command file
    if (*argc <= 1) {
        FILE *fp = fopen_path(SDCARD_COMMAND_FILE, "r");
        if (fp != NULL) {
            char *argv0 = (*argv)[0];
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;  // use the same program name

            char buf[MAX_ARG_LENGTH];
            for (*argc = 1; *argc < MAX_ARGS; ) {
                if (!fgets(buf, sizeof(buf), fp)) break;
			temp_args = strtok(buf, "\r\n");
			if(temp_args == NULL)  continue;
	       		(*argv)[*argc]  = strdup(temp_args);   // Strip newline.      
                		++*argc;
            }

            check_and_fclose(fp, SDCARD_COMMAND_FILE);
            LOGI("Got arguments from %s\n", SDCARD_COMMAND_FILE);
        }
    }

    // --- if that doesn't work, try the udisk command file
    if (*argc <= 1) {
        FILE *fp = fopen_path(UDISK_COMMAND_FILE, "r");
        if (fp != NULL) {
            char *argv0 = (*argv)[0];
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;  // use the same program name

            char buf[MAX_ARG_LENGTH];
            for (*argc = 1; *argc < MAX_ARGS; ) {
                if (!fgets(buf, sizeof(buf), fp)) break;
			temp_args = strtok(buf, "\r\n");
			if(temp_args == NULL)  continue;
	       		(*argv)[*argc]  = strdup(temp_args);   // Strip newline.      
                		++*argc;
            }

            check_and_fclose(fp, UDISK_COMMAND_FILE);
            LOGI("Got arguments from %s\n", UDISK_COMMAND_FILE);
        }
    }

    // --- if no argument, then force show_text
    if (*argc <= 1) {
        char *argv0 = (*argv)[0];
        *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
        (*argv)[0] = argv0;  // use the same program name
        (*argv)[1] = "--show_text";
        *argc = 2;
    }

    // --> write the arguments we have back into the bootloader control block
    // always boot into recovery after this (until finish_recovery() is called)
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    int i;
    for (i = 1; i < *argc; ++i) {
        strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
        strlcat(boot.recovery, "\n", sizeof(boot.recovery));
    }
    set_bootloader_message(&boot);
}
开发者ID:fards,项目名称:ainol_elfii_bootable,代码行数:101,代码来源:recovery.c


示例20: main

int
main(int argc, char **argv) {
	if (strcmp(basename(argv[0]), "recovery") != 0)
	{
        if (strstr(argv[0], "flash_image") != NULL)
            return flash_image_main(argc, argv);
        if (strstr(argv[0], "dump_image") != NULL)
            return dump_image_main(argc, argv);
        if (strstr(argv[0], "erase_image") != NULL)
            return erase_image_main(argc, argv);
        if (strstr(argv[0], "mkyaffs2image") != NULL)
            return mkyaffs2image_main(argc, argv);
        if (strstr(argv[0], "unyaffs") != NULL)
            return unyaffs_main(argc, argv);
        if (strstr(argv[0], "nandroid"))
            return nandroid_main(argc, argv);
        if (strstr(argv[0], "reboot"))
            return reboot_main(argc, argv);
#ifdef BOARD_RECOVERY_HANDLES_MOUNT
        if (strstr(argv[0], "mount") && argc == 2 && !strstr(argv[0], "umount"))
        {
            load_volume_table();
            return ensure_path_mounted(argv[1]);
        }
#endif
        if (strstr(argv[0], "poweroff")){
            return reboot_main(argc, argv);
        }
    }
	__system("/sbin/postrecoveryboot.sh");

    time_t start = time(NULL);

    // If these fail, there's not really anywhere to complain...
#ifndef DEBUG
    unlink(TEMPORARY_LOG_FILE);
#endif

    freopen(TEMPORARY_LOG_FILE, "a", stdout); setbuf(stdout, NULL);
    freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL);
    printf("Starting recovery on %s", ctime(&start));
    //miuiIntent init
    miuiIntent_init(10);
    miuiIntent_register(INTENT_MOUNT, &intent_mount);
    miuiIntent_register(INTENT_ISMOUNT, &intent_ismount);
    miuiIntent_register(INTENT_UNMOUNT, &intent_unmount);
    miuiIntent_register(INTENT_REBOOT, &intent_reboot);
    miuiIntent_register(INTENT_INSTALL, &intent_install);
    miuiIntent_register(INTENT_WIPE, &intent_wipe);
    miuiIntent_register(INTENT_TOGGLE, &intent_toggle);
    miuiIntent_register(INTENT_FORMAT, &intent_format);
    miuiIntent_register(INTENT_RESTORE, &intent_restore);
    miuiIntent_register(INTENT_BACKUP, &intent_backup);
    miuiIntent_register(INTENT_ADVANCED_BACKUP, &intent_advanced_backup);
    miuiIntent_register(INTENT_SYSTEM, &intent_system);
    miuiIntent_register(INTENT_COPY, &intent_copy);
    device_ui_init();
    load_volume_table();
    get_args(&argc, &argv);

    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);
	create_fstab();
    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 't': ui_show_text(1); break;
        case '?':
            LOGE("Invalid command argument\n");
            continue;
        }
    }

    device_recovery_start();

    printf("Command:");
    for (arg = 0; arg < argc; arg++) {
        printf(" \"%s\"", argv[arg]);
    }
    printf("\n");

    if (update_package) {
        // For backwards compatibility on the cache partition only, if
        // we're given an old 'root' path "CACHE:foo", change it to
        // "/cache/foo".
        if (strncmp(update_package, "CACHE:", 6) == 0) {
            int len = strlen(update_package) + 10;
            char* modified_path = malloc(len);
            strlcpy(modified_path, "/cache/", len);
//.........这里部分代码省略.........
开发者ID:TheNameIsNigel,项目名称:miui_recovery,代码行数:101,代码来源:recovery.c



注:本文中的set_bootloader_message函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_border_width函数代码示例发布时间:2022-05-30
下一篇:
C++ set_boolean函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap