All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name()
@ 2019-02-23 10:20 Heinrich Schuchardt
  2019-02-23 13:37 ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2019-02-23 10:20 UTC (permalink / raw)
  To: u-boot

In the `efidebug boot add` command we do not want a unsollicitated leading
backslash added to the file name.

There is no good reason to mark a loaded file with a backslash as absolute.
Anyway when reading files the file name will be interpreted as relative to
root directory of the device.

So let's get rid of this backslash.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_device_path.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 98c36e798f5..53b40c8c3c2 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -985,12 +985,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 	if (!path)
 		return EFI_SUCCESS;
 
-	if (!is_net) {
-		/* Add leading / to fs paths, because they're absolute */
-		snprintf(filename, sizeof(filename), "/%s", path);
-	} else {
-		snprintf(filename, sizeof(filename), "%s", path);
-	}
+	snprintf(filename, sizeof(filename), "%s", path);
 	/* DOS style file path: */
 	s = filename;
 	while ((s = strchr(s, '/')))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name()
  2019-02-23 10:20 [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name() Heinrich Schuchardt
@ 2019-02-23 13:37 ` Alexander Graf
  2019-02-23 17:27   ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2019-02-23 13:37 UTC (permalink / raw)
  To: u-boot



> Am 23.02.2019 um 02:20 schrieb Heinrich Schuchardt <xypron.glpk@gmx.de>:
> 
> In the `efidebug boot add` command we do not want a unsollicitated leading
> backslash added to the file name.
> 
> There is no good reason to mark a loaded file with a backslash as absolute.
> Anyway when reading files the file name will be interpreted as relative to
> root directory of the device.
> 
> So let's get rid of this backslash.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> lib/efi_loader/efi_device_path.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index 98c36e798f5..53b40c8c3c2 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -985,12 +985,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
>    if (!path)
>        return EFI_SUCCESS;
> 
> -    if (!is_net) {
> -        /* Add leading / to fs paths, because they're absolute */
> -        snprintf(filename, sizeof(filename), "/%s", path);
> -    } else {
> -        snprintf(filename, sizeof(filename), "%s", path);
> -    }
> +    snprintf(filename, sizeof(filename), "%s", path);

I'm pretty sure that code was there for a reason. Without, grub would not find its config file iirc.

Alex

>    /* DOS style file path: */
>    s = filename;
>    while ((s = strchr(s, '/')))
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name()
  2019-02-23 13:37 ` Alexander Graf
@ 2019-02-23 17:27   ` Heinrich Schuchardt
  2019-02-24 17:46     ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2019-02-23 17:27 UTC (permalink / raw)
  To: u-boot

On 2/23/19 2:37 PM, Alexander Graf wrote:
> 
> 
>> Am 23.02.2019 um 02:20 schrieb Heinrich Schuchardt <xypron.glpk@gmx.de>:
>>
>> In the `efidebug boot add` command we do not want a unsollicitated leading
>> backslash added to the file name.
>>
>> There is no good reason to mark a loaded file with a backslash as absolute.
>> Anyway when reading files the file name will be interpreted as relative to
>> root directory of the device.
>>
>> So let's get rid of this backslash.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>> lib/efi_loader/efi_device_path.c | 7 +------
>> 1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
>> index 98c36e798f5..53b40c8c3c2 100644
>> --- a/lib/efi_loader/efi_device_path.c
>> +++ b/lib/efi_loader/efi_device_path.c
>> @@ -985,12 +985,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
>>    if (!path)
>>        return EFI_SUCCESS;
>>
>> -    if (!is_net) {
>> -        /* Add leading / to fs paths, because they're absolute */
>> -        snprintf(filename, sizeof(filename), "/%s", path);
>> -    } else {
>> -        snprintf(filename, sizeof(filename), "%s", path);
>> -    }
>> +    snprintf(filename, sizeof(filename), "%s", path);
> 
> I'm pretty sure that code was there for a reason. Without, grub would not find its config file iirc.
> 
> Alex

Alex, you introduced the logic in 492716662fbdc08e254dda2c209b320e2bf6c837.

Typically the grubaa64.efi file is on an EFI partition while the rest of
GRUB is on the boot partition which could be ext2. In which way would it
make a difference to GRUB whether the path to grubaa64.efi is absolute
or relative? The next thing it will load is anyway on a different path.

On my Odroid C2 I built U-Boot with the patch and executed

=> load mmc 0:1 ${fdt_addr_r} dtb
22925 bytes read in 5 ms (4.4 MiB/s)
=> load mmc 0:4 ${kernel_addr_r} EFI/debian/grubaa64.efi
139264 bytes read in 8 ms (16.6 MiB/s)
=> bootefi ${kernel_addr_r} ${fdt_addr_r}

And the system booted normally. grub/ is on mmc 0:1 so on a different
partition of the same deive.

In grubaa64.efi I found a string (,msdos1)/grub. Wouldn't this be the
path GRUB is using on the boot device?

Can you provide any evidence that GRUB is actually using anything else
than the device part of the device path?

Best regards

Heinrich


> 
>>    /* DOS style file path: */
>>    s = filename;
>>    while ((s = strchr(s, '/')))
>> -- 
>> 2.20.1
>>
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name()
  2019-02-23 17:27   ` Heinrich Schuchardt
@ 2019-02-24 17:46     ` Alexander Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2019-02-24 17:46 UTC (permalink / raw)
  To: u-boot



On 23.02.19 18:27, Heinrich Schuchardt wrote:
> On 2/23/19 2:37 PM, Alexander Graf wrote:
>>
>>
>>> Am 23.02.2019 um 02:20 schrieb Heinrich Schuchardt <xypron.glpk@gmx.de>:
>>>
>>> In the `efidebug boot add` command we do not want a unsollicitated leading
>>> backslash added to the file name.
>>>
>>> There is no good reason to mark a loaded file with a backslash as absolute.
>>> Anyway when reading files the file name will be interpreted as relative to
>>> root directory of the device.
>>>
>>> So let's get rid of this backslash.
>>>
>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> ---
>>> lib/efi_loader/efi_device_path.c | 7 +------
>>> 1 file changed, 1 insertion(+), 6 deletions(-)
>>>
>>> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
>>> index 98c36e798f5..53b40c8c3c2 100644
>>> --- a/lib/efi_loader/efi_device_path.c
>>> +++ b/lib/efi_loader/efi_device_path.c
>>> @@ -985,12 +985,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
>>>    if (!path)
>>>        return EFI_SUCCESS;
>>>
>>> -    if (!is_net) {
>>> -        /* Add leading / to fs paths, because they're absolute */
>>> -        snprintf(filename, sizeof(filename), "/%s", path);
>>> -    } else {
>>> -        snprintf(filename, sizeof(filename), "%s", path);
>>> -    }
>>> +    snprintf(filename, sizeof(filename), "%s", path);
>>
>> I'm pretty sure that code was there for a reason. Without, grub would not find its config file iirc.
>>
>> Alex
> 
> Alex, you introduced the logic in 492716662fbdc08e254dda2c209b320e2bf6c837.
> 
> Typically the grubaa64.efi file is on an EFI partition while the rest of
> GRUB is on the boot partition which could be ext2. In which way would it
> make a difference to GRUB whether the path to grubaa64.efi is absolute
> or relative? The next thing it will load is anyway on a different path.
> 
> On my Odroid C2 I built U-Boot with the patch and executed
> 
> => load mmc 0:1 ${fdt_addr_r} dtb
> 22925 bytes read in 5 ms (4.4 MiB/s)
> => load mmc 0:4 ${kernel_addr_r} EFI/debian/grubaa64.efi
> 139264 bytes read in 8 ms (16.6 MiB/s)
> => bootefi ${kernel_addr_r} ${fdt_addr_r}
> 
> And the system booted normally. grub/ is on mmc 0:1 so on a different
> partition of the same deive.
> 
> In grubaa64.efi I found a string (,msdos1)/grub. Wouldn't this be the
> path GRUB is using on the boot device?
> 
> Can you provide any evidence that GRUB is actually using anything else
> than the device part of the device path?

I can no longer reproduce the problem that York reported. So yes, I'm ok
with simplifying the logic. But beware that there *might* be something
lurking we just don't remember and that eventually there could be a bug
report.


Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-24 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 10:20 [U-Boot] [PATCH 1/1] efi_loader: do not add \ in efi_fs_from_name() Heinrich Schuchardt
2019-02-23 13:37 ` Alexander Graf
2019-02-23 17:27   ` Heinrich Schuchardt
2019-02-24 17:46     ` Alexander Graf

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.