* util/getroot.c (strip_extra_slashes) [CYGWIN]: #ifdef-out.

(exec_pipe) [CYGWIN || MINGW32]: Likewise.
	(find_root_devices_from_poolname) [CYGWIN || MINGW32]: Likewise.
	(find_root_devices_from_libzfs) [CYGWIN || MINGW32]: Likewise.
	Disable -Werror for -Wdeprecated-declarations.
	(grub_guess_root_devices) [CYGWIN || MINGW32]: #ifdef-out.
	(get_dm_uuid) [!HAVE_DEVICE_MAPPER]: Likewise.
	(grub_util_get_dm_abstraction) [! __linux__]: #ifdef-out.
	(grub_util_get_grub_dev): Make luks handling dependent on
	HAVE_DEVICE_MAPPER and not __linux__.
	(get_win32_path): Fix format security.
	(grub_find_zpool_from_dir) [CYGWIN || MINGW32]: #ifdef-out.
	(grub_make_system_path_relative_to_its_root) [CYGWIN || MINGW32]:
	Don't try grub_find_zpool_from_dir.
	(grub_make_system_path_relative_to_its_root) [!__linux__]:
	#ifdef-out paresdir.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-03-02 11:36:07 +01:00
parent 1bab1ae335
commit 937fd0cc0c
2 changed files with 65 additions and 24 deletions

View file

@ -1,3 +1,22 @@
2012-03-02 Vladimir Serbinenko <phcoder@gmail.com>
* util/getroot.c (strip_extra_slashes) [CYGWIN]: #ifdef-out.
(exec_pipe) [CYGWIN || MINGW32]: Likewise.
(find_root_devices_from_poolname) [CYGWIN || MINGW32]: Likewise.
(find_root_devices_from_libzfs) [CYGWIN || MINGW32]: Likewise.
Disable -Werror for -Wdeprecated-declarations.
(grub_guess_root_devices) [CYGWIN || MINGW32]: #ifdef-out.
(get_dm_uuid) [!HAVE_DEVICE_MAPPER]: Likewise.
(grub_util_get_dm_abstraction) [! __linux__]: #ifdef-out.
(grub_util_get_grub_dev): Make luks handling dependent on
HAVE_DEVICE_MAPPER and not __linux__.
(get_win32_path): Fix format security.
(grub_find_zpool_from_dir) [CYGWIN || MINGW32]: #ifdef-out.
(grub_make_system_path_relative_to_its_root) [CYGWIN || MINGW32]:
Don't try grub_find_zpool_from_dir.
(grub_make_system_path_relative_to_its_root) [!__linux__]:
#ifdef-out paresdir.
2012-03-02 Vladimir Serbinenko <phcoder@gmail.com> 2012-03-02 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-pe2elf.c (usage): Add missing noreturn. * util/grub-pe2elf.c (usage): Add missing noreturn.

View file

