Documentation ¶
Index ¶
- Constants
- Variables
- func FreezeFS(fd int) error
- func GetBlockDeviceFromID(devID [2]uint32) (string, error)
- func GetBlockDeviceSectorSize(file *os.File) (int, error)
- func GetBlockDeviceSize(file *os.File) (uint64, error)
- func GetDeviceIDFromPath(path string) ([2]uint32, error)
- func GetPipeSize(fd int) int
- func IsUbiBlockDevice(deviceName string) bool
- func NewCmdLoggerStderr(cmd string) *cmdLogger
- func NewCmdLoggerStdout(cmd string) *cmdLogger
- func SetUbiUpdateVolume(file *os.File, imageSize uint64) error
- func ThawFS(fd int) error
- type Cmd
- type Commander
- type Flusher
- type MountInfo
- type OsCalls
- type StatCommander
- type SysLinux
- type SystemRebootCmd
Constants ¶
const ( // ioctl magics from <linux/fs.h> IOCTL_FIFREEZE_MAGIC uint = 0xC0045877 // _IOWR('X', 119, int) IOCTL_FITHAW_MAGIC uint = 0xC0045878 // _IOWR('X', 120, int) )
Variables ¶
var ( ErrDevNotMounted = fmt.Errorf("device not mounted") NotABlockDevice = fmt.Errorf("not a block device") )
Functions ¶
func FreezeFS ¶
FreezeFS freezes the filesystem for which the inode that fd points to belongs to, maintaining read-consistency. All write operations to the filesystem will be blocked until ThawFS is called.
func GetBlockDeviceFromID ¶
GetBlockDeviceFromID returns the expanded path to the device with the given device ID, devID, on the form [2]uint32{major, minor}
func GetDeviceIDFromPath ¶
GetDeviceIDFromPath retrieves the device id for the block device pointed to by the inode at path.
func GetPipeSize ¶
GetPipeSize returns the buffer-size of a pipe or 1 if the file descriptor is not a pipe.
func IsUbiBlockDevice ¶
func NewCmdLoggerStderr ¶
func NewCmdLoggerStderr(cmd string) *cmdLogger
func NewCmdLoggerStdout ¶
func NewCmdLoggerStdout(cmd string) *cmdLogger
func ThawFS ¶
ThawFS unfreezes the filesystem after FreezeFS is called. The error returned by this function is system critical, if we can't unfreeze the filesystem, we need to ask the user to run `fsfreeze -u /` if this fails then the user has no option but to "pull the plug" (or sys request unfreeze?)
Types ¶
type Cmd ¶
func Command ¶
Command wraps the golang/exec Cmd struct, and captures the stderr/stdout output by default, and logs properly.
func (*Cmd) CombinedOutput ¶
func (*Cmd) StderrPipe ¶
func (c *Cmd) StderrPipe() (io.ReadCloser, error)
func (*Cmd) StdoutPipe ¶
func (c *Cmd) StdoutPipe() (io.ReadCloser, error)
type MountInfo ¶
type MountInfo struct { // MountID: is the unique identifier of the mount MountID uint32 // (1) // ParentID: is the MountID of the parent (or self if on top) ParentID uint32 // (2) // DevID: is the st_dev uint32{Major, Minor} number of the device DevID [2]uint32 // (3) // Root: root of the mount within the filesystem Root string // (4) // MountPoint: mount point relative to the process's root MountPoint string // (5) // MountSource: filesystem specific information or "none" MountSource string // (10) // FSType: name of the filesystem of the form "type[.subtype]" FSType string // (9) // MountOptions: per mount options MountOptions []string // (6) // TagFields: optional list of fields of the form "tag[:value]" TagFields []string // (7) // SuperOptions: per super block options SuperOptions []string // (11) }
MountInfo maps a single line in /proc/<pid|self>/mountinfo See the linux kernel documentation: linux/Documentation/filesystems/proc.txt A line takes the form: 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
func GetMountInfoFromDeviceID ¶
GetMountInfoFromDeviceID parses /proc/self/mountinfo and, on success, returns a populated MountInfo for the device given the devID ([2]uint32{major, minor}). If the device is not mounted ErrDevNotMounted is returned, otherwise the function returns an internal error with a descriptive error message. NOTE: You can get the mount info of an arbitrary path by first calling
"GetDeviceIDFromPath".
Pro tip: use together with GetDeviceIDFromPath to get
type SysLinux ¶
type SysLinux interface { Stat(string, *stat) error RawSyscall(uintptr, uintptr, uintptr, uintptr) (uintptr, uintptr, unix.Errno) IoctlSetInt(int, uint, int) error OpenMountInfo() (io.ReadCloser, error) DeviceFromID([2]uint32) (string, error) GetPipeSize(fd int) int }
SysLinux wraps the interface to unix-specific system calls or functions that make assertions about the system is running linux.
type SystemRebootCmd ¶
type SystemRebootCmd struct {
// contains filtered or unexported fields
}
func NewSystemRebootCmd ¶
func NewSystemRebootCmd(command Commander) *SystemRebootCmd
func (*SystemRebootCmd) Reboot ¶
func (s *SystemRebootCmd) Reboot() error