https://github.com/thediveo/ioctl
A tiny package to help with dealing with constructing Linux ioctl request values that are not already included in the sys/unix standard package
https://github.com/thediveo/ioctl
Last synced: 6 months ago
JSON representation
A tiny package to help with dealing with constructing Linux ioctl request values that are not already included in the sys/unix standard package
- Host: GitHub
- URL: https://github.com/thediveo/ioctl
- Owner: thediveo
- License: apache-2.0
- Created: 2023-04-17T10:25:31.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-06T15:36:27.000Z (6 months ago)
- Last Synced: 2025-01-06T16:38:19.317Z (6 months ago)
- Language: Go
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `ioctl`
[](https://pkg.go.dev/github.com/thediveo/ioctl)
[](https://img.shields.io/github/license/thediveo/ioctl)

[](https://goreportcard.com/report/github.com/thediveo/ioctl)
A tiny package to help with dealing with constructing Linux
[ioctl(2)](https://man7.org/linux/man-pages/man2/ioctl.2.html) request values
that are not already included in the
[sys/unix](https://pkg.go.dev/golang.org/x/sys/unix) standard package.For devcontainer instructions, please see the [section "DevContainer"
below](#devcontainer).## Usage
A good example are
[ioctl_ns(2)](https://man7.org/linux/man-pages/man2/ioctl_ns.2.html) operations
on Linux namespaces. For instance, this ioctl operation request value is defined
in
[include/uapi/linux/nsfs.h](https://elixir.bootlin.com/linux/v6.2.11/source/include/uapi/linux/nsfs.h#L10)
in the Linux kernel C headers as follows:```c
#define NSIO 0xb7/* Returns a file descriptor that refers to an owning user namespace */
#define NS_GET_USERNS _IO(NSIO, 0x1)
```These definitions can now be applied to Go code as follows:
```go
import "github.com/thediveo/ioctl"const NSIO = 0xb7
var NS_GET_USERNS = ioctl.IO(NSIO, 0x1)func main() {
fd, err := ioctl.RetFd(nsfd, NS_GET_USERNS)
}
```## DevContainer
> [!CAUTION]
>
> Do **not** use VSCode's "~~Dev Containers: Clone Repository in Container
> Volume~~" command, as it is utterly broken by design, ignoring
> `.devcontainer/devcontainer.json`.1. `git clone https://github.com/thediveo/enumflag`
2. in VSCode: Ctrl+Shift+P, "Dev Containers: Open Workspace in Container..."
3. select `enumflag.code-workspace` and off you go...## Supported Go Versions
`native` supports versions of Go that are noted by the [Go release
policy](https://golang.org/doc/devel/release.html#policy), that is, major
versions _N_ and _N_-1 (where _N_ is the current major version).## Copyright and License
Copyright 2023, 2025 Harald Albrecht, licensed under the Apache License, Version
2.0.