[PATCH v4 1/2] watchdog_ioctl: Add decoding of WDIOC_GETSUPPORT and WDIOC_SETOPTIONS ioctls
Sahil Siddiq
icegambit91 at gmail.com
Sun Aug 25 18:30:01 UTC 2024
* src/watchdog_ioctl.c: Implement new ioctl decoders.
* src/xlat/watchdog_ioctl_cmds.in (WDIOC_GETSUPPORT): Add new constant.
* src/xlat/watchdog_ioctl_flags.in: New file.
* src/xlat/watchdog_ioctl_setoptions.in: New file.
* NEWS: Mention this change.
Signed-off-by: Sahil Siddiq <sahilcdq at proton.me>
---
Changes v3 -> v4:
- src/watchdog_ioctl.c:
- (headers): Include watchdog_ioctl_flags.h
- (WDIOC_GETSUPPORT):
- Place tprint_arg_next() before return.
- Check umove_or_printaddr() for non-zero return value.
- Use PRINT_FIELD_X for firmware_version.
- Code style changes.
- src/xlat/watchdog_ioctl_support_options.in: Rename to
watchdog_ioctl_flags.in
NEWS | 2 ++
src/watchdog_ioctl.c | 35 +++++++++++++++++++++++++++
src/xlat/watchdog_ioctl_cmds.in | 1 +
src/xlat/watchdog_ioctl_flags.in | 12 +++++++++
src/xlat/watchdog_ioctl_setoptions.in | 3 +++
5 files changed, 53 insertions(+)
create mode 100644 src/xlat/watchdog_ioctl_flags.in
create mode 100644 src/xlat/watchdog_ioctl_setoptions.in
diff --git a/NEWS b/NEWS
index b3bc8e932..cf1466c7e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Noteworthy changes in release ?.?? (????-??-??)
* Updated decoding of listmount, statmount, and statx syscalls.
* Updated lists of ETHTOOL_*, IORING_*, IPPROTO_*, RWF_*, STATX_*, and V4L2_*
constants.
+ * Implemented decoding of WDIOC_GETSUPPORT and WDIOC_SETOPTIONS ioctl
+ commands.
Noteworthy changes in release 6.10 (2024-07-21)
===============================================
diff --git a/src/watchdog_ioctl.c b/src/watchdog_ioctl.c
index b88094f0d..c2bc26620 100644
--- a/src/watchdog_ioctl.c
+++ b/src/watchdog_ioctl.c
@@ -9,6 +9,9 @@
#include <linux/watchdog.h>
+#include "xlat/watchdog_ioctl_flags.h"
+#include "xlat/watchdog_ioctl_setoptions.h"
+
#define XLAT_MACROS_ONLY
#include "xlat/watchdog_ioctl_cmds.h"
#undef XLAT_MACROS_ONLY
@@ -17,7 +20,30 @@ int
watchdog_ioctl(struct tcb *const tcp, const unsigned int code,
const kernel_ulong_t arg)
{
+ struct watchdog_info ident;
+ unsigned int options;
+
switch (code) {
+ case WDIOC_GETSUPPORT:
+ if (entering(tcp)) {
+ tprint_arg_next();
+ return 0;
+ }
+ if (umove_or_printaddr(tcp, arg, &ident))
+ break;
+ tprint_struct_begin();
+ PRINT_FIELD_FLAGS(ident, options, watchdog_ioctl_flags,
+ "WDIOF_???");
+ tprint_struct_next();
+ if (abbrev(tcp)) {
+ tprint_more_data_follows();
+ } else {
+ PRINT_FIELD_X(ident, firmware_version);
+ tprint_struct_next();
+ PRINT_FIELD_CSTRING(ident, identity);
+ }
+ tprint_struct_end();
+ break;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
case WDIOC_GETTEMP:
@@ -32,6 +58,15 @@ watchdog_ioctl(struct tcb *const tcp, const unsigned int code,
tprint_arg_next();
printnum_int(tcp, arg, "%d");
break;
+ case WDIOC_SETOPTIONS:
+ tprint_arg_next();
+ if (umove_or_printaddr(tcp, arg, &options))
+ break;
+ tprint_indirect_begin();
+ printflags(watchdog_ioctl_setoptions, options,
+ "WDIOS_???");
+ tprint_indirect_end();
+ break;
/*
* linux/watchdog.h says that this takes an int, but in
diff --git a/src/xlat/watchdog_ioctl_cmds.in b/src/xlat/watchdog_ioctl_cmds.in
index b871cbd1e..d77f3d41c 100644
--- a/src/xlat/watchdog_ioctl_cmds.in
+++ b/src/xlat/watchdog_ioctl_cmds.in
@@ -1,3 +1,4 @@
+WDIOC_GETSUPPORT _IOR('W', 0, struct watchdog_info)
WDIOC_GETSTATUS _IOR('W', 1, int)
WDIOC_GETBOOTSTATUS _IOR('W', 2, int)
WDIOC_GETTEMP _IOR('W', 3, int)
diff --git a/src/xlat/watchdog_ioctl_flags.in b/src/xlat/watchdog_ioctl_flags.in
new file mode 100644
index 000000000..2030cf329
--- /dev/null
+++ b/src/xlat/watchdog_ioctl_flags.in
@@ -0,0 +1,12 @@
+WDIOF_OVERHEAT 0x0001
+WDIOF_FANFAULT 0x0002
+WDIOF_EXTERN1 0x0004
+WDIOF_EXTERN2 0x0008
+WDIOF_POWERUNDER 0x0010
+WDIOF_CARDRESET 0x0020
+WDIOF_POWEROVER 0x0040
+WDIOF_SETTIMEOUT 0x0080
+WDIOF_MAGICCLOSE 0x0100
+WDIOF_PRETIMEOUT 0x0200
+WDIOF_ALARMONLY 0x0400
+WDIOF_KEEPALIVEPING 0x8000
diff --git a/src/xlat/watchdog_ioctl_setoptions.in b/src/xlat/watchdog_ioctl_setoptions.in
new file mode 100644
index 000000000..5ef67714e
--- /dev/null
+++ b/src/xlat/watchdog_ioctl_setoptions.in
@@ -0,0 +1,3 @@
+WDIOS_DISABLECARD 0x0001
+WDIOS_ENABLECARD 0x0002
+WDIOS_TEMPPANIC 0x0004
--
2.46.0
More information about the Strace-devel
mailing list