libgrub_menu.c revision 753a6d457b330b1b29b2d3eefcd0831116ce950d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file contains functions for manipulating the GRUB menu.
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "libgrub_impl.h"
#include "libgrub_cmd.def"
};
static void
{
} else {
}
}
static void
{
int n;
n = sizeof (grub_cmd_descs) / sizeof (grub_cmd_descs[0]);
/* search through the table of known commands */
;
/* unknown command */
if (n < 0)
return;
/* we found command, fill lp fields */
}
static void
{
int i;
emask = 0;
emask |= 1 << i;
}
}
}
static int
{
return (errno);
} else {
}
return (0);
}
static void
{
defent = 0;
defent = 0;
}
;
}
static void
{
return;
}
static void
{
return;
while (line) {
}
}
static void
{
return;
;
}
static int
{
int rc;
size_t n;
return (EINVAL);
rc = 0;
return (errno);
}
/* skip initial white space */
/* process comment line */
if (line[0] == '#') {
} else {
/* get command */
else
line += n;
/* get separator */
else
line += n;
/* get arguments */
}
if (rc != 0) {
return (rc);
}
return (0);
}
static int
{
int ret;
/* Free remaininig entries, if any */
/*
* Walk through lines, till first 'title' command is encountered.
* Initialize globals.
*/
break;
}
/*
* Walk through remaining lines and recreate menu entries.
*/
/* is first entry */
return (ret);
}
}
/* Add last entry */
return (ret);
return (0);
}
static int
{
== DI_NODE_NIL ||
return (EG_INITFS);
}
return (0);
}
static void
{
return;
}
/*
* Reads and parses GRUB menu file into a grub_menu_t data structure.
* If grub_menu_path file path is NULL, will use 'currently active'
* GRUB menu file.
*
* Memory for the menu data structure is allocated within the routine.
* Caller must call grub_menu_fini() to release memory after calling
* grub_menu_init().
*/
int
{
char *cp;
char buf[GRBM_MAXLINE];
return (EINVAL);
/*
* Allocate space, perform initialization
*/
return (errno);
}
goto err_out1;
/*
* Use default grub-menu.
* If top dataset is not mounted, mount it now.
*/
goto err_out1;
}
} else {
}
goto err_out1;
}
break;
}
/* remove white space at the end of line */
;
cp[n] = '\0';
len -= n - 1;
cp += n - 1;
continue;
}
break;
}
else if (ret == 0)
if (0 != ret) {
}
return (ret);
}
void
{
return;
}
{
else
}
{
else
}
{
return (NULL);
;
return (lp);
}
{
return (size_t)(-1);
}
{
return (mp->gm_ent_start);
} else {
}
}
{
return (mp->gm_ent_end);
} else {
}
}
{
if (num == GRUB_ENTRY_DEFAULT) {
} else {
;
}
return (ent);
}