]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/emu/misc.c
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 23 Oct 2010 18:34:50 +0000 (20:34 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 23 Oct 2010 18:34:50 +0000 (20:34 +0200)
(grub_make_system_path_relative_to_its_root): Revert r2882.

ChangeLog
grub-core/kern/emu/misc.c

index 85ff4d08875e4fb0fbb1b7a127fd8982c11f86cc..bdeb62500cfac81201ca1f4f81aac868fbfb5e07 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-22  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/emu/misc.c
+       (grub_make_system_path_relative_to_its_root): Revert r2882.
+
 2010-10-22  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/lib/relocator.c (grub_relocator_subchunk): Remove now
index cfc143bf9a39c87770809ef1e6627ad913ea01e4..d8db3be9def4c01b0473383e1f0b9166709b9d1d 100644 (file)
@@ -406,7 +406,21 @@ grub_make_system_path_relative_to_its_root (const char *path)
 
       /* buf is another filesystem; we found it.  */
       if (st.st_dev != num)
-       break;
+       {
+         /* offset == 0 means path given is the mount point.
+            This works around special-casing of "/" in Un*x.  This function never
+            prints trailing slashes (so that its output can be appended a slash
+            unconditionally).  Each slash in is considered a preceding slash, and
+            therefore the root directory is an empty string.  */
+         if (offset == 0)
+           {
+             free (buf);
+             free (buf2);
+             return xstrdup ("");
+           }
+         else
+           break;
+       }
 
       offset = p - buf;
       /* offset == 1 means root directory.  */
@@ -434,10 +448,7 @@ grub_make_system_path_relative_to_its_root (const char *path)
     }
 #endif
 
-  /* This works around special-casing of "/" in Un*x.  This function never
-     prints trailing slashes (so that its output can be appended a slash
-     unconditionally).  Each slash in it is considered a preceding slash,
-     and therefore the root directory is an empty string.  */
+  /* Remove trailing slashes, return empty string if root directory.  */
   len = strlen (buf3);
   while (len > 0 && buf3[len - 1] == '/')
     {