mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>, chalianis1@gmail.com
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] blspec: derive root prefix from blspec config path instead of mountpoint
Date: Fri, 14 Nov 2025 14:51:08 +0100	[thread overview]
Message-ID: <865dceb4-1dae-49f1-b8cc-36dfd24746dd@pengutronix.de> (raw)
In-Reply-To: <20251114101100.4dpxj3vztsdmezqg@pengutronix.de>

Hello Marco,

On 11/14/25 11:11 AM, Marco Felsch wrote:
> Hi,
> 
> thanks for your patch.
> 
> On 25-11-14, chalianis1@gmail.com wrote:
>> From: Chali Anis <chalianis1@gmail.com>
>>
>> Add get_prefix_path() to compute the filesystem prefix of a BLSpec
>> entry by locating the deepest /loader/entries/ component in the
> 
> What exactly do you mean by "deepest"? The specification says that the
> entries should be under /loader/entries of $BOOT or $EFI partition [1].
> 
> There is also a note:
> """""""""
> In all cases the /loader/entries/ directory should be located directly
> in the root of the ESP or XBOOTLDR filesystem. Specifically, the
> /loader/entries/ directory should not be located under the /EFI/
> subdirectory on the ESP.
> """""""""
> 
> So searching in subdirs seems not to be spec compatible. May I ask why
> your loader entries are within some subdir in the first place?

I was also confused when Anis first mentioned this on IRC, but the
missing piece of information was that get_mounted_path() (and now
get_blspec_prefix_path()) is only used when booting a specific
bootloader spec config by name, e.g.,

bootm /mnt/.../loader/entries/my.conf

as opposed to:

bootm /mnt/.../


In that case, it makes sense to not go up to the first mount, but just
take the loader/entries the file is inside.

I believe this can also be useful for testing: include a loader/
directory in the barebox environment and then run tests over it directly
without having to copy /env/loader to /loader first, because that's the
file system root.

Cheers,
Ahmad

> 
> Regards,
>   Marco
> 
> [1] https://uapi-group.org/specifications/specs/boot_loader_specification/#type-1-boot-loader-specification-entries
> 
>> configuration path. This ensures correct rootpath extraction for
>> nested loader directories, mixed path layouts, duplicate segments,
>> and paths without valid loader entries. If no prefix is found,
>> fall back to get_mounted_path().
>>
>> Signed-off-by: Chali Anis <chalianis1@gmail.com>
>> ---
>>  common/blspec.c | 25 ++++++++++++++++++++++++-
>>  1 file changed, 24 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/blspec.c b/common/blspec.c
>> index 80ebe256ceaf..ad94d4d6be64 100644
>> --- a/common/blspec.c
>> +++ b/common/blspec.c
>> @@ -391,6 +391,29 @@ static bool entry_is_match_machine_id(struct blspec_entry *entry)
>>  	return ret;
>>  }
>>  
>> +/*
>> + * Return the path prefix before the deepest "/loader/entries/" component
>> + * in @configname. Falls back to the mounted path if none is found.
>> + */
>> +static char *get_blspec_prefix_path(char *configname)
>> +{
>> +	char *p;
>> +	char *scfg = configname;
>> +	char *save = NULL;
>> +
>> +	while ((p = strstr(scfg, "/loader/entries/")) != NULL) {
>> +		if (p - configname > 0)
>> +			save = p;
>> +
>> +		scfg = p + 1;
>> +	}
>> +
>> +	if (save && save - configname > 0)
>> +		return xstrndup(configname, save - configname);
>> +
>> +	return get_mounted_path(configname);
>> +}
>> +
>>  static int __blspec_scan_file(struct bootentries *bootentries, const char *root,
>>  			      const char *configname)
>>  {
>> @@ -404,7 +427,7 @@ static int __blspec_scan_file(struct bootentries *bootentries, const char *root,
>>  	if (IS_ERR(entry))
>>  		return PTR_ERR(entry);
>>  
>> -	root = root ?: get_mounted_path(configname);
>> +	root = root ?: get_blspec_prefix_path(configname);
>>  	entry->rootpath = xstrdup_const(root);
>>  	entry->configpath = xstrdup_const(configname);
>>  	entry->cdev = get_cdev_by_mountpath(root);
>> -- 
>> 2.49.0
>>
>>
>>
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2025-11-14 13:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14  5:00 chalianis1
2025-11-14 10:11 ` Marco Felsch
2025-11-14 13:51   ` Ahmad Fatoum [this message]
     [not found]     ` <CAL+1fyCeZdxMhpDNYjpvbteGre+mgDi0pRyUn_24wUkKJa_+4w@mail.gmail.com>
2025-11-14 16:49       ` anis chali

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=865dceb4-1dae-49f1-b8cc-36dfd24746dd@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=chalianis1@gmail.com \
    --cc=m.felsch@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox