diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:08 -0400 |
commit | cd1ae0e49bdd814cfaa2e5ab28cff21a30e20085 (patch) | |
tree | 1b993b9de4cb9a8578022a4014063c3e87ec996e /arch/um/drivers/slirp_user.c | |
parent | 1a80521990a0e30e61a92994a009adc52161b070 (diff) |
uml: network formatting
Style and other non-functional changes in the UML networking code, including
include tidying
style violations
copyright updates
printks getting severities
userspace code calling libc directly rather than using the os_*
wrappers
There's also a exit path cleanup in the pcap driver.
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/slirp_user.c')
-rw-r--r-- | arch/um/drivers/slirp_user.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c index 0e462f64f227..a4755bc33e1e 100644 --- a/arch/um/drivers/slirp_user.c +++ b/arch/um/drivers/slirp_user.c | |||
@@ -1,18 +1,17 @@ | |||
1 | #include <stdio.h> | 1 | /* |
2 | #include <stdlib.h> | 2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL. | ||
4 | */ | ||
5 | |||
3 | #include <unistd.h> | 6 | #include <unistd.h> |
4 | #include <stddef.h> | ||
5 | #include <sched.h> | ||
6 | #include <string.h> | ||
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <string.h> | ||
8 | #include <sys/wait.h> | 9 | #include <sys/wait.h> |
9 | #include <sys/signal.h> | 10 | #include "kern_constants.h" |
10 | #include "kern_util.h" | ||
11 | #include "user.h" | ||
12 | #include "net_user.h" | 11 | #include "net_user.h" |
13 | #include "slirp.h" | ||
14 | #include "slip_common.h" | ||
15 | #include "os.h" | 12 | #include "os.h" |
13 | #include "slirp.h" | ||
14 | #include "user.h" | ||
16 | 15 | ||
17 | static int slirp_user_init(void *data, void *dev) | 16 | static int slirp_user_init(void *data, void *dev) |
18 | { | 17 | { |
@@ -31,8 +30,10 @@ static void slirp_pre_exec(void *arg) | |||
31 | { | 30 | { |
32 | struct slirp_pre_exec_data *data = arg; | 31 | struct slirp_pre_exec_data *data = arg; |
33 | 32 | ||
34 | if(data->stdin != -1) dup2(data->stdin, 0); | 33 | if (data->stdin != -1) |
35 | if(data->stdout != -1) dup2(data->stdout, 1); | 34 | dup2(data->stdin, 0); |
35 | if (data->stdout != -1) | ||
36 | dup2(data->stdout, 1); | ||
36 | } | 37 | } |
37 | 38 | ||
38 | static int slirp_tramp(char **argv, int fd) | 39 | static int slirp_tramp(char **argv, int fd) |
@@ -44,7 +45,7 @@ static int slirp_tramp(char **argv, int fd) | |||
44 | pe_data.stdout = fd; | 45 | pe_data.stdout = fd; |
45 | pid = run_helper(slirp_pre_exec, &pe_data, argv); | 46 | pid = run_helper(slirp_pre_exec, &pe_data, argv); |
46 | 47 | ||
47 | return(pid); | 48 | return pid; |
48 | } | 49 | } |
49 | 50 | ||
50 | static int slirp_open(void *data) | 51 | static int slirp_open(void *data) |
@@ -53,12 +54,12 @@ static int slirp_open(void *data) | |||
53 | int fds[2], pid, err; | 54 | int fds[2], pid, err; |
54 | 55 | ||
55 | err = os_pipe(fds, 1, 1); | 56 | err = os_pipe(fds, 1, 1); |
56 | if(err) | 57 | if (err) |
57 | return(err); | 58 | return err; |
58 | 59 | ||
59 | err = slirp_tramp(pri->argw.argv, fds[1]); | 60 | err = slirp_tramp(pri->argw.argv, fds[1]); |
60 | if(err < 0){ | 61 | if (err < 0) { |
61 | printk("slirp_tramp failed - errno = %d\n", -err); | 62 | printk(UM_KERN_ERR "slirp_tramp failed - errno = %d\n", -err); |
62 | goto out; | 63 | goto out; |
63 | } | 64 | } |
64 | pid = err; | 65 | pid = err; |
@@ -68,10 +69,10 @@ static int slirp_open(void *data) | |||
68 | pri->slip.esc = 0; | 69 | pri->slip.esc = 0; |
69 | pri->pid = err; | 70 | pri->pid = err; |
70 | 71 | ||
71 | return(fds[0]); | 72 | return fds[0]; |
72 | out: | 73 | out: |
73 | os_close_file(fds[0]); | 74 | close(fds[0]); |
74 | os_close_file(fds[1]); | 75 | close(fds[1]); |
75 | return err; | 76 | return err; |
76 | } | 77 | } |
77 | 78 | ||
@@ -80,31 +81,33 @@ static void slirp_close(int fd, void *data) | |||
80 | struct slirp_data *pri = data; | 81 | struct slirp_data *pri = data; |
81 | int status,err; | 82 | int status,err; |
82 | 83 | ||
83 | os_close_file(fd); | 84 | close(fd); |
84 | os_close_file(pri->slave); | 85 | close(pri->slave); |
85 | 86 | ||
86 | pri->slave = -1; | 87 | pri->slave = -1; |
87 | 88 | ||
88 | if(pri->pid<1) { | 89 | if (pri->pid<1) { |
89 | printk("slirp_close: no child process to shut down\n"); | 90 | printk(UM_KERN_ERR "slirp_close: no child process to shut " |
91 | "down\n"); | ||
90 | return; | 92 | return; |
91 | } | 93 | } |
92 | 94 | ||
93 | #if 0 | 95 | #if 0 |
94 | if(kill(pri->pid, SIGHUP)<0) { | 96 | if (kill(pri->pid, SIGHUP)<0) { |
95 | printk("slirp_close: sending hangup to %d failed (%d)\n", | 97 | printk(UM_KERN_ERR "slirp_close: sending hangup to %d failed " |
96 | pri->pid, errno); | 98 | "(%d)\n", pri->pid, errno); |
97 | } | 99 | } |
98 | #endif | 100 | #endif |
99 | 101 | ||
100 | CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG)); | 102 | CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG)); |
101 | if(err < 0) { | 103 | if (err < 0) { |
102 | printk("slirp_close: waitpid returned %d\n", errno); | 104 | printk(UM_KERN_ERR "slirp_close: waitpid returned %d\n", errno); |
103 | return; | 105 | return; |
104 | } | 106 | } |
105 | 107 | ||
106 | if(err == 0) { | 108 | if (err == 0) { |
107 | printk("slirp_close: process %d has not exited\n", pri->pid); | 109 | printk(UM_KERN_ERR "slirp_close: process %d has not exited\n", |
110 | pri->pid); | ||
108 | return; | 111 | return; |
109 | } | 112 | } |
110 | 113 | ||
@@ -123,7 +126,7 @@ int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri) | |||
123 | 126 | ||
124 | static int slirp_set_mtu(int mtu, void *data) | 127 | static int slirp_set_mtu(int mtu, void *data) |
125 | { | 128 | { |
126 | return(mtu); | 129 | return mtu; |
127 | } | 130 | } |
128 | 131 | ||
129 | const struct net_user_info slirp_user_info = { | 132 | const struct net_user_info slirp_user_info = { |