mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 08:37:31 -04:00
unix: add Linux watchdog structures and missing constants
This CL also adds the type-safe wrappers IoctlGetWatchdogInfo and IoctlWatchdogKeepalive around the raw ioctl interface. Change-Id: I98e3970807b28832e49524700b17b6b6f75d91ed Reviewed-on: https://go-review.googlesource.com/c/sys/+/259497 Run-TryBot: Matt Layher <mdlayher@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Terin Stock <terinjokes@gmail.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
@@ -120,6 +120,7 @@ struct termios2 {
|
|||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
#include <linux/taskstats.h>
|
#include <linux/taskstats.h>
|
||||||
#include <linux/tipc.h>
|
#include <linux/tipc.h>
|
||||||
|
#include <linux/watchdog.h>
|
||||||
#include <linux/vm_sockets.h>
|
#include <linux/vm_sockets.h>
|
||||||
|
|
||||||
// abi/abi.h generated by mkall.go.
|
// abi/abi.h generated by mkall.go.
|
||||||
@@ -2510,3 +2511,7 @@ const (
|
|||||||
CAN_RAW_FD_FRAMES = C.CAN_RAW_FD_FRAMES
|
CAN_RAW_FD_FRAMES = C.CAN_RAW_FD_FRAMES
|
||||||
CAN_RAW_JOIN_FILTERS = C.CAN_RAW_JOIN_FILTERS
|
CAN_RAW_JOIN_FILTERS = C.CAN_RAW_JOIN_FILTERS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Watchdog API
|
||||||
|
|
||||||
|
type WatchdogInfo C.struct_watchdog_info
|
||||||
|
|||||||
+1
-1
@@ -546,7 +546,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
||||||
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
||||||
$2 ~ /^FSOPT_/ ||
|
$2 ~ /^FSOPT_/ ||
|
||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIO[CFS]_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
$2 ~ /^RWF_/ ||
|
$2 ~ /^RWF_/ ||
|
||||||
|
|||||||
@@ -106,6 +106,15 @@ func IoctlGetRTCTime(fd int) (*RTCTime, error) {
|
|||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||||
|
// Linux watchdog API. For more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
|
||||||
|
var value WatchdogInfo
|
||||||
|
err := ioctl(fd, WDIOC_GETSUPPORT, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
||||||
var value RTCWkAlrm
|
var value RTCWkAlrm
|
||||||
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
||||||
@@ -137,6 +146,13 @@ func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
|
||||||
|
// more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlWatchdogKeepalive(fd int) error {
|
||||||
|
return ioctl(fd, WDIOC_KEEPALIVE, 0)
|
||||||
|
}
|
||||||
|
|
||||||
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
||||||
|
|
||||||
func Link(oldpath string, newpath string) (err error) {
|
func Link(oldpath string, newpath string) (err error) {
|
||||||
|
|||||||
@@ -2357,6 +2357,23 @@ const (
|
|||||||
WCONTINUED = 0x8
|
WCONTINUED = 0x8
|
||||||
WDIOC_SETPRETIMEOUT = 0xc0045708
|
WDIOC_SETPRETIMEOUT = 0xc0045708
|
||||||
WDIOC_SETTIMEOUT = 0xc0045706
|
WDIOC_SETTIMEOUT = 0xc0045706
|
||||||
|
WDIOF_ALARMONLY = 0x400
|
||||||
|
WDIOF_CARDRESET = 0x20
|
||||||
|
WDIOF_EXTERN1 = 0x4
|
||||||
|
WDIOF_EXTERN2 = 0x8
|
||||||
|
WDIOF_FANFAULT = 0x2
|
||||||
|
WDIOF_KEEPALIVEPING = 0x8000
|
||||||
|
WDIOF_MAGICCLOSE = 0x100
|
||||||
|
WDIOF_OVERHEAT = 0x1
|
||||||
|
WDIOF_POWEROVER = 0x40
|
||||||
|
WDIOF_POWERUNDER = 0x10
|
||||||
|
WDIOF_PRETIMEOUT = 0x200
|
||||||
|
WDIOF_SETTIMEOUT = 0x80
|
||||||
|
WDIOF_UNKNOWN = -0x1
|
||||||
|
WDIOS_DISABLECARD = 0x1
|
||||||
|
WDIOS_ENABLECARD = 0x2
|
||||||
|
WDIOS_TEMPPANIC = 0x4
|
||||||
|
WDIOS_UNKNOWN = -0x1
|
||||||
WEXITED = 0x4
|
WEXITED = 0x4
|
||||||
WIN_ACKMEDIACHANGE = 0xdb
|
WIN_ACKMEDIACHANGE = 0xdb
|
||||||
WIN_CHECKPOWERMODE1 = 0xe5
|
WIN_CHECKPOWERMODE1 = 0xe5
|
||||||
|
|||||||
@@ -2567,3 +2567,9 @@ const (
|
|||||||
CAN_RAW_FD_FRAMES = 0x5
|
CAN_RAW_FD_FRAMES = 0x5
|
||||||
CAN_RAW_JOIN_FILTERS = 0x6
|
CAN_RAW_JOIN_FILTERS = 0x6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type WatchdogInfo struct {
|
||||||
|
Options uint32
|
||||||
|
Version uint32
|
||||||
|
Identity [32]uint8
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user