Skip to contentSkip to conversation

menu: Ignore prompt variable if timeout is != 0

PATCH In review FUKAUMI Naoki 3 participants 7 messages Jul 14, 2023 – Jul 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 menu: Ignore prompt variable if timeout is != 0

From: Manuel Traut <[email protected]>

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the following /boot/extlinux/extlinux.conf (which sets timeout to 50) immediately boots the first entry in the config without displaying a boot menu. According to the description, that should only happen if both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
 common/menu.c | 3 +++
 1 file changed, 3 insertions(+)
common/menu.c +3 -0
index 8fe00965c0..8eabcccc87 100644
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
 	if (!m->item_cnt)
 		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);
+
 	if (!m->prompt)
 		return menu_default_choice(m, choice);
 
Signature · 1 line
2.39.0
#1 lore raw
Quoted 19 lines · FUKAUMI Naoki

From: Manuel Traut <[email protected]>

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the following /boot/extlinux/extlinux.conf (which sets timeout to 50) immediately boots the first entry in the config without displaying a boot menu. According to the description, that should only happen if both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
 common/menu.c | 3 +++
 1 file changed, 3 insertions(+)
common/menu.c +0 -0
index 8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
 	if (!m->item_cnt)
 		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

PROMPT 1
TIMEOUT 50

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

Regards,
Jonas

Quoted 4 lines
common/menu.c +1 -0
+
 	if (!m->prompt)
 		return menu_default_choice(m, choice);
 
#2 lore raw

hi,

thank you for your reply!

Quoted 29 lines · Jonas Karlman
Quoted 19 lines · FUKAUMI Naoki

From: Manuel Traut <[email protected]>

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the following /boot/extlinux/extlinux.conf (which sets timeout to 50) immediately boots the first entry in the config without displaying a boot menu. According to the description, that should only happen if both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
  common/menu.c | 3 +++
  1 file changed, 3 insertions(+)
common/menu.c +0 -0
index 8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
  	if (!m->item_cnt)
  		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

Quoted 6 lines

PROMPT 1
TIMEOUT 50

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L346-351

this description is unclear for me if (timeout > 0) && (prompt == 0)

Best regards,

--
FUKAUMI Naoki
Radxa

Quoted 7 lines

Regards,
Jonas

Quoted 4 lines
common/menu.c +1 -0
+
  	if (!m->prompt)
  		return menu_default_choice(m, choice);
 
#3 lore raw

Hi,

Quoted 1 line

thank you for your reply!

thanks for taking care on this somehow lost patch

Quoted 33 lines · Jonas Karlman
Quoted 32 lines · FUKAUMI Naoki
Quoted 19 lines

From: Manuel Traut <[email protected]>

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the
following /boot/extlinux/extlinux.conf (which sets timeout to 50)
immediately boots the first entry in the config without displaying a
boot menu. According to the description, that should only happen if
both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
  common/menu.c | 3 +++
  1 file changed, 3 insertions(+)
common/menu.c index renamed from common/menu.c +0 -0

8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
  	if (!m->item_cnt)
  		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

PROMPT 1
TIMEOUT 50

Quoted 7 lines
Quoted 3 lines

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L346-351

this description is unclear for me if (timeout > 0) && (prompt == 0)

This is my current understanding after reading the description multiple times:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user interrupt
------------+--------------+-----------------------------------------
prompt != 0 | ask user | ask user

so for (timeout > 0) && (prompt == 0) I would expect to boot the default choice immediately.

Without reading the documentation I would expect
PROMPT 1
TIMEOUT 50
to show a prompt for 5 seconds and afterwards boot the default choice. This also matches the current implantation and the explanation in the arch wiki.

The current implementation, behaves like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | boot default
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

The patch under discussion considers a configuration of:
PROMPT 0
TIMEOUT 50
that currently is booting the default target immediately. This clearly does not match the description.

The patch would change the behavior like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user input
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

It does not match the description regarding:
"prompt - If 1, the user will be prompted for input regardless of the value of timeout"

If I write a configuration like:
PROMPT 1
TIMEOUT 50
I would expect to get a prompt for 5 seconds, than boot the default target.

I can update the patch to include changing the documentation along with table above as a comment to make it easier understandable. Or shall I update the patch to match the behavior described in the first table?
Just let me know..

Regards
Manuel

#4 lore raw
Quoted 87 lines · Traut Manuel LCPF-CH

Hi,

Quoted 1 line

thank you for your reply!

thanks for taking care on this somehow lost patch

Quoted 33 lines · Jonas Karlman
Quoted 32 lines · FUKAUMI Naoki
Quoted 19 lines

From: Manuel Traut <[email protected]>

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the
following /boot/extlinux/extlinux.conf (which sets timeout to 50)
immediately boots the first entry in the config without displaying a
boot menu. According to the description, that should only happen if
both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
  common/menu.c | 3 +++
  1 file changed, 3 insertions(+)
