sandbox: Add a function to load a relative file path

At present this implementation is specific to loading the test FDT. We
plan to load others, so create a generic function to handle this.

The path is now limited to 256 characters, to simplify the code.

When there is an empty argv[0] (which should not happen), the function now
just uses the path as is, with no prefix.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2022-09-06 20:27:08 -06:00
committed by Tom Rini
parent 2b90e0d54e
commit 73c5cb9dac
3 changed files with 43 additions and 9 deletions

View File

@@ -265,6 +265,20 @@ void state_reset_for_test(struct sandbox_state *state);
*/
void state_show(struct sandbox_state *state);
/**
* state_get_rel_filename() - Get a filename relative to the executable
*
* This uses argv[0] to obtain a filename path
*
* @rel_path: Relative path to build, e.g. "arch/sandbox/dts/test.dtb". Must not
* have a trailing /
* @buf: Buffer to use to return the filename
* @size: Size of buffer
* @return length of filename (including terminator), -ENOSPC if @size is too
* small
*/
int state_get_rel_filename(const char *rel_path, char *buf, int size);
/**
* Initialize the test system state
*/