/*-
* Copyright (c) 2011 Google, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <dirent.h>
#include <dlfcn.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
char *image;
/*
* Console i/o
*/
void
{
char c = ch;
}
int
{
char c;
return c;
return -1;
}
int
{
int n;
return (n > 0);
return (0);
}
/*
* Host filesystem i/o
*/
struct test_file {
int tf_isdir;
union {
int fd;
} tf_u;
};
int
{
if (!host_base)
return (ENOENT);
return (errno);
}
goto out;
return (0);
}
goto out;
return (0);
}
out:
return (EINVAL);
}
int
{
else
return (0);
}
int
{
}
int
{
return (EINVAL);
if (sz < 0)
return (EINVAL);
return (0);
}
int
{
return (EINVAL);
if (!dp)
return (ENOENT);
/*
* Note: d_namlen is in the range 0..255 and therefore less
* than PATH_MAX so we don't need to test before copying.
*/
return (0);
}
int
{
return (EINVAL);
return (errno);
return (0);
}
int
{
return (0);
}
/*
* Disk image i/o
*/
int
{
ssize_t n;
return (EIO);
if (n < 0)
return (errno);
*resid_return = size - n;
return (0);
}
int
{
return (EBADF);
switch (cmd) {
case DIOCGSECTORSIZE:
break;
case DIOCGMEDIASIZE:
else
return (ENOTTY);
break;
default:
return (ENOTTY);
};
return (0);
}
/*
* Guest virtual machine i/o
*
* Note: guest addresses are kernel virtual
*/
int
{
to &= 0x7fffffff;
if (to > image_size)
return (EFAULT);
return(0);
}
int
{
from &= 0x7fffffff;
if (from > image_size)
return (EFAULT);
return(0);
}
void
{
if (r < 0 || r >= 16)
return;
regs[r] = v;
}
void
{
}
void
{
}
void
{
}
void
{
}
/*
* Misc
*/
void
{
}
void
{
exit(v);
}
void
{
*highmem = 0;
}
const char *
{
static const char *vars[] = {
"foo=bar",
"bar=barbar",
};
}
.close = test_close,
.isdir = test_isdir,
.readdir = test_readdir,
.copyin = test_copyin,
.copyout = test_copyout,
.setreg = test_setreg,
.setmsr = test_setmsr,
.setcr = test_setcr,
.setgdt = test_setgdt,
.delay = test_delay,
.getmem = test_getmem,
.getenv = test_getenv,
};
void
usage()
{
printf("usage: [-b <userboot shared object>] [-d <disk image path>] [-h <host filesystem path>\n");
exit(1);
}
int
{
void *h;
void (*func)(struct loader_callbacks *, void *, int, int);
int opt;
switch (opt) {
case 'b':
break;
case 'd':
disk_image = optarg;
break;
case 'h':
break;
case '?':
usage();
}
}
if (!h) {
return (1);
}
if (!func) {
return (1);
}
if (disk_image) {
if (disk_fd < 0)
}
}