[autoboot] Retain initial-slash (if present) when constructing TFTP URIs

When we boot from a DHCP-supplied filename, we previously relied on
the fact that the current working URI is set to tftp://[next-server]/
in order to resolve the filename into a full tftp:// URI.  However,
this process will eliminate the distinction between filenames with and
without initial slashes:

 cwuri="tftp://10.0.0.1/" filename="vmlinuz"  => URI="tftp://10.0.0.1/vmlinuz"
 cwuri="tftp://10.0.0.1/" filename="/vmlinuz" => URI="tftp://10.0.0.1/vmlinuz"

This distinction is important for some TFTP servers.  We now
explicitly construct a string of the form

 "tftp://[next-server]/filename"

so that a filename with an initial slash will result in a URI
containing a double-slash, e.g.

 "tftp://10.0.0.1//vmlinuz"

The TFTP code always strips a single initial slash, and so ends up
presenting the correct path to the server.

URIs entered explicitly by users at the command line must include a
double slash if they want an initial slash presented to the TFTP
server:

  "kernel tftp://10.0.0.1/vmlinuz"  => filename="vmlinuz"
  "kernel tftp://10.0.0.1//vmlinuz" => filename="/vmlinuz"
This commit is contained in:
Michael Brown
2008-07-31 16:55:46 +01:00
parent 193426d960
commit 481a21798d
2 changed files with 31 additions and 3 deletions

View File

@@ -215,6 +215,7 @@ extern struct setting password_setting __setting;
extern struct setting priority_setting __setting;
extern struct setting bios_drive_setting __setting;
extern struct setting uuid_setting __setting;
extern struct setting next_server_setting __setting;
/**
* Initialise a settings block