diff options
Diffstat (limited to 'arch/um/os-Linux/file.c')
-rw-r--r-- | arch/um/os-Linux/file.c | 82 |
1 files changed, 31 insertions, 51 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index fd45bb260907..f55773c819e6 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -119,15 +119,11 @@ int os_window_size(int fd, int *rows, int *cols) | |||
119 | 119 | ||
120 | int os_new_tty_pgrp(int fd, int pid) | 120 | int os_new_tty_pgrp(int fd, int pid) |
121 | { | 121 | { |
122 | if(ioctl(fd, TIOCSCTTY, 0) < 0){ | 122 | if(ioctl(fd, TIOCSCTTY, 0) < 0) |
123 | printk("TIOCSCTTY failed, errno = %d\n", errno); | 123 | return -errno; |
124 | return(-errno); | ||
125 | } | ||
126 | 124 | ||
127 | if(tcsetpgrp(fd, pid) < 0){ | 125 | if(tcsetpgrp(fd, pid) < 0) |
128 | printk("tcsetpgrp failed, errno = %d\n", errno); | 126 | return -errno; |
129 | return(-errno); | ||
130 | } | ||
131 | 127 | ||
132 | return(0); | 128 | return(0); |
133 | } | 129 | } |
@@ -146,18 +142,12 @@ int os_set_slip(int fd) | |||
146 | int disc, sencap; | 142 | int disc, sencap; |
147 | 143 | ||
148 | disc = N_SLIP; | 144 | disc = N_SLIP; |
149 | if(ioctl(fd, TIOCSETD, &disc) < 0){ | 145 | if(ioctl(fd, TIOCSETD, &disc) < 0) |
150 | printk("Failed to set slip line discipline - " | 146 | return -errno; |
151 | "errno = %d\n", errno); | ||
152 | return(-errno); | ||
153 | } | ||
154 | 147 | ||
155 | sencap = 0; | 148 | sencap = 0; |
156 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){ | 149 | if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) |
157 | printk("Failed to set slip encapsulation - " | 150 | return -errno; |
158 | "errno = %d\n", errno); | ||
159 | return(-errno); | ||
160 | } | ||
161 | 151 | ||
162 | return(0); | 152 | return(0); |
163 | } | 153 | } |
@@ -180,22 +170,15 @@ int os_sigio_async(int master, int slave) | |||
180 | int flags; | 170 | int flags; |
181 | 171 | ||
182 | flags = fcntl(master, F_GETFL); | 172 | flags = fcntl(master, F_GETFL); |
183 | if(flags < 0) { | 173 | if(flags < 0) |
184 | printk("fcntl F_GETFL failed, errno = %d\n", errno); | 174 | return errno; |
185 | return(-errno); | ||
186 | } | ||
187 | 175 | ||
188 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || | 176 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || |
189 | (fcntl(master, F_SETOWN, os_getpid()) < 0)){ | 177 | (fcntl(master, F_SETOWN, os_getpid()) < 0)) |
190 | printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", | 178 | return -errno; |
191 | errno); | ||
192 | return(-errno); | ||
193 | } | ||
194 | 179 | ||
195 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){ | 180 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)) |
196 | printk("fcntl F_SETFL failed, errno = %d\n", errno); | 181 | return -errno; |
197 | return(-errno); | ||
198 | } | ||
199 | 182 | ||
200 | return(0); | 183 | return(0); |
201 | } | 184 | } |
@@ -255,7 +238,7 @@ int os_file_mode(char *file, struct openflags *mode_out) | |||
255 | 238 | ||
256 | int os_open_file(char *file, struct openflags flags, int mode) | 239 | int os_open_file(char *file, struct openflags flags, int mode) |
257 | { | 240 | { |
258 | int fd, f = 0; | 241 | int fd, err, f = 0; |
259 | 242 | ||
260 | if(flags.r && flags.w) f = O_RDWR; | 243 | if(flags.r && flags.w) f = O_RDWR; |
261 | else if(flags.r) f = O_RDONLY; | 244 | else if(flags.r) f = O_RDONLY; |
@@ -272,8 +255,9 @@ int os_open_file(char *file, struct openflags flags, int mode) | |||
272 | return(-errno); | 255 | return(-errno); |
273 | 256 | ||
274 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ | 257 | if(flags.cl && fcntl(fd, F_SETFD, 1)){ |
258 | err = -errno; | ||
275 | os_close_file(fd); | 259 | os_close_file(fd); |
276 | return(-errno); | 260 | return err; |
277 | } | 261 | } |
278 | 262 | ||
279 | return(fd); | 263 | return(fd); |
@@ -383,9 +367,9 @@ int os_file_size(char *file, unsigned long long *size_out) | |||
383 | return(fd); | 367 | return(fd); |
384 | } | 368 | } |
385 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ | 369 | if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ |
370 | err = -errno; | ||
386 | printk("Couldn't get the block size of \"%s\", " | 371 | printk("Couldn't get the block size of \"%s\", " |
387 | "errno = %d\n", file, errno); | 372 | "errno = %d\n", file, errno); |
388 | err = -errno; | ||
389 | os_close_file(fd); | 373 | os_close_file(fd); |
390 | return(err); | 374 | return(err); |
391 | } | 375 | } |
@@ -473,11 +457,14 @@ int os_pipe(int *fds, int stream, int close_on_exec) | |||
473 | 457 | ||
474 | int os_set_fd_async(int fd, int owner) | 458 | int os_set_fd_async(int fd, int owner) |
475 | { | 459 | { |
460 | int err; | ||
461 | |||
476 | /* XXX This should do F_GETFL first */ | 462 | /* XXX This should do F_GETFL first */ |
477 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ | 463 | if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ |
464 | err = -errno; | ||
478 | printk("os_set_fd_async : failed to set O_ASYNC and " | 465 | printk("os_set_fd_async : failed to set O_ASYNC and " |
479 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); | 466 | "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); |
480 | return(-errno); | 467 | return err; |
481 | } | 468 | } |
482 | #ifdef notdef | 469 | #ifdef notdef |
483 | if(fcntl(fd, F_SETFD, 1) < 0){ | 470 | if(fcntl(fd, F_SETFD, 1) < 0){ |
@@ -488,10 +475,11 @@ int os_set_fd_async(int fd, int owner) | |||
488 | 475 | ||
489 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || | 476 | if((fcntl(fd, F_SETSIG, SIGIO) < 0) || |
490 | (fcntl(fd, F_SETOWN, owner) < 0)){ | 477 | (fcntl(fd, F_SETOWN, owner) < 0)){ |
478 | err = -errno; | ||
491 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " | 479 | printk("os_set_fd_async : Failed to fcntl F_SETOWN " |
492 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, | 480 | "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, |
493 | owner, errno); | 481 | owner, errno); |
494 | return(-errno); | 482 | return err; |
495 | } | 483 | } |
496 | 484 | ||
497 | return(0); | 485 | return(0); |
@@ -516,11 +504,9 @@ int os_set_fd_block(int fd, int blocking) | |||
516 | if(blocking) flags &= ~O_NONBLOCK; | 504 | if(blocking) flags &= ~O_NONBLOCK; |
517 | else flags |= O_NONBLOCK; | 505 | else flags |= O_NONBLOCK; |
518 | 506 | ||
519 | if(fcntl(fd, F_SETFL, flags) < 0){ | 507 | if(fcntl(fd, F_SETFL, flags) < 0) |
520 | printk("Failed to change blocking on fd # %d, errno = %d\n", | 508 | return -errno; |
521 | fd, errno); | 509 | |
522 | return(-errno); | ||
523 | } | ||
524 | return(0); | 510 | return(0); |
525 | } | 511 | } |
526 | 512 | ||
@@ -609,11 +595,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
609 | int sock, err; | 595 | int sock, err; |
610 | 596 | ||
611 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 597 | sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
612 | if (sock < 0){ | 598 | if(sock < 0) |
613 | printk("create_unix_socket - socket failed, errno = %d\n", | 599 | return -errno; |
614 | errno); | ||
615 | return(-errno); | ||
616 | } | ||
617 | 600 | ||
618 | if(close_on_exec) { | 601 | if(close_on_exec) { |
619 | err = os_set_exec_close(sock, 1); | 602 | err = os_set_exec_close(sock, 1); |
@@ -628,11 +611,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec) | |||
628 | snprintf(addr.sun_path, len, "%s", file); | 611 | snprintf(addr.sun_path, len, "%s", file); |
629 | 612 | ||
630 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); | 613 | err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); |
631 | if (err < 0){ | 614 | if(err < 0) |
632 | printk("create_listening_socket at '%s' - bind failed, " | 615 | return -errno; |
633 | "errno = %d\n", file, errno); | ||
634 | return(-errno); | ||
635 | } | ||
636 | 616 | ||
637 | return(sock); | 617 | return(sock); |
638 | } | 618 | } |