| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Positional parameters are set in the environment with '$' prepended to
the name. This causes lookups to fail because parameter lookups don't
include the '$'.
TESTED:
Added a test that covers positional parameters in GRUB2 parser.
Build succeeds, tests pass.
Bootstrapped-by: Nancy Yuen <yuenn@google.com>
Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, the GRUB2 parser incorrectly reports "[ -f <path> ]" as
false if the size of the file is above 1 MB. This patch changes the
parser interface to allow stating files (with parser_stat_file). Then
in the implementation of "[ -f <path> ]", we can use parser_stat_file
instead of parser_request_file which has the size limitation. I
eliminate parser_check_dir in lieu of this new interface, which has
the side effect of making "[ -d <path> ]" work (the error code for
stat was not checked correctly before).
I add a basic test for the test file operations -f, -s, and -d (to
show that my changes to test file operations do not break them) and
minorly modify the test framework to ensure it has enough fidelity to
cause the expected results. Unfortunately the test wouldn't have
caught the issue with -d, since the test framework stubs out the
parser interface itself. Nor can the test framework catch the initial
problem with -f because the imposed limit is (transitively) in
function parser_request_file.
Note that -f and -d follow symlinks despite the fact that GRUB does
not (see
http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00142.html
discussing GRUB's behavior). This is not a change to Petitboot's
behavior though.
Tested:
The test test-grub2-test-file-ops passes. I booted Petitboot against
a GRUB snippet:
status=success
if [ ! -f /large_file -a $status = success ]
then status=fail_large_file
fi
if [ ! -d /a_directory -a $status = success ]
then status=fail_dir
fi
menuentry $status {
linux /vmlinux
}
(after making /large_file a file of size > 1 MiB and /a_directory a
directory) and the menuentry had title "success", as desired.
Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, "save_env -f" in the GRUB2 parser only works with three
arguments, which means only commands of the form "save_env -f <path>"
that save *no* environment variables are allowed.
Allow "save_env -f <path> [<var>]*", making "save_env -f" useful.
Tested:
Unit test test-grub2-save-env-dash-f tests this change, and the
remaining unit tests still pass.
Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the default environment variable is unset or invalid (i.e.,
references a non-existent boot option), then GRUB2 will fallback to the
first boot option present. This is preventing petitboot from autobooting
where no default is explicitly set, or is stale.
This change adds this fallback behaviour to petitboot. Because we don't
know if the first option will be a default at parse time (as no other
options matched the default env var), we need to keep options in a list,
and register them with the discover server once the parse is complete.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The SYSAPPEND/IPAPPEND option 2 in PXE configs requires
the MAC address of the booting interface to be appended
to the boot options. Previously we formatted this as
"BOOTIF=01:02:03:04:05:06",
but syslinux/pxelinux implementation use this format:
"BOOTIF=01-01-02-03-04-05-06",
where the leading '01' represents the hardware type.
The relevant part of the pxelinux doc is at:
http://www.syslinux.org/wiki/index.php/SYSLINUX#SYSAPPEND_bitmask
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
This has caused problems with the old delimiter code, add a test to
ensure we don't regress.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, the delimiter token handling is a little fragile: we try to
ignore non-inter-word delimiters in the lexer with a selective set of
regexes on the possible delimiter characters.
This means we don't need to handle potential delimiters in every grammar
rule, but there are other situations (not regex-able) where we may see
delimters, and this will cause a parse error.
Instead of relying on the regex behaviour, we have an 'inter_word' flag,
which is set when we see the first word token, and cleared when we see
an end-of-line token. We only emit TOKEN_DELIM when this flag is set.
This means that we only get the delim tokens when they're required -
when we're looking for word separators (becuase WORD DELIM WORD is
distinct from WORD WORD - eg "linux /vmlinux" and "x$var").
We add a few new tests for the "menuentry" and "if" syntax, with
different delimiter configurations.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, build only a test object will fail:
[jk@pablo obj]$ make ./test/parser/test-grub2-single
CCLD test/parser/test-grub2-single
libtool: link: cannot find the library `lib/libpbcore.la' or unhandled argument `lib/libpbcore.la'
We're adding this to the link argument, but not as a dependency. This
change adds the dependency.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
This change implements SYSAPPEND/IPAPPEND 2, to add a BOOTIF argument to
the kernel command line.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
'make distcheck' will do a 'make all' srcdir == objdir, then later a
'make check' sith srcdir != objdir. Since gcc's cpp always assumes that
a source file's directory is first in the include paths, we may see
discover/parser.h included when we wanted the generated
discover/grub2/parser.h.
This change renames the grub2 lexer and parser files, to work-around
this behaviour, and fix 'make distcheck'.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
| |
Currently, we get a lot of noise out of the build process; automake
supports V={0,1}, which we can use to suppress the output a little.
This needs a few cleanups for custom commands.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
With the current testing infrastructure, we don't have a strictly
hierarchical set of dependencies. This causes problems with a recursive
make, and means we have to hack around some of the dependencies.
This change generates a single, top-level makefile from all of the
Makefile.am fragments. We still need the po/ directory as a separate
SUBDIR, but all others can be converted to non-recursive.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We need a couple of automake options to prevent errors when regenerating
Makefile.ins during source preparation.
Some makefiles assume GNU make, so add 'foreign' where necessary. Also,
we are building objects in subdirectories, so we need 'subdir-objects'.
Modified to suit recent petitboot by Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Jeff Bailey <jeffbailey@google.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, we have a bug when parsing zero-length files: we subtract one
from the length to exclude the trailing NUL (added by read_file), but a
zero-length file will result in a length of -1.
This change adds an explicit exit if we're attempting to parse an empty
file.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
| |
Add tests to cover pxlinux-style configuration autodiscovery.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
PXELinux treats all paths as relative, requiring a "::/path" syntax for
truly absolute URLs.
This change implements the same behaviour in petitboot, and updates the
testcases to suit.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There's no need to include the config storage code in lib/ as only the
discover server should be using it.
This change moves the config-storage code to discover/, with the
platform-specific parts moved to a 'struct platform'. Each platform has
a probe function, which is called during init. The first probe function
to return a platform is used.
At present we only have the one platform, but it's now non-intrusive to
add others.
We keep an array of platform pointers in a separate ("platforms")
section, to allow the test module to drop-in its own test "platform".
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
The de-facto PXELINUX standard specifies lowercase characters for the
MAC addresses, so change our reuqests to suit.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change implements support for the DHCP "pathprefix" option. We use
the following logic:
- If pathprefix is present and a full URL, we base the config file
location on pathprefix + conffile
- If pathprefix is present but not a full URL, we use it as the path
component of the URL, and pick up the host from other parameters in
the DHCP response
- If no pathprefix is present, we determine the configuration prefix
from the DHCP bootfile parameter.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
| |
Fix Petitboot's grub.cfg parser to handle --id=label argument to
menuentry, and use it (in preference to the option name) when looking
for a default option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
Add a test to ensure that boot option parameters don't leak into later
options.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
Currently, we have a bug where a 'known_name' that appears before an
image section will cause globals_done to be set, and we don't see any
further global variables.
This change sets globals_done only once we see an image section.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
yaboot configuration files with no option will cause an assertion
failure (or segfault), as we unconditionally call yaboot_finish().
Check for the presence of an option in yaboot_finish() instead of
asserting.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
When we remove a device, some options may still be unresolved, and so
won't be deallocated through freeing the device.
This chagne explicitly removes & frees any currently-unresolved options
for this device.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
Rather than always using the default prefix, we should determine it from
the location of the grub2 config file.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
Implement -s and -f checks for grub, and test with the standard GRUB2
saved_default config.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
| |
Adding new cases to the pxe parser code of having conffile file without
complete URL and determining conffile names using mac and ip addresses
passed from the udhcpc.
Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
Update the parser test code/cases as per new prototyping of parse()
function which doesn't require buf and len to be passed from the caller,
instead reading the configuration data either embedded or from file to
a parser's known conffile.
Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
Use the new parser_request_file API to access the GRUB environment
block.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
| |
Rather than printf() & exit(), use the pb logging functions and abort
the parse.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
If we didn't find any valid boot options in the pxe buffer, we'll call
discover_context_add_boot_option with a NULL boot option.
This change adds a check before we try to add the boot option, and a
test to verify this situation.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
| |
Check the overriding of 'partition' directive from yaboot conf file for
'petitboot', then verify the device name on which the resource resides
Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
| |
Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A couple of fixes for yaboot's device-handling code. Firstly, we need to
use 'device=' rather than 'root=', as the latter is purely for ybin, to
define where the yaboot binary goes.
Secondly, we need to respect global and option-specific device=
parameters. To do this, we keep all boot_image and initrd strings in the
state, and create the actual resources in yaboot_finish.
Add a test for all override cases, and fix the incorrect boot= parsing
in the rh8 test.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
All of the image options should be overridable by global options.
Instead of building the boot_args during yaboot_process_pair, we add
discovered data into the state struct, then create the boot args from
this data during yaboot_finish
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
| |
In the cleanup of yaboot option state, 3fb8fb6fb, we change from
checking opt->boot_image to opt, to indicate that we're parsing an image
section.
We missed one check, which is causing a segfault due to the null opt.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
| |
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
|
|
|
|
|
|
| |
Add a couple of tests to verify the pxe parser, particularly the
different styles of initrd handling.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the Makfile.am relocatable output files from automake _LIBRARIES
to automake _PROGRAMS. Also, change the output file name extension
from .o to .ro to better show these are relocatable files.
Fixes automake warnings like these:
discover/Makefile.am: `libparser.o' is not a standard library name
discover/Makefile.am: did you mean `libparser.a'?
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
|
|
|
|
|
|
| |
General cleanup of Makefile.am. This cleanup should retain the same
makefile behavior.
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
|
|
|
|
|
| |
Fixes to make maintainer-clean work properly.
Signed-off-by: Geoff Levand <geoff@infradead.org>
|
|
|
|
|
|
|
| |
Remove the GNU awk specifics to allow the use of a standard
awk program. Fixes build errors on older distros.
Signed-off-by: Geoff Levand <geoff@infradead.org>
|