/* grub-probe.c - probe device information for a given path */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,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 <grub/partition.h>
#include <grub/msdos_partition.h>
#include <grub/cryptodisk.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include "progname.h"
enum {
};
static unsigned int argument_is_device = 0;
static void
{
{
}
{
}
while (list)
{
}
}
static void
{
{
}
while (list)
{
}
}
static int
{
/* disk might be NULL in the case of a LVM physical volume with no LVM
signature. Ignore such cases here. */
if (!disk)
return -1;
return -1;
}
/* Since OF path names can have "," characters in them, and GRUB
internally uses "," to indicate partitions (unlike OF which uses
":" for this purpose) we escape such commas. */
static char *
{
char *new_path, *d, c;
const char *p;
return (char *) orig_path;
p = orig_path;
while ((c = *p++) != '\0')
{
if (c == ',')
*d++ = '\\';
*d++ = c;
}
*d = 0;
return new_path;
}
static char *
{
char *canon;
char *ptr;
#if !defined(__sun__)
if (!canon)
return NULL;
if (ptr)
ptr++;
else
{
}
{
}
#endif
return NULL;
}
static char *
{
char *canon;
char *ptr;
#if !defined(__sun__)
if (!canon)
return NULL;
if (ptr)
ptr++;
else
{
}
{
}
#endif
return NULL;
}
static char *
{
char *canon;
char *ptr;
#if !defined(__sun__)
if (!canon)
return NULL;
if (ptr)
ptr++;
else
{
}
{
}
#endif
return NULL;
}
static void
{
{
}
else
}
static void
{
int raid_level;
while (list)
{
}
printf ("lvm ");
if (raid_level >= 0)
{
printf ("raid ");
}
if (raid_level == 5)
printf ("raid5rec ");
if (raid_level == 6)
printf ("raid6rec ");
}
static void
{
{
if (! grub_util_check_char_device (device_name))
#else
if (! grub_util_check_block_device (device_name))
#endif
}
else
{
}
if (! device_name)
if (print == PRINT_DEVICE)
{
goto end;
}
if (! drive_name)
grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
if (print == PRINT_DRIVE)
{
goto end;
}
if (! dev)
if (print == PRINT_HINT_STR)
{
#if !defined(__sun__)
/* Do not do this on Solaris for now */
#else
const char *orig_path = 0;
#endif
const char *map;
if (orig_path)
{
printf ("--hint-ieee1275='");
printf ("' ");
}
if (biosname)
{
printf ("--hint-bios=");
printf (" ");
}
if (efi)
{
printf ("--hint-efi=");
printf (" ");
}
if (bare)
{
printf ("--hint-baremetal=");
printf (" ");
}
/* FIXME: Add ARC hint. */
if (map)
{
printf ("--hint='");
printf ("' ");
}
printf ("\n");
goto end;
}
if (print == PRINT_COMPATIBILITY_HINT)
{
const char *map;
char *biosname;
if (map)
{
printf ("\n");
goto end;
}
if (biosname)
printf ("\n");
goto end;
}
if (print == PRINT_BIOS_HINT)
{
char *biosname;
if (biosname)
printf ("\n");
goto end;
}
if (print == PRINT_IEEE1275_HINT)
{
const char *map;
if (map)
{
printf (" ");
}
printf (" ");
printf ("\n");
goto end;
}
if (print == PRINT_EFI_HINT)
{
char *biosname;
char *name;
const char *map;
if (map)
{
printf (" ");
}
if (biosname)
{
printf (" ");
}
printf ("\n");
goto end;
}
if (print == PRINT_BAREMETAL_HINT)
{
char *biosname;
char *name;
const char *map;
if (map)
{
printf (" ");
}
if (biosname)
{
printf (" ");
}
printf ("\n");
goto end;
}
if (print == PRINT_ARC_HINT)
{
const char *map;
if (map)
{
printf (" ");
}
printf ("\n");
/* FIXME */
goto end;
}
if (print == PRINT_ABSTRACTION)
{
printf ("\n");
goto end;
}
if (print == PRINT_CRYPTODISK_UUID)
{
printf ("\n");
goto end;
}
if (print == PRINT_PARTMAP)
{
/* Check if dev->disk itself is contained in a partmap. */
printf ("\n");
goto end;
}
if (! fs)
{
}
else if (print == PRINT_FS_UUID)
{
char *uuid;
}
else if (print == PRINT_FS_LABEL)
{
char *label;
}
end:
if (dev)
free (drive_name);
}
{
{0, 0, 0, 0}
};
static void
{
if (status)
_("Try `%s --help' for more information.\n"), program_name);
else
printf (_("\
Usage: %s [OPTION]... [PATH|DEVICE]\n\
\n\
Probe device information for a given path (or device, if the -d option is given).\n\
\n\
-d, --device given argument is a system device, not a path\n\
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid)\n\
print filesystem module, GRUB drive, system device, partition map module, abstraction module or CRYPTO UUID [default=fs]\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
"), program_name,
}
int
{
char *dev_map = 0;
char *argument;
set_program_name (argv[0]);
/* Check for options. */
while (1)
{
if (c == -1)
break;
else
switch (c)
{
case 'd':
argument_is_device = 1;
break;
case 'm':
if (dev_map)
break;
case 't':
print = PRINT_DRIVE;
else
usage (1);
break;
case 'h':
usage (0);
break;
case 'V':
return 0;
case 'v':
verbosity++;
break;
default:
usage (1);
break;
}
}
if (verbosity > 1)
/* Obtain ARGUMENT. */
{
usage (1);
}
{
usage (1);
}
/* Initialize the emulated biosdisk driver. */
/* Initialize all modules. */
grub_init_all ();
grub_lvm_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_lvm_init ();
/* Do it. */
if (argument_is_device)
else
/* Free resources. */
grub_fini_all ();
return 0;
}