diff options
| -rw-r--r-- | arch/um/drivers/mcast_user.c | 11 | ||||
| -rw-r--r-- | arch/um/drivers/mconsole_user.c | 6 | ||||
| -rw-r--r-- | arch/um/drivers/pty.c | 3 | ||||
| -rw-r--r-- | arch/um/drivers/xterm.c | 6 | ||||
| -rw-r--r-- | arch/um/kernel/helper.c | 12 | ||||
| -rw-r--r-- | arch/um/kernel/user_util.c | 12 | ||||
| -rw-r--r-- | arch/um/os-Linux/aio.c | 5 | ||||
| -rw-r--r-- | arch/um/os-Linux/drivers/tuntap_user.c | 8 | ||||
| -rw-r--r-- | arch/um/os-Linux/file.c | 82 |
9 files changed, 67 insertions, 78 deletions
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 3fd69067a5f5..5db136e2651c 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
| @@ -54,7 +54,7 @@ static int mcast_open(void *data) | |||
| 54 | struct mcast_data *pri = data; | 54 | struct mcast_data *pri = data; |
| 55 | struct sockaddr_in *sin = pri->mcast_addr; | 55 | struct sockaddr_in *sin = pri->mcast_addr; |
| 56 | struct ip_mreq mreq; | 56 | struct ip_mreq mreq; |
| 57 | int fd = -EINVAL, yes = 1, err = -EINVAL;; | 57 | int fd, yes = 1, err = 0; |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) | 60 | if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) |
| @@ -65,13 +65,14 @@ static int mcast_open(void *data) | |||
| 65 | if (fd < 0){ | 65 | if (fd < 0){ |
| 66 | printk("mcast_open : data socket failed, errno = %d\n", | 66 | printk("mcast_open : data socket failed, errno = %d\n", |
| 67 | errno); | 67 | errno); |
| 68 | fd = -errno; | 68 | err = -errno; |
| 69 | goto out; | 69 | goto out; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { | 72 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { |
| 73 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", | 73 | printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", |
| 74 | errno); | 74 | errno); |
| 75 | err = -errno; | ||
| 75 | goto out_close; | 76 | goto out_close; |
| 76 | } | 77 | } |
| 77 | 78 | ||
| @@ -80,6 +81,7 @@ static int mcast_open(void *data) | |||
| 80 | sizeof(pri->ttl)) < 0) { | 81 | sizeof(pri->ttl)) < 0) { |
| 81 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", | 82 | printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", |
| 82 | errno); | 83 | errno); |
| 84 | err = -errno; | ||
| 83 | goto out_close; | 85 | goto out_close; |
| 84 | } | 86 | } |
| 85 | 87 | ||
| @@ -87,12 +89,14 @@ static int mcast_open(void *data) | |||
| 87 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { | 89 | if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { |
| 88 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", | 90 | printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", |
| 89 | errno); | 91 | errno); |
| 92 | err = -errno; | ||
| 90 | goto out_close; | 93 | goto out_close; |
| 91 | } | 94 | } |
| 92 | 95 | ||
| 93 | /* bind socket to mcast address */ | 96 | /* bind socket to mcast address */ |
| 94 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { | 97 | if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { |
| 95 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 98 | printk("mcast_open : data bind failed, errno = %d\n", errno); |
| 99 | err = -errno; | ||
| 96 | goto out_close; | 100 | goto out_close; |
| 97 | } | 101 | } |
| 98 | 102 | ||
| @@ -107,14 +111,15 @@ static int mcast_open(void *data) | |||
| 107 | "interface on the host.\n"); | 111 | "interface on the host.\n"); |
| 108 | printk("eth0 should be configured in order to use the " | 112 | printk("eth0 should be configured in order to use the " |
| 109 | "multicast transport.\n"); | 113 | "multicast transport.\n"); |
| 114 | err = -errno; | ||
| 110 | goto out_close; | 115 | goto out_close; |
| 111 | } | 116 | } |
| 112 | 117 | ||
| 113 | out: | ||
| 114 | return fd; | 118 | return fd; |
| 115 | 119 | ||
| 116 | out_close: | 120 | out_close: |
| 117 | os_close_file(fd); | 121 | os_close_file(fd); |
| 122 | out: | ||
| 118 | return err; | 123 | return err; |
| 119 | } | 124 | } |
| 120 | 125 | ||
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index a5b8aeade1c5..310c1f823f26 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c | |||
| @@ -173,9 +173,9 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
| 173 | if(notify_sock < 0){ | 173 | if(notify_sock < 0){ |
| 174 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); | 174 | notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 175 | if(notify_sock < 0){ | 175 | if(notify_sock < 0){ |
| 176 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
| 177 | errno); | ||
| 178 | err = -errno; | 176 | err = -errno; |
| 177 | printk("mconsole_notify - socket failed, errno = %d\n", | ||
| 178 | err); | ||
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | unlock_notify(); | 181 | unlock_notify(); |
| @@ -198,8 +198,8 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len) | |||
| 198 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, | 198 | n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, |
| 199 | sizeof(target)); | 199 | sizeof(target)); |
| 200 | if(n < 0){ | 200 | if(n < 0){ |
| 201 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
| 202 | err = -errno; | 201 | err = -errno; |
| 202 | printk("mconsole_notify - sendto failed, errno = %d\n", errno); | ||
| 203 | } | 203 | } |
| 204 | return(err); | 204 | return(err); |
| 205 | } | 205 | } |
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c index ed84d01df6cc..0306a1b215b7 100644 --- a/arch/um/drivers/pty.c +++ b/arch/um/drivers/pty.c | |||
| @@ -43,8 +43,9 @@ static int pts_open(int input, int output, int primary, void *d, | |||
| 43 | 43 | ||
| 44 | fd = get_pty(); | 44 | fd = get_pty(); |
| 45 | if(fd < 0){ | 45 | if(fd < 0){ |
| 46 | err = -errno; | ||
| 46 | printk("open_pts : Failed to open pts\n"); | 47 | printk("open_pts : Failed to open pts\n"); |
| 47 | return(-errno); | 48 | return err; |
| 48 | } | 49 | } |
| 49 | if(data->raw){ | 50 | if(data->raw){ |
| 50 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | 51 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); |
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 93dc1911363f..90e0e5ff451e 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
| @@ -110,13 +110,15 @@ int xterm_open(int input, int output, int primary, void *d, | |||
| 110 | 110 | ||
| 111 | fd = mkstemp(file); | 111 | fd = mkstemp(file); |
| 112 | if(fd < 0){ | 112 | if(fd < 0){ |
| 113 | err = -errno; | ||
| 113 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); | 114 | printk("xterm_open : mkstemp failed, errno = %d\n", errno); |
| 114 | return(-errno); | 115 | return err; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | if(unlink(file)){ | 118 | if(unlink(file)){ |
| 119 | err = -errno; | ||
| 118 | printk("xterm_open : unlink failed, errno = %d\n", errno); | 120 | printk("xterm_open : unlink failed, errno = %d\n", errno); |
| 119 | return(-errno); | 121 | return err; |
| 120 | } | 122 | } |
| 121 | os_close_file(fd); | 123 | os_close_file(fd); |
| 122 | 124 | ||
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c index f83e1e8e2392..33fb0bd3b11a 100644 --- a/arch/um/kernel/helper.c +++ b/arch/um/kernel/helper.c | |||
| @@ -85,8 +85,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
| 85 | data.fd = fds[1]; | 85 | data.fd = fds[1]; |
| 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); | 86 | pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); |
| 87 | if(pid < 0){ | 87 | if(pid < 0){ |
| 88 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
| 89 | ret = -errno; | 88 | ret = -errno; |
| 89 | printk("run_helper : clone failed, errno = %d\n", errno); | ||
| 90 | goto out_close; | 90 | goto out_close; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| @@ -122,7 +122,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
| 122 | unsigned long *stack_out, int stack_order) | 122 | unsigned long *stack_out, int stack_order) |
| 123 | { | 123 | { |
| 124 | unsigned long stack, sp; | 124 | unsigned long stack, sp; |
| 125 | int pid, status; | 125 | int pid, status, err; |
| 126 | 126 | ||
| 127 | stack = alloc_stack(stack_order, um_in_interrupt()); | 127 | stack = alloc_stack(stack_order, um_in_interrupt()); |
| 128 | if(stack == 0) return(-ENOMEM); | 128 | if(stack == 0) return(-ENOMEM); |
| @@ -130,16 +130,18 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
| 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); | 130 | sp = stack + (page_size() << stack_order) - sizeof(void *); |
| 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); | 131 | pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); |
| 132 | if(pid < 0){ | 132 | if(pid < 0){ |
| 133 | err = -errno; | ||
| 133 | printk("run_helper_thread : clone failed, errno = %d\n", | 134 | printk("run_helper_thread : clone failed, errno = %d\n", |
| 134 | errno); | 135 | errno); |
| 135 | return(-errno); | 136 | return err; |
| 136 | } | 137 | } |
| 137 | if(stack_out == NULL){ | 138 | if(stack_out == NULL){ |
| 138 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); | 139 | CATCH_EINTR(pid = waitpid(pid, &status, 0)); |
| 139 | if(pid < 0){ | 140 | if(pid < 0){ |
| 141 | err = -errno; | ||
| 140 | printk("run_helper_thread - wait failed, errno = %d\n", | 142 | printk("run_helper_thread - wait failed, errno = %d\n", |
| 141 | errno); | 143 | errno); |
| 142 | pid = -errno; | 144 | pid = err; |
| 143 | } | 145 | } |
| 144 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) | 146 | if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) |
| 145 | printk("run_helper_thread - thread returned status " | 147 | printk("run_helper_thread - thread returned status " |
| @@ -156,8 +158,8 @@ int helper_wait(int pid) | |||
| 156 | 158 | ||
| 157 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); | 159 | CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); |
| 158 | if(ret < 0){ | 160 | if(ret < 0){ |
| 161 | ret = -errno; | ||
| 159 | printk("helper_wait : waitpid failed, errno = %d\n", errno); | 162 | printk("helper_wait : waitpid failed, errno = %d\n", errno); |
| 160 | return(-errno); | ||
| 161 | } | 163 | } |
| 162 | return(ret); | 164 | return(ret); |
| 163 | } | 165 | } |
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c index 954ff67cc8b3..a25f3ea11fd7 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/kernel/user_util.c | |||
| @@ -109,18 +109,14 @@ int raw(int fd) | |||
| 109 | int err; | 109 | int err; |
| 110 | 110 | ||
| 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); | 111 | CATCH_EINTR(err = tcgetattr(fd, &tt)); |
| 112 | if (err < 0) { | 112 | if(err < 0) |
| 113 | printk("tcgetattr failed, errno = %d\n", errno); | 113 | return -errno; |
| 114 | return(-errno); | ||
| 115 | } | ||
| 116 | 114 | ||
| 117 | cfmakeraw(&tt); | 115 | cfmakeraw(&tt); |
| 118 | 116 | ||
| 119 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | 117 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); |
| 120 | if (err < 0) { | 118 | if(err < 0) |
| 121 | printk("tcsetattr failed, errno = %d\n", errno); | 119 | return -errno; |
| 122 | return(-errno); | ||
| 123 | } | ||
| 124 | 120 | ||
| 125 | /* XXX tcsetattr could have applied only some changes | 121 | /* XXX tcsetattr could have applied only some changes |
| 126 | * (and cfmakeraw() is a set of changes) */ | 122 | * (and cfmakeraw() is a set of changes) */ |
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index 182905be869e..e942beb4e108 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c | |||
| @@ -313,15 +313,16 @@ static int init_aio_26(void) | |||
| 313 | int err; | 313 | int err; |
| 314 | 314 | ||
| 315 | if(io_setup(256, &ctx)){ | 315 | if(io_setup(256, &ctx)){ |
| 316 | err = -errno; | ||
| 316 | printk("aio_thread failed to initialize context, err = %d\n", | 317 | printk("aio_thread failed to initialize context, err = %d\n", |
| 317 | errno); | 318 | errno); |
| 318 | return -errno; | 319 | return err; |
| 319 | } | 320 | } |
| 320 | 321 | ||
| 321 | err = run_helper_thread(aio_thread, NULL, | 322 | err = run_helper_thread(aio_thread, NULL, |
| 322 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); | 323 | CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); |
| 323 | if(err < 0) | 324 | if(err < 0) |
| 324 | return -errno; | 325 | return err; |
| 325 | 326 | ||
| 326 | aio_pid = err; | 327 | aio_pid = err; |
| 327 | 328 | ||
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 4b83c6c3f48d..4ba9b17adf13 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c | |||
| @@ -75,7 +75,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
| 75 | struct msghdr msg; | 75 | struct msghdr msg; |
| 76 | struct cmsghdr *cmsg; | 76 | struct cmsghdr *cmsg; |
| 77 | struct iovec iov; | 77 | struct iovec iov; |
| 78 | int pid, n; | 78 | int pid, n, err; |
| 79 | 79 | ||
| 80 | sprintf(version_buf, "%d", UML_NET_VERSION); | 80 | sprintf(version_buf, "%d", UML_NET_VERSION); |
| 81 | 81 | ||
| @@ -105,9 +105,10 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, | |||
| 105 | n = recvmsg(me, &msg, 0); | 105 | n = recvmsg(me, &msg, 0); |
| 106 | *used_out = n; | 106 | *used_out = n; |
| 107 | if(n < 0){ | 107 | if(n < 0){ |
| 108 | err = -errno; | ||
| 108 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", | 109 | printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", |
| 109 | errno); | 110 | errno); |
| 110 | return(-errno); | 111 | return err; |
| 111 | } | 112 | } |
| 112 | CATCH_EINTR(waitpid(pid, NULL, 0)); | 113 | CATCH_EINTR(waitpid(pid, NULL, 0)); |
| 113 | 114 | ||
| @@ -147,9 +148,10 @@ static int tuntap_open(void *data) | |||
| 147 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; | 148 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
| 148 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); | 149 | strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); |
| 149 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ | 150 | if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ |
| 151 | err = -errno; | ||
| 150 | printk("TUNSETIFF failed, errno = %d\n", errno); | 152 | printk("TUNSETIFF failed, errno = %d\n", errno); |
| 151 | os_close_file(pri->fd); | 153 | os_close_file(pri->fd); |
| 152 | return(-errno); | 154 | return err; |
| 153 | } | 155 | } |
| 154 | } | 156 | } |
| 155 | else { | 157 | else { |
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 | } |
