Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1O3Y0f-0005eR-7X for mharc-grub-devel@gnu.org; Sun, 18 Apr 2010 13:10:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3Y0d-0005e5-M2 for grub-devel@gnu.org; Sun, 18 Apr 2010 13:10:15 -0400 Received: from [140.186.70.92] (port=53021 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3Y0X-0005cl-Dh for grub-devel@gnu.org; Sun, 18 Apr 2010 13:10:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3Y0Q-0006Sr-US for grub-devel@gnu.org; Sun, 18 Apr 2010 13:10:09 -0400 Received: from mailout03.t-online.de ([194.25.134.81]:49654) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3Y0Q-0006Qj-Hc for grub-devel@gnu.org; Sun, 18 Apr 2010 13:10:02 -0400 Received: from fwd01.aul.t-online.de (fwd01.aul.t-online.de ) by mailout03.t-online.de with smtp id 1O3Y0E-0002Jz-NW; Sun, 18 Apr 2010 19:09:50 +0200 Received: from [192.168.2.100] (JbvqJwZrQhnWZ9pfwWejeOzM8tMw6SqPjnk0BPGHcjzFJI0lrJyO1B4MvNmr4-YQp0@[217.235.239.48]) by fwd01.aul.t-online.de with esmtp id 1O3Y05-0cKwkq0; Sun, 18 Apr 2010 19:09:41 +0200 Message-ID: <4BCB3CD6.8030900@t-online.de> Date: Sun, 18 Apr 2010 19:09:42 +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: grub-devel@gnu.org Content-Type: multipart/mixed; boundary="------------030801020805090808060703" X-ID: JbvqJwZrQhnWZ9pfwWejeOzM8tMw6SqPjnk0BPGHcjzFJI0lrJyO1B4MvNmr4-YQp0 X-TOI-MSGID: 3ab5bd16-46f6-416e-91ed-4dffcb87199c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Remove grub_get_prefix() 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: Sun, 18 Apr 2010 17:10:15 -0000 This is a multi-part message in MIME format. --------------030801020805090808060703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This patch removes grub_get_prefix() and replaces the two remaining calls with make_system_path_relative_to_its_root(). Already discussed in thread "[PATCH] Fix Cygwin path handling". Change in util/grub-emu.c was tested, but not the change in util/sparc64/ieee1275/grub-setup.c. -- Regards, Christian Franke --------------030801020805090808060703 Content-Type: text/x-patch; name="grub2-rm-get_prefix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub2-rm-get_prefix.patch" === modified file 'ChangeLog' --- ChangeLog 2010-04-18 11:00:06 +0000 +++ ChangeLog 2010-04-18 14:39:41 +0000 @@ -1,3 +1,12 @@ +2010-04-18 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. + * util/grub-emu.c (main): Replace grub_get_prefix () call by + make_system_path_relative_to_its_root (). + * util/sparc64/ieee1275/grub-setup.c (main): Likewise. + 2010-04-18 Vladimir Serbinenko * po/POTFILES: Renamed multiboot_loader.c to multiboot.c @@ -10,7 +19,7 @@ * disk/lvm.c (grub_lvm_memberlist): Issue an error if pv->disk = 0. -2010-04-17 Christian Franke +2010-04-17 Christian Franke * Makefile.in: Add missing localedir setting. === modified file 'include/grub/util/getroot.h' --- include/grub/util/getroot.h 2009-04-11 09:40:39 +0000 +++ include/grub/util/getroot.h 2010-04-18 14:19:18 +0000 @@ -26,7 +26,6 @@ }; char *grub_guess_root_device (const char *dir); -char *grub_get_prefix (const char *dir); int grub_util_get_dev_abstraction (const char *os_dev); char *grub_util_get_grub_dev (const char *os_dev); const char *grub_util_check_block_device (const char *blk_dev); === modified file 'util/getroot.c' --- util/getroot.c 2010-04-10 15:07:33 +0000 +++ util/getroot.c 2010-04-18 14:21:03 +0000 @@ -79,103 +79,6 @@ return path; } -#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]; - cygwin_conv_to_full_win32_path (path, winpath); - - int len = strlen (winpath); - if (len > 2 && winpath[1] == ':') - { - len -= 2; - memmove (winpath, winpath + 2, len + 1); - } - - int i; - for (i = 0; i < len; i++) - if (winpath[i] == '\\') - winpath[i] = '/'; - return xstrdup (winpath); -} -#endif - -char * -grub_get_prefix (const char *dir) -{ - char *saved_cwd; - char *abs_dir, *prev_dir; - char *prefix; - struct stat st, prev_st; - - /* Save the current directory. */ - saved_cwd = xgetcwd (); - - if (chdir (dir) < 0) - grub_util_error ("cannot change directory to `%s'", dir); - - abs_dir = xgetcwd (); - strip_extra_slashes (abs_dir); - prev_dir = xstrdup (abs_dir); - - if (stat (".", &prev_st) < 0) - grub_util_error ("cannot stat `%s'", dir); - - if (! S_ISDIR (prev_st.st_mode)) - grub_util_error ("`%s' is not a directory", dir); - - while (1) - { - if (chdir ("..") < 0) - grub_util_error ("cannot change directory to the parent"); - - if (stat (".", &st) < 0) - grub_util_error ("cannot stat current directory"); - - if (! S_ISDIR (st.st_mode)) - grub_util_error ("current directory is not a directory???"); - - if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino) - break; - - free (prev_dir); - prev_dir = xgetcwd (); - prev_st = st; - } - - strip_extra_slashes (prev_dir); - prefix = xmalloc (strlen (abs_dir) - strlen (prev_dir) + 2); - prefix[0] = '/'; - strcpy (prefix + 1, abs_dir + strlen (prev_dir)); - strip_extra_slashes (prefix); - - if (chdir (saved_cwd) < 0) - grub_util_error ("cannot change directory to `%s'", dir); - -#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 prefix = %s", prefix); - char * wprefix = get_win32_path (prefix); - free (prefix); - prefix = wprefix; - } -#endif - - free (saved_cwd); - free (abs_dir); - free (prev_dir); - - grub_util_info ("prefix = %s", prefix); - return prefix; -} - #ifdef __MINGW32__ static char * === modified file 'util/grub-emu.c' --- util/grub-emu.c 2010-02-07 16:52:11 +0000 +++ util/grub-emu.c 2010-04-18 14:38:28 +0000 @@ -242,7 +242,7 @@ if (strcmp (root_dev, "host") == 0) dir = xstrdup (dir); else - dir = grub_get_prefix (dir); + dir = make_system_path_relative_to_its_root (dir); prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1); sprintf (prefix, "(%s)%s", root_dev, dir); free (dir); === modified file 'util/sparc64/ieee1275/grub-setup.c' --- util/sparc64/ieee1275/grub-setup.c 2010-01-16 00:26:52 +0000 +++ util/sparc64/ieee1275/grub-setup.c 2010-04-18 14:38:02 +0000 @@ -635,7 +635,8 @@ find_dest_dev (&ginfo, argv); - ginfo.prefix = grub_get_prefix (ginfo.dir ? : DEFAULT_DIRECTORY); + ginfo.prefix = make_system_path_relative_to_its_root (ginfo.dir ? + : DEFAULT_DIRECTORY); check_root_dev (&ginfo); --------------030801020805090808060703--