| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
Code is fine, but clang's -Wparentheses-equality warns when using double
parentheses in conditionals that don't do assignment. This aligns with
our code style as well, so change it to silence the warning.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230404090542.1820785-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently when doing:
echo foo\ bar
we will get argv[1] = "foo\" and argv[2] = "bar".
An unquoted escaped whitespace should be replaced by a whitespace.
With this the above will correctly result in argv[1] = "foo bar"
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix warning fwterated by checkincludes.pl:
./net/nfs.c: libgen.h is included more than once.
./net/ifup.c: globalvar.h is included more than once.
./crypto/rsa.c: asm/types.h is included more than once.
./lib/decompress_unlz4.c: linux/decompress/mm.h is included more than once.
./scripts/stb_image.h: stdio.h is included more than once.
./scripts/kwbimage.c: unistd.h is included more than once.
./scripts/common.c: sys/types.h is included more than once.
./scripts/bareboximd.c: sys/types.h is included more than once.
./scripts/bareboximd.c: sys/mman.h is included more than once.
./fs/pstore/ram_core.c: linux/rslib.h is included more than once.
./fs/pstore/fs.c: fs.h is included more than once.
./fs/pstore/fs.c: linux/pstore.h is included more than once.
./fs/nfs.c: fs.h is included more than once.
./fs/uimagefs.c: fs.h is included more than once.
./fs/fs.c: command.h is included more than once.
./arch/sandbox/board/hostfile.c: linux/err.h is included more than once.
./arch/sandbox/board/devices.c: mach/linux.h is included more than once.
./arch/sandbox/os/common.c: signal.h is included more than once.
./arch/arm/boards/zii-imx51-rdu1/board.c: envfs.h is included more than once.
./arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c: generated/mach-types.h is
./arch/arm/mach-stm32mp/ddrctrl.c: mach/stm32.h is included more than once.
./arch/arm/mach-imx/cpu_init.c: common.h is included more than once.
./arch/arm/mach-imx/imx8m.c: mach/imx8m-ccm-regs.h is included more than once.
./common/efi/payload/init.c: efi.h is included more than once.
./common/state/backend_format_raw.c: common.h is included more than once.
./common/state/backend_format_raw.c: crc.h is included more than once.
./common/hush.c: libbb.h is included more than once.
./drivers/spi/atmel-quadspi.c: linux/clk.h is included more than once.
./drivers/spi/atmel-quadspi.c: linux/err.h is included more than once.
./drivers/net/virtio.c: net.h is included more than once.
./drivers/net/phy/phy.c: linux/phy.h is included more than once.
./drivers/net/cpsw.c: net.h is included more than once.
./drivers/virtio/virtio_pci_common.h: linux/list.h is included more than once.
./drivers/usb/host/ohci-hcd.c: dma.h is included more than once.
./drivers/usb/gadget/fsl_udc.c: dma.h is included more than once.
./drivers/nvmem/eeprom_93xx46.c: spi/spi.h is included more than once.
./drivers/nvmem/eeprom_93xx46.c: of.h is included more than once.
./drivers/video/imx-ipu-v3/imx-ldb.c: linux/clk.h is included more than once.
./drivers/video/imx-ipu-v3/imx-hdmi.c: linux/clk.h is included more than once.
./drivers/video/omap.c: common.h is included more than once.
./drivers/mtd/nand/nand_s3c24xx.c: asm/sections.h is included more than once.
./drivers/clk/imx/clk-imx6sx.c: linux/clk.h is included more than once.
./drivers/clk/imx/clk-imx6sl.c: linux/clk.h is included more than once.
./commands/bootm.c: of.h is included more than once.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Link: https://lore.barebox.org/20220607051957.2497-1-eagle.alexander923@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix conditional statements ("if" , "elif", "while" and "until") exit
code when used in scripts. Before the change, when conditional statement
evaluated false just before the end of the script, script's exit code
would have been 1 (instead of 0), which implies error condition. This is
not expected nor desired behavior, so correct it by handling such cases
and passing exit code 0 (SUCCESS) instead in such situations.
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Link: https://lore.barebox.org/20210810054712.1547433-1-andrej.picej@norik.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Entering very long lines can crash the readline prompt due to missing
NUL terminator. Make sure we don't exceed CONFIG_CBSIZE to avoid this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
For all files in common/ that already have a license text:
- Replace with appropriate SPDX-License-Identifier
- Remove empty comment lines around replacement
- remove comment completely if only thing remaining is name
of file without description
Reviewed-by: Roland Hieber <rhi@pengutronix.de>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We have the split by '=' snippet at multiple locations that parse
key=value pairs. Consolidate them to a single location. This makes code
a bit easier to read at the cost of an extra 8 bytes (LZO-compressed
THUMB2 barebox, static inline version is bigger).
No functional change.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
| |
name is unused except for printing and value is modified, but never read
back. They currently serve no purpose, so drop them. The actual
splitting by '=' happens in set_local_var later.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some code wants to run arbitrary code in the background, examples are
fastboot and ratp. Currently this is implemented in pollers. The problem
with this is that pollers are executed whenever is_timeout() is called
which may happen anywhere in the code. With this we can never tell which
resources are currently in use when the poller is executed.
This adds a work queue interface which is specifically designed to
trigger doing work in a context where it's safe to run arbitrary commands.
Code in pollers can attach work to a work queue which is at that time
only queued up. A new slice, the command slice, is added which by
default is acquired. It is only released at places where the shell waits
for input. When during this time pollers are executed the queued up
works are done before running the registered pollers.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Hush is the only one user of simple_itoa() and the code there can be
re-implemented using snprintf(). Change the code to get rid of
simple_itoa().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It's easy to get stuck in an infinite loop in the hush shell:
while true; do sleep 1; done
The 'sleep' command will check for ctrl-c with the ctrlc() function. This
will abort the sleep command. Hush then checks for ctrl-c again in the
loop. The ctrl-c in the buffer has already been eaten by the sleep
command, so the loop will continue.
With this patch we remember the presence of a ctrl-c character in a
variable instead of checking for a new character each time. The
variable must be resetted explicitly by calling ctrlc_handled() which
will be called by the shell in the outer loop.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
I've seen people increasing the compile loglevel to get more debugging
output from barebox. This is generally a good idea, but the tons of hush
debugging printed makes barebox quite unusable. This patch puts hush
debugging behind an extra HUSH_DEBUG define so increasing the compile
loglevel no longer results in hush debugging.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
To give the hush debug output more context.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Although the elements of `source_aliases[]` are of type `const char *`,
the elements themselves are not const-qualified. Make them `const`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The hush context must be initialized before it is used. Add
initialization where necessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Before a context can be used it must be initialized. This was forgotten
in several places. Add the missing calls to initialize_context().
This fixes crashes when sourcing empty files
Reported-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to have the login functionality in the /env/bin/init script.
This is hard to review and it's too easy to break the login functionality
with changes to this script. Move the places to ask for a password to
C code where we have only a few places where we have to ask for a password.
Mainly these are run_shell() and the menutree command.
This patch introduces a login() function which will only return if the correct
password has been entered. Following calls will return immediately without
asking for a password again.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| | |
Conflicts:
lib/Makefile
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Just returns error code instead of 0 or 1.
With this fix, $? is set to child exit code in all cases.
Without this fix, /child $PATH;echo $? displays 1 even if
child script calls exit with a specific non zero error code.
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
|
| |
We have our file helper functions in several places. Move them
all to lib/libfile.c.
With this we no longer have file helpers in fs/fs.c which contains
the core fs functions and no functions in lib/libbb.c which are
not from busybox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| | |
Conflicts:
commands/devinfo.c
|
| |
| |
| |
| |
| |
| |
| |
| | |
In case of device parameters setting variables may fail. return
the result of set_local_var so that the user has a chance to detect
the failure with $?.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* this compile option actually turns on a command, so name it
accordingly
* also move the Kconfig definition into commands/Kconfig, thus
placing getopt into the "Shell scripting commands" section
* while at it, improve Kconfig documention
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
shell_expand expands shell variables in a string.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Save indentation level for easier readability.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Use standard ARRAY_SIZE instead of handcrafted NRES.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Print the token that led to a syntax error, at least for the common
case.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
syntax is defined as syntax_err. Drop syntax_err and call syntax instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
the name '__promptme' does not make clear what the variable means. rename
it to 'interrupt' which is set to true when the user has hit ctrl-c.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Save indentation level by returning early.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Save indentation level by returning early.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Don't call readline in if/else, instead setup a variable and call
it once.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
input.__promptme is no valid indicator that run_shell should be left.
It should be left on executing the 'exit' builtin which is indicated
by a return code < 0 from parse_stream_outer(). Track this with an extra
variable and use it as a condition to return from an interactive shell.
This fixes the weird behaviour that hush exits (and the user finds itself
in the menu) when a syntax error occured.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
To get all arguments a script is called with.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
This patch add getopt to the command list if it enabled via
Kconfig. With this patch we get a 'command not found' error.
Otherwise getopt doing nothing.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The FSF address has changed in the past. Instead of updating it
each time the address changes, just drop it completely treewide.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
execute_binfmt may return negative return values which hush interprets
as 'exit'. Catch this and print an error message instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
'exit' used to do its job by returning value < 0. This is a sign
for hush that 'exit' is executed. This has problems:
- Often commands accidently return a negative value. This causes
the shell to exit.
- execute_binfmt returns a negative value when it does not find
a binary to execute. This again causes the shell to exit.
Returning a negative error value seems to be the right thing
to do, but catching this in the shell would mean that the exit
command does not work anymore.
- if called without arguments exit is supposed to return the code
of the last command. As a command exit has no access to this code.
This patch changes exit to be a builtin and also fixes the last return
code problem. While at it, update the help text.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Make the nonopt arguments to a script available starting from $1
after running getopt. This allows for scripts which use option
parsing but also have nonopts.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
parse_stream_outer used to convert a exit value to a return code,
but parse_stream_outer maybe inside a recursion. This means that
the exit status is lost in this case. Test case:
if [ 0 = 0 ]; then
false
exit $?
fi
echo "shouldn't be here"
Without this patch "shouldn't be here" will be printed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|