svr4_filio.c (107839) | svr4_filio.c (107849) |
---|---|
1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/compat/svr4/svr4_filio.c 107839 2002-12-13 22:41:47Z alfred $ | 28 * $FreeBSD: head/sys/compat/svr4/svr4_filio.c 107849 2002-12-14 01:56:26Z alfred $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/proc.h> 33#include <sys/systm.h> 34#include <sys/file.h> 35#include <sys/filio.h> 36#include <sys/lock.h> --- 21 unchanged lines hidden (view full) --- 58 struct svr4_sys_poll_args *uap; 59{ 60 int error; 61 struct poll_args pa; 62 struct pollfd *pfd; 63 int idx = 0, cerr; 64 u_long siz; 65 | 29 */ 30 31#include <sys/param.h> 32#include <sys/proc.h> 33#include <sys/systm.h> 34#include <sys/file.h> 35#include <sys/filio.h> 36#include <sys/lock.h> --- 21 unchanged lines hidden (view full) --- 58 struct svr4_sys_poll_args *uap; 59{ 60 int error; 61 struct poll_args pa; 62 struct pollfd *pfd; 63 int idx = 0, cerr; 64 u_long siz; 65 |
66 SCARG(&pa, fds) = SCARG(uap, fds); 67 SCARG(&pa, nfds) = SCARG(uap, nfds); 68 SCARG(&pa, timeout) = SCARG(uap, timeout); | 66 pa.fds = uap->fds; 67 pa.nfds = uap->nfds; 68 pa.timeout = uap->timeout; |
69 | 69 |
70 siz = SCARG(uap, nfds) * sizeof(struct pollfd); | 70 siz = uap->nfds * sizeof(struct pollfd); |
71 pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK); 72 73 error = poll(td, (struct poll_args *)uap); 74 | 71 pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK); 72 73 error = poll(td, (struct poll_args *)uap); 74 |
75 if ((cerr = copyin(SCARG(uap, fds), pfd, siz)) != 0) { | 75 if ((cerr = copyin(uap->fds, pfd, siz)) != 0) { |
76 error = cerr; 77 goto done; 78 } 79 | 76 error = cerr; 77 goto done; 78 } 79 |
80 for (idx = 0; idx < SCARG(uap, nfds); idx++) { | 80 for (idx = 0; idx < uap->nfds; idx++) { |
81 /* POLLWRNORM already equals POLLOUT, so we don't worry about that */ 82 if (pfd[idx].revents & (POLLOUT | POLLWRNORM | POLLWRBAND)) 83 pfd[idx].revents |= (POLLOUT | POLLWRNORM | POLLWRBAND); 84 } | 81 /* POLLWRNORM already equals POLLOUT, so we don't worry about that */ 82 if (pfd[idx].revents & (POLLOUT | POLLWRNORM | POLLWRBAND)) 83 pfd[idx].revents |= (POLLOUT | POLLWRNORM | POLLWRBAND); 84 } |
85 if ((cerr = copyout(pfd, SCARG(uap, fds), siz)) != 0) { | 85 if ((cerr = copyout(pfd, uap->fds, siz)) != 0) { |
86 error = cerr; 87 goto done; /* yeah, I know it's the next line, but this way I won't 88 forget to update it if I add more code */ 89 } 90done: 91 free(pfd, M_TEMP); 92 return error; 93} --- 6 unchanged lines hidden (view full) --- 100{ 101 struct read_args ra; 102 struct file *fp; 103 struct socket *so = NULL; 104 int so_state; 105 sigset_t sigmask; 106 int rv; 107 | 86 error = cerr; 87 goto done; /* yeah, I know it's the next line, but this way I won't 88 forget to update it if I add more code */ 89 } 90done: 91 free(pfd, M_TEMP); 92 return error; 93} --- 6 unchanged lines hidden (view full) --- 100{ 101 struct read_args ra; 102 struct file *fp; 103 struct socket *so = NULL; 104 int so_state; 105 sigset_t sigmask; 106 int rv; 107 |
108 SCARG(&ra, fd) = SCARG(uap, fd); 109 SCARG(&ra, buf) = SCARG(uap, buf); 110 SCARG(&ra, nbyte) = SCARG(uap, nbyte); | 108 ra.fd = uap->fd; 109 ra.buf = uap->buf; 110 ra.nbyte = uap->nbyte; |
111 112 if (fget(td, uap->fd, &fp) != 0) { 113 DPRINTF(("Something fishy with the user-supplied file descriptor...\n")); 114 return EBADF; 115 } 116 117 if (fp->f_type == DTYPE_SOCKET) { 118 so = (struct socket *)fp->f_data; | 111 112 if (fget(td, uap->fd, &fp) != 0) { 113 DPRINTF(("Something fishy with the user-supplied file descriptor...\n")); 114 return EBADF; 115 } 116 117 if (fp->f_type == DTYPE_SOCKET) { 118 so = (struct socket *)fp->f_data; |
119 DPRINTF(("fd %d is a socket\n", SCARG(uap, fd))); | 119 DPRINTF(("fd %d is a socket\n", uap->fd)); |
120 if (so->so_state & SS_ASYNC) { | 120 if (so->so_state & SS_ASYNC) { |
121 DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd))); | 121 DPRINTF(("fd %d is an ASYNC socket!\n", uap->fd)); |
122 } 123 DPRINTF(("Here are its flags: 0x%x\n", so->so_state)); 124#if defined(GROTTY_READ_HACK) 125 so_state = so->so_state; 126 so->so_state &= ~SS_NBIO; 127#endif 128 } 129 130 rv = read(td, &ra); 131 132 DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n", | 122 } 123 DPRINTF(("Here are its flags: 0x%x\n", so->so_state)); 124#if defined(GROTTY_READ_HACK) 125 so_state = so->so_state; 126 so->so_state &= ~SS_NBIO; 127#endif 128 } 129 130 rv = read(td, &ra); 131 132 DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n", |
133 SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv)); | 133 uap->fd, uap->buf, uap->nbyte, rv)); |
134 if (rv == EAGAIN) { 135 DPRINTF(("sigmask = 0x%x\n", td->td_proc->p_sigmask)); 136 DPRINTF(("sigignore = 0x%x\n", td->td_proc->p_sigignore)); 137 DPRINTF(("sigcaught = 0x%x\n", td->td_proc->p_sigcatch)); 138 DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist)); 139 } 140 141#if defined(GROTTY_READ_HACK) --- 12 unchanged lines hidden (view full) --- 154svr4_sys_write(td, uap) 155 struct thread *td; 156 struct svr4_sys_write_args *uap; 157{ 158 struct write_args wa; 159 struct file *fp; 160 int rv; 161 | 134 if (rv == EAGAIN) { 135 DPRINTF(("sigmask = 0x%x\n", td->td_proc->p_sigmask)); 136 DPRINTF(("sigignore = 0x%x\n", td->td_proc->p_sigignore)); 137 DPRINTF(("sigcaught = 0x%x\n", td->td_proc->p_sigcatch)); 138 DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist)); 139 } 140 141#if defined(GROTTY_READ_HACK) --- 12 unchanged lines hidden (view full) --- 154svr4_sys_write(td, uap) 155 struct thread *td; 156 struct svr4_sys_write_args *uap; 157{ 158 struct write_args wa; 159 struct file *fp; 160 int rv; 161 |
162 SCARG(&wa, fd) = SCARG(uap, fd); 163 SCARG(&wa, buf) = SCARG(uap, buf); 164 SCARG(&wa, nbyte) = SCARG(uap, nbyte); | 162 wa.fd = uap->fd; 163 wa.buf = uap->buf; 164 wa.nbyte = uap->nbyte; |
165 166 rv = write(td, &wa); 167 168 DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n", | 165 166 rv = write(td, &wa); 167 168 DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n", |
169 SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv)); | 169 uap->fd, uap->buf, uap->nbyte, rv)); |
170 171 return(rv); 172} 173#endif /* BOGUS */ 174 175int 176svr4_fil_ioctl(fp, td, retval, fd, cmd, data) 177 struct file *fp; --- 57 unchanged lines hidden --- | 170 171 return(rv); 172} 173#endif /* BOGUS */ 174 175int 176svr4_fil_ioctl(fp, td, retval, fd, cmd, data) 177 struct file *fp; --- 57 unchanged lines hidden --- |