summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2001-07-11 01:59:24 +0000
committerJeremy Katz <katzj@redhat.com>2001-07-11 01:59:24 +0000
commita7bab3f6865cc2ffcfe36c855145976bbbb6200a (patch)
tree90011d9fb12a5306faadcb6d834d1e4393f3abb1
parent3f3a0483d9a72a5a1111fd3bf6b1ec318aaf0201 (diff)
downloadanaconda-a7bab3f6865cc2ffcfe36c855145976bbbb6200a.tar.gz
anaconda-a7bab3f6865cc2ffcfe36c855145976bbbb6200a.tar.xz
anaconda-a7bab3f6865cc2ffcfe36c855145976bbbb6200a.zip
badblocks support -- have to do this before even formatting swap as they
might want to check their swap for badblocks. also, still needs to parse the output and have a progress bar post-beta 2
-rw-r--r--fsset.py41
-rw-r--r--iw/partition_gui.py33
-rw-r--r--kickstart.py8
-rw-r--r--packages.py1
-rw-r--r--partitioning.py7
-rw-r--r--textw/partition_text.py38
6 files changed, 121 insertions, 7 deletions
diff --git a/fsset.py b/fsset.py
index be82d7c06..73c953778 100644
--- a/fsset.py
+++ b/fsset.py
@@ -130,6 +130,16 @@ class FileSystemType:
def registerDeviceArgumentFunction(self, klass, function):
self.deviceArguments[klass] = function
+ def badblocksDevice(self, entry, progress, chroot='/'):
+ devicePath = entry.device.setupDevice(chroot)
+ args = [ "badblocks", "-vv", devicePath ]
+
+ rc = iutil.execWithRedirect("/usr/sbin/badblocks", args,
+ stdout = "/dev/tty5",
+ stderr = "/dev/tty5")
+ if rc:
+ raise SystemError
+
def formatDevice(self, devicePath, device, progress, chroot='/'):
if self.isFormattable():
raise RuntimeError, "formatDevice method not defined"
@@ -635,6 +645,9 @@ class FileSystemSet:
def formatEntry(self, entry, chroot):
entry.fsystem.formatDevice(entry, self.progressWindow, chroot)
+
+ def badblocksEntry(self, entry, chroot):
+ entry.fsystem.badblocksDevice(entry, self.progressWindow, chroot)
def formattablePartitions(self):
list = []
@@ -643,6 +656,24 @@ class FileSystemSet:
list.append (entry)
return list
+ def checkBadblocks(self, chroot='/'):
+ for entry in self.entries:
+ if (not entry.fsystem.isFormattable() or not entry.getBadblocks()
+ or entry.isMounted()):
+ continue
+ try:
+ self.badblocksEntry(entry, chroot)
+ except SystemError:
+ if self.messageWindow:
+ self.messageWindow(_("Error"),
+ _("An error occurred searching for "
+ "bad blocks on %s. This problem is "
+ "serious, and the install cannot "
+ "continue.\n\n"
+ "Press Enter to reboot your system.")
+ % (entry.device.getDevice(),))
+ sys.exit(0)
+
def makeFilesystems (self, chroot='/'):
for entry in self.entries:
if (not entry.fsystem.isFormattable() or not entry.getFormat()
@@ -766,7 +797,8 @@ class FileSystemSetEntry:
def __init__ (self, device, mountpoint,
fsystem=None, options=None,
origfsystem=None, migrate=0,
- order=-1, fsck=-1, format=0):
+ order=-1, fsck=-1, format=0,
+ badblocks = 0):
if not fsystem:
fsystem = fileSystemTypeGet("ext2")
self.device = device
@@ -798,6 +830,7 @@ class FileSystemSetEntry:
"but has been added to fsset with format "
"flag on" % fsystem.getName())
self.format = format
+ self.badblocks = badblocks
def mount(self, chroot='/', devPrefix='/tmp'):
device = self.device.setupDevice(chroot, devPrefix=devPrefix)
@@ -809,6 +842,12 @@ class FileSystemSetEntry:
self.fsystem.umount(self.device, "%s/%s" % (chroot,
self.mountpoint))
self.mountcount = self.mountcount - 1
+
+ def setBadblocks(self, state):
+ self.badblocks = state
+
+ def getBadblocks(self):
+ return self.badblocks
def setFormat (self, state):
if self.migrate:
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index fc6028981..16afb3b65 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -626,6 +626,9 @@ class PartitionWindow(InstallWindow):
def formatOptionCB(widget, menu):
menu.set_sensitive(widget.get_active())
+ def noformatCB(widget, badblocks):
+ badblocks.set_sensitive(not widget.get_active())
+
def sizespinchangedCB(widget, fillmaxszsb):
size = widget.get_value_as_int()
maxsize = fillmaxszsb.get_value_as_int()
@@ -855,6 +858,17 @@ class PartitionWindow(InstallWindow):
else:
migraterb = None
+
+ badblocks = GtkCheckButton(_("Check for bad blocks?"))
+ badblocks.set_active(0)
+ maintable.attach(badblocks, 0, 1, row, row + 1)
+ noformatrb.connect("toggled", noformatCB, badblocks)
+ noformatCB(noformatrb, badblocks)
+ if origrequest.badblocks:
+ badblocks.set_active(1)
+
+ row = row + 1
+
else:
noformatrb = None
formatrb = None
@@ -882,6 +896,13 @@ class PartitionWindow(InstallWindow):
primonlycheckbutton.set_active(1)
maintable.attach(primonlycheckbutton, 0, 2, row, row+1)
row = row + 1
+
+ badblocks = GtkCheckButton(_("Check for bad blocks?"))
+ badblocks.set_active(0)
+ maintable.attach(badblocks, 0, 1, row, row + 1)
+ row = row + 1
+ if origrequest.badblocks:
+ badblocks.set_active(1)
# put main table into dialog
dialog.vbox.pack_start(maintable)
@@ -914,6 +935,11 @@ class PartitionWindow(InstallWindow):
else:
primonly = None
+ if badblocks and badblocks.get_active():
+ request.badblocks = TRUE
+ else:
+ request.badblocks = None
+
if not newbycyl:
if fixedrb.get_active():
grow = None
@@ -962,8 +988,14 @@ class PartitionWindow(InstallWindow):
request.format = formatrb.get_active()
if request.format:
request.fstype = fstypeMenu.get_active().get_data("type")
+ if badblocks and badblocks.get_active():
+ request.badblocks = TRUE
+ else:
+ request.badblocks = None
+
else:
request.format = 0
+ request.badblocks = None
if migraterb:
request.migrate = migraterb.get_active()
@@ -1175,6 +1207,7 @@ class PartitionWindow(InstallWindow):
formatButton.set_active(0)
maintable.attach(formatButton, 0, 2, row, row + 1)
row = row + 1
+
else:
formatButton = None
diff --git a/kickstart.py b/kickstart.py
index 3a5291752..e00f8bf49 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -681,12 +681,14 @@ class KickstartBase(BaseInstallClass):
uniqueID = None
start = None
end = None
+ badblocks = None
(args, extra) = isys.getopt(args, '', [ 'size=', 'maxsize=',
'grow', 'onpart=', 'ondisk=',
'bytes-per-inode=', 'usepart=',
'type=', 'fstype=', 'asprimary',
- 'noformat', 'start=', 'end='])
+ 'noformat', 'start=', 'end=',
+ 'badblocks'])
for n in args:
(str, arg) = n
@@ -719,6 +721,8 @@ class KickstartBase(BaseInstallClass):
start = arg
elif str == "--end":
end = arg
+ elif str == "--badblocks":
+ badblocks = 1
if len(extra) != 1:
raise ValueError, "partition command requires one anonymous argument"
@@ -756,6 +760,8 @@ class KickstartBase(BaseInstallClass):
request.format = 0
if id:
request.uniqueID = uniqueID
+ if badblocks:
+ request.badblocks = badblocks
id.partitions.autoPartitionRequests.append(request)
diff --git a/packages.py b/packages.py
index 3d67b892f..81846f2b1 100644
--- a/packages.py
+++ b/packages.py
@@ -305,6 +305,7 @@ def turnOnFilesystems(dir, thefsset, diskset, upgrade, instPath):
if not upgrade.get():
thefsset.setActive(diskset)
diskset.savePartitions ()
+ thefsset.checkBadblocks(instPath)
thefsset.formatSwap(instPath)
thefsset.turnOnSwap(instPath)
thefsset.migrateFilesystems (instPath)
diff --git a/partitioning.py b/partitioning.py
index 24aa96b97..49b1bc50c 100644
--- a/partitioning.py
+++ b/partitioning.py
@@ -503,7 +503,7 @@ class PartitionSpec:
format = None, options = None,
constraint = None, migrate = None,
raidmembers = None, raidlevel = None,
- raidspares = None):
+ raidspares = None, badblocks = None):
#
# requesttype: REQUEST_PREEXIST or REQUEST_NEW or REQUEST_RAID
#
@@ -529,6 +529,7 @@ class PartitionSpec:
self.drive = drive
self.primary = primary
self.format = format
+ self.badblocks = badblocks
self.migrate = migrate
self.options = options
self.constraint = constraint
@@ -600,6 +601,10 @@ class PartitionSpec:
if self.migrate:
entry.setMigrate(self.migrate)
+
+ if self.badblocks:
+ entry.setBadblocks(self.badblocks)
+
return entry
class Partitions:
diff --git a/textw/partition_text.py b/textw/partition_text.py
index b5a02db10..0d7330967 100644
--- a/textw/partition_text.py
+++ b/textw/partition_text.py
@@ -397,7 +397,13 @@ class PartitionWindow:
subgrid.setField(entry, 0, 0, (0,0,1,0))
return (entry, subgrid)
- def fsOptionsDialog(self, origrequest, format, migrate, newfstype):
+ def fsOptionsDialog(self, origrequest, format, migrate, newfstype, badblocks):
+
+ def formatChanged((formatrb, badblocksCB)):
+ flag = FLAGS_SET
+ if formatrb.selected():
+ flag = FLAGS_RESET
+ badblocksCB.setFlags(FLAG_DISABLED, flag)
poplevel = GridFormHelp(self.screen, _("Filesystem Options"),
"fsoption", 1, 6)
@@ -408,6 +414,8 @@ class PartitionWindow:
row = row + 1
subgrid = Grid(2, 5)
srow = 0
+ badblocksCB = Checkbox(_("Check for bad blocks"))
+
noformatrb = SingleRadioButton(_("Leave unchanged (preserve data)"),
None, not format and not migrate)
subgrid.setField(noformatrb, 0, srow, (0,0,0,1),anchorLeft = 1)
@@ -418,6 +426,9 @@ class PartitionWindow:
else:
forflag = 0
formatrb = SingleRadioButton(_("Format as:"), noformatrb, forflag)
+ formatrb.setCallback(formatChanged, (formatrb, badblocksCB))
+ noformatrb.setCallback(formatChanged, (formatrb, badblocksCB))
+
subgrid.setField(formatrb, 0, srow, (0,0,0,1), anchorLeft = 1)
(fortype, forgrid) = self.makeFsList(origrequest, usecallback = 0,
@@ -434,6 +445,7 @@ class PartitionWindow:
else:
migflag = 0
migraterb = SingleRadioButton(_("Migrate to:"), formatrb, migflag)
+ migraterb.setCallback(formatChanged, (formatrb, badblocksCB))
subgrid.setField(migraterb, 0, srow, (0,0,0,1), anchorLeft = 1)
migtypes = origrequest.origfstype.getMigratableFSTargets()
@@ -451,6 +463,14 @@ class PartitionWindow:
poplevel.add(subgrid, 0, row, (0,1,0,1))
row = row + 1
+
+ poplevel.add(badblocksCB, 0, row, (0,1,0,1))
+ if badblocks:
+ badblocksCB.setValue("*")
+ row = row + 1
+
+ formatChanged((formatrb, badblocksCB))
+
popbb = ButtonBar(self.screen, (TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON))
poplevel.add(popbb, 0, row, (0,0,0,0), growx = 1)
@@ -459,7 +479,7 @@ class PartitionWindow:
if popbb.buttonPressed(res) == 'cancel':
self.screen.popWindow()
- return (format, migrate, newfstype)
+ return (format, migrate, newfstype, badblocks)
if noformatrb.selected():
format = 0
@@ -475,7 +495,7 @@ class PartitionWindow:
newfstype = migtype.current()
self.screen.popWindow()
- return (format, migrate, newfstype)
+ return (format, migrate, newfstype, badblocksCB.selected())
def editPartitionRequest(self, origrequest):
poplevel = GridFormHelp(self.screen,_("Add Partition"),"addpart", 1, 6)
@@ -521,6 +541,11 @@ class PartitionWindow:
row = row + 1
primary = Checkbox(_("Force to be a primary partition"))
poplevel.add(primary, 0, row, (0,1,0,0))
+ row = row + 1
+ badblocksCB = Checkbox(_("Check for bad blocks"))
+ poplevel.add(badblocksCB, 0, row)
+ if origrequest.badblocks:
+ badblocksCB.setValue("*")
fsoptLbl = None
@@ -546,6 +571,7 @@ class PartitionWindow:
format = origrequest.format
migrate = origrequest.migrate
newfstype = origrequest.fstype
+ badblocks = origrequest.badblocks
row = row + 1
if origrequest.type == REQUEST_NEW:
@@ -574,7 +600,7 @@ class PartitionWindow:
return
if popbb.buttonPressed(res) == 'fsopts':
- (format, migrate, newfstype) = self.fsOptionsDialog(origrequest, format, migrate, newfstype)
+ (format, migrate, newfstype, badblocks) = self.fsOptionsDialog(origrequest, format, migrate, newfstype, badblocks)
self.fstypeSet((newfstype, self.mount))
type.setText(newfstype.getName())
continue
@@ -596,6 +622,8 @@ class PartitionWindow:
request.format = TRUE
request.primary = primonly
+ request.badblocks = badblocksCB.selected()
+
if origrequest.start == None:
request.size = int(size.value())
@@ -620,6 +648,7 @@ class PartitionWindow:
request.drive = allowdrives
else:
request.start = int(start.value())
+ request.badblocks = badblocks
cyltype = cylopts.getSelection()
if cyltype == "end":
@@ -645,6 +674,7 @@ class PartitionWindow:
origrequest.format = format
origrequest.migrate = migrate
origrequest.fstype = newfstype
+ origrequest.badblocks = badblocks
err = sanityCheckPartitionRequest(self.partitions, origrequest)
if err: