示例#1
0
文件: init.c 项目: flihp/grub2
void
grub_machine_get_bootlocation (char **device, char **path)
{
  grub_efi_loaded_image_t *image = NULL;
  char *p;

  image = grub_efi_get_loaded_image (grub_efi_image_handle);
  if (!image)
    return;
  *device = grub_efidisk_get_device_name (image->device_handle);
  if (!*device && grub_efi_net_config)
    {
      grub_efi_net_config (image->device_handle, device, path);
      return;
    }

  *path = grub_efi_get_filename (image->file_path);
  if (*path)
    {
      /* Get the directory.  */
      p = grub_strrchr (*path, '/');
      if (p)
        *p = '\0';
    }
}
示例#2
0
void
grub_efi_set_prefix (void)
{
  grub_efi_loaded_image_t *image = NULL;
  char *device = NULL;
  char *path = NULL;

  {
    char *pptr = NULL;
    if (grub_prefix[0] == '(')
      {
	pptr = grub_strrchr (grub_prefix, ')');
	if (pptr)
	  {
	    device = grub_strndup (grub_prefix + 1, pptr - grub_prefix - 1);
	    pptr++;
	  }
      }
    if (!pptr)
      pptr = grub_prefix;
    if (pptr[0])
      path = grub_strdup (pptr);
  }

  if (!device || !path)
    image = grub_efi_get_loaded_image (grub_efi_image_handle);
  if (image && !device)
    device = grub_efidisk_get_device_name (image->device_handle);

  if (image && !path)
    {
      char *p;

      path = grub_efi_get_filename (image->file_path);

      /* Get the directory.  */
      p = grub_strrchr (path, '/');
      if (p)
	*p = '\0';
    }

  if (device && path)
    {
      char *prefix;

      prefix = grub_xasprintf ("(%s)%s", device, path);
      if (prefix)
	{
	  grub_env_set ("prefix", prefix);
	  grub_free (prefix);
	}
    }

  grub_free (device);
  grub_free (path);
}
示例#3
0
文件: init.c 项目: Firef0x/burg-new
void
grub_efi_set_prefix (void)
{
  grub_efi_loaded_image_t *image;

  image = grub_efi_get_loaded_image (grub_efi_image_handle);
  if (image)
    {
      char *device;
      char *file;
      char *prefix;

      device = grub_efidisk_get_device_name (image->device_handle);
      file = grub_efi_get_filename (image->file_path);

      if (file)
        {
          char *p;

          /* Get the directory.  */
          p = grub_strrchr (file, '/');
          if (p)
            *p = '\0';
        }

      prefix = grub_xasprintf ("(%s)%s", (device) ? device : "net0",
			       (file) ? file : "");

      if (prefix)
        {
          grub_env_set ("prefix", prefix);
          grub_free (prefix);
        }
      grub_free (device);
      grub_free (file);
    }
}