Annotation of qemu/roms/ipxe/src/hci/commands/sanboot_cmd.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (C) 2010 Michael Brown <[email protected]>.
                      3:  *
                      4:  * This program is free software; you can redistribute it and/or
                      5:  * modify it under the terms of the GNU General Public License as
                      6:  * published by the Free Software Foundation; either version 2 of the
                      7:  * License, or any later version.
                      8:  *
                      9:  * This program is distributed in the hope that it will be useful, but
                     10:  * WITHOUT ANY WARRANTY; without even the implied warranty of
                     11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     12:  * General Public License for more details.
                     13:  *
                     14:  * You should have received a copy of the GNU General Public License
                     15:  * along with this program; if not, write to the Free Software
                     16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     17:  */
                     18: 
                     19: #include <stdio.h>
                     20: #include <string.h>
                     21: #include <errno.h>
                     22: #include <getopt.h>
                     23: #include <ipxe/command.h>
                     24: #include <ipxe/parseopt.h>
                     25: #include <ipxe/uri.h>
                     26: #include <usr/autoboot.h>
                     27: 
                     28: FILE_LICENCE ( GPL2_OR_LATER );
                     29: 
                     30: /** @file
                     31:  *
                     32:  * SAN commands
                     33:  *
                     34:  */
                     35: 
                     36: /** "sanboot" options */
                     37: struct sanboot_options {};
                     38: 
                     39: /** "sanboot" option list */
                     40: static struct option_descriptor sanboot_opts[] = {};
                     41: 
                     42: /** "sanboot" command descriptor */
                     43: static struct command_descriptor sanboot_cmd =
                     44:        COMMAND_DESC ( struct sanboot_options, sanboot_opts, 1, 1,
                     45:                       "<root-path>" );
                     46: 
                     47: /**
                     48:  * The "sanboot" command
                     49:  *
                     50:  * @v argc             Argument count
                     51:  * @v argv             Argument list
                     52:  * @ret rc             Return status code
                     53:  */
                     54: static int sanboot_exec ( int argc, char **argv ) {
                     55:        struct sanboot_options opts;
                     56:        const char *root_path;
                     57:        struct uri *uri;
                     58:        int rc;
                     59: 
                     60:        /* Parse options */
                     61:        if ( ( rc = parse_options ( argc, argv, &sanboot_cmd, &opts ) ) != 0 )
                     62:                goto err_parse_options;
                     63: 
                     64:        /* Parse root path */
                     65:        root_path = argv[optind];
                     66:        uri = parse_uri ( root_path );
                     67:        if ( ! uri ) {
                     68:                rc = -ENOMEM;
                     69:                goto err_parse_uri;
                     70:        }
                     71: 
                     72:        /* Boot from root path */
                     73:        if ( ( rc = uriboot ( NULL, uri ) ) != 0 ) {
                     74:                printf ( "Could not boot from %s: %s\n",
                     75:                         root_path, strerror ( rc ) );
                     76:                goto err_uriboot;
                     77:        }
                     78: 
                     79:  err_uriboot:
                     80:        uri_put ( uri );
                     81:  err_parse_uri:
                     82:  err_parse_options:
                     83:        return rc;
                     84: }
                     85: 
                     86: /** SAN commands */
                     87: struct command sanboot_command __command = {
                     88:        .name = "sanboot",
                     89:        .exec = sanboot_exec,
                     90: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.