common/menu.c index renamed from common/menu.c +0 -0

8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
  	if (!m->item_cnt)
  		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

PROMPT 1
TIMEOUT 50

Quoted 7 lines
Quoted 3 lines

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L346-351

this description is unclear for me if (timeout > 0) && (prompt == 0)

This is my current understanding after reading the description multiple times:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user interrupt
------------+--------------+-----------------------------------------
prompt != 0 | ask user | ask user

so for (timeout > 0) && (prompt == 0) I would expect to boot the default choice immediately.

Without reading the documentation I would expect
PROMPT 1
TIMEOUT 50
to show a prompt for 5 seconds and afterwards boot the default choice. This also matches the current implantation and the explanation in the arch wiki.

The current implementation, behaves like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | boot default
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

The patch under discussion considers a configuration of:
PROMPT 0
TIMEOUT 50
that currently is booting the default target immediately. This clearly does not match the description.

The patch would change the behavior like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user input
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

It does not match the description regarding:
"prompt - If 1, the user will be prompted for input regardless of the value of timeout"

Quoted 8 lines

If I write a configuration like:
PROMPT 1
TIMEOUT 50
I would expect to get a prompt for 5 seconds, than boot the default target.

I can update the patch to include changing the documentation along with table above as a comment to make it easier understandable. Or shall I update the patch to match the behavior described in the first table?
Just let me know..

I agree that the documentation is not clear, because this is a common menu function I would expect the use of timeout and prompt to be explicit and that each control a single function.

prompt: 0 = do not ask user, 1 = ask user
timeout: 0 = wait indefinitely, > 0 time to wait for input

If anything needs to be done related to how extlinux.conf handles menu options the menu config should probably be changed in pxe_utils.c and not in the common menu.c.

My expectations related to extlinux.conf would be:
- No need to prompt or wait for timeout if there is only one bootable choice, regardless of PROMPT or TIMEOUT values
- Should not prompt when I have explicitly specified PROMPT 0
- Having multiple bootable choices and a TIMEOUT > 0 or PROMPT 1 should prompt, at least if I have some way to see and control the menu

Regards,
Jonas

Quoted 3 lines

Regards
Manuel

#5 lore raw

AW: EXTERNAL - [PATCH] menu: Ignore prompt variable if timeout is != 0

Hi,

Quoted 82 lines
Quoted 82 lines
Quoted 29 lines
Quoted 29 lines
Quoted 17 lines

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the
following /boot/extlinux/extlinux.conf (which sets timeout to 50)
immediately boots the first entry in the config without displaying
a boot menu. According to the description, that should only happen
if both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
  common/menu.c | 3 +++
  1 file changed, 3 insertions(+)
common/menu.c index renamed from common/menu.c +0 -0

8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
  	if (!m->item_cnt)
  		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

PROMPT 1
TIMEOUT 50

Quoted 8 lines
Quoted 3 lines

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L346
-351

this description is unclear for me if (timeout > 0) && (prompt == 0)

This is my current understanding after reading the description multiple times:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user interrupt
------------+--------------+-----------------------------------------
prompt != 0 | ask user | ask user

so for (timeout > 0) && (prompt == 0) I would expect to boot the default choice immediately.

Without reading the documentation I would expect PROMPT 1 TIMEOUT 50 to show a prompt for 5 seconds and afterwards boot the default choice. This also matches the current implantation and the explanation in the arch wiki.

The current implementation, behaves like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | boot default
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

The patch under discussion considers a configuration of:
PROMPT 0
TIMEOUT 50
that currently is booting the default target immediately. This clearly does not match the description.

The patch would change the behavior like this:

            | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user input
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

It does not match the description regarding:
"prompt - If 1, the user will be prompted for input regardless of the value of timeout"

If I write a configuration like:
PROMPT 1
TIMEOUT 50
I would expect to get a prompt for 5 seconds, than boot the default target.

Quoted 8 lines
Quoted 3 lines

I can update the patch to include changing the documentation along with table above as a comment to make it easier understandable. Or shall I update the patch to match the behavior described in the first table?
Just let me know..

I agree that the documentation is not clear, because this is a common menu function I would expect the use of timeout and prompt to be explicit and that each control a single function.

prompt: 0 = do not ask user, 1 = ask user
timeout: 0 = wait indefinitely, > 0 time to wait for input

This should match the current implementation (but not documentation..)

@FUKAUMI Naoki, @[email protected] - is it ok for you if we keep this behavior and I will fix the documentation?

Quoted 8 lines

If anything needs to be done related to how extlinux.conf handles menu options the menu config should probably be changed in pxe_utils.c and not in the common menu.c.

