ioctl

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: ISC Imports: 3 Imported by: 0

README

ioctl

import "acln.ro/ioctl"

Package ioctl provides facilities to define ioctl numbers and perform ioctls against file descriptors.

See the documentation at https://godoc.org/acln.ro/ioctl.

For the time being, pacakge ioctl is only tested and used on amd64, and arm (thanks to @tv42), but it should work on other architectures too, based on my (admittedly rather cursory) reading of Linux header files. Please file a bug if the numbers are wrong for your architecture.

Package ioctl is pure Go, but running tests requires a C compiler and the appropriate C headers. See internal/cgoioctl.

Package ioctl presents itself as a Go module. The current version is v0.9.0.

License

Package ioctl is distributed under the ISC license. A copy of the license can be found in the LICENSE file.

Documentation

Overview

Package ioctl provides facilities to define ioctl numbers and perform ioctls against file descriptors.

The Name field on all ioctl types is optional. If a name is specified, the name will be included in error messages returned by method calls.

In case of errors, all method calls return errors of type Error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v0.3.0

type Error struct {
	// Name is the name of the ioctl, e.g. "KVM_CREATE_VM".
	//
	// This field may be empty, in which case it is not included in the
	// error message.
	Name string

	// Number is the 32 bit ioctl number. It is rendered in hexadecimal
	// in the error message.
	Number uint32

	// Err is the underlying error, of type syscall.Errno.
	Err error
}

Error records an error from an ioctl(2) system call.

func (*Error) Error added in v0.3.0

func (e *Error) Error() string

type N

type N struct {
	Name string
	Type uint16
	Nr   uint16
}

N specifies an ioctl that does not exchange data with the kernel through a pointer. An N can nevertheless have an integer argument.

func (N) Exec

func (n N) Exec(fd int) (int, error)

Exec executes n against fd, with no argument.

func (N) ExecInt added in v0.7.0

func (n N) ExecInt(fd int, val uintptr) (int, error)

ExecInt executes n against fd with the integer argument val.

func (N) Number added in v0.4.0

func (n N) Number() uint32

Number returns the ioctl number associated with n.

type R

type R struct {
	Name string
	Type uint16
	Nr   uint16
	Size uint16
}

R specifies a read ioctl: information is passed from kernel to userspace.

func (R) Number added in v0.4.0

func (r R) Number() uint32

Number returns the ioctl number associated with r.

func (R) Read added in v0.9.0

func (r R) Read(fd int, ptr unsafe.Pointer) error

Read executes r against fd with the pointer argument ptr.

The size of the object ptr is pointing to must match r.Size.

type W

type W struct {
	Name string
	Type uint16
	Nr   uint16
	Size uint16
}

W specifies a write ioctl: information is passed from userspace into the kernel.

func (W) Number added in v0.4.0

func (w W) Number() uint32

Number returns the ioctl number associated with w.

func (W) Write added in v0.9.0

func (w W) Write(fd int, ptr unsafe.Pointer) error

Write executes w against fd with the pointer argument ptr.

The size of the object ptr is pointing to must match w.Size.

type WR

type WR struct {
	Name string
	Type uint16
	Nr   uint16
	Size uint16
}

WR specifies a bidirectional ioctl.

func (WR) Exec

func (wr WR) Exec(fd int, ptr unsafe.Pointer) error

Exec executes wr against fd. ptr is the input / output argument.

The size of the object ptr is pointing to must match wr.Size.

func (WR) Number added in v0.4.0

func (wr WR) Number() uint32

Number returns the ioctl number associated with wr.

Directories

Path Synopsis
internal
cgoioctl
Package cgoioctl contains wrapper functions around the _IOC C macro.
Package cgoioctl contains wrapper functions around the _IOC C macro.

Jump to

Keyboard shortcuts

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