[Gluster-devel] bootloader patch for gpartdump

amar at zresearch.com amar at zresearch.com
Thu Mar 23 07:08:30 UTC 2006


Sorry for not attaching the file in earlier mail

-amar
-------------- next part --------------
diff -pru gluster-orig/extensions/gpartdump/gpartdump.py gluster-alpha1-gprobe/extensions/gpartdump/gpartdump.py
--- gluster-orig/extensions/gpartdump/gpartdump.py	2006-03-19 21:50:30.000000000 +0530
+++ gluster-alpha1-gprobe/extensions/gpartdump/gpartdump.py	2006-03-23 12:33:35.000000000 +0530
@@ -61,6 +61,11 @@ def write_dump (fd, disks):
                           (part_name,
                            fstab_part,
                            disk[part_no]['FSTAB'][fstab_part]))
+            for bootloader in disk[part_no]['BLOADER'].keys ():
+                fd.write ('bootloader:%s:%s:%s\n' %
+                          (part_name,
+                           bootloader,
+                           disk[part_no]['BLOADER'][bootloader]))
 
 
 def read_gdump (fd):
@@ -72,12 +77,17 @@ def read_gdump (fd):
             (d, p) = get_disk_part (pieces[1])
             _disks[d][p]['FSTAB'][pieces[2]] = pieces[3]
             continue
+        if pieces[0] == 'bootloader':
+            (d, p) = get_disk_part (pieces[1])
+            _disks[d][p]['BLOADER'][pieces[2]] = pieces[3]
+            continue
         (d, p) = get_disk_part (pieces[0])
         if not _disks.has_key (d):
             _disks[d] = {}
         if not _disks[d].has_key (p):
             _disks[d][p] = {}
         _disks[d][p]['FSTAB'] = {}
+        _disks[d][p]['BLOADER'] = {}
         _disks[d][p]['TYPE'] = pieces[1]
         _disks[d][p]['FS'] = pieces[2]
         _disks[d][p]['LABEL'] = pieces[3]
diff -pru gluster-orig/extensions/gpartdump/gprobe gluster-alpha1-gprobe/extensions/gpartdump/gprobe
--- gluster-orig/extensions/gpartdump/gprobe	2006-03-19 21:50:30.000000000 +0530
+++ gluster-alpha1-gprobe/extensions/gpartdump/gprobe	2006-03-23 12:36:20.000000000 +0530
@@ -7,18 +7,18 @@ from gpartdump import *
 distro_db = {
     'slackware' : ['/etc/slackware-version',
                    'slack_style',
-                   'cat /etc/slackware-version'],
+                   'cat etc/slackware-version'],
     'debian' : [ '/etc/debian_version',
                  'debian_style',
-                 'echo Debian `cat /etc/debian_version`'],
+                 'echo Debian `cat etc/debian_version`'],
     'redhat' : ['/etc/redhat-release',
                 'redhat_style',
-                'cat /etc/redhat-release'],
+                'cat etc/redhat-release'],
 
     'unknown_slack' : [ '/etc/rc.d/rc.inet1',
                         'slack_style',
                         'echo unknown Slackware style distribution'],
-    'unknown_debian' : [ '/etc/interfaces' ,
+    'unknown_debian' : [ '/etc/network/interfaces' ,
                          'debian_style',
                          'echo unknown Debian style distribution'],
     'unknown_redhat' : [ '/etc/sysconfig/network-scripts',
@@ -26,6 +26,37 @@ distro_db = {
                          'echo unknown Redhat style distribution']
     }
 
+def get_bootloader (part, _fstab):
+    (need_umount, mpoint) = get_mpoint (part)
+    if not mpoint:
+        return {}
+    bootloader = {}
+    
+    if os.access ("%s/etc/lilo.conf" % mpoint, os.R_OK):
+        hnd = os.popen ("grep 'boot *=' %s/etc/lilo.conf | cut -f 2 -d '='"
+                        % mpoint)
+        bootloader['lilo'] = hnd.readline ().strip ()
+        hnd.close ()
+    if os.access ("%s/boot/grub/menu.lst" % mpoint, os.R_OK):
+        bootloader['grub'] = 'default'
+    # If /boot is mapped to another partition, then check for
+    # grub/menu.lst in the path
+    for k, v in _fstab.iteritems ():
+        if '/boot' == v:
+            (tmp_need_umount, tmp_mpoint) = get_mpoint (k)
+            if not tmp_mpoint:
+                unget_mpoint (need_umount, mpoint)
+                return {}
+            if os.access ("%s/grub/menu.lst" % tmp_mpoint, os.R_OK):
+                bootloader['grub'] = 'default'
+            unget_mpoint (tmp_need_umount, tmp_mpoint)
+            
+    if os.access ("%s/ntldr" % mpoint, os.R_OK) \
+           or os.access ("%s/boot.ini" % mpoint, os.R_OK):
+        bootloader['windows'] = part #need to check this still
+                    
+    unget_mpoint (need_umount, mpoint)
+    return bootloader
 
 
 def get_fstab (part, _parts):
@@ -147,9 +178,12 @@ def main ():
             disks[_disk][part_no]['OS'] = os
             disks[_disk][part_no]['DESC'] = desc
             disks[_disk][part_no]['FSTAB'] = {}
+            disks[_disk][part_no]['BLOADER'] = {}
             if os != '':
                 fstab = get_fstab (part_name, _parts)
                 disks[_disk][part_no]['FSTAB'] = fstab
+                bootloader = get_bootloader (part_name, fstab)
+                disks[_disk][part_no]['BLOADER'] = bootloader
             disks[_disk][part_no]['LABEL'] = ''
             if part_name in _parts.keys ():
                 if 'LABEL' in _parts[part_name].keys ():


More information about the Gluster-devel mailing list