Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aUJFl-00062m-Bm for mharc-grub-devel@gnu.org; Fri, 12 Feb 2016 14:19:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUJFj-00062f-Ks for grub-devel@gnu.org; Fri, 12 Feb 2016 14:19:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUJFg-00026H-F9 for grub-devel@gnu.org; Fri, 12 Feb 2016 14:19:39 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:35866 helo=homiemail-a47.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUJFg-00025E-4H for grub-devel@gnu.org; Fri, 12 Feb 2016 14:19:36 -0500 Received: from homiemail-a47.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTP id 8D3A128405B for ; Fri, 12 Feb 2016 11:19:33 -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=hPaUvdEOSr0Mw+e8rV6y6BQj7Mo=; b=JUwgG53ptlxjhQCf2FNNT4lEE6C FajarTn8mMcexnjqL87kDymIb0pv6B8azxGgctAjouEW6+innZOpOwmsaT54KBJ+ rUySJkwLb9rLscBcIk+Bzt2xPgAseeKEtIsMxnqE14YMLlWMKPYu0NahWaB8rLVG 6hkIlV4Ev600QzPU= 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 79A06284058 for ; Fri, 12 Feb 2016 11:19:33 -0800 (PST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Fri, 12 Feb 2016 14:19:33 -0500 From: Shea Levy To: Subject: Re: [PATCH v3 2/3] i386: Add support for loading from android bootimg In-Reply-To: <56BE1B60.5060900@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> Message-ID: <7384a36941a77cced1fde7e3d084280a@shealevy.com> 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: Fri, 12 Feb 2016 19:19:40 -0000 On 2016-02-12 12:50, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: > 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=20 >> 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=20 >> __attribute__ ((unused)), >> goto fail; >> } >> >> - file =3D grub_file_open (argv[0]); >> + char android_cmdline[BOOT_ARGS_SIZE]; >> + android_cmdline[0] =3D '\0'; >> + if (grub_memcmp (argv[0], "android_bootimg:", sizeof=20 >> "android_bootimg:" - 1) =3D=3D 0) >> + grub_android_bootimg_load_kernel (argv[0] + sizeof=20 >> "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 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. Autodetection would be possible actually, I didn't think of that. If=20 grub_file_open fails, we can try grub_android_bootimg_load_kernel on the=20 same file. Would that be preferable or do we still want a separate=20 command? > >> if (! file) >> goto fail; >> >> @@ -1008,12 +1015,20 @@ grub_cmd_linux (grub_command_t cmd=20 >> __attribute__ ((unused)), >> linux_cmdline =3D 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 =3D 0; >> + if (android_cmdline[0]) >> + { >> + cmdline_offset =3D grub_strlen (android_cmdline) + 1; >> + grub_memcpy (linux_cmdline, android_cmdline, cmdline_offset -=20 >> 1); >> + linux_cmdline[cmdline_offset - 1] =3D ' '; >> + } >> + grub_memcpy (linux_cmdline + cmdline_offset, LINUX_IMAGE, sizeof=20 >> (LINUX_IMAGE)); >> + cmdline_offset +=3D sizeof LINUX_IMAGE - 1; > LINUX_IMAGE must be at the beginning. don't forget brackets around=20 > 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 &&=20 >> !grub_errno) >> > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel