aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/net_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/net_user.c')
-rw-r--r--arch/um/drivers/net_user.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0a7786e00cfb..8cd851be0e4d 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -22,13 +22,14 @@ int tap_open_common(void *dev, char *gate_addr)
22{ 22{
23 int tap_addr[4]; 23 int tap_addr[4];
24 24
25 if(gate_addr == NULL) return(0); 25 if(gate_addr == NULL)
26 return 0;
26 if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], 27 if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
27 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){ 28 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){
28 printk("Invalid tap IP address - '%s'\n", gate_addr); 29 printk("Invalid tap IP address - '%s'\n", gate_addr);
29 return(-EINVAL); 30 return -EINVAL;
30 } 31 }
31 return(0); 32 return 0;
32} 33}
33 34
34void tap_check_ips(char *gate_addr, unsigned char *eth_addr) 35void tap_check_ips(char *gate_addr, unsigned char *eth_addr)
@@ -94,10 +95,10 @@ int net_read(int fd, void *buf, int len)
94 n = os_read_file(fd, buf, len); 95 n = os_read_file(fd, buf, len);
95 96
96 if(n == -EAGAIN) 97 if(n == -EAGAIN)
97 return(0); 98 return 0;
98 else if(n == 0) 99 else if(n == 0)
99 return(-ENOTCONN); 100 return -ENOTCONN;
100 return(n); 101 return n;
101} 102}
102 103
103int net_recvfrom(int fd, void *buf, int len) 104int net_recvfrom(int fd, void *buf, int len)
@@ -108,11 +109,13 @@ int net_recvfrom(int fd, void *buf, int len)
108 (errno == EINTR)) ; 109 (errno == EINTR)) ;
109 110
110 if(n < 0){ 111 if(n < 0){
111 if(errno == EAGAIN) return(0); 112 if(errno == EAGAIN)
112 return(-errno); 113 return 0;
114 return -errno;
113 } 115 }
114 else if(n == 0) return(-ENOTCONN); 116 else if(n == 0)
115 return(n); 117 return -ENOTCONN;
118 return n;
116} 119}
117 120
118int net_write(int fd, void *buf, int len) 121int net_write(int fd, void *buf, int len)
@@ -122,10 +125,10 @@ int net_write(int fd, void *buf, int len)
122 n = os_write_file(fd, buf, len); 125 n = os_write_file(fd, buf, len);
123 126
124 if(n == -EAGAIN) 127 if(n == -EAGAIN)
125 return(0); 128 return 0;
126 else if(n == 0) 129 else if(n == 0)
127 return(-ENOTCONN); 130 return -ENOTCONN;
128 return(n); 131 return n;
129} 132}
130 133
131int net_send(int fd, void *buf, int len) 134int net_send(int fd, void *buf, int len)
@@ -134,11 +137,13 @@ int net_send(int fd, void *buf, int len)
134 137
135 while(((n = send(fd, buf, len, 0)) < 0) && (errno == EINTR)) ; 138 while(((n = send(fd, buf, len, 0)) < 0) && (errno == EINTR)) ;
136 if(n < 0){ 139 if(n < 0){
137 if(errno == EAGAIN) return(0); 140 if(errno == EAGAIN)
138 return(-errno); 141 return 0;
142 return -errno;
139 } 143 }
140 else if(n == 0) return(-ENOTCONN); 144 else if(n == 0)
141 return(n); 145 return -ENOTCONN;
146 return n;
142} 147}
143 148
144int net_sendto(int fd, void *buf, int len, void *to, int sock_len) 149int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
@@ -148,11 +153,13 @@ int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
148 while(((n = sendto(fd, buf, len, 0, (struct sockaddr *) to, 153 while(((n = sendto(fd, buf, len, 0, (struct sockaddr *) to,
149 sock_len)) < 0) && (errno == EINTR)) ; 154 sock_len)) < 0) && (errno == EINTR)) ;
150 if(n < 0){ 155 if(n < 0){
151 if(errno == EAGAIN) return(0); 156 if(errno == EAGAIN)
152 return(-errno); 157 return 0;
158 return -errno;
153 } 159 }
154 else if(n == 0) return(-ENOTCONN); 160 else if(n == 0)
155 return(n); 161 return -ENOTCONN;
162 return n;
156} 163}
157 164
158struct change_pre_exec_data { 165struct change_pre_exec_data {
@@ -176,7 +183,7 @@ static int change_tramp(char **argv, char *output, int output_len)
176 err = os_pipe(fds, 1, 0); 183 err = os_pipe(fds, 1, 0);
177 if(err < 0){ 184 if(err < 0){
178 printk("change_tramp - pipe failed, err = %d\n", -err); 185 printk("change_tramp - pipe failed, err = %d\n", -err);
179 return(err); 186 return err;
180 } 187 }
181 pe_data.close_me = fds[0]; 188 pe_data.close_me = fds[0];
182 pe_data.stdout = fds[1]; 189 pe_data.stdout = fds[1];
@@ -190,7 +197,7 @@ static int change_tramp(char **argv, char *output, int output_len)
190 197
191 if (pid > 0) 198 if (pid > 0)
192 CATCH_EINTR(err = waitpid(pid, NULL, 0)); 199 CATCH_EINTR(err = waitpid(pid, NULL, 0));
193 return(pid); 200 return pid;
194} 201}
195 202
196static void change(char *dev, char *what, unsigned char *addr, 203static void change(char *dev, char *what, unsigned char *addr,
@@ -241,26 +248,15 @@ char *split_if_spec(char *str, ...)
241 va_start(ap, str); 248 va_start(ap, str);
242 while((arg = va_arg(ap, char **)) != NULL){ 249 while((arg = va_arg(ap, char **)) != NULL){
243 if(*str == '\0') 250 if(*str == '\0')
244 return(NULL); 251 return NULL;
245 end = strchr(str, ','); 252 end = strchr(str, ',');
246 if(end != str) 253 if(end != str)
247 *arg = str; 254 *arg = str;
248 if(end == NULL) 255 if(end == NULL)
249 return(NULL); 256 return NULL;
250 *end++ = '\0'; 257 *end++ = '\0';
251 str = end; 258 str = end;
252 } 259 }
253 va_end(ap); 260 va_end(ap);
254 return(str); 261 return str;
255} 262}
256
257/*
258 * Overrides for Emacs so that we follow Linus's tabbing style.
259 * Emacs will notice this stuff at the end of the file and automatically
260 * adjust the settings for this buffer only. This must remain at the end
261 * of the file.
262 * ---------------------------------------------------------------------------
263 * Local variables:
264 * c-file-style: "linux"
265 * End:
266 */