All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH v3 2/3] i386: Add support for loading from android bootimg
Date: Fri, 12 Feb 2016 18:50:24 +0100	[thread overview]
Message-ID: <56BE1B60.5060900@gmail.com> (raw)
In-Reply-To: <1454964459-28213-3-git-send-email-shea@shealevy.com>

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

On 08.02.2016 21:47, Shea Levy wrote:
> ---
>  grub-core/loader/i386/linux.c | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
> index fddcc46..6ab8d3c 100644
> --- a/grub-core/loader/i386/linux.c
> +++ b/grub-core/loader/i386/linux.c
> @@ -35,6 +35,7 @@
>  #include <grub/i18n.h>
>  #include <grub/lib/cmdline.h>
>  #include <grub/linux.h>
> +#include <grub/android_bootimg.h>
>  
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
> @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
>        goto fail;
>      }
>  
> -  file = grub_file_open (argv[0]);
> +  char android_cmdline[BOOT_ARGS_SIZE];
> +  android_cmdline[0] = '\0';
> +  if (grub_memcmp (argv[0], "android_bootimg:", sizeof "android_bootimg:" - 1) == 0)
> +    grub_android_bootimg_load_kernel (argv[0] + sizeof "android_bootimg:" - 1,
> +                                      &file, android_cmdline);
> +  else
> +      file = grub_file_open (argv[0]);
I hoped more for autodetection. This gets a bit hairy and proper
separation is better. Sorry for confusion. I think it's simpler with
commands like
android_bootimg [--no-cmdline] [--no-initrd] IMAGE [EXTRA_ARGUMENTS]
by default it will load both IMAGE, with cmdline and initrd. With
--no-initrd you can use initrd for custom initrd.
>    if (! file)
>      goto fail;
>  
> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
>    linux_cmdline = grub_zalloc (maximal_cmdline_size + 1);
>    if (!linux_cmdline)
>      goto fail;
> -  grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE));
> +  grub_size_t cmdline_offset = 0;
> +  if (android_cmdline[0])
> +    {
> +      cmdline_offset = grub_strlen (android_cmdline) + 1;
> +      grub_memcpy (linux_cmdline, android_cmdline, cmdline_offset - 1);
> +      linux_cmdline[cmdline_offset - 1] = ' ';
> +    }
> +  grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE, sizeof (LINUX_IMAGE));
> +  cmdline_offset += sizeof LINUX_IMAGE - 1;
LINUX_IMAGE must be at the beginning. don't forget brackets around sizeof.
>    grub_create_loader_cmdline (argc, argv,
> -			      linux_cmdline
> -			      + sizeof (LINUX_IMAGE) - 1,
> -			      maximal_cmdline_size
> -			      - (sizeof (LINUX_IMAGE) - 1));
> +                              linux_cmdline
> +                              + cmdline_offset,
> +                              maximal_cmdline_size
> +                              - cmdline_offset);
>  
>    len = prot_file_size;
>    if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno)
> 



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

  reply	other threads:[~2016-02-12 17:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 20:47 [PATCH v3 0/3] Android bootimg support Shea Levy
2016-02-08 20:47 ` [PATCH v3 1/3] Add helper functions to interact with android bootimg disks Shea Levy
2016-02-12 17:42   ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-12 17:53     ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-08 20:47 ` [PATCH v3 2/3] i386: Add support for loading from android bootimg Shea Levy
2016-02-12 17:50   ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2016-02-12 19:19     ` Shea Levy
2016-02-12 19:22       ` Vladimir 'phcoder' Serbinenko
2016-02-12 19:34         ` Shea Levy
2016-02-12 21:16           ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-13 10:32             ` Andrei Borzenkov
2016-02-14 13:21             ` Shea Levy
2016-02-14 13:26               ` Vladimir 'phcoder' Serbinenko
2016-02-14 17:20                 ` Andrei Borzenkov
2016-02-14 20:58                 ` Seth Goldberg
2016-02-15  3:41                   ` Andrei Borzenkov
2016-02-15  4:13                     ` Seth Goldberg
2016-02-15 10:55                     ` Vladimir 'phcoder' Serbinenko
2016-02-08 20:47 ` [PATCH v3 3/3] Add support for loading initrd " Shea Levy

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=56BE1B60.5060900@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.