diff options
| author | ad <ad@NetBSD.org> | 2008-03-21 21:54:58 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2008-03-21 21:54:58 +0000 |
| commit | a9ca7a3734751f09c9dc4e1f645cd528fd403e8c (patch) | |
| tree | ff26aca94a1a611e6be984fcff411406b466507f /sys/compat/linux | |
| parent | c743ad71591a886accf44c9e93c1ff677b45a41f (diff) | |
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
Diffstat (limited to 'sys/compat/linux')
| -rw-r--r-- | sys/compat/linux/arch/i386/linux_machdep.c | 33 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_blkio.c | 22 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_cdrom.c | 65 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_fcntl.h | 6 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_fdio.c | 18 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_file.c | 56 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_file64.c | 16 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_hdio.c | 25 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_ioctl.c | 13 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_misc.c | 10 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_mtio.c | 17 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_sg.c | 19 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_socket.c | 64 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_termios.c | 41 |
14 files changed, 174 insertions, 231 deletions
diff --git a/sys/compat/linux/arch/i386/linux_machdep.c b/sys/compat/linux/arch/i386/linux_machdep.c index 5848b9e4ffa..a0e1902343f 100644 --- a/sys/compat/linux/arch/i386/linux_machdep.c +++ b/sys/compat/linux/arch/i386/linux_machdep.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_machdep.c,v 1.133 2007/12/20 23:02:52 dsl Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.134 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 2000, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.133 2007/12/20 23:02:52 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.134 2008/03/21 21:54:58 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_vm86.h" @@ -861,30 +861,24 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist struct linux_hd_geometry hdg; struct linux_hd_big_geometry hdg_big; struct biosdisk_info *bip; - struct filedesc *fdp; - struct file *fp; + file_t *fp; int fd; struct disklabel label, *labp; struct partinfo partp; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(struct file *, u_long, void *); u_long start, biostotal, realtotal; u_char heads, sectors; u_int cylinders; struct ioctl_pt pt; - struct proc *p = l->l_proc; fd = SCARG(uap, fd); SCARG(&bia, fd) = fd; SCARG(&bia, data) = SCARG(uap, data); com = SCARG(uap, com); - fdp = p->p_fd; - - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(fd)) == NULL) return (EBADF); - FILE_USE(fp); - switch (com) { #if (NWSDISPLAY > 0) case LINUX_KDGKBMODE: @@ -925,7 +919,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist com = VT_OPENQRY; break; case LINUX_VT_GETMODE: - error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt, l); + error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt); if (error != 0) goto out; lvt.relsig = native_to_linux_signo[lvt.relsig]; @@ -940,7 +934,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist lvt.relsig = linux_to_native_signo[lvt.relsig]; lvt.acqsig = linux_to_native_signo[lvt.acqsig]; lvt.frsig = linux_to_native_signo[lvt.frsig]; - error = fp->f_ops->fo_ioctl(fp, VT_SETMODE, &lvt, l); + error = fp->f_ops->fo_ioctl(fp, VT_SETMODE, &lvt); goto out; case LINUX_VT_DISALLOCATE: /* XXX should use WSDISPLAYIO_DELSCREEN */ @@ -995,10 +989,10 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist * the real geometry) if not found, by returning an * error. See common/linux_hdio.c */ - bip = fd2biosinfo(p, fp); + bip = fd2biosinfo(curproc, fp); ioctlf = fp->f_ops->fo_ioctl; - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l); - error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l); + error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label); + error1 = ioctlf(fp, DIOCGPART, (void *)&partp); if (error != 0 && error1 != 0) { error = error1; goto out; @@ -1048,7 +1042,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist ioctlf = fp->f_ops->fo_ioctl; pt.com = SCARG(uap, com); pt.data = SCARG(uap, data); - error = ioctlf(fp, PTIOCLINUX, (void *)&pt, l); + error = ioctlf(fp, PTIOCLINUX, &pt); if (error == EJUSTRETURN) { retval[0] = (register_t)pt.data; error = 0; @@ -1061,10 +1055,9 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist goto out; } SCARG(&bia, com) = com; - /* XXX NJWLWP */ error = sys_ioctl(curlwp, &bia, retval); out: - FILE_UNUSE(fp ,l); + fd_putfile(fd); return error; } diff --git a/sys/compat/linux/common/linux_blkio.c b/sys/compat/linux/common/linux_blkio.c index dc0c4b3bceb..c6b512f47e2 100644 --- a/sys/compat/linux/common/linux_blkio.c +++ b/sys/compat/linux/common/linux_blkio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_blkio.c,v 1.16 2007/12/20 23:02:53 dsl Exp $ */ +/* $NetBSD: linux_blkio.c,v 1.17 2008/03/21 21:54:58 ad Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_blkio.c,v 1.16 2007/12/20 23:02:53 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_blkio.c,v 1.17 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -63,21 +63,17 @@ int linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) { - struct proc *p = l->l_proc; u_long com; long size; int error; - struct filedesc *fdp; - struct file *fp; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + file_t *fp; + int (*ioctlf)(file_t *, u_long, void *); struct partinfo partp; struct disklabel label; - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); error = 0; ioctlf = fp->f_ops->fo_ioctl; com = SCARG(uap, com); @@ -89,9 +85,9 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap, * fails, it may be a disk without label; try to get * the default label and compute the size from it. */ - error = ioctlf(fp, DIOCGPART, (void *)&partp, l); + error = ioctlf(fp, DIOCGPART, &partp); if (error != 0) { - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l); + error = ioctlf(fp, DIOCGDEFLABEL, &label); if (error != 0) break; size = label.d_nsectors * label.d_ntracks * @@ -101,7 +97,7 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = copyout(&size, SCARG(uap, data), sizeof size); break; case LINUX_BLKSECTGET: - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l); + error = ioctlf(fp, DIOCGDEFLABEL, &label); if (error != 0) break; error = copyout(&label.d_secsize, SCARG(uap, data), @@ -122,7 +118,7 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = ENOTTY; } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } diff --git a/sys/compat/linux/common/linux_cdrom.c b/sys/compat/linux/common/linux_cdrom.c index c08329bf41c..0e92e684370 100644 --- a/sys/compat/linux/common/linux_cdrom.c +++ b/sys/compat/linux/common/linux_cdrom.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_cdrom.c,v 1.25 2007/12/20 23:02:53 dsl Exp $ */ +/* $NetBSD: linux_cdrom.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */ /* - * Copyright (c) 1997 The NetBSD Foundation, Inc. + * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.25 2007/12/20 23:02:53 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.26 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -102,9 +102,8 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe } */ int error, idata; u_long com, ncom; - struct file *fp; - struct filedesc *fdp; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + file_t *fp; + int (*ioctlf)(file_t *, u_long, void *); union { struct linux_cdrom_blk ll_blk; @@ -149,14 +148,10 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe #define t_vol u2->tt_vol struct cd_toc_entry *entry; - struct proc *p = l->l_proc; - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); - com = SCARG(uap, com); ioctlf = fp->f_ops->fo_ioctl; retval[0] = error = 0; @@ -177,7 +172,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_msf.end_s = l_msf.cdmsf_sec1; t_msf.end_f = l_msf.cdmsf_frame1; - error = ioctlf(fp, CDIOCPLAYMSF, (void *)&t_msf, l); + error = ioctlf(fp, CDIOCPLAYMSF, &t_msf); break; case LINUX_CDROMPLAYTRKIND: @@ -190,11 +185,11 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_track.end_track = l_ti.cdti_trk1; t_track.end_index = l_ti.cdti_ind1; - error = ioctlf(fp, CDIOCPLAYTRACKS, (void *)&t_track, l); + error = ioctlf(fp, CDIOCPLAYTRACKS, &t_track); break; case LINUX_CDROMREADTOCHDR: - error = ioctlf(fp, CDIOREADTOCHEADER, (void *)&t_header, l); + error = ioctlf(fp, CDIOREADTOCHEADER, &t_header); if (error) break; @@ -215,7 +210,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_toc_entry.req.data_len = sizeof *entry; t_toc_entry.req.data = NULL; - error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry, l); + error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry); if (error) break; @@ -242,11 +237,11 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_vol.vol[2] = l_volctrl.channel2; t_vol.vol[3] = l_volctrl.channel3; - error = ioctlf(fp, CDIOCSETVOL, (void *)&t_vol, l); + error = ioctlf(fp, CDIOCSETVOL, &t_vol); break; case LINUX_CDROMVOLREAD: - error = ioctlf(fp, CDIOCGETVOL, (void *)&t_vol, l); + error = ioctlf(fp, CDIOCGETVOL, &t_vol); if (error) break; @@ -271,7 +266,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe DPRINTF(("linux_ioctl: CDROMSUBCHNL %d %d\n", l_subchnl.cdsc_format, l_subchnl.cdsc_trk)); - error = ioctlf(fp, CDIOCREADSUBCHANNEL_BUF, &t_subchannel, l); + error = ioctlf(fp, CDIOCREADSUBCHANNEL_BUF, &t_subchannel); if (error) break; @@ -313,7 +308,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_blocks.blk = l_blk.from; t_blocks.len = l_blk.len; - error = ioctlf(fp, CDIOCPLAYBLOCKS, (void *)&t_blocks, l); + error = ioctlf(fp, CDIOCPLAYBLOCKS, &t_blocks); break; case LINUX_CDROMEJECT_SW: @@ -325,31 +320,31 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe ncom = CDIOCALLOW; else ncom = CDIOCPREVENT; - error = ioctlf(fp, ncom, NULL, l); + error = ioctlf(fp, ncom, NULL); break; case LINUX_CDROMPAUSE: - error = ioctlf(fp, CDIOCPAUSE, NULL, l); + error = ioctlf(fp, CDIOCPAUSE, NULL); break; case LINUX_CDROMRESUME: - error = ioctlf(fp, CDIOCRESUME, NULL, l); + error = ioctlf(fp, CDIOCRESUME, NULL); break; case LINUX_CDROMSTOP: - error = ioctlf(fp, CDIOCSTOP, NULL, l); + error = ioctlf(fp, CDIOCSTOP, NULL); break; case LINUX_CDROMSTART: - error = ioctlf(fp, CDIOCSTART, NULL, l); + error = ioctlf(fp, CDIOCSTART, NULL); break; case LINUX_CDROMEJECT: - error = ioctlf(fp, CDIOCEJECT, NULL, l); + error = ioctlf(fp, CDIOCEJECT, NULL); break; case LINUX_CDROMRESET: - error = ioctlf(fp, CDIOCRESET, NULL, l); + error = ioctlf(fp, CDIOCRESET, NULL); break; case LINUX_CDROMMULTISESSION: @@ -357,7 +352,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe if (error) break; - error = ioctlf(fp, CDIOREADTOCHEADER, (void *)&t_header, l); + error = ioctlf(fp, CDIOREADTOCHEADER, &t_header); if (error) break; @@ -366,7 +361,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe t_toc_entry.req.data_len = sizeof t_toc_entry.entry; t_toc_entry.req.data = NULL; - error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry, l); + error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry); if (error) break; @@ -383,12 +378,12 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe break; case LINUX_CDROMCLOSETRAY: - error = ioctlf(fp, CDIOCCLOSE, NULL, l); + error = ioctlf(fp, CDIOCCLOSE, NULL); break; case LINUX_CDROM_LOCKDOOR: ncom = SCARG(uap, data) != 0 ? CDIOCPREVENT : CDIOCALLOW; - error = ioctlf(fp, ncom, NULL, l); + error = ioctlf(fp, ncom, NULL); break; case LINUX_CDROM_SET_OPTIONS: @@ -398,7 +393,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe case LINUX_CDROM_DEBUG: ncom = SCARG(uap, data) != 0 ? CDIOCSETDEBUG : CDIOCCLRDEBUG; - error = ioctlf(fp, ncom, NULL, l); + error = ioctlf(fp, ncom, NULL); break; case LINUX_CDROM_SELECT_SPEED: @@ -415,7 +410,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe error = copyin(SCARG(uap, data), &ds, sizeof ds); if (error) break; - error = ioctlf(fp, DVD_READ_STRUCT, (void *)&ds, l); + error = ioctlf(fp, DVD_READ_STRUCT, &ds); if (error) break; error = copyout(&ds, SCARG(uap, data), sizeof ds); @@ -425,7 +420,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe error = copyin(SCARG(uap, data), &ds, sizeof ds); if (error) break; - error = ioctlf(fp, DVD_WRITE_STRUCT, (void *)&ds, l); + error = ioctlf(fp, DVD_WRITE_STRUCT, &ds); if (error) break; error = copyout(&ds, SCARG(uap, data), sizeof ds); @@ -435,7 +430,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe error = copyin(SCARG(uap, data), &dai, sizeof dai); if (error) break; - error = ioctlf(fp, DVD_AUTH, (void *)&dai, l); + error = ioctlf(fp, DVD_AUTH, &dai); if (error) break; error = copyout(&dai, SCARG(uap, data), sizeof dai); @@ -447,7 +442,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe error = EINVAL; } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); free(u1, M_TEMP); free(u2, M_TEMP); return error; diff --git a/sys/compat/linux/common/linux_fcntl.h b/sys/compat/linux/common/linux_fcntl.h index ad95b62b05c..6f7101c351d 100644 --- a/sys/compat/linux/common/linux_fcntl.h +++ b/sys/compat/linux/common/linux_fcntl.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fcntl.h,v 1.12 2008/02/02 21:54:01 dsl Exp $ */ +/* $NetBSD: linux_fcntl.h,v 1.13 2008/03/21 21:54:58 ad Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp, const struct LINUX##_##FLOCK *lfp) \ if ((fl_error = copyin(arg, &lfl, sizeof lfl))) \ return fl_error; \ LINUX##_to_bsd_##FLOCK(&bfl, &lfl); \ - fl_error = do_fcntl_lock(l, fd, F_GETLK, &bfl); \ + fl_error = do_fcntl_lock(fd, F_GETLK, &bfl); \ if (fl_error) \ return fl_error; \ bsd_to_##LINUX##_##FLOCK(&lfl, &bfl); \ @@ -147,7 +147,7 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp, const struct LINUX##_##FLOCK *lfp) \ if ((fl_error = copyin(arg, &lfl, sizeof lfl))) \ return fl_error; \ LINUX##_to_bsd_##FLOCK(&bfl, &lfl); \ - return do_fcntl_lock(l, fd, cmd == setlk ? F_SETLK : F_SETLKW, &bfl); \ + return do_fcntl_lock(fd, cmd == setlk ? F_SETLK : F_SETLKW, &bfl); \ } while (0) diff --git a/sys/compat/linux/common/linux_fdio.c b/sys/compat/linux/common/linux_fdio.c index 0ab183f8724..bf9b5be0590 100644 --- a/sys/compat/linux/common/linux_fdio.c +++ b/sys/compat/linux/common/linux_fdio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fdio.c,v 1.12 2007/12/20 23:02:54 dsl Exp $ */ +/* $NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */ /* * Copyright (c) 2000 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.12 2007/12/20 23:02:54 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -67,10 +67,9 @@ int linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) { - struct filedesc *fdp; - struct file *fp; + file_t *fp; int error; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(file_t *, u_long, void *); u_long com; struct fdformat_parms fparams; struct linux_floppy_struct lflop; @@ -78,12 +77,9 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, com = (u_long)SCARG(uap, data); - fdp = l->l_proc->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); - com = SCARG(uap, com); ioctlf = fp->f_ops->fo_ioctl; @@ -108,7 +104,7 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = copyout(&ldrive, SCARG(uap, data), sizeof ldrive); break; case LINUX_FDGETPRM: - error = ioctlf(fp, FDIOCGETFORMAT, (void *)&fparams, l); + error = ioctlf(fp, FDIOCGETFORMAT, &fparams); if (error != 0) break; lflop.size = fparams.ncyl * fparams.nspt * fparams.ntrk; @@ -169,7 +165,7 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = EINVAL; } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return 0; } diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c index 365ebca6bbf..003e8d000e6 100644 --- a/sys/compat/linux/common/linux_file.c +++ b/sys/compat/linux/common/linux_file.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_file.c,v 1.92 2008/02/02 21:54:01 dsl Exp $ */ +/* $NetBSD: linux_file.c,v 1.93 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.92 2008/02/02 21:54:01 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.93 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -191,19 +191,16 @@ linux_sys_open(struct lwp *l, const struct linux_sys_open_args *uap, register_t * this the controlling terminal. */ if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) { - struct filedesc *fdp = p->p_fd; - struct file *fp; + file_t *fp; - fp = fd_getfile(fdp, *retval); + fp = fd_getfile(*retval); /* ignore any error, just give it a try */ if (fp != NULL) { - FILE_USE(fp); if (fp->f_type == DTYPE_VNODE) { - (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, - (void *) 0, l); + (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, NULL); } - FILE_UNUSE(fp, l); + fd_putfile(*retval); } } return 0; @@ -228,8 +225,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ u_long val; void *arg; struct sys_fcntl_args fca; - struct filedesc *fdp; - struct file *fp; + file_t *fp; struct vnode *vp; struct vattr va; const struct cdevsw *cdev; @@ -265,7 +261,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ return 0; case LINUX_F_SETFL: { - struct file *fp1 = NULL; + file_t *fp1 = NULL; val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg)); /* @@ -285,18 +281,15 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ * so that F_GETFL would report the ASYNC i/o is on. */ if (val & O_ASYNC) { - if (((fp1 = fd_getfile(p->p_fd, fd)) == NULL)) + if (((fp1 = fd_getfile(fd)) == NULL)) return (EBADF); - - FILE_USE(fp1); - if (((fp1->f_type == DTYPE_SOCKET) && fp1->f_data && ((struct socket *)fp1->f_data)->so_state & SS_ISAPIPE) || (fp1->f_type == DTYPE_PIPE)) val &= ~O_ASYNC; else { /* not a pipe, do not modify anything */ - FILE_UNUSE(fp1, l); + fd_putfile(fd); fp1 = NULL; } } @@ -309,9 +302,12 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ /* Now set the FASYNC flag for pipes */ if (fp1) { - if (!error) + if (!error) { + mutex_enter(&fp1->f_lock); fp1->f_flag |= FASYNC; - FILE_UNUSE(fp1, l); + mutex_exit(&fp1->f_lock); + } + fd_putfile(fd); } return (error); @@ -332,16 +328,14 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ * restrictive for Linux F_{G,S}ETOWN. For non-tty descriptors, * this is not a problem. */ - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(fd)) == NULL) return EBADF; - FILE_USE(fp); /* Check it's a character device vnode */ if (fp->f_type != DTYPE_VNODE || (vp = (struct vnode *)fp->f_data) == NULL || vp->v_type != VCHR) { - FILE_UNUSE(fp, l); + fd_putfile(fd); not_tty: /* Not a tty, proceed with common fcntl() */ @@ -351,7 +345,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_ error = VOP_GETATTR(vp, &va, l->l_cred); - FILE_UNUSE(fp, l); + fd_putfile(fd); if (error) return error; @@ -448,7 +442,7 @@ linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_ struct stat tmpst; int error; - error = do_sys_fstat(l, SCARG(uap, fd), &tmpst); + error = do_sys_fstat(SCARG(uap, fd), &tmpst); if (error != 0) return error; bsd_to_linux_stat(&tmpst, &tmplst); @@ -457,13 +451,13 @@ linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_ } static int -linux_stat1(struct lwp *l, const struct linux_sys_stat_args *uap, register_t *retval, int flags) +linux_stat1(const struct linux_sys_stat_args *uap, register_t *retval, int flags) { struct linux_stat tmplst; struct stat tmpst; int error; - error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst); + error = do_sys_stat(SCARG(uap, path), flags, &tmpst); if (error != 0) return error; @@ -480,7 +474,7 @@ linux_sys_stat(struct lwp *l, const struct linux_sys_stat_args *uap, register_t syscallarg(struct linux_stat *) sp; } */ - return linux_stat1(l, uap, retval, FOLLOW); + return linux_stat1(uap, retval, FOLLOW); } /* Note: this is "newlstat" in the Linux sources */ @@ -493,7 +487,7 @@ linux_sys_lstat(struct lwp *l, const struct linux_sys_lstat_args *uap, register_ syscallarg(struct linux_stat *) sp; } */ - return linux_stat1(l, (const void *)uap, retval, NOFOLLOW); + return linux_stat1((const void *)uap, retval, NOFOLLOW); } #endif /* !__amd64__ */ @@ -524,7 +518,7 @@ linux_sys_unlink(struct lwp *l, const struct linux_sys_unlink_args *uap, registe if (namei(&nd) == 0) { struct stat sb; - if (vn_stat(nd.ni_vp, &sb, l) == 0 + if (vn_stat(nd.ni_vp, &sb) == 0 && S_ISDIR(sb.st_mode)) error = EISDIR; diff --git a/sys/compat/linux/common/linux_file64.c b/sys/compat/linux/common/linux_file64.c index 72646b2c5d5..1724b7a3e5a 100644 --- a/sys/compat/linux/common/linux_file64.c +++ b/sys/compat/linux/common/linux_file64.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_file64.c,v 1.45 2008/02/02 19:37:53 dsl Exp $ */ +/* $NetBSD: linux_file64.c,v 1.46 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998, 2000 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.45 2008/02/02 19:37:53 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.46 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -130,7 +130,7 @@ linux_sys_fstat64(struct lwp *l, const struct linux_sys_fstat64_args *uap, regis struct stat tmpst; int error; - error = do_sys_fstat(l, SCARG(uap, fd), &tmpst); + error = do_sys_fstat(SCARG(uap, fd), &tmpst); if (error != 0) return error; @@ -146,7 +146,7 @@ linux_do_stat64(struct lwp *l, const struct linux_sys_stat64_args *uap, register struct stat tmpst; int error; - error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst); + error = do_sys_stat(SCARG(uap, path), flags, &tmpst); if (error != 0) return error; @@ -240,7 +240,7 @@ linux_sys_getdents64(struct lwp *l, const struct linux_sys_getdents64_args *uap, int len, reclen; /* BSD-format */ char *outp; /* Linux-format */ int resid, linux_reclen = 0; /* Linux-format */ - struct file *fp; + file_t *fp; struct uio auio; struct iovec aiov; struct linux_dirent64 idb; @@ -251,7 +251,7 @@ linux_sys_getdents64(struct lwp *l, const struct linux_sys_getdents64_args *uap, int ncookies; /* getvnode() will use the descriptor for us */ - if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) { @@ -355,6 +355,6 @@ out: free(cookiebuf, M_TEMP); free(tbuf, M_TEMP); out1: - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } diff --git a/sys/compat/linux/common/linux_hdio.c b/sys/compat/linux/common/linux_hdio.c index c112d36d203..80437eadb35 100644 --- a/sys/compat/linux/common/linux_hdio.c +++ b/sys/compat/linux/common/linux_hdio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdio.c,v 1.15 2007/12/20 23:02:54 dsl Exp $ */ +/* $NetBSD: linux_hdio.c,v 1.16 2008/03/21 21:54:58 ad Exp $ */ /* * Copyright (c) 2000 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_hdio.c,v 1.15 2007/12/20 23:02:54 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdio.c,v 1.16 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -67,24 +67,19 @@ int linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) { - struct proc *p = l->l_proc; u_long com; int error, error1; - struct filedesc *fdp; struct file *fp; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(struct file *, u_long, void *); struct atareq req; struct disklabel label, *labp; struct partinfo partp; struct linux_hd_geometry hdg; struct linux_hd_big_geometry hdg_big; - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); - com = SCARG(uap, com); ioctlf = fp->f_ops->fo_ioctl; retval[0] = error = 0; @@ -102,7 +97,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, */ req.datalen = com == LINUX_HDIO_GET_IDENTITY ? 512 : 142; req.timeout = 1000; - error = ioctlf(fp, ATAIOCCOMMAND, &req, l); + error = ioctlf(fp, ATAIOCCOMMAND, &req); if (error != 0) break; if (req.retsts != ATACMD_OK) @@ -112,8 +107,8 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = linux_machdepioctl(l, uap, retval); if (error == 0) break; - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l); - error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l); + error = ioctlf(fp, DIOCGDEFLABEL, &label); + error1 = ioctlf(fp, DIOCGPART, &partp); if (error != 0 && error1 != 0) { error = error1; break; @@ -130,8 +125,8 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, if (error == 0) break; case LINUX_HDIO_GETGEO_BIG_RAW: - error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l); - error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l); + error = ioctlf(fp, DIOCGDEFLABEL, &label); + error1 = ioctlf(fp, DIOCGPART, &partp); if (error != 0 && error1 != 0) { error = error1; break; @@ -167,7 +162,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = EINVAL; } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } diff --git a/sys/compat/linux/common/linux_ioctl.c b/sys/compat/linux/common/linux_ioctl.c index 7cb6b082426..45b8c9ebbcd 100644 --- a/sys/compat/linux/common/linux_ioctl.c +++ b/sys/compat/linux/common/linux_ioctl.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_ioctl.c,v 1.52 2007/12/20 23:02:54 dsl Exp $ */ +/* $NetBSD: linux_ioctl.c,v 1.53 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.52 2007/12/20 23:02:54 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.53 2008/03/21 21:54:58 ad Exp $"); #if defined(_KERNEL_OPT) #include "sequencer.h" @@ -119,15 +119,12 @@ linux_sys_ioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_ * device number and check if that is the sequencer entry. */ struct file *fp; - struct filedesc *fdp; struct vnode *vp; struct vattr va; extern const struct cdevsw sequencer_cdevsw; - fdp = l->l_proc->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return EBADF; - FILE_USE(fp); if (fp->f_type == DTYPE_VNODE && (vp = (struct vnode *)fp->f_data) != NULL && vp->v_type == VCHR && @@ -139,7 +136,7 @@ linux_sys_ioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_ else { error = linux_ioctl_termios(l, uap, retval); } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); #else error = linux_ioctl_termios(l, uap, retval); #endif diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index 58d97e7c31f..6abbf6b2860 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $ */ +/* $NetBSD: linux_misc.c,v 1.194 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.194 2008/03/21 21:54:58 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ptrace.h" @@ -713,7 +713,7 @@ linux_sys_getdents(struct lwp *l, const struct linux_sys_getdents_args *uap, reg int ncookies; /* getvnode() will use the descriptor for us */ - if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) { @@ -841,7 +841,7 @@ out: free(cookiebuf, M_TEMP); free(tbuf, M_TEMP); out1: - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } diff --git a/sys/compat/linux/common/linux_mtio.c b/sys/compat/linux/common/linux_mtio.c index b2ca1cc1fdf..b92051d65f2 100644 --- a/sys/compat/linux/common/linux_mtio.c +++ b/sys/compat/linux/common/linux_mtio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $ */ +/* $NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $ */ /* * Copyright (c) 2005 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -74,20 +74,17 @@ int linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) { - struct file *fp; - struct filedesc *fdp; + file_t *fp; u_long com = SCARG(uap, com); int i, error = 0; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(file_t *, u_long, void *); struct linux_mtop lmtop; struct linux_mtget lmtget; struct mtop mt; - fdp = l->l_proc->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return EBADF; - FILE_USE(fp); ioctlf = fp->f_ops->fo_ioctl; *retval = 0; @@ -106,7 +103,7 @@ linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap, mt.mt_op = mtop_map[i].op; mt.mt_count = lmtop.mt_count; - error = ioctlf(fp, MTIOCTOP, (void *)&mt, l); + error = ioctlf(fp, MTIOCTOP, &mt); break; case LINUX_MTIOCGET: lmtget.mt_type = LINUX_MT_ISUNKNOWN; @@ -125,7 +122,7 @@ linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap, break; } - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } diff --git a/sys/compat/linux/common/linux_sg.c b/sys/compat/linux/common/linux_sg.c index f604ab9f915..68cf20e9175 100644 --- a/sys/compat/linux/common/linux_sg.c +++ b/sys/compat/linux/common/linux_sg.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sg.c,v 1.12 2007/12/20 23:02:56 dsl Exp $ */ +/* $NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */ /* * Copyright (c) 2004 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.12 2007/12/20 23:02:56 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -72,19 +72,16 @@ int linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) { - struct file *fp; - struct filedesc *fdp; + file_t *fp; u_long com = SCARG(uap, com); int error = 0; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(file_t *, u_long, void *); struct linux_sg_io_hdr lreq; struct scsireq req; - fdp = l->l_proc->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return EBADF; - FILE_USE(fp); ioctlf = fp->f_ops->fo_ioctl; *retval = 0; @@ -143,7 +140,7 @@ linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap, req.datalen = lreq.dxfer_len; req.databuf = lreq.dxferp; - error = ioctlf(fp, SCIOCCOMMAND, (void *)&req, l); + error = ioctlf(fp, SCIOCCOMMAND, &req); if (error) { DPRINTF(("SCIOCCOMMAND failed %d\n", error)); break; @@ -212,8 +209,8 @@ linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap, break; } -done: - FILE_UNUSE(fp, l); + done: + fd_putfile(SCARG(uap, fd)); DPRINTF(("Return=%d\n", error)); return error; diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c index 7f186120675..3089c4d336e 100644 --- a/sys/compat/linux/common/linux_socket.c +++ b/sys/compat/linux/common/linux_socket.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_socket.c,v 1.86 2008/02/06 21:57:53 ad Exp $ */ +/* $NetBSD: linux_socket.c,v 1.87 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.86 2008/02/06 21:57:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.87 2008/03/21 21:54:58 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -318,10 +318,9 @@ linux_sys_socket(struct lwp *l, const struct linux_sys_socket_args *uap, registe * for Linux apps if the sysctl value is set to 1. */ if (!error && ip6_v6only && SCARG(&bsa, domain) == PF_INET6) { - struct proc *p = l->l_proc; - struct file *fp; + file_t *fp; - if (getsock(p->p_fd, *retval, &fp) == 0) { + if (getsock(*retval, &fp) == 0) { struct mbuf *m; m = m_get(M_WAIT, MT_SOOPTS); @@ -332,7 +331,7 @@ linux_sys_socket(struct lwp *l, const struct linux_sys_socket_args *uap, registe (void) sosetopt((struct socket *)fp->f_data, IPPROTO_IPV6, IPV6_V6ONLY, m); - FILE_UNUSE(fp, l); + fd_putfile(*retval); } } #endif @@ -875,7 +874,6 @@ linux_sys_setsockopt(struct lwp *l, const struct linux_sys_setsockopt_args *uap, syscallarg(void *) optval; syscallarg(int) optlen; } */ - struct proc *p = l->l_proc; struct sys_setsockopt_args bsa; int name; @@ -889,19 +887,19 @@ linux_sys_setsockopt(struct lwp *l, const struct linux_sys_setsockopt_args *uap, * and returns EOPNOTSUPP for other levels */ if (SCARG(&bsa, level) != SOL_SOCKET) { - struct file *fp; + file_t *fp; struct socket *so; int error, s, family; /* getsock() will use the descriptor for us */ - if ((error = getsock(p->p_fd, SCARG(&bsa, s), &fp)) != 0) + if ((error = getsock(SCARG(&bsa, s), &fp)) != 0) return error; s = splsoftnet(); so = (struct socket *)fp->f_data; family = so->so_proto->pr_domain->dom_family; splx(s); - FILE_UNUSE(fp, l); + fd_putfile(SCARG(&bsa, s)); if (family == AF_LOCAL) return EOPNOTSUPP; @@ -987,9 +985,7 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd, char if_name[IF_NAME_LEN]; struct osockaddr hwaddr; } lreq; - struct proc *p = l->l_proc; - struct filedesc *fdp; - struct file *fp; + file_t *fp; struct ifaddr *ifa; struct ifnet *ifp; struct sockaddr_dl *sadl; @@ -1007,11 +1003,9 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd, * So, we must duplicate code from sys_ioctl() and ifconf(). Ugh. */ - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(fd)) == NULL) return (EBADF); - FILE_USE(fp); if ((fp->f_flag & (FREAD | FWRITE)) == 0) { error = EBADF; goto out; @@ -1096,7 +1090,7 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd, } out: - FILE_UNUSE(fp, l); + fd_putfile(fd); return error; } #undef IF_NAME_LEN @@ -1109,22 +1103,17 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist syscallarg(u_long) com; syscallarg(void *) data; } */ - struct proc *p = l->l_proc; u_long com; int error = 0, isdev = 0, dosys = 1; struct sys_ioctl_args ia; - struct file *fp; - struct filedesc *fdp; + file_t *fp; struct vnode *vp; - int (*ioctlf)(struct file *, u_long, void *, struct lwp *); + int (*ioctlf)(file_t *, u_long, void *); struct ioctl_pt pt; - fdp = p->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); - if (fp->f_type == DTYPE_VNODE) { vp = (struct vnode *)fp->f_data; isdev = vp->v_type == VCHR; @@ -1142,7 +1131,7 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist ioctlf = fp->f_ops->fo_ioctl; pt.com = SCARG(uap, com); pt.data = SCARG(uap, data); - error = ioctlf(fp, PTIOCLINUX, (void *)&pt, l); + error = ioctlf(fp, PTIOCLINUX, &pt); /* * XXX hack: if the function returns EJUSTRETURN, * it has stuffed a sysctl return value in pt.data. @@ -1187,20 +1176,19 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist break; case LINUX_SIOCGIFHWADDR: error = linux_getifhwaddr(l, retval, SCARG(uap, fd), - SCARG(uap, data)); + SCARG(uap, data)); dosys = 0; break; default: error = EINVAL; } -out: - FILE_UNUSE(fp, l); + out: + fd_putfile(SCARG(uap, fd)); if (error ==0 && dosys) { SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - /* XXX NJWLWP */ error = sys_ioctl(curlwp, &ia, retval); } @@ -1226,12 +1214,12 @@ linux_sys_connect(struct lwp *l, const struct linux_sys_connect_args *uap, regis error = do_sys_connect(l, SCARG(uap, s), nam); if (error == EISCONN) { - struct file *fp; + file_t *fp; struct socket *so; int s, state, prflags, nbio; /* getsock() will use the descriptor for us */ - if (getsock(l->l_proc->p_fd, SCARG(uap, s), &fp) != 0) + if (getsock(SCARG(uap, s), &fp) != 0) return EISCONN; s = splsoftnet(); @@ -1240,7 +1228,7 @@ linux_sys_connect(struct lwp *l, const struct linux_sys_connect_args *uap, regis nbio = so->so_nbio; prflags = so->so_proto->pr_flags; splx(s); - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, s)); /* * We should only let this call succeed once per * non-blocking connect; however we don't have @@ -1359,18 +1347,16 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa * This avoid triggering strict family checks in netinet/in_pcb.c et.al. */ if (bdom == AF_UNSPEC) { - struct file *fp; + file_t *fp; struct socket *so; /* getsock() will use the descriptor for us */ - if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0) + if ((error = getsock(s, &fp)) != 0) goto bad; so = (struct socket *)fp->f_data; bdom = so->so_proto->pr_domain->dom_family; - FILE_UNUSE(fp, l); - DPRINTF(("AF_UNSPEC family adjusted to %d\n", bdom)); } @@ -1398,6 +1384,7 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa "sockaddr_in6 rejected", p->p_pid, p->p_comm, uid); error = EINVAL; + fd_putfile(s); goto bad; } salen = sizeof (struct sockaddr_in6); @@ -1422,6 +1409,7 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa #endif *mp = m; + fd_putfile(s); return 0; bad: diff --git a/sys/compat/linux/common/linux_termios.c b/sys/compat/linux/common/linux_termios.c index aa26f40edce..49cf504f695 100644 --- a/sys/compat/linux/common/linux_termios.c +++ b/sys/compat/linux/common/linux_termios.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_termios.c,v 1.33 2007/12/20 23:02:57 dsl Exp $ */ +/* $NetBSD: linux_termios.c,v 1.34 2008/03/21 21:54:58 ad Exp $ */ /*- - * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.33 2007/12/20 23:02:57 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.34 2008/03/21 21:54:58 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ptm.h" @@ -78,8 +78,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis syscallarg(u_long) com; syscallarg(void *) data; } */ - struct file *fp; - struct filedesc *fdp; + file_t *fp; u_long com; struct linux_termio tmplt; struct linux_termios tmplts; @@ -88,14 +87,11 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis struct sys_ioctl_args ia; int error; char tioclinux; - int (*bsdioctl)(struct file *, u_long, void *, struct lwp *); + int (*bsdioctl)(file_t *, u_long, void *); - fdp = l->l_proc->p_fd; - if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) + if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) return (EBADF); - FILE_USE(fp); - if ((fp->f_flag & (FREAD | FWRITE)) == 0) { error = EBADF; goto out; @@ -107,7 +103,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis switch (com) { case LINUX_TCGETS: - error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, TIOCGETA, &tmpbts); if (error) goto out; bsd_termios_to_linux_termios(&tmpbts, &tmplts); @@ -120,7 +116,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis * First fill in all fields, so that we keep the current * values for fields that Linux doesn't know about. */ - error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, TIOCGETA, &tmpbts); if (error) goto out; error = copyin(SCARG(uap, data), &tmplts, sizeof tmplts); @@ -138,10 +134,10 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis com = TIOCSETAF; break; } - error = (*bsdioctl)(fp, com, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, com, &tmpbts); goto out; case LINUX_TCGETA: - error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, TIOCGETA, &tmpbts); if (error) goto out; bsd_termios_to_linux_termio(&tmpbts, &tmplt); @@ -154,7 +150,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis * First fill in all fields, so that we keep the current * values for fields that Linux doesn't know about. */ - error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, TIOCGETA, &tmpbts); if (error) goto out; error = copyin(SCARG(uap, data), &tmplt, sizeof tmplt); @@ -172,7 +168,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis com = TIOCSETAF; break; } - error = (*bsdioctl)(fp, com, (void *)&tmpbts, l); + error = (*bsdioctl)(fp, com, &tmpbts); goto out; case LINUX_TCFLSH: switch((u_long)SCARG(uap, data)) { @@ -189,10 +185,10 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis error = EINVAL; goto out; } - error = (*bsdioctl)(fp, TIOCFLUSH, (void *)&idat, l); + error = (*bsdioctl)(fp, TIOCFLUSH, &idat); goto out; case LINUX_TIOCGETD: - error = (*bsdioctl)(fp, TIOCGETD, (void *)&idat, l); + error = (*bsdioctl)(fp, TIOCGETD, &idat); if (error) goto out; switch (idat) { @@ -246,7 +242,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis error = EINVAL; goto out; } - error = (*bsdioctl)(fp, TIOCSETD, (void *)&idat, l); + error = (*bsdioctl)(fp, TIOCSETD, &idat); goto out; case LINUX_TIOCLINUX: error = copyin(SCARG(uap, data), &tioclinux, sizeof tioclinux); @@ -327,7 +323,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis { struct ptmget ptm; - error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm, l); + error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm); if (error != 0) goto out; error = copyout(&ptm.sfd, SCARG(uap, data), @@ -338,7 +334,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis #endif /* LINUX_TIOCGPTN */ #ifdef LINUX_TIOCSPTLCK case LINUX_TIOCSPTLCK: - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); error = copyin(SCARG(uap, data), &idat, sizeof(idat)); if (error) return error; @@ -352,9 +348,8 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - /* XXX NJWLWP */ error = sys_ioctl(curlwp, &ia, retval); out: - FILE_UNUSE(fp, l); + fd_putfile(SCARG(uap, fd)); return error; } |
