From 4e5c9372113656866b5cd6ad01a8e57fc5f5af52 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Wed, 16 Apr 2014 20:34:11 +0100 Subject: Check for file system errors when setting up archive Check for ENOSPC and EROFS when setting up the archive directory structure and exit with failure and an error message. Signed-off-by: Bryn M. Reeves --- sos/sosreport.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sos/sosreport.py b/sos/sosreport.py index c3b2f421..0ae82936 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -35,6 +35,7 @@ supplied for application-specific information import sys import traceback import os +import errno import logging from optparse import OptionParser, Option from sos.plugins import import_plugin @@ -903,17 +904,24 @@ class SoSReport(object): self.soslog.error("%s\n%s" % (plugin_name, traceback.format_exc())) def prework(self): + self.policy.pre_work() try: - self.policy.pre_work() self.ui_log.info(_(" Setting up archive ...")) self._set_archive() self._make_archive_paths() + return + except OSError as e: + if e.errno in (errno.ENOSPC, errno.EROFS): + self.ui_log.error("") + self.ui_log.error(" %s while setting up archive" % e.strerror) + self.ui_log.error(" %s" % e.filename) except Exception as e: import traceback + self.ui_log.error("") self.ui_log.error(" Unexpected exception setting up archive:") traceback.print_exc(e) self.ui_log.error(e) - self._exit(1) + self._exit(1) def setup(self): self.ui_log.info(_(" Setting up plugins ...")) -- cgit