merge mainline into net
This commit is contained in:
commit
6e706342c3
8 changed files with 409 additions and 290 deletions
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
||||||
|
2011-07-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Remove getroot.c from core on emu platform.
|
||||||
|
|
||||||
|
* grub-core/Makefile.core.def (kernel): Remove kern/emu/getroot.c and
|
||||||
|
kern/emu/raid.c.
|
||||||
|
* grub-core/kern/emu/main.c (main): Don't try to guess root device. It's
|
||||||
|
useless.
|
||||||
|
* grub-core/kern/emu/misc.c (get_win32_path): Moved from here...
|
||||||
|
* util/getroot.c (get_win32_path): ... here.
|
||||||
|
* grub-core/kern/emu/misc.c (fini_libzfs): Moved from here...
|
||||||
|
* util/getroot.c (fini_libzfs): ... here.
|
||||||
|
* grub-core/kern/emu/misc.c (grub_get_libzfs_handle): Moved from here...
|
||||||
|
* util/getroot.c (grub_get_libzfs_handle): ... here.
|
||||||
|
* grub-core/kern/emu/misc.c (grub_find_zpool_from_dir):
|
||||||
|
Moved from here...
|
||||||
|
* util/getroot.c (grub_find_zpool_from_dir): ... here.
|
||||||
|
* grub-core/kern/emu/misc.c
|
||||||
|
(grub_make_system_path_relative_to_its_root): Moved from here...
|
||||||
|
* util/getroot.c (grub_make_system_path_relative_to_its_root): ... here.
|
||||||
|
* grub-core/kern/emu/getroot.c: Moved from here ...
|
||||||
|
* util/getroot.c: ... here. All users updated.
|
||||||
|
* grub-core/kern/emu/raid.c: Moved from here ...
|
||||||
|
* util/raid.c: ... here. All users updated.
|
||||||
|
|
||||||
|
2011-07-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* po/POTFILES.in: Regenerate.
|
||||||
|
|
||||||
2011-07-07 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-07-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Fix compilation on GNU/Linux.
|
Fix compilation on GNU/Linux.
|
||||||
|
|
|
@ -9,8 +9,8 @@ library = {
|
||||||
common = grub-core/kern/command.c;
|
common = grub-core/kern/command.c;
|
||||||
common = grub-core/kern/device.c;
|
common = grub-core/kern/device.c;
|
||||||
common = grub-core/kern/disk.c;
|
common = grub-core/kern/disk.c;
|
||||||
common = grub-core/kern/emu/getroot.c;
|
common = util/getroot.c;
|
||||||
common = grub-core/kern/emu/raid.c;
|
common = util/raid.c;
|
||||||
common = grub-core/kern/emu/hostdisk.c;
|
common = grub-core/kern/emu/hostdisk.c;
|
||||||
common = grub-core/kern/emu/misc.c;
|
common = grub-core/kern/emu/misc.c;
|
||||||
common = grub-core/kern/emu/mm.c;
|
common = grub-core/kern/emu/mm.c;
|
||||||
|
|
|
@ -195,8 +195,6 @@ kernel = {
|
||||||
emu = gnulib/error.c;
|
emu = gnulib/error.c;
|
||||||
emu = kern/emu/cache_s.S;
|
emu = kern/emu/cache_s.S;
|
||||||
emu = kern/emu/console.c;
|
emu = kern/emu/console.c;
|
||||||
emu = kern/emu/getroot.c;
|
|
||||||
emu = kern/emu/raid.c;
|
|
||||||
emu = kern/emu/hostdisk.c;
|
emu = kern/emu/hostdisk.c;
|
||||||
emu = kern/emu/hostfs.c;
|
emu = kern/emu/hostfs.c;
|
||||||
emu = kern/emu/main.c;
|
emu = kern/emu/main.c;
|
||||||
|
|
|
@ -111,7 +111,7 @@ usage (int status)
|
||||||
"\n"
|
"\n"
|
||||||
"GRUB emulator.\n"
|
"GRUB emulator.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -r, --root-device=DEV use DEV as the root device [default=guessed]\n"
|
" -r, --root-device=DEV use DEV as the root device [default=host]\n"
|
||||||
" -m, --device-map=FILE use FILE as the device map [default=%s]\n"
|
" -m, --device-map=FILE use FILE as the device map [default=%s]\n"
|
||||||
" -d, --directory=DIR use GRUB files in the directory DIR [default=%s]\n"
|
" -d, --directory=DIR use GRUB files in the directory DIR [default=%s]\n"
|
||||||
" -v, --verbose print verbose messages\n"
|
" -v, --verbose print verbose messages\n"
|
||||||
|
@ -204,24 +204,9 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
/* Make sure that there is a root device. */
|
/* Make sure that there is a root device. */
|
||||||
if (! root_dev)
|
if (! root_dev)
|
||||||
{
|
root_dev = grub_strdup ("host");
|
||||||
char *device_name = grub_guess_root_device (dir);
|
|
||||||
if (! device_name)
|
|
||||||
grub_util_error ("cannot find a device for %s", dir);
|
|
||||||
|
|
||||||
root_dev = grub_util_get_grub_dev (device_name);
|
dir = xstrdup (dir);
|
||||||
if (! root_dev)
|
|
||||||
{
|
|
||||||
grub_util_info ("guessing the root device failed, because of `%s'",
|
|
||||||
grub_errmsg);
|
|
||||||
grub_util_error ("cannot guess the root device. Specify the option `--root-device'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp (root_dev, "host") == 0)
|
|
||||||
dir = xstrdup (dir);
|
|
||||||
else
|
|
||||||
dir = grub_make_system_path_relative_to_its_root (dir);
|
|
||||||
|
|
||||||
/* Start GRUB! */
|
/* Start GRUB! */
|
||||||
if (setjmp (main_env) == 0)
|
if (setjmp (main_env) == 0)
|
||||||
|
|
|
@ -46,14 +46,6 @@
|
||||||
# include <libdevmapper.h>
|
# include <libdevmapper.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBZFS
|
|
||||||
# include <grub/util/libzfs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBNVPAIR
|
|
||||||
# include <grub/util/libnvpair.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_PARAM_H
|
#ifdef HAVE_SYS_PARAM_H
|
||||||
# include <sys/param.h>
|
# include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -242,265 +234,6 @@ canonicalize_file_name (const char *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
/* Convert POSIX path to Win32 path,
|
|
||||||
remove drive letter, replace backslashes. */
|
|
||||||
static char *
|
|
||||||
get_win32_path (const char *path)
|
|
||||||
{
|
|
||||||
char winpath[PATH_MAX];
|
|
||||||
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
|
|
||||||
grub_util_error ("cygwin_conv_path() failed");
|
|
||||||
|
|
||||||
int len = strlen (winpath);
|
|
||||||
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = offs; i < len; i++)
|
|
||||||
if (winpath[i] == '\\')
|
|
||||||
winpath[i] = '/';
|
|
||||||
return xstrdup (winpath + offs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBZFS
|
|
||||||
static libzfs_handle_t *__libzfs_handle;
|
|
||||||
|
|
||||||
static void
|
|
||||||
fini_libzfs (void)
|
|
||||||
{
|
|
||||||
libzfs_fini (__libzfs_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
libzfs_handle_t *
|
|
||||||
grub_get_libzfs_handle (void)
|
|
||||||
{
|
|
||||||
if (! __libzfs_handle)
|
|
||||||
{
|
|
||||||
__libzfs_handle = libzfs_init ();
|
|
||||||
|
|
||||||
if (__libzfs_handle)
|
|
||||||
atexit (fini_libzfs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return __libzfs_handle;
|
|
||||||
}
|
|
||||||
#endif /* HAVE_LIBZFS */
|
|
||||||
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
|
||||||
/* ZFS has similar problems to those of btrfs (see above). */
|
|
||||||
void
|
|
||||||
grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
|
|
||||||
{
|
|
||||||
char *slash;
|
|
||||||
|
|
||||||
*poolname = *poolfs = NULL;
|
|
||||||
|
|
||||||
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && defined(HAVE_STRUCT_STATFS_F_MNTFROMNAME)
|
|
||||||
/* FreeBSD and GNU/kFreeBSD. */
|
|
||||||
{
|
|
||||||
struct statfs mnt;
|
|
||||||
|
|
||||||
if (statfs (dir, &mnt) != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (strcmp (mnt.f_fstypename, "zfs") != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
*poolname = xstrdup (mnt.f_mntfromname);
|
|
||||||
}
|
|
||||||
#elif defined(HAVE_GETEXTMNTENT)
|
|
||||||
/* Solaris. */
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
struct extmnttab mnt;
|
|
||||||
|
|
||||||
if (stat (dir, &st) != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FILE *mnttab = fopen ("/etc/mnttab", "r");
|
|
||||||
if (! mnttab)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (getextmntent (mnttab, &mnt, sizeof (mnt)) == 0)
|
|
||||||
{
|
|
||||||
if (makedev (mnt.mnt_major, mnt.mnt_minor) == st.st_dev
|
|
||||||
&& !strcmp (mnt.mnt_fstype, "zfs"))
|
|
||||||
{
|
|
||||||
*poolname = xstrdup (mnt.mnt_special);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose (mnttab);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (! *poolname)
|
|
||||||
return;
|
|
||||||
|
|
||||||
slash = strchr (*poolname, '/');
|
|
||||||
if (slash)
|
|
||||||
{
|
|
||||||
*slash = '\0';
|
|
||||||
*poolfs = xstrdup (slash + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*poolfs = xstrdup ("");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This function never prints trailing slashes (so that its output
|
|
||||||
can be appended a slash unconditionally). */
|
|
||||||
char *
|
|
||||||
grub_make_system_path_relative_to_its_root (const char *path)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
char *p, *buf, *buf2, *buf3, *ret;
|
|
||||||
uintptr_t offset = 0;
|
|
||||||
dev_t num;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
|
||||||
char *poolfs = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* canonicalize. */
|
|
||||||
p = canonicalize_file_name (path);
|
|
||||||
if (p == NULL)
|
|
||||||
grub_util_error ("failed to get canonical path of %s", path);
|
|
||||||
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
|
||||||
/* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */
|
|
||||||
{
|
|
||||||
char *dummy;
|
|
||||||
grub_find_zpool_from_dir (p, &dummy, &poolfs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
len = strlen (p) + 1;
|
|
||||||
buf = xstrdup (p);
|
|
||||||
free (p);
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
buf2 = xstrdup (buf);
|
|
||||||
num = st.st_dev;
|
|
||||||
|
|
||||||
/* This loop sets offset to the number of chars of the root
|
|
||||||
directory we're inspecting. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
p = strrchr (buf, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
/* This should never happen. */
|
|
||||||
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
|
||||||
if (p != buf)
|
|
||||||
*p = 0;
|
|
||||||
else
|
|
||||||
*++p = 0;
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
/* buf is another filesystem; we found it. */
|
|
||||||
if (st.st_dev != num)
|
|
||||||
{
|
|
||||||
/* offset == 0 means path given is the mount point.
|
|
||||||
This works around special-casing of "/" in Un*x. This function never
|
|
||||||
prints trailing slashes (so that its output can be appended a slash
|
|
||||||
unconditionally). Each slash in is considered a preceding slash, and
|
|
||||||
therefore the root directory is an empty string. */
|
|
||||||
if (offset == 0)
|
|
||||||
{
|
|
||||||
free (buf);
|
|
||||||
#ifdef __linux__
|
|
||||||
{
|
|
||||||
char *bind;
|
|
||||||
grub_free (grub_find_root_device_from_mountinfo (buf2, &bind));
|
|
||||||
if (bind && bind[0] && bind[1])
|
|
||||||
{
|
|
||||||
buf3 = bind;
|
|
||||||
goto parsedir;
|
|
||||||
}
|
|
||||||
grub_free (bind);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
free (buf2);
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
|
||||||
if (poolfs)
|
|
||||||
return xasprintf ("/%s/@", poolfs);
|
|
||||||
#endif
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = p - buf;
|
|
||||||
/* offset == 1 means root directory. */
|
|
||||||
if (offset == 1)
|
|
||||||
{
|
|
||||||
/* Include leading slash. */
|
|
||||||
offset = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free (buf);
|
|
||||||
buf3 = xstrdup (buf2 + offset);
|
|
||||||
buf2[offset] = 0;
|
|
||||||
#ifdef __linux__
|
|
||||||
{
|
|
||||||
char *bind;
|
|
||||||
grub_free (grub_find_root_device_from_mountinfo (buf2, &bind));
|
|
||||||
if (bind && bind[0] && bind[1])
|
|
||||||
{
|
|
||||||
char *temp = buf3;
|
|
||||||
buf3 = grub_xasprintf ("%s%s%s", bind, buf3[0] == '/' ?"":"/", buf3);
|
|
||||||
grub_free (temp);
|
|
||||||
}
|
|
||||||
grub_free (bind);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
free (buf2);
|
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
|
||||||
{
|
|
||||||
/* Reached some mount point not below /cygdrive.
|
|
||||||
GRUB does not know Cygwin's emulated mounts,
|
|
||||||
convert to Win32 path. */
|
|
||||||
grub_util_info ("Cygwin path = %s\n", buf3);
|
|
||||||
char * temp = get_win32_path (buf3);
|
|
||||||
free (buf3);
|
|
||||||
buf3 = temp;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
parsedir:
|
|
||||||
/* Remove trailing slashes, return empty string if root directory. */
|
|
||||||
len = strlen (buf3);
|
|
||||||
while (len > 0 && buf3[len - 1] == '/')
|
|
||||||
{
|
|
||||||
buf3[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
|
||||||
if (poolfs)
|
|
||||||
{
|
|
||||||
ret = xasprintf ("/%s/@%s", poolfs, buf3);
|
|
||||||
free (buf3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
ret = buf3;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_DEVICE_MAPPER
|
#ifdef HAVE_DEVICE_MAPPER
|
||||||
static void device_mapper_null_log (int level __attribute__ ((unused)),
|
static void device_mapper_null_log (int level __attribute__ ((unused)),
|
||||||
const char *file __attribute__ ((unused)),
|
const char *file __attribute__ ((unused)),
|
||||||
|
|
117
po/POTFILES.in
117
po/POTFILES.in
|
@ -83,16 +83,20 @@ grub-core/commands/videoinfo.c
|
||||||
grub-core/commands/videotest.c
|
grub-core/commands/videotest.c
|
||||||
grub-core/commands/wildcard.c
|
grub-core/commands/wildcard.c
|
||||||
grub-core/commands/xnu_uuid.c
|
grub-core/commands/xnu_uuid.c
|
||||||
|
grub-core/disk/AFSplitter.c
|
||||||
grub-core/disk/ahci.c
|
grub-core/disk/ahci.c
|
||||||
grub-core/disk/arc/arcdisk.c
|
grub-core/disk/arc/arcdisk.c
|
||||||
grub-core/disk/ata.c
|
grub-core/disk/ata.c
|
||||||
|
grub-core/disk/cryptodisk.c
|
||||||
grub-core/disk/dmraid_nvidia.c
|
grub-core/disk/dmraid_nvidia.c
|
||||||
grub-core/disk/efi/efidisk.c
|
grub-core/disk/efi/efidisk.c
|
||||||
|
grub-core/disk/geli.c
|
||||||
grub-core/disk/host.c
|
grub-core/disk/host.c
|
||||||
grub-core/disk/i386/pc/biosdisk.c
|
grub-core/disk/i386/pc/biosdisk.c
|
||||||
grub-core/disk/ieee1275/nand.c
|
grub-core/disk/ieee1275/nand.c
|
||||||
grub-core/disk/ieee1275/ofdisk.c
|
grub-core/disk/ieee1275/ofdisk.c
|
||||||
grub-core/disk/loopback.c
|
grub-core/disk/loopback.c
|
||||||
|
grub-core/disk/luks.c
|
||||||
grub-core/disk/lvm.c
|
grub-core/disk/lvm.c
|
||||||
grub-core/disk/mdraid1x_linux.c
|
grub-core/disk/mdraid1x_linux.c
|
||||||
grub-core/disk/mdraid_linux.c
|
grub-core/disk/mdraid_linux.c
|
||||||
|
@ -174,6 +178,59 @@ grub-core/gfxmenu/model.c
|
||||||
grub-core/gfxmenu/theme_loader.c
|
grub-core/gfxmenu/theme_loader.c
|
||||||
grub-core/gfxmenu/view.c
|
grub-core/gfxmenu/view.c
|
||||||
grub-core/gfxmenu/widget-box.c
|
grub-core/gfxmenu/widget-box.c
|
||||||
|
grub-core/gnulib/alloca.c
|
||||||
|
grub-core/gnulib/argp-ba.c
|
||||||
|
grub-core/gnulib/argp-eexst.c
|
||||||
|
grub-core/gnulib/argp-fmtstream.c
|
||||||
|
grub-core/gnulib/argp-fs-xinl.c
|
||||||
|
grub-core/gnulib/argp-help.c
|
||||||
|
grub-core/gnulib/argp-parse.c
|
||||||
|
grub-core/gnulib/argp-pin.c
|
||||||
|
grub-core/gnulib/argp-pv.c
|
||||||
|
grub-core/gnulib/argp-pvh.c
|
||||||
|
grub-core/gnulib/argp-xinl.c
|
||||||
|
grub-core/gnulib/asnprintf.c
|
||||||
|
grub-core/gnulib/basename-lgpl.c
|
||||||
|
grub-core/gnulib/btowc.c
|
||||||
|
grub-core/gnulib/dirname-lgpl.c
|
||||||
|
grub-core/gnulib/error.c
|
||||||
|
grub-core/gnulib/fnmatch.c
|
||||||
|
grub-core/gnulib/fnmatch_loop.c
|
||||||
|
grub-core/gnulib/getdelim.c
|
||||||
|
grub-core/gnulib/getline.c
|
||||||
|
grub-core/gnulib/getopt1.c
|
||||||
|
grub-core/gnulib/getopt.c
|
||||||
|
grub-core/gnulib/localcharset.c
|
||||||
|
grub-core/gnulib/malloc.c
|
||||||
|
grub-core/gnulib/mbrtowc.c
|
||||||
|
grub-core/gnulib/mbsinit.c
|
||||||
|
grub-core/gnulib/mbsrtowcs.c
|
||||||
|
grub-core/gnulib/mbsrtowcs-state.c
|
||||||
|
grub-core/gnulib/memchr.c
|
||||||
|
grub-core/gnulib/mempcpy.c
|
||||||
|
grub-core/gnulib/nl_langinfo.c
|
||||||
|
grub-core/gnulib/printf-args.c
|
||||||
|
grub-core/gnulib/printf-parse.c
|
||||||
|
grub-core/gnulib/progname.c
|
||||||
|
grub-core/gnulib/rawmemchr.c
|
||||||
|
grub-core/gnulib/realloc.c
|
||||||
|
grub-core/gnulib/regcomp.c
|
||||||
|
grub-core/gnulib/regex.c
|
||||||
|
grub-core/gnulib/regexec.c
|
||||||
|
grub-core/gnulib/regex_internal.c
|
||||||
|
grub-core/gnulib/sleep.c
|
||||||
|
grub-core/gnulib/stdio-write.c
|
||||||
|
grub-core/gnulib/strcasecmp.c
|
||||||
|
grub-core/gnulib/strchrnul.c
|
||||||
|
grub-core/gnulib/strerror.c
|
||||||
|
grub-core/gnulib/stripslash.c
|
||||||
|
grub-core/gnulib/strncasecmp.c
|
||||||
|
grub-core/gnulib/strndup.c
|
||||||
|
grub-core/gnulib/strnlen1.c
|
||||||
|
grub-core/gnulib/strnlen.c
|
||||||
|
grub-core/gnulib/vasnprintf.c
|
||||||
|
grub-core/gnulib/vsnprintf.c
|
||||||
|
grub-core/gnulib/wcrtomb.c
|
||||||
grub-core/hello/hello.c
|
grub-core/hello/hello.c
|
||||||
grub-core/hook/datehook.c
|
grub-core/hook/datehook.c
|
||||||
grub-core/io/bufio.c
|
grub-core/io/bufio.c
|
||||||
|
@ -198,6 +255,7 @@ grub-core/kern/emu/lite.c
|
||||||
grub-core/kern/emu/main.c
|
grub-core/kern/emu/main.c
|
||||||
grub-core/kern/emu/misc.c
|
grub-core/kern/emu/misc.c
|
||||||
grub-core/kern/emu/mm.c
|
grub-core/kern/emu/mm.c
|
||||||
|
grub-core/kern/emu/raid.c
|
||||||
grub-core/kern/emu/time.c
|
grub-core/kern/emu/time.c
|
||||||
grub-core/kern/env.c
|
grub-core/kern/env.c
|
||||||
grub-core/kern/err.c
|
grub-core/kern/err.c
|
||||||
|
@ -264,6 +322,63 @@ grub-core/lib/ieee1275/datetime.c
|
||||||
grub-core/lib/ieee1275/halt.c
|
grub-core/lib/ieee1275/halt.c
|
||||||
grub-core/lib/ieee1275/relocator.c
|
grub-core/lib/ieee1275/relocator.c
|
||||||
grub-core/lib/legacy_parse.c
|
grub-core/lib/legacy_parse.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/ac.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/arcfour.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/blowfish.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/camellia.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/camellia-glue.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/cast5.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/cipher.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/crc.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/des.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/dsa.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/ecc.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/elgamal.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/hash-common.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/hmac-tests.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/md4.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/md5.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/md.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/primegen.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/pubkey.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/rfc2268.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/rijndael.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/rmd160.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/rsa.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/seed.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/serpent.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/sha1.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/sha256.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/sha512.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/tiger.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/twofish.c
|
||||||
|
grub-core/lib/libgcrypt/cipher/whirlpool.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/arcfour.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/blowfish.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/camellia.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/cast5.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/crc.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/des.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/dsa.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/ecc.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/elgamal.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/init.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/md4.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/md5.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/primegen.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/rfc2268.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/rijndael.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/rmd160.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/rsa.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/seed.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/serpent.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/sha1.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/sha256.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/sha512.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/tiger.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/twofish.c
|
||||||
|
grub-core/lib/libgcrypt-grub/cipher/whirlpool.c
|
||||||
grub-core/lib/LzFind.c
|
grub-core/lib/LzFind.c
|
||||||
grub-core/lib/LzmaDec.c
|
grub-core/lib/LzmaDec.c
|
||||||
grub-core/lib/LzmaEnc.c
|
grub-core/lib/LzmaEnc.c
|
||||||
|
@ -371,6 +486,7 @@ grub-core/tests/example_functional_test.c
|
||||||
grub-core/tests/lib/functional_test.c
|
grub-core/tests/lib/functional_test.c
|
||||||
grub-core/tests/lib/test.c
|
grub-core/tests/lib/test.c
|
||||||
grub-core/tests/test_blockarg.c
|
grub-core/tests/test_blockarg.c
|
||||||
|
grub-core/unidata.c
|
||||||
grub-core/video/bitmap.c
|
grub-core/video/bitmap.c
|
||||||
grub-core/video/bitmap_scale.c
|
grub-core/video/bitmap_scale.c
|
||||||
grub-core/video/bochs.c
|
grub-core/video/bochs.c
|
||||||
|
@ -419,5 +535,4 @@ util/ieee1275/grub-ofpathname.c
|
||||||
util/ieee1275/ofpath.c
|
util/ieee1275/ofpath.c
|
||||||
util/lvm.c
|
util/lvm.c
|
||||||
util/misc.c
|
util/misc.c
|
||||||
util/raid.c
|
|
||||||
util/resolve.c
|
util/resolve.c
|
||||||
|
|
|
@ -1330,3 +1330,262 @@ grub_util_check_char_device (const char *blk_dev)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
/* Convert POSIX path to Win32 path,
|
||||||
|
remove drive letter, replace backslashes. */
|
||||||
|
static char *
|
||||||
|
get_win32_path (const char *path)
|
||||||
|
{
|
||||||
|
char winpath[PATH_MAX];
|
||||||
|
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
|
||||||
|
grub_util_error ("cygwin_conv_path() failed");
|
||||||
|
|
||||||
|
int len = strlen (winpath);
|
||||||
|
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = offs; i < len; i++)
|
||||||
|
if (winpath[i] == '\\')
|
||||||
|
winpath[i] = '/';
|
||||||
|
return xstrdup (winpath + offs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBZFS
|
||||||
|
static libzfs_handle_t *__libzfs_handle;
|
||||||
|
|
||||||
|
static void
|
||||||
|
fini_libzfs (void)
|
||||||
|
{
|
||||||
|
libzfs_fini (__libzfs_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
libzfs_handle_t *
|
||||||
|
grub_get_libzfs_handle (void)
|
||||||
|
{
|
||||||
|
if (! __libzfs_handle)
|
||||||
|
{
|
||||||
|
__libzfs_handle = libzfs_init ();
|
||||||
|
|
||||||
|
if (__libzfs_handle)
|
||||||
|
atexit (fini_libzfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return __libzfs_handle;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LIBZFS */
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
|
/* ZFS has similar problems to those of btrfs (see above). */
|
||||||
|
void
|
||||||
|
grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
|
||||||
|
{
|
||||||
|
char *slash;
|
||||||
|
|
||||||
|
*poolname = *poolfs = NULL;
|
||||||
|
|
||||||
|
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && defined(HAVE_STRUCT_STATFS_F_MNTFROMNAME)
|
||||||
|
/* FreeBSD and GNU/kFreeBSD. */
|
||||||
|
{
|
||||||
|
struct statfs mnt;
|
||||||
|
|
||||||
|
if (statfs (dir, &mnt) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (strcmp (mnt.f_fstypename, "zfs") != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*poolname = xstrdup (mnt.f_mntfromname);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_GETEXTMNTENT)
|
||||||
|
/* Solaris. */
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct extmnttab mnt;
|
||||||
|
|
||||||
|
if (stat (dir, &st) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FILE *mnttab = fopen ("/etc/mnttab", "r");
|
||||||
|
if (! mnttab)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (getextmntent (mnttab, &mnt, sizeof (mnt)) == 0)
|
||||||
|
{
|
||||||
|
if (makedev (mnt.mnt_major, mnt.mnt_minor) == st.st_dev
|
||||||
|
&& !strcmp (mnt.mnt_fstype, "zfs"))
|
||||||
|
{
|
||||||
|
*poolname = xstrdup (mnt.mnt_special);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (mnttab);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (! *poolname)
|
||||||
|
return;
|
||||||
|
|
||||||
|
slash = strchr (*poolname, '/');
|
||||||
|
if (slash)
|
||||||
|
{
|
||||||
|
*slash = '\0';
|
||||||
|
*poolfs = xstrdup (slash + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*poolfs = xstrdup ("");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This function never prints trailing slashes (so that its output
|
||||||
|
can be appended a slash unconditionally). */
|
||||||
|
char *
|
||||||
|
grub_make_system_path_relative_to_its_root (const char *path)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *p, *buf, *buf2, *buf3, *ret;
|
||||||
|
uintptr_t offset = 0;
|
||||||
|
dev_t num;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
|
char *poolfs = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* canonicalize. */
|
||||||
|
p = canonicalize_file_name (path);
|
||||||
|
if (p == NULL)
|
||||||
|
grub_util_error ("failed to get canonical path of %s", path);
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
|
/* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */
|
||||||
|
{
|
||||||
|
char *dummy;
|
||||||
|
grub_find_zpool_from_dir (p, &dummy, &poolfs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
len = strlen (p) + 1;
|
||||||
|
buf = xstrdup (p);
|
||||||
|
free (p);
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
buf2 = xstrdup (buf);
|
||||||
|
num = st.st_dev;
|
||||||
|
|
||||||
|
/* This loop sets offset to the number of chars of the root
|
||||||
|
directory we're inspecting. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
p = strrchr (buf, '/');
|
||||||
|
if (p == NULL)
|
||||||
|
/* This should never happen. */
|
||||||
|
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
||||||
|
if (p != buf)
|
||||||
|
*p = 0;
|
||||||
|
else
|
||||||
|
*++p = 0;
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
/* buf is another filesystem; we found it. */
|
||||||
|
if (st.st_dev != num)
|
||||||
|
{
|
||||||
|
/* offset == 0 means path given is the mount point.
|
||||||
|
This works around special-casing of "/" in Un*x. This function never
|
||||||
|
prints trailing slashes (so that its output can be appended a slash
|
||||||
|
unconditionally). Each slash in is considered a preceding slash, and
|
||||||
|
therefore the root directory is an empty string. */
|
||||||
|
if (offset == 0)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
#ifdef __linux__
|
||||||
|
{
|
||||||
|
char *bind;
|
||||||
|
grub_free (grub_find_root_device_from_mountinfo (buf2, &bind));
|
||||||
|
if (bind && bind[0] && bind[1])
|
||||||
|
{
|
||||||
|
buf3 = bind;
|
||||||
|
goto parsedir;
|
||||||
|
}
|
||||||
|
grub_free (bind);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
free (buf2);
|
||||||
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
|
if (poolfs)
|
||||||
|
return xasprintf ("/%s/@", poolfs);
|
||||||
|
#endif
|
||||||
|
return xstrdup ("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = p - buf;
|
||||||
|
/* offset == 1 means root directory. */
|
||||||
|
if (offset == 1)
|
||||||
|
{
|
||||||
|
/* Include leading slash. */
|
||||||
|
offset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (buf);
|
||||||
|
buf3 = xstrdup (buf2 + offset);
|
||||||
|
buf2[offset] = 0;
|
||||||
|
#ifdef __linux__
|
||||||
|
{
|
||||||
|
char *bind;
|
||||||
|
grub_free (grub_find_root_device_from_mountinfo (buf2, &bind));
|
||||||
|
if (bind && bind[0] && bind[1])
|
||||||
|
{
|
||||||
|
char *temp = buf3;
|
||||||
|
buf3 = grub_xasprintf ("%s%s%s", bind, buf3[0] == '/' ?"":"/", buf3);
|
||||||
|
grub_free (temp);
|
||||||
|
}
|
||||||
|
grub_free (bind);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free (buf2);
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||||
|
{
|
||||||
|
/* Reached some mount point not below /cygdrive.
|
||||||
|
GRUB does not know Cygwin's emulated mounts,
|
||||||
|
convert to Win32 path. */
|
||||||
|
grub_util_info ("Cygwin path = %s\n", buf3);
|
||||||
|
char * temp = get_win32_path (buf3);
|
||||||
|
free (buf3);
|
||||||
|
buf3 = temp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
parsedir:
|
||||||
|
/* Remove trailing slashes, return empty string if root directory. */
|
||||||
|
len = strlen (buf3);
|
||||||
|
while (len > 0 && buf3[len - 1] == '/')
|
||||||
|
{
|
||||||
|
buf3[len - 1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
|
if (poolfs)
|
||||||
|
{
|
||||||
|
ret = xasprintf ("/%s/@%s", poolfs, buf3);
|
||||||
|
free (buf3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
ret = buf3;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in a new issue