Skip to content

Commit

Permalink
unix: add IoctlLoop{Get,Set}Status64 on linux
Browse files Browse the repository at this point in the history
These ioctls are used to get/set the status of a loop device. See
https://man7.org/linux/man-pages/man4/loop.4.html for details.

Change-Id: Ia66db639e6d9326af79954eea5c8f7515aa171d1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/425296
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Tobias Klauser <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
  • Loading branch information
tklauser authored and gopherbot committed Aug 29, 2022
1 parent c680a09 commit 2c41d75
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions unix/ioctl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

package unix

import (
"unsafe"
)
import "unsafe"

// IoctlRetInt performs an ioctl operation specified by req on a device
// associated with opened file descriptor fd, and returns a non-negative
Expand Down Expand Up @@ -217,3 +215,19 @@ func IoctlKCMAttach(fd int, info KCMAttach) error {
func IoctlKCMUnattach(fd int, info KCMUnattach) error {
return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info))
}

// IoctlLoopGetStatus64 gets the status of the loop device associated with the
// file descriptor fd using the LOOP_GET_STATUS64 operation.
func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) {
var value LoopInfo64
if err := ioctlPtr(fd, LOOP_GET_STATUS64, unsafe.Pointer(&value)); err != nil {
return nil, err
}
return &value, nil
}

// IoctlLoopSetStatus64 sets the status of the loop device associated with the
// file descriptor fd using the LOOP_SET_STATUS64 operation.
func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error {
return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value))
}

0 comments on commit 2c41d75

Please sign in to comment.