From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1O6LP0-00053r-GU for mharc-grub-devel@gnu.org; Mon, 26 Apr 2010 06:18:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6LOw-00053Q-99 for grub-devel@gnu.org; Mon, 26 Apr 2010 06:18:54 -0400 Received: from [140.186.70.92] (port=43760 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6LOu-00053H-OK for grub-devel@gnu.org; Mon, 26 Apr 2010 06:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6LOs-0001aw-Gb for grub-devel@gnu.org; Mon, 26 Apr 2010 06:18:52 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:53178) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6LOs-0001an-5O for grub-devel@gnu.org; Mon, 26 Apr 2010 06:18:50 -0400 Received: from fwd06.aul.t-online.de (fwd06.aul.t-online.de ) by mailout06.t-online.de with smtp id 1O6LOq-0002lO-B8; Mon, 26 Apr 2010 12:18:48 +0200 Received: from [192.168.2.100] (JJXHaZZGrhsI3lbFs6IzSYuIC+YA+pbmDiX-lRDt4QygthYag4YGPBpnI5GFHGVgqh@[217.235.238.121]) by fwd06.aul.t-online.de with esmtp id 1O6LOf-1EpFAm0; Mon, 26 Apr 2010 12:18:37 +0200 Message-ID: <4BD5687C.1020507@t-online.de> Date: Mon, 26 Apr 2010 12:18:36 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 SeaMonkey/2.0.4 MIME-Version: 1.0 To: The development of GNU GRUB References: <4BC60B1D.8080609@t-online.de> <4BD4F04D.8030005@gmail.com> <4BD52EE8.5020403@t-online.de> <4BD53918.9030609@gmail.com> In-Reply-To: <4BD53918.9030609@gmail.com> Content-Type: multipart/mixed; boundary="------------050708050004090009000703" X-ID: JJXHaZZGrhsI3lbFs6IzSYuIC+YA+pbmDiX-lRDt4QygthYag4YGPBpnI5GFHGVgqh X-TOI-MSGID: 1925c25a-62f9-4340-9760-29630c5325f1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: [PATCH] Fix Cygwin path handling X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2010 10:18:55 -0000 This is a multi-part message in MIME format. --------------050708050004090009000703 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > I actually seen the '/' case and have incorrectly assumed it's always > so. However there is still one case when you patch changes the behaviour: > $ grub-mkrelpath / > > $ ./grub-mkrelpath / > / > Although: > $ ./grub-mkrelpath /mnt/boot/ > > $ grub-mkrelpath /mnt/boot/ > > > I actually did not test the "/" corner case, sorry. New patch attached. -- Regards, Christian Franke --------------050708050004090009000703 Content-Type: text/x-diff; name="grub2-cygwin-path-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub2-cygwin-path-2.patch" === modified file 'ChangeLog' --- ChangeLog 2010-04-26 01:35:55 +0000 +++ ChangeLog 2010-04-26 09:44:43 +0000 @@ -1,5 +1,17 @@ 2010-04-26 Christian Franke + * 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-04-26 Christian Franke + * include/grub/util/getroot.h (grub_get_prefix): Remove prototype. * util/getroot.c [__CYGWIN__] (get_win32_path): Remove function. (grub_get_prefix): Remove function. === modified file 'util/grub-mkconfig_lib.in' --- util/grub-mkconfig_lib.in 2010-04-19 19:25:41 +0000 +++ util/grub-mkconfig_lib.in 2010-04-26 08:59:10 +0000 @@ -1,5 +1,5 @@ # 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 # it under the terms of the GNU General Public License as published by @@ -44,21 +44,7 @@ make_system_path_relative_to_its_root () { - path="`${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" + ${grub_mkrelpath} $1 } is_path_readable_by_grub () === modified file 'util/misc.c' --- util/misc.c 2010-04-09 23:25:46 +0000 +++ util/misc.c 2010-04-26 10:08:04 +0000 @@ -53,6 +53,11 @@ # include #endif +#ifdef __CYGWIN__ +# include +# define DEV_CYGDRIVE_MAJOR 98 +#endif + #ifdef __MINGW32__ #include #include @@ -456,6 +461,27 @@ 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 can be appended a slash unconditionally). */ char * @@ -521,30 +547,31 @@ /* offset == 1 means root directory. */ if (offset == 1) { - free (buf); - len = strlen (buf2); - while (buf2[len - 1] == '/' && len > 1) - { - 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 (""); - } + /* Include leading slash. */ + offset = 0; + break; } } free (buf); buf3 = xstrdup (buf2 + offset); 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); - while (buf3[len - 1] == '/' && len > 1) + while (len > 0 && buf3[len - 1] == '/') { buf3[len - 1] = '\0'; len--; --------------050708050004090009000703--