[blivet:master] Only write label if there is a label AND labeling application.

mulhern amulhern at redhat.com
Tue Oct 21 19:59:28 UTC 2014


Previously, the code attempted to write the label if there was a label
OR no application to do the labeling.
However, the writeLabel() method defensively noticed if there was no label
or no application to do the labeling and raised an error in either case,
which was immediately caught by the enclosing code.

The difference in behavior is that there will be fewer lines of the form
"Failed to write label...[makes no sense..., no application to set...]"
in the storage log, ideally none at all.

There probably weren't very many error messages, as there are few major
filesystems that do not have a labeling application.

Also, use relabels() method in place of equivalent expression.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/formats/fs.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 19b115a..ad9bf98 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -401,7 +401,7 @@ class FS(DeviceFormat):
         self.exists = True
         self.notifyKernel()
 
-        if self.label is not None or not self.relabels():
+        if self.label is not None and self.relabels():
             try:
                 self.writeLabel()
             except FSError as e:
@@ -637,7 +637,7 @@ class FS(DeviceFormat):
         if not os.path.exists(self.device):
             raise FSError("device does not exist")
 
-        if not self._labelfs or not self._labelfs.label_app or not self._labelfs.label_app.reads:
+        if not self.relabels() or not self._labelfs.label_app.reads:
             raise FSError("no application to read label for filesystem %s" % self.type)
 
         (rc, out) = util.run_program_and_capture_output(self._labelfs.label_app.readLabelCommand(self))
@@ -667,7 +667,7 @@ class FS(DeviceFormat):
         if not self.exists:
             raise FSError("filesystem has not been created")
 
-        if not self._labelfs or not self._labelfs.label_app:
+        if not self.relabels():
             raise FSError("no application to set label for filesystem %s" % self.type)
 
         if not self.labelFormatOK(self.label):
-- 
1.9.3



More information about the anaconda-patches mailing list