0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * CDDL HEADER START
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * The contents of this file are subject to the terms of the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Common Development and Distribution License (the "License").
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * You may not use this file except in compliance with the License.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * See the License for the specific language governing permissions
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * and limitations under the License.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * When distributing Covered Code, include this CDDL HEADER in each
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * If applicable, add the following below this CDDL HEADER, with the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * fields enclosed by brackets "[]" replaced with your own identifying
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * information: Portions Copyright [yyyy] [name of copyright owner]
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * CDDL HEADER END
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Copyright 2016 Toomas Soome <tsoome@me.com>
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome#include "../../common/bblk_einfo.h"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome#include "../../common/boot_utils.h"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome#include "../../common/mboot_extra.h"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * BIOS bootblock installation:
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * 1. MBR is first sector of the disk. If the file system on target is
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * ufs or zfs, the same MBR code is installed on first sector of the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * partition as well; this will allow to have real MBR sector to be
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * replaced by some other boot loader and have illumos chainloaded.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * installboot will record the start LBA and size of stage2 code in MBR code.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * On boot, the MBR code will read the stage2 code and executes it.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * 2. Stage2 location depends on file system type;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * In case of zfs, installboot will store stage2 to zfs bootblk area,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * which is 512k bytes from partition start and size is 3.5MB.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * In case of ufs, the stage2 location is 50 512B sectors from
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Solaris2 MBR partition start, within boot slice, boot slice size is
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * one cylinder.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * In case of pcfs, the stage2 location is 50 512B sectors from beginning
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * of the disk, filling the space between MBR and first partition.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * This location assumes no other bootloader and the space is one cylinder,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * as first partition is starting from cylinder 1.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * In case of GPT partitioning and if file system is not zfs, the boot
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * support is only possible with dedicated boot partition. For GPT,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * the current implementation is using BOOT partition, which must exist.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * BOOT partition does only contain raw boot blocks, without any file system.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Loader stage2 is created with embedded version, by using fake multiboot (MB)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * header within first 32k and EINFO block is at the end of the actual
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * boot block. MB header load_addr is set to 0 and load_end_addr is set to
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * actual block end, so the EINFO size is (file size - load_end_addr).
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * installboot does also store the illumos boot partition LBA to MB space,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * starting from bss_end_addr structure member location; stage2 will
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * detect the partition and file system based on this value.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Stored location values in MBR/stage2 also mean the bootblocks must be
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * reinstalled in case the partition content is relocated.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome/* Versioning string, if present. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Temporary buffer to store the first 32K of data looking for a multiboot
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * signature.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome/* Function prototypes. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic void check_options(char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int read_stage1_from_file(char *, ib_data_t *data);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int read_bootblock_from_file(char *, ib_data_t *data);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int read_bootblock_from_disk(ib_device_t *device, ib_bootblock_t *,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic void add_bootblock_einfo(ib_bootblock_t *, char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int prepare_bootblock(ib_data_t *, char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int handle_install(char *, char **);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int handle_getinfo(char *, char **);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int handle_mirror(char *, char **);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic boolean_t is_update_necessary(ib_data_t *, char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic int propagate_bootblock(ib_data_t *, ib_data_t *, char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomestatic void usage(char *);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeread_stage1_from_file(char *path, ib_data_t *dest)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* read the stage1 file from filesystem */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome read(fd, dest->stage1, SECTOR_SIZE) != SECTOR_SIZE) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("cannot read stage1 file %s\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeread_bootblock_from_file(char *file, ib_data_t *data)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Error getting information (stat) about %s", file);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* loader bootblock has version built in */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("bootblock in-memory buffer size is %d\n",
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read(fd, bblock->file, bblock->buf_size) != bblock->buf_size) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (find_multiboot(bblock->file, MBOOT_SCAN_SIZE, &mboot_off)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->mboot = (multiboot_header_t *)(bblock->file + mboot_off);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->mboot->load_end_addr - bblock->mboot->load_addr;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("bootblock file size is %d\n", bblock->file_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra = bblock->buf + P2ROUNDUP(bblock->file_size, 8);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra_size = bblock->buf_size - P2ROUNDUP(bblock->file_size, 8);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("mboot at %p offset %d, extra at %p size %d, buf=%p "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "(size=%d)\n", bblock->mboot, bblock->mboot_off, bblock->extra,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra_size, bblock->buf, bblock->buf_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeread_bootblock_from_disk(ib_device_t *device, ib_bootblock_t *bblock,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read_in(dev_fd, mboot_scan, sizeof (mboot_scan), offset)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* No multiboot means no chance of knowing bootblock size */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (find_multiboot(mboot_scan, sizeof (mboot_scan), &mboot_off)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Unable to find multiboot header\n");
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome mboot = (multiboot_header_t *)(mboot_scan + mboot_off);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * make sure mboot has sane values
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Currently, the amount of space reserved for extra information
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * is "fixed". We may have to scan for the terminating extra payload
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * in the future.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome size = mboot->load_end_addr - mboot->load_addr;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome buf_size = P2ROUNDUP(size + SECTOR_SIZE, SECTOR_SIZE);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Unable to allocate enough memory to read"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome " the extra bootblock from the disk\n");
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read_in(dev_fd, bblock->buf, buf_size, offset) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Update pointers. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->mboot = (multiboot_header_t *)(bblock->buf + bblock->mboot_off);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra = bblock->buf + P2ROUNDUP(bblock->file_size, 8);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra_size = bblock->buf_size - P2ROUNDUP(bblock->file_size, 8);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("mboot at %p offset %d, extra at %p size %d, buf=%p "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "(size=%d)\n", bblock->mboot, bblock->mboot_off, bblock->extra,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock->extra_size, bblock->buf, bblock->buf_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeis_update_necessary(ib_data_t *data, char *updt_str)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ib_bootblock_t *bblock_file = &data->bootblock;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = read_bootblock_from_disk(device, &bblock_disk, &path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Unable to read bootblock from %s\n", path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome einfo = find_einfo(bblock_disk.extra, bblock_disk.extra_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("No extended information available on disk\n");
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome einfo_file = find_einfo(bblock_file->extra, bblock_file->extra_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * loader bootblock is versioned. missing version means
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * probably incompatible block. installboot can not install
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * grub, for example.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome gettext("ERROR: non versioned bootblock in file\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "versioned bootblock that is going to be overwritten by a "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Forcing update of %s bootblock\n", device->path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Ready to check installed version vs %s\n", updt_str);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bblock_hs.src_buf = (unsigned char *)bblock_file->file;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome return (einfo_should_update(einfo, &bblock_hs, updt_str));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeadd_bootblock_einfo(ib_bootblock_t *bblock, char *updt_str)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("WARNING: no update string passed to "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "add_bootblock_einfo()\n");
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Fill bootblock hashing source information. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* How much space for the extended information structure? */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome avail_space = bblock->buf_size - P2ROUNDUP(bblock->file_size, 8);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Place the extended information structure. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome add_einfo(bblock->extra, updt_str, &hs, avail_space);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * set up data for case stage1 is installed as MBR
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * set up location and size of bootblock
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * set disk guid to provide unique information for biosdev command
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* copy BPB */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome data->stage1 + STAGE1_BPB_OFFSET, STAGE1_BPB_SIZE);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* copy MBR, note STAGE1_SIG == BOOTSZ */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome bcopy(device->mbr + STAGE1_SIG, data->stage1 + STAGE1_SIG,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* set stage2 size */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome *((uint16_t *)(data->stage1 + STAGE1_STAGE2_SIZE)) =
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (uint16_t)(data->bootblock.buf_size / SECTOR_SIZE);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * set stage2 location.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * for zfs always use zfs embedding, for ufs/pcfs use partition_start
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * as base for stage2 location, for ufs/pcfs in MBR partition, use
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * free space after MBR record.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome *((uint64_t *)(data->stage1 + STAGE1_STAGE2_LBA)) =
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome *((uint64_t *)(data->stage1 + STAGE1_STAGE2_LBA)) =
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * set disk uuid. we only need reasonable amount of uniqueness
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * to allow biosdev to identify disk based on mbr differences.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome uuid_generate(data->stage1 + STAGE1_STAGE2_UUID);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeprepare_bootblock(ib_data_t *data, char *updt_str)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ptr = (uint64_t *)(&bblock->mboot->bss_end_addr);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * the loader bootblock has built in version, if custom
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * version was provided, update it.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * ZFS bootblock area is 3.5MB, make sure we can fit.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * buf_size is size of bootblk+EINFO.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("bootblock is too large\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome abs = device->target.start + device->target.offset;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome abs = device->stage.start + device->stage.offset;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (device->stage.size - device->stage.offset) * SECTOR_SIZE) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = write_out(dev_fd, bblock->buf, bblock->buf_size, offset);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("bootblock written for %s,"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome " %d sectors starting at %d (abs %lld)\n"), path,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (bblock->buf_size / SECTOR_SIZE) + 1, offset / SECTOR_SIZE, abs);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Partition boot block or volume boot record.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * This is essentially copy of MBR (1 sector) and we store it
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * to support multi boot setups.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Not all combinations are supported; as pcfs does not leave
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * space, we will not write to pcfs target.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * In addition, in VTOC setup, we will only write VBR to slice 2.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome strcmp(device->target.path, device->stage.path)) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* we got separate stage area, use it */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "partition boot sector\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("stage1 written to "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "%s %d sector 0 (abs %d)\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->devtype == IG_DEV_MBR? "partition":"slice",
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * both ufs and zfs have initial 8k reserved for VTOC/boot
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * so its safe to use this area. however, only
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * write to target if we have MBR/GPT.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "partition boot sector\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("stage1 written to "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "%s %d sector 0 (abs %d)\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->devtype == IG_DEV_MBR? "partition":"slice",
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome gettext("stage1 written to master boot sector\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * find partition/slice start sector. will be recorded in stage2 and used
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * by stage2 to identify partition with boot file system.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* zero size means the fstype must be zfs */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* with pcfs we always write MBR */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* For MBR we have device->stage filled already. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* MBR partition starts from 0 */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Partition %d of the "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "disk has an incorrect offset\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* with pcfs we always write MBR */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Search for Solaris fdisk partition
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Get the solaris partition information from the device
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * and compare the offset of S2 with offset of solaris partition
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * from fdisk partition table.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (ioctl(device->target.fd, DKIOCEXTPARTINFO, &edkpi) < 0) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (ioctl(device->target.fd, DKIOCPARTINFO, &dkpi) < 0) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("cannot get the "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "slice information of the disk\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome for (i = 0; i < FD_NUMPART; i++) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Partition %d of the "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome edkpi.p_start < (part->relsect + part->numsect)) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Found the partition */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* No solaris fdisk partitions (primary or logical) */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Solaris partition not found. "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "Aborting operation.\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * We have found a Solaris fdisk partition (primary or extended)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Handle the simple case first: Solaris in a primary partition
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Solaris in a logical partition. Find that partition in the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * extended part.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if ((rval = libfdisk_init(&epp, device->path, NULL, FDISK_READ_DISK))
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * The first 3 cases are not an error per-se, just that
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * there is no Solaris logical partition
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "partition not found. "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "Aborting operation.\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Could not get "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "virtual geometry\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Could not get "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "physical geometry\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Could not get "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "label geometry\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "initialize libfdisk.\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome rval = fdisk_get_solaris_part(epp, &pno, &secnum, &numsec);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* No solaris logical partition */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Solaris partition not found. "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "Aborting operation.\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* get confirmation for -m */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("Updating master boot sector "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "destroys existing boot managers (if any).\n"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "continue (y/n)? "));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("master boot sector "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "not updated\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * warn, if illumos in primary partition and loader not in MBR and
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * partition is not active
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (!log_part && part->bootid != 128 && !write_mbr) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("Solaris fdisk "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "partition is inactive.\n"), device->stage.id);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome return (-1);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome return (-1);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("%s: Not a character device\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome return (-1);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeget_boot_partition(ib_device_t *device, struct mboot *mbr)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome for (i = 0; i < FD_NUMPART; i++) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* no X86BOOT, try to use space between MBR and first partition */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) asprintf(&ptr, "%s%d", path, i+1); /* partitions are p1..p4 */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.offset = 1; /* leave sector 0 for VBR */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomeget_boot_slice(ib_device_t *device, struct dk_gpt *vtoc)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if ((path = strdup(device->target.path)) == NULL) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.start = vtoc->efi_parts[i].p_start;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.size = vtoc->efi_parts[i].p_size;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.offset = 1; /* leave sector 0 for VBR */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.fd = -1; /* bootblock partition fd */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->target.fd = -1; /* target fs partition fd */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* basic check, whole disk is not allowed */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if ((strrchr(p, 'p') == NULL && strrchr(p, 's') == NULL) ||
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (path[pathlen-2] == 'p' && path[pathlen-1] == '0')) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("installing loader to "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "whole disk device is not supported\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* change device name to p0 */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("installing loader to a floppy "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "disk is not supported\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Detect if the target device is a pcfs partition. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("installing loader to x86 boot "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "partition is not supported\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if ((device->fd = open_device(device->path)) == -1)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* read in the device boot sector. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read(device->fd, device->mbr, SECTOR_SIZE) != SECTOR_SIZE) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error reading boot sector\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (efi_alloc_and_read(device->fd, &vtoc) >= 0) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome } else if (device->target.path[pathlen - 2] == 'p') {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = get_boot_partition(device, (struct mboot *)device->mbr);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome } else if (device->target.path[pathlen - 1] == '2') {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * NOTE: we could relax there and allow zfs boot on
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * slice 2 for instance, but lets keep traditional limits.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome gettext("raw device must be a root slice (not s2)\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* fill stage partition for case there is no boot partition */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if ((device->stage.path = strdup(path)) == NULL) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* use slice 2 */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->stage.fd = open_device(device->stage.path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (strcmp(device->stage.path, device->target.path) == 0)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome device->target.fd = open_device(device->target.path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (fstyp_init(device->target.fd, 0, NULL, &fhdl) != 0)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Failed to detect file "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "system type\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* at this moment non-boot partition has no size set, use this fact */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (device->devtype == IG_DEV_EFI && strcmp(fident, "zfs") &&
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Booting %s of EFI labeled "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "disks requires the boot partition.\n"), fident);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("File system %s is not "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* check for boot partition content */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (fstyp_init(device->stage.fd, 0, NULL, &fhdl) != 0)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Unexpected %s file "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Propagate the bootblock on the source disk to the destination disk and
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * version it with 'updt_str' in the process. Since we cannot trust any data
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * on the attaching disk, we do not perform any specific check on a potential
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * target extended information structure and we just blindly update.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomepropagate_bootblock(ib_data_t *src, ib_data_t *dest, char *updt_str)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ib_bootblock_t *dest_bblock = &dest->bootblock;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* read the stage1 file from source disk */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read(src->device.fd, dest->stage1, SECTOR_SIZE) != SECTOR_SIZE) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("cannot read stage1 from %s\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->buf = malloc(dest_bblock->buf_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->file_size = src_bblock->file_size;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) memcpy(dest_bblock->buf, src_bblock->buf,
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->mboot = (multiboot_header_t *)(dest_bblock->file +
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->mboot_off = src_bblock->mboot_off;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->extra = (char *)dest_bblock->file +
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome dest_bblock->extra_size = src_bblock->extra_size;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("Propagating %s bootblock to %s\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soomecommit_to_disk(ib_data_t *data, char *update_str)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (prepare_bootblock(data, update_str) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error updating the bootblock "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "image\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error updating the stage1 "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "image\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error writing bootblock to "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Install a new bootblock on the given device. handle_install() expects argv
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * to contain 3 parameters (the target device path and the path to the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * bootblock.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Returns: BC_SUCCESS - if the installation is successful
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * BC_ERROR - if the installation failed
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * BC_NOUPDT - if no installation was performed because the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * version currently installed is more recent than the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * supplied one.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Missing parameter"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("device path: %s, stage1 path: %s bootblock path: %s\n",
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (init_device(&install_data.device, device_path) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Unable to open device %s\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read_stage1_from_file(stage1, &install_data) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error opening %s\n"), stage1);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (read_bootblock_from_file(bootblock, &install_data) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error reading %s\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * is_update_necessary() will take care of checking if versioning and/or
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * forcing the update have been specified. It will also emit a warning
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * if a non-versioned update is attempted over a versioned bootblock.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (!is_update_necessary(&install_data, update_str)) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("bootblock version installed "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "on %s is more recent or identical\n"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "Use -F to override or install without the -u option\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = commit_to_disk(&install_data, update_str);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Retrieves from a device the extended information (einfo) associated to the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * installed stage2.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Expects one parameter, the device path, in the form: /dev/rdsk/c?[t?]d?s0.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_SUCCESS (and prints out einfo contents depending on 'flags')
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_ERROR (on error)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_NOEINFO (no extended information available)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Missing parameter"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (init_device(device, device_path) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Unable to gather device "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = read_bootblock_from_disk(device, bblock, &path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Error reading bootblock from "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("No multiboot header found on %s, unable "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "to locate extra information area (old/non versioned "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("No extended information "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "found\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome einfo = find_einfo(bblock->extra, bblock->extra_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("No extended information "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "found\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* Print the extended information. */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * Attempt to mirror (propagate) the current bootblock over the attaching disk.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_SUCCESS (a successful propagation happened)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_ERROR (an error occurred)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * - BC_NOEXTRA (it is not possible to dump the current bootblock since
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * there is no multiboot information)
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ib_device_t *attach_device = &attach_data.device;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ib_bootblock_t *bblock_curr = &curr_data.bootblock;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ib_bootblock_t *bblock_attach = &attach_data.bootblock;
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (!curr_device_path || !attach_device_path) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Missing parameter"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Current device path is: %s, attaching device path is: "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome " %s\n", curr_device_path, attach_device_path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (init_device(curr_device, curr_device_path) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Unable to gather device "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "information from %s (current device)\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome if (init_device(attach_device, attach_device_path) != BC_SUCCESS) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Unable to gather device "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "information from %s (attaching device)\n"),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome ret = read_bootblock_from_disk(curr_device, bblock_curr, &path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("Error reading bootblock from %s\n", path);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome BOOT_DEBUG("No multiboot header found on %s, unable to retrieve"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome einfo_curr = find_einfo(bblock_curr->extra, bblock_curr->extra_size);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome retval = propagate_bootblock(&curr_data, &attach_data, updt_str);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome#define USAGE_STRING "Usage:\t%s [-h|-m|-f|-n|-F|-u verstr] stage1 stage2 " \
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "raw-device\n" \
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "\t%s -M [-n] raw-device attach-raw-device\n" \
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "\t%s [-e|-V] -i raw-device\n"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, CANON_USAGE_STR, progname, progname, progname);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext(ERR_MSG_INIT_YES),
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome while ((opt = getopt(argc, argv, "deFfhiMmnu:V")) != EOF) {
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) strlcpy(update_str, optarg, strlen(optarg) + 1);
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* fall through to process non-optional args */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome /* check arguments */
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stdout, gettext("Dry run requested. Nothing will"
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome " be written to disk.\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome#define MEANINGLESS_OPT gettext("%s specified but meaningless, ignoring\n")
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome (void) fprintf(stderr, gettext("Only one of -M and -i can be "
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome "specified at the same time\n"));
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * -u and -F may actually reflect a user intent that is not
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * correct with this command (mirror can be interpreted
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * "similar" to install. Emit a message and continue.
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * -e and -V have no meaning, be quiet here and only report the
0c946d80993858b7b1314e0b31773e48500e03fbToomas Soome * incongruence if a debug output is requested.