From 4ef8b6883032a540e7744c2c48c973fc7fcd3cf4 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 7 Apr 2014 20:30:05 +0100
Subject: [PATCH 04/17] Abort run on fatal IO exceptions

Abort the run if a plugin hits a fatal write IO exception (EROFS,
ENOSPC). Do not clean up the temporary tree.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/sosreport.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sos/sosreport.py b/sos/sosreport.py
index 862476c..f27df40 100755
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -45,6 +45,7 @@ from time import strftime, localtime
 from itertools import *
 from collections import deque
 from textwrap import fill
+import errno
 
 from sos import _sos as _
 from sos import __version__
@@ -733,6 +734,13 @@ No changes will be made to system configuration.
     for plugname, plug in GlobalVars.loadedplugins:
         try:
             plug.setup()
+        except IOError as e:
+            if e.errno in (errno.ENOSPC, errno.EROFS):
+                print _("Fatal error writing archive:")
+                print e
+                print _("Aborting.")
+                doExit(1)
+
         except KeyboardInterrupt:
             raise
         except:
@@ -756,6 +764,13 @@ No changes will be made to system configuration.
         plugname, plug = i[0]
         try:
             plug.copyStuff()
+        except IOError as e:
+            if e.errno in (errno.ENOSPC, errno.EROFS):
+                print
+                print _("Fatal error writing archive:")
+                print e
+                print _("Aborting.")
+                doExit(1)
         except KeyboardInterrupt:
             raise
         except:
-- 
1.9.3

