ia64/xen-unstable

changeset 9029:c7550ed2ccbf

pygrub currently takes a file on the command line to mean a config file
if it can't figure out partitions and filesystems. This then makes it
balloon to absurd sizes. Make this only happen if you pass a debugging
flag

Signed-off-by: Jeremy Katz <katzj@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Feb 26 10:54:06 2006 +0100 (2006-02-26)
parents a861cbd578f2
children af6a564ea81c
files tools/pygrub/src/pygrub
line diff
     1.1 --- a/tools/pygrub/src/pygrub	Sun Feb 26 10:53:18 2006 +0100
     1.2 +++ b/tools/pygrub/src/pygrub	Sun Feb 26 10:54:06 2006 +0100
     1.3 @@ -94,12 +94,18 @@ def get_active_offset(file):
     1.4              return struct.unpack("<L", buf[poff+8:poff+12])[0] * SECTOR_SIZE
     1.5      return -1
     1.6  
     1.7 -def get_config(fn):
     1.8 +def get_config(fn, isconfig = False):
     1.9      if not os.access(fn, os.R_OK):
    1.10          raise RuntimeError, "Unable to access %s" %(fn,)
    1.11  
    1.12      cf = grub.GrubConf.GrubConfigFile()
    1.13  
    1.14 +    if isconfig:
    1.15 +        # set the config file and parse it
    1.16 +        cf.filename = fn
    1.17 +        cf.parse()
    1.18 +        return cf
    1.19 +
    1.20      offset = 0
    1.21      if is_disk_image(fn):
    1.22          offset = get_active_offset(fn)
    1.23 @@ -130,9 +136,7 @@ def get_config(fn):
    1.24          # then parse the grub config
    1.25          cf.parse(buf)
    1.26      else:
    1.27 -        # set the config file and parse it
    1.28 -        cf.filename = fn
    1.29 -        cf.parse()
    1.30 +        raise RuntimeError, "Unable to read filesystem" 
    1.31      
    1.32      return cf
    1.33  
    1.34 @@ -214,7 +218,8 @@ if __name__ == "__main__":
    1.35  
    1.36      try:
    1.37          opts, args = getopt.gnu_getopt(sys.argv[1:], 'qh::',
    1.38 -                                   ["quiet", "help", "output=", "entry="])
    1.39 +                                   ["quiet", "help", "output=", "entry=",
    1.40 +                                    "isconfig"])
    1.41      except getopt.GetoptError:
    1.42          usage()
    1.43          sys.exit(1)
    1.44 @@ -227,6 +232,7 @@ if __name__ == "__main__":
    1.45      output = None
    1.46      entry = None
    1.47      interactive = True
    1.48 +    isconfig = False
    1.49      for o, a in opts:
    1.50          if o in ("-q", "--quiet"):
    1.51              interactive = False
    1.52 @@ -239,13 +245,15 @@ if __name__ == "__main__":
    1.53              entry = a
    1.54              # specifying the entry to boot implies non-interactive
    1.55              interactive = False
    1.56 +        elif o in ("--isconfig",):
    1.57 +            isconfig = True
    1.58  
    1.59      if output is None or output == "-":
    1.60          fd = sys.stdout.fileno()
    1.61      else:
    1.62          fd = os.open(output, os.O_WRONLY)
    1.63  
    1.64 -    cf = get_config(file)
    1.65 +    cf = get_config(file, isconfig)
    1.66      if interactive:
    1.67          curses.wrapper(run_main)
    1.68      else: