summaryrefslogtreecommitdiffstats
path: root/storage/formats/fs.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-10-16 17:49:04 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-10-19 14:31:38 -1000
commit735b20c7a8d7588806f36f2290dddd2811e9a6eb (patch)
tree793729c9ccbc54cb14b9d71431564e3417959023 /storage/formats/fs.py
parent71d840fd7c664ce0ef73a67b8c1d2d2b36fef5e7 (diff)
downloadanaconda-735b20c7a8d7588806f36f2290dddd2811e9a6eb.tar.gz
anaconda-735b20c7a8d7588806f36f2290dddd2811e9a6eb.tar.xz
anaconda-735b20c7a8d7588806f36f2290dddd2811e9a6eb.zip
Improve message given to user for fsck failures (#527626).
If fsck fails with a return code indicating errors we can't automatically fix, give the user a more descriptive error dialog before exiting. There's not much we can do if the filesystem is beyond automatic repair, so tell the user to repair the filesystem under rescue mode or something similar.
Diffstat (limited to 'storage/formats/fs.py')
-rw-r--r--storage/formats/fs.py66
1 files changed, 64 insertions, 2 deletions
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 7255a9e64..493abb62e 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -110,6 +110,7 @@ class FS(DeviceFormat):
_resizefs = "" # resize utility
_labelfs = "" # labeling utility
_fsck = "" # fs check utility
+ _fsckErrors = {} # fs check command error codes & msgs
_migratefs = "" # fs migration utility
_infofs = "" # fs info utility
_defaultFormatOptions = [] # default options passed to mkfs
@@ -457,6 +458,12 @@ class FS(DeviceFormat):
argv.append(self.device)
return argv
+ def _fsckFailed(self, rc):
+ return False
+
+ def _fsckErrorMessage(self, rc):
+ return _("Unknown return code: %d.") % (rc,)
+
def doCheck(self, intf=None):
if not self.exists:
raise FSError("filesystem has not been created")
@@ -486,8 +493,27 @@ class FS(DeviceFormat):
if w:
w.pop()
- if rc >= 4:
- raise FSError("filesystem check failed: %s" % rc)
+ if self._fsckFailed(rc):
+ hdr = _("%(type)s filesystem check failure on %(device)s: ") % \
+ (self.type, self.device,)
+
+ msg = self._fsckErrorMessage(rc)
+
+ if intf:
+ help = _("Errors like this usually mean there is a problem "
+ "with the filesystem that will require user "
+ "interaction to repair. Before restarting "
+ "installation, reboot to rescue mode or another "
+ "system that allows you to repair the filesystem "
+ "interactively. Restart installation after you "
+ "have corrected the problems on the filesystem.")
+
+ self.intf.messageWindow(_("Unrecoverable Error"),
+ hdr + "\n\n" + msg + "\n\n" + help,
+ custom_icon='error')
+ sys.exit(0)
+ else:
+ raise FSError(hdr + msg)
def loadModule(self):
"""Load whatever kernel module is required to support this filesystem."""
@@ -811,6 +837,11 @@ class Ext2FS(FS):
_resizefs = "resize2fs"
_labelfs = "e2label"
_fsck = "e2fsck"
+ _fsckErrors = {4: _("File system errors left uncorrected."),
+ 8: _("Operational error."),
+ 16: _("Usage or syntax error."),
+ 32: _("e2fsck cancelled by user request."),
+ 128: _("Shared library error.")}
_packages = ["e2fsprogs"]
_formattable = True
_supported = True
@@ -833,6 +864,21 @@ class Ext2FS(FS):
_existingSizeFields = ["Block count:", "Block size:"]
partedSystem = fileSystemType["ext2"]
+ def _fsckFailed(self, rc):
+ for errorCode in self._fsckErrors.keys():
+ if rc & errorCode:
+ return True
+ return False
+
+ def _fsckErrorMessage(self, rc):
+ msg = ''
+
+ for errorCode in self._fsckErrors.keys():
+ if rc & errorCode:
+ msg += "\n" + self._fsckErrors[errorCode]
+
+ return msg.strip()
+
def doMigrate(self, intf=None):
FS.doMigrate(self, intf=intf)
self.tuneFS()
@@ -932,6 +978,9 @@ class FATFS(FS):
_modules = ["vfat"]
_labelfs = "dosfslabel"
_fsck = "dosfsck"
+ _fsckErrors = {1: _("Recoverable errors have been detected or dosfsck has "
+ "discovered an internal inconsistency."),
+ 2: _("Usage error.")}
_supported = True
_formattable = True
_maxSize = 1024 * 1024
@@ -940,6 +989,14 @@ class FATFS(FS):
# FIXME this should be fat32 in some cases
partedSystem = fileSystemType["fat16"]
+ def _fsckFailed(self, rc):
+ if rc >= 1:
+ return True
+ return False
+
+ def _fsckErrorMessage(self, rc):
+ return self._fsckErrors[rc]
+
register_device_format(FATFS)
@@ -1189,6 +1246,11 @@ class NTFS(FS):
_existingSizeFields = ["Cluster Size:", "Volume Size in Clusters:"]
partedSystem = fileSystemType["ntfs"]
+ def _fsckFailed(self, rc):
+ if rc != 0:
+ return True
+ return False
+
@property
def minSize(self):
""" The minimum filesystem size in megabytes. """