From fbfe4e7dda7095309a1b9a423af05cfe98e89929 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Sun, 9 Oct 2005 18:07:55 +0000 Subject: [PATCH] 1:1 Userland threading stage 2.5/4: Remove compatibility p_dupfd and use the per-lwp one. --- sys/dev/misc/streams/streams.c | 13 +++++++------ sys/kern/kern_descrip.c | 8 ++++---- sys/kern/vfs_syscalls.c | 11 ++++++----- sys/sys/proc.h | 3 +-- sys/vfs/fdesc/fdesc_vnops.c | 10 +++++----- sys/vfs/portal/portal_vnops.c | 6 +++--- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sys/dev/misc/streams/streams.c b/sys/dev/misc/streams/streams.c index 3742562b21..aa7666218d 100644 --- a/sys/dev/misc/streams/streams.c +++ b/sys/dev/misc/streams/streams.c @@ -31,7 +31,7 @@ * in 3.0-980524-SNAP then hacked a bit (but probably not enough :-). * * $FreeBSD: src/sys/dev/streams/streams.c,v 1.16.2.1 2001/02/26 04:23:07 jlemon Exp $ - * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.20 2005/09/02 07:16:58 hsu Exp $ + * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.21 2005/10/09 18:07:55 corecode Exp $ */ #include @@ -182,6 +182,7 @@ static int streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) { struct proc *p = td->td_proc; + struct lwp *lp = td->td_lwp; int type, protocol; int fd; struct file *fp; @@ -191,7 +192,7 @@ streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) KKASSERT(p != NULL); - if (p->p_dupfd >= 0) + if (lp->lwp_dupfd >= 0) return ENODEV; switch (minor(dev)) { @@ -258,7 +259,7 @@ streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) fp->f_data = so; (void)svr4_stream_get(fp); fdrop(fp, td); - p->p_dupfd = fd; + lp->lwp_dupfd = fd; return ENXIO; } @@ -281,11 +282,11 @@ svr4_ptm_alloc(struct thread *td) static char ptyname[] = "/dev/ptyXX"; static char ttyletters[] = "pqrstuwxyzPQRST"; static char ttynumbers[] = "0123456789abcdef"; - struct proc *p = td->td_proc; + struct lwp *lp = td->td_lwp; struct nlookupdata nd; int error, fd, l = 0, n = 0; - KKASSERT(p); + KKASSERT(lp); for (;;) { ptyname[8] = ttyletters[l]; @@ -301,7 +302,7 @@ svr4_ptm_alloc(struct thread *td) case ENXIO: return error; case 0: - p->p_dupfd = fd; + lp->lwp_dupfd = fd; return ENXIO; default: if (ttynumbers[++n] == '\0') { diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 1cb0d0cdd5..c2c70c1c41 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -70,7 +70,7 @@ * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.81.2.19 2004/02/28 00:43:31 tegge Exp $ - * $DragonFly: src/sys/kern/kern_descrip.c,v 1.47 2005/07/23 23:26:50 joerg Exp $ + * $DragonFly: src/sys/kern/kern_descrip.c,v 1.48 2005/10/09 18:07:55 corecode Exp $ */ #include "opt_compat.h" @@ -1717,17 +1717,17 @@ flock(struct flock_args *uap) static int fdopen(dev_t dev, int mode, int type, struct thread *td) { - KKASSERT(td->td_proc != NULL); + KKASSERT(td->td_lwp != NULL); /* - * XXX Kludge: set curproc->p_dupfd to contain the value of the + * XXX Kludge: set curlwp->lwp_dupfd to contain the value of the * the file descriptor being sought for duplication. The error * return ensures that the vnode for this device will be released * by vn_open. Open will detect this special error and take the * actions in dupfdopen below. Other callers of vn_open or VOP_OPEN * will simply report the error. */ - td->td_proc->p_dupfd = minor(dev); + td->td_lwp->lwp_dupfd = minor(dev); return (ENODEV); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 954b9b9f02..f904ef8857 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -37,7 +37,7 @@ * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 * $FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.151.2.18 2003/04/04 20:35:58 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_syscalls.c,v 1.73 2005/09/29 20:59:30 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_syscalls.c,v 1.74 2005/10/09 18:07:55 corecode Exp $ */ #include @@ -1271,6 +1271,7 @@ kern_open(struct nlookupdata *nd, int oflags, int mode, int *res) { struct thread *td = curthread; struct proc *p = td->td_proc; + struct lwp *lp = td->td_lwp; struct filedesc *fdp = p->p_fd; int cmode, flags; struct file *nfp; @@ -1293,7 +1294,7 @@ kern_open(struct nlookupdata *nd, int oflags, int mode, int *res) * file descriptor to be duplicated rather then doing the open * itself. */ - p->p_dupfd = -1; + lp->lwp_dupfd = -1; /* * Call vn_open() to do the lookup and assign the vnode to the @@ -1314,9 +1315,9 @@ kern_open(struct nlookupdata *nd, int oflags, int mode, int *res) * which represents the fd_files[] assignment. We must still * drop our reference. */ - if ((error == ENODEV || error == ENXIO) && p->p_dupfd >= 0) { + if ((error == ENODEV || error == ENXIO) && lp->lwp_dupfd >= 0) { if (fsetfd(p, fp, &indx) == 0) { - error = dupfdopen(fdp, indx, p->p_dupfd, flags, error); + error = dupfdopen(fdp, indx, lp->lwp_dupfd, flags, error); if (error == 0) { *res = indx; fdrop(fp, td); /* our ref */ @@ -1351,7 +1352,7 @@ kern_open(struct nlookupdata *nd, int oflags, int mode, int *res) * If no error occurs the vp will have been assigned to the file * pointer. */ - p->p_dupfd = 0; + lp->lwp_dupfd = 0; /* * There should be 2 references on the file, one from the descriptor diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0c486c4c89..d61c7abad8 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.66 2005/10/08 19:46:51 corecode Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.67 2005/10/09 18:07:55 corecode Exp $ */ #ifndef _SYS_PROC_H_ @@ -218,7 +218,6 @@ struct proc { #define p_startzero p_oppid pid_t p_oppid; /* Save parent pid during ptrace. XXX */ -#define p_dupfd p_lwp.lwp_dupfd struct vmspace *p_vmspace; /* Address space. */ diff --git a/sys/vfs/fdesc/fdesc_vnops.c b/sys/vfs/fdesc/fdesc_vnops.c index 37ee989c16..8054db1c40 100644 --- a/sys/vfs/fdesc/fdesc_vnops.c +++ b/sys/vfs/fdesc/fdesc_vnops.c @@ -36,7 +36,7 @@ * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 * * $FreeBSD: src/sys/miscfs/fdesc/fdesc_vnops.c,v 1.47.2.1 2001/10/22 22:49:26 chris Exp $ - * $DragonFly: src/sys/vfs/fdesc/fdesc_vnops.c,v 1.21 2005/09/14 01:13:33 dillon Exp $ + * $DragonFly: src/sys/vfs/fdesc/fdesc_vnops.c,v 1.22 2005/10/09 18:07:55 corecode Exp $ */ /* @@ -246,22 +246,22 @@ static int fdesc_open(struct vop_open_args *ap) { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_td->td_proc; + struct lwp *lp = ap->a_td->td_proc; - KKASSERT(p); + KKASSERT(lp); if (VTOFDESC(vp)->fd_type == Froot) return (0); /* - * XXX Kludge: set p->p_dupfd to contain the value of the the file + * XXX Kludge: set lp->lwp_dupfd to contain the value of the the file * descriptor being sought for duplication. The error return ensures * that the vnode for this device will be released by vn_open. Open * will detect this special error and take the actions in dupfdopen. * Other callers of vn_open or VOP_OPEN will simply report the * error. */ - p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ + lp->lwp_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ return (ENODEV); } diff --git a/sys/vfs/portal/portal_vnops.c b/sys/vfs/portal/portal_vnops.c index 8eecc4727d..505b8a2d23 100644 --- a/sys/vfs/portal/portal_vnops.c +++ b/sys/vfs/portal/portal_vnops.c @@ -36,7 +36,7 @@ * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * * $FreeBSD: src/sys/miscfs/portal/portal_vnops.c,v 1.38 1999/12/21 06:29:00 chris Exp $ - * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.23 2005/09/14 01:13:43 dillon Exp $ + * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.24 2005/10/09 18:07:55 corecode Exp $ */ /* @@ -236,7 +236,7 @@ portal_open(struct vop_open_args *ap) * by testing whether the p_dupfd has been set. */ KKASSERT(td->td_proc); - if (td->td_proc->p_dupfd >= 0) + if (td->td_lwp->lwp_dupfd >= 0) return (ENODEV); pt = VTOPORTAL(vp); @@ -413,7 +413,7 @@ portal_open(struct vop_open_args *ap) * special error code (ENXIO) which causes magic things to * happen in vn_open. The whole concept is, well, hmmm. */ - td->td_proc->p_dupfd = fd; + td->td_lwp->lwp_dupfd = fd; error = ENXIO; bad:; -- 2.41.0