diff options
author | Simon Glass | 2021-10-14 12:48:08 -0600 |
---|---|---|
committer | Tom Rini | 2021-11-11 19:02:36 -0500 |
commit | 4d79e884adf6842beb94566bf5249c07a84a5b51 (patch) | |
tree | 7eb943b038db3795e57cec8536553dbc959197e1 /cmd | |
parent | 4a255ea3b65e7793eea97a90ad00dc2b59889683 (diff) |
pxe: Return the file size from the getfile() function
It is pretty strange that the pxe code uses the 'filesize' environment
variable find the size of a file it has just read.
Partly this is because it uses the command-line interpreter to parse its
request to load the file.
As a first step towards unwinding this, return it directly from the
getfile() function. This makes the code a bit longer, for now, but will be
cleaned up in future patches.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/pxe.c | 7 | ||||
-rw-r--r-- | cmd/sysboot.c | 21 |
2 files changed, 24 insertions, 4 deletions
diff --git a/cmd/pxe.c b/cmd/pxe.c index e319db51ef5..81703386c42 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -25,15 +25,20 @@ const char *pxe_default_paths[] = { }; static int do_get_tftp(struct pxe_context *ctx, const char *file_path, - char *file_addr) + char *file_addr, ulong *sizep) { char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; + int ret; tftp_argv[1] = file_addr; tftp_argv[2] = (void *)file_path; if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv)) return -ENOENT; + ret = pxe_get_file_size(sizep); + if (ret) + return log_msg_ret("tftp", ret); + ctx->pxe_file_size = *sizep; return 1; } diff --git a/cmd/sysboot.c b/cmd/sysboot.c index c45fed774d6..6344ecd357b 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -9,43 +9,58 @@ static char *fs_argv[5]; static int do_get_ext2(struct pxe_context *ctx, const char *file_path, - char *file_addr) + char *file_addr, ulong *sizep) { #ifdef CONFIG_CMD_EXT2 + int ret; + fs_argv[0] = "ext2load"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_ext2load(ctx->cmdtp, 0, 5, fs_argv)) return 1; + ret = pxe_get_file_size(sizep); + if (ret) + return log_msg_ret("tftp", ret); #endif return -ENOENT; } static int do_get_fat(struct pxe_context *ctx, const char *file_path, - char *file_addr) + char *file_addr, ulong *sizep) { #ifdef CONFIG_CMD_FAT + int ret; + fs_argv[0] = "fatload"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_fat_fsload(ctx->cmdtp, 0, 5, fs_argv)) return 1; + ret = pxe_get_file_size(sizep); + if (ret) + return log_msg_ret("tftp", ret); #endif return -ENOENT; } static int do_get_any(struct pxe_context *ctx, const char *file_path, - char *file_addr) + char *file_addr, ulong *sizep) { #ifdef CONFIG_CMD_FS_GENERIC + int ret; + fs_argv[0] = "load"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_load(ctx->cmdtp, 0, 5, fs_argv, FS_TYPE_ANY)) return 1; + ret = pxe_get_file_size(sizep); + if (ret) + return log_msg_ret("tftp", ret); #endif return -ENOENT; } |