+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>
* util/grub-pe2elf.c (usage): Add missing noreturn.
struct btrfs_ioctl_fs_info_args)
#endif
+#if ! defined(__CYGWIN__)
+
static void
strip_extra_slashes (char *dir)
{
return path;
}
+#endif
+
+#if !defined (__MINGW32__) && !defined (__CYGWIN__)
+
static pid_t
exec_pipe (char **argv, int *fd)
{
return devices;
}
+#endif
+
#ifdef __linux__
#define ESCAPED_PATH_MAX (4 * PATH_MAX)
#endif /* __linux__ */
+#if !defined (__MINGW32__) && !defined (__CYGWIN__)
+
static char **
find_root_devices_from_libzfs (const char *dir)
{
return devices;
}
+#endif
+
#ifdef __MINGW32__
char *
return serial;
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+
char *
grub_find_device (const char *path, dev_t dev)
{
os_dev = grub_find_root_devices_from_mountinfo (dir, NULL);
#endif /* __linux__ */
+#if !defined (__MINGW32__) && !defined (__CYGWIN__)
if (!os_dev)
os_dev = find_root_devices_from_libzfs (dir);
+#endif
if (os_dev)
{
#endif
+#ifdef HAVE_DEVICE_MAPPER
static char *
get_dm_uuid (const char *os_dev)
{
+ struct dm_tree *tree;
+ struct dm_tree_node *node;
+ const char *node_uuid;
+ char *ret;
+
if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
return NULL;
-#ifdef HAVE_DEVICE_MAPPER
- {
- struct dm_tree *tree;
- struct dm_tree_node *node;
- const char *node_uuid;
- char *ret;
+ if (!grub_util_open_dm (os_dev, &tree, &node))
+ return NULL;
- if (!grub_util_open_dm (os_dev, &tree, &node))
+ node_uuid = dm_tree_node_get_uuid (node);
+ if (! node_uuid)
+ {
+ grub_dprintf ("hostdisk", "%s has no DM uuid\n", os_dev);
+ dm_tree_free (tree);
return NULL;
+ }
- node_uuid = dm_tree_node_get_uuid (node);
- if (! node_uuid)
- {
- grub_dprintf ("hostdisk", "%s has no DM uuid\n", os_dev);
- dm_tree_free (tree);
- return NULL;
- }
-
- ret = grub_strdup (node_uuid);
+ ret = grub_strdup (node_uuid);
- dm_tree_free (tree);
+ dm_tree_free (tree);
- return ret;
- }
+ return ret;
+}
#endif
- return NULL;
-}
+#ifdef __linux__
static enum grub_dev_abstraction_types
grub_util_get_dm_abstraction (const char *os_dev)
#endif
}
+#endif
+
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <libgeom.h>
break;
#endif
-#ifdef __linux__
case GRUB_DEV_ABSTRACTION_LUKS:
+#ifdef HAVE_DEVICE_MAPPER
{
char *uuid, *dash;
uuid = get_dm_uuid (os_dev);
uuid + sizeof ("CRYPT-LUKS1-") - 1);
grub_free (uuid);
}
- break;
#endif
+ break;
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
case GRUB_DEV_ABSTRACTION_GELI:
{
char winpath[PATH_MAX];
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 offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
}
#endif /* HAVE_LIBZFS */
+#if !defined (__MINGW32__) && !defined (__CYGWIN__)
/* ZFS has similar problems to those of btrfs (see above). */
void
grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
else
*poolfs = xstrdup ("");
}
+#endif
/* This function never prints trailing slashes (so that its output
can be appended a slash unconditionally). */
grub_util_error (_("failed to get canonical path of %s"), path);
/* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */
+#if !defined (__MINGW32__) && !defined (__CYGWIN__)
{
char *dummy;
grub_find_zpool_from_dir (p, &dummy, &poolfs);
}
+#endif
len = strlen (p) + 1;
buf = xstrdup (p);
}
#endif
+#ifdef __linux__
parsedir:
+#endif
/* Remove trailing slashes, return empty string if root directory. */
len = strlen (buf3);
while (len > 0 && buf3[len - 1] == '/')