Show
Ignore:
Timestamp:
09/27/08 12:08:28 (3 months ago)
Author:
stepan
Message:

Add string support to nvramtool.

To add a string to your cmos.layout, you need to specify type 's':

#start len type unused name
416 512 s 0 boot_devices

With this patch you can do

$ nvramtool -w boot_devices="(hd0,0);(hd2,1);(hd3)"

And FILO will attempt to load a menu.lst from any of these devices in that
order.

The patch is not exactly pretty, but a cleaner solution might have resulted in
a complete rewrite of the tool, which I did not want.

Signed-off-by: Stefan Reinauer <stepan@…>
Acked-by: Joseph Smith <joe@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/util/nvramtool/cmos_ops.c

    r3122 r3613  
    11/*****************************************************************************\ 
    22 * cmos_ops.c 
    3  * $Id$ 
    43 ***************************************************************************** 
    54 *  Copyright (C) 2002-2005 The Regents of the University of California. 
     
    4847      return CMOS_OP_RESERVED; 
    4948 
    50    if ((result = verify_cmos_op(e->bit, e->length)) != OK) 
     49   if ((result = verify_cmos_op(e->bit, e->length, e->config)) != OK) 
    5150      return result; 
    5251 
     
    7170    { case CMOS_ENTRY_ENUM: 
    7271      case CMOS_ENTRY_HEX: 
     72      case CMOS_ENTRY_STRING: 
    7373         break; 
    7474 
     
    9393   unsigned long long out; 
    9494   const char *p; 
     95   char *memory; 
    9596   int negative, result, found_one; 
    9697 
     
    140141         break; 
    141142 
     143      case CMOS_ENTRY_STRING: 
     144         if (e->length < (8 * strlen(value_str))) 
     145            return CMOS_OP_VALUE_TOO_WIDE; 
     146         memory = malloc(e->length / 8); 
     147         memset(memory, 0, e->length / 8); 
     148         strcpy(memory, value_str); 
     149         out = (unsigned long)memory; 
     150         break; 
     151 
    142152      default: 
    143153         BUG();