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/daemon_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/daemon_user.c')
-rw-r--r-- | arch/um/drivers/daemon_user.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c index 8d2008f06682..90983d480ac6 100644 --- a/arch/um/drivers/daemon_user.c +++ b/arch/um/drivers/daemon_user.c | |||
@@ -1,22 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | 2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | ||
3 | * James Leu (jleu@mindspring.net). | 4 | * James Leu (jleu@mindspring.net). |
4 | * Copyright (C) 2001 by various other people who didn't put their name here. | 5 | * Copyright (C) 2001 by various other people who didn't put their name here. |
5 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include <errno.h> | ||
9 | #include <unistd.h> | ||
10 | #include <stdint.h> | 9 | #include <stdint.h> |
10 | #include <unistd.h> | ||
11 | #include <errno.h> | ||
12 | #include <sys/types.h> | ||
11 | #include <sys/socket.h> | 13 | #include <sys/socket.h> |
12 | #include <sys/un.h> | ||
13 | #include <sys/time.h> | 14 | #include <sys/time.h> |
14 | #include "net_user.h" | 15 | #include <sys/un.h> |
15 | #include "daemon.h" | 16 | #include "daemon.h" |
16 | #include "kern_util.h" | 17 | #include "net_user.h" |
17 | #include "user.h" | ||
18 | #include "os.h" | 18 | #include "os.h" |
19 | #include "um_malloc.h" | 19 | #include "um_malloc.h" |
20 | #include "user.h" | ||
20 | 21 | ||
21 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 22 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
22 | 23 | ||
@@ -36,8 +37,9 @@ static struct sockaddr_un *new_addr(void *name, int len) | |||
36 | struct sockaddr_un *sun; | 37 | struct sockaddr_un *sun; |
37 | 38 | ||
38 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 39 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
39 | if(sun == NULL){ | 40 | if (sun == NULL) { |
40 | printk("new_addr: allocation of sockaddr_un failed\n"); | 41 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
42 | "failed\n"); | ||
41 | return NULL; | 43 | return NULL; |
42 | } | 44 | } |
43 | sun->sun_family = AF_UNIX; | 45 | sun->sun_family = AF_UNIX; |
@@ -54,38 +56,39 @@ static int connect_to_switch(struct daemon_data *pri) | |||
54 | int fd, n, err; | 56 | int fd, n, err; |
55 | 57 | ||
56 | pri->control = socket(AF_UNIX, SOCK_STREAM, 0); | 58 | pri->control = socket(AF_UNIX, SOCK_STREAM, 0); |
57 | if(pri->control < 0){ | 59 | if (pri->control < 0) { |
58 | err = -errno; | 60 | err = -errno; |
59 | printk("daemon_open : control socket failed, errno = %d\n", | 61 | printk(UM_KERN_ERR "daemon_open : control socket failed, " |
60 | -err); | 62 | "errno = %d\n", -err); |
61 | return err; | 63 | return err; |
62 | } | 64 | } |
63 | 65 | ||
64 | if(connect(pri->control, (struct sockaddr *) ctl_addr, | 66 | if (connect(pri->control, (struct sockaddr *) ctl_addr, |
65 | sizeof(*ctl_addr)) < 0){ | 67 | sizeof(*ctl_addr)) < 0) { |
66 | err = -errno; | 68 | err = -errno; |
67 | printk("daemon_open : control connect failed, errno = %d\n", | 69 | printk(UM_KERN_ERR "daemon_open : control connect failed, " |
68 | -err); | 70 | "errno = %d\n", -err); |
69 | goto out; | 71 | goto out; |
70 | } | 72 | } |
71 | 73 | ||
72 | fd = socket(AF_UNIX, SOCK_DGRAM, 0); | 74 | fd = socket(AF_UNIX, SOCK_DGRAM, 0); |
73 | if(fd < 0){ | 75 | if (fd < 0) { |
74 | err = -errno; | 76 | err = -errno; |
75 | printk("daemon_open : data socket failed, errno = %d\n", | 77 | printk(UM_KERN_ERR "daemon_open : data socket failed, " |
76 | -err); | 78 | "errno = %d\n", -err); |
77 | goto out; | 79 | goto out; |
78 | } | 80 | } |
79 | if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){ | 81 | if (bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0) { |
80 | err = -errno; | 82 | err = -errno; |
81 | printk("daemon_open : data bind failed, errno = %d\n", | 83 | printk(UM_KERN_ERR "daemon_open : data bind failed, " |
82 | -err); | 84 | "errno = %d\n", -err); |
83 | goto out_close; | 85 | goto out_close; |
84 | } | 86 | } |
85 | 87 | ||
86 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 88 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
87 | if(sun == NULL){ | 89 | if (sun == NULL) { |
88 | printk("new_addr: allocation of sockaddr_un failed\n"); | 90 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
91 | "failed\n"); | ||
89 | err = -ENOMEM; | 92 | err = -ENOMEM; |
90 | goto out_close; | 93 | goto out_close; |
91 | } | 94 | } |
@@ -94,18 +97,18 @@ static int connect_to_switch(struct daemon_data *pri) | |||
94 | req.version = SWITCH_VERSION; | 97 | req.version = SWITCH_VERSION; |
95 | req.type = REQ_NEW_CONTROL; | 98 | req.type = REQ_NEW_CONTROL; |
96 | req.sock = *local_addr; | 99 | req.sock = *local_addr; |
97 | n = os_write_file(pri->control, &req, sizeof(req)); | 100 | n = write(pri->control, &req, sizeof(req)); |
98 | if(n != sizeof(req)){ | 101 | if (n != sizeof(req)) { |
99 | printk("daemon_open : control setup request failed, err = %d\n", | 102 | printk(UM_KERN_ERR "daemon_open : control setup request " |
100 | -n); | 103 | "failed, err = %d\n", -errno); |
101 | err = -ENOTCONN; | 104 | err = -ENOTCONN; |
102 | goto out_free; | 105 | goto out_free; |
103 | } | 106 | } |
104 | 107 | ||
105 | n = os_read_file(pri->control, sun, sizeof(*sun)); | 108 | n = read(pri->control, sun, sizeof(*sun)); |
106 | if(n != sizeof(*sun)){ | 109 | if (n != sizeof(*sun)) { |
107 | printk("daemon_open : read of data socket failed, err = %d\n", | 110 | printk(UM_KERN_ERR "daemon_open : read of data socket failed, " |
108 | -n); | 111 | "err = %d\n", -errno); |
109 | err = -ENOTCONN; | 112 | err = -ENOTCONN; |
110 | goto out_free; | 113 | goto out_free; |
111 | } | 114 | } |
@@ -116,9 +119,9 @@ static int connect_to_switch(struct daemon_data *pri) | |||
116 | out_free: | 119 | out_free: |
117 | kfree(sun); | 120 | kfree(sun); |
118 | out_close: | 121 | out_close: |
119 | os_close_file(fd); | 122 | close(fd); |
120 | out: | 123 | out: |
121 | os_close_file(pri->control); | 124 | close(pri->control); |
122 | return err; | 125 | return err; |
123 | } | 126 | } |
124 | 127 | ||
@@ -132,8 +135,8 @@ static int daemon_user_init(void *data, void *dev) | |||
132 | int usecs; | 135 | int usecs; |
133 | } name; | 136 | } name; |
134 | 137 | ||
135 | if(!strcmp(pri->sock_type, "unix")) | 138 | if (!strcmp(pri->sock_type, "unix")) |
136 | pri->ctl_addr = new_addr(pri->ctl_sock, | 139 | pri->ctl_addr = new_addr(pri->ctl_sock, |
137 | strlen(pri->ctl_sock) + 1); | 140 | strlen(pri->ctl_sock) + 1); |
138 | name.zero = 0; | 141 | name.zero = 0; |
139 | name.pid = os_getpid(); | 142 | name.pid = os_getpid(); |
@@ -142,7 +145,7 @@ static int daemon_user_init(void *data, void *dev) | |||
142 | pri->local_addr = new_addr(&name, sizeof(name)); | 145 | pri->local_addr = new_addr(&name, sizeof(name)); |
143 | pri->dev = dev; | 146 | pri->dev = dev; |
144 | pri->fd = connect_to_switch(pri); | 147 | pri->fd = connect_to_switch(pri); |
145 | if(pri->fd < 0){ | 148 | if (pri->fd < 0) { |
146 | kfree(pri->local_addr); | 149 | kfree(pri->local_addr); |
147 | pri->local_addr = NULL; | 150 | pri->local_addr = NULL; |
148 | return pri->fd; | 151 | return pri->fd; |
@@ -161,9 +164,9 @@ static void daemon_remove(void *data) | |||
161 | { | 164 | { |
162 | struct daemon_data *pri = data; | 165 | struct daemon_data *pri = data; |
163 | 166 | ||
164 | os_close_file(pri->fd); | 167 | close(pri->fd); |
165 | pri->fd = -1; | 168 | pri->fd = -1; |
166 | os_close_file(pri->control); | 169 | close(pri->control); |
167 | pri->control = -1; | 170 | pri->control = -1; |
168 | 171 | ||
169 | kfree(pri->data_addr); | 172 | kfree(pri->data_addr); |