diff options
| author | Joel Andres Granados <jgranado@redhat.com> | 2008-10-28 14:19:02 +0100 |
|---|---|---|
| committer | Joel Andres Granados <jgranado@redhat.com> | 2008-10-28 14:23:30 +0100 |
| commit | c9de756d4f4dff1f2fafc4b839e23313c6090f5c (patch) | |
| tree | 1286c3d63f6fea6c678a39a6e6b84274f5e1429e /plugins | |
| parent | c3b0571983d7c636f7bab216b82adef7fe1f0f18 (diff) | |
| download | firstaidkit-c9de756d4f4dff1f2fafc4b839e23313c6090f5c.tar.gz firstaidkit-c9de756d4f4dff1f2fafc4b839e23313c6090f5c.tar.xz firstaidkit-c9de756d4f4dff1f2fafc4b839e23313c6090f5c.zip | |
Grub Plugin:
1. Add a search for the window bootloader. This search is based on
http://en.wikipedia.org/wiki/Master_boot_record and will be the plugins
default until I or someone more intelligent than me comes up with a better
way of iding windows bootloader.
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/grub/grubUtils.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/plugins/grub/grubUtils.py b/plugins/grub/grubUtils.py index d4bba41..7d1a286 100644 --- a/plugins/grub/grubUtils.py +++ b/plugins/grub/grubUtils.py @@ -15,17 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +import os, os.path, re, subprocess, tempfile, getopt +import minihal, parted import pyfirstaidkit.utils as utils -import os.path -import re -import subprocess -import tempfile -import getopt - -import minihal -import parted - # List of known or expected values for the system. # # Where the grub dir shoulc be with respect to the partition root. @@ -251,6 +244,32 @@ def other_bootloader_present(dev): def none_grub(dev): return False + # Check for presence of windows bootloader. This is taken out of + # http://en.wikipedia.org/wiki/Master_boot_record, if anyone can + # point me to a better source, please do. Moreover, if anyone can + # come up with a better way of doing this please send patch. + windowsStrings = ["Invalid partition table", \ + "Error loading operating system" \ + "Missing operating system"] + def windows_boot_loader(dev): + + # read the first 512 bytes of device. + fd = os.open(dev.path(), os.O_RDONLY) + first512b = os.read(fd, 512) + os.close(fd) + + # Search for the strings that will give the windows partition away. + # We assert that its windows when all the strings are found. + foundstrings = 0 + for string in windowsStrings: + if re.search(string, first512b) != None: + foundstrings = foundstrings + 1 + + if foundstrings == len(windowsStrings): + return True + + return False + # We will have the list of all the tests in the tests variable. tests = [none_grub] |
