| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: wdogctl.c,v 1.17 2006/08/13 23:24:53 wiz Exp $ */ | | 1 | /* $NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000 Zembu Labs, Inc. | | 4 | * Copyright (c) 2000 Zembu Labs, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Author: Jason R. Thorpe <thorpej@zembu.com> | | 7 | * Author: Jason R. Thorpe <thorpej@zembu.com> |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR- | | 25 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR- |
26 | * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS- | | 26 | * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS- |
27 | * CLAIMED. IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT, | | 27 | * CLAIMED. IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | | | 36 | |
37 | #ifndef lint | | 37 | #ifndef lint |
38 | __RCSID("$NetBSD: wdogctl.c,v 1.17 2006/08/13 23:24:53 wiz Exp $"); | | 38 | __RCSID("$NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $"); |
39 | #endif | | 39 | #endif |
40 | | | 40 | |
41 | | | 41 | |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | #include <sys/ioctl.h> | | 43 | #include <sys/ioctl.h> |
44 | #include <sys/wdog.h> | | 44 | #include <sys/wdog.h> |
45 | | | 45 | |
46 | #include <err.h> | | 46 | #include <err.h> |
47 | #include <errno.h> | | 47 | #include <errno.h> |
48 | #include <fcntl.h> | | 48 | #include <fcntl.h> |
49 | #include <stdio.h> | | 49 | #include <stdio.h> |
50 | #include <stdlib.h> | | 50 | #include <stdlib.h> |
51 | #include <time.h> | | 51 | #include <time.h> |
| @@ -74,27 +74,27 @@ enum cmd { | | | @@ -74,27 +74,27 @@ enum cmd { |
74 | CMD_DISABLE, | | 74 | CMD_DISABLE, |
75 | CMD_DOTICKLE, | | 75 | CMD_DOTICKLE, |
76 | CMD_EXT_TICKLE, | | 76 | CMD_EXT_TICKLE, |
77 | CMD_KERN_TICKLE, | | 77 | CMD_KERN_TICKLE, |
78 | CMD_NOCANCEL_TICKLE, | | 78 | CMD_NOCANCEL_TICKLE, |
79 | CMD_USER_TICKLE | | 79 | CMD_USER_TICKLE |
80 | }; | | 80 | }; |
81 | | | 81 | |
82 | int | | 82 | int |
83 | main(int argc, char *argv[]) | | 83 | main(int argc, char *argv[]) |
84 | { | | 84 | { |
85 | enum cmd command = CMD_NONE; | | 85 | enum cmd command = CMD_NONE; |
86 | int period_flag = 0; | | 86 | int period_flag = 0; |
87 | int ch; | | 87 | int ch, tmp; |
88 | u_int period = WDOG_PERIOD_DEFAULT; | | 88 | u_int period = WDOG_PERIOD_DEFAULT; |
89 | | | 89 | |
90 | while ((ch = getopt(argc, argv, "Adekp:utx")) != -1) { | | 90 | while ((ch = getopt(argc, argv, "Adekp:utx")) != -1) { |
91 | switch (ch) { | | 91 | switch (ch) { |
92 | case 'A': | | 92 | case 'A': |
93 | Aflag = 1; | | 93 | Aflag = 1; |
94 | break; | | 94 | break; |
95 | | | 95 | |
96 | case 'd': | | 96 | case 'd': |
97 | if (command != CMD_NONE) | | 97 | if (command != CMD_NONE) |
98 | usage(); | | 98 | usage(); |
99 | command = CMD_DISABLE; | | 99 | command = CMD_DISABLE; |
100 | break; | | 100 | break; |
| @@ -109,29 +109,30 @@ main(int argc, char *argv[]) | | | @@ -109,29 +109,30 @@ main(int argc, char *argv[]) |
109 | if (command != CMD_NONE) | | 109 | if (command != CMD_NONE) |
110 | usage(); | | 110 | usage(); |
111 | command = CMD_KERN_TICKLE; | | 111 | command = CMD_KERN_TICKLE; |
112 | break; | | 112 | break; |
113 | | | 113 | |
114 | case 't': | | 114 | case 't': |
115 | if (command != CMD_NONE) | | 115 | if (command != CMD_NONE) |
116 | usage(); | | 116 | usage(); |
117 | command = CMD_DOTICKLE; | | 117 | command = CMD_DOTICKLE; |
118 | break; | | 118 | break; |
119 | | | 119 | |
120 | case 'p': | | 120 | case 'p': |
121 | period_flag = 1; | | 121 | period_flag = 1; |
122 | period = atoi(optarg); | | 122 | tmp = atoi(optarg); |
123 | if (period == -1) | | 123 | if (tmp < 0) |
124 | usage(); | | 124 | usage(); |
| | | 125 | period = (unsigned int)tmp; |
125 | break; | | 126 | break; |
126 | | | 127 | |
127 | case 'x': | | 128 | case 'x': |
128 | case 'u': | | 129 | case 'u': |
129 | if (command != CMD_NONE) | | 130 | if (command != CMD_NONE) |
130 | usage(); | | 131 | usage(); |
131 | command = | | 132 | command = |
132 | (ch == 'u') ? CMD_USER_TICKLE : CMD_NOCANCEL_TICKLE; | | 133 | (ch == 'u') ? CMD_USER_TICKLE : CMD_NOCANCEL_TICKLE; |
133 | break; | | 134 | break; |
134 | | | 135 | |
135 | default: | | 136 | default: |
136 | usage(); | | 137 | usage(); |
137 | } | | 138 | } |