diff options
author | Adrian Bunk <bunk@kernel.org> | 2008-10-16 01:01:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:30 -0400 |
commit | d2efa6d5ce14f92d13e2710f7343687a9acfd324 (patch) | |
tree | ac206ab4734b64e6fc04402b3289e72f102162df /arch/um/os-Linux | |
parent | b25f29b0da23f4f784f9bcae954b157e1f45cc69 (diff) |
uml: remove the dead TTY_LOG code
Remove the dead CONFIG_TTY_LOG (no kconfig option).
Reported-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/Makefile | 3 | ||||
-rw-r--r-- | arch/um/os-Linux/tty_log.c | 217 |
2 files changed, 0 insertions, 220 deletions
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 8a48d6a30064..d66f0388f091 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
@@ -7,9 +7,6 @@ obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ | |||
7 | registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ | 7 | registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ |
8 | umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ | 8 | umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ |
9 | 9 | ||
10 | obj-$(CONFIG_TTY_LOG) += tty_log.o | ||
11 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | ||
12 | |||
13 | USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ | 10 | USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ |
14 | main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ | 11 | main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ |
15 | tty.o tls.o uaccess.o umid.o util.o | 12 | tty.o tls.o uaccess.o umid.o util.o |
diff --git a/arch/um/os-Linux/tty_log.c b/arch/um/os-Linux/tty_log.c deleted file mode 100644 index cc648e6fd3a2..000000000000 --- a/arch/um/os-Linux/tty_log.c +++ /dev/null | |||
@@ -1,217 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and | ||
3 | * geoffrey hing <ghing@net.ohio-state.edu> | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <errno.h> | ||
8 | #include <string.h> | ||
9 | #include <stdio.h> | ||
10 | #include <stdlib.h> | ||
11 | #include <unistd.h> | ||
12 | #include <sys/time.h> | ||
13 | #include "init.h" | ||
14 | #include "user.h" | ||
15 | #include "os.h" | ||
16 | |||
17 | #define TTY_LOG_DIR "./" | ||
18 | |||
19 | /* Set early in boot and then unchanged */ | ||
20 | static char *tty_log_dir = TTY_LOG_DIR; | ||
21 | static int tty_log_fd = -1; | ||
22 | |||
23 | #define TTY_LOG_OPEN 1 | ||
24 | #define TTY_LOG_CLOSE 2 | ||
25 | #define TTY_LOG_WRITE 3 | ||
26 | #define TTY_LOG_EXEC 4 | ||
27 | |||
28 | #define TTY_READ 1 | ||
29 | #define TTY_WRITE 2 | ||
30 | |||
31 | struct tty_log_buf { | ||
32 | int what; | ||
33 | unsigned long tty; | ||
34 | int len; | ||
35 | int direction; | ||
36 | unsigned long sec; | ||
37 | unsigned long usec; | ||
38 | }; | ||
39 | |||
40 | int open_tty_log(void *tty, void *current_tty) | ||
41 | { | ||
42 | struct timeval tv; | ||
43 | struct tty_log_buf data; | ||
44 | char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")]; | ||
45 | int fd; | ||
46 | |||
47 | gettimeofday(&tv, NULL); | ||
48 | if(tty_log_fd != -1){ | ||
49 | data = ((struct tty_log_buf) { .what = TTY_LOG_OPEN, | ||
50 | .tty = (unsigned long) tty, | ||
51 | .len = sizeof(current_tty), | ||
52 | .direction = 0, | ||
53 | .sec = tv.tv_sec, | ||
54 | .usec = tv.tv_usec } ); | ||
55 | write(tty_log_fd, &data, sizeof(data)); | ||
56 | write(tty_log_fd, ¤t_tty, data.len); | ||
57 | return tty_log_fd; | ||
58 | } | ||
59 | |||
60 | sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, | ||
61 | (unsigned int) tv.tv_usec); | ||
62 | |||
63 | fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))), | ||
64 | 0644); | ||
65 | if(fd < 0){ | ||
66 | printk("open_tty_log : couldn't open '%s', errno = %d\n", | ||
67 | buf, -fd); | ||
68 | } | ||
69 | return fd; | ||
70 | } | ||
71 | |||
72 | void close_tty_log(int fd, void *tty) | ||
73 | { | ||
74 | struct tty_log_buf data; | ||
75 | struct timeval tv; | ||
76 | |||
77 | if(tty_log_fd != -1){ | ||
78 | gettimeofday(&tv, NULL); | ||
79 | data = ((struct tty_log_buf) { .what = TTY_LOG_CLOSE, | ||
80 | .tty = (unsigned long) tty, | ||
81 | .len = 0, | ||
82 | .direction = 0, | ||
83 | .sec = tv.tv_sec, | ||
84 | .usec = tv.tv_usec } ); | ||
85 | write(tty_log_fd, &data, sizeof(data)); | ||
86 | return; | ||
87 | } | ||
88 | os_close_file(fd); | ||
89 | } | ||
90 | |||
91 | static int log_chunk(int fd, const char *buf, int len) | ||
92 | { | ||
93 | int total = 0, try, missed, n; | ||
94 | char chunk[64]; | ||
95 | |||
96 | while(len > 0){ | ||
97 | try = (len > sizeof(chunk)) ? sizeof(chunk) : len; | ||
98 | missed = copy_from_user_proc(chunk, (char *) buf, try); | ||
99 | try -= missed; | ||
100 | n = write(fd, chunk, try); | ||
101 | if(n != try) { | ||
102 | if(n < 0) | ||
103 | return -errno; | ||
104 | return -EIO; | ||
105 | } | ||
106 | if(missed != 0) | ||
107 | return -EFAULT; | ||
108 | |||
109 | len -= try; | ||
110 | total += try; | ||
111 | buf += try; | ||
112 | } | ||
113 | |||
114 | return total; | ||
115 | } | ||
116 | |||
117 | int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read) | ||
118 | { | ||
119 | struct timeval tv; | ||
120 | struct tty_log_buf data; | ||
121 | int direction; | ||
122 | |||
123 | if(fd == tty_log_fd){ | ||
124 | gettimeofday(&tv, NULL); | ||
125 | direction = is_read ? TTY_READ : TTY_WRITE; | ||
126 | data = ((struct tty_log_buf) { .what = TTY_LOG_WRITE, | ||
127 | .tty = (unsigned long) tty, | ||
128 | .len = len, | ||
129 | .direction = direction, | ||
130 | .sec = tv.tv_sec, | ||
131 | .usec = tv.tv_usec } ); | ||
132 | write(tty_log_fd, &data, sizeof(data)); | ||
133 | } | ||
134 | |||
135 | return log_chunk(fd, buf, len); | ||
136 | } | ||
137 | |||
138 | void log_exec(char **argv, void *tty) | ||
139 | { | ||
140 | struct timeval tv; | ||
141 | struct tty_log_buf data; | ||
142 | char **ptr,*arg; | ||
143 | int len; | ||
144 | |||
145 | if(tty_log_fd == -1) return; | ||
146 | |||
147 | gettimeofday(&tv, NULL); | ||
148 | |||
149 | len = 0; | ||
150 | for(ptr = argv; ; ptr++){ | ||
151 | if(copy_from_user_proc(&arg, ptr, sizeof(arg))) | ||
152 | return; | ||
153 | if(arg == NULL) break; | ||
154 | len += strlen_user_proc(arg); | ||
155 | } | ||
156 | |||
157 | data = ((struct tty_log_buf) { .what = TTY_LOG_EXEC, | ||
158 | .tty = (unsigned long) tty, | ||
159 | .len = len, | ||
160 | .direction = 0, | ||
161 | .sec = tv.tv_sec, | ||
162 | .usec = tv.tv_usec } ); | ||
163 | write(tty_log_fd, &data, sizeof(data)); | ||
164 | |||
165 | for(ptr = argv; ; ptr++){ | ||
166 | if(copy_from_user_proc(&arg, ptr, sizeof(arg))) | ||
167 | return; | ||
168 | if(arg == NULL) break; | ||
169 | log_chunk(tty_log_fd, arg, strlen_user_proc(arg)); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | extern void register_tty_logger(int (*opener)(void *, void *), | ||
174 | int (*writer)(int, const char *, int, | ||
175 | void *, int), | ||
176 | void (*closer)(int, void *)); | ||
177 | |||
178 | static int register_logger(void) | ||
179 | { | ||
180 | register_tty_logger(open_tty_log, write_tty_log, close_tty_log); | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | __uml_initcall(register_logger); | ||
185 | |||
186 | static int __init set_tty_log_dir(char *name, int *add) | ||
187 | { | ||
188 | tty_log_dir = name; | ||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | __uml_setup("tty_log_dir=", set_tty_log_dir, | ||
193 | "tty_log_dir=<directory>\n" | ||
194 | " This is used to specify the directory where the logs of all pty\n" | ||
195 | " data from this UML machine will be written.\n\n" | ||
196 | ); | ||
197 | |||
198 | static int __init set_tty_log_fd(char *name, int *add) | ||
199 | { | ||
200 | char *end; | ||
201 | |||
202 | tty_log_fd = strtoul(name, &end, 0); | ||
203 | if((*end != '\0') || (end == name)){ | ||
204 | printf("set_tty_log_fd - strtoul failed on '%s'\n", name); | ||
205 | tty_log_fd = -1; | ||
206 | } | ||
207 | |||
208 | *add = 0; | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | __uml_setup("tty_log_fd=", set_tty_log_fd, | ||
213 | "tty_log_fd=<fd>\n" | ||
214 | " This is used to specify a preconfigured file descriptor to which all\n" | ||
215 | " tty data will be written. Preconfigure the descriptor with something\n" | ||
216 | " like '10>tty_log tty_log_fd=10'.\n\n" | ||
217 | ); | ||