Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add hacky symlink support

Add somewhat hacky support for handling symlinks on UEFI filesystems.
  • Loading branch information...
commit 80fb290102a8d667687766ec52b25402b746ee5c 1 parent 40e34cb
authored April 16, 2012 vathpela committed April 16, 2012

Showing 1 changed file with 34 additions and 0 deletions. Show diff stats Hide diff stats

  1. 34  stage2/fsys_uefi.c
34  stage2/fsys_uefi.c
@@ -129,6 +129,7 @@ uefi_dir (char *dirname)
129 129
       grub_printf(" ");
130 130
     }
131 131
   } else {
  132
+    char *data = NULL;
132 133
     dir_name_w = grub_malloc (2 * dirlen + 2);
133 134
     if (!dir_name_w)
134 135
       goto done;
@@ -174,6 +175,39 @@ uefi_dir (char *dirname)
174 175
 	break;
175 176
     }
176 177
 
  178
+    if (fileinfo->filesize < 256 && fileinfo->filesize > 3)
  179
+      {
  180
+	data = grub_malloc(fileinfo->filesize);
  181
+	filepos = 0;
  182
+
  183
+	uefi_read(data, fileinfo->filesize);
  184
+
  185
+	/*
  186
+	 * UEFI doesn't really support symlinks. Apple's UEFI driver exposes
  187
+	 * them as files containing the path of the target. This provides
  188
+	 * hacky support in the absence of a real driver.
  189
+	 */
  190
+	if (data[0] == '.' && data[1] == '.' && data[2] == '/')
  191
+	  {
  192
+	    int j;
  193
+	    char *tmpdir = grub_malloc(dirlen + fileinfo->filesize);
  194
+
  195
+	    for (j=0; j<dirlen+1; j++)
  196
+	      tmpdir[j] = dirname[j];
  197
+	    for (j=0; j<fileinfo->filesize; j++)
  198
+	      tmpdir[j+dirlen+1] = data[j];
  199
+	    tmpdir[j+dirlen+1] = '\0';
  200
+
  201
+	    /* Open the new file */
  202
+	    ret = uefi_dir(tmpdir);
  203
+	    grub_free (tmpdir);
  204
+	    grub_free (data);
  205
+	    goto done;
  206
+	  }
  207
+      }
  208
+
  209
+    if (data)
  210
+      grub_free(data);
177 211
     ret = 1;
178 212
     filemax = fileinfo->filesize;
179 213
     filepos = 0;

0 notes on commit 80fb290

Please sign in to comment.
Something went wrong with that request. Please try again.