1 /*
2 * Copyright (c) 2019-2021 The strace developers.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8 #include "defs.h"
9
10 #include <linux/watchdog.h>
11
12 #define XLAT_MACROS_ONLY
13 #include "xlat/watchdog_ioctl_cmds.h"
14 #undef XLAT_MACROS_ONLY
15
16 int
17 watchdog_ioctl(struct tcb *const tcp, const unsigned int code,
18 const kernel_ulong_t arg)
19 {
20 switch (code) {
21 case WDIOC_GETSTATUS:
22 case WDIOC_GETBOOTSTATUS:
23 case WDIOC_GETTEMP:
24 case WDIOC_GETTIMEOUT:
25 case WDIOC_GETPRETIMEOUT:
26 case WDIOC_GETTIMELEFT:
27 if (entering(tcp))
28 return 0;
29 ATTRIBUTE_FALLTHROUGH;
30 case WDIOC_SETTIMEOUT:
31 case WDIOC_SETPRETIMEOUT:
32 tprint_arg_next();
33 printnum_int(tcp, arg, "%d");
34 break;
35
36 /*
37 * linux/watchdog.h says that this takes an int, but in
38 * practice the argument is ignored.
39 */
40 case WDIOC_KEEPALIVE:
41 break;
42 default:
43 return RVAL_DECODED;
44 }
45 return RVAL_IOCTL_DECODED;
46 }