[PATCH 3/3] Improve message given to user for fsck failures (#527626).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 storage/formats/fs.py |   53 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 7255a9e..b53eabd 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,9 @@ class FS(DeviceFormat):
         argv.append(self.device)
         return argv
 
+    def _fsckFailed(self, rc):
+        return False
+
     def doCheck(self, intf=None):
         if not self.exists:
             raise FSError("filesystem has not been created")
@@ -486,8 +490,30 @@ 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,)
+
+            if rc in self._fsckErrors.keys():
+                msg = self._fsckErrors[rc]
+            else:
+                msg = _("Unknown return code: %d.") % (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 correct 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,11 @@ class Ext2FS(FS):
     _existingSizeFields = ["Block count:", "Block size:"]
     partedSystem = fileSystemType["ext2"]
 
+    def _fsckFailed(self, rc):
+        if rc >= 4:
+            return True
+        return False
+
     def doMigrate(self, intf=None):
         FS.doMigrate(self, intf=intf)
         self.tuneFS()
@@ -932,6 +968,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 +979,11 @@ 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
+
 register_device_format(FATFS)
 
 
@@ -1189,6 +1233,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. """
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux