bootenv.c revision bcbe91555f717d9e65cf05794295dfe172334908
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/bootconf.h>
#include "util.h"
#include "debug.h"
#include "multiboot.h"
#include "bootprop.h"
#define BOOTENV_BUFSIZE 4096
#define BOOTENV_LINESIZE 256
/*
* Note this path name must be consistent with that used
* in the ramdisk construction.
*/
static char *f_bootenv = "/boot/solaris/bootenv.rc";
static void
{
char *p;
int inq;
char *name;
char *val;
char **propp;
/*
* Trim comments, respecting single quotes, then
* skip any blank lines and leading white space.
*/
inq = 0;
for (p = line; *p; p++) {
if (*p == '\'' || *p == '"') {
inq ^= 1;
} else if ((inq == 0 && *p == '#') ||
*p == '\r' || *p == '\n') {
*p = 0;
break;
}
}
line++;
return;
/*
* Anything remaining must be in a fixed format
*/
goto err;
*name++ = 0;
goto err;
goto err;
*val++ = 0;
*p = 0;
val++;
}
/*
* An empty name indicates a syntax error but
* an empty value should just be ignored.
*/
goto err;
return;
/*
* We respect certain eeprom(1M) properties internally
* if not overridden on the grub kernel cmdline.
* There should never be multiple definitions, but
* should that occur, the last one is the one that sticks.
*/
propp = &bootfile_prop;
propp = &console_prop;
if (propp) {
if (*propp)
}
return;
err:
}
void
{
int fd;
char *line;
char *buf;
int n, bufcnt;
int c, linecnt;
int lineno = 1;
int err;
if (fd == -1) {
return;
}
*lp = 0;
bufcnt = 0;
linecnt = 0;
err = 0;
for (;;) {
if (bufcnt == 0) {
if (n <= 0)
goto exit;
bufcnt = n;
}
while (bufcnt > 0) {
if ((c = *bp++) == '\n') {
linecnt = 0;
err = 0;
*lp++ = c;
linecnt++;
} else if (err == 0) {
printf("%s: line %d exceeds maximum (%d)\n",
err = 1;
}
bufcnt--;
*lp = 0;
}
}
exit:
}