fs

package
v3.6.8+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fs provides access to the file system on the host.

It exposes ioctl syscall and epoll in an OS agnostic way and permits completely disabling file access to lock down unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IO

func IO(typ, nr uint) uint

IO defines an ioctl with no parameters. It corresponds to _IO in the Linux userland API.

func IOR

func IOR(typ, nr, size uint) uint

IOR defines an ioctl with read (userland perspective) parameters. It corresponds to _IOR in the Linux userland API.

func IOW

func IOW(typ, nr, size uint) uint

IOW defines an ioctl with write (userland perspective) parameters. It corresponds to _IOW in the Linux userland API.

func IOWR

func IOWR(typ, nr, size uint) uint

IOWR defines an ioctl with both read and write parameters. It corresponds to _IOWR in the Linux userland API.

func Inhibit

func Inhibit()

Inhibit inhibits any future file I/O. It panics if any file was opened up to now.

It should only be called in unit tests.

Types

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is a file system event.

func (*Event) MakeEvent

func (e *Event) MakeEvent(fd uintptr) error

MakeEvent initializes an epoll *edge* triggered event on linux.

An edge triggered event is basically an "auto-reset" event, where waiting on the edge resets it. A level triggered event requires manual resetting; this could be done via a Read() call but there's no need to require the user to call Read(). This is particularly useless in the case of gpio.RisingEdge and gpio.FallingEdge.

As per the official doc, edge triggers is still remembered even when no epoll_wait() call is running, so no edge is missed. Two edges will be coallesced into one if the user mode process can't keep up. There's no accumulation of edges.

func (*Event) Wait

func (e *Event) Wait(timeoutms int) (int, error)

Wait waits for an event or the specified amount of time.

type File

type File struct {
	*os.File
}

File is a superset of os.File.

func Open

func Open(path string, flag int) (*File, error)

Open opens a file.

Returns an error if Inhibit() was called.

func (*File) Ioctl

func (f *File) Ioctl(op uint, data uintptr) error

Ioctl sends an ioctl to the file handle.

type Ioctler

type Ioctler interface {
	// Ioctl sends a linux ioctl on the file handle.
	//
	// op is effectively an uint32. op is expected to be encoded in the format on
	// x64. ARM happens to share the same format.
	Ioctl(op uint, data uintptr) error
}

Ioctler is a file handle that supports ioctl calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL