fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 6000 - 6499
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 128 is the size of the largest (currently) property name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 8192 - MAXPROPSIZE - sizeof (int) is the size of the largest
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (currently) property value, viz. nvramrc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the sizeof(uint_t) is from struct openpromio
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAXVALSIZE (8192 - MAXPROPSIZE - sizeof (uint_t))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getbootdevname(char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setprom(unsigned, unsigned, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int devfs_dev_to_prom_name(char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call getbootdevname() to get the absolute pathname of boot device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and call setprom() to set the boot-device variable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesetboot(unsigned int yes, unsigned int verbose, char *fname)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Cannot determine device name for %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read the mnttab and resolve the special device of the fs we are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * interested in, into an absolute pathname
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (getmntent(f, &m) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (devfs_dev_to_prom_name(devname, bdev) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setprom() - use /dev/openprom to read the "boot_device" variable and set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it to the new value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesetprom(unsigned yes, unsigned verbose, char *bdev)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(MSGSTR(6002, "Could not open openprom dev"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pio = (struct openpromio *)malloc(sizeof (struct openpromio) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(MSGSTR(6003, " Error: Unable to allocate memory."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(pio->oprom_array, BOOTDEV_PROP_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * save the existing boot-device, so we can use it if setting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to new value fails.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Current boot-device = %s\n"), pio->oprom_array);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Do you want to change boot-device "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to the new setting? (y/n) "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the new value for boot-device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pio->oprom_size = (int)strlen(BOOTDEV_PROP_NAME) + 1 +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(pio->oprom_array, BOOTDEV_PROP_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(pio->oprom_array + (int)strlen(BOOTDEV_PROP_NAME) + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read back the value that was set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(pio->oprom_array, BOOTDEV_PROP_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* could not set the new device name, set the old one back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Could not set boot-device, reverting to old value"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pio->oprom_size = (int)strlen(BOOTDEV_PROP_NAME) + 1 +