self._canonicalize_subvol_opt

in cookbooks/fb_fstab/libraries/default.rb [180:213]


      def self._canonicalize_subvol_opt(mount, opts)
        type = ''
        value = ''

        opts.split(',').each do |option|
          if option.include?('subvol=') || option.include?('subvolid=')
            data = option.split('=')
            type = data[0]
            value = data[1]
            break
          end
        end

        if type == 'subvolid' && !value.empty?
          return value
        elsif type != 'subvol'
          fail "fb_fstab: Cannot canonicalize subvolume from options: #{opts}"
        end

        cmd = "/usr/sbin/btrfs subvol list #{mount}"
        subvolume_data = Mixlib::ShellOut.new(cmd).run_command
        subvolume_data.error!

        subvolume_data.stdout.each_line do |line|
          
          fields = line.split

          if fields[8] == value
            return fields[1]
          end
        end
        fail "fb_fstab: Cannot canonicalize subvolume: #{opts}"
      end