diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:09 -0400 |
commit | cb8fa61c2b8b29d422d7310f064d60022f18f89b (patch) | |
tree | f5c8ac78b109e6c76e05250d19fd75e28c47dc74 /arch/um/drivers/mconsole_user.c | |
parent | 54ae36f24b103e521dd683f66fe72b0584ccb7e2 (diff) |
uml: arch/um/drivers formatting
Style fixes for the rest of the drivers. arch/um/drivers should be pretty
CodingStyle-compliant now.
Except for the ubd driver, which will have to be treated separately.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/mconsole_user.c')
-rw-r--r-- | arch/um/drivers/mconsole_user.c | 119 |
1 files changed, 54 insertions, 65 deletions
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index f31e71546e52..430c024a19b0 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
@@ -1,25 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) | 2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) |
3 | * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com) | 3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
4 | * Licensed under the GPL | 4 | * Licensed under the GPL |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <stdio.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <errno.h> | 7 | #include <errno.h> |
10 | #include <signal.h> | 8 | #include <string.h> |
9 | #include <unistd.h> | ||
11 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
12 | #include <sys/types.h> | ||
13 | #include <sys/uio.h> | 11 | #include <sys/uio.h> |
14 | #include <sys/un.h> | 12 | #include <sys/un.h> |
15 | #include <unistd.h> | 13 | #include "kern_constants.h" |
16 | #include "user.h" | ||
17 | #include "sysdep/ptrace.h" | ||
18 | #include "mconsole.h" | 14 | #include "mconsole.h" |
19 | #include "os.h" | 15 | #include "user.h" |
20 | 16 | ||
21 | static struct mconsole_command commands[] = { | 17 | static struct mconsole_command commands[] = { |
22 | /* With uts namespaces, uts information becomes process-specific, so | 18 | /* |
19 | * With uts namespaces, uts information becomes process-specific, so | ||
23 | * we need a process context. If we try handling this in interrupt | 20 | * we need a process context. If we try handling this in interrupt |
24 | * context, we may hit an exiting process without a valid uts | 21 | * context, we may hit an exiting process without a valid uts |
25 | * namespace. | 22 | * namespace. |
@@ -36,7 +33,7 @@ static struct mconsole_command commands[] = { | |||
36 | { "go", mconsole_go, MCONSOLE_INTR }, | 33 | { "go", mconsole_go, MCONSOLE_INTR }, |
37 | { "log", mconsole_log, MCONSOLE_INTR }, | 34 | { "log", mconsole_log, MCONSOLE_INTR }, |
38 | { "proc", mconsole_proc, MCONSOLE_PROC }, | 35 | { "proc", mconsole_proc, MCONSOLE_PROC }, |
39 | { "stack", mconsole_stack, MCONSOLE_INTR }, | 36 | { "stack", mconsole_stack, MCONSOLE_INTR }, |
40 | }; | 37 | }; |
41 | 38 | ||
42 | /* Initialized in mconsole_init, which is an initcall */ | 39 | /* Initialized in mconsole_init, which is an initcall */ |
@@ -44,21 +41,21 @@ char mconsole_socket_name[256]; | |||
44 | 41 | ||
45 | int mconsole_reply_v0(struct mc_request *req, char *reply) | 42 | int mconsole_reply_v0(struct mc_request *req, char *reply) |
46 | { | 43 | { |
47 | struct iovec iov; | 44 | struct iovec iov; |
48 | struct msghdr msg; | 45 | struct msghdr msg; |
49 | 46 | ||
50 | iov.iov_base = reply; | 47 | iov.iov_base = reply; |
51 | iov.iov_len = strlen(reply); | 48 | iov.iov_len = strlen(reply); |
52 | 49 | ||
53 | msg.msg_name = &(req->origin); | 50 | msg.msg_name = &(req->origin); |
54 | msg.msg_namelen = req->originlen; | 51 | msg.msg_namelen = req->originlen; |
55 | msg.msg_iov = &iov; | 52 | msg.msg_iov = &iov; |
56 | msg.msg_iovlen = 1; | 53 | msg.msg_iovlen = 1; |
57 | msg.msg_control = NULL; | 54 | msg.msg_control = NULL; |
58 | msg.msg_controllen = 0; | 55 | msg.msg_controllen = 0; |
59 | msg.msg_flags = 0; | 56 | msg.msg_flags = 0; |
60 | 57 | ||
61 | return sendmsg(req->originating_fd, &msg, 0); | 58 | return sendmsg(req->originating_fd, &msg, 0); |
62 | } | 59 | } |
63 | 60 | ||
64 | static struct mconsole_command *mconsole_parse(struct mc_request *req) | 61 | static struct mconsole_command *mconsole_parse(struct mc_request *req) |
@@ -66,10 +63,10 @@ static struct mconsole_command *mconsole_parse(struct mc_request *req) | |||
66 | struct mconsole_command *cmd; | 63 | struct mconsole_command *cmd; |
67 | int i; | 64 | int i; |
68 | 65 | ||
69 | for(i = 0; i < ARRAY_SIZE(commands); i++){ | 66 | for (i = 0; i < ARRAY_SIZE(commands); i++) { |
70 | cmd = &commands[i]; | 67 | cmd = &commands[i]; |
71 | if(!strncmp(req->request.data, cmd->command, | 68 | if (!strncmp(req->request.data, cmd->command, |
72 | strlen(cmd->command))){ | 69 | strlen(cmd->command))) { |
73 | return cmd; | 70 | return cmd; |
74 | } | 71 | } |
75 | } | 72 | } |
@@ -94,9 +91,9 @@ int mconsole_get_request(int fd, struct mc_request *req) | |||
94 | 91 | ||
95 | req->originating_fd = fd; | 92 | req->originating_fd = fd; |
96 | 93 | ||
97 | if(req->request.magic != MCONSOLE_MAGIC){ | 94 | if (req->request.magic != MCONSOLE_MAGIC) { |
98 | /* Unversioned request */ | 95 | /* Unversioned request */ |
99 | len = MIN(sizeof(req->request.data) - 1, | 96 | len = MIN(sizeof(req->request.data) - 1, |
100 | strlen((char *) &req->request)); | 97 | strlen((char *) &req->request)); |
101 | memmove(req->request.data, &req->request, len); | 98 | memmove(req->request.data, &req->request, len); |
102 | req->request.data[len] = '\0'; | 99 | req->request.data[len] = '\0'; |
@@ -107,32 +104,33 @@ int mconsole_get_request(int fd, struct mc_request *req) | |||
107 | 104 | ||
108 | mconsole_reply_v0(req, "ERR Version 0 mconsole clients are " | 105 | mconsole_reply_v0(req, "ERR Version 0 mconsole clients are " |
109 | "not supported by this driver"); | 106 | "not supported by this driver"); |
110 | return(0); | 107 | return 0; |
111 | } | 108 | } |
112 | 109 | ||
113 | if(req->request.len >= MCONSOLE_MAX_DATA){ | 110 | if (req->request.len >= MCONSOLE_MAX_DATA) { |
114 | mconsole_reply(req, "Request too large", 1, 0); | 111 | mconsole_reply(req, "Request too large", 1, 0); |
115 | return(0); | 112 | return 0; |
116 | } | 113 | } |
117 | if(req->request.version != MCONSOLE_VERSION){ | 114 | if (req->request.version != MCONSOLE_VERSION) { |
118 | mconsole_reply(req, "This driver only supports version " | 115 | mconsole_reply(req, "This driver only supports version " |
119 | STRING(MCONSOLE_VERSION) " clients", 1, 0); | 116 | STRING(MCONSOLE_VERSION) " clients", 1, 0); |
120 | } | 117 | } |
121 | 118 | ||
122 | req->request.data[req->request.len] = '\0'; | 119 | req->request.data[req->request.len] = '\0'; |
123 | req->cmd = mconsole_parse(req); | 120 | req->cmd = mconsole_parse(req); |
124 | if(req->cmd == NULL){ | 121 | if (req->cmd == NULL) { |
125 | mconsole_reply(req, "Unknown command", 1, 0); | 122 | mconsole_reply(req, "Unknown command", 1, 0); |
126 | return(0); | 123 | return 0; |
127 | } | 124 | } |
128 | 125 | ||
129 | return(1); | 126 | return 1; |
130 | } | 127 | } |
131 | 128 | ||
132 | int mconsole_reply_len(struct mc_request *req, const char *str, int total, | 129 | int mconsole_reply_len(struct mc_request *req, const char *str, int total, |
133 | int err, int more) | 130 | int err, int more) |
134 | { | 131 | { |
135 | /* XXX This is a stack consumption problem. It'd be nice to | 132 | /* |
133 | * XXX This is a stack consumption problem. It'd be nice to | ||
136 | * make it global and serialize access to it, but there are a | 134 | * make it global and serialize access to it, but there are a |
137 | * ton of callers to this function. | 135 | * ton of callers to this function. |
138 | */ | 136 | */ |
@@ -147,7 +145,7 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total, | |||
147 | 145 | ||
148 | len = MIN(total, MCONSOLE_MAX_DATA - 1); | 146 | len = MIN(total, MCONSOLE_MAX_DATA - 1); |
149 | 147 | ||
150 | if(len == total) reply.more = more; | 148 | if (len == total) reply.more = more; |
151 | else reply.more = 1; | 149 | else reply.more = 1; |
152 | 150 | ||
153 | memcpy(reply.data, str, len); | 151 | memcpy(reply.data, str, len); |
@@ -161,9 +159,10 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total, | |||
161 | n = sendto(req->originating_fd, &reply, len, 0, | 159 | n = sendto(req->originating_fd, &reply, len, 0, |
162 | (struct sockaddr *) req->origin, req->originlen); | 160 | (struct sockaddr *) req->origin, req->originlen); |
163 | 161 | ||
164 | if(n < 0) return(-errno); | 162 | if (n < 0) |
165 | } while(total > 0); | 163 | return -errno; |
166 | return(0); | 164 | } while (total > 0); |
165 | return 0; | ||
167 | } | 166 | } |
168 | 167 | ||
169 | int mconsole_reply(struct mc_request *req, const char *str, int err, int more) | 168 | int mconsole_reply(struct mc_request *req, const char *str, int err, int more) |
@@ -187,18 +186,18 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
187 | int n, err = 0; | 186 | int n, err = 0; |
188 | 187 | ||
189 | lock_notify(); | 188 | lock_notify(); |
190 | if(notify_sock < 0){ | 189 | if (notify_sock < 0) { |
191 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 190 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
192 | if(notify_sock < 0){ | 191 | if (notify_sock < 0) { |
193 | err = -errno; | 192 | err = -errno; |
194 | printk("mconsole_notify - socket failed, errno = %d\n", | 193 | printk(UM_KERN_ERR "mconsole_notify - socket failed, " |
195 | err); | 194 | "errno = %d\n", errno); |
196 | } | 195 | } |
197 | } | 196 | } |
198 | unlock_notify(); | 197 | unlock_notify(); |
199 | 198 | ||
200 | if(err) | 199 | if (err) |
201 | return(err); | 200 | return err; |
202 | 201 | ||
203 | target.sun_family = AF_UNIX; | 202 | target.sun_family = AF_UNIX; |
204 | strcpy(target.sun_path, sock_name); | 203 | strcpy(target.sun_path, sock_name); |
@@ -212,22 +211,12 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
212 | 211 | ||
213 | err = 0; | 212 | err = 0; |
214 | len = sizeof(packet) + packet.len - sizeof(packet.data); | 213 | len = sizeof(packet) + packet.len - sizeof(packet.data); |
215 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, | 214 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, |
216 | sizeof(target)); | 215 | sizeof(target)); |
217 | if(n < 0){ | 216 | if (n < 0) { |
218 | err = -errno; | 217 | err = -errno; |
219 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | 218 | printk(UM_KERN_ERR "mconsole_notify - sendto failed, " |
219 | "errno = %d\n", errno); | ||
220 | } | 220 | } |
221 | return(err); | 221 | return err; |
222 | } | 222 | } |
223 | |||
224 | /* | ||
225 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
226 | * Emacs will notice this stuff at the end of the file and automatically | ||
227 | * adjust the settings for this buffer only. This must remain at the end | ||
228 | * of the file. | ||
229 | * --------------------------------------------------------------------------- | ||
230 | * Local variables: | ||
231 | * c-file-style: "linux" | ||
232 | * End: | ||
233 | */ | ||