Skip to content

Commit 2c41d75

Browse files
tklausergopherbot
authored andcommitted
unix: add IoctlLoop{Get,Set}Status64 on linux
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]>
1 parent c680a09 commit 2c41d75

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

unix/ioctl_linux.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package unix
66

7-
import (
8-
"unsafe"
9-
)
7+
import "unsafe"
108

119
// IoctlRetInt performs an ioctl operation specified by req on a device
1210
// associated with opened file descriptor fd, and returns a non-negative
@@ -217,3 +215,19 @@ func IoctlKCMAttach(fd int, info KCMAttach) error {
217215
func IoctlKCMUnattach(fd int, info KCMUnattach) error {
218216
return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info))
219217
}
218+
219+
// IoctlLoopGetStatus64 gets the status of the loop device associated with the
220+
// file descriptor fd using the LOOP_GET_STATUS64 operation.
221+
func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) {
222+
var value LoopInfo64
223+
if err := ioctlPtr(fd, LOOP_GET_STATUS64, unsafe.Pointer(&value)); err != nil {
224+
return nil, err
225+
}
226+
return &value, nil
227+
}
228+
229+
// IoctlLoopSetStatus64 sets the status of the loop device associated with the
230+
// file descriptor fd using the LOOP_SET_STATUS64 operation.
231+
func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error {
232+
return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value))
233+
}

0 commit comments

Comments
 (0)