github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/gadget/export_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2019 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package gadget
    21  
    22  type (
    23  	ValidationState          = validationState
    24  	MountedFilesystemUpdater = mountedFilesystemUpdater
    25  	RawStructureUpdater      = rawStructureUpdater
    26  )
    27  
    28  type LsblkFilesystemInfo = lsblkFilesystemInfo
    29  type LsblkBlockDevice = lsblkBlockDevice
    30  type SFDiskPartitionTable = sfdiskPartitionTable
    31  type SFDiskPartition = sfdiskPartition
    32  
    33  var (
    34  	ValidateStructureType   = validateStructureType
    35  	ValidateVolumeStructure = validateVolumeStructure
    36  	ValidateRole            = validateRole
    37  	ValidateVolume          = validateVolume
    38  
    39  	ResolveVolume      = resolveVolume
    40  	CanUpdateStructure = canUpdateStructure
    41  	CanUpdateVolume    = canUpdateVolume
    42  
    43  	WriteFile = writeFileOrSymlink
    44  
    45  	RawContentBackupPath = rawContentBackupPath
    46  
    47  	UpdaterForStructure = updaterForStructure
    48  
    49  	EnsureVolumeConsistency = ensureVolumeConsistency
    50  
    51  	Flatten = flatten
    52  
    53  	FilesystemInfo                 = filesystemInfo
    54  	OnDiskVolumeFromPartitionTable = onDiskVolumeFromPartitionTable
    55  
    56  	NewRawStructureUpdater      = newRawStructureUpdater
    57  	NewMountedFilesystemUpdater = newMountedFilesystemUpdater
    58  
    59  	FindDeviceForStructureWithFallback = findDeviceForStructureWithFallback
    60  	FindMountPointForStructure         = findMountPointForStructure
    61  
    62  	ParseSize           = parseSize
    63  	ParseRelativeOffset = parseRelativeOffset
    64  )
    65  
    66  func MockEvalSymlinks(mock func(path string) (string, error)) (restore func()) {
    67  	oldEvalSymlinks := evalSymlinks
    68  	evalSymlinks = mock
    69  	return func() {
    70  		evalSymlinks = oldEvalSymlinks
    71  	}
    72  }
    73  
    74  func (m *MountedFilesystemWriter) WriteDirectory(volumeRoot, src, dst string, preserveInDst []string) error {
    75  	return m.writeDirectory(volumeRoot, src, dst, preserveInDst)
    76  }