My expectations related to extlinux.conf would be:
- No need to prompt or wait for timeout if there is only one bootable choice, regardless of PROMPT or TIMEOUT values
- Should not prompt when I have explicitly specified PROMPT 0
- Having multiple bootable choices and a TIMEOUT > 0 or PROMPT 1 should prompt, at least if I have some way to see and control the menu

This is also fine for me, we could implement this as an additional feature, if we have agreed on the basic behavior.

Best regards
Manuel

#6 lore raw

Re: AW: EXTERNAL - [PATCH] menu: Ignore prompt variable if timeout is != 0

hi,

Quoted 88 lines · Traut Manuel LCPF-CH

Hi,

Quoted 86 lines
Quoted 85 lines
Quoted 29 lines
Quoted 29 lines
Quoted 17 lines

Since 739e8361f3fe78038251216df6096a32bc2d5839, a system with the
following /boot/extlinux/extlinux.conf (which sets timeout to 50)
immediately boots the first entry in the config without displaying
a boot menu. According to the description, that should only happen
if both prompt and timeout are set to zero in the config, but it also happens with timeout set to a non-zero value.

---
   common/menu.c | 3 +++
   1 file changed, 3 insertions(+)
common/menu.c index renamed from common/menu.c +0 -0

8fe00965c0..8eabcccc87 100644

common/menu.c int menu_get_choice(struct menu *m, void **choice) · line 281

Quoted 5 lines
common/menu.c +2 -0
@@ -277,6 +277,9 @@ int menu_get_choice(struct menu *m, void **choice)
   	if (!m->item_cnt)
   		return -ENOENT;
 
+	if (m->timeout)
+		return menu_interactive_choice(m, choice);

This should not be needed, if the user wants to prompt the menu there is the PROMPT keyword that can be used in extlinux.conf, e.g.:

PROMPT 1
TIMEOUT 50

Quoted 8 lines
Quoted 3 lines

See https://wiki.archlinux.org/title/Syslinux#Boot_prompt

That should set pxe cfg->prompt = 1 and that in turn menu m->prompt = 1.

https://source.denx.de/u-boot/u-boot/-/blob/master/common/menu.c#L346
-351

this description is unclear for me if (timeout > 0) && (prompt == 0)

This is my current understanding after reading the description multiple times:

             | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user interrupt
------------+--------------+-----------------------------------------
prompt != 0 | ask user | ask user

so for (timeout > 0) && (prompt == 0) I would expect to boot the default choice immediately.

Without reading the documentation I would expect PROMPT 1 TIMEOUT 50 to show a prompt for 5 seconds and afterwards boot the default choice. This also matches the current implantation and the explanation in the arch wiki.

The current implementation, behaves like this:

             | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | boot default
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

The patch under discussion considers a configuration of:
PROMPT 0
TIMEOUT 50
that currently is booting the default target immediately. This clearly does not match the description.

The patch would change the behavior like this:

             | timeout == 0 | timeout > 0

------------+--------------+-----------------------------------------
prompt == 0 | boot default | wait for timeout or user input
------------+--------------+-----------------------------------------
prompt != 0 | ask user | wait for timeout or user input

It does not match the description regarding:
"prompt - If 1, the user will be prompted for input regardless of the value of timeout"

If I write a configuration like:
PROMPT 1
TIMEOUT 50
I would expect to get a prompt for 5 seconds, than boot the default target.

I can update the patch to include changing the documentation along with table above as a comment to make it easier understandable. Or shall I update the patch to match the behavior described in the first table?
Just let me know..

Quoted 8 lines
Quoted 4 lines

I agree that the documentation is not clear, because this is a common menu function I would expect the use of timeout and prompt to be explicit and that each control a single function.

prompt: 0 = do not ask user, 1 = ask user
timeout: 0 = wait indefinitely, > 0 time to wait for input

This should match the current implementation (but not documentation..)

@FUKAUMI Naoki, @[email protected] - is it ok for you if we keep this behavior and I will fix the documentation?

I'm fine.

Quoted 10 lines
Quoted 8 lines

If anything needs to be done related to how extlinux.conf handles menu options the menu config should probably be changed in pxe_utils.c and not in the common menu.c.

My expectations related to extlinux.conf would be:
- No need to prompt or wait for timeout if there is only one bootable choice, regardless of PROMPT or TIMEOUT values
- Should not prompt when I have explicitly specified PROMPT 0
- Having multiple bootable choices and a TIMEOUT > 0 or PROMPT 1 should prompt, at least if I have some way to see and control the menu

This is also fine for me, we could implement this as an additional feature, if we have agreed on the basic behavior.

I like this too.

Best regards,

--
FUKAUMI Naoki
Radxa

Quoted 2 lines

Best regards
Manuel