[blivet/f21/master] Write a fs label for HFS+ ESP

Vratislav Podzimek vpodzime at redhat.com
Mon Jul 21 06:25:22 UTC 2014


On Fri, 2014-07-18 at 17:31 -0700, Brian C. Lane wrote:
> 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         |  8 ++++++++
>  blivet/formats/fslabeling.py | 11 +++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
> index 06d12d5..8724334 100644
> --- a/blivet/formats/fs.py
> +++ b/blivet/formats/fs.py
> @@ -1293,6 +1293,8 @@ class HFSPlus(FS):
>      _mkfs = "mkfs.hfsplus"
>      _fsck = "fsck.hfsplus"
>      _packages = ["hfsplus-tools"]
> +    _labelfs = fslabeling.HFSLabeling()
> +    _maxLabelChars = 128
>      _formattable = True
>      _mountType = "hfsplus"
>      _minSize = Size("1 MiB")
> @@ -1306,6 +1308,7 @@ register_device_format(HFSPlus)
>  class MacEFIFS(HFSPlus):
>      _type = "macefi"
>      _name = N_("Linux HFS+ ESP")
> +    _labelfs = fslabeling.HFSPlusLabeling()
>      _udevTypes = []
>      _minSize = 50
>  
> @@ -1314,6 +1317,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..ea9ab48 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 len(label) < 129 and len(label) > 0
You could rewrite the len(label) testing as '0 < len(label) < 129', pick
the one you like more. ACK.

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list