2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2025-08-29 22:38:20 +00:00
Files
xcat-dep/xnba/ipxe-registersan.patch
2010-11-12 16:03:31 +00:00

63 lines
2.0 KiB
Diff

diff -urN ipxe-branded/src/usr/autoboot.c ipxe-registersan/src/usr/autoboot.c
--- ipxe-branded/src/usr/autoboot.c 2010-11-11 14:09:48.142334824 -0500
+++ ipxe-registersan/src/usr/autoboot.c 2010-11-12 10:31:31.972972171 -0500
@@ -150,6 +150,38 @@
* @v root_path Root path
* @ret rc Return status code
*/
+int reg_root_path ( const char *root_path ) {
+ struct uri *uri;
+ int drive;
+ int rc;
+
+ /* Parse URI */
+ uri = parse_uri ( root_path );
+ if ( ! uri ) {
+ printf("Unrecognized root path, ignoring\n");
+ return 0; // Not necessarily an error in this case, since this is PXE and FreeBSD may have it's own thing to say, as an example
+ }
+ if ( ( drive = san_hook ( uri, 0 ) ) < 0 ) {
+ rc = drive;
+ printf ( "Could not open SAN device: %s\n",
+ strerror ( rc ) );
+ uri_put ( uri );
+ return 0;
+ }
+ printf ( "Registered as SAN device %#02x\n", drive );
+ /* Describe SAN device */
+ if ( ( rc = san_describe ( drive ) ) != 0 ) {
+ printf ( "Could not describe SAN device %#02x: %s\n",
+ drive, strerror ( rc ) );
+ uri_put(uri);
+ return 0;
+ }
+ //If still in function, we registered fine.
+ //Unclear whether uri should have it's refcnt decremented in this case
+ //in boot_root_path, it would not be, so matching that behavior for now
+ return rc;
+
+}
int boot_root_path ( const char *root_path ) {
struct uri *uri;
int drive;
@@ -228,6 +260,7 @@
struct setting pxe_boot_menu_setting
= { .tag = DHCP_PXE_BOOT_MENU };
char buf[256];
+ char rbuf[256];
struct in_addr next_server;
unsigned int pxe_discovery_control;
int rc;
@@ -259,6 +292,11 @@
fetch_ipv4_setting ( NULL, &next_server_setting, &next_server );
fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
+ fetch_string_setting ( NULL, &root_path_setting, rbuf, sizeof ( buf ) );
+ if ( rbuf[0] ) {
+ printf ( "Attempting SAN registration per root path \"%s\"\n", rbuf );
+ reg_root_path ( rbuf );
+ }
printf ( "Booting from filename \"%s\"\n", buf );
return boot_next_server_and_filename ( next_server, buf );
}