summaryrefslogtreecommitdiffstats
path: root/src/core/image.c
diff options
context:
space:
mode:
authorMichael Brown2007-08-07 15:50:12 +0200
committerMichael Brown2007-08-07 15:50:12 +0200
commitcfcc41d407e99968c23c2402a600263401ee41b8 (patch)
tree24f42fa8779441dcf73d75801bcb27419dfe8d99 /src/core/image.c
parentAdd PXE FILE API. (diff)
downloadipxe-cfcc41d407e99968c23c2402a600263401ee41b8.tar.gz
ipxe-cfcc41d407e99968c23c2402a600263401ee41b8.tar.xz
ipxe-cfcc41d407e99968c23c2402a600263401ee41b8.zip
Set current working URI to be that of the executable image when
executing any image, not just a script. (This will enable pxelinux to use relative URIs, should it wish to.)
Diffstat (limited to 'src/core/image.c')
-rw-r--r--src/core/image.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/image.c b/src/core/image.c
index 63c2502b..440a68c9 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -237,6 +237,7 @@ int image_autoload ( struct image *image ) {
* @ret rc Return status code
*/
int image_exec ( struct image *image ) {
+ struct uri *old_cwuri;
int rc;
/* Image must be loaded first */
@@ -252,15 +253,23 @@ int image_exec ( struct image *image ) {
if ( ! image->type->exec )
return -ENOEXEC;
+ /* Switch current working directory to be that of the image itself */
+ old_cwuri = uri_get ( cwuri );
+ churi ( image->uri );
+
/* Try executing the image */
if ( ( rc = image->type->exec ( image ) ) != 0 ) {
DBGC ( image, "IMAGE %p could not execute: %s\n",
image, strerror ( rc ) );
- return rc;
+ goto done;
}
- /* Well, some formats might return... */
- return 0;
+ done:
+ /* Reset current working directory */
+ churi ( old_cwuri );
+ uri_put ( old_cwuri );
+
+ return rc;
}
/**