* util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root):
Remove broken Cygwin path conversion. * util/misc.c: [__CYGWIN__] Add include and define. [__CYGWIN__] (get_win32_path): Copy function from getroot.c, modify for Cygwin 1.7. (make_system_path_relative_to_its_root): Simplify loop, replace early return by break. [__CYGWIN__] Add conversion to win32 path. Include "/" case in trailing slash removal.
This commit is contained in:
parent
3558c6e93c
commit
d1b61374ed
3 changed files with 58 additions and 33 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2010-05-01 Christian Franke <franke@computer.org>
|
||||||
|
|
||||||
|
* util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root):
|
||||||
|
Remove broken Cygwin path conversion.
|
||||||
|
* util/misc.c: [__CYGWIN__] Add include and define.
|
||||||
|
[__CYGWIN__] (get_win32_path): Copy function from getroot.c, modify
|
||||||
|
for Cygwin 1.7.
|
||||||
|
(make_system_path_relative_to_its_root): Simplify loop, replace early
|
||||||
|
return by break.
|
||||||
|
[__CYGWIN__] Add conversion to win32 path.
|
||||||
|
Include "/" case in trailing slash removal.
|
||||||
|
|
||||||
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* kern/main.c (grub_load_config): Fix copy-pasted comment.
|
* kern/main.c (grub_load_config): Fix copy-pasted comment.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Helper library for grub-mkconfig
|
# Helper library for grub-mkconfig
|
||||||
# Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
|
# Copyright (C) 2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# GRUB is free software: you can redistribute it and/or modify
|
# GRUB is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -44,21 +44,7 @@ grub_warn ()
|
||||||
|
|
||||||
make_system_path_relative_to_its_root ()
|
make_system_path_relative_to_its_root ()
|
||||||
{
|
{
|
||||||
path="`${grub_mkrelpath} $1`"
|
${grub_mkrelpath} $1
|
||||||
|
|
||||||
case "`uname 2>/dev/null`" in
|
|
||||||
CYGWIN*)
|
|
||||||
# Cygwin: Check if regular or emulated mount.
|
|
||||||
if [ -z "$dir" ] || [ "`stat -c %D "$dir/.."`" != 620000 ] ; then
|
|
||||||
# Reached some mount point not below /cygdrive.
|
|
||||||
# GRUB does not know Cygwin's emulated mounts,
|
|
||||||
# convert to Win32 path and remove drive letter.
|
|
||||||
path=`cygpath -m "$path" | sed -n 's,^[A-Za-z]:,,p'`
|
|
||||||
test ! -z "$path" || return 1
|
|
||||||
fi ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "$path"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_path_readable_by_grub ()
|
is_path_readable_by_grub ()
|
||||||
|
|
61
util/misc.c
61
util/misc.c
|
@ -53,6 +53,11 @@
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
# include <sys/cygwin.h>
|
||||||
|
# define DEV_CYGDRIVE_MAJOR 98
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
@ -456,6 +461,27 @@ 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
|
||||||
|
|
||||||
/* 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). */
|
||||||
char *
|
char *
|
||||||
|
@ -521,30 +547,31 @@ make_system_path_relative_to_its_root (const char *path)
|
||||||
/* offset == 1 means root directory. */
|
/* offset == 1 means root directory. */
|
||||||
if (offset == 1)
|
if (offset == 1)
|
||||||
{
|
{
|
||||||
free (buf);
|
/* Include leading slash. */
|
||||||
len = strlen (buf2);
|
offset = 0;
|
||||||
while (buf2[len - 1] == '/' && len > 1)
|
break;
|
||||||
{
|
|
||||||
buf2[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
if (len > 1)
|
|
||||||
return buf2;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This means path given is just a backslash. As above
|
|
||||||
we have to return an empty string. */
|
|
||||||
free (buf2);
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (buf);
|
free (buf);
|
||||||
buf3 = xstrdup (buf2 + offset);
|
buf3 = xstrdup (buf2 + offset);
|
||||||
free (buf2);
|
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
|
||||||
|
|
||||||
|
/* Remove trailing slashes, return empty string if root directory. */
|
||||||
len = strlen (buf3);
|
len = strlen (buf3);
|
||||||
while (buf3[len - 1] == '/' && len > 1)
|
while (len > 0 && buf3[len - 1] == '/')
|
||||||
{
|
{
|
||||||
buf3[len - 1] = '\0';
|
buf3[len - 1] = '\0';
|
||||||
len--;
|
len--;
|
||||||
|
|
Loading…
Reference in a new issue