All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH 1/2] efidisk: move device path helpers in core for efinet
Date: Thu, 07 May 2015 16:53:41 +0200	[thread overview]
Message-ID: <554B7C75.9090401@gmail.com> (raw)
In-Reply-To: <1429430471-7229-1-git-send-email-arvidjaar@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 7149 bytes --]

Go ahead
On 19.04.2015 10:01, Andrei Borzenkov wrote:
> ---
>  grub-core/disk/efi/efidisk.c | 61 ++++++++------------------------------------
>  grub-core/kern/efi/efi.c     | 41 +++++++++++++++++++++++++++++
>  include/grub/efi/efi.h       |  4 +++
>  3 files changed, 55 insertions(+), 51 deletions(-)
> 
> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> index 60a6d3c..a8783a3 100644
> --- a/grub-core/disk/efi/efidisk.c
> +++ b/grub-core/disk/efi/efidisk.c
> @@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices;
>  static struct grub_efidisk_data *hd_devices;
>  static struct grub_efidisk_data *cd_devices;
>  
> -/* Duplicate a device path.  */
> -static grub_efi_device_path_t *
> -duplicate_device_path (const grub_efi_device_path_t *dp)
> -{
> -  grub_efi_device_path_t *p;
> -  grub_size_t total_size = 0;
> -
> -  for (p = (grub_efi_device_path_t *) dp;
> -       ;
> -       p = GRUB_EFI_NEXT_DEVICE_PATH (p))
> -    {
> -      total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
> -      if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
> -	break;
> -    }
> -
> -  p = grub_malloc (total_size);
> -  if (! p)
> -    return 0;
> -
> -  grub_memcpy (p, dp, total_size);
> -  return p;
> -}
> -
> -/* Return the device path node right before the end node.  */
> -static grub_efi_device_path_t *
> -find_last_device_path (const grub_efi_device_path_t *dp)
> -{
> -  grub_efi_device_path_t *next, *p;
> -
> -  if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
> -    return 0;
> -
> -  for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
> -       ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
> -       p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
> -    ;
> -
> -  return p;
> -}
> -
>  static struct grub_efidisk_data *
>  make_devices (void)
>  {
> @@ -110,7 +69,7 @@ make_devices (void)
>        if (! dp)
>  	continue;
>  
> -      ldp = find_last_device_path (dp);
> +      ldp = grub_efi_find_last_device_path (dp);
>        if (! ldp)
>  	/* This is empty. Why?  */
>  	continue;
> @@ -150,11 +109,11 @@ find_parent_device (struct grub_efidisk_data *devices,
>    grub_efi_device_path_t *dp, *ldp;
>    struct grub_efidisk_data *parent;
>  
> -  dp = duplicate_device_path (d->device_path);
> +  dp = grub_efi_duplicate_device_path (d->device_path);
>    if (! dp)
>      return 0;
>  
> -  ldp = find_last_device_path (dp);
> +  ldp = grub_efi_find_last_device_path (dp);
>    ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
>    ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
>    ldp->length = sizeof (*ldp);
> @@ -180,11 +139,11 @@ is_child (struct grub_efidisk_data *child,
>    grub_efi_device_path_t *dp, *ldp;
>    int ret;
>  
> -  dp = duplicate_device_path (child->device_path);
> +  dp = grub_efi_duplicate_device_path (child->device_path);
>    if (! dp)
>      return 0;
>  
> -  ldp = find_last_device_path (dp);
> +  ldp = grub_efi_find_last_device_path (dp);
>    ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
>    ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
>    ldp->length = sizeof (*ldp);
> @@ -207,8 +166,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
>      {
>        int ret;
>  
> -      ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path),
> -					   find_last_device_path (d->device_path));
> +      ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path),
> +					   grub_efi_find_last_device_path (d->device_path));
>        if (ret == 0)
>  	ret = grub_efi_compare_device_paths ((*p)->device_path,
>  					     d->device_path);
> @@ -795,7 +754,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
>    if (! dp)
>      return 0;
>  
> -  ldp = find_last_device_path (dp);
> +  ldp = grub_efi_find_last_device_path (dp);
>    if (! ldp)
>      return 0;
>  
> @@ -810,14 +769,14 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
>  
>        /* It is necessary to duplicate the device path so that GRUB
>  	 can overwrite it.  */
> -      dup_dp = duplicate_device_path (dp);
> +      dup_dp = grub_efi_duplicate_device_path (dp);
>        if (! dup_dp)
>  	return 0;
>  
>        while (1)
>  	{
>  	  grub_efi_device_path_t *dup_ldp;
> -	  dup_ldp = find_last_device_path (dup_dp);
> +	  dup_ldp = grub_efi_find_last_device_path (dup_dp);
>  	  if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
>  		&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
>  		    || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
> diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
> index b9eb1ab..49a1501 100644
> --- a/grub-core/kern/efi/efi.c
> +++ b/grub-core/kern/efi/efi.c
> @@ -394,6 +394,47 @@ grub_efi_get_device_path (grub_efi_handle_t handle)
>  				 GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
>  }
>  
> +/* Return the device path node right before the end node.  */
> +grub_efi_device_path_t *
> +grub_efi_find_last_device_path (const grub_efi_device_path_t *dp)
> +{
> +  grub_efi_device_path_t *next, *p;
> +
> +  if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
> +    return 0;
> +
> +  for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
> +       ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
> +       p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
> +    ;
> +
> +  return p;
> +}
> +
> +/* Duplicate a device path.  */
> +grub_efi_device_path_t *
> +grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp)
> +{
> +  grub_efi_device_path_t *p;
> +  grub_size_t total_size = 0;
> +
> +  for (p = (grub_efi_device_path_t *) dp;
> +       ;
> +       p = GRUB_EFI_NEXT_DEVICE_PATH (p))
> +    {
> +      total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
> +      if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
> +	break;
> +    }
> +
> +  p = grub_malloc (total_size);
> +  if (! p)
> +    return 0;
> +
> +  grub_memcpy (p, dp, total_size);
> +  return p;
> +}
> +
>  static void
>  dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
>  {
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index 489cf9e..0e6fd86 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -53,6 +53,10 @@ void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
>  char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
>  grub_efi_device_path_t *
>  EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
> +grub_efi_device_path_t *
> +EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp);
> +grub_efi_device_path_t *
> +EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp);
>  grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf,
>  							grub_efi_uintn_t *map_key,
>  							grub_efi_uintn_t *efi_desc_size,
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

      parent reply	other threads:[~2015-05-07 14:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-19  8:01 [PATCH 1/2] efidisk: move device path helpers in core for efinet Andrei Borzenkov
2015-04-19  8:01 ` [PATCH 2/2] efinet: fix lost packets due to active MNP instances Andrei Borzenkov
2015-04-20  6:30   ` Michael Chang
2015-04-21  6:12     ` [edk2] " Michael Chang
2015-04-21  6:49       ` Michael Chang
2015-04-21 12:30         ` Laszlo Ersek
2015-04-22  9:57           ` Michael Chang
2015-04-22 10:50             ` Laszlo Ersek
2015-04-25 14:12       ` Andrei Borzenkov
2015-04-27  6:42         ` Michael Chang
2015-04-29 13:47         ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-05-07 17:39           ` Andrei Borzenkov
2015-04-26  6:42       ` Andrei Borzenkov
2015-04-26 10:44         ` Andrei Borzenkov
2015-04-27  6:47         ` Michael Chang
2015-04-28  6:03           ` Michael Chang
2015-04-28  8:45             ` Michael Chang
2015-04-29 15:42 ` [PATCH 1/2] efidisk: move device path helpers in core for efinet Vladimir 'phcoder' Serbinenko
2015-05-07 14:53 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=554B7C75.9090401@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.