/*
* 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 constructing boot arguments
* from GRUB menu for Fast Reboot.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include "libgrub_impl.h"
#if defined(__sparc)
#endif /* __i386 */
/*
* Open the kernel file.
* Return zero on sucess or error code otherwise.
* On success the kernel file descriptor is returned in fdp.
*/
static int
{
const char *bname;
char ident[EI_NIDENT];
/* kernel basename must be unix */
else
bname++;
return (EG_XVMNOTSUP);
return (EG_NOTUNIX);
}
format == CUR_ELFDATA) {
return (0);
}
}
if (fd >= 0)
return (EG_OPENKERNFILE);
}
/*
* Construct boot arguments for Fast Reboot from the ge_barg field of
* a GRUB menu entry.
* Return 0 on success, errno on failure.
*/
static int
{
int rc = 0;
if (!IS_BARG_VALID(barg))
return (EINVAL);
return (EG_UNKNOWNFS);
return (rc);
goto err_out;
}
(void) clean_path(path);
/*
* GRUB requires absolute path, no symlinks, so do we
*/
else {
rc = EG_NOTABSPATH;
else
}
/* construct bootargs command-line */
if (rc != 0)
return (rc);
}
/*
* Construct boot arguments for Fast Reboot from grub_menu_t.
* Return 0 on success, errno on failure.
*/
static int
{
else
return (rc);
}
/*
* Construct boot arguments for Fast Reboot from grub_menu_t and the
* entry number.
* Return 0 on success, errno on failure.
*/
static int
{
return (EG_NOENTRY);
}
/*
* Construct boot arguments from the specified GRUB menu entry.
* Caller must allocate space for fbarg, and call grub_cleanup_boot_args()
* when it's done with fbarg to clean up.
*
* Return 0 on success, errno on failure.
*/
int
{
int rc;
}
return (rc);
}
/*
* Clean up when done with fbarg: close file handle, unmount file
* systems. Must be safe to call even if not all the fields are
* set up.
*/
void
{
return;
}