From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] Add support for extlinux.conf
Date: Fri, 24 Apr 2026 16:53:59 +0200 [thread overview]
Message-ID: <29fb6d15-f449-45ee-8b2f-485a618ec573@pengutronix.de> (raw)
In-Reply-To: <CAP1tNvSfV1Yz0f9NDaN-e88KYFzPNkC16ZjTRPSyBd-hNKXMyg@mail.gmail.com>
Hello,
On 4/24/26 10:46 AM, Alexander Shiyan wrote:
>> On 4/16/26 3:45 PM, Alexander Shiyan wrote:
>>> This adds support for the extlinux.conf configuration format, commonly
>>> used by Syslinux and many Linux distributions. The configuration file
>>> is typically located at /boot/extlinux/extlinux.conf or
>>> /extlinux/extlinux.conf and defines boot entries with kernel, initrd,
>>> device tree, and command line options.
> ...
>>> +static int extlinux_boot(struct bootentry *be, int verbose, int dryrun)
>>> +{
>>> + struct extlinux_entry *e =
>>> + container_of(be, struct extlinux_entry, entry);
>>> + char *kernel_abs, *initrd_abs = NULL, *fdt_abs = NULL;
>>> + struct bootm_data data = {};
>>> + int ret;
>>> +
>>> + bootm_data_init_defaults(&data);
>>> +
>>> + data.dryrun = max_t(int, dryrun, data.dryrun);
>>> + data.verbose = max(verbose, data.verbose);
>>> + data.appendroot = true;
>>
>> Not sure this is a good idea because of potential of clashing with
>> extlinux appended command line options.
>
> globalvar_add_bool("extlinux.fix_root", NULL); ?
global.extlinux.strip_root to remove root=
and bootm.appendroot to add barebox' own root?
@Sascha, any thoughts on this?
>
> ...
>>> + if (e->append)
>>> + globalvar_add_simple("linux.bootargs.dyn.extlinux", e->append);
>>> +
>>> + pr_info("Booting extlinux label '%s'\n", e->label);
>>> +
>>> + ret = bootm_boot(&data);
>>
>> Please make use of new bootm_entry instead, so it can be used with devboot:
>>
>> https://github.com/barebox/barebox/blob/next/Documentation/user/devboot.rst
>
> I haven't figured out how to do this yet...
Just make sure it can be used by calling bootm_entry instead of bootm_boot.
> ...
>>> +static struct extlinux_entry *parse_extlinux_conf(const char *abspath,
>>> + const char *rootpath)
>>> +{
>>> + char *buf, *bufptr, *line, *p, *default_label = NULL;
>>> + struct extlinux_entry *entry = NULL;
>>> +
>>> + bufptr = read_file(abspath, NULL);
>>> + if (!bufptr)
>>> + return ERR_PTR(-errno);
>>> +
>>> + for (p = bufptr; *p; p++)
>>> + if (*p == '\r')
>>> + *p = '\n';
>>
>> I think this can be dropped.
>>
>>> +
>>> + buf = bufptr;
>>> + while ((line = strsep(&buf, "\n")) != NULL) {
>>
>> And then you replace the set searched here with "\r\n"
>
> The end of the line may be \n, \r, \n\r.
> We are simply converting it to a uniform format.
strsep's second argument means split at any of these characters and not
split at them in exactly that order.
>
>>> + char *key, *val;
>>> +
>>> + line = skip_spaces(line);
>>> +
>>> + if (*line == '#' || *line == '\0')
>>> + continue;
>>> +
>>
>> Nitpick: I think below can be simplified to:
>>
>>> + key = line;
>>> + val = strchr(line, ' ');
>>> + if (!val)
>>> + val = strchr(line, '\t');
>>> + if (val) {
>>> + *val++ = '\0';
>>> + val = skip_spaces(val);
>>> + } else
>>> + continue;
>>
>> key = strsep(&line, ' \t');
>> val = strsep(&line, '\n');
>> val = isempty(val) ? NULL : skip_spaces(val);
>
> strsep inserts a null byte in place of the separator; this will
> corrupt the buffer,
> and consequently, we will not be able to find the val.
char line[] = "DEFAULT test", *p = line;
char *key = strsep(&p, " \t");
char *val = strsep(&p, "\n");
printf("key<%s> value<%s>\n", key, val);
prints key<DEFAULT> value<test>.
Isn't that exactly what you need?
>> defaut_label might not have been set here?
>
> No: if (!default_label) ... continue;
Ah ok.
Cheers,
Ahmad
--
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 |
next prev parent reply other threads:[~2026-04-24 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 13:45 Alexander Shiyan
2026-04-16 13:45 ` [PATCH 2/2] Documentation: add extlinux.conf support description Alexander Shiyan
2026-04-22 9:14 ` Ahmad Fatoum
2026-04-24 8:19 ` Alexander Shiyan
2026-04-22 9:10 ` [PATCH 1/2] Add support for extlinux.conf Ahmad Fatoum
2026-04-24 8:46 ` Alexander Shiyan
2026-04-24 14:53 ` Ahmad Fatoum [this message]
2026-04-27 8:58 ` Sascha Hauer
2026-04-27 17:34 ` Alexander Shiyan
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=29fb6d15-f449-45ee-8b2f-485a618ec573@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=eagle.alexander923@gmail.com \
/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