diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-07-01 19:44:53 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-07-01 19:44:53 -0700 |
commit | ccce101b32ae26dd180ecaebe95cc749c2f90373 (patch) | |
tree | 5ad9f4caa8b9ae1d1150bdd56cf3a0ef24907f15 | |
parent | 18de1534f9b69fb298a5b56e61919130d875b34b (diff) | |
download | syslinux-ccce101b32ae26dd180ecaebe95cc749c2f90373.tar.gz |
pxelinux: new IPAPPEND 4 to generate a SYSUUID= option.syslinux-4.01-pre3
Add a new IPAPPEND option to generate a SYSUUID= option with the
in-system UUID.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | com32/menu/readconfig.c | 3 | ||||
-rw-r--r-- | core/cmdline.inc | 4 | ||||
-rw-r--r-- | core/fs/pxe/dhcp_option.c | 3 | ||||
-rw-r--r-- | core/fs/pxe/pxe.c | 73 | ||||
-rw-r--r-- | core/fs/pxe/pxe.h | 2 | ||||
-rw-r--r-- | doc/syslinux.txt | 8 |
7 files changed, 72 insertions, 25 deletions
@@ -15,6 +15,10 @@ Changes in 4.01: * Correct a severe memory overwrite bug (mainly related to the menu system.) * lua.c32: Lua script interpreter, currently experimental. + * PXELINUX: new option IPAPPEND 4 to append the system UUID to + the kernel command line. + * PXELINUX: display BOOTIF and SYSUUID at startup time, and + when Ctrl-N is pressed on the command line. Changes in 4.00: * Major code base changes; all filesystem rewritten in C. diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c index ca9c35e6..8c16fda1 100644 --- a/com32/menu/readconfig.c +++ b/com32/menu/readconfig.c @@ -343,7 +343,8 @@ static void record(struct menu *m, struct labeldata *ld, const char *append) if (ld->ipappend) { ipappend = syslinux_ipappend_strings(); for (i = 0; i < ipappend->count; i++) { - if ((ld->ipappend & (1U << i)) && ipappend->ptr[i]) + if ((ld->ipappend & (1U << i)) && ipappend->ptr[i] && + ipappend->ptr[i][0]) ipp += sprintf(ipp, " %s", ipappend->ptr[i]); } } diff --git a/core/cmdline.inc b/core/cmdline.inc index 7fa53816..3e63f9ab 100644 --- a/core/cmdline.inc +++ b/core/cmdline.inc @@ -48,12 +48,14 @@ make_plain_cmdline: ; Actual IPAppend strings... ; %if IS_PXELINUX - extern IPOption, BOOTIFStr + extern IPOption, BOOTIFStr, SYSUUIDStr + global IPAppends, numIPAppends section .data16 alignz 2 IPAppends dw IPOption dw BOOTIFStr + dw SYSUUIDStr numIPAppends equ ($-IPAppends)/2 %else IPAppends equ 0 diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c index ab0f4c08..50f2de04 100644 --- a/core/fs/pxe/dhcp_option.c +++ b/core/fs/pxe/dhcp_option.c @@ -8,7 +8,7 @@ char LocalDomain[256]; int over_load; uint8_t uuid_type; -char uuid[17]; +uint8_t uuid[16]; static void parse_dhcp_options(const void *, int, uint8_t); @@ -113,7 +113,6 @@ static void uuid_client_identifier(const void *data, int opt_len) have_uuid = true; uuid_type = type; memcpy(uuid, data+1, 16); - uuid[16] = 0; } static void pxelinux_configfile(const void *data, int opt_len) diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index dd209fcf..25bd094d 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -16,7 +16,9 @@ uint8_t MAC_len; /* MAC address len */ uint8_t MAC_type; /* MAC address type */ char __bss16 BOOTIFStr[7+3*(MAC_MAX+1)]; -#define MAC_str (BOOTIFStr+7) +#define MAC_str (BOOTIFStr+7) /* The actual hardware address */ +char __bss16 SYSUUIDStr[8+32+5]; +#define UUID_str (SYSUUIDStr+8) /* The actual UUID */ char boot_file[256]; /* From DHCP */ char path_prefix[256]; /* From DHCP */ @@ -1062,7 +1064,6 @@ static int pxe_load_config(void) const char *default_str = "default"; char *config_file; char *last; - char *p; int tries = 8; get_prefix(); @@ -1079,22 +1080,7 @@ static int pxe_load_config(void) /* Try loading by UUID */ if (have_uuid) { - static const uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; - char *src = uuid; - const uint8_t *uuid_ptr = uuid_dashes; - - p = config_file; - while (*uuid_ptr) { - int len = *uuid_ptr; - - lchexbytes(p, src, len); - p += len * 2; - src += len; - uuid_ptr++; - *p++ = '-'; - } - /* Remove last dash and zero-terminate */ - *--p = '\0'; + strcpy(config_file, UUID_str); if (try_load(ConfigName)) return 0; } @@ -1125,7 +1111,7 @@ static int pxe_load_config(void) } /* - * Generate the botif string, and the hardware-based config string + * Generate the bootif string. */ static void make_bootif_string(void) { @@ -1138,6 +1124,35 @@ static void make_bootif_string(void) for (i = MAC_len; i; i--) dst += sprintf(dst, "-%02x", *src++); } +/* + * Generate the SYSUUID string, if we have one... + */ +static void make_sysuuid_string(void) +{ + static const uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; + const uint8_t *src = uuid; + const uint8_t *uuid_ptr = uuid_dashes; + char *dst; + + SYSUUIDStr[0] = '\0'; /* If nothing there... */ + + /* Try loading by UUID */ + if (have_uuid) { + dst = stpcpy(SYSUUIDStr, "SYSUUID="); + + while (*uuid_ptr) { + int len = *uuid_ptr; + + lchexbytes(dst, src, len); + dst += len * 2; + src += len; + uuid_ptr++; + *dst++ = '-'; + } + /* Remove last dash and zero-terminate */ + *--dst = '\0'; + } +} /* * Generate an ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> @@ -1172,7 +1187,23 @@ static void ip_init(void) ip = ntohl(ip); printf("My IP address seems to be %08X %s\n", ip, dot_quad_buf); - printf("%s\n", IPOption); +} + +/* + * Print the IPAPPEND strings, in order + */ +extern const uint16_t IPAppends[]; +extern const char numIPAppends[]; + +static void print_ipappend(void) +{ + size_t i; + + for (i = 0; i < (size_t)numIPAppends; i++) { + const char *p = (const char *)(size_t)IPAppends[i]; + if (*p) + printf("%s\n", p); + } } /* @@ -1468,7 +1499,9 @@ static void network_init(void) printf("\n"); make_bootif_string(); + make_sysuuid_string(); ip_init(); + print_ipappend(); /* * Check to see if we got any PXELINUX-specific DHCP options; in particular, diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h index 8a9dbcc5..1e6fa76a 100644 --- a/core/fs/pxe/pxe.h +++ b/core/fs/pxe/pxe.h @@ -209,7 +209,7 @@ extern far_ptr_t InitStack; extern bool have_uuid; extern uint8_t uuid_type; -extern char uuid[]; +extern uint8_t uuid[]; extern uint16_t BIOS_fbm; extern const uint8_t TimeoutTable[]; diff --git a/doc/syslinux.txt b/doc/syslinux.txt index 5a93b907..51d1332c 100644 --- a/doc/syslinux.txt +++ b/doc/syslinux.txt @@ -179,6 +179,14 @@ IPAPPEND flag_val [PXELINUX only] This allows an initrd program to determine from which interface the system booted. + 4: indicates that an option of the following format + should be generated and added to the kernel command line: + + SYSUUID=<system uuid> + + ... in lower case hexadecimal in the format normally used for + UUIDs (same as for the configuration file; see pxelinux.txt.) + LABEL label KERNEL image APPEND options... |