mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
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>
This commit is contained in:
parent
4a255ea3b6
commit
4d79e884ad
4 changed files with 79 additions and 32 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue