Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aUwcH-000088-6v for mharc-grub-devel@gnu.org; Sun, 14 Feb 2016 08:21:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUwcE-00006s-Fd for grub-devel@gnu.org; Sun, 14 Feb 2016 08:21:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUwcB-0002Yt-8S for grub-devel@gnu.org; Sun, 14 Feb 2016 08:21:30 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:42990 helo=homiemail-a47.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUwcA-0002Yf-WC for grub-devel@gnu.org; Sun, 14 Feb 2016 08:21:27 -0500 Received: from homiemail-a47.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTP id 42084284058 for ; Sun, 14 Feb 2016 05:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=shealevy.com; h= mime-version:content-type:date:from:to:subject:in-reply-to :references:message-id:content-transfer-encoding; s=shealevy.com ; bh=OpcwHJujqv3X4aVbNchbk1O8vJo=; b=PIV5Jfplw32Nf0c6dPStgNQw/CG SGL72MvIOk8EMqRp55+XmLqbkw1AdJ5gL4E3ESs4lvqrbpm/f48pjF8SpNkXJEQE t+AZjy/Z+Ik7VN2FWNeelxWjSLlf2oMmqnEz/qVDAps7BBph8USYRRR5rz2Lq480 B6vkUhp6eVurZB/0= Received: from webmail.shealevy.com (caiajhbihbdd.dreamhost.com [208.97.187.133]) (Authenticated sender: shea@shealevy.com) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTPA id 3CCBF284056 for ; Sun, 14 Feb 2016 05:21:22 -0800 (PST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Sun, 14 Feb 2016 08:21:21 -0500 From: Shea Levy To: Subject: Re: [PATCH v3 2/3] i386: Add support for loading from android bootimg In-Reply-To: <56BE4BB7.6040203@gmail.com> References: <1454964459-28213-1-git-send-email-shea@shealevy.com> <1454964459-28213-3-git-send-email-shea@shealevy.com> <56BE1B60.5060900@gmail.com> <7384a36941a77cced1fde7e3d084280a@shealevy.com> <2b7ecf3a0dda2687029878e0e745bd73@shealevy.com> <56BE4BB7.6040203@gmail.com> Message-ID: X-Sender: shea@shealevy.com User-Agent: Roundcube Webmail/0.8.2 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 208.113.200.129 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2016 13:21:32 -0000 This patch uses grub_file_open, but the android bootimg is a disk, not=20 a file. You mentioned something about file_offset_open, but that also=20 expects an input file, not a disk. Should I modify your patch with my=20 code I wrote to create a grub_file_t from an android_bootimg disk=20 device, or is there another approach? On 2016-02-12 16:16, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: > On 12.02.2016 20:34, Shea Levy wrote: >> OK. Do you have any thoughts on how best to extract the "load the=20 >> kernel >> and set the command line to a specific string" functionality out of=20 >> the >> linux command, then? >> > At first I wanted to write a short skeleton patch to show what I=20 > meant > but once skeleton is done, there is little actual code involved.=20 > Please > try attached patch >> On 2016-02-12 14:22, Vladimir 'phcoder' Serbinenko wrote: >>> Separate command is better as it keeps interface tidy and=20 >>> unpoluted, >>> decreasing maintenance cost. Correct me if I'm wrong but it should=20 >>> be >>> clear from context of file is Android image or usual linux one? >>> >>> Le ven. 12 f=C3=A9vr. 2016 20:19, Shea Levy a =C3= =A9crit=20 >>> : >>> >>>> On 2016-02-12 12:50, Vladimir '=CF=86-coder/phcoder' Serbinenko wrot= e: >>>> > 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 >>>> >> #include >>>> >> #include >>>> >> +#include >>>> >> >>>> >> GRUB_MOD_LICENSE ("GPLv3+"); >>>> >> >>>> >> @@ -695,7 +696,13 @@ grub_cmd_linux (grub_command_t cmd >>>> >> __attribute__ ((unused)), >>>> >> goto fail; >>>> >> } >>>> >> >>>> >> - file =3D grub_file_open (argv[0]); >>>> >> + char android_cmdline[BOOT_ARGS_SIZE]; >>>> >> + android_cmdline[0] =3D ''; >>>> >> + if (grub_memcmp (argv[0], "android_bootimg:", sizeof >>>> >> "android_bootimg:" - 1) =3D=3D 0) >>>> >> + grub_android_bootimg_load_kernel (argv[0] + sizeof >>>> >> "android_bootimg:" - 1, >>>> >> + &file, android_cmdline); >>>> >> + else >>>> >> + file =3D 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=20 >>>> with >>>> > commands like >>>> > android_bootimg [--no-cmdline] [--no-initrd] IMAGE=20 >>>> [EXTRA_ARGUMENTS] >>>> > by default it will load both IMAGE, with cmdline and initrd.=20 >>>> With >>>> > --no-initrd you can use initrd for custom initrd. >>>> >>>> Autodetection would be possible actually, I didn't think of that.=20 >>>> If >>>> grub_file_open fails, we can try grub_android_bootimg_load_kernel=20 >>>> on the >>>> same file. Would that be preferable or do we still want a separate >>>> command? >>>> >>>> > >>>> >> if (! file) >>>> >> goto fail; >>>> >> >>>> >> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd >>>> >> __attribute__ ((unused)), >>>> >> linux_cmdline =3D grub_zalloc (maximal_cmdline_size + 1); >>>> >> if (!linux_cmdline) >>>> >> goto fail; >>>> >> - grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof=20 >>>> (LINUX_IMAGE)); >>>> >> + grub_size_t cmdline_offset =3D 0; >>>> >> + if (android_cmdline[0]) >>>> >> + { >>>> >> + cmdline_offset =3D grub_strlen (android_cmdline) + 1; >>>> >> + grub_memcpy (linux_cmdline, android_cmdline,=20 >>>> cmdline_offset - >>>> >> 1); >>>> >> + linux_cmdline[cmdline_offset - 1] =3D ' '; >>>> >> + } >>>> >> + grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE,=20 >>>> sizeof >>>> >> (LINUX_IMAGE)); >>>> >> + cmdline_offset +=3D sizeof LINUX_IMAGE - 1; >>>> > LINUX_IMAGE must be at the beginning. don't forget brackets=20 >>>> 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 =3D prot_file_size; >>>> >> if (grub_file_read (file, prot_mode_mem, len) !=3D len && >>>> >> !grub_errno) >>>> >> >>>> > >>>> > >>>> > >>>> > _______________________________________________ >>>> > Grub-devel mailing list >>>> > Grub-devel@gnu.org >>>> > https://lists.gnu.org/mailman/listinfo/grub-devel [1] >>>> >>>> _______________________________________________ >>>> Grub-devel mailing list >>>> Grub-devel@gnu.org >>>> https://lists.gnu.org/mailman/listinfo/grub-devel [1] >>> >>> >>> Links: >>> ------ >>> [1] https://lists.gnu.org/mailman/listinfo/grub-devel >>> >>> _______________________________________________ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/grub-devel >> >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel