Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cLmiK-0005M5-5q for mharc-grub-devel@gnu.org; Tue, 27 Dec 2016 03:02:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLmiH-0005Le-TQ for grub-devel@gnu.org; Tue, 27 Dec 2016 03:02:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLmiE-0003S1-RB for grub-devel@gnu.org; Tue, 27 Dec 2016 03:02:25 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:33635) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cLmiE-0003QZ-KF; Tue, 27 Dec 2016 03:02:22 -0500 Received: by mail-lf0-x243.google.com with SMTP id y21so26995415lfa.0; Tue, 27 Dec 2016 00:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=TMidUAkgOfT4bhAjws5jiAg+M/BwkiaxWB2tDi8Dwu8=; b=daivfntOtPjPA/3grJNfDmPQsHJ5L/CBUI5R3Reakz6iHURnJb8rkQhLwm3w5p1zSY 5P1BY9oSiOeGI8FAkeK3mEEtXLPp0wC8AEfRqufJf/NOYVF26ON33iLFWTTGtFcGuaZZ +mf4sZfXBJCakR09wHNA79nkqTnI4v+scq6li77uw388X+afuXFTRQU9lRvdy+uOgQ5L fEyKWyhbuWxs8bXHQXTTbofayP+4NJ+FSg0ki03I439v9+Rv09wpGzEnOPR0Gl/ltuqn uwCxX5gFNwQBpHDDUzr8nCtEHHHmcGIgoGT9q/usOJQH1W2XdwU5nl7TOzWIvRcRqkEf VIAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=TMidUAkgOfT4bhAjws5jiAg+M/BwkiaxWB2tDi8Dwu8=; b=oTgiNMGtLLIOn32u/IOYk0tvto0BzpRjqxHY8bQEMHdLmdXABu+RL8CdOdmFrE81t4 aTHY5lXx269M/YfMQYDlBPubq4Py7WGdkRRI8bnjg+KGjTgC7xSfOayAFCQf95h0aV4r i4MBgd4LRdjhd8/gTvLpXiFF0tGSPSBkNhojNN4/YcLm2+ZebCPyi0LwBKvMdj6BHHyl Vrgo9GjPVp5xBJKIhID+JUFn2tBkPisST+MMRKZpB2lzwWINCFKvvQvKPY2eHjjkkvts QhhK2xbkvRzpy9HRpDkHDAW7FUzeJaxKXuBafUOFoOl6wgtkVjLLPvuDly+EyMZ7piaq 87pA== X-Gm-Message-State: AIkVDXKrmjH129H2VTiL5LryTrP2MBBPelDGjtw9YSYIs81cpf1iPuDirOtNVgfCq9cZOg== X-Received: by 10.25.25.204 with SMTP id 195mr10750514lfz.84.1482825741061; Tue, 27 Dec 2016 00:02:21 -0800 (PST) Received: from [192.168.1.3] (ppp109-252-90-129.pppoe.spdop.ru. [109.252.90.129]) by smtp.gmail.com with ESMTPSA id u203sm11263117lff.9.2016.12.27.00.02.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 00:02:20 -0800 (PST) Subject: Re: Cannot pass a single backslash in multiboot cmdline To: =?UTF-8?B?SmFrdWIgSmVybcOhxZk=?= , bug-grub@gnu.org, The development of GNU GRUB References: <20d4df38-a503-7200-d942-0f020d8338d0@jermar.eu> <2f587f88-f1d9-8978-a429-77998dbb07a5@gmail.com> <937ffda3-4666-3b8b-7ad2-cde16466378b@jermar.eu> From: Andrei Borzenkov Message-ID: Date: Tue, 27 Dec 2016 11:02:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <937ffda3-4666-3b8b-7ad2-cde16466378b@jermar.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::243 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2016 08:02:27 -0000 26.12.2016 21:56, Jakub Jermář пишет: > On 12/26/2016 07:24 PM, Andrei Borzenkov wrote: >> 26.12.2016 21:12, Jakub Jermář пишет: >>>>> I am observing a strange behavior when passing boot arguments with a >>>>> backslash to the kernel (the multiboot cmd_line via the multiboot >>>>> command in grub.cfg). I would like to pass foo\bar to the kernel, but to >>>>> no avail. I tried: >>>>> >>>> >>>> Which kernel? What do you load? >>> >>> The kernel is a modified version of HelenOS, but IMHO this issue is >>> kernel agnostic. >> >> Not really. It depends on target program being loaded which is why I >> asked what you use. > > Ok, I submitted my grub.cfg and stated that HelenOS is > multiboot-compliant, gets loaded by the multiboot command. We boot from > an ISO image, which was created like this: > > "The binary files of GRUB boot loader in this directory have been > created by compiling GRUB for the 'i386-pc' target and then using the > grub-mkrescue script to create the El Torito boot image." > > Is there anything else I should include in order to answer your question? > Multiboot only passes single "string" as command line. As far as I can tell this is true for both multiboot1 and multiboot2. Loaded kernel likely will need to parse this string to split it into individual parameters. This means that to pass character(s) used to split string verbatim you need some quoting rules. So it is up to you to define how your kernel parses string. grub is just the messenger here. >>> The cmd_line is already wrong when picked up from the >>> multiboot info and printed out (so there is no processing on it from the >>> HelenOS side). >> >> Sure, but /if/ your kernel interpreted `\' as quoting character, the >> result would be correct. > > But instead of the plain actual data there would be escaped data, which > is a hassle. And also a possible workaround. > Again - how your kernel splits string into multiple parameters? Assuming your kernel does support multiple parameters of course. >>> I think I understand why it is eating the single backslash (expected >>> behavior), >> >> You have two levels here. First level is grub command line processing. >> It is loosely compatible with (Bourne) shell so yes, backslash is >> treated as escape character. You can still pass backslash using usual >> shell quoting, e.g. foo\\bar or 'foo\bar'. Second level is >> grub_create_loader_cmdline() function. This one escapes `\' with second >> `\'. So in the above case this function receives `foo\bar' as adds >> second `\'. > > This explains a lot, but does not make much sense for my usecase. > Sure but we need to understand your use case first :)