ia64/xen-unstable

changeset 7759:d5775d0bcf1e

Fix some more bugs in pygrub including:
a) a couple of variables were referenced wrong
b) fix using arrow keys in the menu to act correctly
c) and look for grub config properly for /boot partition

Signed-off-by: Jeremy Katz <katzj@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 10 12:01:15 2005 +0100 (2005-11-10)
parents 06d08564b982
children 74737286e9f5
files tools/pygrub/src/pygrub
line diff
     1.1 --- a/tools/pygrub/src/pygrub	Thu Nov 10 11:59:49 2005 +0100
     1.2 +++ b/tools/pygrub/src/pygrub	Thu Nov 10 12:01:15 2005 +0100
     1.3 @@ -89,8 +89,8 @@ def get_active_offset(file):
     1.4      buf = os.read(fd, 512)
     1.5      for poff in (446, 462, 478, 494): # partition offsets
     1.6          # active partition has 0x80 as the first byte
     1.7 -        if struct.unpack("<c", buf[p:p+1]) == ('\x80',):
     1.8 -            return struct.unpack("<", buf[p+8:p+12])[0] * SECTOR_SIZE
     1.9 +        if struct.unpack("<c", buf[poff:poff+1]) == ('\x80',):
    1.10 +            return struct.unpack("<L", buf[poff+8:poff+12])[0] * SECTOR_SIZE
    1.11      return -1
    1.12  
    1.13  def get_config(fn):
    1.14 @@ -113,11 +113,13 @@ def get_config(fn):
    1.15              break
    1.16  
    1.17      if fs is not None:
    1.18 -        if fs.file_exist("/boot/grub/menu.lst"):
    1.19 -            grubfile = "/boot/grub/menu.lst"
    1.20 -        elif fs.file_exist("/boot/grub/grub.conf"):
    1.21 -            grubfile = "/boot/grub/grub.conf"
    1.22 -        else:
    1.23 +        grubfile = None
    1.24 +        for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
    1.25 +                  "/grub/menu.lst", "/grub/grub.conf"):
    1.26 +            if fs.file_exist(f):
    1.27 +                grubfile = f
    1.28 +                break
    1.29 +        if grubfile is None:
    1.30              raise RuntimeError, "we couldn't find /boot/grub{menu.lst,grub.conf} " + \
    1.31                                  "in the image provided. halt!"
    1.32          f = fs.open_file(grubfile)
    1.33 @@ -169,7 +171,7 @@ def main(cf = None):
    1.34  #        if c == ord('q'):
    1.35  #            selected = -1
    1.36  #            break
    1.37 -        elif c == ord('c'):
    1.38 +        if c == ord('c'):
    1.39              # FIXME: needs to go to command line mode
    1.40              continue
    1.41          elif c == ord('a'):
    1.42 @@ -261,7 +263,7 @@ if __name__ == "__main__":
    1.43  
    1.44      offset = 0
    1.45      if is_disk_image(file):
    1.46 -        offset = get_active_offset(fn)
    1.47 +        offset = get_active_offset(file)
    1.48          if offset == -1:
    1.49              raise RuntimeError, "Unable to find active partition on disk"
    1.50