Documentation ¶
Overview ¶
Copyright 2020 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- type BlockDevice
- type BlockDeviceGetSectorSizeFunc
- type BlockDeviceGetSizeFunc
- type BlockDevicer
- type BlockFrameWriter
- type DeltaRootfsInstaller
- func (d DeltaRootfsInstaller) Cleanup() error
- func (d DeltaRootfsInstaller) CommitUpdate() error
- func (d DeltaRootfsInstaller) Failure() error
- func (d DeltaRootfsInstaller) FinishStoreUpdate() error
- func (d DeltaRootfsInstaller) GetActive() (string, error)
- func (d DeltaRootfsInstaller) GetInactive() (string, error)
- func (d DeltaRootfsInstaller) GetType() string
- func (d DeltaRootfsInstaller) Initialize(artifactHeaders artifact.HeaderInfoer, ...) error
- func (d DeltaRootfsInstaller) InstallUpdate() error
- func (d DeltaRootfsInstaller) NeedsReboot() (installer.RebootAction, error)
- func (d DeltaRootfsInstaller) NewUpdateStorer(updateType *string, payloadNum int) (handlers.UpdateStorer, error)
- func (d DeltaRootfsInstaller) PrepareStoreUpdate() error
- func (d DeltaRootfsInstaller) Reboot() error
- func (d DeltaRootfsInstaller) Rollback() error
- func (d DeltaRootfsInstaller) RollbackReboot() error
- func (d DeltaRootfsInstaller) StoreUpdate(r io.Reader, info os.FileInfo) error
- func (d DeltaRootfsInstaller) SupportsRollback() (bool, error)
- func (d DeltaRootfsInstaller) VerifyReboot() error
- func (d DeltaRootfsInstaller) VerifyRollbackReboot() error
- type FlushingWriter
- type OptimizedBlockDeviceWriter
Constants ¶
This section is empty.
Variables ¶
var ( BlockDeviceGetSizeOf BlockDeviceGetSizeFunc = system.GetBlockDeviceSize BlockDeviceGetSectorSizeOf BlockDeviceGetSectorSizeFunc = system.GetBlockDeviceSectorSize )
Functions ¶
This section is empty.
Types ¶
type BlockDevice ¶
type BlockDevice struct { Path string // Device path, ex. /dev/mmcblk0p1 // contains filtered or unexported fields }
BlockDevice is a low-level wrapper for a block device. The wrapper implements the io.Writer and io.Closer interfaces, which is all that is needed by the rdfm-client.
func (*BlockDevice) Close ¶
func (bd *BlockDevice) Close() error
Close closes the underlying block device, thus automatically syncing any unwritten data. Othewise, behaves like io.Closer.
func (*BlockDevice) SectorSize ¶
func (bd *BlockDevice) SectorSize() (int, error)
SectorSize queries the logical sector size of the underlying block device. Automatically opens a new fd in O_RDONLY mode, thus can be used in parallel to other operations.
func (*BlockDevice) Size ¶
func (bd *BlockDevice) Size() (uint64, error)
Size queries the size of the underlying block device. Automatically opens a new fd in O_RDONLY mode, thus can be used in parallel to other operations.
func (*BlockDevice) Write ¶
func (bd *BlockDevice) Write(b []byte) (n int, err error)
Write writes data 'b' to the underlying writer. Although this is just one line, the underlying implementation is currently slightly more involved. The BlockDevice writer will write to a chain of writers as follows:
LimitWriter Make sure that no more than image-size bytes are written to the block-device. | | v BlockFrameWriter Buffers the writes into 'chunkSize' frames for writing to the underlying writer. | | v OptimizedBlockDeviceWriter Only writes dirty frames to the underlying block-device. Note: This is not done for UBI volumes | | v BlockDevicer This is an interface with all the main functionality of a file, and is in this case a FlushingWriter, which writes a chunk to the underlying file-descriptor, and then calls Sync() on every 'FlushIntervalBytes' written.
Due to the underlying writer caching writes, the block-device needs to be closed, in order to make sure that all data has been flushed to the device.
type BlockDeviceGetSectorSizeFunc ¶
BlockDeviceGetSectorSizeFunc is a helper for obtaining the sector size of a block device.
type BlockDeviceGetSizeFunc ¶
BlockDeviceGetSizeFunc is a helper for obtaining the size of a block device.
type BlockDevicer ¶
type BlockDevicer interface { io.Reader io.Writer io.Closer io.Seeker Sync() error // Commits previously-written data to stable storage. }
BlockDevicer is a file-like interface for the block-device.
type BlockFrameWriter ¶
type BlockFrameWriter struct {
// contains filtered or unexported fields
}
func (*BlockFrameWriter) Close ¶
func (bw *BlockFrameWriter) Close() error
Close flushes the remaining cached bytes -- if any.
type DeltaRootfsInstaller ¶
type DeltaRootfsInstaller struct { installer.DualRootfsDevice // contains filtered or unexported fields }
This is a simple wrapper class for the original DualRootfsDevice installer. It requires the original DualRootfsDevice created for the current device configuration, to which all regular artifact installation handling is passed. When a delta artifact is being installed, the patch is applied onto a proper base image and installed to the block device.
func NewDeltaInstaller ¶
func NewDeltaInstaller(realDev installer.DualRootfsDevice) DeltaRootfsInstaller
func (DeltaRootfsInstaller) Cleanup ¶
func (d DeltaRootfsInstaller) Cleanup() error
func (DeltaRootfsInstaller) CommitUpdate ¶
func (d DeltaRootfsInstaller) CommitUpdate() error
func (DeltaRootfsInstaller) Failure ¶
func (d DeltaRootfsInstaller) Failure() error
func (DeltaRootfsInstaller) FinishStoreUpdate ¶
func (d DeltaRootfsInstaller) FinishStoreUpdate() error
func (DeltaRootfsInstaller) GetActive ¶
func (d DeltaRootfsInstaller) GetActive() (string, error)
func (DeltaRootfsInstaller) GetInactive ¶
func (d DeltaRootfsInstaller) GetInactive() (string, error)
func (DeltaRootfsInstaller) GetType ¶
func (d DeltaRootfsInstaller) GetType() string
func (DeltaRootfsInstaller) Initialize ¶
func (d DeltaRootfsInstaller) Initialize(artifactHeaders artifact.HeaderInfoer, artifactAugmentedHeaders artifact.HeaderInfoer, payloadHeaders handlers.ArtifactUpdateHeaders) error
func (DeltaRootfsInstaller) InstallUpdate ¶
func (d DeltaRootfsInstaller) InstallUpdate() error
func (DeltaRootfsInstaller) NeedsReboot ¶
func (d DeltaRootfsInstaller) NeedsReboot() (installer.RebootAction, error)
func (DeltaRootfsInstaller) NewUpdateStorer ¶
func (d DeltaRootfsInstaller) NewUpdateStorer(updateType *string, payloadNum int) (handlers.UpdateStorer, error)
func (DeltaRootfsInstaller) PrepareStoreUpdate ¶
func (d DeltaRootfsInstaller) PrepareStoreUpdate() error
func (DeltaRootfsInstaller) Reboot ¶
func (d DeltaRootfsInstaller) Reboot() error
func (DeltaRootfsInstaller) Rollback ¶
func (d DeltaRootfsInstaller) Rollback() error
func (DeltaRootfsInstaller) RollbackReboot ¶
func (d DeltaRootfsInstaller) RollbackReboot() error
func (DeltaRootfsInstaller) StoreUpdate ¶
func (DeltaRootfsInstaller) SupportsRollback ¶
func (d DeltaRootfsInstaller) SupportsRollback() (bool, error)
func (DeltaRootfsInstaller) VerifyReboot ¶
func (d DeltaRootfsInstaller) VerifyReboot() error
func (DeltaRootfsInstaller) VerifyRollbackReboot ¶
func (d DeltaRootfsInstaller) VerifyRollbackReboot() error
type FlushingWriter ¶
type FlushingWriter struct { BlockDevicer FlushIntervalBytes uint64 // contains filtered or unexported fields }
FlushingWriter is a wrapper around a BlockDevice which forces a Sync() to occur every FlushIntervalBytes.
func NewFlushingWriter ¶
func NewFlushingWriter(wf *os.File, flushIntervalBytes uint64) *FlushingWriter
NewFlushingWriter returns a FlushingWriter which wraps the provided block-device (BlockDevicer) and automatically flushes (calls Sync()) each time the specified number of bytes is written. Setting flushIntervalBytes == 0 causes Sync() to be called after every Write().
func (*FlushingWriter) Sync ¶
func (fw *FlushingWriter) Sync() error
type OptimizedBlockDeviceWriter ¶
type OptimizedBlockDeviceWriter struct {
// contains filtered or unexported fields
}
OptimizedBlockDeviceWriter wraps an underlying blockDevice write, however, with the optimization that it compares the bytes passed in to the Write method, with the next len([]byte) bytes (considered a frame) on the block device, and if they match, the write is discarded. The lingo is that only dirty frames are written. Clean ones are discarded.
func (*OptimizedBlockDeviceWriter) Close ¶
func (obw *OptimizedBlockDeviceWriter) Close() error