svr4_filio.c (83366) | svr4_filio.c (89306) |
---|---|
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 83366 2001-09-12 08:38:13Z julian $ | 28 * $FreeBSD: head/sys/compat/svr4/svr4_filio.c 89306 2002-01-13 11:58:06Z 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/signal.h> --- 55 unchanged lines hidden (view full) --- 92 93#if defined(READ_TEST) 94int 95svr4_sys_read(td, uap) 96 struct thread *td; 97 struct svr4_sys_read_args *uap; 98{ 99 struct read_args ra; | 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/signal.h> --- 55 unchanged lines hidden (view full) --- 92 93#if defined(READ_TEST) 94int 95svr4_sys_read(td, uap) 96 struct thread *td; 97 struct svr4_sys_read_args *uap; 98{ 99 struct read_args ra; |
100 struct filedesc *fdp = td->td_proc->p_fd; | |
101 struct file *fp; 102 struct socket *so = NULL; 103 int so_state; 104 sigset_t sigmask; 105 int rv; 106 107 SCARG(&ra, fd) = SCARG(uap, fd); 108 SCARG(&ra, buf) = SCARG(uap, buf); 109 SCARG(&ra, nbyte) = SCARG(uap, nbyte); 110 | 100 struct file *fp; 101 struct socket *so = NULL; 102 int so_state; 103 sigset_t sigmask; 104 int rv; 105 106 SCARG(&ra, fd) = SCARG(uap, fd); 107 SCARG(&ra, buf) = SCARG(uap, buf); 108 SCARG(&ra, nbyte) = SCARG(uap, nbyte); 109 |
111 if ((fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) { | 110 fp = ffind_hold(td, uap->fd); 111 if (fp == NULL) { |
112 DPRINTF(("Something fishy with the user-supplied file descriptor...\n")); 113 return EBADF; 114 } 115 116 if (fp->f_type == DTYPE_SOCKET) { 117 so = (struct socket *)fp->f_data; 118 DPRINTF(("fd %d is a socket\n", SCARG(uap, fd))); 119 if (so->so_state & SS_ASYNC) { --- 17 unchanged lines hidden (view full) --- 137 DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist)); 138 } 139 140#if defined(GROTTY_READ_HACK) 141 if (so) { /* We've already checked to see if this is a socket */ 142 so->so_state = so_state; 143 } 144#endif | 112 DPRINTF(("Something fishy with the user-supplied file descriptor...\n")); 113 return EBADF; 114 } 115 116 if (fp->f_type == DTYPE_SOCKET) { 117 so = (struct socket *)fp->f_data; 118 DPRINTF(("fd %d is a socket\n", SCARG(uap, fd))); 119 if (so->so_state & SS_ASYNC) { --- 17 unchanged lines hidden (view full) --- 137 DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist)); 138 } 139 140#if defined(GROTTY_READ_HACK) 141 if (so) { /* We've already checked to see if this is a socket */ 142 so->so_state = so_state; 143 } 144#endif |
145 fdrop(fp, td); |
|
145 146 return(rv); 147} 148#endif /* READ_TEST */ 149 150#if defined(BOGUS) 151int 152svr4_sys_write(td, uap) 153 struct thread *td; 154 struct svr4_sys_write_args *uap; 155{ 156 struct write_args wa; | 146 147 return(rv); 148} 149#endif /* READ_TEST */ 150 151#if defined(BOGUS) 152int 153svr4_sys_write(td, uap) 154 struct thread *td; 155 struct svr4_sys_write_args *uap; 156{ 157 struct write_args wa; |
157 struct filedesc *fdp; | |
158 struct file *fp; 159 int rv; 160 161 SCARG(&wa, fd) = SCARG(uap, fd); 162 SCARG(&wa, buf) = SCARG(uap, buf); 163 SCARG(&wa, nbyte) = SCARG(uap, nbyte); 164 165 rv = write(td, &wa); --- 15 unchanged lines hidden (view full) --- 181 caddr_t data; 182{ 183 int error; 184 int num; 185 struct filedesc *fdp = td->td_proc->p_fd; 186 187 *retval = 0; 188 | 158 struct file *fp; 159 int rv; 160 161 SCARG(&wa, fd) = SCARG(uap, fd); 162 SCARG(&wa, buf) = SCARG(uap, buf); 163 SCARG(&wa, nbyte) = SCARG(uap, nbyte); 164 165 rv = write(td, &wa); --- 15 unchanged lines hidden (view full) --- 181 caddr_t data; 182{ 183 int error; 184 int num; 185 struct filedesc *fdp = td->td_proc->p_fd; 186 187 *retval = 0; 188 |
189 FILEDESC_LOCK(fdp); |
|
189 switch (cmd) { 190 case SVR4_FIOCLEX: 191 fdp->fd_ofileflags[fd] |= UF_EXCLOSE; | 190 switch (cmd) { 191 case SVR4_FIOCLEX: 192 fdp->fd_ofileflags[fd] |= UF_EXCLOSE; |
193 FILEDESC_UNLOCK(fdp); |
|
192 return 0; 193 194 case SVR4_FIONCLEX: 195 fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE; | 194 return 0; 195 196 case SVR4_FIONCLEX: 197 fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE; |
198 FILEDESC_UNLOCK(fdp); |
|
196 return 0; 197 198 case SVR4_FIOGETOWN: 199 case SVR4_FIOSETOWN: 200 case SVR4_FIOASYNC: 201 case SVR4_FIONBIO: 202 case SVR4_FIONREAD: | 199 return 0; 200 201 case SVR4_FIOGETOWN: 202 case SVR4_FIOSETOWN: 203 case SVR4_FIOASYNC: 204 case SVR4_FIONBIO: 205 case SVR4_FIONREAD: |
206 FILEDESC_UNLOCK(fdp); |
|
203 if ((error = copyin(data, &num, sizeof(num))) != 0) 204 return error; 205 206 switch (cmd) { 207 case SVR4_FIOGETOWN: cmd = FIOGETOWN; break; 208 case SVR4_FIOSETOWN: cmd = FIOSETOWN; break; 209 case SVR4_FIOASYNC: cmd = FIOASYNC; break; 210 case SVR4_FIONBIO: cmd = FIONBIO; break; --- 6 unchanged lines hidden (view full) --- 217 error = fo_ioctl(fp, cmd, (caddr_t) &num, td); 218 219 if (error) 220 return error; 221 222 return copyout(&num, data, sizeof(num)); 223 224 default: | 207 if ((error = copyin(data, &num, sizeof(num))) != 0) 208 return error; 209 210 switch (cmd) { 211 case SVR4_FIOGETOWN: cmd = FIOGETOWN; break; 212 case SVR4_FIOSETOWN: cmd = FIOSETOWN; break; 213 case SVR4_FIOASYNC: cmd = FIOASYNC; break; 214 case SVR4_FIONBIO: cmd = FIONBIO; break; --- 6 unchanged lines hidden (view full) --- 221 error = fo_ioctl(fp, cmd, (caddr_t) &num, td); 222 223 if (error) 224 return error; 225 226 return copyout(&num, data, sizeof(num)); 227 228 default: |
229 FILEDESC_UNLOCK(fdp); |
|
225 DPRINTF(("Unknown svr4 filio %lx\n", cmd)); 226 return 0; /* ENOSYS really */ 227 } 228} | 230 DPRINTF(("Unknown svr4 filio %lx\n", cmd)); 231 return 0; /* ENOSYS really */ 232 } 233} |