All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 4/8 v2] efi_loader: Introduce helper functions for EFI
Date: Wed, 30 Dec 2020 23:21:17 +0200	[thread overview]
Message-ID: <X+zvTdH7PKkCXTbp@enceladus> (raw)
In-Reply-To: <87541610-8b3c-7b81-c9fe-a6abcf855286@gmx.de>

On Wed, Dec 30, 2020 at 08:29:54PM +0100, Heinrich Schuchardt wrote:
> On 12/30/20 4:07 PM, Ilias Apalodimas wrote:
> > A following patch introduces a different logic for loading initrd's

[...]

> > +struct load_file_info {
> > +	char dev[32];
> 
> if_typename_str[] contains all available strings. 8 bytes are long
> enough. The value can be validated with blk_get_device_by_str().
> 
> > +	char part[16];
> 
> Windows allows 128 partitions per device. I would not expect millions of
> devices. 8 bytes should be long enough.
> 
> > +	char filename[256];
> 
> This is a path not a file name. Please, adjust the parameter name.
> 
> In Windows the maximum length of a path is 260 characters. But does such
> a limit exist in UEFI?
> 
> In U-Boot we have:
> include/ext_common.h:33:#define EXT2_PATH_MAX 4096
> 
> So you cannot assume that the path is shorter then 4096 bytes.

This is defining something entirely differnt though. So I dont think we need
to adhere to any of these. 256 is perfectly sane for an initrd path.

> 
> I think the best thing to do is to use strdup() and then put 0x00 at the
> end of each string part. How about:
> 
> struct load_file_info {
> 	/*
> 	 * duplicated filespec, to be freed after usage
> 	 * 0x00 separated device, part, path
> 	 */
> 	char *filespec;
> 	char *part;
> 	char *filepath;
> }
> 
> So filespec would point to a buffer containing:
> 
> device\0   part\0   \path\file\0    \0
> |          |        |- filepath points here
> |          |- part points here
> |- filespec points here
> 

I generally try to avoid functions that need free() after the usagem since
they tend to be error prone. 
In any case this whole thing we probably go away if we just store a device
path in initrd. So let me have a look and see were we'll end up.

[...]

Cheers
/Ilias

  reply	other threads:[~2020-12-30 21:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 15:07 [PATCH 0/8 v2] Change logic of EFI LoadFile2 protocol for initrd loading Ilias Apalodimas
2020-12-30 15:07 ` [PATCH 1/8 v2] efi_loader: Remove unused headers from efi_load_initrd.c Ilias Apalodimas
2020-12-30 18:21   ` Heinrich Schuchardt
2020-12-30 15:07 ` [PATCH 2/8 v2] efi_loader: Remove unconditional installation of file2 protocol for initrd Ilias Apalodimas
2020-12-30 18:15   ` Heinrich Schuchardt
2020-12-30 15:07 ` [PATCH 3/8 v2] efi_loader: Add size checks to efi_create_indexed_name() Ilias Apalodimas
2020-12-30 18:34   ` Heinrich Schuchardt
2020-12-30 21:23     ` Ilias Apalodimas
2020-12-30 15:07 ` [PATCH 4/8 v2] efi_loader: Introduce helper functions for EFI Ilias Apalodimas
2020-12-30 19:29   ` Heinrich Schuchardt
2020-12-30 21:21     ` Ilias Apalodimas [this message]
2020-12-30 15:07 ` [PATCH 5/8 v2] efi_loader: bootmgr: Use get_var from efi_helper file Ilias Apalodimas
2020-12-30 19:32   ` Heinrich Schuchardt
2020-12-30 15:07 ` [PATCH 6/8 v2] efi_loader: Replace config option with EFI variable for initrd loading Ilias Apalodimas
2020-12-30 19:38   ` Heinrich Schuchardt
2021-01-05  2:42   ` AKASHI Takahiro
2021-01-05  8:50     ` Ilias Apalodimas
2021-01-06 10:43       ` Ilias Apalodimas
2021-01-06 11:07         ` Heinrich Schuchardt
2021-01-06 12:53           ` Ilias Apalodimas
2020-12-30 15:07 ` [PATCH 7/8 v2] efi_selftest: Modify self-tests for initrd loading via Loadfile2 Ilias Apalodimas
2020-12-30 20:29   ` Heinrich Schuchardt
2020-12-30 15:07 ` [PATCH 8/8 v2] doc: uefi: Add instruction for initrd loading Ilias Apalodimas
2020-12-30 20:17   ` Heinrich Schuchardt
2020-12-30 20:44 ` [PATCH 0/8 v2] Change logic of EFI LoadFile2 protocol " Heinrich Schuchardt
2020-12-30 21:17   ` Ilias Apalodimas

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=X+zvTdH7PKkCXTbp@enceladus \
    --to=ilias.apalodimas@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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.