Hello Nils,

Is this for defining the "TFTP Prefix:" one usually sees in a PXELINUX
boot or is it something else?  Is there a specific usage scenario for
it?

I'm just curious.  Not much of a developer here myself, but I'm
intrigued by something that helps keep PXELINUX strictly to the PXE
boot scenarios that specifically require it, rather than having to
bolt it on to solve funny netboot problems :)

Thanks,
Andrew Bobulsky


On Fri, Jan 21, 2011 at 10:10 AM, Nils Carlson
<[email protected]> wrote:
> Add a setdirname command allowing us to retrieve the directory
> from a filename. Simplifies the replacement of pxelinux with
> ipxe.
>
> Signed-off-by: Nils Carlson <[email protected]>
> ---
>  src/hci/commands/nvo_cmd.c |   52 
> ++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 52 insertions(+), 0 deletions(-)
>
> diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c
> index 3513c8d..784c14c 100644
> --- a/src/hci/commands/nvo_cmd.c
> +++ b/src/hci/commands/nvo_cmd.c
> @@ -16,6 +16,7 @@
>  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>  */
>
> +#include <libgen.h>
>  #include <stdint.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -178,6 +179,53 @@ static int clear_exec ( int argc, char **argv ) {
>        return 0;
>  }
>
> +/** "setdirname" options */
> +struct setdirname_options {};
> +
> +/** "setdirname" option list */
> +static struct option_descriptor setdirname_opts[] = {};
> +
> +/** "clear" command descriptor */
> +static struct command_descriptor setdirname_cmd =
> +       COMMAND_DESC ( struct setdirname_options, setdirname_opts, 2, 2,
> +                      "<setting> <path>", "" );
> +
> +/**
> + * "setdirname" command
> + *
> + * @v argc             Argument count
> + * @v argv             Argument list
> + * @ret rc             Return status code
> + */
> +static int setdirname_exec ( int argc, char **argv ) {
> +       struct setdirname_options opts;
> +       int rc;
> +       char buf[256];
> +       unsigned int len;
> +
> +       /* Parse options */
> +       if ( ( rc = parse_options ( argc, argv, &setdirname_cmd, &opts ) ) != 
> 0 )
> +               return rc;
> +
> +       len = strlen(argv[optind + 1]);
> +       if ( len > (sizeof(buf) - 1) ) {
> +               printf( "Path %s too long to save dirname\n", argv[optind + 
> 1] );
> +               return 1;
> +       }
> +
> +       strncpy( buf, argv[optind + 1], sizeof(buf) - 1 );
> +
> +       if ( ( rc = storef_named_setting ( argv[optind], dirname(buf) ) ) != 
> 0 ) {
> +               printf ( "Could not set \"%s\" to dirname of \"%s\": %s\n",
> +                        argv[optind], argv[optind + 1], strerror ( rc ) );
> +               return 1;
> +       }
> +
> +       return 0;
> +}
> +
> +
> +
>  /** Non-volatile option commands */
>  struct command nvo_commands[] __command = {
>        {
> @@ -192,4 +240,8 @@ struct command nvo_commands[] __command = {
>                .name = "clear",
>                .exec = clear_exec,
>        },
> +       {
> +               .name = "setdirname",
> +               .exec = setdirname_exec,
> +       },
>  };
> --
> 1.6.0.2
>
> _______________________________________________
> ipxe-devel mailing list
> [email protected]
> https://lists.ipxe.org/mailman/listinfo/ipxe-devel
>
_______________________________________________
ipxe-devel mailing list
[email protected]
https://lists.ipxe.org/mailman/listinfo/ipxe-devel

Reply via email to