@ -172,6 +172,8 @@ struct btrfs_ioctl_fs_info_args
struct btrfs_ioctl_fs_info_args) struct btrfs_ioctl_fs_info_args)
#endif #endif
#if ! defined(__CYGWIN__)
static void static void
strip_extra_slashes (char *dir) strip_extra_slashes (char *dir)
{ {
@ -211,6 +213,10 @@ xgetcwd (void)
return path; return path;
} }
#endif
#if !defined (__MINGW32__) && !defined (__CYGWIN__)
static pid_t static pid_t
exec_pipe (char **argv, int *fd) exec_pipe (char **argv, int *fd)
{ {
@ -414,6 +420,8 @@ find_root_devices_from_poolname (char *poolname)
return devices; return devices;
} }
#endif
#ifdef __linux__ #ifdef __linux__
#define ESCAPED_PATH_MAX (4 * PATH_MAX) #define ESCAPED_PATH_MAX (4 * PATH_MAX)
@ -652,6 +660,8 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
#endif /* __linux__ */ #endif /* __linux__ */
#if !defined (__MINGW32__) && !defined (__CYGWIN__)
static char ** static char **
find_root_devices_from_libzfs (const char *dir) find_root_devices_from_libzfs (const char *dir)
{ {
@ -672,6 +682,8 @@ find_root_devices_from_libzfs (const char *dir)
return devices; return devices;
} }
#endif
#ifdef __MINGW32__ #ifdef __MINGW32__
char * char *
@ -858,6 +870,8 @@ get_bootsec_serial (const char *os_dev, int mbr)
return serial; return serial;
} }
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
char * char *
grub_find_device (const char *path, dev_t dev) grub_find_device (const char *path, dev_t dev)
{ {
@ -976,8 +990,10 @@ grub_guess_root_devices (const char *dir)
os_dev = grub_find_root_devices_from_mountinfo (dir, NULL); os_dev = grub_find_root_devices_from_mountinfo (dir, NULL);
#endif /* __linux__ */ #endif /* __linux__ */
#if !defined (__MINGW32__) && !defined (__CYGWIN__)
if (!os_dev) if (!os_dev)
os_dev = find_root_devices_from_libzfs (dir); os_dev = find_root_devices_from_libzfs (dir);
#endif
if (os_dev) if (os_dev)
{ {
@ -1080,19 +1096,18 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
#endif #endif
#ifdef HAVE_DEVICE_MAPPER
static char * static char *
get_dm_uuid (const char *os_dev) get_dm_uuid (const char *os_dev)
{ {
if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
return NULL;
#ifdef HAVE_DEVICE_MAPPER
{
struct dm_tree *tree; struct dm_tree *tree;
struct dm_tree_node *node; struct dm_tree_node *node;
const char *node_uuid; const char *node_uuid;
char *ret; char *ret;
if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
return NULL;
if (!grub_util_open_dm (os_dev, &tree, &node)) if (!grub_util_open_dm (os_dev, &tree, &node))
return NULL; return NULL;
@ -1109,11 +1124,10 @@ get_dm_uuid (const char *os_dev)
dm_tree_free (tree); dm_tree_free (tree);
return ret; return ret;
} }
#endif #endif
return NULL; #ifdef __linux__
}
static enum grub_dev_abstraction_types static enum grub_dev_abstraction_types
grub_util_get_dm_abstraction (const char *os_dev) grub_util_get_dm_abstraction (const char *os_dev)
@ -1146,6 +1160,8 @@ grub_util_get_dm_abstraction (const char *os_dev)
#endif #endif
} }
#endif
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <libgeom.h> #include <libgeom.h>
@ -2270,8 +2286,8 @@ grub_util_get_grub_dev (const char *os_dev)
break; break;
#endif #endif
#ifdef __linux__
case GRUB_DEV_ABSTRACTION_LUKS: case GRUB_DEV_ABSTRACTION_LUKS:
#ifdef HAVE_DEVICE_MAPPER
{ {
char *uuid, *dash; char *uuid, *dash;
uuid = get_dm_uuid (os_dev); uuid = get_dm_uuid (os_dev);
@ -2284,8 +2300,8 @@ grub_util_get_grub_dev (const char *os_dev)
uuid + sizeof ("CRYPT-LUKS1-") - 1); uuid + sizeof ("CRYPT-LUKS1-") - 1);
grub_free (uuid); grub_free (uuid);
} }
break;
#endif #endif
break;
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
case GRUB_DEV_ABSTRACTION_GELI: case GRUB_DEV_ABSTRACTION_GELI:
@ -2487,7 +2503,7 @@ get_win32_path (const char *path)
{ {
char winpath[PATH_MAX]; char winpath[PATH_MAX];
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath))) if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
grub_util_error (_("cygwin_conv_path() failed")); grub_util_error ("%s", _("cygwin_conv_path() failed"));
int len = strlen (winpath); int len = strlen (winpath);
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0); int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
@ -2524,6 +2540,7 @@ grub_get_libzfs_handle (void)
} }
#endif /* HAVE_LIBZFS */ #endif /* HAVE_LIBZFS */
#if !defined (__MINGW32__) && !defined (__CYGWIN__)
/* ZFS has similar problems to those of btrfs (see above). */ /* ZFS has similar problems to those of btrfs (see above). */
void void
grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs) grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
@ -2584,6 +2601,7 @@ grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
else else
*poolfs = xstrdup (""); *poolfs = xstrdup ("");
} }
#endif
/* This function never prints trailing slashes (so that its output /* This function never prints trailing slashes (so that its output
can be appended a slash unconditionally). */ can be appended a slash unconditionally). */
@ -2603,10 +2621,12 @@ grub_make_system_path_relative_to_its_root (const char *path)
grub_util_error (_("failed to get canonical path of %s"), path); grub_util_error (_("failed to get canonical path of %s"), path);
/* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */ /* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */
#if !defined (__MINGW32__) && !defined (__CYGWIN__)
{ {
char *dummy; char *dummy;
grub_find_zpool_from_dir (p, &dummy, &poolfs); grub_find_zpool_from_dir (p, &dummy, &poolfs);
} }
#endif
len = strlen (p) + 1; len = strlen (p) + 1;
buf = xstrdup (p); buf = xstrdup (p);
@ -2708,7 +2728,9 @@ grub_make_system_path_relative_to_its_root (const char *path)
} }
#endif #endif
#ifdef __linux__
parsedir: parsedir:
#endif
/* Remove trailing slashes, return empty string if root directory. */ /* Remove trailing slashes, return empty string if root directory. */
len = strlen (buf3); len = strlen (buf3);
while (len > 0 && buf3[len - 1] == '/') while (len > 0 && buf3[len - 1] == '/')