Re: [Etherboot-users] Getting the original BOOTP values in userspace after boot
Brought to you by:
marty_connor,
stefanhajnoczi
From: Donald J C. <dj...@ci...> - 2001-04-25 17:24:14
|
Mark Atwood wrote: > > I'm using Etherboot to book Linux 2.4. Is there a way for > a userspace program get a list of all the BOOTP/DHCP tags & values > that booted the image? As Ken said, first32.c can copy things into the parameter string and it will show up in /proc/cmdline. I believe there is 512 bytes of space to work with. I rearranged things and got 2k, which is all the kernel supports (at least last time I checked.) I am passing a bunch of things to the application level that way. I have changed the code too much for you to use it directly, but I can share a snippet that adds strings to /proc/cmdline to use as an example. You'll have to fit this into first32.c. Remember, the first32.c that I am using is quite different from the distributed first32.c, but this code should be pretty close to usable. YMMV. params = ( char * )seg[ S_PARAMS ]->p_paddr; /* p is insertion point for new parameters */ p = params + strlen( params ); *p++ = ' '; /* Copy image file name to params */ { /* NOTE: params is not checked for enough space */ unsigned char s[ 128 ]; sprintf( s, "fwvers=%d.%s%d platform=xyz img=", eb->major, eb->minor < 10 ? "0" : "", eb->minor ); for ( i = 0; i < strlen( s ); i++ ) *p++ = s[ i ]; for ( i = 0; i < strlen( bp->bp_file ); i++ ) *p++ = bp->bp_file[ i ]; *p++ = ' '; /* space, not null, since another option follows */ } { /* NOTE: params is not checked for enough space */ unsigned char s[ ] = "cfg="; for ( i = 0; i < strlen( s ); i++ ) *p++ = s[ i ]; /* Find config file name and copy it to params */ q = gettag(RFC1533_VENDOR_SPECIFIC); if (( q[ 0 ] != 0 ) && ( q[ 1 ] == 67 )) { i = q[ 2 ]; q += 3; while ( i-- > 0 ) *p++ = *q++; } else { unsigned char s2[ ] = ".cfg"; for ( i = 0; i < strlen( bp->bp_file ); i++ ) *p++ = bp->bp_file[ i ]; for ( i = 0; i < strlen( s2 ); i++ ) *p++ = s2[ i ]; } *p++ = '\0'; } /* Move parameters to end of parameter area, tail first to avoid overwriting */ q = params + PARAMSIZE; /* At least 1 byte is copied, the NUL */ do { *--q = *--p; } while ( p != params ); ip = q; op = params; process_params( ); if ( verbose ) printf( "Parameters: %s\n", params ); -- Don Christensen Senior Software Development Engineer dj...@ci... MMABU - Mid-Market Access Business Unit Cisco Systems ComLOB - Commercial Line of Business San Jose, CA "So much relies on the course that you take The fool and the wise man both burn at the stake" |