Documentation ¶
Overview ¶
Package device defines reserved virtual kernel devices and structures for managing them.
Saving and restoring devices is not necessary if the devices are initialized as package global variables. Package initialization happens in a single goroutine and in a deterministic order, so minor device numbers will be assigned in the same order as packages are loaded.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { ID // contains filtered or unexported fields }
Device is a simple virtual kernel device.
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()
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.