Documentation ¶
Overview ¶
Package device defines reserved virtual kernel devices and structures for managing them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SimpleDevices = newRegistry()
SimpleDevices is the system-wide simple device registry. This is saved/restored by kernel.Kernel, but defined here to allow access without depending on the kernel package. See kernel.Kernel.deviceRegistry.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { ID // contains filtered or unexported fields }
Device is a simple virtual kernel device.
+stateify savable
func NewAnonDevice ¶
func NewAnonDevice() *Device
NewAnonDevice creates a new anonymous device. Packages that require an anonymous device should initialize the device in a global variable in a file called device.go:
var myDevice = device.NewAnonDevice()
func (*Device) StateFields ¶
func (*Device) StateTypeName ¶
type ID ¶
ID identifies a device.
+stateify savable
func (*ID) DeviceID ¶
DeviceID formats a major and minor device number into a standard device number.
func (*ID) StateFields ¶
func (*ID) StateTypeName ¶
type MultiDevice ¶
type MultiDevice struct { ID // contains filtered or unexported fields }
MultiDevice allows for remapping resources that come from a variety of raw devices into a single device. The device ID should be one of the static Device IDs above and cannot be reused.
func NewAnonMultiDevice ¶
func NewAnonMultiDevice() *MultiDevice
NewAnonMultiDevice creates a new multi-keyed anonymous device. Packages that require a multi-key anonymous device should initialize the device in a global variable in a file called device.go:
var myDevice = device.NewAnonMultiDevice()
func (*MultiDevice) Load ¶
func (m *MultiDevice) Load(key MultiDeviceKey, value uint64) bool
Load loads a raw device and inode into MultiDevice inode mappings with value as the virtual inode.
By design, inodes start from 1 and continue until max uint64. This means that the zero value, which is often the uninitialized value, can be rejected as invalid.
func (*MultiDevice) Map ¶
func (m *MultiDevice) Map(key MultiDeviceKey) uint64
Map maps a raw device and inode into the inode space of MultiDevice, returning a virtualized inode. Raw devices and inodes can be reused; in this case, the same virtual inode will be returned.
type MultiDeviceKey ¶
MultiDeviceKey provides a hashable key for a MultiDevice. The key consists of a raw device and inode for a resource, which must consistently identify the unique resource. It may optionally include a secondary device if appropriate.
Note that using the path is not enough, because filesystems may rename a file to a different backing resource, at which point the path points to a different entity. Using only the inode is also not enough because the inode is assumed to be unique only within the device on which the resource exists.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks all simple devices and related state on the system for save/restore.
The set of devices across save/restore must remain consistent. That is, no devices may be created or removed on restore relative to the saved system. Practically, this means do not create new devices specifically as part of restore.
+stateify savable
func (*Registry) LoadFrom ¶
LoadFrom initializes the internal state of all devices in r from other. The set of devices in both registries must match. Devices may not be created or destroyed across save/restore.