aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass2021-10-14 12:48:05 -0600
committerTom Rini2021-11-11 19:02:30 -0500
commit74b7a2b8815cf953ea0b72800bd9db7f0d6a119a (patch)
tree49cf70c7cc0d176b73ca8eb0ee66d249b13cbd6b /boot
parent12df842ee324a7e188a643bfee6fe08f28127b26 (diff)
pxe: Drop get_bootfile_path()
This function no longer makes sense, since it is pretty easy to prepend the boot directory to the filename. Drop it and update its only caller. 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 'boot')
-rw-r--r--boot/pxe_utils.c53
1 files changed, 5 insertions, 48 deletions
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 5d47d30a9ee..48fb7076fd1 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -65,47 +65,6 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len)
}
/**
- * get_bootfile_path() - Figure out the path of a file to read
- *
- * Copies the boot directory into the supplied buffer. If there is no boot
- * directory, set it to ""
- *
- * @ctx: PXE context
- * @file_path: File path to read (relative to the PXE file)
- * @bootfile_path: Place to put the bootfile path
- * @bootfile_path_size: Size of @bootfile_path in bytes
- * @allow_abs_path: true to allow an absolute path (where @file_path starts with
- * '/', false to return an empty path (and success) in that case
- * Returns 1 for success, -ENOSPC if bootfile_path_size is to small to hold the
- * resulting path
- */
-static int get_bootfile_path(struct pxe_context *ctx, const char *file_path,
- char *bootfile_path, size_t bootfile_path_size,
- bool allow_abs_path)
-{
- size_t path_len = 0;
-
- /* Only syslinux allows absolute paths */
- if (file_path[0] == '/' && allow_abs_path)
- goto ret;
-
- path_len = strlen(ctx->bootdir);
- if (bootfile_path_size < path_len + 1) {
- printf("bootfile_path too small. (%zd < %zd)\n",
- bootfile_path_size, path_len);
-
- return -ENOSPC;
- }
-
- strncpy(bootfile_path, ctx->bootdir, path_len);
-
- ret:
- bootfile_path[path_len] = '\0';
-
- return 1;
-}
-
-/**
* get_relfile() - read a file relative to the PXE file
*
* As in pxelinux, paths to files referenced from files we retrieve are
@@ -124,15 +83,13 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path,
size_t path_len;
char relfile[MAX_TFTP_PATH_LEN + 1];
char addr_buf[18];
- int err;
- err = get_bootfile_path(ctx, file_path, relfile, sizeof(relfile),
- ctx->allow_abs_path);
- if (err < 0)
- return err;
+ if (file_path[0] == '/' && ctx->allow_abs_path)
+ *relfile = '\0';
+ else
+ strncpy(relfile, ctx->bootdir, MAX_TFTP_PATH_LEN);
- path_len = strlen(file_path);
- path_len += strlen(relfile);
+ path_len = strlen(file_path) + strlen(relfile);
if (path_len > MAX_TFTP_PATH_LEN) {
printf("Base path too long (%s%s)\n", relfile, file_path);