Initial revision
[openwrt/svn-archive/archive.git] / obsolete-buildroot / sources / busybox-openwrt-130-resetmon.patch
1 diff -urN busybox-dist/include/applets.h busybox/include/applets.h
2 --- busybox-dist/include/applets.h 2004-03-16 09:56:27.000000000 -0600
3 +++ busybox/include/applets.h 2004-03-16 10:00:14.000000000 -0600
4 @@ -484,6 +484,9 @@
5 #ifdef CONFIG_RESET
6 APPLET(reset, reset_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
7 #endif
8 +#ifdef CONFIG_RESETMON
9 + APPLET(resetmon, resetmon_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
10 +#endif
11 #ifdef CONFIG_RM
12 APPLET(rm, rm_main, _BB_DIR_BIN, _BB_SUID_NEVER)
13 #endif
14 diff -urN busybox-dist/include/usage.h busybox/include/usage.h
15 --- busybox-dist/include/usage.h 2004-03-16 09:56:27.000000000 -0600
16 +++ busybox/include/usage.h 2004-03-16 10:00:14.000000000 -0600
17 @@ -2024,6 +2024,11 @@
18 #define reset_full_usage \
19 "Resets the screen."
20
21 +#define resetmon_trivial_usage \
22 + ""
23 +#define resetmon_full_usage \
24 + "Return an exit code of TRUE (0) if reset is NOT pressed."
25 +
26 #define rm_trivial_usage \
27 "[OPTION]... FILE..."
28 #define rm_full_usage \
29 diff -urN busybox-dist/miscutils/Config.in busybox/miscutils/Config.in
30 --- busybox-dist/miscutils/Config.in 2004-03-15 02:28:46.000000000 -0600
31 +++ busybox/miscutils/Config.in 2004-03-16 10:00:14.000000000 -0600
32 @@ -156,6 +156,12 @@
33 to advance or rewind a tape past a specified number of archive
34 files on the tape.
35
36 +config CONFIG_RESETMON
37 + bool "resetmon"
38 + default y
39 + help
40 + Linksys wrt54g reset button monitor. Returns TRUE if NOT pressed.
41 +
42 config CONFIG_RX
43 bool "rx"
44 default n
45 diff -urN busybox-dist/miscutils/Makefile.in busybox/miscutils/Makefile.in
46 --- busybox-dist/miscutils/Makefile.in 2004-03-15 02:28:46.000000000 -0600
47 +++ busybox/miscutils/Makefile.in 2004-03-16 10:00:14.000000000 -0600
48 @@ -33,6 +33,7 @@
49 MISCUTILS-$(CONFIG_LAST) += last.o
50 MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
51 MISCUTILS-$(CONFIG_MT) += mt.o
52 +MISCUTILS-$(CONFIG_RESETMON) += resetmon.o
53 MISCUTILS-$(CONFIG_RX) += rx.o
54 MISCUTILS-$(CONFIG_STRINGS) += strings.o
55 MISCUTILS-$(CONFIG_TIME) += time.o
56 diff -urN busybox-dist/miscutils/resetmon.c busybox/miscutils/resetmon.c
57 --- busybox-dist/miscutils/resetmon.c 1969-12-31 18:00:00.000000000 -0600
58 +++ busybox/miscutils/resetmon.c 2004-03-16 10:00:14.000000000 -0600
59 @@ -0,0 +1,30 @@
60 +#include <unistd.h>
61 +#include <fcntl.h>
62 +#include "busybox.h"
63 +
64 +#define RESET (1<<6)
65 +
66 +int resetmon_main(int argc, char **argv) {
67 + int fd = -1;
68 + unsigned int val=0;
69 +
70 +#if 0
71 + if ((fd = open("/dev/gpio/control",O_RDWR))<0) goto error;
72 + read(fd,&val,4);
73 + val|=RESET;
74 + write(fd,&val,4);
75 +
76 + if ((fd = open("/dev/gpio/outen",O_RDWR))<0) goto error;
77 + read(fd,&val,4);
78 + val&=~RESET;
79 + write(fd,&val,4);
80 +#endif
81 +
82 + if ((fd = open("/dev/gpio/in",O_RDONLY))<0) goto error;
83 + read(fd,&val,4);
84 +
85 + return !(val&RESET);
86 +
87 +error:
88 + return 1;
89 +}