Skip to content

Commit

Permalink
unix: add IoctlLoopConfigure on linux
Browse files Browse the repository at this point in the history
LOOP_CONFIGURE ioctl is used to setup and configure all loop device
parameters in a single step.
Add to the unix package a new function that exposes LOOP_CONFIGURE.

Fixes golang/go#63962

Change-Id: Ia169d268b52b1384febc6bff9c707b721ab2bb24
GitHub-Last-Rev: f9cc4c9
GitHub-Pull-Request: #181
Reviewed-on: https://go-review.googlesource.com/c/sys/+/540075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
alex-matei authored and gopherbot committed Nov 18, 2023
1 parent 11eadc0 commit 13b15b7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions unix/ioctl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,8 @@ func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) {
func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error {
return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value))
}

// IoctlLoopConfigure configures all loop device parameters in a single step
func IoctlLoopConfigure(fd int, value *LoopConfig) error {
return ioctlPtr(fd, LOOP_CONFIGURE, unsafe.Pointer(value))
}
1 change: 1 addition & 0 deletions unix/linux/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,7 @@ const (

type LoopInfo C.struct_loop_info
type LoopInfo64 C.struct_loop_info64
type LoopConfig C.struct_loop_config

// AF_TIPC

Expand Down
1 change: 1 addition & 0 deletions unix/mkerrors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ ccflags="$@"
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
$2 ~ /^LO_(KEY|NAME)_SIZE$/ ||
$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ ||
$2 == "LOOP_CONFIGURE" ||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
Expand Down
1 change: 1 addition & 0 deletions unix/zerrors_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions unix/ztypes_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13b15b7

Please sign in to comment.