[blivet 1/3] Write a fs label for HFS+ ESP

Brian C. Lane bcl at redhat.com
Mon Jul 21 16:05:05 UTC 2014


Now that we have the ability to set the filesystem label, take advantage
of it to set the HFS+ ESP label to "Linux HFS+ ESP" so that it matches
the partition name and will show up in the OSX file browser.
---
 blivet/formats/fs.py         |  7 +++++++
 blivet/formats/fslabeling.py | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 06d12d5..78566f2 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -1293,6 +1293,7 @@ class HFSPlus(FS):
     _mkfs = "mkfs.hfsplus"
     _fsck = "fsck.hfsplus"
     _packages = ["hfsplus-tools"]
+    _labelfs = fslabeling.HFSPlusLabeling()
     _formattable = True
     _mountType = "hfsplus"
     _minSize = Size("1 MiB")
@@ -1306,6 +1307,7 @@ register_device_format(HFSPlus)
 class MacEFIFS(HFSPlus):
     _type = "macefi"
     _name = N_("Linux HFS+ ESP")
+    _labelfs = fslabeling.HFSPlusLabeling()
     _udevTypes = []
     _minSize = 50
 
@@ -1314,6 +1316,11 @@ class MacEFIFS(HFSPlus):
         return (isinstance(platform.platform, platform.MacEFI) and
                 self.utilsAvailable)
 
+    def __init__(self, **kwargs):
+        if "label" not in kwargs:
+            kwargs["label"] = self._name
+        super(MacEFIFS, self).__init__(**kwargs)
+
 register_device_format(MacEFIFS)
 
 
diff --git a/blivet/formats/fslabeling.py b/blivet/formats/fslabeling.py
index f8d7b42..ef5b4ae 100644
--- a/blivet/formats/fslabeling.py
+++ b/blivet/formats/fslabeling.py
@@ -125,6 +125,17 @@ class HFSLabeling(FSLabeling):
     def labelingArgs(self, label):
         return ["-l", label]
 
+class HFSPlusLabeling(FSLabeling):
+
+    default_label = property(lambda s: "Untitled")
+    label_app = property(lambda s: None)
+
+    def labelFormatOK(self, label):
+        return ':' not in label and 0 < len(label) < 129
+
+    def labelingArgs(self, label):
+        return ["-v", label]
+
 class NTFSLabeling(FSLabeling):
 
     default_label = property(lambda s: "")
-- 
1.9.3



More information about the anaconda-patches mailing list