int
main(int argc, char *argv[])
{
    struct disk_info *dinfo;

    if (argc < 2) {
        LOGE("usage: %s <conf file>", argv[0]);
        return 1;
    }

    if (!(dinfo = load_diskconfig(argv[1], NULL)))
        return 1;

    dump_disk_config(dinfo);

    return 0;
}
int
main(int argc, char *argv[])
{
    struct disk_info *dinfo = NULL;
    int test = 0;
    int verbose = 0;
    int cnt;

    if (parse_args(argc, argv, &dinfo, &test, &verbose))
        return 1;

    if (process_disk_config(dinfo)) {
        fprintf(stderr, "Disk configuration is bad\n");
        return 1;
    }

    if (verbose)
        dump_disk_config(dinfo);

    if (test)
        printf("Test mode enabled. Actions will not be committed to disk!\n");

    if (apply_disk_config(dinfo, test)) {
        fprintf(stderr, "Could not apply disk configuration!\n");
        return 1;
    }

    printf("Copying images to specified partition offsets\n");
    /* now copy the images to their appropriate locations on disk */
    for (cnt = 0; cnt < MAX_NUM_PARTS && part_file_map[cnt].pinfo; ++cnt) {
        off64_t offs = part_file_map[cnt].pinfo->start_lba * dinfo->sect_size;
        const char *dest_fn = dinfo->device;
        if (write_raw_image(dest_fn, part_file_map[cnt].filename, offs, test)) {
            fprintf(stderr, "Could not write images after editing label.\n");
            return 1;
        }
    }
    printf("File edit complete. Wrote %d images.\n", cnt);

    return 0;
}
Esempio n. 3
0
void setup_disk_information(char *disk_layout_location)
{
	char *disk_force;
	/* Read the preos.fstab, which is used to for filesystem
	 * meta-data and also the sd card device node */
	load_volume_table();

	/*
	 * If all device nodes exist and disk_force set to no in
	 * config file, skip to load/write partition table
	 */
	disk_force = tboot_config_get(DISK_FORCE_KEY);
	if (!disk_force) {
		pr_error("Invalid tboot config disk_force.\n");
		tboot_config_set(DISK_FORCE_KEY, "yes");
	}

	if (!check_devnodes() && !strcasecmp(disk_force, "no")) {
		pr_debug("bypass load disk config\n");
		return;
	}

	/* Read disk_layout.conf, which provides physical partition
	 * layout information */
	pr_debug("Reading disk layout from %s\n", disk_layout_location);
	disk_info = load_diskconfig(disk_layout_location, NULL);
	if (!disk_info) {
		pr_error("Disk layout unreadable.\n");
		die();
	}
	process_disk_config(disk_info);
	dump_disk_config(disk_info);

	/* Set up the partition table */
	if (apply_disk_config(disk_info, 0)) {
		pr_error("Couldn't apply disk configuration.\n");
		die();
	}
}