summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2024-03-29 14:45:24 +0100
committerMichael Brown2024-03-29 15:12:10 +0100
commitf39b48d5f82793c75700b0787b36f65d33079f3b (patch)
tree23201cabc157ab19f7ee6418ea0317e73767ed13
parent[build] Fix build failures with random versions of gcc (diff)
downloadipxe-f39b48d5f82793c75700b0787b36f65d33079f3b.tar.gz
ipxe-f39b48d5f82793c75700b0787b36f65d33079f3b.tar.xz
ipxe-f39b48d5f82793c75700b0787b36f65d33079f3b.zip
[image] Allow opaque URI component to provide image name
Some URI schemes allow for a path name to be specified via the opaque component of the URI (e.g. "file:/script.ipxe" to specify a path on the filesystem from which iPXE itself was loaded). Files loaded from such paths will currently fail to be assigned an appropriate name, since only the path component of the URI will be used to construct a default image name. Fix by falling back to attempt deriving an image name from the opaque component of a URI, if no path component is specified. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/core/image.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/image.c b/src/core/image.c
index 3e65b5ed..bf0e4f75 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -134,10 +134,13 @@ int image_set_uri ( struct image *image, struct uri *uri ) {
int rc;
/* Set name, if image does not already have one */
- if ( uri->path && ( ! ( image->name && image->name[0] ) ) ) {
- name = basename ( ( char * ) uri->path );
- if ( ( rc = image_set_name ( image, name ) ) != 0 )
- return rc;
+ if ( ! ( image->name && image->name[0] ) ) {
+ name = ( uri->path ? uri->path : uri->opaque );
+ if ( name ) {
+ name = basename ( ( char * ) name );
+ if ( ( rc = image_set_name ( image, name ) ) != 0 )
+ return rc;
+ }
}
/* Update image URI */