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.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0a7786e00cfb..107c5e43fa00 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,25 +95,25 @@ 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)
104{ 105{
105 int n; 106 int n;
106 107
107 while(((n = recvfrom(fd, buf, len, 0, NULL, NULL)) < 0) && 108 CATCH_EINTR(n = recvfrom(fd, buf, len, 0, NULL, NULL));
108 (errno == EINTR)) ;
109
110 if(n < 0){ 109 if(n < 0){
111 if(errno == EAGAIN) return(0); 110 if(errno == EAGAIN)
112 return(-errno); 111 return 0;
112 return -errno;
113 } 113 }
114 else if(n == 0) return(-ENOTCONN); 114 else if(n == 0)
115 return(n); 115 return -ENOTCONN;
116 return n;
116} 117}
117 118
118int net_write(int fd, void *buf, int len) 119int net_write(int fd, void *buf, int len)
@@ -122,37 +123,41 @@ int net_write(int fd, void *buf, int len)
122 n = os_write_file(fd, buf, len); 123 n = os_write_file(fd, buf, len);
123 124
124 if(n == -EAGAIN) 125 if(n == -EAGAIN)
125 return(0); 126 return 0;
126 else if(n == 0) 127 else if(n == 0)
127 return(-ENOTCONN); 128 return -ENOTCONN;
128 return(n); 129 return n;
129} 130}
130 131
131int net_send(int fd, void *buf, int len) 132int net_send(int fd, void *buf, int len)
132{ 133{
133 int n; 134 int n;
134 135
135 while(((n = send(fd, buf, len, 0)) < 0) && (errno == EINTR)) ; 136 CATCH_EINTR(n = send(fd, buf, len, 0));
136 if(n < 0){ 137 if(n < 0){
137 if(errno == EAGAIN) return(0); 138 if(errno == EAGAIN)
138 return(-errno); 139 return 0;
140 return -errno;
139 } 141 }
140 else if(n == 0) return(-ENOTCONN); 142 else if(n == 0)
141 return(n); 143 return -ENOTCONN;
144 return n;
142} 145}
143 146
144int net_sendto(int fd, void *buf, int len, void *to, int sock_len) 147int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
145{ 148{
146 int n; 149 int n;
147 150
148 while(((n = sendto(fd, buf, len, 0, (struct sockaddr *) to, 151 CATCH_EINTR(n = sendto(fd, buf, len, 0, (struct sockaddr *) to,
149 sock_len)) < 0) && (errno == EINTR)) ; 152 sock_len));
150 if(n < 0){ 153 if(n < 0){
151 if(errno == EAGAIN) return(0); 154 if(errno == EAGAIN)
152 return(-errno); 155 return 0;
156 return -errno;
153 } 157 }
154 else if(n == 0) return(-ENOTCONN); 158 else if(n == 0)
155 return(n); 159 return -ENOTCONN;
160 return n;
156} 161}
157 162
158struct change_pre_exec_data { 163struct change_pre_exec_data {
@@ -176,7 +181,7 @@ static int change_tramp(char **argv, char *output, int output_len)
176 err = os_pipe(fds, 1, 0); 181 err = os_pipe(fds, 1, 0);
177 if(err < 0){ 182 if(err < 0){
178 printk("change_tramp - pipe failed, err = %d\n", -err); 183 printk("change_tramp - pipe failed, err = %d\n", -err);
179 return(err); 184 return err;
180 } 185 }
181 pe_data.close_me = fds[0]; 186 pe_data.close_me = fds[0];
182 pe_data.stdout = fds[1]; 187 pe_data.stdout = fds[1];
@@ -190,7 +195,7 @@ static int change_tramp(char **argv, char *output, int output_len)
190 195
191 if (pid > 0) 196 if (pid > 0)
192 CATCH_EINTR(err = waitpid(pid, NULL, 0)); 197 CATCH_EINTR(err = waitpid(pid, NULL, 0));
193 return(pid); 198 return pid;
194} 199}
195 200
196static void change(char *dev, char *what, unsigned char *addr, 201static void change(char *dev, char *what, unsigned char *addr,
@@ -241,26 +246,15 @@ char *split_if_spec(char *str, ...)
241 va_start(ap, str); 246 va_start(ap, str);
242 while((arg = va_arg(ap, char **)) != NULL){ 247 while((arg = va_arg(ap, char **)) != NULL){
243 if(*str == '\0') 248 if(*str == '\0')
244 return(NULL); 249 return NULL;
245 end = strchr(str, ','); 250 end = strchr(str, ',');
246 if(end != str) 251 if(end != str)
247 *arg = str; 252 *arg = str;
248 if(end == NULL) 253 if(end == NULL)
249 return(NULL); 254 return NULL;
250 *end++ = '\0'; 255 *end++ = '\0';
251 str = end; 256 str = end;
252 } 257 }
253 va_end(ap); 258 va_end(ap);
254 return(str); 259 return str;
255} 260}
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 */