]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-01-11 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Mon, 11 Jan 2010 14:55:20 +0000 (14:55 +0000)
committerRobert Millan <rmh@aybabtu.com>
Mon, 11 Jan 2010 14:55:20 +0000 (14:55 +0000)
* util/misc.c (canonicalize_file_name): New function.
(make_system_path_relative_to_its_root): Use canonicalize_file_name()
instead of realpath().

ChangeLog
util/misc.c

index 42343a8b661c6bc8daccc94c6bf543c1bc217a1e..768a65944eb2a2699820c48cfadacda4688b211e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-11  Robert Millan  <rmh.grub@aybabtu.com>
+
+       * util/misc.c (canonicalize_file_name): New function.
+       (make_system_path_relative_to_its_root): Use canonicalize_file_name()
+       instead of realpath().
+
 2010-01-11  Colin Watson  <cjwatson@ubuntu.com>
 
        * util/grub-install.in (usage): Clarify meaning of --root-directory,
index d8aa041bebd5ee1f9ea75e9d6e31e24095c46226..47dd8c78d8b54c18a0ca3d0643e4f3bae90c0d5a 100644 (file)
@@ -479,6 +479,19 @@ fail:
 
 #endif /* __MINGW32__ */
 
+char *
+canonicalize_file_name (const char *path)
+{
+  char *ret;
+#ifdef PATH_MAX
+  ret = xmalloc (PATH_MAX);
+  (void) realpath (path, ret);
+#else
+  ret = realpath (path, NULL);
+#endif
+  return ret;
+}
+
 /* This function never prints trailing slashes (so that its output
    can be appended a slash unconditionally).  */
 char *
@@ -491,15 +504,11 @@ make_system_path_relative_to_its_root (const char *path)
   size_t len;
 
   /* canonicalize.  */
-  p = realpath (path, NULL);
+  p = canonicalize_file_name (path);
 
   if (p == NULL)
-    {
-      if (errno != EINVAL)
-       grub_util_error ("failed to get realpath of %s", path);
-      else
-       grub_util_error ("realpath not supporting (path, NULL)");
-    }
+    grub_util_error ("failed to get canonical path of %s", path);
+
   len = strlen (p) + 1;
   buf = strdup (p);
   free (p);