/* grub-fstest.c - debug tool for filesystem driver */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "progname.h"
#include "argp.h"
static grub_err_t
{
if (! cmd)
}
enum {
};
static int uncompress = 0;
static void
{
{
dev = grub_device_open (0);
grub_util_error (_("can\'t open device"));
grub_util_info ("total sectors : %lld",
if (! leng)
while (leng)
{
grub_util_error (_("disk read fails at offset %lld, length %d"),
break;
}
return;
}
if (uncompress == 0)
if (!file)
{
return;
}
{
return;
}
while (len)
{
if (sz < 0)
{
break;
}
break;
}
}
static void
{
{
(void) ofs;
{
grub_util_error (_("write error"));
return 1;
}
return 0;
}
{
return;
}
}
static void
{
{
(void) ofs;
{
grub_util_error (_("write error"));
return 1;
}
return 0;
}
}
static void
{
{
{
return 1;
}
{
int i;
{
return 1;
}
}
return 0;
}
{
return;
}
grub_util_error (_("seek error"));
{
grub_util_error (_("unexpected end of file"));
}
}
static void
{
{
return 0;
}
}
static void
{
{
(void) ofs;
return 0;
}
printf ("%08x\n",
}
static int args_count = 0;
static int nparm = 0;
static int cmd = 0;
static int mount_crypt = 0;
static void
{
char *host_file;
char *loop_name;
int i;
for (i = 0; i < num_disks; i++)
{
if (!loop_name)
if (!host_file)
grub_util_error (_("loopback command fails"));
}
{
if (mount_crypt)
{
}
}
grub_lvm_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_lvm_init ();
switch (cmd)
{
case CMD_LS:
break;
case CMD_ZFSINFO:
break;
case CMD_CP:
break;
case CMD_CAT:
break;
case CMD_CMP:
break;
case CMD_HEX:
break;
case CMD_CRC:
break;
case CMD_BLOCKLIST:
grub_printf ("\n");
case CMD_TESTLOAD:
grub_printf ("\n");
case CMD_XNU_UUID:
{
char *uuid = 0;
if (!dev)
if (!fs)
grub_util_error (_("couldn't retrieve UUID"));
if (!uuid)
grub_util_error (_("couldn't retrieve UUID"));
}
}
for (i = 0; i < num_disks; i++)
{
if (!loop_name)
argv[0] = "-d";
}
}
{0, 0, 0, 0, 0, 0}
};
/* Print the version information. */
static void
{
}
{
char *p;
switch (key)
{
case 'r':
return 0;
case 'K':
{
{
}
}
else
{
FILE *f;
if (!f)
{
return 0;
}
if (real_size < 0)
{
fclose (f);
return 0;
}
}
return 0;
case 'C':
mount_crypt = 1;
return 0;
case 's':
if (*p == 's')
return 0;
case 'n':
if (*p == 's')
return 0;
case 'c':
if (num_disks < 1)
{
argp_usage (state);
}
if (args_count != 0)
{
argp_usage (state);
}
return 0;
case 'd':
return 0;
case 'v':
verbosity++;
return 0;
case 'u':
uncompress = 1;
return 0;
case ARGP_KEY_END:
if (args_count < num_disks)
{
argp_usage (state);
}
{
argp_usage (state);
}
return 0;
case ARGP_KEY_ARG:
break;
default:
return ARGP_ERR_UNKNOWN;
}
if (args_count < num_disks)
{
if (args_count == 0)
args_count++;
return 0;
}
if (args_count == num_disks)
{
{
}
{
cmd = CMD_ZFSINFO;
}
{
nparm = 2;
}
{
nparm = 1;
}
{
nparm = 2;
}
{
nparm = 1;
}
{
nparm = 1;
}
{
cmd = CMD_BLOCKLIST;
nparm = 1;
}
{
cmd = CMD_TESTLOAD;
nparm = 1;
}
{
cmd = CMD_XNU_UUID;
nparm = 0;
}
else
{
argp_usage (state);
}
args_count++;
return 0;
}
args_count++;
return 0;
}
N_("Debug tool for filesystem driver."),
};
int
{
set_program_name (argv[0]);
/* Initialize all modules. */
grub_init_all ();
if (debug_str)
alloc_root = 0;
if (root)
{
{
root = alloc_root;
}
}
else
root = default_root;
if (alloc_root)
free (alloc_root);
/* Do it. */
/* Free resources. */
grub_fini_all ();
return 0;
}