[PATCH 2/2] Use _netdev mount option as needed. (#1166509)

Vratislav Podzimek vpodzime at redhat.com
Wed Jan 7 07:26:01 UTC 2015


On Tue, 2015-01-06 at 14:15 -0600, David Lehman wrote:
> The intention is to pass the option as needed when mounting filesystems
> in addition to putting it in /etc/fstab.
> ---
>  blivet/__init__.py          |  1 -
>  blivet/devices/btrfs.py     |  6 ++++--
>  blivet/devices/partition.py |  5 -----
>  blivet/devices/storage.py   | 20 ++++++++++++++++++++
>  tests/devices_test.py       | 30 ++++++++++++++++++++++++++++++
>  5 files changed, 54 insertions(+), 8 deletions(-)
> 
> diff --git a/blivet/__init__.py b/blivet/__init__.py
> index e785053..6742ca5 100644
> --- a/blivet/__init__.py
> +++ b/blivet/__init__.py
> @@ -2803,7 +2803,6 @@ class FSSet(object):
>              options = options or "defaults"
>              for netdev in netdevs:
>                  if device.dependsOn(netdev):
> -                    options = options + ",_netdev"
>                      if root_on_netdev and mountpoint not in ["/", "/usr"]:
>                          options = options + ",x-initrd.mount"
>                      break
> diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
> index 13adbb4..9b5c9ca 100644
> --- a/blivet/devices/btrfs.py
> +++ b/blivet/devices/btrfs.py
> @@ -481,11 +481,13 @@ class BTRFSSubVolumeDevice(BTRFSDevice, RaidDevice):
>              return
>  
>          # propagate mount options specified for members via kickstart
> +        # start with options (not mountopts) so we don't lose the default mount
> +        # options
>          opts = "subvol=%s" % self.name
>          if self.volume.format.mountopts:
> -            opts = "%s,%s" % (self.volume.format.mountopts, opts)
> +            opts = "%s,%s" % (self.volume.format.options, opts)
>  
> -        self.format.mountopts = opts
> +        self.format.mountopts = "%s,%s" % (self.format.options, opts)
>  
>      @property
>      def volume(self):
> diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
> index 24f85b3..c4bd136 100644
> --- a/blivet/devices/partition.py
> +++ b/blivet/devices/partition.py
> @@ -408,11 +408,6 @@ class PartitionDevice(StorageDevice):
>          """ Is this device directly accessible? """
>          return self.isleaf and not self.isExtended
>  
> -    def _setFormat(self, fmt):
> -        """ Set the Device's format. """
> -        log_method_call(self, self.name)
> -        StorageDevice._setFormat(self, fmt)
> -
>      def _setBootable(self, bootable):
>          """ Set the bootable flag for this partition. """
>          if self.partedPartition:
> diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
> index 7bcdc2f..962f83c 100644
> --- a/blivet/devices/storage.py
> +++ b/blivet/devices/storage.py
> @@ -38,6 +38,7 @@ import logging
>  log = logging.getLogger("blivet")
>  
>  from .device import Device
> +from .network import NetworkStorageDevice
>  
>  class StorageDevice(Device):
>      """ A generic storage device.
> @@ -511,6 +512,8 @@ class StorageDevice(Device):
>              self._partedDevice = None
>              self._targetSize = self.currentSize
>  
> +        self._updateNetDevMountOption()
> +
>      #
>      # destroy
>      #
> @@ -630,6 +633,23 @@ class StorageDevice(Device):
>  
>          self._format = fmt
>          self._format.device = self.path
> +        self._updateNetDevMountOption()
> +
> +    def _updateNetDevMountOption(self):
> +        if not self._format.mountable:
> +            return
> +
> +        is_netdev = any(isinstance(a, NetworkStorageDevice)
> +                        for a in self.ancestors)
> +        has_netdev_option = "_netdev" in self._format.options.split(",")
> +        if not is_netdev and has_netdev_option:
> +            mountopts = self._format.mountopts.split(",")
> +            mountopts.remove("_netdev")
> +            self._format.mountopts = mountopts.join(",")
> +        elif is_netdev and not has_netdev_option:
> +            # notice we're appending to options -- not mountopts -- so we get
> +            # the default options, too
> +            self._format.mountopts = self._format.options + ",_netdev"
I think having 'mountopts = self._format.mountopts.split(",")' before
the 'if' and then using it in both code branches would be nicer.

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list