diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-07-10 07:45:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 16:24:24 -0400 |
commit | 108ffa8cbfa323d462a2f4b49f38da3205d36e5a (patch) | |
tree | a9474c48ff4da341ce296b9b26da70dd5bba0fd2 /arch | |
parent | 1d3468a6643a6a5905e2ac9ae1fa1aefc06d882a (diff) |
[PATCH] uml: formatting fixes
Fix a bunch of formatting problems.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/drivers/net_user.c | 70 | ||||
-rw-r--r-- | arch/um/drivers/tty.c | 31 | ||||
-rw-r--r-- | arch/um/os-Linux/file.c | 137 |
3 files changed, 110 insertions, 128 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 | ||
34 | void tap_check_ips(char *gate_addr, unsigned char *eth_addr) | 35 | void 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 | ||
103 | int net_recvfrom(int fd, void *buf, int len) | 104 | int 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 | ||
118 | int net_write(int fd, void *buf, int len) | 121 | int 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 | ||
131 | int net_send(int fd, void *buf, int len) | 134 | int 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 | ||
144 | int net_sendto(int fd, void *buf, int len, void *to, int sock_len) | 149 | int 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 | ||
158 | struct change_pre_exec_data { | 165 | struct 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 | ||
196 | static void change(char *dev, char *what, unsigned char *addr, | 203 | static 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 | */ | ||
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c index 94c9265a4f2c..9f70edf5d8ef 100644 --- a/arch/um/drivers/tty.c +++ b/arch/um/drivers/tty.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -25,17 +25,17 @@ static void *tty_chan_init(char *str, int device, struct chan_opts *opts) | |||
25 | if(*str != ':'){ | 25 | if(*str != ':'){ |
26 | printk("tty_init : channel type 'tty' must specify " | 26 | printk("tty_init : channel type 'tty' must specify " |
27 | "a device\n"); | 27 | "a device\n"); |
28 | return(NULL); | 28 | return NULL; |
29 | } | 29 | } |
30 | str++; | 30 | str++; |
31 | 31 | ||
32 | data = um_kmalloc(sizeof(*data)); | 32 | data = um_kmalloc(sizeof(*data)); |
33 | if(data == NULL) | 33 | if(data == NULL) |
34 | return(NULL); | 34 | return NULL; |
35 | *data = ((struct tty_chan) { .dev = str, | 35 | *data = ((struct tty_chan) { .dev = str, |
36 | .raw = opts->raw }); | 36 | .raw = opts->raw }); |
37 | 37 | ||
38 | return(data); | 38 | return data; |
39 | } | 39 | } |
40 | 40 | ||
41 | static int tty_open(int input, int output, int primary, void *d, | 41 | static int tty_open(int input, int output, int primary, void *d, |
@@ -45,19 +45,21 @@ static int tty_open(int input, int output, int primary, void *d, | |||
45 | int fd, err; | 45 | int fd, err; |
46 | 46 | ||
47 | fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0); | 47 | fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0); |
48 | if(fd < 0) return(fd); | 48 | if(fd < 0) |
49 | return fd; | ||
50 | |||
49 | if(data->raw){ | 51 | if(data->raw){ |
50 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | 52 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); |
51 | if(err) | 53 | if(err) |
52 | return(err); | 54 | return err; |
53 | 55 | ||
54 | err = raw(fd); | 56 | err = raw(fd); |
55 | if(err) | 57 | if(err) |
56 | return(err); | 58 | return err; |
57 | } | 59 | } |
58 | 60 | ||
59 | *dev_out = data->dev; | 61 | *dev_out = data->dev; |
60 | return(fd); | 62 | return fd; |
61 | } | 63 | } |
62 | 64 | ||
63 | struct chan_ops tty_ops = { | 65 | struct chan_ops tty_ops = { |
@@ -72,14 +74,3 @@ struct chan_ops tty_ops = { | |||
72 | .free = generic_free, | 74 | .free = generic_free, |
73 | .winch = 0, | 75 | .winch = 0, |
74 | }; | 76 | }; |
75 | |||
76 | /* | ||
77 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
78 | * Emacs will notice this stuff at the end of the file and automatically | ||
79 | * adjust the settings for this buffer only. This must remain at the end | ||
80 | * of the file. | ||
81 | * --------------------------------------------------------------------------- | ||
82 | * Local variables: | ||
83 | * c-file-style: "linux" | ||
84 | * End: | ||
85 | */ | ||
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 09251338d99e..367ac33c566d 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -47,11 +47,11 @@ int os_stat_fd(const int fd, struct uml_stat *ubuf) | |||
47 | } while((err < 0) && (errno == EINTR)) ; | 47 | } while((err < 0) && (errno == EINTR)) ; |
48 | 48 | ||
49 | if(err < 0) | 49 | if(err < 0) |
50 | return(-errno); | 50 | return -errno; |
51 | 51 | ||
52 | if(ubuf != NULL) | 52 | if(ubuf != NULL) |
53 | copy_stat(ubuf, &sbuf); | 53 | copy_stat(ubuf, &sbuf); |
54 | return(err); | 54 | return err; |
55 | } | 55 | } |
56 | 56 | ||
57 | int os_stat_file(const char *file_name, struct uml_stat *ubuf) | 57 | int os_stat_file(const char *file_name, struct uml_stat *ubuf) |
@@ -64,11 +64,11 @@ int os_stat_file(const char *file_name, struct uml_stat *ubuf) | |||
64 | } while((err < 0) && (errno == EINTR)) ; | 64 | } while((err < 0) && (errno == EINTR)) ; |
65 | 65 | ||
66 | if(err < 0) | 66 | if(err < 0) |
67 | return(-errno); | 67 | return -errno; |
68 | 68 | ||
69 | if(ubuf != NULL) | 69 | if(ubuf != NULL) |
70 | copy_stat(ubuf, &sbuf); | 70 | copy_stat(ubuf, &sbuf); |
71 | return(err); | 71 | return err; |
72 | } | 72 | } |
73 | 73 | ||
74 | int os_access(const char* file, int mode) | 74 | int os_access(const char* file, int mode) |
@@ -80,9 +80,9 @@ int os_access(const char* file, int mode) | |||
80 | 80 | ||
81 | err = access(file, amode); | 81 | err = access(file, amode); |
82 | if(err < 0) | 82 | if(err < 0) |
83 | return(-errno); | 83 | return -errno; |
84 | 84 | ||
85 | return(0); | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | void os_print_error(int error, const char* str) | 88 | void os_print_error(int error, const char* str) |
@@ -99,9 +99,9 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg) | |||
99 | 99 | ||
100 | err = ioctl(fd, cmd, arg); | 100 | err = ioctl(fd, cmd, arg); |
101 | if(err < 0) | 101 | if(err < 0) |
102 | return(-errno); | 102 | return -errno; |
103 | 103 | ||
104 | return(err); | 104 | return err; |
105 | } | 105 | } |
106 | 106 | ||
107 | int os_window_size(int fd, int *rows, int *cols) | 107 | int os_window_size(int fd, int *rows, int *cols) |
@@ -109,12 +109,12 @@ int os_window_size(int fd, int *rows, int *cols) | |||
109 | struct winsize size; | 109 | struct winsize size; |
110 | 110 | ||
111 | if(ioctl(fd, TIOCGWINSZ, &size) < 0) | 111 | if(ioctl(fd, TIOCGWINSZ, &size) < 0) |
112 | return(-errno); | 112 | return -errno; |
113 | 113 | ||
114 | *rows = size.ws_row; | 114 | *rows = size.ws_row; |
115 | *cols = size.ws_col; | 115 | *cols = size.ws_col; |
116 | 116 | ||
117 | return(0); | 117 | return 0; |
118 | } | 118 | } |
119 | 119 | ||
120 | int os_new_tty_pgrp(int fd, int pid) | 120 | int os_new_tty_pgrp(int fd, int pid) |
@@ -125,16 +125,16 @@ int os_new_tty_pgrp(int fd, int pid) | |||
125 | if(tcsetpgrp(fd, pid) < 0) | 125 | if(tcsetpgrp(fd, pid) < 0) |
126 | return -errno; | 126 | return -errno; |
127 | 127 | ||
128 | return(0); | 128 | return 0; |
129 | } | 129 | } |
130 | 130 | ||
131 | /* FIXME: ensure namebuf in os_get_if_name is big enough */ | 131 | /* FIXME: ensure namebuf in os_get_if_name is big enough */ |
132 | int os_get_ifname(int fd, char* namebuf) | 132 | int os_get_ifname(int fd, char* namebuf) |
133 | { | 133 | { |
134 | if(ioctl(fd, SIOCGIFNAME, namebuf) < 0) | 134 | if(ioctl(fd, SIOCGIFNAME, namebuf) < 0) |
135 | return(-errno); | 135 | return -errno; |
136 | 136 | ||
137 | return(0); | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | int os_set_slip(int fd) | 140 | int os_set_slip(int fd) |
@@ -149,7 +149,7 @@ int os_set_slip(int fd) | |||
149 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) | 149 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) |
150 | return -errno; | 150 | return -errno; |
151 | 151 | ||
152 | return(0); | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | int os_set_owner(int fd, int pid) | 155 | int os_set_owner(int fd, int pid) |
@@ -158,10 +158,10 @@ int os_set_owner(int fd, int pid) | |||
158 | int save_errno = errno; | 158 | int save_errno = errno; |
159 | 159 | ||
160 | if(fcntl(fd, F_GETOWN, 0) != pid) | 160 | if(fcntl(fd, F_GETOWN, 0) != pid) |
161 | return(-save_errno); | 161 | return -save_errno; |
162 | } | 162 | } |
163 | 163 | ||
164 | return(0); | 164 | return 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | /* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */ | 167 | /* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */ |
@@ -192,9 +192,9 @@ int os_mode_fd(int fd, int mode) | |||
192 | } while((err < 0) && (errno==EINTR)) ; | 192 | } while((err < 0) && (errno==EINTR)) ; |
193 | 193 | ||
194 | if(err < 0) | 194 | if(err < 0) |
195 | return(-errno); | 195 | return -errno; |
196 | 196 | ||
197 | return(0); | 197 | return 0; |
198 | } | 198 | } |
199 | 199 | ||
200 | int os_file_type(char *file) | 200 | int os_file_type(char *file) |
@@ -204,15 +204,21 @@ int os_file_type(char *file) | |||
204 | 204 | ||
205 | err = os_stat_file(file, &buf); | 205 | err = os_stat_file(file, &buf); |
206 | if(err < 0) | 206 | if(err < 0) |
207 | return(err); | 207 | return err; |
208 | 208 | ||
209 | if(S_ISDIR(buf.ust_mode)) return(OS_TYPE_DIR); | 209 | if(S_ISDIR(buf.ust_mode)) |
210 | else if(S_ISLNK(buf.ust_mode)) return(OS_TYPE_SYMLINK); | 210 | return OS_TYPE_DIR; |
211 | else if(S_ISCHR(buf.ust_mode)) return(OS_TYPE_CHARDEV); | 211 | else if(S_ISLNK(buf.ust_mode)) |
212 | else if(S_ISBLK(buf.ust_mode)) return(OS_TYPE_BLOCKDEV); | 212 | return OS_TYPE_SYMLINK; |
213 | else if(S_ISFIFO(buf.ust_mode)) return(OS_TYPE_FIFO); | 213 | else if(S_ISCHR(buf.ust_mode)) |
214 | else if(S_ISSOCK(buf.ust_mode)) return(OS_TYPE_SOCK); | 214 | return OS_TYPE_CHARDEV; |
215 | else return(OS_TYPE_FILE); | 215 | else if(S_ISBLK(buf.ust_mode)) |
216 | return OS_TYPE_BLOCKDEV; | ||
217 | else if(S_ISFIFO(buf.ust_mode)) | ||
218 | return OS_TYPE_FIFO; | ||
219 | else if(S_ISSOCK(buf.ust_mode)) | ||
220 | return OS_TYPE_SOCK; | ||
221 | else return OS_TYPE_FILE; | ||
216 | } | 222 | } |
217 | 223 | ||
218 | int os_file_mode(char *file, struct openflags *mode_out) | 224 | int os_file_mode(char *file, struct openflags *mode_out) |
@@ -302,8 +308,8 @@ int os_seek_file(int fd, __u64 offset) | |||
302 | 308 | ||
303 | actual = lseek64(fd, offset, SEEK_SET); | 309 | actual = lseek64(fd, offset, SEEK_SET); |
304 | if(actual != offset) | 310 | if(actual != offset) |
305 | return(-errno); | 311 | return -errno; |
306 | return(0); | 312 | return 0; |
307 | } | 313 | } |
308 | 314 | ||
309 | static int fault_buffer(void *start, int len, | 315 | static int fault_buffer(void *start, int len, |
@@ -314,13 +320,13 @@ static int fault_buffer(void *start, int len, | |||
314 | 320 | ||
315 | for(i = 0; i < len; i += page){ | 321 | for(i = 0; i < len; i += page){ |
316 | if((*copy_proc)(start + i, &c, sizeof(c))) | 322 | if((*copy_proc)(start + i, &c, sizeof(c))) |
317 | return(-EFAULT); | 323 | return -EFAULT; |
318 | } | 324 | } |
319 | if((len % page) != 0){ | 325 | if((len % page) != 0){ |
320 | if((*copy_proc)(start + len - 1, &c, sizeof(c))) | 326 | if((*copy_proc)(start + len - 1, &c, sizeof(c))) |
321 | return(-EFAULT); | 327 | return -EFAULT; |
322 | } | 328 | } |
323 | return(0); | 329 | return 0; |
324 | } | 330 | } |
325 | 331 | ||
326 | static int file_io(int fd, void *buf, int len, | 332 | static int file_io(int fd, void *buf, int len, |
@@ -334,26 +340,26 @@ static int file_io(int fd, void *buf, int len, | |||
334 | if((n < 0) && (errno == EFAULT)){ | 340 | if((n < 0) && (errno == EFAULT)){ |
335 | err = fault_buffer(buf, len, copy_user_proc); | 341 | err = fault_buffer(buf, len, copy_user_proc); |
336 | if(err) | 342 | if(err) |
337 | return(err); | 343 | return err; |
338 | n = (*io_proc)(fd, buf, len); | 344 | n = (*io_proc)(fd, buf, len); |
339 | } | 345 | } |
340 | } while((n < 0) && (errno == EINTR)); | 346 | } while((n < 0) && (errno == EINTR)); |
341 | 347 | ||
342 | if(n < 0) | 348 | if(n < 0) |
343 | return(-errno); | 349 | return -errno; |
344 | return(n); | 350 | return n; |
345 | } | 351 | } |
346 | 352 | ||
347 | int os_read_file(int fd, void *buf, int len) | 353 | int os_read_file(int fd, void *buf, int len) |
348 | { | 354 | { |
349 | return(file_io(fd, buf, len, (int (*)(int, void *, int)) read, | 355 | return file_io(fd, buf, len, (int (*)(int, void *, int)) read, |
350 | copy_from_user_proc)); | 356 | copy_from_user_proc); |
351 | } | 357 | } |
352 | 358 | ||
353 | int os_write_file(int fd, const void *buf, int len) | 359 | int os_write_file(int fd, const void *buf, int len) |
354 | { | 360 | { |
355 | return(file_io(fd, (void *) buf, len, | 361 | return file_io(fd, (void *) buf, len, |
356 | (int (*)(int, void *, int)) write, copy_to_user_proc)); | 362 | (int (*)(int, void *, int)) write, copy_to_user_proc); |
357 | } | 363 | } |
358 | 364 | ||
359 | int os_file_size(char *file, unsigned long long *size_out) | 365 | int os_file_size(char *file, unsigned long long *size_out) |
@@ -398,11 +404,11 @@ int os_file_modtime(char *file, unsigned long *modtime) | |||
398 | err = os_stat_file(file, &buf); | 404 | err = os_stat_file(file, &buf); |
399 | if(err < 0){ | 405 | if(err < 0){ |
400 | printk("Couldn't stat \"%s\" : err = %d\n", file, -err); | 406 | printk("Couldn't stat \"%s\" : err = %d\n", file, -err); |
401 | return(err); | 407 | return err; |
402 | } | 408 | } |
403 | 409 | ||
404 | *modtime = buf.ust_mtime; | 410 | *modtime = buf.ust_mtime; |
405 | return(0); | 411 | return 0; |
406 | } | 412 | } |
407 | 413 | ||
408 | int os_get_exec_close(int fd, int* close_on_exec) | 414 | int os_get_exec_close(int fd, int* close_on_exec) |
@@ -455,7 +461,7 @@ int os_pipe(int *fds, int stream, int close_on_exec) | |||
455 | if(err < 0) | 461 | if(err < 0) |
456 | goto error; | 462 | goto error; |
457 | 463 | ||
458 | return(0); | 464 | return 0; |
459 | 465 | ||
460 | error: | 466 | error: |
461 | printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err); | 467 | printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err); |
@@ -486,12 +492,12 @@ int os_set_fd_async(int fd, int owner) | |||
486 | (fcntl(fd, F_SETOWN, owner) < 0)){ | 492 | (fcntl(fd, F_SETOWN, owner) < 0)){ |
487 | err = -errno; | 493 | err = -errno; |
488 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " | 494 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " |
489 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, | 495 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, |
490 | owner, errno); | 496 | owner, errno); |
491 | return err; | 497 | return err; |
492 | } | 498 | } |
493 | 499 | ||
494 | return(0); | 500 | return 0; |
495 | } | 501 | } |
496 | 502 | ||
497 | int os_clear_fd_async(int fd) | 503 | int os_clear_fd_async(int fd) |
@@ -500,8 +506,8 @@ int os_clear_fd_async(int fd) | |||
500 | 506 | ||
501 | flags &= ~(O_ASYNC | O_NONBLOCK); | 507 | flags &= ~(O_ASYNC | O_NONBLOCK); |
502 | if(fcntl(fd, F_SETFL, flags) < 0) | 508 | if(fcntl(fd, F_SETFL, flags) < 0) |
503 | return(-errno); | 509 | return -errno; |
504 | return(0); | 510 | return 0; |
505 | } | 511 | } |
506 | 512 | ||
507 | int os_set_fd_block(int fd, int blocking) | 513 | int os_set_fd_block(int fd, int blocking) |
@@ -516,7 +522,7 @@ int os_set_fd_block(int fd, int blocking) | |||
516 | if(fcntl(fd, F_SETFL, flags) < 0) | 522 | if(fcntl(fd, F_SETFL, flags) < 0) |
517 | return -errno; | 523 | return -errno; |
518 | 524 | ||
519 | return(0); | 525 | return 0; |
520 | } | 526 | } |
521 | 527 | ||
522 | int os_accept_connection(int fd) | 528 | int os_accept_connection(int fd) |
@@ -524,9 +530,9 @@ int os_accept_connection(int fd) | |||
524 | int new; | 530 | int new; |
525 | 531 | ||
526 | new = accept(fd, NULL, 0); | 532 | new = accept(fd, NULL, 0); |
527 | if(new < 0) | 533 | if(new < 0) |
528 | return(-errno); | 534 | return -errno; |
529 | return(new); | 535 | return new; |
530 | } | 536 | } |
531 | 537 | ||
532 | #ifndef SHUT_RD | 538 | #ifndef SHUT_RD |
@@ -550,12 +556,12 @@ int os_shutdown_socket(int fd, int r, int w) | |||
550 | else if(w) what = SHUT_WR; | 556 | else if(w) what = SHUT_WR; |
551 | else { | 557 | else { |
552 | printk("os_shutdown_socket : neither r or w was set\n"); | 558 | printk("os_shutdown_socket : neither r or w was set\n"); |
553 | return(-EINVAL); | 559 | return -EINVAL; |
554 | } | 560 | } |
555 | err = shutdown(fd, what); | 561 | err = shutdown(fd, what); |
556 | if(err < 0) | 562 | if(err < 0) |
557 | return(-errno); | 563 | return -errno; |
558 | return(0); | 564 | return 0; |
559 | } | 565 | } |
560 | 566 | ||
561 | int os_rcv_fd(int fd, int *helper_pid_out) | 567 | int os_rcv_fd(int fd, int *helper_pid_out) |
@@ -578,7 +584,7 @@ int os_rcv_fd(int fd, int *helper_pid_out) | |||
578 | 584 | ||
579 | n = recvmsg(fd, &msg, 0); | 585 | n = recvmsg(fd, &msg, 0); |
580 | if(n < 0) | 586 | if(n < 0) |
581 | return(-errno); | 587 | return -errno; |
582 | 588 | ||
583 | else if(n != sizeof(iov.iov_len)) | 589 | else if(n != sizeof(iov.iov_len)) |
584 | *helper_pid_out = -1; | 590 | *helper_pid_out = -1; |
@@ -586,16 +592,16 @@ int os_rcv_fd(int fd, int *helper_pid_out) | |||
586 | cmsg = CMSG_FIRSTHDR(&msg); | 592 | cmsg = CMSG_FIRSTHDR(&msg); |
587 | if(cmsg == NULL){ | 593 | if(cmsg == NULL){ |
588 | printk("rcv_fd didn't receive anything, error = %d\n", errno); | 594 | printk("rcv_fd didn't receive anything, error = %d\n", errno); |
589 | return(-1); | 595 | return -1; |
590 | } | 596 | } |
591 | if((cmsg->cmsg_level != SOL_SOCKET) || | 597 | if((cmsg->cmsg_level != SOL_SOCKET) || |
592 | (cmsg->cmsg_type != SCM_RIGHTS)){ | 598 | (cmsg->cmsg_type != SCM_RIGHTS)){ |
593 | printk("rcv_fd didn't receive a descriptor\n"); | 599 | printk("rcv_fd didn't receive a descriptor\n"); |
594 | return(-1); | 600 | return -1; |
595 | } | 601 | } |
596 | 602 | ||
597 | new = ((int *) CMSG_DATA(cmsg))[0]; | 603 | new = ((int *) CMSG_DATA(cmsg))[0]; |
598 | return(new); | 604 | return new; |
599 | } | 605 | } |
600 | 606 | ||
601 | int os_create_unix_socket(char *file, int len, int close_on_exec) | 607 | int os_create_unix_socket(char *file, int len, int close_on_exec) |
@@ -623,7 +629,7 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
623 | if(err < 0) | 629 | if(err < 0) |
624 | return -errno; | 630 | return -errno; |
625 | 631 | ||
626 | return(sock); | 632 | return sock; |
627 | } | 633 | } |
628 | 634 | ||
629 | void os_flush_stdout(void) | 635 | void os_flush_stdout(void) |
@@ -654,16 +660,5 @@ int os_lock_file(int fd, int excl) | |||
654 | printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid); | 660 | printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid); |
655 | err = save; | 661 | err = save; |
656 | out: | 662 | out: |
657 | return(err); | 663 | return err; |
658 | } | 664 | } |
659 | |||
660 | /* | ||
661 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
662 | * Emacs will notice this stuff at the end of the file and automatically | ||
663 | * adjust the settings for this buffer only. This must remain at the end | ||
664 | * of the file. | ||
665 | * --------------------------------------------------------------------------- | ||
666 | * Local variables: | ||
667 | * c-file-style: "linux" | ||
668 | * End: | ||
669 | */ | ||