diff options
Diffstat (limited to 'sys')
774 files changed, 15842 insertions, 13853 deletions
diff --git a/sys/alpha/alpha/db_interface.c b/sys/alpha/alpha/db_interface.c index 6a566e3..49463c7 100644 --- a/sys/alpha/alpha/db_interface.c +++ b/sys/alpha/alpha/db_interface.c @@ -592,23 +592,26 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu) db_printf("cpuid = %d\n", gd->gd_cpuid); db_printf("ipis = %lx\n", gd->gd_pending_ipis); db_printf("next ASN = %d\n", gd->gd_next_asn); - db_printf("curproc = "); - if (gd->gd_curproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_curproc, - gd->gd_curproc->p_pid, gd->gd_curproc->p_comm); + db_printf("curthread = "); + if (gd->gd_curthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread, + gd->gd_curthread->td_proc->p_pid, + gd->gd_curthread->td_proc->p_comm); else db_printf("none\n"); db_printf("curpcb = %p\n", gd->gd_curpcb); - db_printf("fpcurproc = "); - if (gd->gd_fpcurproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_fpcurproc, - gd->gd_fpcurproc->p_pid, gd->gd_fpcurproc->p_comm); + db_printf("fpcurthread = "); + if (gd->gd_fpcurthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_fpcurthread, + gd->gd_fpcurthread->td_proc->p_pid, + gd->gd_fpcurthread->td_proc->p_comm); else db_printf("none\n"); - db_printf("idleproc = "); - if (gd->gd_idleproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_idleproc, - gd->gd_idleproc->p_pid, gd->gd_idleproc->p_comm); + db_printf("idlethread = "); + if (gd->gd_idlethread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread, + gd->gd_idlethread->td_proc->p_pid, + gd->gd_idlethread->td_proc->p_comm); else db_printf("none\n"); diff --git a/sys/alpha/alpha/db_trace.c b/sys/alpha/alpha/db_trace.c index c743926..f99e5a0 100644 --- a/sys/alpha/alpha/db_trace.c +++ b/sys/alpha/alpha/db_trace.c @@ -212,6 +212,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m boolean_t ra_from_pcb; u_long last_ipl = ~0L; struct proc *p = NULL; + struct thread *td = NULL; boolean_t have_trapframe = FALSE; pid_t pid; @@ -219,7 +220,8 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m count = 65535; if (!have_addr) { - p = curproc; + td = curthread; + p = td->td_proc; addr = DDB_REGS->tf_regs[FRAME_SP] - FRAME_SIZE * 8; tf = (struct trapframe *)addr; have_trapframe = 1; @@ -231,8 +233,9 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m * The pcb for curproc is not valid at this point, * so fall back to the default case. */ - if (pid == curproc->p_pid) { - p = curproc; + if (pid == curthread->td_proc->p_pid) { + td = curthread; + p = td->td_proc; addr = DDB_REGS->tf_regs[FRAME_SP] - FRAME_SIZE * 8; tf = (struct trapframe *)addr; have_trapframe = 1; @@ -251,7 +254,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m db_printf("pid %d swapped out\n", pid); return; } - pcbp = &p->p_addr->u_pcb; + pcbp = p->p_thread.td_pcb; /* XXXKSE */ addr = (db_expr_t)pcbp->pcb_hw.apcb_ksp; callpc = pcbp->pcb_context[7]; frame = addr; diff --git a/sys/alpha/alpha/exception.s b/sys/alpha/alpha/exception.s index c7119b0..31637b4 100644 --- a/sys/alpha/alpha/exception.s +++ b/sys/alpha/alpha/exception.s @@ -139,17 +139,17 @@ beq t1, exception_return /* set the hae register if this process has specified a value */ - ldq s0, GD_CURPROC(globalp) - ldq t1, P_MD_FLAGS(s0) + ldq s0, GD_CURTHREAD(globalp) + ldq t1, TD_MD_FLAGS(s0) and t1, MDP_HAEUSED beq t1, 3f - ldq a0, P_MD_HAE(s0) + ldq a0, TD_MD_HAE(s0) ldq pv, chipset + CHIPSET_WRITE_HAE CALL((pv)) 3: #ifdef SMP /* leave the kernel */ - stl zero, P_MD_KERNNEST(s0) + stl zero, TD_MD_KERNNEST(s0) #endif /* restore the registers, and return */ @@ -255,9 +255,9 @@ LEAF(exception_return, 1) /* XXX should be NESTED */ br pv, Ler1 Ler1: LDGP(pv) - ldq s0, GD_CURPROC(globalp) /* save curproc in s0 */ + ldq s0, GD_CURTHREAD(globalp) /* save curthread in s0 */ #ifdef SMP - ldl s1, P_MD_KERNNEST(s0) + ldl s1, TD_MD_KERNNEST(s0) subl s1, 1, s1 /* decrement nesting level */ #endif @@ -280,16 +280,16 @@ Lkernelret: Lrestoreregs: /* set the hae register if this process has specified a value */ - ldq t1, P_MD_FLAGS(s0) + ldq t1, TD_MD_FLAGS(s0) and t1, MDP_HAEUSED beq t1, Lnohae - ldq a0, P_MD_HAE(t0) + ldq a0, TD_MD_HAE(t0) ldq pv, chipset + CHIPSET_WRITE_HAE CALL((pv)) Lnohae: #ifdef SMP /* leave the kernel */ - stl s1, P_MD_KERNNEST(s0) + stl s1, TD_MD_KERNNEST(s0) #endif /* restore the registers, and return */ diff --git a/sys/alpha/alpha/fp_emulate.c b/sys/alpha/alpha/fp_emulate.c index 20f64d6..bf5eef7 100644 --- a/sys/alpha/alpha/fp_emulate.c +++ b/sys/alpha/alpha/fp_emulate.c @@ -221,10 +221,10 @@ static fp_register_t fp_cvtql(union alpha_instruction ins, return ret; } -static int fp_emulate(union alpha_instruction ins, struct proc *p) +static int fp_emulate(union alpha_instruction ins, struct thread *td) { - u_int64_t control = p->p_addr->u_pcb.pcb_fp_control; - struct fpreg *fpregs = &p->p_addr->u_pcb.pcb_fp; + u_int64_t control = td->td_pcb->pcb_fp_control; + struct fpreg *fpregs = &td->td_pcb->pcb_fp; static fp_opcode_handler *ops[16] = { fp_add, /* 0 */ fp_sub, /* 1 */ @@ -261,7 +261,7 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p) * them. We are potentially going to modify the fp state, so * cancel fpcurproc too. */ - alpha_fpstate_save(p, 1); + alpha_fpstate_save(td, 1); /* * Decode and execute the instruction. @@ -288,7 +288,7 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p) /* Record the exception in the software control word. */ control |= (status >> IEEE_STATUS_TO_FPCR_SHIFT); - p->p_addr->u_pcb.pcb_fp_control = control; + td->td_pcb->pcb_fp_control = control; /* Regenerate the control register */ fpcr = fpregs->fpr_cr & FPCR_DYN_MASK; @@ -323,9 +323,9 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p) * emulating it in software. Return non-zero if the completion was * successful, otherwise zero. */ -int fp_software_completion(u_int64_t regmask, struct proc *p) +int fp_software_completion(u_int64_t regmask, struct thread *td) { - struct trapframe *frame = p->p_frame; + struct trapframe *frame = td->td_frame; u_int64_t pc = frame->tf_regs[FRAME_PC]; int error; @@ -394,7 +394,7 @@ int fp_software_completion(u_int64_t regmask, struct proc *p) * instructions in the trap shadow, so this * must be the one which generated the trap. */ - if (fp_emulate(ins, p)) { + if (fp_emulate(ins, td)) { /* * Restore pc to the first instruction * in the trap shadow. diff --git a/sys/alpha/alpha/genassym.c b/sys/alpha/alpha/genassym.c index 03990ea..d520b52 100644 --- a/sys/alpha/alpha/genassym.c +++ b/sys/alpha/alpha/genassym.c @@ -68,8 +68,8 @@ #include <nfs/nfs.h> #include <nfs/nfsdiskless.h> -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); -ASSYM(GD_FPCURPROC, offsetof(struct globaldata, gd_fpcurproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); +ASSYM(GD_FPCURTHREAD, offsetof(struct globaldata, gd_fpcurthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); @@ -80,12 +80,15 @@ ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse)); ASSYM(MTX_SAVECRIT, offsetof(struct mtx, mtx_savecrit)); ASSYM(MTX_UNOWNED, MTX_UNOWNED); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); -ASSYM(P_MD_FLAGS, offsetof(struct proc, p_md.md_flags)); -ASSYM(P_MD_PCBPADDR, offsetof(struct proc, p_md.md_pcbpaddr)); -ASSYM(P_MD_HAE, offsetof(struct proc, p_md.md_hae)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); +ASSYM(TD_KSE, offsetof(struct thread, td_kse)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); + +ASSYM(TD_MD_FLAGS, offsetof(struct thread, td_md.md_flags)); +ASSYM(TD_MD_PCBPADDR, offsetof(struct thread, td_md.md_pcbpaddr)); +ASSYM(TD_MD_HAE, offsetof(struct thread, td_md.md_hae)); #ifdef SMP -ASSYM(P_MD_KERNNEST, offsetof(struct proc, p_md.md_kernnest)); +ASSYM(TD_MD_KERNNEST, offsetof(struct thread, td_md.md_kernnest)); #endif ASSYM(MDP_HAEUSED, MDP_HAEUSED); @@ -95,10 +98,9 @@ ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); ASSYM(PTLEV1I, PTLEV1I); ASSYM(PTESIZE, PTESIZE); -ASSYM(U_PCB_ONFAULT, offsetof(struct user, u_pcb.pcb_onfault)); -ASSYM(U_PCB_HWPCB_KSP, offsetof(struct user, u_pcb.pcb_hw.apcb_ksp)); -ASSYM(U_PCB_CONTEXT, offsetof(struct user, u_pcb.pcb_context)); - +ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); +ASSYM(PCB_HWPCB_KSP, offsetof(struct pcb, pcb_hw.apcb_ksp)); +ASSYM(PCB_CONTEXT, offsetof(struct pcb, pcb_context)); ASSYM(PCB_HW, offsetof(struct pcb, pcb_hw)); ASSYM(FPREG_FPR_REGS, offsetof(struct fpreg, fpr_regs)); diff --git a/sys/alpha/alpha/interrupt.c b/sys/alpha/alpha/interrupt.c index 489c948..0bdd6c5 100644 --- a/sys/alpha/alpha/interrupt.c +++ b/sys/alpha/alpha/interrupt.c @@ -90,7 +90,7 @@ interrupt(a0, a1, a2, framep) unsigned long a0, a1, a2; struct trapframe *framep; { - struct proc *p; + struct thread *td; #ifdef SMP critical_t s; #endif @@ -102,19 +102,21 @@ interrupt(a0, a1, a2, framep) s = critical_enter(); #endif globalp = (struct globaldata *) alpha_pal_rdval(); - p = curproc; + td = curthread; #ifdef SMP - p->p_md.md_kernnest++; + td->td_md.md_kernnest++; critical_exit(s); #endif - atomic_add_int(&p->p_intr_nesting_level, 1); + atomic_add_int(&td->td_intr_nesting_level, 1); +#ifndef KSTACK_GUARD #ifndef SMP { - if ((caddr_t) framep < (caddr_t) p->p_addr + 1024) { + if ((caddr_t) framep < (caddr_t) td->td_pcb + 1024) { panic("possible stack overflow\n"); } } #endif +#endif framep->tf_regs[FRAME_TRAPARG_A0] = a0; framep->tf_regs[FRAME_TRAPARG_A1] = a1; @@ -161,7 +163,7 @@ interrupt(a0, a1, a2, framep) a0, a1, a2); /* NOTREACHED */ } - atomic_subtract_int(&p->p_intr_nesting_level, 1); + atomic_subtract_int(&td->td_intr_nesting_level, 1); } void @@ -472,7 +474,7 @@ alpha_clock_interrupt(struct trapframe *framep) #ifdef SMP } else { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(framep)); + hardclock_process(curthread, TRAPF_USERMODE(framep)); if ((schedclk2 & 0x7) == 0) statclock_process(curproc, TRAPF_PC(framep), TRAPF_USERMODE(framep)); diff --git a/sys/alpha/alpha/locore.s b/sys/alpha/alpha/locore.s index f054408..adb481f 100644 --- a/sys/alpha/alpha/locore.s +++ b/sys/alpha/alpha/locore.s @@ -114,10 +114,10 @@ mov v0, globalp /* - * Switch to proc0's PCB, which is at U_PCB off of proc0paddr. + * Switch to proc0's PCB. */ - lda t0,proc0 /* get phys addr of pcb */ - ldq a0,P_MD_PCBPADDR(t0) + ldq t0,thread0 /* get phys addr of pcb */ + ldq a0,TD_MD_PCBPADDR(t0) SWITCH_CONTEXT /* @@ -308,12 +308,6 @@ LEAF(restorefpstate, 1) RET END(restorefpstate) - .data - EXPORT(proc0paddr) - .quad 0 - - .text - /* XXX: make systat/vmstat happy */ .data EXPORT(intrnames) diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 04aa677..10754d3 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -156,7 +156,8 @@ struct bootinfo_kernel bootinfo; struct mtx sched_lock; struct mtx Giant; -struct user *proc0paddr; +struct user *proc0uarea; +vm_offset_t proc0kstack; char machine[] = "alpha"; SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); @@ -887,23 +888,30 @@ alpha_init(pfn, ptb, bim, bip, biv) } + proc_linkup(&proc0); /* * Init mapping for u page(s) for proc 0 */ - proc0.p_addr = proc0paddr = - (struct user *)pmap_steal_memory(UPAGES * PAGE_SIZE); + proc0uarea = (struct user *)pmap_steal_memory(UAREA_PAGES * PAGE_SIZE); + proc0kstack = pmap_steal_memory(KSTACK_PAGES * PAGE_SIZE); + proc0.p_uarea = proc0uarea; + thread0 = &proc0.p_thread; + thread0->td_kstack = proc0kstack; + thread0->td_pcb = (struct pcb *) + (thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; /* * Setup the global data for the bootstrap cpu. */ { - size_t sz = round_page(UPAGES * PAGE_SIZE); + /* This is not a 'struct user' */ + size_t sz = round_page(KSTACK_PAGES * PAGE_SIZE); globalp = (struct globaldata *) pmap_steal_memory(sz); globaldata_init(globalp, alpha_pal_whami(), sz); alpha_pal_wrval((u_int64_t) globalp); PCPU_GET(next_asn) = 1; /* 0 used for proc0 pmap */ #ifdef SMP - proc0.p_md.md_kernnest = 1; + thread0->td_md.md_kernnest = 1; #endif } @@ -921,28 +929,26 @@ alpha_init(pfn, ptb, bim, bip, biv) * Initialize the rest of proc 0's PCB, and cache its physical * address. */ - proc0.p_md.md_pcbpaddr = - (struct pcb *)ALPHA_K0SEG_TO_PHYS((vm_offset_t)&proc0paddr->u_pcb); + thread0->td_md.md_pcbpaddr = + (struct pcb *)ALPHA_K0SEG_TO_PHYS((vm_offset_t)thread0->td_pcb); /* * Set the kernel sp, reserving space for an (empty) trapframe, * and make proc0's trapframe pointer point to it for sanity. */ - proc0paddr->u_pcb.pcb_hw.apcb_ksp = - (u_int64_t)proc0paddr + USPACE - sizeof(struct trapframe); - proc0.p_frame = - (struct trapframe *)proc0paddr->u_pcb.pcb_hw.apcb_ksp; + thread0->td_frame = (struct trapframe *)thread0->td_pcb - 1; + thread0->td_pcb->pcb_hw.apcb_ksp = (u_int64_t)thread0->td_frame; /* * Get the right value for the boot cpu's idle ptbr. */ - globalp->gd_idlepcb.apcb_ptbr = proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr; + globalp->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr; - /* Setup curproc so that mutexes work */ - PCPU_SET(curproc, &proc0); + /* Setup curthread so that mutexes work */ + PCPU_SET(curthread, thread0); PCPU_SET(spinlocks, NULL); - LIST_INIT(&proc0.p_contested); + LIST_INIT(&thread0->td_contested); /* * Initialise mutexes. @@ -1175,13 +1181,16 @@ DELAY(int n) void osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { - struct proc *p = curproc; + struct proc *p; + struct thread *td; osiginfo_t *sip, ksi; struct trapframe *frame; struct sigacts *psp; int oonstack, fsize, rndfsize; - frame = p->p_frame; + td = curthread; + p = td->td_proc; + frame = td->td_frame; oonstack = sigonstack(alpha_pal_rdusp()); fsize = sizeof ksi; rndfsize = ((fsize + 15) / 16) * 16; @@ -1230,16 +1239,16 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) ksi.si_sc.sc_ps = frame->tf_regs[FRAME_PS]; /* copy the registers. */ - fill_regs(p, (struct reg *)ksi.si_sc.sc_regs); + fill_regs(td, (struct reg *)ksi.si_sc.sc_regs); ksi.si_sc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */ ksi.si_sc.sc_regs[R_SP] = alpha_pal_rdusp(); /* save the floating-point state, if necessary, then copy it. */ - alpha_fpstate_save(p, 1); /* XXX maybe write=0 */ - ksi.si_sc.sc_ownedfp = p->p_md.md_flags & MDP_FPUSED; - bcopy(&p->p_addr->u_pcb.pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs, + alpha_fpstate_save(td, 1); /* XXX maybe write=0 */ + ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDP_FPUSED; + bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs, sizeof(struct fpreg)); - ksi.si_sc.sc_fp_control = p->p_addr->u_pcb.pcb_fp_control; + ksi.si_sc.sc_fp_control = td->td_pcb->pcb_fp_control; bzero(ksi.si_sc.sc_reserved, sizeof ksi.si_sc.sc_reserved); /* XXX */ ksi.si_sc.sc_xxx1[0] = 0; /* XXX */ ksi.si_sc.sc_xxx1[1] = 0; /* XXX */ @@ -1279,12 +1288,15 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) void sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { - struct proc *p = curproc; + struct proc *p; + struct thread *td; struct trapframe *frame; struct sigacts *psp; struct sigframe sf, *sfp; int oonstack, rndfsize; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; #ifdef COMPAT_43 @@ -1294,7 +1306,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) } #endif - frame = p->p_frame; + frame = td->td_frame; oonstack = sigonstack(alpha_pal_rdusp()); rndfsize = ((sizeof(sf) + 15) / 16) * 16; @@ -1306,7 +1318,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; - fill_regs(p, (struct reg *)sf.sf_uc.uc_mcontext.mc_regs); + fill_regs(td, (struct reg *)sf.sf_uc.uc_mcontext.mc_regs); sf.sf_uc.uc_mcontext.mc_regs[R_SP] = alpha_pal_rdusp(); sf.sf_uc.uc_mcontext.mc_regs[R_ZERO] = 0xACEDBADE; /* magic number */ sf.sf_uc.uc_mcontext.mc_regs[R_PS] = frame->tf_regs[FRAME_PS]; @@ -1362,12 +1374,12 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) } /* save the floating-point state, if necessary, then copy it. */ - alpha_fpstate_save(p, 1); - sf.sf_uc.uc_mcontext.mc_ownedfp = p->p_md.md_flags & MDP_FPUSED; - bcopy(&p->p_addr->u_pcb.pcb_fp, + alpha_fpstate_save(td, 1); + sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; + bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs, sizeof(struct fpreg)); - sf.sf_uc.uc_mcontext.mc_fp_control = p->p_addr->u_pcb.pcb_fp_control; + sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb->pcb_fp_control; #ifdef COMPAT_OSF1 /* @@ -1428,12 +1440,13 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) */ #ifdef COMPAT_43 int -osigreturn(struct proc *p, +osigreturn(struct thread *td, struct osigreturn_args /* { struct osigcontext *sigcntxp; } */ *uap) { struct osigcontext *scp, ksc; + struct proc *p = td->td_proc; scp = uap->sigcntxp; @@ -1470,25 +1483,25 @@ osigreturn(struct proc *p, SIG_CANTMASK(p->p_sigmask); PROC_UNLOCK(p); - set_regs(p, (struct reg *)ksc.sc_regs); - p->p_frame->tf_regs[FRAME_PC] = ksc.sc_pc; - p->p_frame->tf_regs[FRAME_PS] = + set_regs(td, (struct reg *)ksc.sc_regs); + td->td_frame->tf_regs[FRAME_PC] = ksc.sc_pc; + td->td_frame->tf_regs[FRAME_PS] = (ksc.sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; - p->p_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */ + td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */ alpha_pal_wrusp(ksc.sc_regs[R_SP]); /* XXX ksc.sc_ownedfp ? */ - alpha_fpstate_drop(p); - bcopy((struct fpreg *)ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fp, + alpha_fpstate_drop(td); + bcopy((struct fpreg *)ksc.sc_fpregs, &td->td_pcb->pcb_fp, sizeof(struct fpreg)); - p->p_addr->u_pcb.pcb_fp_control = ksc.sc_fp_control; + td->td_pcb->pcb_fp_control = ksc.sc_fp_control; return (EJUSTRETURN); } #endif int -sigreturn(struct proc *p, +sigreturn(struct thread *td, struct sigreturn_args /* { ucontext_t *sigcntxp; } */ *uap) @@ -1496,14 +1509,16 @@ sigreturn(struct proc *p, ucontext_t uc, *ucp; struct pcb *pcb; unsigned long val; + struct proc *p; #ifdef COMPAT_43 if (((struct osigcontext*)uap->sigcntxp)->sc_regs[R_ZERO] == 0xACEDBADE) - return osigreturn(p, (struct osigreturn_args *)uap); + return osigreturn(td, (struct osigreturn_args *)uap); #endif ucp = uap->sigcntxp; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; + p = td->td_proc; #ifdef DEBUG if (sigdebug & SDB_FOLLOW) @@ -1519,12 +1534,12 @@ sigreturn(struct proc *p, /* * Restore the user-supplied information */ - set_regs(p, (struct reg *)uc.uc_mcontext.mc_regs); + set_regs(td, (struct reg *)uc.uc_mcontext.mc_regs); val = (uc.uc_mcontext.mc_regs[R_PS] | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; - p->p_frame->tf_regs[FRAME_PS] = val; - p->p_frame->tf_regs[FRAME_PC] = uc.uc_mcontext.mc_regs[R_PC]; - p->p_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */ + td->td_frame->tf_regs[FRAME_PS] = val; + td->td_frame->tf_regs[FRAME_PC] = uc.uc_mcontext.mc_regs[R_PC]; + td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */ alpha_pal_wrusp(uc.uc_mcontext.mc_regs[R_SP]); PROC_LOCK(p); @@ -1540,10 +1555,10 @@ sigreturn(struct proc *p, PROC_UNLOCK(p); /* XXX ksc.sc_ownedfp ? */ - alpha_fpstate_drop(p); + alpha_fpstate_drop(td); bcopy((struct fpreg *)uc.uc_mcontext.mc_fpregs, - &p->p_addr->u_pcb.pcb_fp, sizeof(struct fpreg)); - p->p_addr->u_pcb.pcb_fp_control = uc.uc_mcontext.mc_fp_control; + &td->td_pcb->pcb_fp, sizeof(struct fpreg)); + td->td_pcb->pcb_fp_control = uc.uc_mcontext.mc_fp_control; #ifdef DEBUG if (sigdebug & SDB_FOLLOW) @@ -1576,14 +1591,14 @@ cpu_halt(void) * Clear registers on exec */ void -setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) +setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) { - struct trapframe *tfp = p->p_frame; + struct trapframe *tfp = td->td_frame; bzero(tfp->tf_regs, FRAME_SIZE * sizeof tfp->tf_regs[0]); - bzero(&p->p_addr->u_pcb.pcb_fp, sizeof p->p_addr->u_pcb.pcb_fp); - p->p_addr->u_pcb.pcb_fp_control = 0; - p->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL + bzero(&td->td_pcb->pcb_fp, sizeof td->td_pcb->pcb_fp); + td->td_pcb->pcb_fp_control = 0; + td->td_pcb->pcb_fp.fpr_cr = (FPCR_DYN_NORMAL | FPCR_INVD | FPCR_DZED | FPCR_OVFD | FPCR_INED | FPCR_UNFD); @@ -1599,20 +1614,20 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) tfp->tf_regs[FRAME_T12] = tfp->tf_regs[FRAME_PC]; /* a.k.a. PV */ tfp->tf_regs[FRAME_FLAGS] = 0; /* full restore */ - p->p_md.md_flags &= ~MDP_FPUSED; - alpha_fpstate_drop(p); + td->td_md.md_flags &= ~MDP_FPUSED; + alpha_fpstate_drop(td); } int -ptrace_set_pc(struct proc *p, unsigned long addr) +ptrace_set_pc(struct thread *td, unsigned long addr) { - struct trapframe *tp = p->p_frame; + struct trapframe *tp = td->td_frame; tp->tf_regs[FRAME_PC] = addr; return 0; } static int -ptrace_read_int(struct proc *p, vm_offset_t addr, u_int32_t *v) +ptrace_read_int(struct thread *td, vm_offset_t addr, u_int32_t *v) { struct iovec iov; struct uio uio; @@ -1624,12 +1639,12 @@ ptrace_read_int(struct proc *p, vm_offset_t addr, u_int32_t *v) uio.uio_resid = sizeof(u_int32_t); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; - return procfs_domem(curproc, p, NULL, &uio); + uio.uio_td = td; + return procfs_domem(curproc, td->td_proc, NULL, &uio); } static int -ptrace_write_int(struct proc *p, vm_offset_t addr, u_int32_t v) +ptrace_write_int(struct thread *td, vm_offset_t addr, u_int32_t v) { struct iovec iov; struct uio uio; @@ -1641,12 +1656,12 @@ ptrace_write_int(struct proc *p, vm_offset_t addr, u_int32_t v) uio.uio_resid = sizeof(u_int32_t); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_WRITE; - uio.uio_procp = p; - return procfs_domem(curproc, p, NULL, &uio); + uio.uio_td = td; + return procfs_domem(curproc, td->td_proc, NULL, &uio); } static u_int64_t -ptrace_read_register(struct proc *p, int regno) +ptrace_read_register(struct thread *td, int regno) { static int reg_to_frame[32] = { FRAME_V0, @@ -1689,54 +1704,54 @@ ptrace_read_register(struct proc *p, int regno) if (regno == R_ZERO) return 0; - return p->p_frame->tf_regs[reg_to_frame[regno]]; + return td->td_frame->tf_regs[reg_to_frame[regno]]; } static int -ptrace_clear_bpt(struct proc *p, struct mdbpt *bpt) +ptrace_clear_bpt(struct thread *td, struct mdbpt *bpt) { - return ptrace_write_int(p, bpt->addr, bpt->contents); + return ptrace_write_int(td, bpt->addr, bpt->contents); } static int -ptrace_set_bpt(struct proc *p, struct mdbpt *bpt) +ptrace_set_bpt(struct thread *td, struct mdbpt *bpt) { int error; u_int32_t bpins = 0x00000080; - error = ptrace_read_int(p, bpt->addr, &bpt->contents); + error = ptrace_read_int(td, bpt->addr, &bpt->contents); if (error) return error; - return ptrace_write_int(p, bpt->addr, bpins); + return ptrace_write_int(td, bpt->addr, bpins); } int -ptrace_clear_single_step(struct proc *p) +ptrace_clear_single_step(struct thread *td) { - if (p->p_md.md_flags & MDP_STEP2) { - ptrace_clear_bpt(p, &p->p_md.md_sstep[1]); - ptrace_clear_bpt(p, &p->p_md.md_sstep[0]); - p->p_md.md_flags &= ~MDP_STEP2; - } else if (p->p_md.md_flags & MDP_STEP1) { - ptrace_clear_bpt(p, &p->p_md.md_sstep[0]); - p->p_md.md_flags &= ~MDP_STEP1; + if (td->td_md.md_flags & MDP_STEP2) { + ptrace_clear_bpt(td, &td->td_md.md_sstep[1]); + ptrace_clear_bpt(td, &td->td_md.md_sstep[0]); + td->td_md.md_flags &= ~MDP_STEP2; + } else if (td->td_md.md_flags & MDP_STEP1) { + ptrace_clear_bpt(td, &td->td_md.md_sstep[0]); + td->td_md.md_flags &= ~MDP_STEP1; } return 0; } int -ptrace_single_step(struct proc *p) +ptrace_single_step(struct thread *td) { int error; - vm_offset_t pc = p->p_frame->tf_regs[FRAME_PC]; + vm_offset_t pc = td->td_frame->tf_regs[FRAME_PC]; alpha_instruction ins; vm_offset_t addr[2]; /* places to set breakpoints */ int count = 0; /* count of breakpoints */ - if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2)) + if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2)) panic("ptrace_single_step: step breakpoints not removed"); - error = ptrace_read_int(p, pc, &ins.bits); + error = ptrace_read_int(td, pc, &ins.bits); if (error) return error; @@ -1744,7 +1759,7 @@ ptrace_single_step(struct proc *p) case op_j: /* Jump: target is register value */ - addr[0] = ptrace_read_register(p, ins.jump_format.rs) & ~3; + addr[0] = ptrace_read_register(td, ins.jump_format.rs) & ~3; count = 1; break; @@ -1775,20 +1790,20 @@ ptrace_single_step(struct proc *p) count = 1; } - p->p_md.md_sstep[0].addr = addr[0]; - error = ptrace_set_bpt(p, &p->p_md.md_sstep[0]); + td->td_md.md_sstep[0].addr = addr[0]; + error = ptrace_set_bpt(td, &td->td_md.md_sstep[0]); if (error) return error; if (count == 2) { - p->p_md.md_sstep[1].addr = addr[1]; - error = ptrace_set_bpt(p, &p->p_md.md_sstep[1]); + td->td_md.md_sstep[1].addr = addr[1]; + error = ptrace_set_bpt(td, &td->td_md.md_sstep[1]); if (error) { - ptrace_clear_bpt(p, &p->p_md.md_sstep[0]); + ptrace_clear_bpt(td, &td->td_md.md_sstep[0]); return error; } - p->p_md.md_flags |= MDP_STEP2; + td->td_md.md_flags |= MDP_STEP2; } else - p->p_md.md_flags |= MDP_STEP1; + td->td_md.md_flags |= MDP_STEP1; return 0; } @@ -1812,15 +1827,13 @@ alpha_pa_access(vm_offset_t pa) } int -fill_regs(p, regs) - struct proc *p; +fill_regs(td, regs) + struct thread *td; struct reg *regs; { - struct pcb *pcb = &p->p_addr->u_pcb; - struct trapframe *tp = p->p_frame; + struct pcb *pcb = td->td_pcb; + struct trapframe *tp = td->td_frame; - tp = p->p_frame; - #define C(r) regs->r_regs[R_ ## r] = tp->tf_regs[FRAME_ ## r] C(V0); @@ -1839,14 +1852,12 @@ fill_regs(p, regs) } int -set_regs(p, regs) - struct proc *p; +set_regs(td, regs) + struct thread *td; struct reg *regs; { - struct pcb *pcb = &p->p_addr->u_pcb; - struct trapframe *tp = p->p_frame; - - tp = p->p_frame; + struct pcb *pcb = td->td_pcb; + struct trapframe *tp = td->td_frame; #define C(r) tp->tf_regs[FRAME_ ## r] = regs->r_regs[R_ ## r] @@ -1866,24 +1877,24 @@ set_regs(p, regs) } int -fill_fpregs(p, fpregs) - struct proc *p; +fill_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - alpha_fpstate_save(p, 0); + alpha_fpstate_save(td, 0); - bcopy(&p->p_addr->u_pcb.pcb_fp, fpregs, sizeof *fpregs); + bcopy(&td->td_pcb->pcb_fp, fpregs, sizeof *fpregs); return (0); } int -set_fpregs(p, fpregs) - struct proc *p; +set_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - alpha_fpstate_drop(p); + alpha_fpstate_drop(td); - bcopy(fpregs, &p->p_addr->u_pcb.pcb_fp, sizeof *fpregs); + bcopy(fpregs, &td->td_pcb->pcb_fp, sizeof *fpregs); return (0); } @@ -1976,27 +1987,27 @@ SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock, CTLFLAG_RW, &wall_cmos_clock, 0, ""); void -alpha_fpstate_check(struct proc *p) +alpha_fpstate_check(struct thread *td) { /* - * For SMP, we should check the fpcurproc of each cpu. + * For SMP, we should check the fpcurthread of each cpu. */ #ifndef SMP critical_t s; s = critical_enter(); - if (p->p_addr->u_pcb.pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN) - if (p != PCPU_GET(fpcurproc)) - panic("alpha_check_fpcurproc: bogus"); + if (td->td_pcb->pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN) + if (td != PCPU_GET(fpcurthread)) + panic("alpha_check_fpcurthread: bogus"); critical_exit(s); #endif } -#define SET_FEN(p) \ - (p)->p_addr->u_pcb.pcb_hw.apcb_flags |= ALPHA_PCB_FLAGS_FEN +#define SET_FEN(td) \ + (td)->td_pcb->pcb_hw.apcb_flags |= ALPHA_PCB_FLAGS_FEN -#define CLEAR_FEN(p) \ - (p)->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN +#define CLEAR_FEN(td) \ + (td)->td_pcb->pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN /* * Save the floating point state in the pcb. Use this to get read-only @@ -2006,14 +2017,14 @@ alpha_fpstate_check(struct proc *p) * FEN trap. */ void -alpha_fpstate_save(struct proc *p, int write) +alpha_fpstate_save(struct thread *td, int write) { critical_t s; s = critical_enter(); - if (p != NULL && p == PCPU_GET(fpcurproc)) { + if (td != NULL && td == PCPU_GET(fpcurthread)) { /* - * If curproc != fpcurproc, then we need to enable FEN + * If curthread != fpcurthread, then we need to enable FEN * so that we can dump the fp state. */ alpha_pal_wrfen(1); @@ -2021,27 +2032,27 @@ alpha_fpstate_save(struct proc *p, int write) /* * Save the state in the pcb. */ - savefpstate(&p->p_addr->u_pcb.pcb_fp); + savefpstate(&td->td_pcb->pcb_fp); if (write) { /* - * If fpcurproc == curproc, just ask the + * If fpcurthread == curthread, just ask the * PALcode to disable FEN, otherwise we must - * clear the FEN bit in fpcurproc's pcb. + * clear the FEN bit in fpcurthread's pcb. */ - if (PCPU_GET(fpcurproc) == curproc) + if (PCPU_GET(fpcurthread) == curthread) alpha_pal_wrfen(0); else - CLEAR_FEN(PCPU_GET(fpcurproc)); - PCPU_SET(fpcurproc, NULL); + CLEAR_FEN(PCPU_GET(fpcurthread)); + PCPU_SET(fpcurthread, NULL); } else { /* * Make sure that we leave FEN enabled if - * curproc == fpcurproc. We must have at most + * curthread == fpcurthread. We must have at most * one process with FEN enabled. Note that FEN - * must already be set in fpcurproc's pcb. + * must already be set in fpcurthread's pcb. */ - if (curproc != PCPU_GET(fpcurproc)) + if (curthread != PCPU_GET(fpcurthread)) alpha_pal_wrfen(0); } } @@ -2054,13 +2065,13 @@ alpha_fpstate_save(struct proc *p, int write) * (e.g. on sigreturn). */ void -alpha_fpstate_drop(struct proc *p) +alpha_fpstate_drop(struct thread *td) { critical_t s; s = critical_enter(); - if (p == PCPU_GET(fpcurproc)) { - if (p == curproc) { + if (td == PCPU_GET(fpcurthread)) { + if (td == curthread) { /* * Disable FEN via the PALcode. This will * clear the bit in the pcb as well. @@ -2070,9 +2081,9 @@ alpha_fpstate_drop(struct proc *p) /* * Clear the FEN bit of the pcb. */ - CLEAR_FEN(p); + CLEAR_FEN(td); } - PCPU_SET(fpcurproc, NULL); + PCPU_SET(fpcurthread, NULL); } critical_exit(s); } @@ -2082,7 +2093,7 @@ alpha_fpstate_drop(struct proc *p) * from the pcb. */ void -alpha_fpstate_switch(struct proc *p) +alpha_fpstate_switch(struct thread *td) { critical_t s; @@ -2091,31 +2102,31 @@ alpha_fpstate_switch(struct proc *p) */ s = critical_enter(); alpha_pal_wrfen(1); - if (PCPU_GET(fpcurproc)) { + if (PCPU_GET(fpcurthread)) { /* * Dump the old fp state if its valid. */ - savefpstate(&PCPU_GET(fpcurproc)->p_addr->u_pcb.pcb_fp); - CLEAR_FEN(PCPU_GET(fpcurproc)); + savefpstate(&PCPU_GET(fpcurthread)->td_pcb->pcb_fp); + CLEAR_FEN(PCPU_GET(fpcurthread)); } /* * Remember the new FP owner and reload its state. */ - PCPU_SET(fpcurproc, p); - restorefpstate(&PCPU_GET(fpcurproc)->p_addr->u_pcb.pcb_fp); + PCPU_SET(fpcurthread, td); + restorefpstate(&PCPU_GET(fpcurthread)->td_pcb->pcb_fp); /* - * If the new owner is curproc, leave FEN enabled, otherwise + * If the new owner is curthread, leave FEN enabled, otherwise * mark its PCB so that it gets FEN when we context switch to * it later. */ - if (p != curproc) { + if (td != curthread) { alpha_pal_wrfen(0); - SET_FEN(p); + SET_FEN(td); } - p->p_md.md_flags |= MDP_FPUSED; + td->td_md.md_flags |= MDP_FPUSED; critical_exit(s); } @@ -2129,7 +2140,7 @@ globaldata_init(struct globaldata *globaldata, int cpuid, size_t sz) globaldata->gd_idlepcbphys = vtophys((vm_offset_t) &globaldata->gd_idlepcb); globaldata->gd_idlepcb.apcb_ksp = (u_int64_t) ((caddr_t) globaldata + sz - sizeof(struct trapframe)); - globaldata->gd_idlepcb.apcb_ptbr = proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr; + globaldata->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr; globaldata->gd_cpuid = cpuid; globaldata->gd_next_asn = 0; globaldata->gd_current_asngen = 1; diff --git a/sys/alpha/alpha/mem.c b/sys/alpha/alpha/mem.c index 6af53c4..13bbeb1 100644 --- a/sys/alpha/alpha/mem.c +++ b/sys/alpha/alpha/mem.c @@ -100,12 +100,12 @@ static struct cdevsw mem_cdevsw = { struct mem_range_softc mem_range_softc; static int -mmclose(dev_t dev, int flags, int fmt, struct proc *p) +mmclose(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { #ifdef PERFMON case 32: - return perfmon_close(dev, flags, fmt, p); + return perfmon_close(dev, flags, fmt, td); #endif default: break; @@ -114,7 +114,7 @@ mmclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -mmopen(dev_t dev, int flags, int fmt, struct proc *p) +mmopen(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { @@ -125,7 +125,7 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p) break; case 32: #ifdef PERFMON - return perfmon_open(dev, flags, fmt, p); + return perfmon_open(dev, flags, fmt, td); #else return ENODEV; #endif @@ -240,12 +240,12 @@ memmmap(dev_t dev, vm_offset_t offset, int prot) } static int -mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct proc *p) +mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct thread *td) { switch(minor(dev)) { #ifdef PERFMON case 32: - return perfmon_ioctl(dev, cmd, cmdarg, flags, p); + return perfmon_ioctl(dev, cmd, cmdarg, flags, td); #endif default: return ENODEV; diff --git a/sys/alpha/alpha/mp_machdep.c b/sys/alpha/alpha/mp_machdep.c index 7ae77d5..d1324e7 100644 --- a/sys/alpha/alpha/mp_machdep.c +++ b/sys/alpha/alpha/mp_machdep.c @@ -158,7 +158,7 @@ smp_init_secondary(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* @@ -175,12 +175,12 @@ smp_init_secondary(void) * * cache idleproc's physical address. */ - curproc->p_md.md_pcbpaddr = (struct pcb *)PCPU_GET(idlepcbphys); + curthread->td_md.md_pcbpaddr = (struct pcb *)PCPU_GET(idlepcbphys); /* * and make idleproc's trapframe pointer point to its * stack pointer for sanity. */ - curproc->p_frame = + curthread->td_frame = (struct trapframe *)globalp->gd_idlepcb.apcb_ksp; mtx_lock_spin(&ap_boot_mtx); @@ -232,7 +232,7 @@ smp_start_secondary(int cpuid) if (bootverbose) printf("smp_start_secondary: starting cpu %d\n", cpuid); - sz = round_page(UPAGES * PAGE_SIZE); + sz = round_page((UAREA_PAGES + KSTACK_PAGES) * PAGE_SIZE); globaldata = malloc(sz, M_TEMP, M_NOWAIT); if (!globaldata) { printf("smp_start_secondary: can't allocate memory\n"); diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c index eed5e5e..c03d3dd 100644 --- a/sys/alpha/alpha/pmap.c +++ b/sys/alpha/alpha/pmap.c @@ -337,7 +337,7 @@ static pmap_t pmap_active[MAXCPU]; static vm_zone_t pvzone; static struct vm_zone pvzone_store; static struct vm_object pvzone_obj; -static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0; +static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; static int pmap_pagedaemon_waken = 0; static struct pv_entry *pvinit; @@ -564,9 +564,9 @@ pmap_bootstrap(vm_offset_t ptaddr, u_int maxasn) * Set up proc0's PCB such that the ptbr points to the right place * and has the kernel pmap's. */ - proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr = + thread0->td_pcb->pcb_hw.apcb_ptbr = ALPHA_K0SEG_TO_PHYS((vm_offset_t)Lev1map) >> PAGE_SHIFT; - proc0.p_addr->u_pcb.pcb_hw.apcb_asn = 0; + thread0->td_pcb->pcb_hw.apcb_asn = 0; } int @@ -934,22 +934,22 @@ pmap_new_proc(struct proc *p) */ upobj = p->p_upages_obj; if (upobj == NULL) { - upobj = vm_object_allocate(OBJT_DEFAULT, UPAGES); + upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES); p->p_upages_obj = upobj; } /* get a kernel virtual address for the UPAGES for this proc */ - up = (vm_offset_t)p->p_addr; + up = (vm_offset_t)p->p_uarea; if (up == 0) { - up = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); + up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE); if (up == 0) panic("pmap_new_proc: upage allocation failed"); - p->p_addr = (struct user *)up; + p->p_uarea = (struct user *)up; } ptek = vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { /* * Get a kernel stack page */ @@ -992,9 +992,9 @@ pmap_dispose_proc(p) pt_entry_t *ptek, oldpte; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; + up = (vm_offset_t)p->p_uarea; ptek = vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_dispose_proc: upage already missing?"); @@ -1019,14 +1019,9 @@ pmap_swapout_proc(p) vm_offset_t up; vm_page_t m; - /* - * Make sure we aren't fpcurproc. - */ - alpha_fpstate_save(p, 1); - upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_swapout_proc: upage already missing?"); @@ -1049,8 +1044,8 @@ pmap_swapin_proc(p) vm_page_t m; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); if (m->valid != VM_PAGE_BITS_ALL) { @@ -1064,12 +1059,180 @@ pmap_swapin_proc(p) vm_page_wakeup(m); vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); } +} + +/* + * Create the kernel stack for a new thread. + * This routine directly affects the fork perf for a process and thread. + */ +void +pmap_new_thread(struct thread *td) +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + pt_entry_t *ptek, oldpte; + + /* + * allocate object for the upages + */ + ksobj = td->td_kstack_obj; + if (ksobj == NULL) { + ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES); + td->td_kstack_obj = ksobj; + } + +#ifdef KSTACK_GUARD + /* get a kernel virtual address for the kstack for this thread */ + ks = td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, + (KSTACK_PAGES + 1) * PAGE_SIZE); + if (ks == NULL) + panic("pmap_new_thread: kstack allocation failed"); + ks += PAGE_SIZE; + td->td_kstack = ks; + } + + ptek = vtopte(ks - PAGE_SIZE); + oldpte = *ptek; + *ptek = 0; + if (oldpte) + pmap_invalidate_page(kernel_pmap, ks - PAGE_SIZE); + ptek++; +#else + /* get a kernel virtual address for the kstack for this thread */ + ks = td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE); + if (ks == NULL) + panic("pmap_new_thread: kstack allocation failed"); + td->td_kstack = ks; + } + ptek = vtopte(ks); +#endif + for (i = 0; i < KSTACK_PAGES; i++) { + /* + * Get a kernel stack page + */ + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + + /* + * Wire the page + */ + m->wire_count++; + cnt.v_wire_count++; + + oldpte = *(ptek + i); + /* + * Enter the page into the kernel address space. + */ + *(ptek + i) = pmap_phys_to_pte(VM_PAGE_TO_PHYS(m)) + | PG_ASM | PG_KRE | PG_KWE | PG_V; + if (oldpte) + pmap_invalidate_page(kernel_pmap, ks + i * PAGE_SIZE); + + vm_page_wakeup(m); + vm_page_flag_clear(m, PG_ZERO); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + m->valid = VM_PAGE_BITS_ALL; + } +} + +/* + * Dispose the kernel stack for a thread that has exited. + * This routine directly impacts the exit perf of a thread. + */ +void +pmap_dispose_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + pt_entry_t *ptek, oldpte; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + ptek = vtopte(ks); + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_dispose_thread: kstack already missing?"); + vm_page_busy(m); + oldpte = *(ptek + i); + *(ptek + i) = 0; + pmap_invalidate_page(kernel_pmap, ks + i * PAGE_SIZE); + vm_page_unwire(m, 0); + vm_page_free(m); + } +} + +/* + * Allow the kernel stack for a thread to be prejudicially paged out. + */ +void +pmap_swapout_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + /* + * Make sure we aren't fpcurthread. + */ + alpha_fpstate_save(td, 1); + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_swapout_thread: kstack already missing?"); + vm_page_dirty(m); + vm_page_unwire(m, 0); + pmap_kremove(ks + i * PAGE_SIZE); + } +} + +/* + * Bring the kernel stack for a specified thread back in. + */ +void +pmap_swapin_thread(td) + struct thread *td; +{ + int i, rv; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); + if (m->valid != VM_PAGE_BITS_ALL) { + rv = vm_pager_get_pages(ksobj, &m, 1, 0); + if (rv != VM_PAGER_OK) + panic("pmap_swapin_thread: cannot get kstack for proc: %d\n", td->td_proc->p_pid); + m = vm_page_lookup(ksobj, i); + m->valid = VM_PAGE_BITS_ALL; + } + vm_page_wire(m); + vm_page_wakeup(m); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + } /* * The pcb may be at a different physical address now so cache the * new address. */ - p->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p->p_addr->u_pcb); + td->td_md.md_pcbpaddr = (void *)vtophys((vm_offset_t)td->td_pcb); } /*************************************************** @@ -1677,7 +1840,7 @@ pmap_collect() { int i; vm_page_t m; - static int warningdone=0; + static int warningdone = 0; if (pmap_pagedaemon_waken == 0) return; @@ -2917,7 +3080,7 @@ pmap_clear_reference(vm_page_t m) * From NetBSD */ void -pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write) +pmap_emulate_reference(struct vmspace *vm, vm_offset_t v, int user, int write) { pt_entry_t faultoff, *pte; vm_offset_t pa; @@ -2932,9 +3095,8 @@ pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write) pte = vtopte(v); user_addr = 0; } else { - KASSERT(p != NULL, ("pmap_emulate_reference: bad proc")); - KASSERT(p->p_vmspace != NULL, ("pmap_emulate_reference: bad p_vmspace")); - pte = pmap_lev3pte(p->p_vmspace->vm_map.pmap, v); + KASSERT(vm != NULL, ("pmap_emulate_reference: bad vmspace")); + pte = pmap_lev3pte(vm->vm_map.pmap, v); user_addr = 1; } #ifdef DEBUG /* These checks are more expensive */ @@ -2964,7 +3126,7 @@ pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write) KASSERT((*pte & PG_MANAGED) != 0, ("pmap_emulate_reference(%p, 0x%lx, %d, %d): pa 0x%lx not managed", - p, v, user, write, pa)); + curthread, v, user, write, pa)); /* * Twiddle the appropriate bits to reflect the reference @@ -3092,11 +3254,11 @@ pmap_mincore(pmap, addr) } void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { pmap_t pmap; - pmap = vmspace_pmap(p->p_vmspace); + pmap = vmspace_pmap(td->td_proc->p_vmspace); if (pmap_active[PCPU_GET(cpuid)] && pmap != pmap_active[PCPU_GET(cpuid)]) { atomic_clear_32(&pmap_active[PCPU_GET(cpuid)]->pm_active, @@ -3104,7 +3266,7 @@ pmap_activate(struct proc *p) pmap_active[PCPU_GET(cpuid)] = 0; } - p->p_addr->u_pcb.pcb_hw.apcb_ptbr = + td->td_pcb->pcb_hw.apcb_ptbr = ALPHA_K0SEG_TO_PHYS((vm_offset_t) pmap->pm_lev1) >> PAGE_SHIFT; if (pmap->pm_asn[PCPU_GET(cpuid)].gen != PCPU_GET(current_asngen)) @@ -3113,18 +3275,19 @@ pmap_activate(struct proc *p) pmap_active[PCPU_GET(cpuid)] = pmap; atomic_set_32(&pmap->pm_active, 1 << PCPU_GET(cpuid)); - p->p_addr->u_pcb.pcb_hw.apcb_asn = pmap->pm_asn[PCPU_GET(cpuid)].asn; + td->td_pcb->pcb_hw.apcb_asn = pmap->pm_asn[PCPU_GET(cpuid)].asn; - if (p == curproc) { - alpha_pal_swpctx((u_long)p->p_md.md_pcbpaddr); + if (td == curthread) { + alpha_pal_swpctx((u_long)td->td_md.md_pcbpaddr); } } void -pmap_deactivate(struct proc *p) +pmap_deactivate(struct thread *td) { pmap_t pmap; - pmap = vmspace_pmap(p->p_vmspace); + + pmap = vmspace_pmap(td->td_proc->p_vmspace); atomic_clear_32(&pmap->pm_active, 1 << PCPU_GET(cpuid)); pmap_active[PCPU_GET(cpuid)] = 0; } @@ -3154,14 +3317,14 @@ pmap_pid_dump(int pid) int i,j; index = 0; pmap = vmspace_pmap(p->p_vmspace); - for(i=0;i<1024;i++) { + for (i = 0; i < 1024; i++) { pd_entry_t *pde; pt_entry_t *pte; unsigned base = i << PDRSHIFT; pde = &pmap->pm_pdir[i]; if (pde && pmap_pde_v(pde)) { - for(j=0;j<1024;j++) { + for (j = 0; j < 1024; j++) { unsigned va = base + (j << PAGE_SHIFT); if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) { if (index) { diff --git a/sys/alpha/alpha/procfs_machdep.c b/sys/alpha/alpha/procfs_machdep.c index 96fd0e5..ae7fa10 100644 --- a/sys/alpha/alpha/procfs_machdep.c +++ b/sys/alpha/alpha/procfs_machdep.c @@ -85,7 +85,7 @@ int error; \ \ mtx_lock_spin(&sched_lock); \ - if ((p->p_sflag & PS_INMEM) == 0) \ + if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ error = EIO; \ else \ error = (action); \ @@ -94,21 +94,21 @@ } while(0) int -procfs_read_regs(p, regs) - struct proc *p; +procfs_read_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(fill_regs(p, regs)); + PROCFS_ACTION(fill_regs(td, regs)); } int -procfs_write_regs(p, regs) - struct proc *p; +procfs_write_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(set_regs(p, regs)); + PROCFS_ACTION(set_regs(td, regs)); } /* @@ -117,26 +117,26 @@ procfs_write_regs(p, regs) */ int -procfs_read_fpregs(p, fpregs) - struct proc *p; +procfs_read_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(fill_fpregs(p, fpregs)); + PROCFS_ACTION(fill_fpregs(td, fpregs)); } int -procfs_write_fpregs(p, fpregs) - struct proc *p; +procfs_write_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(set_fpregs(p, fpregs)); + PROCFS_ACTION(set_fpregs(td, fpregs)); } int -procfs_sstep(p) - struct proc *p; +procfs_sstep(td) + struct thread *td; { return (EINVAL); } @@ -145,16 +145,16 @@ procfs_sstep(p) * Placeholders */ int -procfs_read_dbregs(p, dbregs) - struct proc *p; +procfs_read_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { return (EIO); } int -procfs_write_dbregs(p, dbregs) - struct proc *p; +procfs_write_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { return (EIO); diff --git a/sys/alpha/alpha/prom.c b/sys/alpha/alpha/prom.c index 887f991..54d913a 100644 --- a/sys/alpha/alpha/prom.c +++ b/sys/alpha/alpha/prom.c @@ -315,8 +315,8 @@ hwrpb_restart_setup() p = (struct pcs *)((char *)hwrpb + hwrpb->rpb_pcs_off); p->pcs_flags &= ~PCS_BIP; - bcopy(&proc0.p_addr->u_pcb.pcb_hw, p->pcs_hwpcb, - sizeof proc0.p_addr->u_pcb.pcb_hw); + bcopy(&thread0->td_pcb->pcb_hw, p->pcs_hwpcb, + sizeof thread0->td_pcb->pcb_hw); hwrpb->rpb_vptb = VPTBASE; /* when 'c'ontinuing from console halt, do a dump */ diff --git a/sys/alpha/alpha/promcons.c b/sys/alpha/alpha/promcons.c index fa0511d..e95d951 100644 --- a/sys/alpha/alpha/promcons.c +++ b/sys/alpha/alpha/promcons.c @@ -92,10 +92,10 @@ int promparam __P((struct tty *, struct termios *)); void promstop __P((struct tty *, int)); int -promopen(dev, flag, mode, p) +promopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { struct tty *tp; int unit = minor(dev); @@ -124,7 +124,7 @@ promopen(dev, flag, mode, p) ttsetwater(tp); setuptimeout = 1; - } else if ((tp->t_state & TS_XCLUDE) && suser(p)) { + } else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) { splx(s); return EBUSY; } @@ -143,10 +143,10 @@ promopen(dev, flag, mode, p) } int -promclose(dev, flag, mode, p) +promclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { int unit = minor(dev); struct tty *tp = prom_tp; @@ -161,12 +161,12 @@ promclose(dev, flag, mode, p) } int -promioctl(dev, cmd, data, flag, p) +promioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { int unit = minor(dev); struct tty *tp = prom_tp; @@ -175,7 +175,7 @@ promioctl(dev, cmd, data, flag, p) if (unit != 0) return ENXIO; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; error = ttioctl(tp, cmd, data, flag); diff --git a/sys/alpha/alpha/support.s b/sys/alpha/alpha/support.s index 6c42b81..61c692e 100644 --- a/sys/alpha/alpha/support.s +++ b/sys/alpha/alpha/support.s @@ -72,13 +72,13 @@ beq t1, fusufault lda t0, fusufault /* trap faults */ - ldq t2, GD_CURPROC(globalp) - ldq t2, P_ADDR(t2) - stq t0, U_PCB_ONFAULT(t2) + ldq t2, GD_CURTHREAD(globalp) + ldq t2, TD_PCB(t2) + stq t0, PCB_ONFAULT(t2) stq a1, 0(a0) /* try the store */ - stq zero, U_PCB_ONFAULT(t2) /* clean up */ + stq zero, PCB_ONFAULT(t2) /* clean up */ mov zero, v0 RET @@ -92,9 +92,9 @@ beq t1, fusufault lda t0, fusufault /* trap faults */ - ldq t2, GD_CURPROC(globalp) - ldq t2, P_ADDR(t2) - stq t0, U_PCB_ONFAULT(t2) + ldq t2, GD_CURTHREAD(globalp) + ldq t2, TD_PCB(t2) + stq t0, PCB_ONFAULT(t2) zap a1, 0xfe, a1 /* mask off the byte to store */ insbl a1, a0, a1 /* shift it to the right place */ @@ -103,7 +103,7 @@ or a1, t0, a1 /* move it in */ stq_u a1, 0(a0) /* and put the byte back */ - stq zero, U_PCB_ONFAULT(t2) /* clean up */ + stq zero, PCB_ONFAULT(t2) /* clean up */ mov zero, v0 RET @@ -117,13 +117,13 @@ beq t1, fusufault lda t0, fusufault /* trap faults */ - ldq t2, GD_CURPROC(globalp) - ldq t2, P_ADDR(t2) - stq t0, U_PCB_ONFAULT(t2) + ldq t2, GD_CURTHREAD(globalp) + ldq t2, TD_PCB(t2) + stq t0, PCB_ONFAULT(t2) ldq v0, 0(a0) /* try the fetch */ - stq zero, U_PCB_ONFAULT(t2) /* clean up */ + stq zero, PCB_ONFAULT(t2) /* clean up */ RET END(fuword) @@ -136,14 +136,14 @@ beq t1, fusufault lda t0, fusufault /* trap faults */ - ldq t2, GD_CURPROC(globalp) - ldq t2, P_ADDR(t2) - stq t0, U_PCB_ONFAULT(t2) + ldq t2, GD_CURTHREAD(globalp) + ldq t2, TD_PCB(t2) + stq t0, PCB_ONFAULT(t2) ldq_u v0, 0(a0) /* get the word containing our byte */ extbl v0, a0, v0 /* extract the byte */ - stq zero, U_PCB_ONFAULT(t2) /* clean up */ + stq zero, PCB_ONFAULT(t2) /* clean up */ RET END(fubyte) @@ -154,9 +154,9 @@ END(suibyte) LEAF(fusufault, 0) - ldq t0, GD_CURPROC(globalp) - ldq t0, P_ADDR(t0) - stq zero, U_PCB_ONFAULT(t0) + ldq t0, GD_CURTHREAD(globalp) + ldq t0, TD_PCB(t0) + stq zero, PCB_ONFAULT(t0) ldiq v0, -1 RET END(fusufault) @@ -222,15 +222,15 @@ NESTED(copyinstr, 4, 16, ra, 0, 0) beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat - ldq at_reg, GD_CURPROC(globalp) - ldq at_reg, P_ADDR(at_reg) - stq v0, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) + ldq at_reg, TD_PCB(at_reg) + stq v0, PCB_ONFAULT(at_reg) .set at CALL(copystr) /* do the copy. */ .set noat - ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */ - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */ + ldq at_reg, TD_PCB(at_reg) + stq zero, PCB_ONFAULT(at_reg) .set at ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ @@ -246,15 +246,15 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0) beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat - ldq at_reg, GD_CURPROC(globalp) - ldq at_reg, P_ADDR(at_reg) - stq v0, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) + ldq at_reg, TD_PCB(at_reg) + stq v0, PCB_ONFAULT(at_reg) .set at CALL(copystr) /* do the copy. */ .set noat - ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */ - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */ + ldq at_reg, TD_PCB(at_reg) + stq zero, PCB_ONFAULT(at_reg) .set at ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ @@ -514,15 +514,15 @@ NESTED(copyin, 3, 16, ra, 0, 0) beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat - ldq at_reg, GD_CURPROC(globalp) - ldq at_reg, P_ADDR(at_reg) - stq v0, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) + ldq at_reg, TD_PCB(at_reg) + stq v0, PCB_ONFAULT(at_reg) .set at CALL(bcopy) /* do the copy. */ .set noat - ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */ - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */ + ldq at_reg, TD_PCB(at_reg) + stq zero, PCB_ONFAULT(at_reg) .set at ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ @@ -539,15 +539,15 @@ NESTED(copyout, 3, 16, ra, 0, 0) beq t1, copyerr /* if it's not, error out. */ lda v0, copyerr /* set up fault handler. */ .set noat - ldq at_reg, GD_CURPROC(globalp) - ldq at_reg, P_ADDR(at_reg) - stq v0, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) + ldq at_reg, TD_PCB(at_reg) + stq v0, PCB_ONFAULT(at_reg) .set at CALL(bcopy) /* do the copy. */ .set noat - ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */ - ldq at_reg, P_ADDR(at_reg) - stq zero, U_PCB_ONFAULT(at_reg) + ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */ + ldq at_reg, TD_PCB(at_reg) + stq zero, PCB_ONFAULT(at_reg) .set at ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ @@ -556,9 +556,9 @@ NESTED(copyout, 3, 16, ra, 0, 0) END(copyout) LEAF(copyerr, 0) - ldq t0, GD_CURPROC(globalp) - ldq t0, P_ADDR(t0) - stq zero, U_PCB_ONFAULT(t0) /* reset fault handler. */ + ldq t0, GD_CURTHREAD(globalp) + ldq t0, TD_PCB(t0) + stq zero, PCB_ONFAULT(t0) /* reset fault handler. */ ldq ra, (16-8)(sp) /* restore ra. */ lda sp, 16(sp) /* kill stack frame. */ ldiq v0, EFAULT /* return EFAULT. */ diff --git a/sys/alpha/alpha/swtch.s b/sys/alpha/alpha/swtch.s index 0d244fc..79454c5 100644 --- a/sys/alpha/alpha/swtch.s +++ b/sys/alpha/alpha/swtch.s @@ -49,13 +49,13 @@ /* * savectx: save process context, i.e. callee-saved registers * - * Note that savectx() only works for processes other than curproc, + * Note that savectx() only works for processes other than curthread, * since cpu_switch will copy over the info saved here. (It _can_ - * sanely be used for curproc iff cpu_switch won't be called again, e.g. + * sanely be used for curthread iff cpu_switch won't be called again, e.g. * from if called from boot().) * * Arguments: - * a0 'struct user *' of the process that needs its context saved + * a0 'struct pcb *' of the process that needs its context saved * * Return: * v0 0. (note that for child processes, it seems @@ -66,17 +66,17 @@ LEAF(savectx, 1) br pv, Lsavectx1 Lsavectx1: LDGP(pv) - stq sp, U_PCB_HWPCB_KSP(a0) /* store sp */ - stq s0, U_PCB_CONTEXT+(0 * 8)(a0) /* store s0 - s6 */ - stq s1, U_PCB_CONTEXT+(1 * 8)(a0) - stq s2, U_PCB_CONTEXT+(2 * 8)(a0) - stq s3, U_PCB_CONTEXT+(3 * 8)(a0) - stq s4, U_PCB_CONTEXT+(4 * 8)(a0) - stq s5, U_PCB_CONTEXT+(5 * 8)(a0) - stq s6, U_PCB_CONTEXT+(6 * 8)(a0) - stq ra, U_PCB_CONTEXT+(7 * 8)(a0) /* store ra */ + stq sp, PCB_HWPCB_KSP(a0) /* store sp */ + stq s0, PCB_CONTEXT+(0 * 8)(a0) /* store s0 - s6 */ + stq s1, PCB_CONTEXT+(1 * 8)(a0) + stq s2, PCB_CONTEXT+(2 * 8)(a0) + stq s3, PCB_CONTEXT+(3 * 8)(a0) + stq s4, PCB_CONTEXT+(4 * 8)(a0) + stq s5, PCB_CONTEXT+(5 * 8)(a0) + stq s6, PCB_CONTEXT+(6 * 8)(a0) + stq ra, PCB_CONTEXT+(7 * 8)(a0) /* store ra */ call_pal PAL_OSF1_rdps /* NOTE: doesn't kill a0 */ - stq v0, U_PCB_CONTEXT+(8 * 8)(a0) /* store ps, for ipl */ + stq v0, PCB_CONTEXT+(8 * 8)(a0) /* store ps, for ipl */ mov zero, v0 RET @@ -103,49 +103,49 @@ LEAF(cpu_throw, 0) LEAF(cpu_switch, 1) LDGP(pv) /* do an inline savectx(), to save old context */ - ldq a0, GD_CURPROC(globalp) - ldq a1, P_ADDR(a0) + ldq a0, GD_CURTHREAD(globalp) + ldq a1, TD_PCB(a0) /* NOTE: ksp is stored by the swpctx */ - stq s0, U_PCB_CONTEXT+(0 * 8)(a1) /* store s0 - s6 */ - stq s1, U_PCB_CONTEXT+(1 * 8)(a1) - stq s2, U_PCB_CONTEXT+(2 * 8)(a1) - stq s3, U_PCB_CONTEXT+(3 * 8)(a1) - stq s4, U_PCB_CONTEXT+(4 * 8)(a1) - stq s5, U_PCB_CONTEXT+(5 * 8)(a1) - stq s6, U_PCB_CONTEXT+(6 * 8)(a1) - stq ra, U_PCB_CONTEXT+(7 * 8)(a1) /* store ra */ + stq s0, PCB_CONTEXT+(0 * 8)(a1) /* store s0 - s6 */ + stq s1, PCB_CONTEXT+(1 * 8)(a1) + stq s2, PCB_CONTEXT+(2 * 8)(a1) + stq s3, PCB_CONTEXT+(3 * 8)(a1) + stq s4, PCB_CONTEXT+(4 * 8)(a1) + stq s5, PCB_CONTEXT+(5 * 8)(a1) + stq s6, PCB_CONTEXT+(6 * 8)(a1) + stq ra, PCB_CONTEXT+(7 * 8)(a1) /* store ra */ call_pal PAL_OSF1_rdps /* NOTE: doesn't kill a0 */ - stq v0, U_PCB_CONTEXT+(8 * 8)(a1) /* store ps, for ipl */ + stq v0, PCB_CONTEXT+(8 * 8)(a1) /* store ps, for ipl */ - mov a0, s0 /* save old curproc */ - mov a1, s1 /* save old U-area */ + mov a0, s0 /* s0 = old curthread */ + mov a1, s1 /* s1 = old pcb */ sw1: br pv, Lcs1 Lcs1: LDGP(pv) - CALL(chooseproc) /* can't return NULL */ - mov v0, s2 - ldq s3, P_MD_PCBPADDR(s2) /* save new pcbpaddr */ + CALL(choosethread) /* can't return NULL */ + mov v0, s2 /* s2 = new thread */ + ldq s3, TD_MD_PCBPADDR(s2) /* s3 = new pcbpaddr */ /* * Check to see if we're switching to ourself. If we are, * don't bother loading the new context. * * Note that even if we re-enter cpu_switch() from idle(), - * s0 will still contain the old curproc value because any + * s0 will still contain the old curthread value because any * users of that register between then and now must have * saved it. Also note that switch_exit() ensures that * s0 is clear before jumping here to find a new process. */ - cmpeq s0, s2, t0 /* oldproc == newproc? */ + cmpeq s0, s2, t0 /* oldthread == newthread? */ bne t0, Lcs7 /* Yes! Skip! */ #ifdef SMP /* * Save fp state if we have some. */ - mov s0, a0 /* curproc */ - ldiq a1, 1 /* clear fpcurproc */ + mov s0, a0 /* curthread */ + ldiq a1, 1 /* clear fpcurthread */ CALL(alpha_fpstate_save) #endif @@ -165,8 +165,8 @@ Lcs1: LDGP(pv) */ beq s0, Lcs6 - mov s0, a0 /* pmap_deactivate(oldproc) */ - CALL(pmap_deactivate) + mov s0, a0 /* pmap_deactivate(oldthread) */ + CALL(pmap_deactivate) /* XXXKSE */ Lcs6: /* @@ -174,8 +174,8 @@ Lcs6: * the actual context swap. */ - mov s2, a0 /* pmap_activate(p) */ - CALL(pmap_activate) + mov s2, a0 /* pmap_activate(newthread) */ + CALL(pmap_activate) /* XXXKSE */ mov s3, a0 /* swap the context */ SWITCH_CONTEXT @@ -183,28 +183,28 @@ Lcs6: Lcs7: /* - * Now that the switch is done, update curproc and other + * Now that the switch is done, update curthread and other * globals. We must do this even if switching to ourselves * because we might have re-entered cpu_switch() from idle(), - * in which case curproc would be NULL. + * in which case curthread would be NULL. */ - stq s2, GD_CURPROC(globalp) /* curproc = p */ + stq s2, GD_CURTHREAD(globalp) /* curthread = p */ /* * Now running on the new u struct. * Restore registers and return. */ - ldq t0, P_ADDR(s2) + ldq t0, TD_PCB(s2) /* NOTE: ksp is restored by the swpctx */ - ldq s0, U_PCB_CONTEXT+(0 * 8)(t0) /* restore s0 - s6 */ - ldq s1, U_PCB_CONTEXT+(1 * 8)(t0) - ldq s2, U_PCB_CONTEXT+(2 * 8)(t0) - ldq s3, U_PCB_CONTEXT+(3 * 8)(t0) - ldq s4, U_PCB_CONTEXT+(4 * 8)(t0) - ldq s5, U_PCB_CONTEXT+(5 * 8)(t0) - ldq s6, U_PCB_CONTEXT+(6 * 8)(t0) - ldq ra, U_PCB_CONTEXT+(7 * 8)(t0) /* restore ra */ + ldq s0, PCB_CONTEXT+(0 * 8)(t0) /* restore s0 - s6 */ + ldq s1, PCB_CONTEXT+(1 * 8)(t0) + ldq s2, PCB_CONTEXT+(2 * 8)(t0) + ldq s3, PCB_CONTEXT+(3 * 8)(t0) + ldq s4, PCB_CONTEXT+(4 * 8)(t0) + ldq s5, PCB_CONTEXT+(5 * 8)(t0) + ldq s6, PCB_CONTEXT+(6 * 8)(t0) + ldq ra, PCB_CONTEXT+(7 * 8)(t0) /* restore ra */ ldiq v0, 1 /* possible ret to savectx() */ RET diff --git a/sys/alpha/alpha/sys_machdep.c b/sys/alpha/alpha/sys_machdep.c index ea0f49c..0d304cb 100644 --- a/sys/alpha/alpha/sys_machdep.c +++ b/sys/alpha/alpha/sys_machdep.c @@ -63,34 +63,34 @@ struct sysarch_args { }; #endif -static int alpha_sethae(struct proc *p, char *args); -static int alpha_get_fpmask(struct proc *p, char *args); -static int alpha_set_fpmask(struct proc *p, char *args); -static int alpha_set_uac(struct proc *p, char *args); -static int alpha_get_uac(struct proc *p, char *args); +static int alpha_sethae(struct thread *td, char *args); +static int alpha_get_fpmask(struct thread *td, char *args); +static int alpha_set_fpmask(struct thread *td, char *args); +static int alpha_set_uac(struct thread *td, char *args); +static int alpha_get_uac(struct thread *td, char *args); int -sysarch(p, uap) - struct proc *p; +sysarch(td, uap) + struct thread *td; register struct sysarch_args *uap; { int error = 0; switch(SCARG(uap,op)) { case ALPHA_SETHAE: - error = alpha_sethae(p, uap->parms); + error = alpha_sethae(td, uap->parms); break; case ALPHA_GET_FPMASK: - error = alpha_get_fpmask(p, uap->parms); + error = alpha_get_fpmask(td, uap->parms); break; case ALPHA_SET_FPMASK: - error = alpha_set_fpmask(p, uap->parms); + error = alpha_set_fpmask(td, uap->parms); break; case ALPHA_SET_UAC: - error = alpha_set_uac(p, uap->parms); + error = alpha_set_uac(td, uap->parms); break; case ALPHA_GET_UAC: - error = alpha_get_uac(p, uap->parms); + error = alpha_get_uac(td, uap->parms); break; default: @@ -105,7 +105,7 @@ struct alpha_sethae_args { }; static int -alpha_sethae(struct proc *p, char *args) +alpha_sethae(struct thread *td, char *args) { int error; struct alpha_sethae_args ua; @@ -117,12 +117,12 @@ alpha_sethae(struct proc *p, char *args) if (securelevel > 0) return (EPERM); - error = suser(p); + error = suser(td->td_proc); if (error) return (error); - p->p_md.md_flags |= MDP_HAEUSED; - p->p_md.md_hae = ua.hae; + td->td_md.md_flags |= MDP_HAEUSED; + td->td_md.md_hae = ua.hae; return (0); } @@ -132,19 +132,19 @@ struct alpha_fpmask_args { }; static int -alpha_get_fpmask(struct proc *p, char *args) +alpha_get_fpmask(struct thread *td, char *args) { int error; struct alpha_fpmask_args ua; - ua.mask = p->p_addr->u_pcb.pcb_fp_control; + ua.mask = td->td_pcb->pcb_fp_control; error = copyout(&ua, args, sizeof(struct alpha_fpmask_args)); return (error); } static int -alpha_set_fpmask(struct proc *p, char *args) +alpha_set_fpmask(struct thread *td, char *args) { int error; u_int64_t oldmask, *fp_control; @@ -154,7 +154,7 @@ alpha_set_fpmask(struct proc *p, char *args) if (error) return (error); - fp_control = &p->p_addr->u_pcb.pcb_fp_control; + fp_control = &td->td_pcb->pcb_fp_control; oldmask = *fp_control; *fp_control = ua.mask & IEEE_TRAP_ENABLE_MASK; ua.mask = oldmask; @@ -164,20 +164,23 @@ alpha_set_fpmask(struct proc *p, char *args) } static int -alpha_set_uac(struct proc *p, char *args) +alpha_set_uac(struct thread *td, char *args) { int error; unsigned long uac; + struct proc *p; error = copyin(args, &uac, sizeof(uac)); if (error) return (error); + p = td->td_proc; PROC_LOCK(p); if (p->p_pptr) { PROC_LOCK(p->p_pptr); - p->p_pptr->p_md.md_flags &= ~MDP_UAC_MASK; - p->p_pptr->p_md.md_flags |= uac & MDP_UAC_MASK; + /* XXXKSE which threads? */ + p->p_pptr->p_thread.td_md.md_flags &= ~MDP_UAC_MASK; + p->p_pptr->p_thread.td_md.md_flags |= uac & MDP_UAC_MASK; PROC_UNLOCK(p->p_pptr); } PROC_UNLOCK(p); @@ -185,16 +188,19 @@ alpha_set_uac(struct proc *p, char *args) } static int -alpha_get_uac(struct proc *p, char *args) +alpha_get_uac(struct thread *td, char *args) { + struct proc *p; int error; unsigned long uac; + p = td->td_proc; error = ESRCH; PROC_LOCK(p); if (p->p_pptr) { PROC_LOCK(p->p_pptr); - uac = p->p_pptr->p_md.md_flags & MDP_UAC_MASK; + /* XXXKSE which threads? */ + uac = p->p_pptr->p_thread.td_md.md_flags & MDP_UAC_MASK; PROC_UNLOCK(p->p_pptr); PROC_UNLOCK(p); error = copyout(&uac, args, sizeof(uac)); diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 9b7d8f4..726615a 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -81,8 +81,8 @@ unsigned long Gfloat_reg_cvt __P((unsigned long)); #endif int unaligned_fixup __P((unsigned long, unsigned long, - unsigned long, struct proc *)); -int handle_opdec(struct proc *p, u_int64_t *ucodep); + unsigned long, struct thread *)); +int handle_opdec(struct thread *td, u_int64_t *ucodep); static void printtrap __P((const unsigned long, const unsigned long, const unsigned long, const unsigned long, struct trapframe *, int, int)); @@ -256,6 +256,7 @@ trap(a0, a1, a2, entry, framep) const unsigned long a0, a1, a2, entry; struct trapframe *framep; { + register struct thread *td; register struct proc *p; register int i; u_int64_t ucode; @@ -272,11 +273,12 @@ trap(a0, a1, a2, entry, framep) s = critical_enter(); #endif globalp = (struct globaldata *) alpha_pal_rdval(); - p = curproc; + td = curthread; #ifdef SMP - p->p_md.md_kernnest++; + td->td_md.md_kernnest++; critical_exit(s); #endif + p = td->td_proc; /* GIANT_REQUIRED; @@ -289,15 +291,15 @@ trap(a0, a1, a2, entry, framep) CTR5(KTR_TRAP, "%s trap: pid %d, (%lx, %lx, %lx)", user ? "user" : "kernel", p->p_pid, a0, a1, a2); if (user) { - sticks = p->p_sticks; - p->p_frame = framep; + sticks = td->td_kse->ke_sticks; + td->td_frame = framep; } else { sticks = 0; /* XXX bogus -Wuninitialized warning */ } #ifdef DIAGNOSTIC if (user) - alpha_fpstate_check(p); + alpha_fpstate_check(td); #endif switch (entry) { @@ -309,7 +311,7 @@ trap(a0, a1, a2, entry, framep) */ if (user) { mtx_lock(&Giant); - if ((i = unaligned_fixup(a0, a1, a2, p)) == 0) { + if ((i = unaligned_fixup(a0, a1, a2, td)) == 0) { mtx_unlock(&Giant); goto out; } @@ -339,7 +341,7 @@ trap(a0, a1, a2, entry, framep) if (user) { mtx_lock(&Giant); if (a0 & EXCSUM_SWC) - if (fp_software_completion(a1, p)) { + if (fp_software_completion(a1, td)) { mtx_unlock(&Giant); goto out; } @@ -391,10 +393,10 @@ trap(a0, a1, a2, entry, framep) /* FALLTHROUTH */ case ALPHA_IF_CODE_BPT: case ALPHA_IF_CODE_BUGCHK: - if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2)) { + if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2)) { mtx_lock(&Giant); - ptrace_clear_single_step(p); - p->p_frame->tf_regs[FRAME_PC] -= 4; + ptrace_clear_single_step(td); + td->td_frame->tf_regs[FRAME_PC] -= 4; mtx_unlock(&Giant); } ucode = a0; /* trap type */ @@ -402,23 +404,23 @@ trap(a0, a1, a2, entry, framep) break; case ALPHA_IF_CODE_OPDEC: - i = handle_opdec(p, &ucode); + i = handle_opdec(td, &ucode); if (i == 0) goto out; break; case ALPHA_IF_CODE_FEN: /* - * on exit from the kernel, if proc == fpcurproc, + * on exit from the kernel, if thread == fpcurthread, * FP is enabled. */ - if (PCPU_GET(fpcurproc) == p) { - printf("trap: fp disabled for fpcurproc == %p", - p); + if (PCPU_GET(fpcurthread) == td) { + printf("trap: fp disabled for fpcurthread == %p", + td); goto dopanic; } - alpha_fpstate_switch(p); + alpha_fpstate_switch(td); goto out; default: @@ -432,7 +434,7 @@ trap(a0, a1, a2, entry, framep) case ALPHA_MMCSR_FOR: case ALPHA_MMCSR_FOE: case ALPHA_MMCSR_FOW: - pmap_emulate_reference(p, a0, user, + pmap_emulate_reference(p->p_vmspace, a0, user, a1 == ALPHA_MMCSR_FOW); goto out; @@ -453,13 +455,13 @@ trap(a0, a1, a2, entry, framep) * when they are running. */ if (!user && - p != NULL && - p->p_addr->u_pcb.pcb_onfault == + td != NULL && + td->td_pcb->pcb_onfault == (unsigned long)fswintrberr && - p->p_addr->u_pcb.pcb_accessaddr == a0) { + td->td_pcb->pcb_accessaddr == a0) { framep->tf_regs[FRAME_PC] = - p->p_addr->u_pcb.pcb_onfault; - p->p_addr->u_pcb.pcb_onfault = 0; + td->td_pcb->pcb_onfault; + td->td_pcb->pcb_onfault = 0; goto out; } @@ -479,8 +481,8 @@ trap(a0, a1, a2, entry, framep) */ if (!user && ((a0 >= VM_MIN_KERNEL_ADDRESS) - || (p == NULL) - || (p->p_addr->u_pcb.pcb_onfault == 0))) { + || (td == NULL) + || (td->td_pcb->pcb_onfault == 0))) { if (a0 >= trunc_page(PS_STRINGS - szsigcode - SPARE_USRSPACE) @@ -578,11 +580,11 @@ trap(a0, a1, a2, entry, framep) mtx_unlock(&Giant); if (!user) { /* Check for copyin/copyout fault */ - if (p != NULL && - p->p_addr->u_pcb.pcb_onfault != 0) { + if (td != NULL && + td->td_pcb->pcb_onfault != 0) { framep->tf_regs[FRAME_PC] = - p->p_addr->u_pcb.pcb_onfault; - p->p_addr->u_pcb.pcb_onfault = 0; + td->td_pcb->pcb_onfault; + td->td_pcb->pcb_onfault = 0; goto out; } goto dopanic; @@ -615,7 +617,7 @@ trap(a0, a1, a2, entry, framep) out: if (user) { framep->tf_regs[FRAME_SP] = alpha_pal_rdusp(); - userret(p, framep, sticks); + userret(td, framep, sticks); if (mtx_owned(&Giant)) mtx_unlock(&Giant); } @@ -649,6 +651,7 @@ syscall(code, framep) struct trapframe *framep; { struct sysent *callp; + struct thread *td; struct proc *p; int error = 0; u_int64_t opc; @@ -666,11 +669,12 @@ syscall(code, framep) s = critical_enter(); #endif globalp = (struct globaldata *) alpha_pal_rdval(); - p = curproc; + td = curthread; #ifdef SMP - p->p_md.md_kernnest++; + td->td_md.md_kernnest++; critical_exit(s); #endif + p = td->td_proc; framep->tf_regs[FRAME_TRAPARG_A0] = 0; framep->tf_regs[FRAME_TRAPARG_A1] = 0; @@ -681,9 +685,9 @@ syscall(code, framep) #endif cnt.v_syscall++; - p->p_frame = framep; + td->td_frame = framep; opc = framep->tf_regs[FRAME_PC] - 4; - sticks = p->p_sticks; + sticks = td->td_kse->ke_sticks; #ifdef DIAGNOSTIC alpha_fpstate_check(p); @@ -750,19 +754,19 @@ syscall(code, framep) } #endif if (error == 0) { - p->p_retval[0] = 0; - p->p_retval[1] = 0; + td->td_retval[0] = 0; + td->td_retval[1] = 0; STOPEVENT(p, S_SCE, (callp->sy_narg & SYF_ARGMASK)); - error = (*callp->sy_call)(p, args + hidden); + error = (*callp->sy_call)(td, args + hidden); } switch (error) { case 0: - framep->tf_regs[FRAME_V0] = p->p_retval[0]; - framep->tf_regs[FRAME_A4] = p->p_retval[1]; + framep->tf_regs[FRAME_V0] = td->td_retval[0]; + framep->tf_regs[FRAME_A4] = td->td_retval[1]; framep->tf_regs[FRAME_A3] = 0; break; case ERESTART: @@ -782,10 +786,10 @@ syscall(code, framep) break; } - userret(p, framep, sticks); + userret(td, framep, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - ktrsysret(p->p_tracep, code, error, p->p_retval[0]); + ktrsysret(p->p_tracep, code, error, td->td_retval[0]); } #endif @@ -805,7 +809,7 @@ syscall(code, framep) STOPEVENT(p, S_SCX, code); #ifdef WITNESS - if (witness_list(p)) { + if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", syscallnames[code]); } @@ -829,23 +833,23 @@ const static int reg_to_framereg[32] = { FRAME_AT, FRAME_GP, FRAME_SP, -1, }; -#define irp(p, reg) \ +#define irp(td, reg) \ ((reg_to_framereg[(reg)] == -1) ? NULL : \ - &(p)->p_frame->tf_regs[reg_to_framereg[(reg)]]) + &(td)->td_frame->tf_regs[reg_to_framereg[(reg)]]) -#define frp(p, reg) \ - (&(p)->p_addr->u_pcb.pcb_fp.fpr_regs[(reg)]) +#define frp(td, reg) \ + (&(td)->td_pcb->pcb_fp.fpr_regs[(reg)]) #define unaligned_load(storage, ptrf, mod) \ if (copyin((caddr_t)va, &(storage), sizeof (storage)) == 0 && \ - (regptr = ptrf(p, reg)) != NULL) \ + (regptr = ptrf(td, reg)) != NULL) \ signal = 0; \ else \ break; \ *regptr = mod (storage); #define unaligned_store(storage, ptrf, mod) \ - if ((regptr = ptrf(p, reg)) == NULL) \ + if ((regptr = ptrf(td, reg)) == NULL) \ (storage) = 0; \ else \ (storage) = mod (*regptr); \ @@ -861,11 +865,11 @@ const static int reg_to_framereg[32] = { unaligned_store(storage, irp, ) #define unaligned_load_floating(storage, mod) \ - alpha_fpstate_save(p, 1); \ + alpha_fpstate_save(td, 1); \ unaligned_load(storage, frp, mod) #define unaligned_store_floating(storage, mod) \ - alpha_fpstate_save(p, 0); \ + alpha_fpstate_save(td, 0); \ unaligned_store(storage, frp, mod) unsigned long @@ -988,13 +992,14 @@ extern int alpha_unaligned_print, alpha_unaligned_fix; extern int alpha_unaligned_sigbus; int -unaligned_fixup(va, opcode, reg, p) +unaligned_fixup(va, opcode, reg, td) unsigned long va, opcode, reg; - struct proc *p; + struct thread *td; { int doprint, dofix, dosigbus; int signal, size; const char *type; + struct proc *p; unsigned long *regptr, longdata, uac; int intdata; /* signed to get extension when storing */ struct { @@ -1024,10 +1029,13 @@ unaligned_fixup(va, opcode, reg, p) * */ - if (p) - uac = p->p_md.md_flags & MDP_UAC_MASK; - else + if (td) { + uac = td->td_md.md_flags & MDP_UAC_MASK; + p = td->td_proc; + } else { uac = 0; + p = NULL; + } doprint = alpha_unaligned_print && !(uac & MDP_UAC_NOPRINT); dofix = alpha_unaligned_fix && !(uac & MDP_UAC_NOFIX); @@ -1061,8 +1069,8 @@ unaligned_fixup(va, opcode, reg, p) if (doprint) { uprintf( "pid %d (%s): unaligned access: va=0x%lx pc=0x%lx ra=0x%lx op=", - p->p_pid, p->p_comm, va, p->p_frame->tf_regs[FRAME_PC], - p->p_frame->tf_regs[FRAME_RA]); + p->p_pid, p->p_comm, va, td->td_frame->tf_regs[FRAME_PC], + td->td_frame->tf_regs[FRAME_RA]); uprintf(type,opcode); uprintf("\n"); } @@ -1165,8 +1173,8 @@ out: * and fills in *ucodep with the code to be delivered. */ int -handle_opdec(p, ucodep) - struct proc *p; +handle_opdec(td, ucodep) + struct thread *td; u_int64_t *ucodep; { alpha_instruction inst; @@ -1179,9 +1187,9 @@ handle_opdec(p, ucodep) * This keeps us from having to check for it in lots of places * later. */ - p->p_frame->tf_regs[FRAME_SP] = alpha_pal_rdusp(); + td->td_frame->tf_regs[FRAME_SP] = alpha_pal_rdusp(); - inst_pc = memaddr = p->p_frame->tf_regs[FRAME_PC] - 4; + inst_pc = memaddr = td->td_frame->tf_regs[FRAME_PC] - 4; if (copyin((caddr_t)inst_pc, &inst, sizeof (inst)) != 0) { /* * really, this should never happen, but in case it @@ -1196,21 +1204,21 @@ handle_opdec(p, ucodep) case op_ldwu: case op_stw: case op_stb: - regptr = irp(p, inst.mem_format.rs); + regptr = irp(td, inst.mem_format.rs); if (regptr != NULL) memaddr = *regptr; else memaddr = 0; memaddr += inst.mem_format.displacement; - regptr = irp(p, inst.mem_format.rd); + regptr = irp(td, inst.mem_format.rd); if (inst.mem_format.opcode == op_ldwu || inst.mem_format.opcode == op_stw) { if (memaddr & 0x01) { sig = unaligned_fixup(memaddr, inst.mem_format.opcode, - inst.mem_format.rd, p); + inst.mem_format.rd, td); if (sig) goto unaligned_fixup_sig; break; @@ -1260,11 +1268,11 @@ handle_opdec(p, ucodep) } else { if (inst.operate_reg_format.sbz != 0) goto sigill; - regptr = irp(p, inst.operate_reg_format.rt); + regptr = irp(td, inst.operate_reg_format.rt); b = (regptr != NULL) ? *regptr : 0; } - regptr = irp(p, inst.operate_generic_format.rc); + regptr = irp(td, inst.operate_generic_format.rc); if (regptr != NULL) *regptr = b; break; @@ -1278,11 +1286,11 @@ handle_opdec(p, ucodep) } else { if (inst.operate_reg_format.sbz != 0) goto sigill; - regptr = irp(p, inst.operate_reg_format.rt); + regptr = irp(td, inst.operate_reg_format.rt); w = (regptr != NULL) ? *regptr : 0; } - regptr = irp(p, inst.operate_generic_format.rc); + regptr = irp(td, inst.operate_generic_format.rc); if (regptr != NULL) *regptr = w; break; @@ -1298,7 +1306,7 @@ handle_opdec(p, ucodep) * nothing will have been successfully modified so we don't * have to write it out. */ - alpha_pal_wrusp(p->p_frame->tf_regs[FRAME_SP]); + alpha_pal_wrusp(td->td_frame->tf_regs[FRAME_SP]); return (0); @@ -1308,7 +1316,7 @@ sigill: sigsegv: sig = SIGSEGV; - p->p_frame->tf_regs[FRAME_PC] = inst_pc; /* re-run instr. */ + td->td_frame->tf_regs[FRAME_PC] = inst_pc; /* re-run instr. */ unaligned_fixup_sig: *ucodep = memaddr; /* faulting address */ return (sig); diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index 0aec807..6e302cd 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -118,30 +118,35 @@ vm_fault_quick(v, prot) * ready to run and return to user mode. */ void -cpu_fork(p1, p2, flags) - register struct proc *p1, *p2; +cpu_fork(td1, p2, flags) + register struct thread *td1; + register struct proc *p2; int flags; { - struct user *up; + struct proc *p1; + struct thread *td2; struct trapframe *p2tf; if ((flags & RFPROC) == 0) return; - p2->p_frame = p1->p_frame; - p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK); + p1 = td1->td_proc; + td2 = &p2->p_thread; + td2->td_pcb = (struct pcb *) + (td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td2->td_md.md_flags = td1->td_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK); /* * Cache the physical address of the pcb, so we can * swap to it easily. */ - p2->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p2->p_addr->u_pcb); + td2->td_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)td2->td_pcb); /* * Copy floating point state from the FP chip to the PCB * if this process has state stored there. */ - alpha_fpstate_save(p1, 0); + alpha_fpstate_save(td1, 0); /* * Copy pcb and stack from proc p1 to p2. We do this as @@ -149,16 +154,16 @@ cpu_fork(p1, p2, flags) * stack. The stack and pcb need to agree. Make sure that the * new process has FEN disabled. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp(); - p2->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN; + bcopy(td1->td_pcb, td2->td_pcb, sizeof(struct pcb)); + td2->td_pcb->pcb_hw.apcb_usp = alpha_pal_rdusp(); + td2->td_pcb->pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN; /* * Set the floating point state. */ - if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) { - p2->p_addr->u_pcb.pcb_fp_control = 0; - p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL + if ((td2->td_pcb->pcb_fp_control & IEEE_INHERIT) == 0) { + td2->td_pcb->pcb_fp_control = 0; + td2->td_pcb->pcb_fp.fpr_cr = (FPCR_DYN_NORMAL | FPCR_INVD | FPCR_DZED | FPCR_OVFD | FPCR_INED | FPCR_UNFD); @@ -169,7 +174,7 @@ cpu_fork(p1, p2, flags) * is started, to resume here, returning nonzero from setjmp. */ #ifdef DIAGNOSTIC - alpha_fpstate_check(p1); + alpha_fpstate_check(td1); #endif /* @@ -179,34 +184,32 @@ cpu_fork(p1, p2, flags) * copy trapframe from parent so return to user mode * will be to right address, with correct registers. */ - p2->p_frame = (struct trapframe *) - ((char *)p2->p_addr + USPACE - sizeof(struct trapframe)); - bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe)); + td2->td_frame = (struct trapframe *)td2->td_pcb - 1; + bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); /* * Set up return-value registers as fork() libc stub expects. */ - p2tf = p2->p_frame; - p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */ - p2tf->tf_regs[FRAME_A3] = 0; /* no error */ - p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */ + p2tf = td2->td_frame; + p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */ + p2tf->tf_regs[FRAME_A3] = 0; /* no error */ + p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */ /* * Arrange for continuation at fork_return(), which * will return to exception_return(). Note that the child * process doesn't stay in the kernel for long! */ - up = p2->p_addr; - up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf; - up->u_pcb.pcb_context[0] = (u_int64_t)fork_return; /* s0: a0 */ - up->u_pcb.pcb_context[1] = (u_int64_t)exception_return; /* s1: ra */ - up->u_pcb.pcb_context[2] = (u_long) p2; /* s2: a1 */ - up->u_pcb.pcb_context[7] = (u_int64_t)fork_trampoline; /* ra: magic */ + td2->td_pcb->pcb_hw.apcb_ksp = (u_int64_t)p2tf; + td2->td_pcb->pcb_context[0] = (u_int64_t)fork_return; /* s0: a0 */ + td2->td_pcb->pcb_context[1] = (u_int64_t)exception_return;/* s1: ra */ + td2->td_pcb->pcb_context[2] = (u_long)td2; /* s2: a1 */ + td2->td_pcb->pcb_context[7] = (u_int64_t)fork_trampoline; /* ra: magic*/ #ifdef SMP /* * We start off at a nesting level of 1 within the kernel. */ - p2->p_md.md_kernnest = 1; + td2->td_md.md_kernnest = 1; #endif } @@ -217,8 +220,8 @@ cpu_fork(p1, p2, flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(p, func, arg) - struct proc *p; +cpu_set_fork_handler(td, func, arg) + struct thread *td; void (*func) __P((void *)); void *arg; { @@ -226,8 +229,8 @@ cpu_set_fork_handler(p, func, arg) * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_addr->u_pcb.pcb_context[0] = (u_long) func; - p->p_addr->u_pcb.pcb_context[2] = (u_long) arg; + td->td_pcb->pcb_context[0] = (u_long) func; + td->td_pcb->pcb_context[2] = (u_long) arg; } /* @@ -238,11 +241,11 @@ cpu_set_fork_handler(p, func, arg) * from proc0. */ void -cpu_exit(p) - register struct proc *p; +cpu_exit(td) + register struct thread *td; { - alpha_fpstate_drop(p); + alpha_fpstate_drop(td); } void @@ -255,14 +258,23 @@ cpu_wait(p) * Dump the machine specific header information at the start of a core dump. */ int -cpu_coredump(p, vp, cred) - struct proc *p; +cpu_coredump(td, vp, cred) + struct thread *td; struct vnode *vp; struct ucred *cred; { - - return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p)); + int error; + + /* XXXKSE this is totally bogus! (and insecure) */ + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_proc->p_uarea, + ctob(UAREA_PAGES), (off_t)0, + UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); + if (error) + return error; + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_kstack, + ctob(KSTACK_PAGES), (off_t)ctob(UAREA_PAGES), + UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); + return error; } /* diff --git a/sys/alpha/include/cpu.h b/sys/alpha/include/cpu.h index 69ed2ea..e5fd400 100644 --- a/sys/alpha/include/cpu.h +++ b/sys/alpha/include/cpu.h @@ -52,7 +52,7 @@ #include <machine/frame.h> -#define cpu_getstack(p) (alpha_pal_rdusp()) +#define cpu_getstack(td) (alpha_pal_rdusp()) /* * Arguments to hardclock and gatherstats encapsulate the previous @@ -99,7 +99,7 @@ struct clockframe { #ifdef _KERNEL struct pcb; -struct proc; +struct thread; struct reg; struct rpb; struct trapframe; @@ -116,10 +116,10 @@ void XentSys __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */ void XentUna __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */ void alpha_init __P((u_long, u_long, u_long, u_long, u_long)); int alpha_pa_access __P((u_long)); -void alpha_fpstate_check __P((struct proc *p)); -void alpha_fpstate_save __P((struct proc *p, int write)); -void alpha_fpstate_drop __P((struct proc *p)); -void alpha_fpstate_switch __P((struct proc *p)); +void alpha_fpstate_check __P((struct thread *p)); +void alpha_fpstate_save __P((struct thread *p, int write)); +void alpha_fpstate_drop __P((struct thread *p)); +void alpha_fpstate_switch __P((struct thread *p)); int badaddr __P((void *, size_t)); int badaddr_read __P((void *, size_t, void *)); u_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t)); @@ -138,7 +138,7 @@ void regdump __P((struct trapframe *)); void regtoframe __P((struct reg *, struct trapframe *)); void savectx __P((struct pcb *)); void set_iointr __P((void (*)(void *, unsigned long))); -void switch_exit __P((struct proc *)); /* MAGIC */ +void switch_exit __P((struct thread *)); /* MAGIC */ void fork_trampoline __P((void)); /* MAGIC */ void syscall __P((u_int64_t, struct trapframe *)); void trap __P((unsigned long, unsigned long, unsigned long, unsigned long, diff --git a/sys/alpha/include/fpu.h b/sys/alpha/include/fpu.h index 250db28..712a1f9 100644 --- a/sys/alpha/include/fpu.h +++ b/sys/alpha/include/fpu.h @@ -117,7 +117,7 @@ #ifdef _KERNEL -extern int fp_software_completion(u_int64_t regmask, struct proc *p); +extern int fp_software_completion(u_int64_t regmask, struct thread *p); #endif diff --git a/sys/alpha/include/globaldata.h b/sys/alpha/include/globaldata.h index d577fee..5d8514b 100644 --- a/sys/alpha/include/globaldata.h +++ b/sys/alpha/include/globaldata.h @@ -44,15 +44,15 @@ * point at the globaldata structure. */ struct globaldata { - struct alpha_pcb gd_idlepcb; /* pcb for idling */ - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ + struct alpha_pcb gd_idlepcb; /* pcb for idling */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ u_int64_t gd_pending_ipis; /* pending IPI events */ u_int32_t gd_next_asn; /* next ASN to allocate */ diff --git a/sys/alpha/include/globals.h b/sys/alpha/include/globals.h index 313541b..46dab32 100644 --- a/sys/alpha/include/globals.h +++ b/sys/alpha/include/globals.h @@ -40,9 +40,11 @@ register struct globaldata *globalp __asm__("$8"); #define PCPU_PTR(member) (&GLOBALP->gd_ ## member) #define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value)) -#define CURPROC PCPU_GET(curproc) -#define CURTHD PCPU_GET(curproc) /* temporary */ -#define curproc PCPU_GET(curproc) +#define curthread PCPU_GET(curthread) +#define CURPROC (curthread->td_proc) +#define curproc (curthread->td_proc) +#define curksegrp (curthread->td_ksegrp) +#define curkse (curthread->td_kse) #endif /* _KERNEL */ diff --git a/sys/alpha/include/md_var.h b/sys/alpha/include/md_var.h index 41512d7..b4fdfe4 100644 --- a/sys/alpha/include/md_var.h +++ b/sys/alpha/include/md_var.h @@ -40,7 +40,7 @@ extern int Maxmem; extern int busdma_swi_pending; struct fpreg; -struct proc; +struct thread; struct reg; struct cam_sim; struct pcicfg; @@ -50,10 +50,10 @@ void cpu_halt __P((void)); void cpu_reset __P((void)); int is_physical_memory __P((vm_offset_t addr)); void swi_vm __P((void *)); -int fill_regs __P((struct proc *, struct reg *)); -int set_regs __P((struct proc *, struct reg *)); -int fill_fpregs __P((struct proc *, struct fpreg *)); -int set_fpregs __P((struct proc *, struct fpreg *)); +int fill_regs __P((struct thread *, struct reg *)); +int set_regs __P((struct thread *, struct reg *)); +int fill_fpregs __P((struct thread *, struct fpreg *)); +int set_fpregs __P((struct thread *, struct fpreg *)); void alpha_register_pci_scsi __P((int bus, int slot, struct cam_sim *sim)); #ifdef _SYS_BUS_H_ struct resource *alpha_platform_alloc_ide_intr(int chan); diff --git a/sys/alpha/include/mutex.h b/sys/alpha/include/mutex.h index c141d6f..9192bb2 100644 --- a/sys/alpha/include/mutex.h +++ b/sys/alpha/include/mutex.h @@ -58,7 +58,7 @@ extern struct mtx clock_lock; 1: ldq_l a0, lck+MTX_LOCK; \ cmpeq a0, MTX_UNOWNED, a1; \ beq a1, 1b; \ - ldq a0, PC_CURPROC(globalp); \ + ldq a0, PC_CURTHREAD(globalp); \ stq_c a0, lck+MTX_LOCK; \ beq a0, 1b; \ mb; \ diff --git a/sys/alpha/include/param.h b/sys/alpha/include/param.h index 0a0206e..91dabba 100644 --- a/sys/alpha/include/param.h +++ b/sys/alpha/include/param.h @@ -133,8 +133,10 @@ #define SSIZE 1 /* initial stack size/NBPG */ #define SINCR 1 /* increment of stack/NBPG */ -#define UPAGES 2 /* pages of u-area */ -#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */ +#define KSTACK_PAGES 2 /* pages of kstack (with pcb) */ +#define UAREA_PAGES 1 /* pages of u-area */ + +#define KSTACK_GUARD /* compile in kstack guard page */ /* * Constants related to network buffer management. diff --git a/sys/alpha/include/pcpu.h b/sys/alpha/include/pcpu.h index d577fee..5d8514b 100644 --- a/sys/alpha/include/pcpu.h +++ b/sys/alpha/include/pcpu.h @@ -44,15 +44,15 @@ * point at the globaldata structure. */ struct globaldata { - struct alpha_pcb gd_idlepcb; /* pcb for idling */ - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ + struct alpha_pcb gd_idlepcb; /* pcb for idling */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ u_int64_t gd_pending_ipis; /* pending IPI events */ u_int32_t gd_next_asn; /* next ASN to allocate */ diff --git a/sys/alpha/include/pmap.h b/sys/alpha/include/pmap.h index 055ea36..959805e 100644 --- a/sys/alpha/include/pmap.h +++ b/sys/alpha/include/pmap.h @@ -220,6 +220,8 @@ extern char *ptvmmap; /* poor name! */ extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; +struct vmspace; + vm_offset_t pmap_steal_memory __P((vm_size_t)); void pmap_bootstrap __P((vm_offset_t, u_int)); void pmap_setdevram __P((unsigned long long basea, vm_offset_t sizea)); @@ -230,8 +232,8 @@ unsigned *pmap_pte __P((pmap_t, vm_offset_t)) __pure2; vm_page_t pmap_use_pt __P((pmap_t, vm_offset_t)); void pmap_set_opt __P((unsigned *)); void pmap_set_opt_bsp __P((void)); -void pmap_deactivate __P((struct proc *p)); -void pmap_emulate_reference __P((struct proc *p, vm_offset_t v, int user, int write)); +void pmap_deactivate __P((struct thread *td)); +void pmap_emulate_reference __P((struct vmspace *vm, vm_offset_t v, int user, int write)); #endif /* _KERNEL */ diff --git a/sys/alpha/include/proc.h b/sys/alpha/include/proc.h index b3f98f6..16cf1d5 100644 --- a/sys/alpha/include/proc.h +++ b/sys/alpha/include/proc.h @@ -43,7 +43,7 @@ struct mdbpt { u_int32_t contents; }; -struct mdproc { +struct mdthread { u_long md_flags; struct pcb *md_pcbpaddr; /* phys addr of the pcb */ struct mdbpt md_sstep[2]; /* two single step breakpoints */ @@ -62,4 +62,7 @@ struct mdproc { unaligned access */ #define MDP_UAC_MASK (MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS) +struct mdproc { +}; + #endif /* !_MACHINE_PROC_H_ */ diff --git a/sys/alpha/include/ptrace.h b/sys/alpha/include/ptrace.h index 5a9cf14..87a03af 100644 --- a/sys/alpha/include/ptrace.h +++ b/sys/alpha/include/ptrace.h @@ -48,7 +48,7 @@ #define FIX_SSTEP(p) ptrace_clear_single_step(p) #ifdef _KERNEL -int ptrace_clear_single_step(struct proc *_p); +int ptrace_clear_single_step(struct thread *_p); #endif #endif diff --git a/sys/alpha/include/reg.h b/sys/alpha/include/reg.h index 5dfde65..b4a73f3 100644 --- a/sys/alpha/include/reg.h +++ b/sys/alpha/include/reg.h @@ -110,7 +110,7 @@ struct dbreg { #ifdef _KERNEL void restorefpstate __P((struct fpreg *)); void savefpstate __P((struct fpreg *)); -void setregs __P((struct proc *, u_long, u_long, u_long)); +void setregs __P((struct thread *, u_long, u_long, u_long)); #endif #endif /* _ALPHA_REG_H_ */ diff --git a/sys/alpha/include/vmparam.h b/sys/alpha/include/vmparam.h index bd08553..29dcc99 100644 --- a/sys/alpha/include/vmparam.h +++ b/sys/alpha/include/vmparam.h @@ -62,7 +62,7 @@ * with a 32bit value. OSF1 manages to have a variable location for * the user stack which we should probably also support. */ -#define USRSTACK (0x12000000LL - (UPAGES*PAGE_SIZE)) +#define USRSTACK (0x12000000LL) /* * Virtual memory related constants, all in bytes diff --git a/sys/alpha/linux/linux_proto.h b/sys/alpha/linux/linux_proto.h index 9caa5ea..31f052c 100644 --- a/sys/alpha/linux/linux_proto.h +++ b/sys/alpha/linux/linux_proto.h @@ -15,6 +15,8 @@ struct proc; +struct thread; + #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 0 : sizeof(register_t) - sizeof(t)) @@ -594,144 +596,144 @@ struct linux_getdents64_args { char dirent_l_[PADL_(void *)]; void * dirent; char dirent_r_[PADR_(void *)]; char count_l_[PADL_(l_uint)]; l_uint count; char count_r_[PADR_(l_uint)]; }; -int linux_fork __P((struct proc *, struct linux_fork_args *)); -int osf1_wait4 __P((struct proc *, struct osf1_wait4_args *)); -int linux_link __P((struct proc *, struct linux_link_args *)); -int linux_unlink __P((struct proc *, struct linux_unlink_args *)); -int linux_chdir __P((struct proc *, struct linux_chdir_args *)); -int linux_mknod __P((struct proc *, struct linux_mknod_args *)); -int linux_chmod __P((struct proc *, struct linux_chmod_args *)); -int linux_chown __P((struct proc *, struct linux_chown_args *)); -int linux_brk __P((struct proc *, struct linux_brk_args *)); -int linux_lseek __P((struct proc *, struct linux_lseek_args *)); -int linux_getpid __P((struct proc *, struct linux_getpid_args *)); -int linux_umount __P((struct proc *, struct linux_umount_args *)); -int linux_getuid __P((struct proc *, struct linux_getuid_args *)); -int linux_ptrace __P((struct proc *, struct linux_ptrace_args *)); -int linux_access __P((struct proc *, struct linux_access_args *)); -int linux_kill __P((struct proc *, struct linux_kill_args *)); -int linux_open __P((struct proc *, struct linux_open_args *)); -int linux_getgid __P((struct proc *, struct linux_getgid_args *)); -int osf1_sigprocmask __P((struct proc *, struct osf1_sigprocmask_args *)); -int linux_sigpending __P((struct proc *, struct linux_sigpending_args *)); -int linux_ioctl __P((struct proc *, struct linux_ioctl_args *)); -int linux_symlink __P((struct proc *, struct linux_symlink_args *)); -int linux_readlink __P((struct proc *, struct linux_readlink_args *)); -int linux_execve __P((struct proc *, struct linux_execve_args *)); -int linux_getpagesize __P((struct proc *, struct linux_getpagesize_args *)); -int linux_vfork __P((struct proc *, struct linux_vfork_args *)); -int linux_newstat __P((struct proc *, struct linux_newstat_args *)); -int linux_newlstat __P((struct proc *, struct linux_newlstat_args *)); -int linux_mmap __P((struct proc *, struct linux_mmap_args *)); -int linux_munmap __P((struct proc *, struct linux_munmap_args *)); -int linux_mprotect __P((struct proc *, struct linux_mprotect_args *)); -int linux_madvise __P((struct proc *, struct linux_madvise_args *)); -int linux_vhangup __P((struct proc *, struct linux_vhangup_args *)); -int linux_setgroups __P((struct proc *, struct linux_setgroups_args *)); -int linux_getgroups __P((struct proc *, struct linux_getgroups_args *)); -int linux_setpgid __P((struct proc *, struct linux_setpgid_args *)); -int osf1_setitimer __P((struct proc *, struct osf1_setitimer_args *)); -int linux_gethostname __P((struct proc *, struct linux_gethostname_args *)); -int linux_getdtablesize __P((struct proc *, struct linux_getdtablesize_args *)); -int linux_newfstat __P((struct proc *, struct linux_newfstat_args *)); -int linux_fcntl __P((struct proc *, struct linux_fcntl_args *)); -int osf1_select __P((struct proc *, struct osf1_select_args *)); -int osf1_socket __P((struct proc *, struct osf1_socket_args *)); -int linux_connect __P((struct proc *, struct linux_connect_args *)); -int osf1_sigreturn __P((struct proc *, struct osf1_sigreturn_args *)); -int osf1_sigsuspend __P((struct proc *, struct osf1_sigsuspend_args *)); -int linux_recvmsg __P((struct proc *, struct linux_recvmsg_args *)); -int linux_sendmsg __P((struct proc *, struct linux_sendmsg_args *)); -int osf1_gettimeofday __P((struct proc *, struct osf1_gettimeofday_args *)); -int osf1_getrusage __P((struct proc *, struct osf1_getrusage_args *)); -int linux_rename __P((struct proc *, struct linux_rename_args *)); -int linux_truncate __P((struct proc *, struct linux_truncate_args *)); -int osf1_sendto __P((struct proc *, struct osf1_sendto_args *)); -int linux_socketpair __P((struct proc *, struct linux_socketpair_args *)); -int linux_mkdir __P((struct proc *, struct linux_mkdir_args *)); -int linux_rmdir __P((struct proc *, struct linux_rmdir_args *)); -int linux_getrlimit __P((struct proc *, struct linux_getrlimit_args *)); -int linux_setrlimit __P((struct proc *, struct linux_setrlimit_args *)); -int linux_quotactl __P((struct proc *, struct linux_quotactl_args *)); -int osf1_sigaction __P((struct proc *, struct osf1_sigaction_args *)); -int linux_msgctl __P((struct proc *, struct linux_msgctl_args *)); -int linux_msgget __P((struct proc *, struct linux_msgget_args *)); -int linux_msgrcv __P((struct proc *, struct linux_msgrcv_args *)); -int linux_msgsnd __P((struct proc *, struct linux_msgsnd_args *)); -int linux_semctl __P((struct proc *, struct linux_semctl_args *)); -int linux_semget __P((struct proc *, struct linux_semget_args *)); -int linux_semop __P((struct proc *, struct linux_semop_args *)); -int linux_lchown __P((struct proc *, struct linux_lchown_args *)); -int linux_shmat __P((struct proc *, struct linux_shmat_args *)); -int linux_shmctl __P((struct proc *, struct linux_shmctl_args *)); -int linux_shmdt __P((struct proc *, struct linux_shmdt_args *)); -int linux_shmget __P((struct proc *, struct linux_shmget_args *)); -int linux_msync __P((struct proc *, struct linux_msync_args *)); -int linux_getpgid __P((struct proc *, struct linux_getpgid_args *)); -int linux_getsid __P((struct proc *, struct linux_getsid_args *)); -int linux_sigaltstack __P((struct proc *, struct linux_sigaltstack_args *)); -int osf1_sysinfo __P((struct proc *, struct osf1_sysinfo_args *)); -int linux_sysfs __P((struct proc *, struct linux_sysfs_args *)); -int osf1_getsysinfo __P((struct proc *, struct osf1_getsysinfo_args *)); -int osf1_setsysinfo __P((struct proc *, struct osf1_setsysinfo_args *)); -int linux_bdflush __P((struct proc *, struct linux_bdflush_args *)); -int linux_sethae __P((struct proc *, struct linux_sethae_args *)); -int linux_mount __P((struct proc *, struct linux_mount_args *)); -int linux_old_adjtimex __P((struct proc *, struct linux_old_adjtimex_args *)); -int linux_swapoff __P((struct proc *, struct linux_swapoff_args *)); -int linux_getdents __P((struct proc *, struct linux_getdents_args *)); -int linux_create_module __P((struct proc *, struct linux_create_module_args *)); -int linux_init_module __P((struct proc *, struct linux_init_module_args *)); -int linux_delete_module __P((struct proc *, struct linux_delete_module_args *)); -int linux_get_kernel_syms __P((struct proc *, struct linux_get_kernel_syms_args *)); -int linux_syslog __P((struct proc *, struct linux_syslog_args *)); -int linux_reboot __P((struct proc *, struct linux_reboot_args *)); -int linux_clone __P((struct proc *, struct linux_clone_args *)); -int linux_uselib __P((struct proc *, struct linux_uselib_args *)); -int linux_sysinfo __P((struct proc *, struct linux_sysinfo_args *)); -int linux_sysctl __P((struct proc *, struct linux_sysctl_args *)); -int linux_oldumount __P((struct proc *, struct linux_oldumount_args *)); -int linux_times __P((struct proc *, struct linux_times_args *)); -int linux_personality __P((struct proc *, struct linux_personality_args *)); -int linux_setfsuid __P((struct proc *, struct linux_setfsuid_args *)); -int linux_setfsgid __P((struct proc *, struct linux_setfsgid_args *)); -int linux_ustat __P((struct proc *, struct linux_ustat_args *)); -int linux_statfs __P((struct proc *, struct linux_statfs_args *)); -int linux_fstatfs __P((struct proc *, struct linux_fstatfs_args *)); -int linux_sched_setscheduler __P((struct proc *, struct linux_sched_setscheduler_args *)); -int linux_sched_getscheduler __P((struct proc *, struct linux_sched_getscheduler_args *)); -int linux_sched_get_priority_max __P((struct proc *, struct linux_sched_get_priority_max_args *)); -int linux_sched_get_priority_min __P((struct proc *, struct linux_sched_get_priority_min_args *)); -int linux_newuname __P((struct proc *, struct linux_newuname_args *)); -int linux_mremap __P((struct proc *, struct linux_mremap_args *)); -int linux_nfsservctl __P((struct proc *, struct linux_nfsservctl_args *)); -int linux_pciconfig_read __P((struct proc *, struct linux_pciconfig_read_args *)); -int linux_pciconfig_write __P((struct proc *, struct linux_pciconfig_write_args *)); -int linux_query_module __P((struct proc *, struct linux_query_module_args *)); -int linux_prctl __P((struct proc *, struct linux_prctl_args *)); -int linux_pread __P((struct proc *, struct linux_pread_args *)); -int linux_pwrite __P((struct proc *, struct linux_pwrite_args *)); -int linux_rt_sigreturn __P((struct proc *, struct linux_rt_sigreturn_args *)); -int linux_rt_sigaction __P((struct proc *, struct linux_rt_sigaction_args *)); -int linux_rt_sigprocmask __P((struct proc *, struct linux_rt_sigprocmask_args *)); -int linux_rt_sigpending __P((struct proc *, struct linux_rt_sigpending_args *)); -int linux_rt_sigtimedwait __P((struct proc *, struct linux_rt_sigtimedwait_args *)); -int linux_rt_sigqueueinfo __P((struct proc *, struct linux_rt_sigqueueinfo_args *)); -int linux_rt_sigsuspend __P((struct proc *, struct linux_rt_sigsuspend_args *)); -int linux_select __P((struct proc *, struct linux_select_args *)); -int linux_getitimer __P((struct proc *, struct linux_getitimer_args *)); -int linux_setitimer __P((struct proc *, struct linux_setitimer_args *)); -int linux_utimes __P((struct proc *, struct linux_utimes_args *)); -int linux_wait4 __P((struct proc *, struct linux_wait4_args *)); -int linux_adjtimex __P((struct proc *, struct linux_adjtimex_args *)); -int linux_getcwd __P((struct proc *, struct linux_getcwd_args *)); -int linux_capget __P((struct proc *, struct linux_capget_args *)); -int linux_capset __P((struct proc *, struct linux_capset_args *)); -int linux_sendfile __P((struct proc *, struct linux_sendfile_args *)); -int linux_pivot_root __P((struct proc *, struct linux_pivot_root_args *)); -int linux_mincore __P((struct proc *, struct linux_mincore_args *)); -int linux_pciconfig_iobase __P((struct proc *, struct linux_pciconfig_iobase_args *)); -int linux_getdents64 __P((struct proc *, struct linux_getdents64_args *)); +int linux_fork __P((struct thread *, struct linux_fork_args *)); +int osf1_wait4 __P((struct thread *, struct osf1_wait4_args *)); +int linux_link __P((struct thread *, struct linux_link_args *)); +int linux_unlink __P((struct thread *, struct linux_unlink_args *)); +int linux_chdir __P((struct thread *, struct linux_chdir_args *)); +int linux_mknod __P((struct thread *, struct linux_mknod_args *)); +int linux_chmod __P((struct thread *, struct linux_chmod_args *)); +int linux_chown __P((struct thread *, struct linux_chown_args *)); +int linux_brk __P((struct thread *, struct linux_brk_args *)); +int linux_lseek __P((struct thread *, struct linux_lseek_args *)); +int linux_getpid __P((struct thread *, struct linux_getpid_args *)); +int linux_umount __P((struct thread *, struct linux_umount_args *)); +int linux_getuid __P((struct thread *, struct linux_getuid_args *)); +int linux_ptrace __P((struct thread *, struct linux_ptrace_args *)); +int linux_access __P((struct thread *, struct linux_access_args *)); +int linux_kill __P((struct thread *, struct linux_kill_args *)); +int linux_open __P((struct thread *, struct linux_open_args *)); +int linux_getgid __P((struct thread *, struct linux_getgid_args *)); +int osf1_sigprocmask __P((struct thread *, struct osf1_sigprocmask_args *)); +int linux_sigpending __P((struct thread *, struct linux_sigpending_args *)); +int linux_ioctl __P((struct thread *, struct linux_ioctl_args *)); +int linux_symlink __P((struct thread *, struct linux_symlink_args *)); +int linux_readlink __P((struct thread *, struct linux_readlink_args *)); +int linux_execve __P((struct thread *, struct linux_execve_args *)); +int linux_getpagesize __P((struct thread *, struct linux_getpagesize_args *)); +int linux_vfork __P((struct thread *, struct linux_vfork_args *)); +int linux_newstat __P((struct thread *, struct linux_newstat_args *)); +int linux_newlstat __P((struct thread *, struct linux_newlstat_args *)); +int linux_mmap __P((struct thread *, struct linux_mmap_args *)); +int linux_munmap __P((struct thread *, struct linux_munmap_args *)); +int linux_mprotect __P((struct thread *, struct linux_mprotect_args *)); +int linux_madvise __P((struct thread *, struct linux_madvise_args *)); +int linux_vhangup __P((struct thread *, struct linux_vhangup_args *)); +int linux_setgroups __P((struct thread *, struct linux_setgroups_args *)); +int linux_getgroups __P((struct thread *, struct linux_getgroups_args *)); +int linux_setpgid __P((struct thread *, struct linux_setpgid_args *)); +int osf1_setitimer __P((struct thread *, struct osf1_setitimer_args *)); +int linux_gethostname __P((struct thread *, struct linux_gethostname_args *)); +int linux_getdtablesize __P((struct thread *, struct linux_getdtablesize_args *)); +int linux_newfstat __P((struct thread *, struct linux_newfstat_args *)); +int linux_fcntl __P((struct thread *, struct linux_fcntl_args *)); +int osf1_select __P((struct thread *, struct osf1_select_args *)); +int osf1_socket __P((struct thread *, struct osf1_socket_args *)); +int linux_connect __P((struct thread *, struct linux_connect_args *)); +int osf1_sigreturn __P((struct thread *, struct osf1_sigreturn_args *)); +int osf1_sigsuspend __P((struct thread *, struct osf1_sigsuspend_args *)); +int linux_recvmsg __P((struct thread *, struct linux_recvmsg_args *)); +int linux_sendmsg __P((struct thread *, struct linux_sendmsg_args *)); +int osf1_gettimeofday __P((struct thread *, struct osf1_gettimeofday_args *)); +int osf1_getrusage __P((struct thread *, struct osf1_getrusage_args *)); +int linux_rename __P((struct thread *, struct linux_rename_args *)); +int linux_truncate __P((struct thread *, struct linux_truncate_args *)); +int osf1_sendto __P((struct thread *, struct osf1_sendto_args *)); +int linux_socketpair __P((struct thread *, struct linux_socketpair_args *)); +int linux_mkdir __P((struct thread *, struct linux_mkdir_args *)); +int linux_rmdir __P((struct thread *, struct linux_rmdir_args *)); +int linux_getrlimit __P((struct thread *, struct linux_getrlimit_args *)); +int linux_setrlimit __P((struct thread *, struct linux_setrlimit_args *)); +int linux_quotactl __P((struct thread *, struct linux_quotactl_args *)); +int osf1_sigaction __P((struct thread *, struct osf1_sigaction_args *)); +int linux_msgctl __P((struct thread *, struct linux_msgctl_args *)); +int linux_msgget __P((struct thread *, struct linux_msgget_args *)); +int linux_msgrcv __P((struct thread *, struct linux_msgrcv_args *)); +int linux_msgsnd __P((struct thread *, struct linux_msgsnd_args *)); +int linux_semctl __P((struct thread *, struct linux_semctl_args *)); +int linux_semget __P((struct thread *, struct linux_semget_args *)); +int linux_semop __P((struct thread *, struct linux_semop_args *)); +int linux_lchown __P((struct thread *, struct linux_lchown_args *)); +int linux_shmat __P((struct thread *, struct linux_shmat_args *)); +int linux_shmctl __P((struct thread *, struct linux_shmctl_args *)); +int linux_shmdt __P((struct thread *, struct linux_shmdt_args *)); +int linux_shmget __P((struct thread *, struct linux_shmget_args *)); +int linux_msync __P((struct thread *, struct linux_msync_args *)); +int linux_getpgid __P((struct thread *, struct linux_getpgid_args *)); +int linux_getsid __P((struct thread *, struct linux_getsid_args *)); +int linux_sigaltstack __P((struct thread *, struct linux_sigaltstack_args *)); +int osf1_sysinfo __P((struct thread *, struct osf1_sysinfo_args *)); +int linux_sysfs __P((struct thread *, struct linux_sysfs_args *)); +int osf1_getsysinfo __P((struct thread *, struct osf1_getsysinfo_args *)); +int osf1_setsysinfo __P((struct thread *, struct osf1_setsysinfo_args *)); +int linux_bdflush __P((struct thread *, struct linux_bdflush_args *)); +int linux_sethae __P((struct thread *, struct linux_sethae_args *)); +int linux_mount __P((struct thread *, struct linux_mount_args *)); +int linux_old_adjtimex __P((struct thread *, struct linux_old_adjtimex_args *)); +int linux_swapoff __P((struct thread *, struct linux_swapoff_args *)); +int linux_getdents __P((struct thread *, struct linux_getdents_args *)); +int linux_create_module __P((struct thread *, struct linux_create_module_args *)); +int linux_init_module __P((struct thread *, struct linux_init_module_args *)); +int linux_delete_module __P((struct thread *, struct linux_delete_module_args *)); +int linux_get_kernel_syms __P((struct thread *, struct linux_get_kernel_syms_args *)); +int linux_syslog __P((struct thread *, struct linux_syslog_args *)); +int linux_reboot __P((struct thread *, struct linux_reboot_args *)); +int linux_clone __P((struct thread *, struct linux_clone_args *)); +int linux_uselib __P((struct thread *, struct linux_uselib_args *)); +int linux_sysinfo __P((struct thread *, struct linux_sysinfo_args *)); +int linux_sysctl __P((struct thread *, struct linux_sysctl_args *)); +int linux_oldumount __P((struct thread *, struct linux_oldumount_args *)); +int linux_times __P((struct thread *, struct linux_times_args *)); +int linux_personality __P((struct thread *, struct linux_personality_args *)); +int linux_setfsuid __P((struct thread *, struct linux_setfsuid_args *)); +int linux_setfsgid __P((struct thread *, struct linux_setfsgid_args *)); +int linux_ustat __P((struct thread *, struct linux_ustat_args *)); +int linux_statfs __P((struct thread *, struct linux_statfs_args *)); +int linux_fstatfs __P((struct thread *, struct linux_fstatfs_args *)); +int linux_sched_setscheduler __P((struct thread *, struct linux_sched_setscheduler_args *)); +int linux_sched_getscheduler __P((struct thread *, struct linux_sched_getscheduler_args *)); +int linux_sched_get_priority_max __P((struct thread *, struct linux_sched_get_priority_max_args *)); +int linux_sched_get_priority_min __P((struct thread *, struct linux_sched_get_priority_min_args *)); +int linux_newuname __P((struct thread *, struct linux_newuname_args *)); +int linux_mremap __P((struct thread *, struct linux_mremap_args *)); +int linux_nfsservctl __P((struct thread *, struct linux_nfsservctl_args *)); +int linux_pciconfig_read __P((struct thread *, struct linux_pciconfig_read_args *)); +int linux_pciconfig_write __P((struct thread *, struct linux_pciconfig_write_args *)); +int linux_query_module __P((struct thread *, struct linux_query_module_args *)); +int linux_prctl __P((struct thread *, struct linux_prctl_args *)); +int linux_pread __P((struct thread *, struct linux_pread_args *)); +int linux_pwrite __P((struct thread *, struct linux_pwrite_args *)); +int linux_rt_sigreturn __P((struct thread *, struct linux_rt_sigreturn_args *)); +int linux_rt_sigaction __P((struct thread *, struct linux_rt_sigaction_args *)); +int linux_rt_sigprocmask __P((struct thread *, struct linux_rt_sigprocmask_args *)); +int linux_rt_sigpending __P((struct thread *, struct linux_rt_sigpending_args *)); +int linux_rt_sigtimedwait __P((struct thread *, struct linux_rt_sigtimedwait_args *)); +int linux_rt_sigqueueinfo __P((struct thread *, struct linux_rt_sigqueueinfo_args *)); +int linux_rt_sigsuspend __P((struct thread *, struct linux_rt_sigsuspend_args *)); +int linux_select __P((struct thread *, struct linux_select_args *)); +int linux_getitimer __P((struct thread *, struct linux_getitimer_args *)); +int linux_setitimer __P((struct thread *, struct linux_setitimer_args *)); +int linux_utimes __P((struct thread *, struct linux_utimes_args *)); +int linux_wait4 __P((struct thread *, struct linux_wait4_args *)); +int linux_adjtimex __P((struct thread *, struct linux_adjtimex_args *)); +int linux_getcwd __P((struct thread *, struct linux_getcwd_args *)); +int linux_capget __P((struct thread *, struct linux_capget_args *)); +int linux_capset __P((struct thread *, struct linux_capset_args *)); +int linux_sendfile __P((struct thread *, struct linux_sendfile_args *)); +int linux_pivot_root __P((struct thread *, struct linux_pivot_root_args *)); +int linux_mincore __P((struct thread *, struct linux_mincore_args *)); +int linux_pciconfig_iobase __P((struct thread *, struct linux_pciconfig_iobase_args *)); +int linux_getdents64 __P((struct thread *, struct linux_getdents64_args *)); #ifdef COMPAT_43 diff --git a/sys/alpha/tlsb/zs_tlsb.c b/sys/alpha/tlsb/zs_tlsb.c index f6b67b8..ee3dbef 100644 --- a/sys/alpha/tlsb/zs_tlsb.c +++ b/sys/alpha/tlsb/zs_tlsb.c @@ -264,7 +264,7 @@ zs_cnputc(dev_t dev, int c) static int -zsopen(dev_t dev, int flag, int mode, struct proc *p) +zsopen(dev_t dev, int flag, int mode, struct thread *td) { struct zs_softc *sc = ZS_SOFTC(minor(dev)); struct tty *tp; @@ -290,7 +290,7 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; ttsetwater(tp); setuptimeout = 1; - } else if ((tp->t_state & TS_XCLUDE) && suser(p)) { + } else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) { splx(s); return EBUSY; } @@ -311,7 +311,7 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p) } static int -zsclose(dev_t dev, int flag, int mode, struct proc *p) +zsclose(dev_t dev, int flag, int mode, struct thread *td) { struct zs_softc *sc = ZS_SOFTC(minor(dev)); struct tty *tp; @@ -332,7 +332,7 @@ zsclose(dev_t dev, int flag, int mode, struct proc *p) } static int -zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct zs_softc *sc = ZS_SOFTC(minor(dev)); struct tty *tp; @@ -343,7 +343,7 @@ zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) tp = ZS_SOFTC(minor(dev))->tp; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index 5c68f81..8096d3c 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -48,10 +48,10 @@ IDTVEC(vec_name) ; \ movl $KPSEL,%eax ; \ mov %ax,%fs ; \ FAKE_MCOUNT(13*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ - call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ + call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ addl $4, %esp ; \ movl $0, lapic+LA_EOI ; \ lock ; \ @@ -59,7 +59,7 @@ IDTVEC(vec_name) ; \ movl intr_countp + (irq_num) * 4, %eax ; \ lock ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -152,8 +152,8 @@ IDTVEC(vec_name) ; \ MASK_LEVEL_IRQ(irq_num) ; \ EOI_IRQ(irq_num) ; \ 0: ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ ; \ /* entry point used by doreti_unpend for HWIs. */ \ __CONCAT(Xresume,irq_num): ; \ @@ -162,7 +162,7 @@ __CONCAT(Xresume,irq_num): ; \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -227,10 +227,10 @@ Xhardclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_hardclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti @@ -252,10 +252,10 @@ Xstatclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ FAKE_MCOUNT(13*4(%esp)) - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_statclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S index 0f2f7a8..075aa36 100644 --- a/sys/amd64/amd64/cpu_switch.S +++ b/sys/amd64/amd64/cpu_switch.S @@ -77,17 +77,17 @@ ENTRY(cpu_throw) ENTRY(cpu_switch) /* switch to new process. first, save context as needed */ - movl PCPU(CURPROC),%ecx + movl PCPU(CURTHREAD),%ecx /* if no process to save, don't bother */ testl %ecx,%ecx jz sw1 - - movl P_VMSPACE(%ecx), %edx + movl TD_PROC(%ecx), %eax + movl P_VMSPACE(%eax), %edx movl PCPU(CPUID), %eax btrl %eax, VM_PMAP+PM_ACTIVE(%edx) - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx movl (%esp),%eax /* Hardware registers */ movl %eax,PCB_EIP(%edx) @@ -124,7 +124,7 @@ ENTRY(cpu_switch) #ifdef DEV_NPX /* have we used fp, and need a save? */ - cmpl %ecx,PCPU(NPXPROC) + cmpl %ecx,PCPU(NPXTHREAD) jne 1f addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ pushl %edx @@ -133,7 +133,11 @@ ENTRY(cpu_switch) 1: #endif /* DEV_NPX */ +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* save is done, now choose a new process */ + /* But still trashing space above the old "Top Of Stack".. */ sw1: #ifdef SMP @@ -143,17 +147,17 @@ sw1: cmpl $0,PCPU(CPUID) je 1f - movl PCPU(IDLEPROC), %eax - jmp sw1b + movl PCPU(IDLETHREAD), %eax + jmp sw1b /* Idle thread can run on any kernel context */ 1: #endif /* - * Choose a new process to schedule. chooseproc() returns idleproc + * Choose a new process to schedule. choosethread() returns idleproc * if it cannot find another process to run. */ sw1a: - call chooseproc /* trash ecx, edx, ret eax*/ + call choosethread /* trash ecx, edx, ret eax*/ #ifdef INVARIANTS testl %eax,%eax /* no process? */ @@ -163,15 +167,20 @@ sw1b: movl %eax,%ecx #ifdef INVARIANTS - cmpb $SRUN,P_STAT(%ecx) + movl TD_PROC(%ecx), %eax /* XXXKSE */ + cmpb $SRUN,P_STAT(%eax) jne badsw2 #endif - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx #if defined(SWTCH_OPTIM_STATS) incl swtch_optim_stats #endif + +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* switch address space */ movl %cr3,%ebx cmpl PCB_CR3(%edx),%ebx @@ -181,9 +190,8 @@ sw1b: incl tlb_flush_count #endif movl PCB_CR3(%edx),%ebx - movl %ebx,%cr3 + movl %ebx,%cr3 /* LOAD NEW PAGE TABLES */ 4: - movl PCPU(CPUID), %esi cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ je 1f @@ -191,12 +199,9 @@ sw1b: movl PCB_EXT(%edx), %edi /* new tss descriptor */ jmp 2f 1: - /* update common_tss.tss_esp0 pointer */ - movl %edx, %ebx /* pcb */ - addl $(UPAGES * PAGE_SIZE - 16), %ebx - movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 - + /* esp points to base of usable stack */ + movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */ btrl %esi, private_tss jae 3f PCPU_ADDR(COMMON_TSSD, %edi) @@ -210,7 +215,9 @@ sw1b: movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */ ltr %si 3: - movl P_VMSPACE(%ecx), %ebx + /* note in a vmspace that this cpu is using it */ + movl TD_PROC(%ecx),%eax /* get proc from thread XXXKSE */ + movl P_VMSPACE(%eax), %ebx /* get vmspace of proc */ movl PCPU(CPUID), %eax btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) @@ -233,22 +240,23 @@ sw1b: #endif /** GRAB_LOPRIO */ #endif /* SMP */ movl %edx, PCPU(CURPCB) - movl %ecx, PCPU(CURPROC) /* into next process */ + movl %ecx, PCPU(CURTHREAD) /* into next process */ #ifdef SMP /* XXX FIXME: we should be restoring the local APIC TPR */ #endif /* SMP */ - cmpl $0, PCB_USERLDT(%edx) - jnz 1f - movl _default_ldt,%eax - cmpl PCPU(CURRENTLDT),%eax - je 2f - lldt _default_ldt - movl %eax,PCPU(CURRENTLDT) + cmpl $0, PCB_USERLDT(%edx) /* if there is one */ + jnz 1f /* then use it */ + movl _default_ldt,%eax /* We will use the default */ + cmpl PCPU(CURRENTLDT),%eax /* check to see if already loaded */ + je 2f /* if so skip reload */ + lldt _default_ldt /* load the default... we trust it. */ + movl %eax,PCPU(CURRENTLDT) /* store what we have */ jmp 2f -1: pushl %edx - call set_user_ldt + +1: pushl %edx /* call a non-trusting routine */ + call set_user_ldt /* to check and load the ldt */ popl %edx 2: @@ -275,7 +283,7 @@ cpu_switch_load_gs: andl $0x0000fc00,%eax /* reserved bits */ pushl %ebx movl PCB_DR7(%edx),%ebx - andl $~0x0000fc00,%ebx + andl $~0x0000fc00,%ebx /* re-enable the restored watchpoints */ orl %ebx,%eax popl %ebx movl %eax,%dr7 @@ -322,25 +330,25 @@ ENTRY(savectx) #ifdef DEV_NPX /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the + * If npxthread == NULL, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps (the old book-keeping with FP flags in the pcb * always lost for dumps because the dump pcb has 0 flags). * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the + * If npxthread != NULL, then we have to save the npx h/w state to + * npxthread's pcb and copy it to the requested pcb, or save to the * requested pcb and reload. Copying is easier because we would * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ pushfl cli - movl PCPU(NPXPROC),%eax + movl PCPU(NPXTHREAD),%eax testl %eax,%eax je 1f pushl %ecx - movl P_ADDR(%eax),%eax + movl TD_PCB(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax pushl %eax diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c index a2e5018..7e78088 100644 --- a/sys/amd64/amd64/db_interface.c +++ b/sys/amd64/amd64/db_interface.c @@ -351,23 +351,24 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu) gd = GLOBALDATA; #endif db_printf("cpuid = %d\n", gd->gd_cpuid); - db_printf("curproc = "); - if (gd->gd_curproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_curproc, - gd->gd_curproc->p_pid, gd->gd_curproc->p_comm); + db_printf("curthread = "); + if (gd->gd_curthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread, + gd->gd_curthread->td_proc->p_pid, gd->gd_curthread->td_proc->p_comm); else db_printf("none\n"); db_printf("curpcb = %p\n", gd->gd_curpcb); - db_printf("npxproc = "); - if (gd->gd_npxproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_npxproc, - gd->gd_npxproc->p_pid, gd->gd_npxproc->p_comm); + db_printf("npxthread = "); + if (gd->gd_npxthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_npxthread, + gd->gd_npxthread->td_proc->p_pid, gd->gd_npxthread->td_proc->p_comm); else db_printf("none\n"); - db_printf("idleproc = "); - if (gd->gd_idleproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_idleproc, - gd->gd_idleproc->p_pid, gd->gd_idleproc->p_comm); + db_printf("idlethread = "); + if (gd->gd_idlethread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread, + gd->gd_idlethread->td_proc->p_pid, + gd->gd_idlethread->td_proc->p_comm); else db_printf("none\n"); diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index dc1e2f0..3a07050 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -291,13 +291,15 @@ db_stack_trace_cmd(addr, have_addr, count, modif) boolean_t first; struct pcb *pcb; struct proc *p; + struct thread *td; pid_t pid; if (count == -1) count = 1024; if (!have_addr) { - p = curproc; + td = curthread; + p = td->td_proc; frame = (struct i386_frame *)ddb_regs.tf_ebp; if (frame == NULL) frame = (struct i386_frame *)(ddb_regs.tf_esp - 4); @@ -310,8 +312,9 @@ db_stack_trace_cmd(addr, have_addr, count, modif) * The pcb for curproc is not valid at this point, * so fall back to the default case. */ - if (pid == curproc->p_pid) { - p = curproc; + if (pid == curthread->td_proc->p_pid) { + td = curthread; + p = td->td_proc; frame = (struct i386_frame *)ddb_regs.tf_ebp; if (frame == NULL) frame = (struct i386_frame *) @@ -333,7 +336,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("pid %d swapped out\n", pid); return; } - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread.td_pcb; /* XXXKSE */ frame = (struct i386_frame *)pcb->pcb_ebp; if (frame == NULL) frame = (struct i386_frame *) diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 4fe3d04..84534ea 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -128,23 +128,23 @@ void stop_emulating __P((void)); #endif /* __GNUC__ */ #ifdef CPU_ENABLE_SSE -#define GET_FPU_CW(proc) \ +#define GET_FPU_CW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_cw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_sw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (cpu_fxsr ? \ &(pcb)->pcb_save.sv_xmm.sv_ex_sw : \ &(pcb)->pcb_save.sv_87.sv_ex_sw) #else /* CPU_ENABLE_SSE */ -#define GET_FPU_CW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) +#define GET_FPU_CW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (&(pcb)->pcb_save.sv_87.sv_ex_sw) #endif /* CPU_ENABLE_SSE */ @@ -241,7 +241,7 @@ static void npx_intr(dummy) void *dummy; { - struct proc *p; + struct thread *td; /* * The BUSY# latch must be cleared in all cases so that the next @@ -250,22 +250,22 @@ npx_intr(dummy) outb(0xf0, 0); /* - * npxproc is normally non-null here. In that case, schedule an + * npxthread is normally non-null here. In that case, schedule an * AST to finish the exception handling in the correct context - * (this interrupt may occur after the process has entered the + * (this interrupt may occur after the thread has entered the * kernel via a syscall or an interrupt). Otherwise, the npx - * state of the process that caused this interrupt must have been - * pushed to the process' pcb, and clearing of the busy latch + * state of the thread that caused this interrupt must have been + * pushed to the thread' pcb, and clearing of the busy latch * above has finished the (essentially null) handling of this * interrupt. Control will eventually return to the instruction * that caused it and it will repeat. We will eventually (usually * soon) win the race to handle the interrupt properly. */ - p = PCPU_GET(npxproc); - if (p != NULL) { - p->p_addr->u_pcb.pcb_flags |= PCB_NPXTRAP; + td = PCPU_GET(npxthread); + if (td != NULL) { + td->td_pcb->pcb_flags |= PCB_NPXTRAP; mtx_lock_spin(&sched_lock); - p->p_sflag |= PS_ASTPENDING; + td->td_kse->ke_flags |= KEF_ASTPENDING; mtx_unlock_spin(&sched_lock); } } @@ -570,7 +570,7 @@ npxinit(control) /* * fninit has the same h/w bugs as fnsave. Use the detoxified * fnsave to throw away any junk in the fpu. npxsave() initializes - * the fpu and sets npxproc = NULL as important side effects. + * the fpu and sets npxthread = NULL as important side effects. */ savecrit = critical_enter(); npxsave(&dummy); @@ -586,13 +586,13 @@ npxinit(control) * Free coprocessor (if we have it). */ void -npxexit(p) - struct proc *p; +npxexit(td) + struct thread *td; { critical_t savecrit; savecrit = critical_enter(); - if (p == PCPU_GET(npxproc)) + if (td == PCPU_GET(npxthread)) npxsave(&PCPU_GET(curpcb)->pcb_save); critical_exit(savecrit); #ifdef NPX_DEBUG @@ -607,8 +607,9 @@ npxexit(p) */ if (masked_exceptions & 0x0d) log(LOG_ERR, - "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", - p->p_pid, p->p_comm, masked_exceptions); + "pid %d (%s) exited with masked floating" + " point exceptions 0x%02x\n", + td->td_proc->p_pid, td->td_proc->p_comm, masked_exceptions); } #endif } @@ -809,8 +810,8 @@ npxtrap() u_long *exstat; if (!npx_exists) { - printf("npxtrap: npxproc = %p, curproc = %p, npx_exists = %d\n", - PCPU_GET(npxproc), curproc, npx_exists); + printf("npxtrap: npxthread = %p, curthread = %p, npx_exists = %d\n", + PCPU_GET(npxthread), curthread, npx_exists); panic("npxtrap from nowhere"); } savecrit = critical_enter(); @@ -820,18 +821,18 @@ npxtrap() * state to memory. Fetch the relevant parts of the state from * wherever they are. */ - if (PCPU_GET(npxproc) != curproc) { - control = GET_FPU_CW(curproc); - status = GET_FPU_SW(curproc); + if (PCPU_GET(npxthread) != curthread) { + control = GET_FPU_CW(curthread); + status = GET_FPU_SW(curthread); } else { fnstcw(&control); fnstsw(&status); } - exstat = GET_FPU_EXSW_PTR(&curproc->p_addr->u_pcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); *exstat = status; - if (PCPU_GET(npxproc) != curproc) - GET_FPU_SW(curproc) &= ~0x80bf; + if (PCPU_GET(npxthread) != curthread) + GET_FPU_SW(curthread) &= ~0x80bf; else fnclex(); critical_exit(savecrit); @@ -841,7 +842,7 @@ npxtrap() /* * Implement device not available (DNA) exception * - * It would be better to switch FP context here (if curproc != npxproc) + * It would be better to switch FP context here (if curthread != npxthread) * and not necessarily for every context switch, but it is too hard to * access foreign pcb's. */ @@ -853,9 +854,9 @@ npxdna() if (!npx_exists) return (0); - if (PCPU_GET(npxproc) != NULL) { - printf("npxdna: npxproc = %p, curproc = %p\n", - PCPU_GET(npxproc), curproc); + if (PCPU_GET(npxthread) != NULL) { + printf("npxdna: npxthread = %p, curthread = %p\n", + PCPU_GET(npxthread), curthread); panic("npxdna"); } s = critical_enter(); @@ -863,7 +864,7 @@ npxdna() /* * Record new context early in case frstor causes an IRQ13. */ - PCPU_SET(npxproc, CURPROC); + PCPU_SET(npxthread, curthread); exstat = GET_FPU_EXSW_PTR(PCPU_GET(curpcb)); *exstat = 0; @@ -895,13 +896,13 @@ npxdna() * after the process has entered the kernel. It may even be delivered after * the fnsave here completes. A spurious IRQ13 for the fnsave is handled in * the same way as a very-late-arriving non-spurious IRQ13 from user mode: - * it is normally ignored at first because we set npxproc to NULL; it is + * it is normally ignored at first because we set npxthread to NULL; it is * normally retriggered in npxdna() after return to user mode. * * npxsave() must be called with interrupts disabled, so that it clears - * npxproc atomically with saving the state. We require callers to do the + * npxthread atomically with saving the state. We require callers to do the * disabling, since most callers need to disable interrupts anyway to call - * npxsave() atomically with checking npxproc. + * npxsave() atomically with checking npxthread. * * A previous version of npxsave() went to great lengths to excecute fnsave * with interrupts enabled in case executing it froze the CPU. This case @@ -917,7 +918,7 @@ npxsave(addr) fpusave(addr); start_emulating(); - PCPU_SET(npxproc, NULL); + PCPU_SET(npxthread, NULL); } static void diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 0704db7..8f4be92 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -37,7 +37,7 @@ * $FreeBSD$ */ -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -50,6 +50,7 @@ #include <sys/mutex.h> #include <sys/socket.h> #include <sys/resourcevar.h> +#include <sys/user.h> /* XXX */ #ifdef KTR_PERCPU #include <sys/ktr.h> @@ -79,21 +80,31 @@ ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); -ASSYM(P_INTR_NESTING_LEVEL, offsetof(struct proc, p_intr_nesting_level)); ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_WCHAN, offsetof(struct proc, p_wchan)); +ASSYM(P_UAREA, offsetof(struct proc, p_uarea)); + +/*ASSYM(TD_STAT, offsetof(struct thread, td__stat));*/ +ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); +ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); +ASSYM(TD_KSE, offsetof(struct thread, td_kse)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level)); + +ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags)); -ASSYM(PS_ASTPENDING, PS_ASTPENDING); -ASSYM(PS_NEEDRESCHED, PS_NEEDRESCHED); +ASSYM(KEF_ASTPENDING, KEF_ASTPENDING); +ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED); ASSYM(SSLEEP, SSLEEP); ASSYM(SRUN, SRUN); ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); -ASSYM(UPAGES, UPAGES); +/* ASSYM(UPAGES, UPAGES);*/ +ASSYM(UAREA_PAGES, UAREA_PAGES); +ASSYM(KSTACK_PAGES, KSTACK_PAGES); ASSYM(PAGE_SIZE, PAGE_SIZE); ASSYM(NPTEPG, NPTEPG); ASSYM(NPDEPG, NPDEPG); @@ -133,9 +144,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -#ifdef SMP ASSYM(PCB_SIZE, sizeof(struct pcb)); -#endif ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); @@ -166,9 +175,9 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_PRVSPACE, offsetof(struct globaldata, gd_prvspace)); -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); -ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc)); -ASSYM(GD_IDLEPROC, offsetof(struct globaldata, gd_idleproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); +ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); +ASSYM(GD_IDLETHREAD, offsetof(struct globaldata, gd_idlethread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index 97a1e16..ab3dad5 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -147,9 +147,11 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */ #endif KPTphys: .long 0 /* phys addr of kernel page tables */ - .globl proc0paddr -proc0paddr: .long 0 /* address of proc 0 address space */ -p0upa: .long 0 /* phys addr of proc0's UPAGES */ + .globl proc0uarea, proc0kstack +proc0uarea: .long 0 /* address of proc 0 uarea space */ +proc0kstack: .long 0 /* address of proc 0 kstack space */ +p0upa: .long 0 /* phys addr of proc0's UAREA */ +p0kpa: .long 0 /* phys addr of proc0's STACK */ vm86phystk: .long 0 /* PA of vm86/bios stack */ @@ -369,13 +371,14 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: /* set up bootstrap stack */ - movl proc0paddr,%eax /* location of in-kernel pages */ - leal UPAGES*PAGE_SIZE(%eax),%esp /* bootstrap stack end location */ + movl proc0kstack,%eax /* location of in-kernel stack */ + /* bootstrap stack end location */ + leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp xorl %ebp,%ebp /* mark end of frames */ movl IdlePTD,%esi - movl %esi,PCB_CR3(%eax) + movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax) testl $CPUID_PGE, R(cpu_feature) jz 1f @@ -762,10 +765,15 @@ no_kernend: movl %esi,R(IdlePTD) /* Allocate UPAGES */ - ALLOCPAGES(UPAGES) + ALLOCPAGES(UAREA_PAGES) movl %esi,R(p0upa) addl $KERNBASE, %esi - movl %esi, R(proc0paddr) + movl %esi, R(proc0uarea) + + ALLOCPAGES(KSTACK_PAGES) + movl %esi,R(p0kpa) + addl $KERNBASE, %esi + movl %esi, R(proc0kstack) ALLOCPAGES(1) /* vm86/bios stack */ movl %esi,R(vm86phystk) @@ -833,7 +841,12 @@ map_read_write: /* Map proc0's UPAGES in the physical way ... */ movl R(p0upa), %eax - movl $UPAGES, %ecx + movl $(UAREA_PAGES), %ecx + fillkptphys($PG_RW) + +/* Map proc0's KSTACK in the physical way ... */ + movl R(p0kpa), %eax + movl $(KSTACK_PAGES), %ecx fillkptphys($PG_RW) /* Map ISA hole */ diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s index 97a1e16..ab3dad5 100644 --- a/sys/amd64/amd64/locore.s +++ b/sys/amd64/amd64/locore.s @@ -147,9 +147,11 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */ #endif KPTphys: .long 0 /* phys addr of kernel page tables */ - .globl proc0paddr -proc0paddr: .long 0 /* address of proc 0 address space */ -p0upa: .long 0 /* phys addr of proc0's UPAGES */ + .globl proc0uarea, proc0kstack +proc0uarea: .long 0 /* address of proc 0 uarea space */ +proc0kstack: .long 0 /* address of proc 0 kstack space */ +p0upa: .long 0 /* phys addr of proc0's UAREA */ +p0kpa: .long 0 /* phys addr of proc0's STACK */ vm86phystk: .long 0 /* PA of vm86/bios stack */ @@ -369,13 +371,14 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: /* set up bootstrap stack */ - movl proc0paddr,%eax /* location of in-kernel pages */ - leal UPAGES*PAGE_SIZE(%eax),%esp /* bootstrap stack end location */ + movl proc0kstack,%eax /* location of in-kernel stack */ + /* bootstrap stack end location */ + leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp xorl %ebp,%ebp /* mark end of frames */ movl IdlePTD,%esi - movl %esi,PCB_CR3(%eax) + movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax) testl $CPUID_PGE, R(cpu_feature) jz 1f @@ -762,10 +765,15 @@ no_kernend: movl %esi,R(IdlePTD) /* Allocate UPAGES */ - ALLOCPAGES(UPAGES) + ALLOCPAGES(UAREA_PAGES) movl %esi,R(p0upa) addl $KERNBASE, %esi - movl %esi, R(proc0paddr) + movl %esi, R(proc0uarea) + + ALLOCPAGES(KSTACK_PAGES) + movl %esi,R(p0kpa) + addl $KERNBASE, %esi + movl %esi, R(proc0kstack) ALLOCPAGES(1) /* vm86/bios stack */ movl %esi,R(vm86phystk) @@ -833,7 +841,12 @@ map_read_write: /* Map proc0's UPAGES in the physical way ... */ movl R(p0upa), %eax - movl $UPAGES, %ecx + movl $(UAREA_PAGES), %ecx + fillkptphys($PG_RW) + +/* Map proc0's KSTACK in the physical way ... */ + movl R(p0kpa), %eax + movl $(KSTACK_PAGES), %ecx fillkptphys($PG_RW) /* Map ISA hole */ diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index e0dade2..6711515 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -49,7 +49,7 @@ #include "opt_msgbuf.h" #include "opt_npx.h" #include "opt_perfmon.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" /* #include "opt_userconfig.h" */ #include <sys/param.h> @@ -289,14 +289,16 @@ osendsig(catcher, sig, mask, code) struct osigframe sf; struct osigframe *fp; struct proc *p; + struct thread *td; struct sigacts *psp; struct trapframe *regs; int oonstack; - p = curproc; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); /* Allocate and validate space for the signal handler context. */ @@ -386,7 +388,7 @@ osendsig(catcher, sig, mask, code) if (regs->tf_eflags & PSL_VM) { /* XXX confusing names: `tf' isn't a trapframe; `regs' is. */ struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; @@ -409,7 +411,7 @@ osendsig(catcher, sig, mask, code) * ...Kill the process. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -434,12 +436,14 @@ sendsig(catcher, sig, mask, code) { struct sigframe sf; struct proc *p; + struct thread *td; struct sigacts *psp; struct trapframe *regs; struct sigframe *sfp; int oonstack; - p = curproc; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; #ifdef COMPAT_43 @@ -448,7 +452,7 @@ sendsig(catcher, sig, mask, code) return; } #endif - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); /* Save user context. */ @@ -528,7 +532,7 @@ sendsig(catcher, sig, mask, code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; @@ -561,7 +565,7 @@ sendsig(catcher, sig, mask, code) * ...Kill the process. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -586,17 +590,18 @@ sendsig(catcher, sig, mask, code) */ #ifdef COMPAT_43 int -osigreturn(p, uap) - struct proc *p; +osigreturn(td, uap) + struct thread *td; struct osigreturn_args /* { struct osigcontext *sigcntxp; } */ *uap; { struct trapframe *regs; struct osigcontext *scp; + struct proc *p = td->td_proc; int eflags; - regs = p->p_frame; + regs = td->td_frame; scp = uap->sigcntxp; if (!useracc((caddr_t)scp, sizeof(*scp), VM_PROT_READ)) return (EFAULT); @@ -609,9 +614,9 @@ osigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (td->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &td->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -697,12 +702,13 @@ osigreturn(p, uap) #endif int -sigreturn(p, uap) - struct proc *p; +sigreturn(td, uap) + struct thread *td; struct sigreturn_args /* { ucontext_t *sigcntxp; } */ *uap; { + struct proc *p = td->td_proc; struct trapframe *regs; ucontext_t *ucp; int cs, eflags; @@ -712,7 +718,7 @@ sigreturn(p, uap) if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ)) return (EFAULT); if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516) - return (osigreturn(p, (struct osigreturn_args *)uap)); + return (osigreturn(td, (struct osigreturn_args *)uap)); /* * Since ucp is not an osigcontext but a ucontext_t, we have to * check again if all of it is accessible. A ucontext_t is @@ -724,7 +730,7 @@ sigreturn(p, uap) if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ)) return (EFAULT); - regs = p->p_frame; + regs = td->td_frame; eflags = ucp->uc_mcontext.mc_eflags; if (eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; @@ -734,9 +740,9 @@ sigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (td->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &td->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -865,14 +871,14 @@ cpu_idle(void) * Clear registers on exec */ void -setregs(p, entry, stack, ps_strings) - struct proc *p; +setregs(td, entry, stack, ps_strings) + struct thread *td; u_long entry; u_long stack; u_long ps_strings; { - struct trapframe *regs = p->p_frame; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *regs = td->td_frame; + struct pcb *pcb = td->td_pcb; if (pcb->pcb_ldt) user_ldt_free(pcb); @@ -925,7 +931,7 @@ setregs(p, entry, stack, ps_strings) * traps to the emulator (if it is done at all) mainly because * emulators don't provide an entry point for initialization. */ - p->p_addr->u_pcb.pcb_flags &= ~FP_SOFTFP; + td->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * Arrange to trap the next npx or `fwait' instruction (see npx.c @@ -948,7 +954,7 @@ setregs(p, entry, stack, ps_strings) * Make sure sure edx is 0x0 on entry. Linux binaries depend * on it. */ - p->p_retval[1] = 0; + td->td_retval[1] = 0; } void @@ -1016,7 +1022,8 @@ extern int has_f00f_bug; static struct i386tss dblfault_tss; static char dblfault_stack[PAGE_SIZE]; -extern struct user *proc0paddr; +extern struct user *proc0uarea; +extern vm_offset_t proc0kstack; /* software prototypes -- in more palatable form */ @@ -1661,8 +1668,12 @@ init386(first) struct region_descriptor r_gdt, r_idt; #endif - proc0.p_addr = proc0paddr; - + proc_linkup(&proc0); + proc0.p_uarea = proc0uarea; + thread0 = &proc0.p_thread; + thread0->td_kstack = proc0kstack; + thread0->td_pcb = (struct pcb *) + (thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; atdevbase = ISA_HOLE_START + KERNBASE; metadata_missing = 0; @@ -1721,10 +1732,11 @@ init386(first) lgdt(&r_gdt); /* setup curproc so that mutexes work */ - PCPU_SET(curproc, &proc0); + + PCPU_SET(curthread, thread0); PCPU_SET(spinlocks, NULL); - LIST_INIT(&proc0.p_contested); + LIST_INIT(&thread0->td_contested); /* * Initialize mutexes. @@ -1828,8 +1840,9 @@ init386(first) initializecpu(); /* Initialize CPU registers */ /* make an initial tss so cpu can get interrupt stack on syscall! */ - PCPU_SET(common_tss.tss_esp0, - (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16); + /* Note: -16 is so we can grow the trapframe if we came from vm86 */ + PCPU_SET(common_tss.tss_esp0, thread0->td_kstack + + KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16); PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL)); gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; @@ -1884,10 +1897,10 @@ init386(first) _udatasel = LSEL(LUDATA_SEL, SEL_UPL); /* setup proc 0's pcb */ - proc0.p_addr->u_pcb.pcb_flags = 0; - proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD; - proc0.p_addr->u_pcb.pcb_ext = 0; - proc0.p_frame = &proc0_tf; + thread0->td_pcb->pcb_flags = 0; /* XXXKSE */ + thread0->td_pcb->pcb_cr3 = (int)IdlePTD; + thread0->td_pcb->pcb_ext = 0; + thread0->td_frame = &proc0_tf; } #if defined(I586_CPU) && !defined(NO_F00F_HACK) @@ -1930,31 +1943,26 @@ f00f_hack(void *unused) { #endif /* defined(I586_CPU) && !NO_F00F_HACK */ int -ptrace_set_pc(p, addr) - struct proc *p; - unsigned long addr; +ptrace_set_pc(struct thread *td, unsigned long addr) { - p->p_frame->tf_eip = addr; + td->td_frame->tf_eip = addr; return (0); } int -ptrace_single_step(p) - struct proc *p; +ptrace_single_step(struct thread *td) { - p->p_frame->tf_eflags |= PSL_T; + td->td_frame->tf_eflags |= PSL_T; return (0); } int -fill_regs(p, regs) - struct proc *p; - struct reg *regs; +fill_regs(struct thread *td, struct reg *regs) { struct pcb *pcb; struct trapframe *tp; - tp = p->p_frame; + tp = td->td_frame; regs->r_fs = tp->tf_fs; regs->r_es = tp->tf_es; regs->r_ds = tp->tf_ds; @@ -1970,20 +1978,18 @@ fill_regs(p, regs) regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; regs->r_gs = pcb->pcb_gs; return (0); } int -set_regs(p, regs) - struct proc *p; - struct reg *regs; +set_regs(struct thread *td, struct reg *regs) { struct pcb *pcb; struct trapframe *tp; - tp = p->p_frame; + tp = td->td_frame; if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) || !CS_SECURE(regs->r_cs)) return (EINVAL); @@ -2002,7 +2008,7 @@ set_regs(p, regs) tp->tf_eflags = regs->r_eflags; tp->tf_esp = regs->r_esp; tp->tf_ss = regs->r_ss; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; pcb->pcb_gs = regs->r_gs; return (0); } @@ -2062,45 +2068,39 @@ set_fpregs_xmm(sv_87, sv_xmm) #endif /* CPU_ENABLE_SSE */ int -fill_fpregs(p, fpregs) - struct proc *p; - struct fpreg *fpregs; +fill_fpregs(struct thread *td, struct fpreg *fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - fill_fpregs_xmm(&p->p_addr->u_pcb.pcb_save.sv_xmm, + fill_fpregs_xmm(&td->td_pcb->pcb_save.sv_xmm, (struct save87 *)fpregs); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(&p->p_addr->u_pcb.pcb_save.sv_87, fpregs, sizeof *fpregs); + bcopy(&td->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs); return (0); } int -set_fpregs(p, fpregs) - struct proc *p; - struct fpreg *fpregs; +set_fpregs(struct thread *td, struct fpreg *fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { set_fpregs_xmm((struct save87 *)fpregs, - &p->p_addr->u_pcb.pcb_save.sv_xmm); + &td->td_pcb->pcb_save.sv_xmm); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &p->p_addr->u_pcb.pcb_save.sv_87, sizeof *fpregs); + bcopy(fpregs, &td->td_pcb->pcb_save.sv_87, sizeof *fpregs); return (0); } int -fill_dbregs(p, dbregs) - struct proc *p; - struct dbreg *dbregs; +fill_dbregs(struct thread *td, struct dbreg *dbregs) { struct pcb *pcb; - if (p == NULL) { + if (td == NULL) { dbregs->dr0 = rdr0(); dbregs->dr1 = rdr1(); dbregs->dr2 = rdr2(); @@ -2109,9 +2109,8 @@ fill_dbregs(p, dbregs) dbregs->dr5 = rdr5(); dbregs->dr6 = rdr6(); dbregs->dr7 = rdr7(); - } - else { - pcb = &p->p_addr->u_pcb; + } else { + pcb = td->td_pcb; dbregs->dr0 = pcb->pcb_dr0; dbregs->dr1 = pcb->pcb_dr1; dbregs->dr2 = pcb->pcb_dr2; @@ -2125,15 +2124,13 @@ fill_dbregs(p, dbregs) } int -set_dbregs(p, dbregs) - struct proc *p; - struct dbreg *dbregs; +set_dbregs(struct thread *td, struct dbreg *dbregs) { struct pcb *pcb; int i; u_int32_t mask1, mask2; - if (p == NULL) { + if (td == NULL) { load_dr0(dbregs->dr0); load_dr1(dbregs->dr1); load_dr2(dbregs->dr2); @@ -2142,8 +2139,7 @@ set_dbregs(p, dbregs) load_dr5(dbregs->dr5); load_dr6(dbregs->dr6); load_dr7(dbregs->dr7); - } - else { + } else { /* * Don't let an illegal value for dr7 get set. Specifically, * check for undefined settings. Setting these bit patterns @@ -2155,7 +2151,7 @@ set_dbregs(p, dbregs) if ((dbregs->dr7 & mask1) == mask2) return (EINVAL); - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; /* * Don't let a process set a breakpoint that is not within the @@ -2172,7 +2168,7 @@ set_dbregs(p, dbregs) * from within kernel mode? */ - if (suser(p) != 0) { + if (suser_td(td) != 0) { if (dbregs->dr7 & 0x3) { /* dr0 is enabled */ if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index 5eded32..48ecff8 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -98,17 +98,17 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors"); struct mem_range_softc mem_range_softc; static int -mmclose(dev_t dev, int flags, int fmt, struct proc *p) +mmclose(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { case 14: - p->p_frame->tf_eflags &= ~PSL_IOPL; + td->td_frame->tf_eflags &= ~PSL_IOPL; } return (0); } static int -mmopen(dev_t dev, int flags, int fmt, struct proc *p) +mmopen(dev_t dev, int flags, int fmt, struct thread *td) { int error; @@ -119,12 +119,12 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p) return (EPERM); break; case 14: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); if (securelevel > 0) return (EPERM); - p->p_frame->tf_eflags |= PSL_IOPL; + td->td_frame->tf_eflags |= PSL_IOPL; break; } return (0); @@ -235,7 +235,7 @@ memmmap(dev_t dev, vm_offset_t offset, int prot) * and mem_range_attr_set. */ static int -mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int nd, error = 0; struct mem_range_op *mo = (struct mem_range_op *)data; diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index d912e0c..f558524 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index d912e0c..f558524 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 3ce91ab..b41b11f 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -71,7 +71,7 @@ #include "opt_disable_pse.h" #include "opt_pmap.h" #include "opt_msgbuf.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -171,7 +171,7 @@ vm_offset_t kernel_vm_end; static vm_zone_t pvzone; static struct vm_zone pvzone_store; static struct vm_object pvzone_obj; -static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0; +static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; static int pmap_pagedaemon_waken = 0; static struct pv_entry *pvinit; @@ -183,7 +183,7 @@ static pt_entry_t *CMAP2, *ptmmap; caddr_t CADDR1 = 0, ptvmmap = 0; static caddr_t CADDR2; static pt_entry_t *msgbufmap; -struct msgbuf *msgbufp=0; +struct msgbuf *msgbufp = 0; /* * Crashdump maps. @@ -819,7 +819,7 @@ retry: } /* - * Create the UPAGES for a new process. + * Create the Uarea stack for a new process. * This routine directly affects the fork perf for a process. */ void @@ -840,22 +840,22 @@ pmap_new_proc(p) */ upobj = p->p_upages_obj; if (upobj == NULL) { - upobj = vm_object_allocate(OBJT_DEFAULT, UPAGES); + upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES); p->p_upages_obj = upobj; } - /* get a kernel virtual address for the UPAGES for this proc */ - up = (vm_offset_t)p->p_addr; + /* get a kernel virtual address for the U area for this proc */ + up = (vm_offset_t)p->p_uarea; if (up == 0) { - up = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); + up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE); if (up == 0) panic("pmap_new_proc: upage allocation failed"); - p->p_addr = (struct user *)up; + p->p_uarea = (struct user *)up; } ptek = (unsigned *)vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { /* * Get a kernel stack page */ @@ -892,7 +892,7 @@ pmap_new_proc(p) } /* - * Dispose the UPAGES for a process that has exited. + * Dispose the U-Area for a process that has exited. * This routine directly impacts the exit perf of a process. */ void @@ -906,9 +906,9 @@ pmap_dispose_proc(p) unsigned *ptek, oldpte; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; + up = (vm_offset_t)p->p_uarea; ptek = (unsigned *)vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_dispose_proc: upage already missing?"); @@ -927,7 +927,7 @@ pmap_dispose_proc(p) } /* - * Allow the UPAGES for a process to be prejudicially paged out. + * Allow the U_AREA for a process to be prejudicially paged out. */ void pmap_swapout_proc(p) @@ -939,8 +939,8 @@ pmap_swapout_proc(p) vm_page_t m; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_swapout_proc: upage already missing?"); @@ -951,7 +951,7 @@ pmap_swapout_proc(p) } /* - * Bring the UPAGES for a specified process back in. + * Bring the U-Area for a specified process back in. */ void pmap_swapin_proc(p) @@ -963,8 +963,8 @@ pmap_swapin_proc(p) vm_page_t m; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); if (m->valid != VM_PAGE_BITS_ALL) { @@ -980,6 +980,191 @@ pmap_swapin_proc(p) } } +/* + * Create the kernel stack (including pcb for i386) for a new thread. + * This routine directly affects the fork perf for a process and + * create performance for a thread. + */ +void +pmap_new_thread(td) + struct thread *td; +{ +#ifdef I386_CPU + int updateneeded = 0; +#endif + int i; + vm_object_t ksobj; + vm_page_t m; + vm_offset_t ks; + unsigned *ptek, oldpte; + + /* + * allocate object for the kstack + */ + ksobj = td->td_kstack_obj; + if (ksobj == NULL) { + ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES); + td->td_kstack_obj = ksobj; + } + +#ifdef KSTACK_GUARD + /* get a kernel virtual address for the kstack for this proc */ + ks = (vm_offset_t)td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, + (KSTACK_PAGES + 1) * PAGE_SIZE); + if (ks == 0) + panic("pmap_new_thread: kstack allocation failed"); + ks += PAGE_SIZE; + td->td_kstack = ks; + } + + ptek = (unsigned *)vtopte(ks - PAGE_SIZE); + oldpte = *ptek; + *ptek = 0; + if (oldpte) { +#ifdef I386_CPU + updateneeded = 1; +#else + invlpg(ks - PAGE_SIZE); +#endif + } + ptek++; +#else + /* get a kernel virtual address for the kstack for this proc */ + ks = (vm_offset_t)td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE); + if (ks == 0) + panic("pmap_new_thread: kstack allocation failed"); + td->td_kstack = ks; + } +#endif + for (i = 0; i < KSTACK_PAGES; i++) { + /* + * Get a kernel stack page + */ + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + + /* + * Wire the page + */ + m->wire_count++; + cnt.v_wire_count++; + + oldpte = *(ptek + i); + /* + * Enter the page into the kernel address space. + */ + *(ptek + i) = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag; + if (oldpte) { +#ifdef I386_CPU + updateneeded = 1; +#else + invlpg(ks + i * PAGE_SIZE); +#endif + } + + vm_page_wakeup(m); + vm_page_flag_clear(m, PG_ZERO); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + m->valid = VM_PAGE_BITS_ALL; + } +#ifdef I386_CPU + if (updateneeded) + invltlb(); +#endif +} + +/* + * Dispose the kernel stack for a thread that has exited. + * This routine directly impacts the exit perf of a process and thread. + */ +void +pmap_dispose_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + unsigned *ptek, oldpte; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + ptek = (unsigned *)vtopte(ks); + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_dispose_thread: kstack already missing?"); + vm_page_busy(m); + oldpte = *(ptek + i); + *(ptek + i) = 0; +#ifndef I386_CPU + invlpg(ks + i * PAGE_SIZE); +#endif + vm_page_unwire(m, 0); + vm_page_free(m); + } +#ifdef I386_CPU + invltlb(); +#endif +} + +/* + * Allow the Kernel stack for a thread to be prejudicially paged out. + */ +void +pmap_swapout_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_swapout_thread: kstack already missing?"); + vm_page_dirty(m); + vm_page_unwire(m, 0); + pmap_kremove(ks + i * PAGE_SIZE); + } +} + +/* + * Bring the kernel stack for a specified thread back in. + */ +void +pmap_swapin_thread(td) + struct thread *td; +{ + int i, rv; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); + if (m->valid != VM_PAGE_BITS_ALL) { + rv = vm_pager_get_pages(ksobj, &m, 1, 0); + if (rv != VM_PAGER_OK) + panic("pmap_swapin_thread: cannot get kstack for proc: %d\n", td->td_proc->p_pid); + m = vm_page_lookup(ksobj, i); + m->valid = VM_PAGE_BITS_ALL; + } + vm_page_wire(m); + vm_page_wakeup(m); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + } +} + /*************************************************** * Page table page management routines..... ***************************************************/ @@ -1517,7 +1702,7 @@ pmap_collect() { int i; vm_page_t m; - static int warningdone=0; + static int warningdone = 0; if (pmap_pagedaemon_waken == 0) return; @@ -2333,7 +2518,7 @@ retry: pmap->pm_stats.resident_count += size >> PAGE_SHIFT; npdes = size >> PDRSHIFT; - for(i=0;i<npdes;i++) { + for(i = 0; i < npdes; i++) { pmap->pm_pdir[ptepindex] = (pd_entry_t) (ptepa | PG_U | PG_RW | PG_V | PG_PS); ptepa += NBPDR; @@ -2444,7 +2629,7 @@ pmap_prefault(pmap, addra, entry) vm_page_t m, mpte; vm_object_t object; - if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) + if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace))) return; object = entry->object.vm_object; @@ -2561,6 +2746,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) vm_offset_t pdnxt; unsigned src_frame, dst_frame; vm_page_t m; + pd_entry_t saved_pde; if (dst_addr != src_addr) return; @@ -2580,7 +2766,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) invltlb(); #endif } - + saved_pde = (pd_entry_t)((u_int32_t)APTDpde & (PG_FRAME|PG_RW | PG_V)); for(addr = src_addr; addr < end_addr; addr = pdnxt) { unsigned *src_pte, *dst_pte; vm_page_t dstmpte, srcmpte; @@ -2637,6 +2823,16 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * block. */ dstmpte = pmap_allocpte(dst_pmap, addr); + if (((u_int32_t)APTDpde & PG_FRAME) != + ((u_int32_t)saved_pde & PG_FRAME)) { + APTDpde = saved_pde; +printf ("IT HAPPENNED!"); +#if defined(SMP) + cpu_invltlb(); +#else + invltlb(); +#endif + } if ((*dst_pte == 0) && (ptetemp = *src_pte)) { /* * Clear the modified and @@ -2831,7 +3027,7 @@ pmap_remove_pages(pmap, sva, eva) vm_page_t m; #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY - if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) { + if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace))) { printf("warning: pmap_remove_pages called with non-current pmap\n"); return; } @@ -2839,8 +3035,8 @@ pmap_remove_pages(pmap, sva, eva) s = splvm(); for(pv = TAILQ_FIRST(&pmap->pm_pvlist); - pv; - pv = npv) { + pv; + pv = npv) { if (pv->pv_va >= eva || pv->pv_va < sva) { npv = TAILQ_NEXT(pv, pv_plist); @@ -2854,6 +3050,12 @@ pmap_remove_pages(pmap, sva, eva) #endif tpte = *pte; + if (tpte == 0) { + printf("TPTE at %p IS ZERO @ VA %08x\n", + pte, pv->pv_va); + panic("bad pte"); + } + /* * We cannot remove wired pages from a process' mapping at this time */ @@ -2861,15 +3063,19 @@ pmap_remove_pages(pmap, sva, eva) npv = TAILQ_NEXT(pv, pv_plist); continue; } - *pte = 0; m = PHYS_TO_VM_PAGE(tpte); + KASSERT(m->phys_addr == (tpte & PG_FRAME), + ("vm_page_t %p phys_addr mismatch %08x %08x", + m, m->phys_addr, tpte)); KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %x", tpte)); pv->pv_pmap->pm_stats.resident_count--; + *pte = 0; + /* * Update the vm_page_t clean and reference bits. */ @@ -2877,7 +3083,6 @@ pmap_remove_pages(pmap, sva, eva) vm_page_dirty(m); } - npv = TAILQ_NEXT(pv, pv_plist); TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); @@ -3255,11 +3460,13 @@ pmap_mincore(pmap, addr) } void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { + struct proc *p = td->td_proc; pmap_t pmap; + u_int32_t cr3; - pmap = vmspace_pmap(p->p_vmspace); + pmap = vmspace_pmap(td->td_proc->p_vmspace); #if defined(SMP) pmap->pm_active |= 1 << PCPU_GET(cpuid); #else @@ -3268,7 +3475,20 @@ pmap_activate(struct proc *p) #if defined(SWTCH_OPTIM_STATS) tlb_flush_count++; #endif - load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir)); + cr3 = vtophys(pmap->pm_pdir); + /* XXXKSE this is wrong. + * pmap_activate is for the current thread on the current cpu + */ + if (p->p_flag & P_KSES) { + /* Make sure all other cr3 entries are updated. */ + /* what if they are running? XXXKSE (maybe abort them) */ + FOREACH_THREAD_IN_PROC(p, td) { + td->td_pcb->pcb_cr3 = cr3; + } + } else { + td->td_pcb->pcb_cr3 = cr3; + } + load_cr3(cr3); } vm_offset_t @@ -3301,14 +3521,14 @@ pmap_pid_dump(int pid) int i,j; index = 0; pmap = vmspace_pmap(p->p_vmspace); - for(i=0;i<1024;i++) { + for(i = 0; i < 1024; i++) { pd_entry_t *pde; unsigned *pte; unsigned base = i << PDRSHIFT; pde = &pmap->pm_pdir[i]; if (pde && pmap_pde_v(pde)) { - for(j=0;j<1024;j++) { + for(j = 0; j < 1024; j++) { unsigned va = base + (j << PAGE_SHIFT); if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) { if (index) { diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index 55bc29c..81181cc 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -216,8 +216,8 @@ ENTRY(i586_bzero) * complicated since we avoid it if possible at all levels. We * want to localize the complications even when that increases them. * Here the extra work involves preserving CR0_TS in TS. - * `npxproc != NULL' is supposed to be the condition that all the - * FPU resources belong to an application, but npxproc and CR0_TS + * `npxthread != NULL' is supposed to be the condition that all the + * FPU resources belong to an application, but npxthread and CR0_TS * aren't set atomically enough for this condition to work in * interrupt handlers. * @@ -241,7 +241,7 @@ ENTRY(i586_bzero) * method. CR0_TS must be preserved although it is very likely to * always end up as clear. */ - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz1 /* @@ -303,7 +303,7 @@ fpureg_i586_bzero_loop: cmpl $8,%ecx jae fpureg_i586_bzero_loop - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz3 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -517,7 +517,7 @@ ENTRY(i586_bcopy) sarb $1,kernel_fpu_lock jc small_i586_bcopy - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc1 /* XXX turn off handling of cases 1-2, as above. */ @@ -593,7 +593,7 @@ large_i586_bcopy_loop: cmpl $64,%ecx jae 4b - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc2 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -991,14 +991,14 @@ ENTRY(fastmove) /* XXX grab FPU context atomically. */ cli -/* if (npxproc != NULL) { */ - cmpl $0,PCPU(NPXPROC) +/* if (npxthread != NULL) { */ + cmpl $0,PCPU(NPXTHREAD) je 6f /* fnsave(&curpcb->pcb_savefpu); */ movl PCPU(CURPCB),%eax fnsave PCB_SAVEFPU(%eax) -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* NPXTHREAD = NULL; */ + movl $0,PCPU(NPXTHREAD) /* } */ 6: /* now we own the FPU. */ @@ -1026,9 +1026,9 @@ ENTRY(fastmove) movl -4(%ebp),%edi /* stop_emulating(); */ clts -/* npxproc = curproc; */ - movl PCPU(CURPROC),%eax - movl %eax,PCPU(NPXPROC) +/* npxthread = curthread; */ + movl PCPU(CURTHREAD),%eax + movl %eax,PCPU(NPXTHREAD) movl PCPU(CURPCB),%eax /* XXX end of atomic FPU context grab. */ @@ -1113,8 +1113,8 @@ fastmove_loop: smsw %ax orb $CR0_TS,%al lmsw %ax -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* npxthread = NULL; */ + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti @@ -1154,7 +1154,7 @@ fastmove_fault: smsw %ax orb $CR0_TS,%al lmsw %ax - movl $0,PCPU(NPXPROC) + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti diff --git a/sys/amd64/amd64/support.s b/sys/amd64/amd64/support.s index 55bc29c..81181cc 100644 --- a/sys/amd64/amd64/support.s +++ b/sys/amd64/amd64/support.s @@ -216,8 +216,8 @@ ENTRY(i586_bzero) * complicated since we avoid it if possible at all levels. We * want to localize the complications even when that increases them. * Here the extra work involves preserving CR0_TS in TS. - * `npxproc != NULL' is supposed to be the condition that all the - * FPU resources belong to an application, but npxproc and CR0_TS + * `npxthread != NULL' is supposed to be the condition that all the + * FPU resources belong to an application, but npxthread and CR0_TS * aren't set atomically enough for this condition to work in * interrupt handlers. * @@ -241,7 +241,7 @@ ENTRY(i586_bzero) * method. CR0_TS must be preserved although it is very likely to * always end up as clear. */ - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz1 /* @@ -303,7 +303,7 @@ fpureg_i586_bzero_loop: cmpl $8,%ecx jae fpureg_i586_bzero_loop - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz3 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -517,7 +517,7 @@ ENTRY(i586_bcopy) sarb $1,kernel_fpu_lock jc small_i586_bcopy - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc1 /* XXX turn off handling of cases 1-2, as above. */ @@ -593,7 +593,7 @@ large_i586_bcopy_loop: cmpl $64,%ecx jae 4b - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc2 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -991,14 +991,14 @@ ENTRY(fastmove) /* XXX grab FPU context atomically. */ cli -/* if (npxproc != NULL) { */ - cmpl $0,PCPU(NPXPROC) +/* if (npxthread != NULL) { */ + cmpl $0,PCPU(NPXTHREAD) je 6f /* fnsave(&curpcb->pcb_savefpu); */ movl PCPU(CURPCB),%eax fnsave PCB_SAVEFPU(%eax) -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* NPXTHREAD = NULL; */ + movl $0,PCPU(NPXTHREAD) /* } */ 6: /* now we own the FPU. */ @@ -1026,9 +1026,9 @@ ENTRY(fastmove) movl -4(%ebp),%edi /* stop_emulating(); */ clts -/* npxproc = curproc; */ - movl PCPU(CURPROC),%eax - movl %eax,PCPU(NPXPROC) +/* npxthread = curthread; */ + movl PCPU(CURTHREAD),%eax + movl %eax,PCPU(NPXTHREAD) movl PCPU(CURPCB),%eax /* XXX end of atomic FPU context grab. */ @@ -1113,8 +1113,8 @@ fastmove_loop: smsw %ax orb $CR0_TS,%al lmsw %ax -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* npxthread = NULL; */ + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti @@ -1154,7 +1154,7 @@ fastmove_fault: smsw %ax orb $CR0_TS,%al lmsw %ax - movl $0,PCPU(NPXPROC) + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s index 0f2f7a8..075aa36 100644 --- a/sys/amd64/amd64/swtch.s +++ b/sys/amd64/amd64/swtch.s @@ -77,17 +77,17 @@ ENTRY(cpu_throw) ENTRY(cpu_switch) /* switch to new process. first, save context as needed */ - movl PCPU(CURPROC),%ecx + movl PCPU(CURTHREAD),%ecx /* if no process to save, don't bother */ testl %ecx,%ecx jz sw1 - - movl P_VMSPACE(%ecx), %edx + movl TD_PROC(%ecx), %eax + movl P_VMSPACE(%eax), %edx movl PCPU(CPUID), %eax btrl %eax, VM_PMAP+PM_ACTIVE(%edx) - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx movl (%esp),%eax /* Hardware registers */ movl %eax,PCB_EIP(%edx) @@ -124,7 +124,7 @@ ENTRY(cpu_switch) #ifdef DEV_NPX /* have we used fp, and need a save? */ - cmpl %ecx,PCPU(NPXPROC) + cmpl %ecx,PCPU(NPXTHREAD) jne 1f addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ pushl %edx @@ -133,7 +133,11 @@ ENTRY(cpu_switch) 1: #endif /* DEV_NPX */ +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* save is done, now choose a new process */ + /* But still trashing space above the old "Top Of Stack".. */ sw1: #ifdef SMP @@ -143,17 +147,17 @@ sw1: cmpl $0,PCPU(CPUID) je 1f - movl PCPU(IDLEPROC), %eax - jmp sw1b + movl PCPU(IDLETHREAD), %eax + jmp sw1b /* Idle thread can run on any kernel context */ 1: #endif /* - * Choose a new process to schedule. chooseproc() returns idleproc + * Choose a new process to schedule. choosethread() returns idleproc * if it cannot find another process to run. */ sw1a: - call chooseproc /* trash ecx, edx, ret eax*/ + call choosethread /* trash ecx, edx, ret eax*/ #ifdef INVARIANTS testl %eax,%eax /* no process? */ @@ -163,15 +167,20 @@ sw1b: movl %eax,%ecx #ifdef INVARIANTS - cmpb $SRUN,P_STAT(%ecx) + movl TD_PROC(%ecx), %eax /* XXXKSE */ + cmpb $SRUN,P_STAT(%eax) jne badsw2 #endif - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx #if defined(SWTCH_OPTIM_STATS) incl swtch_optim_stats #endif + +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* switch address space */ movl %cr3,%ebx cmpl PCB_CR3(%edx),%ebx @@ -181,9 +190,8 @@ sw1b: incl tlb_flush_count #endif movl PCB_CR3(%edx),%ebx - movl %ebx,%cr3 + movl %ebx,%cr3 /* LOAD NEW PAGE TABLES */ 4: - movl PCPU(CPUID), %esi cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ je 1f @@ -191,12 +199,9 @@ sw1b: movl PCB_EXT(%edx), %edi /* new tss descriptor */ jmp 2f 1: - /* update common_tss.tss_esp0 pointer */ - movl %edx, %ebx /* pcb */ - addl $(UPAGES * PAGE_SIZE - 16), %ebx - movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 - + /* esp points to base of usable stack */ + movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */ btrl %esi, private_tss jae 3f PCPU_ADDR(COMMON_TSSD, %edi) @@ -210,7 +215,9 @@ sw1b: movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */ ltr %si 3: - movl P_VMSPACE(%ecx), %ebx + /* note in a vmspace that this cpu is using it */ + movl TD_PROC(%ecx),%eax /* get proc from thread XXXKSE */ + movl P_VMSPACE(%eax), %ebx /* get vmspace of proc */ movl PCPU(CPUID), %eax btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) @@ -233,22 +240,23 @@ sw1b: #endif /** GRAB_LOPRIO */ #endif /* SMP */ movl %edx, PCPU(CURPCB) - movl %ecx, PCPU(CURPROC) /* into next process */ + movl %ecx, PCPU(CURTHREAD) /* into next process */ #ifdef SMP /* XXX FIXME: we should be restoring the local APIC TPR */ #endif /* SMP */ - cmpl $0, PCB_USERLDT(%edx) - jnz 1f - movl _default_ldt,%eax - cmpl PCPU(CURRENTLDT),%eax - je 2f - lldt _default_ldt - movl %eax,PCPU(CURRENTLDT) + cmpl $0, PCB_USERLDT(%edx) /* if there is one */ + jnz 1f /* then use it */ + movl _default_ldt,%eax /* We will use the default */ + cmpl PCPU(CURRENTLDT),%eax /* check to see if already loaded */ + je 2f /* if so skip reload */ + lldt _default_ldt /* load the default... we trust it. */ + movl %eax,PCPU(CURRENTLDT) /* store what we have */ jmp 2f -1: pushl %edx - call set_user_ldt + +1: pushl %edx /* call a non-trusting routine */ + call set_user_ldt /* to check and load the ldt */ popl %edx 2: @@ -275,7 +283,7 @@ cpu_switch_load_gs: andl $0x0000fc00,%eax /* reserved bits */ pushl %ebx movl PCB_DR7(%edx),%ebx - andl $~0x0000fc00,%ebx + andl $~0x0000fc00,%ebx /* re-enable the restored watchpoints */ orl %ebx,%eax popl %ebx movl %eax,%dr7 @@ -322,25 +330,25 @@ ENTRY(savectx) #ifdef DEV_NPX /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the + * If npxthread == NULL, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps (the old book-keeping with FP flags in the pcb * always lost for dumps because the dump pcb has 0 flags). * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the + * If npxthread != NULL, then we have to save the npx h/w state to + * npxthread's pcb and copy it to the requested pcb, or save to the * requested pcb and reload. Copying is easier because we would * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ pushfl cli - movl PCPU(NPXPROC),%eax + movl PCPU(NPXTHREAD),%eax testl %eax,%eax je 1f pushl %ecx - movl P_ADDR(%eax),%eax + movl TD_PCB(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax pushl %eax diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 23c1cdd..acca4e7 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -35,7 +35,7 @@ * */ -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -65,10 +65,10 @@ -static int i386_get_ldt __P((struct proc *, char *)); -static int i386_set_ldt __P((struct proc *, char *)); -static int i386_get_ioperm __P((struct proc *, char *)); -static int i386_set_ioperm __P((struct proc *, char *)); +static int i386_get_ldt __P((struct thread *, char *)); +static int i386_set_ldt __P((struct thread *, char *)); +static int i386_get_ioperm __P((struct thread *, char *)); +static int i386_set_ioperm __P((struct thread *, char *)); #ifdef SMP static void set_user_ldt_rv __P((struct pcb *)); #endif @@ -81,28 +81,28 @@ struct sysarch_args { #endif int -sysarch(p, uap) - struct proc *p; +sysarch(td, uap) + struct thread *td; register struct sysarch_args *uap; { int error = 0; switch(uap->op) { case I386_GET_LDT: - error = i386_get_ldt(p, uap->parms); + error = i386_get_ldt(td, uap->parms); break; case I386_SET_LDT: - error = i386_set_ldt(p, uap->parms); + error = i386_set_ldt(td, uap->parms); break; case I386_GET_IOPERM: - error = i386_get_ioperm(p, uap->parms); + error = i386_get_ioperm(td, uap->parms); break; case I386_SET_IOPERM: - error = i386_set_ioperm(p, uap->parms); + error = i386_set_ioperm(td, uap->parms); break; case I386_VM86: - error = vm86_sysarch(p, uap->parms); + error = vm86_sysarch(td, uap->parms); break; default: error = EOPNOTSUPP; @@ -112,7 +112,7 @@ sysarch(p, uap) } int -i386_extend_pcb(struct proc *p) +i386_extend_pcb(struct thread *td) { int i, offset; u_long *addr; @@ -127,12 +127,18 @@ i386_extend_pcb(struct proc *p) 0, /* default 32 size */ 0 /* granularity */ }; + struct proc *p = td->td_proc; + if (td->td_proc->p_flag & P_KSES) + return (EINVAL); /* XXXKSE */ +/* XXXKSE All the code below only works in 1:1 needs changing */ ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1)); if (ext == 0) return (ENOMEM); bzero(ext, sizeof(struct pcb_ext)); - ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16; + /* -16 is so we can convert a trapframe into vm86trapframe inplace */ + ext->ext_tss.tss_esp0 = td->td_kstack + ctob(KSTACK_PAGES) - + sizeof(struct pcb) - 16; ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); /* * The last byte of the i/o map must be followed by an 0xff byte. @@ -153,21 +159,21 @@ i386_extend_pcb(struct proc *p) ssd.ssd_limit -= ((unsigned)&ext->ext_tss - (unsigned)ext); ssdtosd(&ssd, &ext->ext_tssd); - KASSERT(p == curproc, ("giving a TSS to non-curproc")); - KASSERT(p->p_addr->u_pcb.pcb_ext == 0, ("already have a TSS!")); + KASSERT(p == curthread->td_proc, ("giving a TSS to non-curproc")); + KASSERT(td->td_pcb->pcb_ext == 0, ("already have a TSS!")); mtx_lock_spin(&sched_lock); - p->p_addr->u_pcb.pcb_ext = ext; + td->td_pcb->pcb_ext = ext; /* switch to the new TSS after syscall completes */ - p->p_sflag |= PS_NEEDRESCHED; + td->td_kse->ke_flags |= KEF_NEEDRESCHED; mtx_unlock_spin(&sched_lock); return 0; } static int -i386_set_ioperm(p, args) - struct proc *p; +i386_set_ioperm(td, args) + struct thread *td; char *args; { int i, error; @@ -177,7 +183,7 @@ i386_set_ioperm(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0) return (error); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); if (securelevel > 0) return (EPERM); @@ -188,10 +194,10 @@ i386_set_ioperm(p, args) * cause confusion. This probably requires a global 'usage registry'. */ - if (p->p_addr->u_pcb.pcb_ext == 0) - if ((error = i386_extend_pcb(p)) != 0) + if (td->td_pcb->pcb_ext == 0) + if ((error = i386_extend_pcb(td)) != 0) return (error); - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)td->td_pcb->pcb_ext->ext_iomap; if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); @@ -206,8 +212,8 @@ i386_set_ioperm(p, args) } static int -i386_get_ioperm(p, args) - struct proc *p; +i386_get_ioperm(td, args) + struct thread *td; char *args; { int i, state, error; @@ -219,12 +225,12 @@ i386_get_ioperm(p, args) if (ua.start >= IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); - if (p->p_addr->u_pcb.pcb_ext == 0) { + if (td->td_pcb->pcb_ext == 0) { ua.length = 0; goto done; } - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)td->td_pcb->pcb_ext->ext_iomap; i = ua.start; state = (iomap[i >> 3] >> (i & 7)) & 1; @@ -351,12 +357,12 @@ user_ldt_free(struct pcb *pcb) } static int -i386_get_ldt(p, args) - struct proc *p; +i386_get_ldt(td, args) + struct thread *td; char *args; { int error = 0; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; int nldt, num; union descriptor *lp; @@ -388,19 +394,19 @@ i386_get_ldt(p, args) error = copyout(lp, uap->descs, num * sizeof(union descriptor)); if (!error) - p->p_retval[0] = num; + td->td_retval[0] = num; return(error); } static int -i386_set_ldt(p, args) - struct proc *p; +i386_set_ldt(td, args) + struct thread *td; char *args; { int error = 0, i, n; int largest_ld; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; struct i386_ldt_args ua, *uap = &ua; caddr_t old_ldt_base; @@ -530,7 +536,7 @@ i386_set_ldt(p, args) &((union descriptor *)(pcb_ldt->ldt_base))[uap->start], uap->num * sizeof(union descriptor)); if (!error) - p->p_retval[0] = uap->start; + td->td_retval[0] = uap->start; critical_exit(savecrit); return(error); diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 4e72f9b..ee036c2 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -173,7 +173,8 @@ void trap(frame) struct trapframe frame; { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; u_int sticks = 0; int i = 0, ucode = 0, type, code; vm_offset_t eva; @@ -225,8 +226,8 @@ restart: ((frame.tf_eflags & PSL_VM) && !in_vm86call)) { /* user trap */ - sticks = p->p_sticks; - p->p_frame = &frame; + sticks = td->td_kse->ke_sticks; + td->td_frame = &frame; switch (type) { case T_PRIVINFLT: /* privileged instruction fault */ @@ -444,7 +445,7 @@ restart: if (in_vm86call) break; - if (p->p_intr_nesting_level != 0) + if (td->td_intr_nesting_level != 0) break; /* @@ -620,7 +621,7 @@ restart: #endif user: - userret(p, &frame, sticks); + userret(td, &frame, sticks); if (mtx_owned(&Giant)) /* XXX why would Giant be owned here? */ mtx_unlock(&Giant); out: @@ -660,7 +661,7 @@ trap_pfault(frame, usermode, eva) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (p->p_intr_nesting_level != 0 || + (td->td_intr_nesting_level != 0 || PCPU_GET(curpcb) == NULL || PCPU_GET(curpcb)->pcb_onfault == NULL))) { trap_fatal(frame, eva); @@ -696,7 +697,7 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) + if (!grow_stack (td, va)) rv = KERN_FAILURE; else /* Fault in the user page: */ @@ -728,7 +729,7 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (p->p_intr_nesting_level == 0 && + if (td->td_intr_nesting_level == 0 && PCPU_GET(curpcb) != NULL && PCPU_GET(curpcb)->pcb_onfault != NULL) { frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault; @@ -756,7 +757,8 @@ trap_pfault(frame, usermode, eva) vm_map_t map = 0; int rv = 0; vm_prot_t ftype; - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; va = trunc_page(eva); if (va >= KERNBASE) { @@ -839,7 +841,7 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (p->p_intr_nesting_level == 0 && + if (td->td_intr_nesting_level == 0 && PCPU_GET(curpcb) != NULL && PCPU_GET(curpcb)->pcb_onfault != NULL) { frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault; @@ -972,6 +974,7 @@ dblfault_handler() int trapwrite(addr) unsigned addr; { + struct thread *td; struct proc *p; vm_offset_t va; struct vmspace *vm; @@ -984,7 +987,8 @@ int trapwrite(addr) if (va >= VM_MAXUSER_ADDRESS) return (1); - p = curproc; + td = curthread; + p = td->td_proc; vm = p->p_vmspace; PROC_LOCK(p); @@ -1021,7 +1025,8 @@ syscall(frame) caddr_t params; int i; struct sysent *callp; - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; u_int sticks; int error; int narg; @@ -1039,8 +1044,8 @@ syscall(frame) } #endif - sticks = p->p_sticks; - p->p_frame = &frame; + sticks = td->td_kse->ke_sticks; + td->td_frame = &frame; params = (caddr_t)frame.tf_esp + sizeof(int); code = frame.tf_eax; @@ -1109,17 +1114,17 @@ syscall(frame) ktrsyscall(p->p_tracep, code, narg, args); } #endif - p->p_retval[0] = 0; - p->p_retval[1] = frame.tf_edx; + td->td_retval[0] = 0; + td->td_retval[1] = frame.tf_edx; STOPEVENT(p, S_SCE, narg); - error = (*callp->sy_call)(p, args); + error = (*callp->sy_call)(td, args); switch (error) { case 0: - frame.tf_eax = p->p_retval[0]; - frame.tf_edx = p->p_retval[1]; + frame.tf_eax = td->td_retval[0]; + frame.tf_edx = td->td_retval[1]; frame.tf_eflags &= ~PSL_C; break; @@ -1158,11 +1163,11 @@ bad: /* * Handle reschedule and other end-of-syscall issues */ - userret(p, &frame, sticks); + userret(td, &frame, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - ktrsysret(p->p_tracep, code, error, p->p_retval[0]); + ktrsysret(p->p_tracep, code, error, td->td_retval[0]); } #endif @@ -1183,7 +1188,7 @@ bad: STOPEVENT(p, S_SCX, code); #ifdef WITNESS - if (witness_list(p)) { + if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", syscallnames[code]); } diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 53cedff..83ddc21 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -47,7 +47,7 @@ #endif #include "opt_reset.h" #include "opt_isa.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -117,19 +117,24 @@ vm_fault_quick(v, prot) * ready to run and return to user mode. */ void -cpu_fork(p1, p2, flags) - register struct proc *p1, *p2; +cpu_fork(td1, p2, flags) + register struct thread *td1; + register struct proc *p2; int flags; { + register struct proc *p1; + struct thread *td2; struct pcb *pcb2; #ifdef DEV_NPX int savecrit; #endif + p1 = td1->td_proc; + td2 = &p2->p_thread; if ((flags & RFPROC) == 0) { if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = &p1->p_addr->u_pcb; + struct pcb *pcb1 = td1->td_pcb; struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt; if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) { pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len); @@ -145,30 +150,32 @@ cpu_fork(p1, p2, flags) /* Ensure that p1's pcb is up to date. */ #ifdef DEV_NPX - if (p1 == curproc) - p1->p_addr->u_pcb.pcb_gs = rgs(); + if (td1 == curthread) + td1->td_pcb->pcb_gs = rgs(); savecrit = critical_enter(); - if (PCPU_GET(npxproc) == p1) - npxsave(&p1->p_addr->u_pcb.pcb_save); + if (PCPU_GET(npxthread) == td1) + npxsave(&td1->td_pcb->pcb_save); critical_exit(savecrit); #endif + /* Point the pcb to the top of the stack */ + pcb2 = (struct pcb *)(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td2->td_pcb = pcb2; + /* Copy p1's pcb. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - pcb2 = &p2->p_addr->u_pcb; + bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); /* * Create a new fresh stack for the new process. * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ - p2->p_frame = (struct trapframe *) - ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1; - bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe)); + td2->td_frame = (struct trapframe *)td2->td_pcb - 1; + bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); - p2->p_frame->tf_eax = 0; /* Child returns zero */ - p2->p_frame->tf_eflags &= ~PSL_C; /* success */ - p2->p_frame->tf_edx = 1; + td2->td_frame->tf_eax = 0; /* Child returns zero */ + td2->td_frame->tf_eflags &= ~PSL_C; /* success */ + td2->td_frame->tf_edx = 1; /* * Set registers for trampoline to user mode. Leave space for the @@ -178,8 +185,8 @@ cpu_fork(p1, p2, flags) pcb2->pcb_edi = 0; pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */ pcb2->pcb_ebp = 0; - pcb2->pcb_esp = (int)p2->p_frame - sizeof(void *); - pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */ + pcb2->pcb_esp = (int)td2->td_frame - sizeof(void *); + pcb2->pcb_ebx = (int)td2; /* fork_trampoline argument */ pcb2->pcb_eip = (int)fork_trampoline; /*- * pcb2->pcb_dr*: cloned above. @@ -228,8 +235,8 @@ cpu_fork(p1, p2, flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(p, func, arg) - struct proc *p; +cpu_set_fork_handler(td, func, arg) + struct thread *td; void (*func) __P((void *)); void *arg; { @@ -237,18 +244,18 @@ cpu_set_fork_handler(p, func, arg) * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_addr->u_pcb.pcb_esi = (int) func; /* function */ - p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */ + td->td_pcb->pcb_esi = (int) func; /* function */ + td->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void -cpu_exit(p) - register struct proc *p; +cpu_exit(td) + register struct thread *td; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; #ifdef DEV_NPX - npxexit(p); + npxexit(td); #endif if (pcb->pcb_ext != 0) { /* @@ -280,25 +287,29 @@ cpu_wait(p) * Dump the machine specific header information at the start of a core dump. */ int -cpu_coredump(p, vp, cred) - struct proc *p; +cpu_coredump(td, vp, cred) + struct thread *td; struct vnode *vp; struct ucred *cred; { + struct proc *p = td->td_proc; int error; caddr_t tempuser; - tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK | M_ZERO); + tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, M_WAITOK | M_ZERO); if (!tempuser) return EINVAL; - bcopy(p->p_addr, tempuser, sizeof(struct user)); - bcopy(p->p_frame, - tempuser + ((caddr_t) p->p_frame - (caddr_t) p->p_addr), + bcopy(p->p_uarea, tempuser, sizeof(struct user)); +#if 0 /* XXXKSE - broken, fixme!!!!! td_frame is in kstack! */ + bcopy(td->td_frame, + tempuser + ((caddr_t) td->td_frame - (caddr_t) p->p_uarea), sizeof(struct trapframe)); +#endif - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UAREA_PAGES + KSTACK_PAGES), + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); free(tempuser, M_TEMP); diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index 04ef7a0..a7783a0 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -56,8 +56,8 @@ #define cpu_exec(p) /* nothing */ #define cpu_swapin(p) /* nothing */ -#define cpu_getstack(p) ((p)->p_frame->tf_esp) -#define cpu_setstack(p, ap) ((p)->p_frame->tf_esp = (ap)) +#define cpu_getstack(td) ((td)->td_frame->tf_esp) +#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap)) #define TRAPF_USERMODE(framep) \ ((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM)) diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h index 67ce661..589a4be 100644 --- a/sys/amd64/include/fpu.h +++ b/sys/amd64/include/fpu.h @@ -142,7 +142,7 @@ union savefpu { #ifdef _KERNEL int npxdna __P((void)); -void npxexit __P((struct proc *p)); +void npxexit __P((struct thread *td)); void npxinit __P((int control)); void npxsave __P((union savefpu *addr)); int npxtrap __P((void)); diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index bc9cb75..c3564c2 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -61,7 +61,7 @@ extern char sigcode[]; extern int szsigcode, szosigcode; typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss)); -struct proc; +struct thread; struct reg; struct fpreg; struct dbreg; @@ -80,9 +80,9 @@ void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es)); void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault)); void doreti_popl_fs __P((void)) __asm(__STRING(doreti_popl_fs)); void doreti_popl_fs_fault __P((void)) __asm(__STRING(doreti_popl_fs_fault)); -int fill_fpregs __P((struct proc *, struct fpreg *)); -int fill_regs __P((struct proc *p, struct reg *regs)); -int fill_dbregs __P((struct proc *p, struct dbreg *dbregs)); +int fill_fpregs __P((struct thread *, struct fpreg *)); +int fill_regs __P((struct thread *p, struct reg *regs)); +int fill_dbregs __P((struct thread *p, struct dbreg *dbregs)); void fillw __P((int /*u_short*/ pat, void *base, size_t cnt)); void i486_bzero __P((void *buf, size_t len)); void i586_bcopy __P((const void *from, void *to, size_t len)); diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index d912e0c..f558524 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h index b0fe512..ae37b23 100644 --- a/sys/amd64/include/mutex.h +++ b/sys/amd64/include/mutex.h @@ -250,7 +250,7 @@ extern struct mtx clock_lock; pushl %ecx ; \ pushl %ebx ; \ movl $(MTX_UNOWNED) , %eax ; \ - movl PCPU(CURPROC), %ebx ; \ + movl PCPU(CURTHREAD), %ebx ; \ pushfl ; \ popl %ecx ; \ cli ; \ diff --git a/sys/amd64/include/npx.h b/sys/amd64/include/npx.h index 67ce661..589a4be 100644 --- a/sys/amd64/include/npx.h +++ b/sys/amd64/include/npx.h @@ -142,7 +142,7 @@ union savefpu { #ifdef _KERNEL int npxdna __P((void)); -void npxexit __P((struct proc *p)); +void npxexit __P((struct thread *td)); void npxinit __P((int control)); void npxsave __P((union savefpu *addr)); int npxtrap __P((void)); diff --git a/sys/amd64/include/pcb_ext.h b/sys/amd64/include/pcb_ext.h index 7d6fb08..c6f9fc0 100644 --- a/sys/amd64/include/pcb_ext.h +++ b/sys/amd64/include/pcb_ext.h @@ -53,7 +53,7 @@ struct pcb_ldt { #ifdef _KERNEL -int i386_extend_pcb __P((struct proc *)); +int i386_extend_pcb __P((struct thread *)); void set_user_ldt __P((struct pcb *)); struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int)); void user_ldt_free __P((struct pcb *)); diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h index 37388aa..f02354d 100644 --- a/sys/amd64/include/pcpu.h +++ b/sys/amd64/include/pcpu.h @@ -52,19 +52,19 @@ * other processors" */ struct globaldata { - struct globaldata *gd_prvspace; /* self-reference */ - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_npxproc; - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - struct i386tss gd_common_tss; - int gd_switchticks; - struct segment_descriptor gd_common_tssd; - struct segment_descriptor *gd_tss_gdt; - int gd_currentldt; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ + struct globaldata *gd_prvspace; /* self-reference */ + struct thread *gd_curthread; + struct thread *gd_npxthread; + struct pcb *gd_curpcb; + struct thread *gd_idlethread; + struct timeval gd_switchtime; + struct i386tss gd_common_tss; + int gd_switchticks; + struct segment_descriptor gd_common_tssd; + struct segment_descriptor *gd_tss_gdt; + int gd_currentldt; + u_int gd_cpuid; + u_int gd_other_cpus; SLIST_ENTRY(globaldata) gd_allcpu; struct lock_list_entry *gd_spinlocks; #ifdef KTR_PERCPU diff --git a/sys/amd64/include/proc.h b/sys/amd64/include/proc.h index 4217c4f..9e9e449 100644 --- a/sys/amd64/include/proc.h +++ b/sys/amd64/include/proc.h @@ -42,6 +42,9 @@ /* * Machine-dependent part of the proc structure for i386. */ +struct mdthread { +}; + struct mdproc { }; diff --git a/sys/amd64/include/reg.h b/sys/amd64/include/reg.h index 47856a3..f4c6ae5 100644 --- a/sys/amd64/include/reg.h +++ b/sys/amd64/include/reg.h @@ -143,10 +143,10 @@ struct dbreg { /* * XXX these interfaces are MI, so they should be declared in a MI place. */ -int set_fpregs __P((struct proc *, struct fpreg *)); -int set_regs __P((struct proc *p, struct reg *regs)); -void setregs __P((struct proc *, u_long, u_long, u_long)); -int set_dbregs __P((struct proc *p, struct dbreg *dbregs)); +int set_fpregs __P((struct thread *, struct fpreg *)); +int set_regs __P((struct thread *p, struct reg *regs)); +void setregs __P((struct thread *, u_long, u_long, u_long)); +int set_dbregs __P((struct thread *p, struct dbreg *dbregs)); #endif #endif /* !_MACHINE_REG_H_ */ diff --git a/sys/amd64/isa/atpic_vector.S b/sys/amd64/isa/atpic_vector.S index 6b48737..3a42af4 100644 --- a/sys/amd64/isa/atpic_vector.S +++ b/sys/amd64/isa/atpic_vector.S @@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \ mov $KPSEL,%ax ; \ mov %ax,%fs ; \ FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ @@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \ incl cnt+V_INTR ; /* book-keeping can wait */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \ movb %al,imen + IRQ_BYTE(irq_num) ; \ outb %al,$icu+ICU_IMR_OFFSET ; \ enable_icus ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ __CONCAT(Xresume,irq_num): ; \ FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \ pushl $irq_num; /* pass the IRQ */ \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ /* We could usually avoid the following jmp by inlining some of */ \ /* doreti, but it's probably better to use less cache. */ \ diff --git a/sys/amd64/isa/icu_vector.S b/sys/amd64/isa/icu_vector.S index 6b48737..3a42af4 100644 --- a/sys/amd64/isa/icu_vector.S +++ b/sys/amd64/isa/icu_vector.S @@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \ mov $KPSEL,%ax ; \ mov %ax,%fs ; \ FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ @@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \ incl cnt+V_INTR ; /* book-keeping can wait */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \ movb %al,imen + IRQ_BYTE(irq_num) ; \ outb %al,$icu+ICU_IMR_OFFSET ; \ enable_icus ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ __CONCAT(Xresume,irq_num): ; \ FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \ pushl $irq_num; /* pass the IRQ */ \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ /* We could usually avoid the following jmp by inlining some of */ \ /* doreti, but it's probably better to use less cache. */ \ diff --git a/sys/amd64/isa/icu_vector.s b/sys/amd64/isa/icu_vector.s index 6b48737..3a42af4 100644 --- a/sys/amd64/isa/icu_vector.s +++ b/sys/amd64/isa/icu_vector.s @@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \ mov $KPSEL,%ax ; \ mov %ax,%fs ; \ FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ @@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \ incl cnt+V_INTR ; /* book-keeping can wait */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \ movb %al,imen + IRQ_BYTE(irq_num) ; \ outb %al,$icu+ICU_IMR_OFFSET ; \ enable_icus ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ __CONCAT(Xresume,irq_num): ; \ FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \ pushl $irq_num; /* pass the IRQ */ \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ /* We could usually avoid the following jmp by inlining some of */ \ /* doreti, but it's probably better to use less cache. */ \ diff --git a/sys/amd64/isa/npx.c b/sys/amd64/isa/npx.c index 4fe3d04..84534ea 100644 --- a/sys/amd64/isa/npx.c +++ b/sys/amd64/isa/npx.c @@ -128,23 +128,23 @@ void stop_emulating __P((void)); #endif /* __GNUC__ */ #ifdef CPU_ENABLE_SSE -#define GET_FPU_CW(proc) \ +#define GET_FPU_CW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_cw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_sw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (cpu_fxsr ? \ &(pcb)->pcb_save.sv_xmm.sv_ex_sw : \ &(pcb)->pcb_save.sv_87.sv_ex_sw) #else /* CPU_ENABLE_SSE */ -#define GET_FPU_CW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) +#define GET_FPU_CW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (&(pcb)->pcb_save.sv_87.sv_ex_sw) #endif /* CPU_ENABLE_SSE */ @@ -241,7 +241,7 @@ static void npx_intr(dummy) void *dummy; { - struct proc *p; + struct thread *td; /* * The BUSY# latch must be cleared in all cases so that the next @@ -250,22 +250,22 @@ npx_intr(dummy) outb(0xf0, 0); /* - * npxproc is normally non-null here. In that case, schedule an + * npxthread is normally non-null here. In that case, schedule an * AST to finish the exception handling in the correct context - * (this interrupt may occur after the process has entered the + * (this interrupt may occur after the thread has entered the * kernel via a syscall or an interrupt). Otherwise, the npx - * state of the process that caused this interrupt must have been - * pushed to the process' pcb, and clearing of the busy latch + * state of the thread that caused this interrupt must have been + * pushed to the thread' pcb, and clearing of the busy latch * above has finished the (essentially null) handling of this * interrupt. Control will eventually return to the instruction * that caused it and it will repeat. We will eventually (usually * soon) win the race to handle the interrupt properly. */ - p = PCPU_GET(npxproc); - if (p != NULL) { - p->p_addr->u_pcb.pcb_flags |= PCB_NPXTRAP; + td = PCPU_GET(npxthread); + if (td != NULL) { + td->td_pcb->pcb_flags |= PCB_NPXTRAP; mtx_lock_spin(&sched_lock); - p->p_sflag |= PS_ASTPENDING; + td->td_kse->ke_flags |= KEF_ASTPENDING; mtx_unlock_spin(&sched_lock); } } @@ -570,7 +570,7 @@ npxinit(control) /* * fninit has the same h/w bugs as fnsave. Use the detoxified * fnsave to throw away any junk in the fpu. npxsave() initializes - * the fpu and sets npxproc = NULL as important side effects. + * the fpu and sets npxthread = NULL as important side effects. */ savecrit = critical_enter(); npxsave(&dummy); @@ -586,13 +586,13 @@ npxinit(control) * Free coprocessor (if we have it). */ void -npxexit(p) - struct proc *p; +npxexit(td) + struct thread *td; { critical_t savecrit; savecrit = critical_enter(); - if (p == PCPU_GET(npxproc)) + if (td == PCPU_GET(npxthread)) npxsave(&PCPU_GET(curpcb)->pcb_save); critical_exit(savecrit); #ifdef NPX_DEBUG @@ -607,8 +607,9 @@ npxexit(p) */ if (masked_exceptions & 0x0d) log(LOG_ERR, - "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", - p->p_pid, p->p_comm, masked_exceptions); + "pid %d (%s) exited with masked floating" + " point exceptions 0x%02x\n", + td->td_proc->p_pid, td->td_proc->p_comm, masked_exceptions); } #endif } @@ -809,8 +810,8 @@ npxtrap() u_long *exstat; if (!npx_exists) { - printf("npxtrap: npxproc = %p, curproc = %p, npx_exists = %d\n", - PCPU_GET(npxproc), curproc, npx_exists); + printf("npxtrap: npxthread = %p, curthread = %p, npx_exists = %d\n", + PCPU_GET(npxthread), curthread, npx_exists); panic("npxtrap from nowhere"); } savecrit = critical_enter(); @@ -820,18 +821,18 @@ npxtrap() * state to memory. Fetch the relevant parts of the state from * wherever they are. */ - if (PCPU_GET(npxproc) != curproc) { - control = GET_FPU_CW(curproc); - status = GET_FPU_SW(curproc); + if (PCPU_GET(npxthread) != curthread) { + control = GET_FPU_CW(curthread); + status = GET_FPU_SW(curthread); } else { fnstcw(&control); fnstsw(&status); } - exstat = GET_FPU_EXSW_PTR(&curproc->p_addr->u_pcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); *exstat = status; - if (PCPU_GET(npxproc) != curproc) - GET_FPU_SW(curproc) &= ~0x80bf; + if (PCPU_GET(npxthread) != curthread) + GET_FPU_SW(curthread) &= ~0x80bf; else fnclex(); critical_exit(savecrit); @@ -841,7 +842,7 @@ npxtrap() /* * Implement device not available (DNA) exception * - * It would be better to switch FP context here (if curproc != npxproc) + * It would be better to switch FP context here (if curthread != npxthread) * and not necessarily for every context switch, but it is too hard to * access foreign pcb's. */ @@ -853,9 +854,9 @@ npxdna() if (!npx_exists) return (0); - if (PCPU_GET(npxproc) != NULL) { - printf("npxdna: npxproc = %p, curproc = %p\n", - PCPU_GET(npxproc), curproc); + if (PCPU_GET(npxthread) != NULL) { + printf("npxdna: npxthread = %p, curthread = %p\n", + PCPU_GET(npxthread), curthread); panic("npxdna"); } s = critical_enter(); @@ -863,7 +864,7 @@ npxdna() /* * Record new context early in case frstor causes an IRQ13. */ - PCPU_SET(npxproc, CURPROC); + PCPU_SET(npxthread, curthread); exstat = GET_FPU_EXSW_PTR(PCPU_GET(curpcb)); *exstat = 0; @@ -895,13 +896,13 @@ npxdna() * after the process has entered the kernel. It may even be delivered after * the fnsave here completes. A spurious IRQ13 for the fnsave is handled in * the same way as a very-late-arriving non-spurious IRQ13 from user mode: - * it is normally ignored at first because we set npxproc to NULL; it is + * it is normally ignored at first because we set npxthread to NULL; it is * normally retriggered in npxdna() after return to user mode. * * npxsave() must be called with interrupts disabled, so that it clears - * npxproc atomically with saving the state. We require callers to do the + * npxthread atomically with saving the state. We require callers to do the * disabling, since most callers need to disable interrupts anyway to call - * npxsave() atomically with checking npxproc. + * npxsave() atomically with checking npxthread. * * A previous version of npxsave() went to great lengths to excecute fnsave * with interrupts enabled in case executing it froze the CPU. This case @@ -917,7 +918,7 @@ npxsave(addr) fpusave(addr); start_emulating(); - PCPU_SET(npxproc, NULL); + PCPU_SET(npxthread, NULL); } static void diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 9d5ee8f..b3a31fd 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -909,7 +909,7 @@ xptdone(struct cam_periph *periph, union ccb *done_ccb) } static int -xptopen(dev_t dev, int flags, int fmt, struct proc *p) +xptopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit; @@ -946,7 +946,7 @@ xptopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -xptclose(dev_t dev, int flag, int fmt, struct proc *p) +xptclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit; @@ -969,7 +969,7 @@ xptclose(dev_t dev, int flag, int fmt, struct proc *p) } static int -xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { int unit, error; diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 923b4bd..09fe6a8 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -873,7 +873,7 @@ cdregisterexit: } static int -cdopen(dev_t dev, int flags, int fmt, struct proc *p) +cdopen(dev_t dev, int flags, int fmt, struct thread *td) { struct disklabel *label; struct cam_periph *periph; @@ -985,7 +985,7 @@ cdopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -cdclose(dev_t dev, int flag, int fmt, struct proc *p) +cdclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct cd_softc *softc; @@ -1806,7 +1806,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) } static int -cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index 7d9bba3..2e6a40d 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -424,7 +424,7 @@ chregister(struct cam_periph *periph, void *arg) } static int -chopen(dev_t dev, int flags, int fmt, struct proc *p) +chopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct ch_softc *softc; @@ -474,7 +474,7 @@ chopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -chclose(dev_t dev, int flag, int fmt, struct proc *p) +chclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct ch_softc *softc; @@ -724,7 +724,7 @@ cherror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags) } static int -chioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +chioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; struct ch_softc *softc; diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index a402ec0..104cff5 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -378,7 +378,7 @@ static SLIST_HEAD(,da_softc) softc_list; static struct extend_array *daperiphs; static int -daopen(dev_t dev, int flags, int fmt, struct proc *p) +daopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct da_softc *softc; @@ -501,7 +501,7 @@ daopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -daclose(dev_t dev, int flag, int fmt, struct proc *p) +daclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct da_softc *softc; @@ -651,7 +651,7 @@ dastrategy(struct bio *bp) #endif static int -daioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +daioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; struct da_softc *softc; diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index c6ed554..e81de98 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -341,7 +341,7 @@ passregister(struct cam_periph *periph, void *arg) } static int -passopen(dev_t dev, int flags, int fmt, struct proc *p) +passopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct pass_softc *softc; @@ -412,7 +412,7 @@ passopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -passclose(dev_t dev, int flag, int fmt, struct proc *p) +passclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct pass_softc *softc; @@ -478,7 +478,7 @@ passdone(struct cam_periph *periph, union ccb *done_ccb) } static int -passioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +passioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; struct pass_softc *softc; diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index 0211d4d..4e62bc2 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -141,7 +141,7 @@ static struct extend_array *ptperiphs; #endif static int -ptopen(dev_t dev, int flags, int fmt, struct proc *p) +ptopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct pt_softc *softc; @@ -185,7 +185,7 @@ ptopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -ptclose(dev_t dev, int flag, int fmt, struct proc *p) +ptclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct pt_softc *softc; @@ -678,7 +678,7 @@ pterror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags) } static int -ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; struct pt_softc *softc; diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 51edca1..ede582c 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -440,7 +440,7 @@ static struct cdevsw sa_cdevsw = { static struct extend_array *saperiphs; static int -saopen(dev_t dev, int flags, int fmt, struct proc *p) +saopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct sa_softc *softc; @@ -504,7 +504,7 @@ saopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -saclose(dev_t dev, int flag, int fmt, struct proc *p) +saclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct sa_softc *softc; @@ -761,7 +761,7 @@ sastrategy(struct bio *bp) } static int -saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) +saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { struct cam_periph *periph; struct sa_softc *softc; diff --git a/sys/cam/scsi/scsi_ses.c b/sys/cam/scsi/scsi_ses.c index 635556e..62d2092 100644 --- a/sys/cam/scsi/scsi_ses.c +++ b/sys/cam/scsi/scsi_ses.c @@ -426,7 +426,7 @@ sesregister(struct cam_periph *periph, void *arg) } static int -sesopen(dev_t dev, int flags, int fmt, struct proc *p) +sesopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct ses_softc *softc; @@ -482,7 +482,7 @@ out: } static int -sesclose(dev_t dev, int flag, int fmt, struct proc *p) +sesclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct ses_softc *softc; @@ -539,7 +539,7 @@ seserror(union ccb *ccb, u_int32_t cflags, u_int32_t sflags) } static int -sesioctl(dev_t dev, u_long cmd, caddr_t arg_addr, int flag, struct proc *p) +sesioctl(dev_t dev, u_long cmd, caddr_t arg_addr, int flag, struct thread *td) { struct cam_periph *periph; ses_encstat tmp; diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index d7370ee..6945678 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -551,7 +551,7 @@ targdtor(struct cam_periph *periph) } static int -targopen(dev_t dev, int flags, int fmt, struct proc *p) +targopen(dev_t dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct targ_softc *softc; @@ -610,7 +610,7 @@ targopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -targclose(dev_t dev, int flag, int fmt, struct proc *p) +targclose(dev_t dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct targ_softc *softc; @@ -807,7 +807,7 @@ fail: } static int -targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct cam_periph *periph; struct targ_softc *softc; @@ -1080,7 +1080,7 @@ targsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb) static int -targpoll(dev_t dev, int poll_events, struct proc *p) +targpoll(dev_t dev, int poll_events, struct thread *td) { struct cam_periph *periph; struct targ_softc *softc; @@ -1117,9 +1117,9 @@ targpoll(dev_t dev, int poll_events, struct proc *p) if (revents == 0) { if (poll_events & (POLLOUT | POLLWRNORM)) - selrecord(p, &softc->rcv_select); + selrecord(td, &softc->rcv_select); if (poll_events & (POLLIN | POLLRDNORM)) - selrecord(p, &softc->snd_select); + selrecord(td, &softc->snd_select); } splx(s); return (revents); diff --git a/sys/coda/coda_psdev.c b/sys/coda/coda_psdev.c index 0d8560f..2346c7c 100644 --- a/sys/coda/coda_psdev.c +++ b/sys/coda/coda_psdev.c @@ -117,11 +117,11 @@ vcodaattach(n) } int -vc_nb_open(dev, flag, mode, p) +vc_nb_open(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; /* NetBSD only */ + struct thread *td; /* NetBSD only */ { register struct vcomm *vcp; @@ -149,11 +149,11 @@ vc_nb_open(dev, flag, mode, p) } int -vc_nb_close (dev, flag, mode, p) +vc_nb_close (dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { register struct vcomm *vcp; register struct vmsg *vmp, *nvmp = NULL; @@ -225,7 +225,7 @@ vc_nb_close (dev, flag, mode, p) #endif } - err = dounmount(mi->mi_vfsp, flag, p); + err = dounmount(mi->mi_vfsp, flag, td); if (err) myprintf(("Error %d unmounting vfs in vcclose(%d)\n", err, minor(dev))); @@ -387,12 +387,12 @@ vc_nb_write(dev, uiop, flag) } int -vc_nb_ioctl(dev, cmd, addr, flag, p) +vc_nb_ioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { ENTRY; @@ -441,10 +441,10 @@ vc_nb_ioctl(dev, cmd, addr, flag, p) } int -vc_nb_poll(dev, events, p) +vc_nb_poll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { register struct vcomm *vcp; int event_msk = 0; @@ -463,7 +463,7 @@ vc_nb_poll(dev, events, p) if (!EMPTY(vcp->vc_requests)) return(events & (POLLIN|POLLRDNORM)); - selrecord(p, &(vcp->vc_selproc)); + selrecord(curthread, &(vcp->vc_selproc)); return(0); } @@ -490,7 +490,8 @@ coda_call(mntinfo, inSize, outSize, buffer) struct vmsg *vmp; int error; #ifdef CTL_C - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; sigset_t psig_omask; sigset_t tempset; int i; diff --git a/sys/coda/coda_psdev.h b/sys/coda/coda_psdev.h index c6276f3..c6ecf7f 100644 --- a/sys/coda/coda_psdev.h +++ b/sys/coda/coda_psdev.h @@ -31,9 +31,9 @@ * */ -int vc_nb_open(dev_t dev, int flag, int mode, struct proc *p); -int vc_nb_close (dev_t dev, int flag, int mode, struct proc *p); +int vc_nb_open(dev_t dev, int flag, int mode, struct thread *p); +int vc_nb_close (dev_t dev, int flag, int mode, struct thread *p); int vc_nb_read(dev_t dev, struct uio *uiop, int flag); int vc_nb_write(dev_t dev, struct uio *uiop, int flag); -int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p); -int vc_nb_poll(dev_t dev, int events, struct proc *p); +int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *p); +int vc_nb_poll(dev_t dev, int events, struct thread *p); diff --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index 8bcd36f..d01d5a7 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -83,7 +83,7 @@ struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE]; #define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++) extern int coda_nc_initialized; /* Set if cache has been initialized */ -extern int vc_nb_open __P((dev_t, int, int, struct proc *)); +extern int vc_nb_open __P((dev_t, int, int, struct thread *)); int coda_vfsopstats_init(void) @@ -107,12 +107,12 @@ coda_vfsopstats_init(void) */ /*ARGSUSED*/ int -coda_mount(vfsp, path, data, ndp, p) +coda_mount(vfsp, path, data, ndp, td) struct mount *vfsp; /* Allocated and initialized by mount(2) */ char *path; /* path covered: ignored by the fs-layer */ caddr_t data; /* Need to define a data type for this in netbsd? */ struct nameidata *ndp; /* Clobber this to lookup the device name */ - struct proc *p; /* The ever-famous proc pointer */ + struct thread *td; /* The ever-famous proc pointer */ { struct vnode *dvp; struct cnode *cp; @@ -135,7 +135,7 @@ coda_mount(vfsp, path, data, ndp, p) } /* Validate mount device. Similar to getmdev(). */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, td); error = namei(ndp); dvp = ndp->ni_vp; @@ -233,10 +233,10 @@ coda_mount(vfsp, path, data, ndp, p) } int -coda_unmount(vfsp, mntflags, p) +coda_unmount(vfsp, mntflags, td) struct mount *vfsp; int mntflags; - struct proc *p; + struct thread *td; { struct coda_mntinfo *mi = vftomi(vfsp); int active, error = 0; @@ -292,8 +292,12 @@ coda_root(vfsp, vpp) struct coda_mntinfo *mi = vftomi(vfsp); struct vnode **result; int error; - struct proc *p = curproc; /* XXX - bnoble */ + struct thread *td = curthread; /* XXX - bnoble */ + struct proc *p = td->td_proc; ViceFid VFid; + + ENTRY; + ENTRY; MARK_ENTRY(CODA_ROOT_STATS); @@ -308,9 +312,9 @@ coda_root(vfsp, vpp) /* On Mach, this is vref. On NetBSD, VOP_LOCK */ #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_SAT(CODA_ROOT_STATS); return(0); @@ -331,9 +335,9 @@ coda_root(vfsp, vpp) *vpp = mi->mi_rootvp; #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_SAT(CODA_ROOT_STATS); @@ -351,9 +355,9 @@ coda_root(vfsp, vpp) *vpp = mi->mi_rootvp; #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_FAIL(CODA_ROOT_STATS); @@ -374,10 +378,10 @@ coda_root(vfsp, vpp) * Get file system statistics. */ int -coda_nb_statfs(vfsp, sbp, p) +coda_nb_statfs(vfsp, sbp, td) register struct mount *vfsp; struct statfs *sbp; - struct proc *p; + struct thread *td; { ENTRY; /* MARK_ENTRY(CODA_STATFS_STATS); */ @@ -412,11 +416,11 @@ coda_nb_statfs(vfsp, sbp, p) * Flush any pending I/O. */ int -coda_sync(vfsp, waitfor, cred, p) +coda_sync(vfsp, waitfor, cred, td) struct mount *vfsp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { ENTRY; MARK_ENTRY(CODA_SYNC_STATS); @@ -441,7 +445,8 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) struct cfid *cfid = (struct cfid *)fhp; struct cnode *cp = 0; int error; - struct proc *p = curproc; /* XXX -mach */ + struct thread *td = curthread; /* XXX -mach */ + struct proc *p = td->td_proc; ViceFid VFid; int vtype; diff --git a/sys/coda/coda_vfsops.h b/sys/coda/coda_vfsops.h index 7fc9adf..57b9a5a 100644 --- a/sys/coda/coda_vfsops.h +++ b/sys/coda/coda_vfsops.h @@ -48,13 +48,13 @@ struct mount; int coda_vfsopstats_init(void); int coda_mount(struct mount *, char *, caddr_t, struct nameidata *, - struct proc *); -int coda_start(struct mount *, int, struct proc *); -int coda_unmount(struct mount *, int, struct proc *); + struct thread *); +int coda_start(struct mount *, int, struct thread *); +int coda_unmount(struct mount *, int, struct thread *); int coda_root(struct mount *, struct vnode **); -int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *); -int coda_nb_statfs(struct mount *, struct statfs *, struct proc *); -int coda_sync(struct mount *, int, struct ucred *, struct proc *); +int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *); +int coda_nb_statfs(struct mount *, struct statfs *, struct thread *); +int coda_sync(struct mount *, int, struct ucred *, struct thread *); int coda_vget(struct mount *, ino_t, struct vnode **); int coda_fhtovp(struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **); diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c index dd0a96e..8fd7170d 100644 --- a/sys/coda/coda_vnops.c +++ b/sys/coda/coda_vnops.c @@ -235,7 +235,7 @@ coda_open(v) struct cnode *cp = VTOC(*vpp); int flag = ap->a_mode & (~O_EXCL); struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; struct vnode *vp; @@ -256,7 +256,7 @@ coda_open(v) return(0); } - error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, p, &dev, &inode); + error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode); if (error) return (error); if (!error) { @@ -272,7 +272,7 @@ coda_open(v) return (error); /* We get the vnode back locked. Needs unlocked */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* Keep a reference until the close comes in. */ vref(*vpp); @@ -297,14 +297,14 @@ coda_open(v) cp->c_inode = inode; /* Open the cache file. */ - error = VOP_OPEN(vp, flag, cred, p); + error = VOP_OPEN(vp, flag, cred, td); if (error) { printf("coda_open: VOP_OPEN on container failed %d\n", error); return (error); } /* grab (above) does this when it calls newvnode unless it's in the cache*/ if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_open: vfs_object_create() returns %d\n", error); vput(vp); @@ -327,7 +327,7 @@ coda_close(v) struct cnode *cp = VTOC(vp); int flag = ap->a_fflag; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -348,7 +348,7 @@ coda_close(v) #ifdef hmm vgone(cp->c_ovp); #else - VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */ + VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */ vrele(cp->c_ovp); #endif } else { @@ -358,7 +358,7 @@ coda_close(v) } return ENODEV; } else { - VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */ + VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */ vrele(cp->c_ovp); } @@ -368,7 +368,7 @@ coda_close(v) if (flag & FWRITE) /* file was opened for write */ --cp->c_owrite; - error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, p); + error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc); vrele(CTOV(cp)); CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); ) @@ -383,7 +383,7 @@ coda_read(v) ENTRY; return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ, - ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp)); + ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td)); } int @@ -394,24 +394,25 @@ coda_write(v) ENTRY; return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE, - ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp)); + ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td)); } int -coda_rdwr(vp, uiop, rw, ioflag, cred, p) +coda_rdwr(vp, uiop, rw, ioflag, cred, td) struct vnode *vp; struct uio *uiop; enum uio_rw rw; int ioflag; struct ucred *cred; - struct proc *p; + struct thread *td; { /* upcall decl */ /* NOTE: container file operation!!! */ /* locals */ struct cnode *cp = VTOC(vp); struct vnode *cfvp = cp->c_ovp; - struct proc *lp = p; + struct proc *p = td->td_proc; + struct thread *ltd = td; int igot_internally = 0; int opened_internally = 0; int error = 0; @@ -448,7 +449,7 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) PROC_UNLOCK(p); } else - lp = curproc; + ltd = curthread; if (cp->c_inode != 0 && !iscore) { igot_internally = 1; @@ -458,23 +459,23 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) return(error); } /* - * We get the vnode back locked by curproc in both Mach and + * We get the vnode back locked by curthread in both Mach and * NetBSD. Needs unlocked */ - VOP_UNLOCK(cfvp, 0, lp); + VOP_UNLOCK(cfvp, 0, ltd); } else { opened_internally = 1; MARK_INT_GEN(CODA_OPEN_STATS); error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE), - cred, p); + cred, td); printf("coda_rdwr: Internally Opening %p\n", vp); if (error) { printf("coda_rdwr: VOP_OPEN on container failed %d\n", error); return (error); } if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_rdwr: vfs_object_create() returns %d\n", error); vput(vp); @@ -501,7 +502,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp); { struct vattr attr; - if (VOP_GETATTR(cfvp, &attr, cred, p) == 0) { + if (VOP_GETATTR(cfvp, &attr, cred, td) == 0) { vnode_pager_setsize(vp, attr.va_size); } } @@ -515,7 +516,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp); /* Do an internal close if necessary. */ if (opened_internally) { MARK_INT_GEN(CODA_CLOSE_STATS); - (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, p); + (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td); } /* Invalidate cached attributes if writing. */ @@ -537,7 +538,7 @@ coda_ioctl(v) caddr_t data = ap->a_data; int flag = ap->a_fflag; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; struct vnode *tvp; @@ -562,7 +563,7 @@ coda_ioctl(v) /* Should we use the name cache here? It would get it from lookupname sooner or later anyway, right? */ - NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, p); + NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, td); error = namei(&ndp); tvp = ndp.ni_vp; @@ -591,7 +592,7 @@ coda_ioctl(v) NDFREE(&ndp, 0); return(EINVAL); } - error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, p); + error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, td->td_proc); if (error) MARK_INT_FAIL(CODA_IOCTL_STATS); @@ -622,7 +623,7 @@ coda_getattr(v) struct cnode *cp = VTOC(vp); struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -651,7 +652,7 @@ coda_getattr(v) return(0); } - error = venus_getattr(vtomi(vp), &cp->c_fid, cred, p, vap); + error = venus_getattr(vtomi(vp), &cp->c_fid, cred, td->td_proc, vap); if (!error) { CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n", @@ -689,7 +690,7 @@ coda_setattr(v) struct cnode *cp = VTOC(vp); register struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -704,7 +705,7 @@ coda_setattr(v) if (codadebug & CODADBGMSK(CODA_SETATTR)) { print_vattr(vap); } - error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, p); + error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, td->td_proc); if (!error) cp->c_flags &= ~C_VATTR; @@ -729,7 +730,7 @@ coda_access(v) struct cnode *cp = VTOC(vp); int mode = ap->a_mode; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -758,7 +759,7 @@ coda_access(v) } } - error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, p); + error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, td->td_proc); return(error); } @@ -773,7 +774,7 @@ coda_readlink(v) struct cnode *cp = VTOC(vp); struct uio *uiop = ap->a_uio; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; /* locals */ int error; char *str; @@ -797,7 +798,7 @@ coda_readlink(v) return(error); } - error = venus_readlink(vtomi(vp), &cp->c_fid, cred, p, &str, &len); + error = venus_readlink(vtomi(vp), &cp->c_fid, cred, td->td_proc, &str, &len); if (!error) { uiop->uio_rw = UIO_READ; @@ -824,7 +825,7 @@ coda_fsync(v) struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ struct vnode *convp = cp->c_ovp; int error; @@ -847,7 +848,7 @@ coda_fsync(v) } if (convp) - VOP_FSYNC(convp, cred, MNT_WAIT, p); + VOP_FSYNC(convp, cred, MNT_WAIT, td); /* * We see fsyncs with usecount == 1 then usecount == 0. @@ -873,7 +874,7 @@ coda_fsync(v) /* needs research */ return 0; - error = venus_fsync(vtomi(vp), &cp->c_fid, cred, p); + error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc); CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); ); return(error); @@ -890,7 +891,7 @@ coda_inactive(v) struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); struct ucred *cred __attribute__((unused)) = NULL; - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -930,7 +931,7 @@ coda_inactive(v) printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n", vp->v_usecount, vp, cp); #endif - lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, p); + lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, td); } else { #ifdef OLD_DIAGNOSTIC if (CTOV(cp)->v_usecount) { @@ -940,7 +941,7 @@ coda_inactive(v) panic("coda_inactive: cp->ovp != NULL"); } #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vgone(vp); } @@ -972,7 +973,7 @@ coda_lookup(v) */ struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ struct cnode *cp; const char *nm = cnp->cn_nameptr; @@ -1015,7 +1016,7 @@ coda_lookup(v) } else { /* The name wasn't cached, so we need to contact Venus */ - error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, p, &VFid, &vtype); + error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc, &VFid, &vtype); if (error) { MARK_INT_FAIL(CODA_LOOKUP_STATS); @@ -1086,7 +1087,7 @@ coda_lookup(v) */ if (!error || (error == EJUSTRETURN)) { if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) { - if ((error = VOP_UNLOCK(dvp, 0, p))) { + if ((error = VOP_UNLOCK(dvp, 0, td))) { return error; } /* @@ -1094,7 +1095,7 @@ coda_lookup(v) * lock it without bothering to check anything else. */ if (*ap->a_vpp) { - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_lookup: "); panic("unlocked parent but couldn't lock child"); } @@ -1103,7 +1104,7 @@ coda_lookup(v) /* The parent is locked, and may be the same as the child */ if (*ap->a_vpp && (*ap->a_vpp != dvp)) { /* Different, go ahead and lock it. */ - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_lookup: "); panic("unlocked parent but couldn't lock child"); } @@ -1132,7 +1133,7 @@ coda_create(v) struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; struct cnode *cp; @@ -1153,7 +1154,7 @@ coda_create(v) return(EACCES); } - error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, p, &VFid, &attr); + error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, td->td_proc, &VFid, &attr); if (!error) { @@ -1192,7 +1193,7 @@ coda_create(v) if (!error) { if (cnp->cn_flags & LOCKLEAF) { - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_create: "); panic("unlocked parent but couldn't lock child"); } @@ -1216,7 +1217,7 @@ coda_remove(v) struct cnode *cp = VTOC(dvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1259,7 +1260,7 @@ coda_remove(v) return(ENOENT); } - error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, p); + error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, td->td_proc); CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); ) @@ -1278,7 +1279,7 @@ coda_link(v) struct cnode *tdcp = VTOC(tdvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1308,7 +1309,7 @@ coda_link(v) return(EACCES); } - error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, p); + error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, td->td_proc); /* Invalidate the parent's attr cache, the modification time has changed */ VTOC(tdvp)->c_flags &= ~C_VATTR; @@ -1332,7 +1333,7 @@ coda_rename(v) struct cnode *ndcp = VTOC(ndvp); struct componentname *tcnp = ap->a_tcnp; struct ucred *cred = fcnp->cn_cred; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; /* true args */ int error; const char *fnm = fcnp->cn_nameptr; @@ -1346,7 +1347,7 @@ coda_rename(v) This could be Bad. XXX */ #ifdef OLD_DIAGNOSTIC if ((fcnp->cn_cred != tcnp->cn_cred) - || (fcnp->cn_proc != tcnp->cn_proc)) + || (fcnp->cn_thread != tcnp->cn_thread)) { panic("coda_rename: component names don't agree"); } @@ -1389,7 +1390,7 @@ coda_rename(v) goto exit; } - error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, p); + error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, td->td_proc); exit: CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));) @@ -1426,7 +1427,7 @@ coda_mkdir(v) register struct vattr *va = ap->a_vap; struct vnode **vpp = ap->a_vpp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1450,7 +1451,7 @@ coda_mkdir(v) return(EACCES); } - error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, p, &VFid, &ova); + error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, td->td_proc, &VFid, &ova); if (!error) { if (coda_find(&VFid) != NULL) @@ -1495,7 +1496,7 @@ coda_rmdir(v) struct cnode *dcp = VTOC(dvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* true args */ int error; const char *nm = cnp->cn_nameptr; @@ -1527,7 +1528,7 @@ coda_rmdir(v) /* Invalidate the parent's attr cache, the modification time has changed */ dcp->c_flags &= ~C_VATTR; - error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, p); + error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc); CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); ) @@ -1546,7 +1547,7 @@ coda_symlink(v) struct vattr *tva = ap->a_vap; char *path = ap->a_target; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode **vpp = ap->a_vpp; /* locals */ int error; @@ -1589,7 +1590,7 @@ coda_symlink(v) goto exit; } - error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, p); + error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, td->td_proc); /* Invalidate the parent's attr cache, the modification time has changed */ tdcp->c_flags &= ~C_VATTR; @@ -1618,7 +1619,7 @@ coda_readdir(v) int *eofflag = ap->a_eofflag; u_long **cookies = ap->a_cookies; int *ncookies = ap->a_ncookies; - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; /* upcall decl */ /* locals */ int error = 0; @@ -1643,14 +1644,14 @@ coda_readdir(v) if (cp->c_ovp == NULL) { opened_internally = 1; MARK_INT_GEN(CODA_OPEN_STATS); - error = VOP_OPEN(vp, FREAD, cred, p); + error = VOP_OPEN(vp, FREAD, cred, td); printf("coda_readdir: Internally Opening %p\n", vp); if (error) { printf("coda_readdir: VOP_OPEN on container failed %d\n", error); return (error); } if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_readdir: vfs_object_create() returns %d\n", error); vput(vp); @@ -1672,7 +1673,7 @@ printf("coda_readdir: Internally Opening %p\n", vp); /* Do an "internal close" if necessary. */ if (opened_internally) { MARK_INT_GEN(CODA_CLOSE_STATS); - (void)VOP_CLOSE(vp, FREAD, cred, p); + (void)VOP_CLOSE(vp, FREAD, cred, td); } } @@ -1693,7 +1694,7 @@ coda_bmap(v) daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */ struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */ daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */ - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -1731,7 +1732,7 @@ coda_strategy(v) /* true args */ struct vop_strategy_args *ap = v; register struct buf *bp __attribute__((unused)) = ap->a_bp; - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -1786,7 +1787,7 @@ coda_lock(v) struct vop_lock_args *ap = v; struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* upcall decl */ /* locals */ @@ -1798,9 +1799,9 @@ coda_lock(v) } #ifndef DEBUG_LOCKS - return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p)); + return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td)); #else - return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p, + return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td, "coda_lock", vp->filename, vp->line)); #endif } @@ -1813,7 +1814,7 @@ coda_unlock(v) struct vop_unlock_args *ap = v; struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* upcall decl */ /* locals */ @@ -1823,7 +1824,7 @@ coda_unlock(v) cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique)); } - return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, td)); } int @@ -1835,7 +1836,7 @@ coda_islocked(v) struct cnode *cp = VTOC(ap->a_vp); ENTRY; - return (lockstatus(&cp->c_lock, ap->a_p)); + return (lockstatus(&cp->c_lock, ap->a_td)); } /* How one looks up a vnode given a device/inode pair: */ diff --git a/sys/coda/coda_vnops.h b/sys/coda/coda_vnops.h index 9fcd978..663d357 100644 --- a/sys/coda/coda_vnops.h +++ b/sys/coda/coda_vnops.h @@ -82,7 +82,7 @@ int coda_fbsd_getpages __P((void *)); int (**coda_vnodeop_p)(void *); int coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, - int ioflag, struct ucred *cred, struct proc *p); + int ioflag, struct ucred *cred, struct thread *td); int coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp); void print_vattr(struct vattr *attr); void print_cred(struct ucred *cred); diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index f41d536..987588a 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -376,8 +376,8 @@ linprocfs_doversion(PFS_FILL_ARGS) sbuf_printf(sb, "%s version %s (des@freebsd.org) (gcc version " __VERSION__ ")" " #4 Sun Dec 18 04:30:00 CET 1977\n", - linux_get_osname(curp), - linux_get_osrelease(curp)); + linux_get_osname(td->td_proc), + linux_get_osrelease(td->td_proc)); return (0); } @@ -581,7 +581,7 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) static int linprocfs_doselflink(PFS_FILL_ARGS) { - sbuf_printf(sb, "%ld", (long)curp->p_pid); + sbuf_printf(sb, "%ld", (long)td->td_proc->p_pid); return (0); } @@ -604,9 +604,9 @@ linprocfs_doproccmdline(PFS_FILL_ARGS) * Linux behaviour is to return zero-length in this case. */ - if (p->p_args && (ps_argsopen || !p_cansee(curp, p))) { + if (p->p_args && (ps_argsopen || !p_cansee(td->td_proc, p))) { sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length); - } else if (p != curp) { + } else if (p != td->td_proc) { sbuf_printf(sb, "%.*s", MAXCOMLEN, p->p_comm); } else { error = copyin((void*)PS_STRINGS, &pstr, sizeof(pstr)); @@ -663,8 +663,8 @@ linprocfs_donetdev(PFS_FILL_ARGS) sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0); + 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, + 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L); } return (0); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 3d16a94..f1cba52 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -56,7 +56,7 @@ #ifndef __alpha__ int -linux_creat(struct proc *p, struct linux_creat_args *args) +linux_creat(struct thread *td, struct linux_creat_args *args) { struct open_args /* { char *path; @@ -66,7 +66,7 @@ linux_creat(struct proc *p, struct linux_creat_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTCREAT(p, &sg, args->path); + CHECKALTCREAT(td, &sg, args->path); #ifdef DEBUG if (ldebug(creat)) @@ -75,27 +75,28 @@ linux_creat(struct proc *p, struct linux_creat_args *args) bsd_open_args.path = args->path; bsd_open_args.mode = args->mode; bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC; - return open(p, &bsd_open_args); + return open(td, &bsd_open_args); } #endif /*!__alpha__*/ int -linux_open(struct proc *p, struct linux_open_args *args) +linux_open(struct thread *td, struct linux_open_args *args) { struct open_args /* { char *path; int flags; int mode; } */ bsd_open_args; + struct proc *p = td->td_proc; int error; caddr_t sg; sg = stackgap_init(); if (args->flags & LINUX_O_CREAT) - CHECKALTCREAT(p, &sg, args->path); + CHECKALTCREAT(td, &sg, args->path); else - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(open)) @@ -130,16 +131,16 @@ linux_open(struct proc *p, struct linux_open_args *args) bsd_open_args.path = args->path; bsd_open_args.mode = args->mode; - error = open(p, &bsd_open_args); + error = open(td, &bsd_open_args); PROC_LOCK(p); if (!error && !(bsd_open_args.flags & O_NOCTTY) && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; - struct file *fp = fdp->fd_ofiles[p->p_retval[0]]; + struct file *fp = fdp->fd_ofiles[td->td_retval[0]]; PROC_UNLOCK(p); if (fp->f_type == DTYPE_VNODE) - fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); + fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); } else PROC_UNLOCK(p); #ifdef DEBUG @@ -150,7 +151,7 @@ linux_open(struct proc *p, struct linux_open_args *args) } int -linux_lseek(struct proc *p, struct linux_lseek_args *args) +linux_lseek(struct thread *td, struct linux_lseek_args *args) { struct lseek_args /* { @@ -169,13 +170,13 @@ linux_lseek(struct proc *p, struct linux_lseek_args *args) tmp_args.fd = args->fdes; tmp_args.offset = (off_t)args->off; tmp_args.whence = args->whence; - error = lseek(p, &tmp_args); + error = lseek(td, &tmp_args); return error; } #ifndef __alpha__ int -linux_llseek(struct proc *p, struct linux_llseek_args *args) +linux_llseek(struct thread *td, struct linux_llseek_args *args) { struct lseek_args bsd_args; int error; @@ -192,27 +193,27 @@ linux_llseek(struct proc *p, struct linux_llseek_args *args) bsd_args.offset = off; bsd_args.whence = args->whence; - if ((error = lseek(p, &bsd_args))) + if ((error = lseek(td, &bsd_args))) return error; - if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t)))) + if ((error = copyout(td->td_retval, (caddr_t)args->res, sizeof (off_t)))) return error; - p->p_retval[0] = 0; + td->td_retval[0] = 0; return 0; } #endif /*!__alpha__*/ #ifndef __alpha__ int -linux_readdir(struct proc *p, struct linux_readdir_args *args) +linux_readdir(struct thread *td, struct linux_readdir_args *args) { struct linux_getdents_args lda; lda.fd = args->fd; lda.dent = args->dent; lda.count = 1; - return linux_getdents(p, &lda); + return linux_getdents(td, &lda); } #endif /*!__alpha__*/ @@ -246,7 +247,7 @@ struct l_dirent64 { #define LINUX_DIRBLKSIZ 512 static int -getdents_common(struct proc *p, struct linux_getdents64_args *args, +getdents_common(struct thread *td, struct linux_getdents64_args *args, int is64bit) { register struct dirent *bdp; @@ -266,7 +267,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args, u_long *cookies = NULL, *cookiep; int ncookies; - if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, args->fd, &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) @@ -276,7 +277,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args, if (vp->v_type != VDIR) return (EINVAL); - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) + if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td))) return (error); nbytes = args->count; @@ -294,7 +295,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args, buflen = max(LINUX_DIRBLKSIZ, nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); again: aiov.iov_base = buf; @@ -303,7 +304,7 @@ again: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = buflen; auio.uio_offset = off; @@ -427,19 +428,19 @@ again: nbytes = resid + linuxreclen; eof: - p->p_retval[0] = nbytes - resid; + td->td_retval[0] = nbytes - resid; out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } int -linux_getdents(struct proc *p, struct linux_getdents_args *args) +linux_getdents(struct thread *td, struct linux_getdents_args *args) { #ifdef DEBUG @@ -447,11 +448,11 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args) printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count); #endif - return (getdents_common(p, (struct linux_getdents64_args*)args, 0)); + return (getdents_common(td, (struct linux_getdents64_args*)args, 0)); } int -linux_getdents64(struct proc *p, struct linux_getdents64_args *args) +linux_getdents64(struct thread *td, struct linux_getdents64_args *args) { #ifdef DEBUG @@ -459,7 +460,7 @@ linux_getdents64(struct proc *p, struct linux_getdents64_args *args) printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count); #endif - return (getdents_common(p, args, 1)); + return (getdents_common(td, args, 1)); } /* @@ -467,13 +468,13 @@ linux_getdents64(struct proc *p, struct linux_getdents64_args *args) */ int -linux_access(struct proc *p, struct linux_access_args *args) +linux_access(struct thread *td, struct linux_access_args *args) { struct access_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(access)) @@ -482,17 +483,17 @@ linux_access(struct proc *p, struct linux_access_args *args) bsd.path = args->path; bsd.flags = args->flags; - return access(p, &bsd); + return access(td, &bsd); } int -linux_unlink(struct proc *p, struct linux_unlink_args *args) +linux_unlink(struct thread *td, struct linux_unlink_args *args) { struct unlink_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(unlink)) @@ -500,17 +501,17 @@ linux_unlink(struct proc *p, struct linux_unlink_args *args) #endif bsd.path = args->path; - return unlink(p, &bsd); + return unlink(td, &bsd); } int -linux_chdir(struct proc *p, struct linux_chdir_args *args) +linux_chdir(struct thread *td, struct linux_chdir_args *args) { struct chdir_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(chdir)) @@ -518,17 +519,17 @@ linux_chdir(struct proc *p, struct linux_chdir_args *args) #endif bsd.path = args->path; - return chdir(p, &bsd); + return chdir(td, &bsd); } int -linux_chmod(struct proc *p, struct linux_chmod_args *args) +linux_chmod(struct thread *td, struct linux_chmod_args *args) { struct chmod_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(chmod)) @@ -537,17 +538,17 @@ linux_chmod(struct proc *p, struct linux_chmod_args *args) bsd.path = args->path; bsd.mode = args->mode; - return chmod(p, &bsd); + return chmod(td, &bsd); } int -linux_mkdir(struct proc *p, struct linux_mkdir_args *args) +linux_mkdir(struct thread *td, struct linux_mkdir_args *args) { struct mkdir_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTCREAT(p, &sg, args->path); + CHECKALTCREAT(td, &sg, args->path); #ifdef DEBUG if (ldebug(mkdir)) @@ -556,17 +557,17 @@ linux_mkdir(struct proc *p, struct linux_mkdir_args *args) bsd.path = args->path; bsd.mode = args->mode; - return mkdir(p, &bsd); + return mkdir(td, &bsd); } int -linux_rmdir(struct proc *p, struct linux_rmdir_args *args) +linux_rmdir(struct thread *td, struct linux_rmdir_args *args) { struct rmdir_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(rmdir)) @@ -574,18 +575,18 @@ linux_rmdir(struct proc *p, struct linux_rmdir_args *args) #endif bsd.path = args->path; - return rmdir(p, &bsd); + return rmdir(td, &bsd); } int -linux_rename(struct proc *p, struct linux_rename_args *args) +linux_rename(struct thread *td, struct linux_rename_args *args) { struct rename_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->from); - CHECKALTCREAT(p, &sg, args->to); + CHECKALTEXIST(td, &sg, args->from); + CHECKALTCREAT(td, &sg, args->to); #ifdef DEBUG if (ldebug(rename)) @@ -594,18 +595,18 @@ linux_rename(struct proc *p, struct linux_rename_args *args) bsd.from = args->from; bsd.to = args->to; - return rename(p, &bsd); + return rename(td, &bsd); } int -linux_symlink(struct proc *p, struct linux_symlink_args *args) +linux_symlink(struct thread *td, struct linux_symlink_args *args) { struct symlink_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); - CHECKALTCREAT(p, &sg, args->to); + CHECKALTEXIST(td, &sg, args->path); + CHECKALTCREAT(td, &sg, args->to); #ifdef DEBUG if (ldebug(symlink)) @@ -614,17 +615,17 @@ linux_symlink(struct proc *p, struct linux_symlink_args *args) bsd.path = args->path; bsd.link = args->to; - return symlink(p, &bsd); + return symlink(td, &bsd); } int -linux_readlink(struct proc *p, struct linux_readlink_args *args) +linux_readlink(struct thread *td, struct linux_readlink_args *args) { struct readlink_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->name); + CHECKALTEXIST(td, &sg, args->name); #ifdef DEBUG if (ldebug(readlink)) @@ -635,17 +636,17 @@ linux_readlink(struct proc *p, struct linux_readlink_args *args) bsd.buf = args->buf; bsd.count = args->count; - return readlink(p, &bsd); + return readlink(td, &bsd); } int -linux_truncate(struct proc *p, struct linux_truncate_args *args) +linux_truncate(struct thread *td, struct linux_truncate_args *args) { struct truncate_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(truncate)) @@ -655,18 +656,18 @@ linux_truncate(struct proc *p, struct linux_truncate_args *args) bsd.path = args->path; bsd.length = args->length; - return truncate(p, &bsd); + return truncate(td, &bsd); } int -linux_link(struct proc *p, struct linux_link_args *args) +linux_link(struct thread *td, struct linux_link_args *args) { struct link_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); - CHECKALTCREAT(p, &sg, args->to); + CHECKALTEXIST(td, &sg, args->path); + CHECKALTCREAT(td, &sg, args->to); #ifdef DEBUG if (ldebug(link)) @@ -676,25 +677,25 @@ linux_link(struct proc *p, struct linux_link_args *args) bsd.path = args->path; bsd.link = args->to; - return link(p, &bsd); + return link(td, &bsd); } #ifndef __alpha__ int -linux_fdatasync(p, uap) - struct proc *p; +linux_fdatasync(td, uap) + struct thread *td; struct linux_fdatasync_args *uap; { struct fsync_args bsd; bsd.fd = uap->fd; - return fsync(p, &bsd); + return fsync(td, &bsd); } #endif /*!__alpha__*/ int -linux_pread(p, uap) - struct proc *p; +linux_pread(td, uap) + struct thread *td; struct linux_pread_args *uap; { struct pread_args bsd; @@ -703,12 +704,12 @@ linux_pread(p, uap) bsd.buf = uap->buf; bsd.nbyte = uap->nbyte; bsd.offset = uap->offset; - return pread(p, &bsd); + return pread(td, &bsd); } int -linux_pwrite(p, uap) - struct proc *p; +linux_pwrite(td, uap) + struct thread *td; struct linux_pwrite_args *uap; { struct pwrite_args bsd; @@ -717,11 +718,11 @@ linux_pwrite(p, uap) bsd.buf = uap->buf; bsd.nbyte = uap->nbyte; bsd.offset = uap->offset; - return pwrite(p, &bsd); + return pwrite(td, &bsd); } int -linux_mount(struct proc *p, struct linux_mount_args *args) +linux_mount(struct thread *td, struct linux_mount_args *args) { struct ufs_args ufs; char fstypename[MFSNAMELEN]; @@ -782,27 +783,27 @@ linux_mount(struct proc *p, struct linux_mount_args *args) fsflags |= MNT_UPDATE; } - return (vfs_mount(p, fstype, mntonname, fsflags, fsdata)); + return (vfs_mount(td, fstype, mntonname, fsflags, fsdata)); } int -linux_oldumount(struct proc *p, struct linux_oldumount_args *args) +linux_oldumount(struct thread *td, struct linux_oldumount_args *args) { struct linux_umount_args args2; args2.path = args->path; args2.flags = 0; - return (linux_umount(p, &args2)); + return (linux_umount(td, &args2)); } int -linux_umount(struct proc *p, struct linux_umount_args *args) +linux_umount(struct thread *td, struct linux_umount_args *args) { struct unmount_args bsd; bsd.path = args->path; bsd.flags = args->flags; /* XXX correct? */ - return (unmount(p, &bsd)); + return (unmount(td, &bsd)); } /* @@ -918,7 +919,7 @@ bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock) #endif static int -fcntl_common(struct proc *p, struct linux_fcntl64_args *args) +fcntl_common(struct thread *td, struct linux_fcntl64_args *args) { struct fcntl_args fcntl_args; struct filedesc *fdp; @@ -931,36 +932,36 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args) case LINUX_F_DUPFD: fcntl_args.cmd = F_DUPFD; fcntl_args.arg = args->arg; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_GETFD: fcntl_args.cmd = F_GETFD; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_SETFD: fcntl_args.cmd = F_SETFD; fcntl_args.arg = args->arg; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_GETFL: fcntl_args.cmd = F_GETFL; - error = fcntl(p, &fcntl_args); - result = p->p_retval[0]; - p->p_retval[0] = 0; + error = fcntl(td, &fcntl_args); + result = td->td_retval[0]; + td->td_retval[0] = 0; if (result & O_RDONLY) - p->p_retval[0] |= LINUX_O_RDONLY; + td->td_retval[0] |= LINUX_O_RDONLY; if (result & O_WRONLY) - p->p_retval[0] |= LINUX_O_WRONLY; + td->td_retval[0] |= LINUX_O_WRONLY; if (result & O_RDWR) - p->p_retval[0] |= LINUX_O_RDWR; + td->td_retval[0] |= LINUX_O_RDWR; if (result & O_NDELAY) - p->p_retval[0] |= LINUX_O_NONBLOCK; + td->td_retval[0] |= LINUX_O_NONBLOCK; if (result & O_APPEND) - p->p_retval[0] |= LINUX_O_APPEND; + td->td_retval[0] |= LINUX_O_APPEND; if (result & O_FSYNC) - p->p_retval[0] |= LINUX_O_SYNC; + td->td_retval[0] |= LINUX_O_SYNC; if (result & O_ASYNC) - p->p_retval[0] |= LINUX_FASYNC; + td->td_retval[0] |= LINUX_FASYNC; return (error); case LINUX_F_SETFL: @@ -974,11 +975,11 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args) if (args->arg & LINUX_FASYNC) fcntl_args.arg |= O_ASYNC; fcntl_args.cmd = F_SETFL; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_GETOWN: fcntl_args.cmd = F_GETOWN; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_SETOWN: /* @@ -986,7 +987,7 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args) * significant effect for pipes (SIGIO is not delivered for * pipes under Linux-2.2.35 at least). */ - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((u_int)args->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[args->fd]) == NULL) return (EBADF); @@ -995,14 +996,14 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args) fcntl_args.cmd = F_SETOWN; fcntl_args.arg = args->arg; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); } return (EINVAL); } int -linux_fcntl(struct proc *p, struct linux_fcntl_args *args) +linux_fcntl(struct thread *td, struct linux_fcntl_args *args) { struct linux_fcntl64_args args64; struct fcntl_args fcntl_args; @@ -1029,7 +1030,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_GETLK; fcntl_args.arg = (long)bsd_flock; - error = fcntl(p, &fcntl_args); + error = fcntl(td, &fcntl_args); if (error) return (error); bsd_to_linux_flock(bsd_flock, &linux_flock); @@ -1045,7 +1046,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_SETLK; fcntl_args.arg = (long)bsd_flock; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_SETLKW: error = copyin((caddr_t)args->arg, &linux_flock, @@ -1056,18 +1057,18 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_SETLKW; fcntl_args.arg = (long)bsd_flock; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); } args64.fd = args->fd; args64.cmd = args->cmd; args64.arg = args->arg; - return (fcntl_common(p, &args64)); + return (fcntl_common(td, &args64)); } #if defined(__i386__) int -linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args) +linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args) { struct fcntl_args fcntl_args; struct l_flock64 linux_flock; @@ -1093,7 +1094,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_GETLK; fcntl_args.arg = (long)bsd_flock; - error = fcntl(p, &fcntl_args); + error = fcntl(td, &fcntl_args); if (error) return (error); bsd_to_linux_flock64(bsd_flock, &linux_flock); @@ -1109,7 +1110,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_SETLK; fcntl_args.arg = (long)bsd_flock; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); case LINUX_F_SETLKW: error = copyin((caddr_t)args->arg, &linux_flock, @@ -1120,9 +1121,9 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args) fcntl_args.fd = args->fd; fcntl_args.cmd = F_SETLKW; fcntl_args.arg = (long)bsd_flock; - return (fcntl(p, &fcntl_args)); + return (fcntl(td, &fcntl_args)); } - return (fcntl_common(p, args)); + return (fcntl_common(td, args)); } #endif /* __i386__ */ diff --git a/sys/compat/linux/linux_getcwd.c b/sys/compat/linux/linux_getcwd.c index 2231f82..f08163b 100644 --- a/sys/compat/linux/linux_getcwd.c +++ b/sys/compat/linux/linux_getcwd.c @@ -61,10 +61,10 @@ static int linux_getcwd_scandir __P((struct vnode **, struct vnode **, - char **, char *, struct proc *)); + char **, char *, struct thread *)); static int linux_getcwd_common __P((struct vnode *, struct vnode *, - char **, char *, int, int, struct proc *)); + char **, char *, int, int, struct thread *)); #define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4) @@ -104,12 +104,12 @@ linux_getcwd_common __P((struct vnode *, struct vnode *, * On exit, *uvpp is either NULL or is a locked vnode reference. */ static int -linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p) +linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, td) struct vnode **lvpp; struct vnode **uvpp; char **bpp; char *bufp; - struct proc *p; + struct thread *td; { int error = 0; int eofflag; @@ -132,7 +132,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p) * current directory is still locked. */ if (bufp != NULL) { - error = VOP_GETATTR(lvp, &va, p->p_ucred, p); + error = VOP_GETATTR(lvp, &va, td->td_proc->p_ucred, td); if (error) { vput(lvp); *lvpp = NULL; @@ -147,8 +147,8 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p) */ cn.cn_nameiop = LOOKUP; cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY; - cn.cn_proc = p; - cn.cn_cred = p->p_ucred; + cn.cn_thread = td; + cn.cn_cred = td->td_proc->p_ucred; cn.cn_pnbuf = NULL; cn.cn_nameptr = ".."; cn.cn_namelen = 2; @@ -196,11 +196,11 @@ unionread: uio.uio_resid = dirbuflen; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; eofflag = 0; - error = VOP_READDIR(uvp, &uio, p->p_ucred, &eofflag, 0, 0); + error = VOP_READDIR(uvp, &uio, td->td_proc->p_ucred, &eofflag, 0, 0); off = uio.uio_offset; @@ -274,16 +274,16 @@ out: #define GETCWD_CHECK_ACCESS 0x0001 static int -linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p) +linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, td) struct vnode *lvp; struct vnode *rvp; char **bpp; char *bufp; int limit; int flags; - struct proc *p; + struct thread *td; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct vnode *uvp = NULL; char *bp = NULL; int error; @@ -305,7 +305,7 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p) * uvp is either NULL, or locked and held. */ - error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p); + error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td); if (error) { vrele(lvp); lvp = NULL; @@ -335,7 +335,7 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p) * whether or not caller cares. */ if (flags & GETCWD_CHECK_ACCESS) { - error = VOP_ACCESS(lvp, perms, p->p_ucred, p); + error = VOP_ACCESS(lvp, perms, td->td_proc->p_ucred, td); if (error) goto out; perms = VEXEC|VREAD; @@ -361,14 +361,14 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p) goto out; } VREF(lvp); - error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p); + error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td); if (error != 0) { vrele(lvp); lvp = NULL; goto out; } } - error = linux_getcwd_scandir(&lvp, &uvp, &bp, bufp, p); + error = linux_getcwd_scandir(&lvp, &uvp, &bp, bufp, td); if (error) goto out; #if DIAGNOSTIC @@ -405,25 +405,25 @@ out: */ int -linux_getcwd(struct proc *p, struct linux_getcwd_args *args) +linux_getcwd(struct thread *td, struct linux_getcwd_args *args) { struct __getcwd_args bsd; caddr_t sg, bp, bend, path; int error, len, lenused; #ifdef DEBUG - printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid, + printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)td->td_proc->p_pid, args->buf, args->bufsize); #endif sg = stackgap_init(); bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE); bsd.buflen = SPARE_USRSPACE; - error = __getcwd(p, &bsd); + error = __getcwd(td, &bsd); if (!error) { lenused = strlen(bsd.buf) + 1; if (lenused <= args->bufsize) { - p->p_retval[0] = lenused; + td->td_retval[0] = lenused; error = copyout(bsd.buf, args->buf, lenused); } else @@ -448,13 +448,13 @@ linux_getcwd(struct proc *p, struct linux_getcwd_args *args) * limit it to N/2 vnodes for an N byte buffer. */ - error = linux_getcwd_common (p->p_fd->fd_cdir, NULL, - &bp, path, len/2, GETCWD_CHECK_ACCESS, p); + error = linux_getcwd_common (td->td_proc->p_fd->fd_cdir, NULL, + &bp, path, len/2, GETCWD_CHECK_ACCESS, td); if (error) goto out; lenused = bend - bp; - p->p_retval[0] = lenused; + td->td_retval[0] = lenused; /* put the result into user buffer */ error = copyout(bp, args->buf, lenused); diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index b4fc8ce..ab80494 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -91,7 +91,7 @@ DATA_SET(linux_ioctl_handler_set, termio_handler); struct handler_element { TAILQ_ENTRY(handler_element) list; - int (*func)(struct proc *, struct linux_ioctl_args *); + int (*func)(struct thread *, struct linux_ioctl_args *); int low, high, span; }; @@ -99,15 +99,15 @@ static TAILQ_HEAD(, handler_element) handlers = TAILQ_HEAD_INITIALIZER(handlers); static int -linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_disk(struct thread *td, struct linux_ioctl_args *args) { - struct file *fp = p->p_fd->fd_ofiles[args->fd]; + struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd]; int error; struct disklabel dl; switch (args->cmd & 0xffff) { case LINUX_BLKGETSIZE: - error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); + error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td); if (error) return (error); return (copyout(&(dl.d_secperunit), (caddr_t)args->arg, @@ -511,18 +511,18 @@ linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios) } static int -linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args) { struct termios bios; struct linux_termios lios; struct linux_termio lio; - struct file *fp = p->p_fd->fd_ofiles[args->fd]; + struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd]; int error; switch (args->cmd & 0xffff) { case LINUX_TCGETS: - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td); if (error) return (error); bsd_to_linux_termios(&bios, &lios); @@ -533,24 +533,24 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) if (error) return (error); linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td)); case LINUX_TCSETSW: error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); if (error) return (error); linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td)); case LINUX_TCSETSF: error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); if (error) return (error); linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td)); case LINUX_TCGETA: - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td); if (error) return (error); bsd_to_linux_termio(&bios, &lio); @@ -561,21 +561,21 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) if (error) return (error); linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td)); case LINUX_TCSETAW: error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); if (error) return (error); linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td)); case LINUX_TCSETAF: error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); if (error) return (error); linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); + return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td)); /* LINUX_TCSBRK */ @@ -591,7 +591,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) case LINUX_TCION: { int c; struct write_args wr; - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); + error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td); if (error) return (error); c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART; @@ -600,7 +600,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) wr.fd = args->fd; wr.buf = &c; wr.nbyte = sizeof(c); - return (write(p, &wr)); + return (write(td, &wr)); } else return (0); } @@ -608,7 +608,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) return (EINVAL); } args->arg = 0; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } case LINUX_TCFLSH: { @@ -626,66 +626,66 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) default: return (EINVAL); } - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } case LINUX_TIOCEXCL: args->cmd = TIOCEXCL; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCNXCL: args->cmd = TIOCNXCL; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_TIOCSCTTY */ case LINUX_TIOCGPGRP: args->cmd = TIOCGPGRP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCSPGRP: args->cmd = TIOCSPGRP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_TIOCOUTQ */ /* LINUX_TIOCSTI */ case LINUX_TIOCGWINSZ: args->cmd = TIOCGWINSZ; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCSWINSZ: args->cmd = TIOCSWINSZ; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCMGET: args->cmd = TIOCMGET; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCMBIS: args->cmd = TIOCMBIS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCMBIC: args->cmd = TIOCMBIC; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCMSET: args->cmd = TIOCMSET; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* TIOCGSOFTCAR */ /* TIOCSSOFTCAR */ case LINUX_FIONREAD: /* LINUX_TIOCINQ */ args->cmd = FIONREAD; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_TIOCLINUX */ case LINUX_TIOCCONS: args->cmd = TIOCCONS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCGSERIAL: { struct linux_serial_struct lss; @@ -710,11 +710,11 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) case LINUX_FIONBIO: args->cmd = FIONBIO; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCNOTTY: args->cmd = TIOCNOTTY; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_TIOCSETD: { int line; @@ -731,13 +731,13 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) default: return (EINVAL); } - return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p)); + return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, td)); } case LINUX_TIOCGETD: { int linux_line; int bsd_line = TTYDISC; - error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); + error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, td); if (error) return (error); switch (bsd_line) { @@ -761,15 +761,15 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) case LINUX_FIONCLEX: args->cmd = FIONCLEX; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_FIOCLEX: args->cmd = FIOCLEX; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_FIOASYNC: args->cmd = FIOASYNC; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_TIOCSERCONFIG */ /* LINUX_TIOCSERGWILD */ @@ -860,33 +860,33 @@ set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) } static int -linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args) { - struct file *fp = p->p_fd->fd_ofiles[args->fd]; + struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd]; int error; switch (args->cmd & 0xffff) { case LINUX_CDROMPAUSE: args->cmd = CDIOCPAUSE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMRESUME: args->cmd = CDIOCRESUME; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMPLAYMSF: args->cmd = CDIOCPLAYMSF; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMPLAYTRKIND: args->cmd = CDIOCPLAYTRACKS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMREADTOCHDR: { struct ioc_toc_header th; struct linux_cdrom_tochdr lth; - error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); + error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, td); if (!error) { lth.cdth_trk0 = th.starting_track; lth.cdth_trk1 = th.ending_track; @@ -901,7 +901,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) struct ioc_read_toc_single_entry irtse; irtse.address_format = ltep->cdte_format; irtse.track = ltep->cdte_track; - error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); + error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, td); if (!error) { lte = *ltep; lte.cdte_ctrl = irtse.entry.control; @@ -915,15 +915,15 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) case LINUX_CDROMSTOP: args->cmd = CDIOCSTOP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMSTART: args->cmd = CDIOCSTART; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_CDROMEJECT: args->cmd = CDIOCEJECT; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_CDROMVOLCTRL */ @@ -939,7 +939,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) bsdsc.track = 0; bsdsc.data_len = sizeof(struct cd_sub_channel_info); bsdsc.data = bsdinfo; - error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); + error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, td); if (error) return (error); error = copyin((caddr_t)args->arg, &sc, @@ -969,7 +969,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) case LINUX_CDROMRESET: args->cmd = CDIOCRESET; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_CDROMVOLREAD */ /* LINUX_CDROMREADRAW */ @@ -994,227 +994,227 @@ static u_int32_t dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT }; #define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) static int -linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_sound(struct thread *td, struct linux_ioctl_args *args) { switch (args->cmd & 0xffff) { case LINUX_SOUND_MIXER_WRITE_VOLUME: args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_BASS: args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_TREBLE: args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_SYNTH: args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_PCM: args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_SPEAKER: args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_MIC: args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_CD: args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_IMIX: args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_ALTPCM: args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_RECLEV: args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_IGAIN: args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_OGAIN: args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE1: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE2: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE3: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_OSS_GETVERSION: { - int version = linux_get_oss_version(p); + int version = linux_get_oss_version(td->td_proc); return (copyout(&version, (caddr_t)args->arg, sizeof(int))); } case LINUX_SOUND_MIXER_READ_DEVMASK: args->cmd = SOUND_MIXER_READ_DEVMASK; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_RESET: args->cmd = SNDCTL_DSP_RESET; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SYNC: args->cmd = SNDCTL_DSP_SYNC; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SPEED: args->cmd = SNDCTL_DSP_SPEED; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_STEREO: args->cmd = SNDCTL_DSP_STEREO; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */ args->cmd = SNDCTL_DSP_GETBLKSIZE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETFMT: args->cmd = SNDCTL_DSP_SETFMT; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_PCM_WRITE_CHANNELS: args->cmd = SOUND_PCM_WRITE_CHANNELS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SOUND_PCM_WRITE_FILTER: args->cmd = SOUND_PCM_WRITE_FILTER; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_POST: args->cmd = SNDCTL_DSP_POST; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SUBDIVIDE: args->cmd = SNDCTL_DSP_SUBDIVIDE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETFRAGMENT: args->cmd = SNDCTL_DSP_SETFRAGMENT; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETFMTS: args->cmd = SNDCTL_DSP_GETFMTS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETOSPACE: args->cmd = SNDCTL_DSP_GETOSPACE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETISPACE: args->cmd = SNDCTL_DSP_GETISPACE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_NONBLOCK: args->cmd = SNDCTL_DSP_NONBLOCK; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETCAPS: args->cmd = SNDCTL_DSP_GETCAPS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */ args->cmd = SNDCTL_DSP_SETTRIGGER; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETIPTR: args->cmd = SNDCTL_DSP_GETIPTR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETOPTR: args->cmd = SNDCTL_DSP_GETOPTR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETODELAY: args->cmd = SNDCTL_DSP_GETODELAY; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_RESET: args->cmd = SNDCTL_SEQ_RESET; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_SYNC: args->cmd = SNDCTL_SEQ_SYNC; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SYNTH_INFO: args->cmd = SNDCTL_SYNTH_INFO; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_CTRLRATE: args->cmd = SNDCTL_SEQ_CTRLRATE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_GETOUTCOUNT: args->cmd = SNDCTL_SEQ_GETOUTCOUNT; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_GETINCOUNT: args->cmd = SNDCTL_SEQ_GETINCOUNT; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_PERCMODE: args->cmd = SNDCTL_SEQ_PERCMODE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_FM_LOAD_INSTR: args->cmd = SNDCTL_FM_LOAD_INSTR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_TESTMIDI: args->cmd = SNDCTL_SEQ_TESTMIDI; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_RESETSAMPLES: args->cmd = SNDCTL_SEQ_RESETSAMPLES; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_NRSYNTHS: args->cmd = SNDCTL_SEQ_NRSYNTHS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_NRMIDIS: args->cmd = SNDCTL_SEQ_NRMIDIS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_MIDI_INFO: args->cmd = SNDCTL_MIDI_INFO; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_TRESHOLD: args->cmd = SNDCTL_SEQ_TRESHOLD; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SNDCTL_SYNTH_MEMAVL: args->cmd = SNDCTL_SYNTH_MEMAVL; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } @@ -1228,39 +1228,39 @@ linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) static int -linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args) { - struct file *fp = p->p_fd->fd_ofiles[args->fd]; + struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd]; switch (args->cmd & 0xffff) { case LINUX_KIOCSOUND: args->cmd = KIOCSOUND; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDMKTONE: args->cmd = KDMKTONE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDGETLED: args->cmd = KDGETLED; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDSETLED: args->cmd = KDSETLED; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDSETMODE: args->cmd = KDSETMODE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDGETMODE: args->cmd = KDGETMODE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDGKBMODE: args->cmd = KDGKBMODE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_KDSKBMODE: { int kbdmode; @@ -1277,16 +1277,16 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) default: return (EINVAL); } - return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p)); + return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, td)); } case LINUX_VT_OPENQRY: args->cmd = VT_OPENQRY; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_VT_GETMODE: args->cmd = VT_GETMODE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_VT_SETMODE: { struct vt_mode *mode; @@ -1294,24 +1294,24 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) mode = (struct vt_mode *)args->arg; if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) mode->frsig = mode->acqsig; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } case LINUX_VT_GETSTATE: args->cmd = VT_GETACTIVE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_VT_RELDISP: args->cmd = VT_RELDISP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_VT_ACTIVATE: args->cmd = VT_ACTIVATE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_VT_WAITACTIVE: args->cmd = VT_WAITACTIVE; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } @@ -1323,56 +1323,56 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) */ static int -linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args) { switch (args->cmd & 0xffff) { case LINUX_FIOSETOWN: args->cmd = FIOSETOWN; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCSPGRP: args->cmd = SIOCSPGRP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_FIOGETOWN: args->cmd = FIOGETOWN; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGPGRP: args->cmd = SIOCGPGRP; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCATMARK: args->cmd = SIOCATMARK; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); /* LINUX_SIOCGSTAMP */ case LINUX_SIOCGIFCONF: args->cmd = OSIOCGIFCONF; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFFLAGS: args->cmd = SIOCGIFFLAGS; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFADDR: args->cmd = OSIOCGIFADDR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFDSTADDR: args->cmd = OSIOCGIFDSTADDR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFBRDADDR: args->cmd = OSIOCGIFBRDADDR; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFNETMASK: args->cmd = OSIOCGIFNETMASK; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCGIFHWADDR: { int ifn; @@ -1406,11 +1406,11 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) case LINUX_SIOCADDMULTI: args->cmd = SIOCADDMULTI; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); case LINUX_SIOCDELMULTI: args->cmd = SIOCDELMULTI; - return (ioctl(p, (struct ioctl_args *)args)); + return (ioctl(td, (struct ioctl_args *)args)); } @@ -1422,7 +1422,7 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) */ int -linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl(struct thread *td, struct linux_ioctl_args *args) { struct filedesc *fdp; struct file *fp; @@ -1434,7 +1434,7 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args) printf(ARGS(ioctl, "%d, %04lx, *"), args->fd, args->cmd); #endif - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)args->fd >= fdp->fd_nfiles) return (EBADF); fp = fdp->fd_ofiles[args->fd]; @@ -1445,7 +1445,7 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args) cmd = args->cmd & 0xffff; TAILQ_FOREACH(he, &handlers, list) { if (cmd >= he->low && cmd <= he->high) { - error = (*he->func)(p, args); + error = (*he->func)(td, args); if (error != ENOIOCTL) return (error); } diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c index de9b47a..9053efc 100644 --- a/sys/compat/linux/linux_ipc.c +++ b/sys/compat/linux/linux_ipc.c @@ -149,7 +149,7 @@ bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp) } int -linux_semop(struct proc *p, struct linux_semop_args *args) +linux_semop(struct thread *td, struct linux_semop_args *args) { struct semop_args /* { int semid; @@ -160,11 +160,11 @@ linux_semop(struct proc *p, struct linux_semop_args *args) bsd_args.semid = args->semid; bsd_args.sops = (struct sembuf *)args->tsops; bsd_args.nsops = args->nsops; - return semop(p, &bsd_args); + return semop(td, &bsd_args); } int -linux_semget(struct proc *p, struct linux_semget_args *args) +linux_semget(struct thread *td, struct linux_semget_args *args) { struct semget_args /* { key_t key; @@ -175,11 +175,11 @@ linux_semget(struct proc *p, struct linux_semget_args *args) bsd_args.key = args->key; bsd_args.nsems = args->nsems; bsd_args.semflg = args->semflg; - return semget(p, &bsd_args); + return semget(td, &bsd_args); } int -linux_semctl(struct proc *p, struct linux_semctl_args *args) +linux_semctl(struct thread *td, struct linux_semctl_args *args) { struct l_semid_ds linux_semid; struct __semctl_args /* { @@ -226,13 +226,13 @@ linux_semctl(struct proc *p, struct linux_semctl_args *args) unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); linux_to_bsd_semid_ds(&linux_semid, unptr->buf); bsd_args.arg = unptr; - return __semctl(p, &bsd_args); + return __semctl(td, &bsd_args); case LINUX_IPC_STAT: bsd_args.cmd = IPC_STAT; unptr = stackgap_alloc(&sg, sizeof(union semun)); unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); bsd_args.arg = unptr; - error = __semctl(p, &bsd_args); + error = __semctl(td, &bsd_args); if (error) return error; bsd_to_linux_semid_ds(unptr->buf, &linux_semid); @@ -246,11 +246,11 @@ linux_semctl(struct proc *p, struct linux_semctl_args *args) uprintf("linux: 'ipc' typ=%d not implemented\n", args->cmd); return EINVAL; } - return __semctl(p, &bsd_args); + return __semctl(td, &bsd_args); } int -linux_msgsnd(struct proc *p, struct linux_msgsnd_args *args) +linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args) { struct msgsnd_args /* { int msqid; @@ -263,11 +263,11 @@ linux_msgsnd(struct proc *p, struct linux_msgsnd_args *args) bsd_args.msgp = args->msgp; bsd_args.msgsz = args->msgsz; bsd_args.msgflg = args->msgflg; - return msgsnd(p, &bsd_args); + return msgsnd(td, &bsd_args); } int -linux_msgrcv(struct proc *p, struct linux_msgrcv_args *args) +linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args) { struct msgrcv_args /* { int msqid; @@ -282,11 +282,11 @@ linux_msgrcv(struct proc *p, struct linux_msgrcv_args *args) bsd_args.msgsz = args->msgsz; bsd_args.msgtyp = 0; /* XXX - args->msgtyp; */ bsd_args.msgflg = args->msgflg; - return msgrcv(p, &bsd_args); + return msgrcv(td, &bsd_args); } int -linux_msgget(struct proc *p, struct linux_msgget_args *args) +linux_msgget(struct thread *td, struct linux_msgget_args *args) { struct msgget_args /* { key_t key; @@ -295,11 +295,11 @@ linux_msgget(struct proc *p, struct linux_msgget_args *args) bsd_args.key = args->key; bsd_args.msgflg = args->msgflg; - return msgget(p, &bsd_args); + return msgget(td, &bsd_args); } int -linux_msgctl(struct proc *p, struct linux_msgctl_args *args) +linux_msgctl(struct thread *td, struct linux_msgctl_args *args) { struct msgctl_args /* { int msqid; @@ -311,12 +311,12 @@ linux_msgctl(struct proc *p, struct linux_msgctl_args *args) bsd_args.msqid = args->msqid; bsd_args.cmd = args->cmd; bsd_args.buf = (struct msqid_ds *)args->buf; - error = msgctl(p, &bsd_args); + error = msgctl(td, &bsd_args); return ((args->cmd == LINUX_IPC_RMID && error == EINVAL) ? 0 : error); } int -linux_shmat(struct proc *p, struct linux_shmat_args *args) +linux_shmat(struct thread *td, struct linux_shmat_args *args) { struct shmat_args /* { int shmid; @@ -328,29 +328,29 @@ linux_shmat(struct proc *p, struct linux_shmat_args *args) bsd_args.shmid = args->shmid; bsd_args.shmaddr = args->shmaddr; bsd_args.shmflg = args->shmflg; - if ((error = shmat(p, &bsd_args))) + if ((error = shmat(td, &bsd_args))) return error; #ifdef __i386__ - if ((error = copyout(p->p_retval, (caddr_t)args->raddr, sizeof(l_ulong)))) + if ((error = copyout(td->td_retval, (caddr_t)args->raddr, sizeof(l_ulong)))) return error; - p->p_retval[0] = 0; + td->td_retval[0] = 0; #endif return 0; } int -linux_shmdt(struct proc *p, struct linux_shmdt_args *args) +linux_shmdt(struct thread *td, struct linux_shmdt_args *args) { struct shmdt_args /* { void *shmaddr; } */ bsd_args; bsd_args.shmaddr = args->shmaddr; - return shmdt(p, &bsd_args); + return shmdt(td, &bsd_args); } int -linux_shmget(struct proc *p, struct linux_shmget_args *args) +linux_shmget(struct thread *td, struct linux_shmget_args *args) { struct shmget_args /* { key_t key; @@ -361,11 +361,11 @@ linux_shmget(struct proc *p, struct linux_shmget_args *args) bsd_args.key = args->key; bsd_args.size = args->size; bsd_args.shmflg = args->shmflg; - return shmget(p, &bsd_args); + return shmget(td, &bsd_args); } int -linux_shmctl(struct proc *p, struct linux_shmctl_args *args) +linux_shmctl(struct thread *td, struct linux_shmctl_args *args) { struct l_shmid_ds linux_shmid; struct shmctl_args /* { @@ -381,7 +381,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args) bsd_args.shmid = args->shmid; bsd_args.cmd = IPC_STAT; bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); - if ((error = shmctl(p, &bsd_args))) + if ((error = shmctl(td, &bsd_args))) return error; bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid); return copyout(&linux_shmid, (caddr_t)args->buf, sizeof(linux_shmid)); @@ -394,7 +394,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args) linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf); bsd_args.shmid = args->shmid; bsd_args.cmd = IPC_SET; - return shmctl(p, &bsd_args); + return shmctl(td, &bsd_args); case LINUX_IPC_RMID: bsd_args.shmid = args->shmid; @@ -408,7 +408,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args) bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf); } - return shmctl(p, &bsd_args); + return shmctl(td, &bsd_args); case LINUX_IPC_INFO: case LINUX_SHM_STAT: diff --git a/sys/compat/linux/linux_ipc.h b/sys/compat/linux/linux_ipc.h index d0db461..a647b4b 100644 --- a/sys/compat/linux/linux_ipc.h +++ b/sys/compat/linux/linux_ipc.h @@ -112,19 +112,19 @@ struct linux_shmget_args l_int shmflg; }; -int linux_msgctl __P((struct proc *, struct linux_msgctl_args *)); -int linux_msgget __P((struct proc *, struct linux_msgget_args *)); -int linux_msgrcv __P((struct proc *, struct linux_msgrcv_args *)); -int linux_msgsnd __P((struct proc *, struct linux_msgsnd_args *)); - -int linux_semctl __P((struct proc *, struct linux_semctl_args *)); -int linux_semget __P((struct proc *, struct linux_semget_args *)); -int linux_semop __P((struct proc *, struct linux_semop_args *)); - -int linux_shmat __P((struct proc *, struct linux_shmat_args *)); -int linux_shmctl __P((struct proc *, struct linux_shmctl_args *)); -int linux_shmdt __P((struct proc *, struct linux_shmdt_args *)); -int linux_shmget __P((struct proc *, struct linux_shmget_args *)); +int linux_msgctl __P((struct thread *, struct linux_msgctl_args *)); +int linux_msgget __P((struct thread *, struct linux_msgget_args *)); +int linux_msgrcv __P((struct thread *, struct linux_msgrcv_args *)); +int linux_msgsnd __P((struct thread *, struct linux_msgsnd_args *)); + +int linux_semctl __P((struct thread *, struct linux_semctl_args *)); +int linux_semget __P((struct thread *, struct linux_semget_args *)); +int linux_semop __P((struct thread *, struct linux_semop_args *)); + +int linux_shmat __P((struct thread *, struct linux_shmat_args *)); +int linux_shmctl __P((struct thread *, struct linux_shmctl_args *)); +int linux_shmdt __P((struct thread *, struct linux_shmdt_args *)); +int linux_shmget __P((struct thread *, struct linux_shmget_args *)); #endif /* __i386__ */ diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index a717d81..7acea9f 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -108,7 +108,7 @@ struct l_sysinfo { }; #ifndef __alpha__ int -linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args) +linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args) { struct l_sysinfo sysinfo; vm_object_t object; @@ -164,7 +164,7 @@ linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args) #ifndef __alpha__ int -linux_alarm(struct proc *p, struct linux_alarm_args *args) +linux_alarm(struct thread *td, struct linux_alarm_args *args) { struct itimerval it, old_it; struct timeval tv; @@ -183,31 +183,31 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args) it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; s = splsoftclock(); - old_it = p->p_realtimer; + old_it = td->td_proc->p_realtimer; getmicrouptime(&tv); if (timevalisset(&old_it.it_value)) - callout_stop(&p->p_itcallout); + callout_stop(&td->td_proc->p_itcallout); if (it.it_value.tv_sec != 0) { - callout_reset(&p->p_itcallout, tvtohz(&it.it_value), - realitexpire, p); + callout_reset(&td->td_proc->p_itcallout, tvtohz(&it.it_value), + realitexpire, td); timevaladd(&it.it_value, &tv); } - p->p_realtimer = it; + td->td_proc->p_realtimer = it; splx(s); if (timevalcmp(&old_it.it_value, &tv, >)) { timevalsub(&old_it.it_value, &tv); if (old_it.it_value.tv_usec != 0) old_it.it_value.tv_sec++; - p->p_retval[0] = old_it.it_value.tv_sec; + td->td_retval[0] = old_it.it_value.tv_sec; } return 0; } #endif /*!__alpha__*/ int -linux_brk(struct proc *p, struct linux_brk_args *args) +linux_brk(struct thread *td, struct linux_brk_args *args) { - struct vmspace *vm = p->p_vmspace; + struct vmspace *vm = td->td_proc->p_vmspace; vm_offset_t new, old; struct obreak_args /* { char * nsize; @@ -220,16 +220,16 @@ linux_brk(struct proc *p, struct linux_brk_args *args) old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize); new = (vm_offset_t)args->dsend; tmp.nsize = (char *) new; - if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp)) - p->p_retval[0] = (long)new; + if (((caddr_t)new > vm->vm_daddr) && !obreak(td, &tmp)) + td->td_retval[0] = (long)new; else - p->p_retval[0] = (long)old; + td->td_retval[0] = (long)old; return 0; } int -linux_uselib(struct proc *p, struct linux_uselib_args *args) +linux_uselib(struct thread *td, struct linux_uselib_args *args) { struct nameidata ni; struct vnode *vp; @@ -244,7 +244,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) int locked; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->library); + CHECKALTEXIST(td, &sg, args->library); #ifdef DEBUG if (ldebug(uselib)) @@ -255,7 +255,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) locked = 0; vp = NULL; - NDINIT(&ni, LOOKUP, FOLLOW|LOCKLEAF, UIO_USERSPACE, args->library, p); + NDINIT(&ni, LOOKUP, FOLLOW|LOCKLEAF, UIO_USERSPACE, args->library, td); error = namei(&ni); if (error) goto cleanup; @@ -283,7 +283,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) } /* Executable? */ - error = VOP_GETATTR(vp, &attr, p->p_ucred, p); + error = VOP_GETATTR(vp, &attr, td->td_proc->p_ucred, td); if (error) goto cleanup; @@ -300,18 +300,18 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) } /* Can we access it? */ - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); if (error) goto cleanup; - error = VOP_OPEN(vp, FREAD, p->p_ucred, p); + error = VOP_OPEN(vp, FREAD, td->td_proc->p_ucred, td); if (error) goto cleanup; /* * Lock no longer needed */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); locked = 0; /* Pull in executable header into kernel_map */ @@ -357,7 +357,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) goto cleanup; } - /* To protect p->p_rlimit in the if condition. */ + /* To protect td->td_proc->p_rlimit in the if condition. */ mtx_assert(&Giant, MA_OWNED); /* @@ -366,7 +366,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) * the resources needed by this library. */ if (a_out->a_text > MAXTSIZ || - a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) { + a_out->a_data + bss_size > + td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) { error = ENOMEM; goto cleanup; } @@ -389,8 +390,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) vmaddr = trunc_page(a_out->a_entry); /* get anon user mapping, read+write+execute */ - error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, - a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL, + error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0, + &vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; @@ -427,7 +428,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) * Map it all into the process's space as a single * copy-on-write "data" segment. */ - error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr, + error = vm_mmap(&td->td_proc->p_vmspace->vm_map, &vmaddr, a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED, (caddr_t)vp, file_offset); if (error) @@ -443,8 +444,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) a_out->a_data; /* allocate some 'anon' space */ - error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, - bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); + error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0, + &vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; } @@ -452,7 +453,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) cleanup: /* Unlock vnode if needed */ if (locked) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* Release the kernel mapping. */ if (a_out) @@ -463,7 +464,7 @@ cleanup: } int -linux_select(struct proc *p, struct linux_select_args *args) +linux_select(struct thread *td, struct linux_select_args *args) { struct select_args bsa; struct timeval tv0, tv1, utv, *tvp; @@ -520,7 +521,7 @@ linux_select(struct proc *p, struct linux_select_args *args) microtime(&tv0); } - error = select(p, &bsa); + error = select(td, &bsa); #ifdef DEBUG if (ldebug(select)) printf(LMSG("real select returns %d"), error); @@ -536,7 +537,7 @@ linux_select(struct proc *p, struct linux_select_args *args) } if (args->timeout) { - if (p->p_retval[0]) { + if (td->td_retval[0]) { /* * Compute how much time was left of the timeout, * by subtracting the current time and the time @@ -569,7 +570,7 @@ select_out: } int -linux_getpgid(struct proc *p, struct linux_getpgid_args *args) +linux_getpgid(struct thread *td, struct linux_getpgid_args *args) { struct proc *curp; @@ -578,19 +579,19 @@ linux_getpgid(struct proc *p, struct linux_getpgid_args *args) printf(ARGS(getpgid, "%d"), args->pid); #endif - if (args->pid != p->p_pid) { + if (args->pid != td->td_proc->p_pid) { if (!(curp = pfind(args->pid))) return ESRCH; - p->p_retval[0] = curp->p_pgid; + td->td_retval[0] = curp->p_pgid; PROC_UNLOCK(curp); } else - p->p_retval[0] = p->p_pgid; + td->td_retval[0] = td->td_proc->p_pgid; return 0; } int -linux_mremap(struct proc *p, struct linux_mremap_args *args) +linux_mremap(struct thread *td, struct linux_mremap_args *args) { struct munmap_args /* { void *addr; @@ -610,22 +611,22 @@ linux_mremap(struct proc *p, struct linux_mremap_args *args) args->old_len = round_page(args->old_len); if (args->new_len > args->old_len) { - p->p_retval[0] = 0; + td->td_retval[0] = 0; return ENOMEM; } if (args->new_len < args->old_len) { bsd_args.addr = (caddr_t)(args->addr + args->new_len); bsd_args.len = args->old_len - args->new_len; - error = munmap(p, &bsd_args); + error = munmap(td, &bsd_args); } - p->p_retval[0] = error ? 0 : (u_long)args->addr; + td->td_retval[0] = error ? 0 : (u_long)args->addr; return error; } int -linux_msync(struct proc *p, struct linux_msync_args *args) +linux_msync(struct thread *td, struct linux_msync_args *args) { struct msync_args bsd_args; @@ -633,12 +634,12 @@ linux_msync(struct proc *p, struct linux_msync_args *args) bsd_args.len = args->len; bsd_args.flags = 0; /* XXX ignore */ - return msync(p, &bsd_args); + return msync(td, &bsd_args); } #ifndef __alpha__ int -linux_time(struct proc *p, struct linux_time_args *args) +linux_time(struct thread *td, struct linux_time_args *args) { struct timeval tv; l_time_t tm; @@ -653,7 +654,7 @@ linux_time(struct proc *p, struct linux_time_args *args) tm = tv.tv_sec; if (args->tm && (error = copyout(&tm, (caddr_t)args->tm, sizeof(tm)))) return error; - p->p_retval[0] = tm; + td->td_retval[0] = tm; return 0; } #endif /*!__alpha__*/ @@ -674,7 +675,7 @@ struct l_times_argv { #define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) int -linux_times(struct proc *p, struct linux_times_args *args) +linux_times(struct thread *td, struct linux_times_args *args) { struct timeval tv; struct l_times_argv tms; @@ -687,25 +688,25 @@ linux_times(struct proc *p, struct linux_times_args *args) #endif mtx_lock_spin(&sched_lock); - calcru(p, &ru.ru_utime, &ru.ru_stime, NULL); + calcru(td->td_proc, &ru.ru_utime, &ru.ru_stime, NULL); mtx_unlock_spin(&sched_lock); tms.tms_utime = CONVTCK(ru.ru_utime); tms.tms_stime = CONVTCK(ru.ru_stime); - tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); - tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); + tms.tms_cutime = CONVTCK(td->td_proc->p_stats->p_cru.ru_utime); + tms.tms_cstime = CONVTCK(td->td_proc->p_stats->p_cru.ru_stime); if ((error = copyout(&tms, (caddr_t)args->buf, sizeof(tms)))) return error; microuptime(&tv); - p->p_retval[0] = (int)CONVTCK(tv); + td->td_retval[0] = (int)CONVTCK(tv); return 0; } int -linux_newuname(struct proc *p, struct linux_newuname_args *args) +linux_newuname(struct thread *td, struct linux_newuname_args *args) { struct l_new_utsname utsname; char *osrelease, *osname; @@ -715,8 +716,8 @@ linux_newuname(struct proc *p, struct linux_newuname_args *args) printf(ARGS(newuname, "*")); #endif - osname = linux_get_osname(p); - osrelease = linux_get_osrelease(p); + osname = linux_get_osname(td->td_proc); + osrelease = linux_get_osrelease(td->td_proc); bzero(&utsname, sizeof(utsname)); strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1); @@ -736,7 +737,7 @@ struct l_utimbuf { }; int -linux_utime(struct proc *p, struct linux_utime_args *args) +linux_utime(struct thread *td, struct linux_utime_args *args) { struct utimes_args /* { char *path; @@ -748,7 +749,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->fname); + CHECKALTEXIST(td, &sg, args->fname); #ifdef DEBUG if (ldebug(utime)) @@ -773,7 +774,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args) bsdutimes.tptr = NULL; bsdutimes.path = args->fname; - return utimes(p, &bsdutimes); + return utimes(td, &bsdutimes); } #endif /* __i386__ */ @@ -781,7 +782,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args) #ifndef __alpha__ int -linux_waitpid(struct proc *p, struct linux_waitpid_args *args) +linux_waitpid(struct thread *td, struct linux_waitpid_args *args) { struct wait_args /* { int pid; @@ -805,7 +806,7 @@ linux_waitpid(struct proc *p, struct linux_waitpid_args *args) tmp.options |= WLINUXCLONE; tmp.rusage = NULL; - if ((error = wait4(p, &tmp)) != 0) + if ((error = wait4(td, &tmp)) != 0) return error; if (args->status) { @@ -827,7 +828,7 @@ linux_waitpid(struct proc *p, struct linux_waitpid_args *args) #endif /*!__alpha__*/ int -linux_wait4(struct proc *p, struct linux_wait4_args *args) +linux_wait4(struct thread *td, struct linux_wait4_args *args) { struct wait_args /* { int pid; @@ -852,10 +853,10 @@ linux_wait4(struct proc *p, struct linux_wait4_args *args) tmp.options |= WLINUXCLONE; tmp.rusage = (struct rusage *)args->rusage; - if ((error = wait4(p, &tmp)) != 0) + if ((error = wait4(td, &tmp)) != 0) return error; - SIGDELSET(p->p_siglist, SIGCHLD); + SIGDELSET(td->td_proc->p_siglist, SIGCHLD); if (args->status) { if ((error = copyin((caddr_t)args->status, &tmpstat, @@ -875,7 +876,7 @@ linux_wait4(struct proc *p, struct linux_wait4_args *args) } int -linux_mknod(struct proc *p, struct linux_mknod_args *args) +linux_mknod(struct thread *td, struct linux_mknod_args *args) { caddr_t sg; struct mknod_args bsd_mknod; @@ -883,7 +884,7 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args) sg = stackgap_init(); - CHECKALTCREAT(p, &sg, args->path); + CHECKALTCREAT(td, &sg, args->path); #ifdef DEBUG if (ldebug(mknod)) @@ -894,12 +895,12 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args) if (args->mode & S_IFIFO) { bsd_mkfifo.path = args->path; bsd_mkfifo.mode = args->mode; - return mkfifo(p, &bsd_mkfifo); + return mkfifo(td, &bsd_mkfifo); } else { bsd_mknod.path = args->path; bsd_mknod.mode = args->mode; bsd_mknod.dev = args->dev; - return mknod(p, &bsd_mknod); + return mknod(td, &bsd_mknod); } } @@ -907,7 +908,7 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args) * UGH! This is just about the dumbest idea I've ever heard!! */ int -linux_personality(struct proc *p, struct linux_personality_args *args) +linux_personality(struct thread *td, struct linux_personality_args *args) { #ifdef DEBUG if (ldebug(personality)) @@ -919,7 +920,7 @@ linux_personality(struct proc *p, struct linux_personality_args *args) #endif /* Yes Jim, it's still a Linux... */ - p->p_retval[0] = 0; + td->td_retval[0] = 0; return 0; } @@ -927,7 +928,7 @@ linux_personality(struct proc *p, struct linux_personality_args *args) * Wrappers for get/setitimer for debugging.. */ int -linux_setitimer(struct proc *p, struct linux_setitimer_args *args) +linux_setitimer(struct thread *td, struct linux_setitimer_args *args) { struct setitimer_args bsa; struct itimerval foo; @@ -953,11 +954,11 @@ linux_setitimer(struct proc *p, struct linux_setitimer_args *args) } #endif } - return setitimer(p, &bsa); + return setitimer(td, &bsa); } int -linux_getitimer(struct proc *p, struct linux_getitimer_args *args) +linux_getitimer(struct thread *td, struct linux_getitimer_args *args) { struct getitimer_args bsa; #ifdef DEBUG @@ -966,24 +967,24 @@ linux_getitimer(struct proc *p, struct linux_getitimer_args *args) #endif bsa.which = args->which; bsa.itv = (struct itimerval *)args->itv; - return getitimer(p, &bsa); + return getitimer(td, &bsa); } #ifndef __alpha__ int -linux_nice(struct proc *p, struct linux_nice_args *args) +linux_nice(struct thread *td, struct linux_nice_args *args) { struct setpriority_args bsd_args; bsd_args.which = PRIO_PROCESS; bsd_args.who = 0; /* current process */ bsd_args.prio = args->inc; - return setpriority(p, &bsd_args); + return setpriority(td, &bsd_args); } #endif /*!__alpha__*/ int -linux_setgroups(struct proc *p, struct linux_setgroups_args *args) +linux_setgroups(struct thread *td, struct linux_setgroups_args *args) { struct ucred *newcred, *oldcred; l_gid_t linux_gidset[NGROUPS]; @@ -991,7 +992,7 @@ linux_setgroups(struct proc *p, struct linux_setgroups_args *args) int ngrp, error; ngrp = args->gidsetsize; - oldcred = p->p_ucred; + oldcred = td->td_proc->p_ucred; /* * cr_groups[0] holds egid. Setting the whole set from @@ -1024,21 +1025,21 @@ linux_setgroups(struct proc *p, struct linux_setgroups_args *args) else newcred->cr_ngroups = 1; - setsugid(p); - p->p_ucred = newcred; + setsugid(td->td_proc); + td->td_proc->p_ucred = newcred; crfree(oldcred); return (0); } int -linux_getgroups(struct proc *p, struct linux_getgroups_args *args) +linux_getgroups(struct thread *td, struct linux_getgroups_args *args) { struct ucred *cred; l_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int bsd_gidsetsz, ngrp, error; - cred = p->p_ucred; + cred = td->td_proc->p_ucred; bsd_gidset = cred->cr_groups; bsd_gidsetsz = cred->cr_ngroups - 1; @@ -1049,7 +1050,7 @@ linux_getgroups(struct proc *p, struct linux_getgroups_args *args) */ if ((ngrp = args->gidsetsize) == 0) { - p->p_retval[0] = bsd_gidsetsz; + td->td_retval[0] = bsd_gidsetsz; return (0); } @@ -1066,13 +1067,13 @@ linux_getgroups(struct proc *p, struct linux_getgroups_args *args) ngrp * sizeof(l_gid_t)))) return (error); - p->p_retval[0] = ngrp; + td->td_retval[0] = ngrp; return (0); } #ifndef __alpha__ int -linux_setrlimit(struct proc *p, struct linux_setrlimit_args *args) +linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args) { struct __setrlimit_args bsd; struct l_rlimit rlim; @@ -1099,11 +1100,11 @@ linux_setrlimit(struct proc *p, struct linux_setrlimit_args *args) bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur; bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max; - return (setrlimit(p, &bsd)); + return (setrlimit(td, &bsd)); } int -linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args) +linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args) { struct __getrlimit_args bsd; struct l_rlimit rlim; @@ -1124,7 +1125,7 @@ linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args) return (EINVAL); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); - error = getrlimit(p, &bsd); + error = getrlimit(td, &bsd); if (error) return (error); @@ -1138,7 +1139,7 @@ linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args) } int -linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args) +linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args) { struct __getrlimit_args bsd; struct l_rlimit rlim; @@ -1159,7 +1160,7 @@ linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args) return (EINVAL); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); - error = getrlimit(p, &bsd); + error = getrlimit(td, &bsd); if (error) return (error); @@ -1170,7 +1171,7 @@ linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args) #endif /*!__alpha__*/ int -linux_sched_setscheduler(struct proc *p, +linux_sched_setscheduler(struct thread *td, struct linux_sched_setscheduler_args *args) { struct sched_setscheduler_args bsd; @@ -1197,11 +1198,11 @@ linux_sched_setscheduler(struct proc *p, bsd.pid = args->pid; bsd.param = (struct sched_param *)args->param; - return sched_setscheduler(p, &bsd); + return sched_setscheduler(td, &bsd); } int -linux_sched_getscheduler(struct proc *p, +linux_sched_getscheduler(struct thread *td, struct linux_sched_getscheduler_args *args) { struct sched_getscheduler_args bsd; @@ -1213,17 +1214,17 @@ linux_sched_getscheduler(struct proc *p, #endif bsd.pid = args->pid; - error = sched_getscheduler(p, &bsd); + error = sched_getscheduler(td, &bsd); - switch (p->p_retval[0]) { + switch (td->td_retval[0]) { case SCHED_OTHER: - p->p_retval[0] = LINUX_SCHED_OTHER; + td->td_retval[0] = LINUX_SCHED_OTHER; break; case SCHED_FIFO: - p->p_retval[0] = LINUX_SCHED_FIFO; + td->td_retval[0] = LINUX_SCHED_FIFO; break; case SCHED_RR: - p->p_retval[0] = LINUX_SCHED_RR; + td->td_retval[0] = LINUX_SCHED_RR; break; } @@ -1231,7 +1232,7 @@ linux_sched_getscheduler(struct proc *p, } int -linux_sched_get_priority_max(struct proc *p, +linux_sched_get_priority_max(struct thread *td, struct linux_sched_get_priority_max_args *args) { struct sched_get_priority_max_args bsd; @@ -1254,11 +1255,11 @@ linux_sched_get_priority_max(struct proc *p, default: return EINVAL; } - return sched_get_priority_max(p, &bsd); + return sched_get_priority_max(td, &bsd); } int -linux_sched_get_priority_min(struct proc *p, +linux_sched_get_priority_min(struct thread *td, struct linux_sched_get_priority_min_args *args) { struct sched_get_priority_min_args bsd; @@ -1281,7 +1282,7 @@ linux_sched_get_priority_min(struct proc *p, default: return EINVAL; } - return sched_get_priority_min(p, &bsd); + return sched_get_priority_min(td, &bsd); } #define REBOOT_CAD_ON 0x89abcdef @@ -1289,7 +1290,7 @@ linux_sched_get_priority_min(struct proc *p, #define REBOOT_HALT 0xcdef0123 int -linux_reboot(struct proc *p, struct linux_reboot_args *args) +linux_reboot(struct thread *td, struct linux_reboot_args *args) { struct reboot_args bsd_args; @@ -1300,12 +1301,12 @@ linux_reboot(struct proc *p, struct linux_reboot_args *args) if (args->cmd == REBOOT_CAD_ON || args->cmd == REBOOT_CAD_OFF) return (0); bsd_args.opt = (args->cmd == REBOOT_HALT) ? RB_HALT : 0; - return (reboot(p, &bsd_args)); + return (reboot(td, &bsd_args)); } /* * The FreeBSD native getpid(2), getgid(2) and getuid(2) also modify - * p->p_retval[1] when COMPAT_43 or COMPAT_SUNOS is defined. This + * td->td_retval[1] when COMPAT_43 or COMPAT_SUNOS is defined. This * globbers registers that are assumed to be preserved. The following * lightweight syscalls fixes this. See also linux_getgid16() and * linux_getuid16() in linux_uid16.c. @@ -1316,22 +1317,25 @@ linux_reboot(struct proc *p, struct linux_reboot_args *args) */ int -linux_getpid(struct proc *p, struct linux_getpid_args *args) +linux_getpid(struct thread *td, struct linux_getpid_args *args) { - p->p_retval[0] = p->p_pid; + + td->td_retval[0] = td->td_proc->p_pid; return (0); } int -linux_getgid(struct proc *p, struct linux_getgid_args *args) +linux_getgid(struct thread *td, struct linux_getgid_args *args) { - p->p_retval[0] = p->p_ucred->cr_rgid; + + td->td_retval[0] = td->td_proc->p_ucred->cr_rgid; return (0); } int -linux_getuid(struct proc *p, struct linux_getuid_args *args) +linux_getuid(struct thread *td, struct linux_getuid_args *args) { - p->p_retval[0] = p->p_ucred->cr_ruid; + + td->td_retval[0] = td->td_proc->p_ucred->cr_ruid; return (0); } diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 24a540f..ccc30f0 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -131,7 +131,7 @@ bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa) } int -linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa, +linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa, l_sigaction_t *linux_osa) { struct sigaction *nsa, *osa; @@ -163,7 +163,7 @@ linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa, sa_args.act = nsa; sa_args.oact = osa; - error = sigaction(p, &sa_args); + error = sigaction(td, &sa_args); if (error) return (error); @@ -176,7 +176,7 @@ linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa, #ifndef __alpha__ int -linux_signal(struct proc *p, struct linux_signal_args *args) +linux_signal(struct thread *td, struct linux_signal_args *args) { l_sigaction_t nsa, osa; int error; @@ -191,15 +191,15 @@ linux_signal(struct proc *p, struct linux_signal_args *args) nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; LINUX_SIGEMPTYSET(nsa.lsa_mask); - error = linux_do_sigaction(p, args->sig, &nsa, &osa); - p->p_retval[0] = (int)osa.lsa_handler; + error = linux_do_sigaction(td, args->sig, &nsa, &osa); + td->td_retval[0] = (int)osa.lsa_handler; return (error); } #endif /*!__alpha__*/ int -linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) +linux_rt_sigaction(struct thread *td, struct linux_rt_sigaction_args *args) { l_sigaction_t nsa, osa; int error; @@ -220,7 +220,7 @@ linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) return (error); } - error = linux_do_sigaction(p, args->sig, + error = linux_do_sigaction(td, args->sig, args->act ? &nsa : NULL, args->oact ? &osa : NULL); @@ -232,14 +232,15 @@ linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) } static int -linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new, +linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new, l_sigset_t *old) { int error; sigset_t mask; + struct proc *p = td->td_proc; error = 0; - p->p_retval[0] = 0; + td->td_retval[0] = 0; PROC_LOCK(p); if (old != NULL) @@ -272,7 +273,7 @@ linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new, #ifndef __alpha__ int -linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) +linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args) { l_osigset_t mask; l_sigset_t set, oset; @@ -291,7 +292,7 @@ linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) set.__bits[0] = mask; } - error = linux_do_sigprocmask(p, args->how, + error = linux_do_sigprocmask(td, args->how, args->mask ? &set : NULL, args->omask ? &oset : NULL); @@ -305,7 +306,7 @@ linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) #endif /*!__alpha__*/ int -linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) +linux_rt_sigprocmask(struct thread *td, struct linux_rt_sigprocmask_args *args) { l_sigset_t set, oset; int error; @@ -326,7 +327,7 @@ linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) return (error); } - error = linux_do_sigprocmask(p, args->how, + error = linux_do_sigprocmask(td, args->how, args->mask ? &set : NULL, args->omask ? &oset : NULL); @@ -339,8 +340,9 @@ linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) #ifndef __alpha__ int -linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args) +linux_sgetmask(struct thread *td, struct linux_sgetmask_args *args) { + struct proc *p = td->td_proc; l_sigset_t mask; #ifdef DEBUG @@ -351,13 +353,14 @@ linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args) PROC_LOCK(p); bsd_to_linux_sigset(&p->p_sigmask, &mask); PROC_UNLOCK(p); - p->p_retval[0] = mask.__bits[0]; + td->td_retval[0] = mask.__bits[0]; return (0); } int -linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args) +linux_ssetmask(struct thread *td, struct linux_ssetmask_args *args) { + struct proc *p = td->td_proc; l_sigset_t lset; sigset_t bset; @@ -368,7 +371,7 @@ linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args) PROC_LOCK(p); bsd_to_linux_sigset(&p->p_sigmask, &lset); - p->p_retval[0] = lset.__bits[0]; + td->td_retval[0] = lset.__bits[0]; LINUX_SIGEMPTYSET(lset); lset.__bits[0] = args->mask; linux_to_bsd_sigset(&lset, &bset); @@ -379,8 +382,9 @@ linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args) } int -linux_sigpending(struct proc *p, struct linux_sigpending_args *args) +linux_sigpending(struct thread *td, struct linux_sigpending_args *args) { + struct proc *p = td->td_proc; sigset_t bset; l_sigset_t lset; l_osigset_t mask; @@ -401,7 +405,7 @@ linux_sigpending(struct proc *p, struct linux_sigpending_args *args) #endif /*!__alpha__*/ int -linux_kill(struct proc *p, struct linux_kill_args *args) +linux_kill(struct thread *td, struct linux_kill_args *args) { struct kill_args /* { int pid; @@ -427,5 +431,5 @@ linux_kill(struct proc *p, struct linux_kill_args *args) tmp.signum = args->signum; tmp.pid = args->pid; - return (kill(p, &tmp)); + return (kill(td, &tmp)); } diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h index e9dcec0..8d0825b 100644 --- a/sys/compat/linux/linux_signal.h +++ b/sys/compat/linux/linux_signal.h @@ -33,7 +33,7 @@ void linux_to_bsd_sigset __P((l_sigset_t *, sigset_t *)); void bsd_to_linux_sigset __P((sigset_t *, l_sigset_t *)); -int linux_do_sigaction __P((struct proc *, int, l_sigaction_t *, +int linux_do_sigaction __P((struct thread *, int, l_sigaction_t *, l_sigaction_t *)); #endif /* _LINUX_SIGNAL_H_ */ diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index ac73dde..de74054 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -187,7 +187,7 @@ linux_to_bsd_msg_flags(int flags) /* Return 0 if IP_HDRINCL is set for the given socket. */ static int -linux_check_hdrincl(struct proc *p, int s) +linux_check_hdrincl(struct thread *td, int s) { struct getsockopt_args /* { int s; @@ -213,7 +213,7 @@ linux_check_hdrincl(struct proc *p, int s) bsd_args.name = IP_HDRINCL; bsd_args.val = val; bsd_args.avalsize = (int *)valsize; - if ((error = getsockopt(p, &bsd_args))) + if ((error = getsockopt(td, &bsd_args))) return (error); if ((error = copyin(val, &optval, sizeof(optval)))) @@ -227,7 +227,7 @@ linux_check_hdrincl(struct proc *p, int s) * tweak endian-dependent fields in the IP packet. */ static int -linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args) +linux_sendto_hdrincl(struct thread *td, struct sendto_args *bsd_args) { /* * linux_ip_copysize defines how many bytes we should copy @@ -288,7 +288,7 @@ linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args) sendmsg_args.s = bsd_args->s; sendmsg_args.msg = (caddr_t)msg; sendmsg_args.flags = bsd_args->flags; - return (sendmsg(p, &sendmsg_args)); + return (sendmsg(td, &sendmsg_args)); } struct linux_socket_args { @@ -298,7 +298,7 @@ struct linux_socket_args { }; static int -linux_socket(struct proc *p, struct linux_socket_args *args) +linux_socket(struct thread *td, struct linux_socket_args *args) { struct linux_socket_args linux_args; struct socket_args /* { @@ -318,7 +318,7 @@ linux_socket(struct proc *p, struct linux_socket_args *args) if (bsd_args.domain == -1) return (EINVAL); - retval_socket = socket(p, &bsd_args); + retval_socket = socket(td, &bsd_args); if (bsd_args.type == SOCK_RAW && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0) && bsd_args.domain == AF_INET @@ -337,15 +337,15 @@ linux_socket(struct proc *p, struct linux_socket_args *args) sg = stackgap_init(); hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl)); *hdrincl = 1; - bsd_setsockopt_args.s = p->p_retval[0]; + bsd_setsockopt_args.s = td->td_retval[0]; bsd_setsockopt_args.level = IPPROTO_IP; bsd_setsockopt_args.name = IP_HDRINCL; bsd_setsockopt_args.val = (caddr_t)hdrincl; bsd_setsockopt_args.valsize = sizeof(*hdrincl); /* We ignore any error returned by setsockopt() */ - setsockopt(p, &bsd_setsockopt_args); + setsockopt(td, &bsd_setsockopt_args); /* Copy back the return value from socket() */ - p->p_retval[0] = bsd_setsockopt_args.s; + td->td_retval[0] = bsd_setsockopt_args.s; } return (retval_socket); @@ -358,7 +358,7 @@ struct linux_bind_args { }; static int -linux_bind(struct proc *p, struct linux_bind_args *args) +linux_bind(struct thread *td, struct linux_bind_args *args) { struct linux_bind_args linux_args; struct bind_args /* { @@ -374,7 +374,7 @@ linux_bind(struct proc *p, struct linux_bind_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; - return (bind(p, &bsd_args)); + return (bind(td, &bsd_args)); } struct linux_connect_args { @@ -382,11 +382,11 @@ struct linux_connect_args { struct sockaddr * name; int namelen; }; -int linux_connect(struct proc *, struct linux_connect_args *); +int linux_connect(struct thread *, struct linux_connect_args *); #endif /* !__alpha__*/ int -linux_connect(struct proc *p, struct linux_connect_args *args) +linux_connect(struct thread *td, struct linux_connect_args *args) { struct linux_connect_args linux_args; struct connect_args /* { @@ -408,7 +408,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; - error = connect(p, &bsd_args); + error = connect(td, &bsd_args); if (error != EISCONN) return (error); @@ -417,7 +417,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) * when on a non-blocking socket. Instead it returns the * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD. */ - error = holdsock(p->p_fd, linux_args.s, &fp); + error = holdsock(td->td_proc->p_fd, linux_args.s, &fp); if (error) return (error); error = EISCONN; @@ -427,7 +427,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) error = so->so_error; so->so_emuldata = (void *)1; } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -439,7 +439,7 @@ struct linux_listen_args { }; static int -linux_listen(struct proc *p, struct linux_listen_args *args) +linux_listen(struct thread *td, struct linux_listen_args *args) { struct linux_listen_args linux_args; struct listen_args /* { @@ -453,7 +453,7 @@ linux_listen(struct proc *p, struct linux_listen_args *args) bsd_args.s = linux_args.s; bsd_args.backlog = linux_args.backlog; - return (listen(p, &bsd_args)); + return (listen(td, &bsd_args)); } struct linux_accept_args { @@ -463,7 +463,7 @@ struct linux_accept_args { }; static int -linux_accept(struct proc *p, struct linux_accept_args *args) +linux_accept(struct thread *td, struct linux_accept_args *args) { struct linux_accept_args linux_args; struct accept_args /* { @@ -484,7 +484,7 @@ linux_accept(struct proc *p, struct linux_accept_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.addr; bsd_args.anamelen = linux_args.namelen; - error = oaccept(p, &bsd_args); + error = oaccept(td, &bsd_args); if (error) return (error); @@ -493,11 +493,11 @@ linux_accept(struct proc *p, struct linux_accept_args *args) * accepted one, so we must clear the flags in the new descriptor. * Ignore any errors, because we already have an open fd. */ - f_args.fd = p->p_retval[0]; + f_args.fd = td->td_retval[0]; f_args.cmd = F_SETFL; f_args.arg = 0; - (void)fcntl(p, &f_args); - p->p_retval[0] = f_args.fd; + (void)fcntl(td, &f_args); + td->td_retval[0] = f_args.fd; return (0); } @@ -508,7 +508,7 @@ struct linux_getsockname_args { }; static int -linux_getsockname(struct proc *p, struct linux_getsockname_args *args) +linux_getsockname(struct thread *td, struct linux_getsockname_args *args) { struct linux_getsockname_args linux_args; struct getsockname_args /* { @@ -524,7 +524,7 @@ linux_getsockname(struct proc *p, struct linux_getsockname_args *args) bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - return (ogetsockname(p, &bsd_args)); + return (ogetsockname(td, &bsd_args)); } struct linux_getpeername_args { @@ -534,7 +534,7 @@ struct linux_getpeername_args { }; static int -linux_getpeername(struct proc *p, struct linux_getpeername_args *args) +linux_getpeername(struct thread *td, struct linux_getpeername_args *args) { struct linux_getpeername_args linux_args; struct ogetpeername_args /* { @@ -550,7 +550,7 @@ linux_getpeername(struct proc *p, struct linux_getpeername_args *args) bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - return (ogetpeername(p, &bsd_args)); + return (ogetpeername(td, &bsd_args)); } struct linux_socketpair_args { @@ -561,7 +561,7 @@ struct linux_socketpair_args { }; static int -linux_socketpair(struct proc *p, struct linux_socketpair_args *args) +linux_socketpair(struct thread *td, struct linux_socketpair_args *args) { struct linux_socketpair_args linux_args; struct socketpair_args /* { @@ -582,7 +582,7 @@ linux_socketpair(struct proc *p, struct linux_socketpair_args *args) bsd_args.type = linux_args.type; bsd_args.protocol = linux_args.protocol; bsd_args.rsv = linux_args.rsv; - return (socketpair(p, &bsd_args)); + return (socketpair(td, &bsd_args)); } struct linux_send_args { @@ -593,7 +593,7 @@ struct linux_send_args { }; static int -linux_send(struct proc *p, struct linux_send_args *args) +linux_send(struct thread *td, struct linux_send_args *args) { struct linux_send_args linux_args; struct osend_args /* { @@ -611,7 +611,7 @@ linux_send(struct proc *p, struct linux_send_args *args) bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - return (osend(p, &bsd_args)); + return (osend(td, &bsd_args)); } struct linux_recv_args { @@ -622,7 +622,7 @@ struct linux_recv_args { }; static int -linux_recv(struct proc *p, struct linux_recv_args *args) +linux_recv(struct thread *td, struct linux_recv_args *args) { struct linux_recv_args linux_args; struct orecv_args /* { @@ -640,7 +640,7 @@ linux_recv(struct proc *p, struct linux_recv_args *args) bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - return (orecv(p, &bsd_args)); + return (orecv(td, &bsd_args)); } struct linux_sendto_args { @@ -653,7 +653,7 @@ struct linux_sendto_args { }; static int -linux_sendto(struct proc *p, struct linux_sendto_args *args) +linux_sendto(struct thread *td, struct linux_sendto_args *args) { struct linux_sendto_args linux_args; struct sendto_args /* { @@ -676,11 +676,11 @@ linux_sendto(struct proc *p, struct linux_sendto_args *args) bsd_args.to = linux_args.to; bsd_args.tolen = linux_args.tolen; - if (linux_check_hdrincl(p, linux_args.s) == 0) + if (linux_check_hdrincl(td, linux_args.s) == 0) /* IP_HDRINCL set, tweak the packet before sending */ - return (linux_sendto_hdrincl(p, &bsd_args)); + return (linux_sendto_hdrincl(td, &bsd_args)); - return (sendto(p, &bsd_args)); + return (sendto(td, &bsd_args)); } struct linux_recvfrom_args { @@ -693,7 +693,7 @@ struct linux_recvfrom_args { }; static int -linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args) +linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) { struct linux_recvfrom_args linux_args; struct recvfrom_args /* { @@ -715,7 +715,7 @@ linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args) bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); bsd_args.from = linux_args.from; bsd_args.fromlenaddr = linux_args.fromlen; - return (orecvfrom(p, &bsd_args)); + return (orecvfrom(td, &bsd_args)); } struct linux_recvmsg_args { @@ -725,7 +725,7 @@ struct linux_recvmsg_args { }; static int -linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args) +linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args) { struct linux_recvmsg_args linux_args; struct recvmsg_args /* { @@ -741,7 +741,7 @@ linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args) bsd_args.s = linux_args.s; bsd_args.msg = linux_args.msg; bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); - return (recvmsg(p, &bsd_args)); + return (recvmsg(td, &bsd_args)); } struct linux_shutdown_args { @@ -750,7 +750,7 @@ struct linux_shutdown_args { }; static int -linux_shutdown(struct proc *p, struct linux_shutdown_args *args) +linux_shutdown(struct thread *td, struct linux_shutdown_args *args) { struct linux_shutdown_args linux_args; struct shutdown_args /* { @@ -764,7 +764,7 @@ linux_shutdown(struct proc *p, struct linux_shutdown_args *args) bsd_args.s = linux_args.s; bsd_args.how = linux_args.how; - return (shutdown(p, &bsd_args)); + return (shutdown(td, &bsd_args)); } struct linux_setsockopt_args { @@ -776,7 +776,7 @@ struct linux_setsockopt_args { }; static int -linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args) +linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args) { struct linux_setsockopt_args linux_args; struct setsockopt_args /* { @@ -814,7 +814,7 @@ linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args) bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.valsize = linux_args.optlen; - return (setsockopt(p, &bsd_args)); + return (setsockopt(td, &bsd_args)); } struct linux_getsockopt_args { @@ -826,7 +826,7 @@ struct linux_getsockopt_args { }; static int -linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args) +linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) { struct linux_getsockopt_args linux_args; struct getsockopt_args /* { @@ -864,45 +864,45 @@ linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args) bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.avalsize = linux_args.optlen; - return (getsockopt(p, &bsd_args)); + return (getsockopt(td, &bsd_args)); } int -linux_socketcall(struct proc *p, struct linux_socketcall_args *args) +linux_socketcall(struct thread *td, struct linux_socketcall_args *args) { void *arg = (void *)args->args; switch (args->what) { case LINUX_SOCKET: - return (linux_socket(p, arg)); + return (linux_socket(td, arg)); case LINUX_BIND: - return (linux_bind(p, arg)); + return (linux_bind(td, arg)); case LINUX_CONNECT: - return (linux_connect(p, arg)); + return (linux_connect(td, arg)); case LINUX_LISTEN: - return (linux_listen(p, arg)); + return (linux_listen(td, arg)); case LINUX_ACCEPT: - return (linux_accept(p, arg)); + return (linux_accept(td, arg)); case LINUX_GETSOCKNAME: - return (linux_getsockname(p, arg)); + return (linux_getsockname(td, arg)); case LINUX_GETPEERNAME: - return (linux_getpeername(p, arg)); + return (linux_getpeername(td, arg)); case LINUX_SOCKETPAIR: - return (linux_socketpair(p, arg)); + return (linux_socketpair(td, arg)); case LINUX_SEND: - return (linux_send(p, arg)); + return (linux_send(td, arg)); case LINUX_RECV: - return (linux_recv(p, arg)); + return (linux_recv(td, arg)); case LINUX_SENDTO: - return (linux_sendto(p, arg)); + return (linux_sendto(td, arg)); case LINUX_RECVFROM: - return (linux_recvfrom(p, arg)); + return (linux_recvfrom(td, arg)); case LINUX_SHUTDOWN: - return (linux_shutdown(p, arg)); + return (linux_shutdown(td, arg)); case LINUX_SETSOCKOPT: - return (linux_setsockopt(p, arg)); + return (linux_setsockopt(td, arg)); case LINUX_GETSOCKOPT: - return (linux_getsockopt(p, arg)); + return (linux_getsockopt(td, arg)); case LINUX_SENDMSG: do { int error; @@ -940,10 +940,10 @@ linux_socketcall(struct proc *p, struct linux_socketcall_args *args) return (error); } done: - return (sendmsg(p, arg)); + return (sendmsg(td, arg)); } while (0); case LINUX_RECVMSG: - return (linux_recvmsg(p, arg)); + return (linux_recvmsg(td, arg)); } uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what); diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 5d1572b..d0c8ea2 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -87,7 +87,7 @@ newstat_copyout(struct stat *buf, void *ubuf) } int -linux_newstat(struct proc *p, struct linux_newstat_args *args) +linux_newstat(struct thread *td, struct linux_newstat_args *args) { struct stat buf; struct nameidata nd; @@ -95,7 +95,7 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(newstat)) @@ -103,13 +103,13 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args) #endif NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->path, p); + args->path, td); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &buf, p); + error = vn_stat(nd.ni_vp, &buf, td); vput(nd.ni_vp); if (error) return (error); @@ -118,7 +118,7 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args) } int -linux_newlstat(struct proc *p, struct linux_newlstat_args *args) +linux_newlstat(struct thread *td, struct linux_newlstat_args *args) { int error; struct stat sb; @@ -126,7 +126,7 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(newlstat)) @@ -134,13 +134,13 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args) #endif NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->path, p); + args->path, td); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -149,7 +149,7 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args) } int -linux_newfstat(struct proc *p, struct linux_newfstat_args *args) +linux_newfstat(struct thread *td, struct linux_newfstat_args *args) { struct filedesc *fdp; struct file *fp; @@ -161,12 +161,12 @@ linux_newfstat(struct proc *p, struct linux_newfstat_args *args) printf(ARGS(newfstat, "%d, *"), args->fd); #endif - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)args->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[args->fd]) == NULL) return (EBADF); - error = fo_stat(fp, &buf, p); + error = fo_stat(fp, &buf, td); if (!error) error = newstat_copyout(&buf, args->buf); @@ -235,7 +235,7 @@ bsd_to_linux_ftype(int tag) } int -linux_statfs(struct proc *p, struct linux_statfs_args *args) +linux_statfs(struct thread *td, struct linux_statfs_args *args) { struct mount *mp; struct nameidata *ndp; @@ -246,14 +246,14 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(statfs)) printf(ARGS(statfs, "%s, *"), args->path); #endif ndp = &nd; - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curthread); error = namei(ndp); if (error) return error; @@ -261,7 +261,7 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args) mp = ndp->ni_vp->v_mount; bsd_statfs = &mp->mnt_stat; vrele(ndp->ni_vp); - error = VFS_STATFS(mp, bsd_statfs, p); + error = VFS_STATFS(mp, bsd_statfs, td); if (error) return error; bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; @@ -280,7 +280,7 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args) } int -linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args) +linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args) { struct file *fp; struct mount *mp; @@ -292,12 +292,12 @@ linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args) if (ldebug(fstatfs)) printf(ARGS(fstatfs, "%d, *"), args->fd); #endif - error = getvnode(p->p_fd, args->fd, &fp); + error = getvnode(td->td_proc->p_fd, args->fd, &fp); if (error) return error; mp = ((struct vnode *)fp->f_data)->v_mount; bsd_statfs = &mp->mnt_stat; - error = VFS_STATFS(mp, bsd_statfs, p); + error = VFS_STATFS(mp, bsd_statfs, td); if (error) return error; bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; @@ -324,7 +324,7 @@ struct l_ustat }; int -linux_ustat(struct proc *p, struct linux_ustat_args *args) +linux_ustat(struct thread *td, struct linux_ustat_args *args) { struct l_ustat lu; dev_t dev; @@ -355,7 +355,7 @@ linux_ustat(struct proc *p, struct linux_ustat_args *args) if (vp->v_mount == NULL) return (EINVAL); stat = &(vp->v_mount->mnt_stat); - error = VFS_STATFS(vp->v_mount, stat, p); + error = VFS_STATFS(vp->v_mount, stat, td); if (error) return (error); @@ -400,7 +400,7 @@ stat64_copyout(struct stat *buf, void *ubuf) } int -linux_stat64(struct proc *p, struct linux_stat64_args *args) +linux_stat64(struct thread *td, struct linux_stat64_args *args) { struct stat buf; struct nameidata nd; @@ -408,7 +408,7 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->filename); + CHECKALTEXIST(td, &sg, args->filename); #ifdef DEBUG if (ldebug(stat64)) @@ -416,13 +416,13 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args) #endif NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->filename, p); + args->filename, td); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &buf, p); + error = vn_stat(nd.ni_vp, &buf, td); vput(nd.ni_vp); if (error) return (error); @@ -431,7 +431,7 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args) } int -linux_lstat64(struct proc *p, struct linux_lstat64_args *args) +linux_lstat64(struct thread *td, struct linux_lstat64_args *args) { int error; struct stat sb; @@ -439,7 +439,7 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args) caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->filename); + CHECKALTEXIST(td, &sg, args->filename); #ifdef DEBUG if (ldebug(lstat64)) @@ -447,13 +447,13 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args) #endif NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->filename, p); + args->filename, td); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -462,7 +462,7 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args) } int -linux_fstat64(struct proc *p, struct linux_fstat64_args *args) +linux_fstat64(struct thread *td, struct linux_fstat64_args *args) { struct filedesc *fdp; struct file *fp; @@ -474,12 +474,12 @@ linux_fstat64(struct proc *p, struct linux_fstat64_args *args) printf(ARGS(fstat64, "%d, *"), args->fd); #endif - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)args->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[args->fd]) == NULL) return (EBADF); - error = fo_stat(fp, &buf, p); + error = fo_stat(fp, &buf, td); if (!error) error = stat64_copyout(&buf, args->statbuf); diff --git a/sys/compat/linux/linux_sysctl.c b/sys/compat/linux/linux_sysctl.c index 14c5a6f..98dab20 100644 --- a/sys/compat/linux/linux_sysctl.c +++ b/sys/compat/linux/linux_sysctl.c @@ -75,7 +75,7 @@ handle_string(struct l___sysctl_args *la, char *value) } int -linux_sysctl(struct proc *p, struct linux_sysctl_args *args) +linux_sysctl(struct thread *td, struct linux_sysctl_args *args) { struct l___sysctl_args la; l_int *mib; diff --git a/sys/compat/linux/linux_uid16.c b/sys/compat/linux/linux_uid16.c index c6a1c12..80e5763 100644 --- a/sys/compat/linux/linux_uid16.c +++ b/sys/compat/linux/linux_uid16.c @@ -43,13 +43,13 @@ DUMMY(getresuid16); DUMMY(getresgid16); int -linux_chown16(struct proc *p, struct linux_chown16_args *args) +linux_chown16(struct thread *td, struct linux_chown16_args *args) { struct chown_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(chown16)) @@ -60,17 +60,17 @@ linux_chown16(struct proc *p, struct linux_chown16_args *args) bsd.path = args->path; bsd.uid = args->uid; bsd.gid = args->gid; - return (chown(p, &bsd)); + return (chown(td, &bsd)); } int -linux_lchown16(struct proc *p, struct linux_lchown16_args *args) +linux_lchown16(struct thread *td, struct linux_lchown16_args *args) { struct lchown_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(lchown16)) @@ -81,11 +81,11 @@ linux_lchown16(struct proc *p, struct linux_lchown16_args *args) bsd.path = args->path; bsd.uid = args->uid; bsd.gid = args->gid; - return (lchown(p, &bsd)); + return (lchown(td, &bsd)); } int -linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args) +linux_setgroups16(struct thread *td, struct linux_setgroups16_args *args) { struct ucred *newcred, *oldcred; l_gid16_t linux_gidset[NGROUPS]; @@ -98,7 +98,7 @@ linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args) #endif ngrp = args->gidsetsize; - oldcred = p->p_ucred; + oldcred = td->td_proc->p_ucred; /* * cr_groups[0] holds egid. Setting the whole set from @@ -131,14 +131,14 @@ linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args) else newcred->cr_ngroups = 1; - setsugid(p); - p->p_ucred = newcred; + setsugid(td->td_proc); + td->td_proc->p_ucred = newcred; crfree(oldcred); return (0); } int -linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args) +linux_getgroups16(struct thread *td, struct linux_getgroups16_args *args) { struct ucred *cred; l_gid16_t linux_gidset[NGROUPS]; @@ -150,7 +150,7 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args) printf(ARGS(getgroups16, "%d, *"), args->gidsetsize); #endif - cred = p->p_ucred; + cred = td->td_proc->p_ucred; bsd_gidset = cred->cr_groups; bsd_gidsetsz = cred->cr_ngroups - 1; @@ -161,7 +161,7 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args) */ if ((ngrp = args->gidsetsize) == 0) { - p->p_retval[0] = bsd_gidsetsz; + td->td_retval[0] = bsd_gidsetsz; return (0); } @@ -179,12 +179,12 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args) if (error) return (error); - p->p_retval[0] = ngrp; + td->td_retval[0] = ngrp; return (0); } /* - * The FreeBSD native getgid(2) and getuid(2) also modify p->p_retval[1] + * The FreeBSD native getgid(2) and getuid(2) also modify td->td_retval[1] * when COMPAT_43 or COMPAT_SUNOS is defined. This globbers registers that * are assumed to be preserved. The following lightweight syscalls fixes * this. See also linux_getpid(2), linux_getgid(2) and linux_getuid(2) in @@ -195,91 +195,93 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args) */ int -linux_getgid16(struct proc *p, struct linux_getgid16_args *args) +linux_getgid16(struct thread *td, struct linux_getgid16_args *args) { - p->p_retval[0] = p->p_ucred->cr_rgid; + + td->td_retval[0] = td->td_proc->p_ucred->cr_rgid; return (0); } int -linux_getuid16(struct proc *p, struct linux_getuid16_args *args) +linux_getuid16(struct thread *td, struct linux_getuid16_args *args) { - p->p_retval[0] = p->p_ucred->cr_ruid; + + td->td_retval[0] = td->td_proc->p_ucred->cr_ruid; return (0); } int -linux_getegid16(struct proc *p, struct linux_getegid16_args *args) +linux_getegid16(struct thread *td, struct linux_getegid16_args *args) { struct getegid_args bsd; - return (getegid(p, &bsd)); + return (getegid(td, &bsd)); } int -linux_geteuid16(struct proc *p, struct linux_geteuid16_args *args) +linux_geteuid16(struct thread *td, struct linux_geteuid16_args *args) { struct geteuid_args bsd; - return (geteuid(p, &bsd)); + return (geteuid(td, &bsd)); } int -linux_setgid16(struct proc *p, struct linux_setgid16_args *args) +linux_setgid16(struct thread *td, struct linux_setgid16_args *args) { struct setgid_args bsd; bsd.gid = args->gid; - return (setgid(p, &bsd)); + return (setgid(td, &bsd)); } int -linux_setuid16(struct proc *p, struct linux_setuid16_args *args) +linux_setuid16(struct thread *td, struct linux_setuid16_args *args) { struct setuid_args bsd; bsd.uid = args->uid; - return (setuid(p, &bsd)); + return (setuid(td, &bsd)); } int -linux_setregid16(struct proc *p, struct linux_setregid16_args *args) +linux_setregid16(struct thread *td, struct linux_setregid16_args *args) { struct setregid_args bsd; bsd.rgid = args->rgid; bsd.egid = args->egid; - return (setregid(p, &bsd)); + return (setregid(td, &bsd)); } int -linux_setreuid16(struct proc *p, struct linux_setreuid16_args *args) +linux_setreuid16(struct thread *td, struct linux_setreuid16_args *args) { struct setreuid_args bsd; bsd.ruid = args->ruid; bsd.euid = args->euid; - return (setreuid(p, &bsd)); + return (setreuid(td, &bsd)); } int -linux_setresgid16(struct proc *p, struct linux_setresgid16_args *args) +linux_setresgid16(struct thread *td, struct linux_setresgid16_args *args) { struct setresgid_args bsd; bsd.rgid = args->rgid; bsd.egid = args->egid; bsd.sgid = args->sgid; - return (setresgid(p, &bsd)); + return (setresgid(td, &bsd)); } int -linux_setresuid16(struct proc *p, struct linux_setresuid16_args *args) +linux_setresuid16(struct thread *td, struct linux_setresuid16_args *args) { struct setresuid_args bsd; bsd.ruid = args->ruid; bsd.euid = args->euid; bsd.suid = args->suid; - return (setresuid(p, &bsd)); + return (setresuid(td, &bsd)); } diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index 6e14080..45c85b6 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -50,8 +50,8 @@ const char linux_emul_path[] = "/compat/linux"; * be in exists. */ int -linux_emul_find(p, sgp, prefix, path, pbuf, cflag) - struct proc *p; +linux_emul_find(td, sgp, prefix, path, pbuf, cflag) + struct thread *td; caddr_t *sgp; /* Pointer to stackgap memory */ const char *prefix; char *path; @@ -104,7 +104,7 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) for (cp = &ptr[len] - 1; *cp != '/'; cp--); *cp = '\0'; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -114,7 +114,7 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) *cp = '/'; } else { - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -130,7 +130,7 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) * to the emulation root directory. This is expensive :-( */ NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, - p); + td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -140,11 +140,11 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) return error; } - if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { + if ((error = VOP_GETATTR(nd.ni_vp, &vat, td->td_proc->p_ucred, td)) != 0) { goto bad; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, td->td_proc->p_ucred, td)) != 0) { goto bad; } diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index 81bacc2..b79b5b6 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -52,7 +52,7 @@ static __inline caddr_t stackgap_init(void); static __inline void *stackgap_alloc(caddr_t *, size_t); -#define szsigcode (*(curproc->p_sysent->sv_szsigcode)) +#define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode)) static __inline caddr_t stackgap_init() @@ -76,7 +76,7 @@ stackgap_alloc(sgp, sz) extern const char linux_emul_path[]; -int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *, +int linux_emul_find __P((struct thread *, caddr_t *, const char *, char *, char **, int)); #define CHECKALT(p, sgp, path, i) \ @@ -94,18 +94,18 @@ int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *, #define DUMMY(s) \ int \ -linux_ ## s(struct proc *p, struct linux_ ## s ## _args *args) \ +linux_ ## s(struct thread *p, struct linux_ ## s ## _args *args) \ { \ return (unsupported_msg(p, #s)); \ } \ struct __hack static __inline int -unsupported_msg(struct proc *p, const char *fname) +unsupported_msg(struct thread *td, const char *fname) { printf("linux: syscall %s is obsoleted or not implemented (pid=%ld)\n", - fname, (long)p->p_pid); + fname, (long)td->td_proc->p_pid); return (ENOSYS); } diff --git a/sys/compat/pecoff/imgact_pecoff.c b/sys/compat/pecoff/imgact_pecoff.c index 9d08513..3d6db4f 100644 --- a/sys/compat/pecoff/imgact_pecoff.c +++ b/sys/compat/pecoff/imgact_pecoff.c @@ -84,7 +84,7 @@ #define PECOFF_PE_SIGNATURE "PE\0\0" static int pecoff_fixup(register_t **, struct image_params *); static int -pecoff_coredump(register struct proc *, register struct vnode *, +pecoff_coredump(register struct thread *, register struct vnode *, off_t); #ifndef PECOFF_DEBUG #define DPRINTF(a) @@ -131,10 +131,10 @@ static int exec_pecoff_coff_makecmds(struct image_params *, struct coff_filehdr *, int); -static int pecoff_signature(struct proc *, struct vnode *, const struct pecoff_dos_filehdr *); -static int pecoff_read_from(struct proc *, struct vnode *, int, caddr_t, int); +static int pecoff_signature(struct thread *, struct vnode *, const struct pecoff_dos_filehdr *); +static int pecoff_read_from(struct thread *, struct vnode *, int, caddr_t, int); static int -pecoff_load_section(struct proc * p, +pecoff_load_section(struct thread * td, struct vmspace * vmspace, struct vnode * vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot); @@ -160,11 +160,11 @@ pecoff_fixup(register_t ** stack_base, struct image_params * imgp) static int -pecoff_coredump(register struct proc * p, register struct vnode * vp, +pecoff_coredump(register struct thread * td, register struct vnode * vp, off_t limit) { - register struct ucred *cred = p->p_ucred; - register struct vmspace *vm = p->p_vmspace; + register struct ucred *cred = td->td_proc->p_ucred; + register struct vmspace *vm = td->td_proc->p_vmspace; int error; #ifdef PECOFF_DEBUG struct vm_map *map; @@ -172,12 +172,12 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp, struct reg regs; #endif - if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= limit) + if (ctob((UAREA_PAGES+KSTACK_PAGES) + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); - fill_kinfo_proc(p, &p->p_addr->u_kproc); + fill_kinfo_proc(td->td_proc, &td->td_proc->p_uarea->u_kproc); #if PECOFF_DEBUG - fill_regs(p, ®s); + fill_regs(td, ®s); printf("EIP%x\n", regs.r_eip); printf("EAX%x EBX%x ECX%x EDI%x\n", regs.r_eax, regs.r_ebx, regs.r_ecx, regs.r_edi); @@ -185,23 +185,25 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp, ent = &map->header; printf("%p %p %p\n", ent, ent->prev, ent->next); #endif - error = cpu_coredump(p, vp, cred); + error = cpu_coredump(td, vp, cred); if (error == 0) error = vn_rdwr_inchunks(UIO_WRITE, vp, vm->vm_daddr, - (int) ctob(vm->vm_dsize), (off_t) ctob(UPAGES), UIO_USERSPACE, - IO_UNIT, cred, (int *) NULL, p); + (int)ctob(vm->vm_dsize), + (off_t)ctob((UAREA_PAGES+KSTACK_PAGES)), + UIO_USERSPACE, IO_UNIT, cred, (int *)NULL, td); if (error == 0) error = vn_rdwr_inchunks(UIO_WRITE, vp, - (caddr_t) trunc_page(USRSTACK - ctob(vm->vm_ssize)), - round_page(ctob(vm->vm_ssize)), - (off_t) ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE, - IO_UNIT, cred, (int *) NULL, p); + (caddr_t)trunc_page(USRSTACK - ctob(vm->vm_ssize)), + round_page(ctob(vm->vm_ssize)), + (off_t)ctob((UAREA_PAGES+KSTACK_PAGES)) + + ctob(vm->vm_dsize), + UIO_USERSPACE, IO_UNIT, cred, (int *)NULL, td); return (error); } static int -pecoff_load_section(struct proc * p, struct vmspace * vmspace, struct vnode * vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot) +pecoff_load_section(struct thread * td, struct vmspace * vmspace, struct vnode * vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot) { size_t map_len; vm_offset_t map_addr; @@ -318,7 +320,7 @@ pecoff_load_section(struct proc * p, struct vmspace * vmspace, struct vnode * vp } static int -pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entry, u_long * ldexport) +pecoff_load_file(struct thread * td, const char *file, u_long * addr, u_long * entry, u_long * ldexport) { struct nameidata nd; @@ -327,7 +329,7 @@ pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entr struct coff_aouthdr *ap; struct pecoff_opthdr *wp; struct coff_scnhdr *sh = 0; - struct vmspace *vmspace = p->p_vmspace; + struct vmspace *vmspace = td->td_proc->p_vmspace; struct vattr attr; struct image_params image_params, *imgp; int peofs; @@ -337,12 +339,12 @@ pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entr /* * Initialize part of the common data */ - imgp->proc = p; + imgp->proc = td->td_proc; imgp->uap = NULL; imgp->attr = &attr; imgp->firstpage = NULL; - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, file, p); + NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, file, td); if ((error = namei(&nd)) != 0) { nd.ni_vp = NULL; @@ -356,19 +358,19 @@ pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entr */ error = exec_check_permissions(imgp); if (error) { - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); goto fail; } - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); if (error) goto fail; - if ((error = pecoff_read_from(p, imgp->vp, 0, (caddr_t) & dh, sizeof(dh))) != 0) + if ((error = pecoff_read_from(td, imgp->vp, 0, (caddr_t) & dh, sizeof(dh))) != 0) goto fail; - if ((error = pecoff_signature(p, imgp->vp, &dh) != 0)) + if ((error = pecoff_signature(td, imgp->vp, &dh) != 0)) goto fail; fp = malloc(PECOFF_HDR_SIZE, M_TEMP, M_WAITOK); peofs = dh.d_peofs + sizeof(signature) - 1; - if ((error = pecoff_read_from(p, imgp->vp, peofs, (caddr_t) fp, PECOFF_HDR_SIZE) != 0)) + if ((error = pecoff_read_from(td, imgp->vp, peofs, (caddr_t) fp, PECOFF_HDR_SIZE) != 0)) goto fail; if (COFF_BADMAG(fp)) { error = ENOEXEC; @@ -379,7 +381,7 @@ pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entr /* read section header */ scnsiz = sizeof(struct coff_scnhdr) * fp->f_nscns; sh = malloc(scnsiz, M_TEMP, M_WAITOK); - if ((error = pecoff_read_from(p, imgp->vp, peofs + PECOFF_HDR_SIZE, + if ((error = pecoff_read_from(td, imgp->vp, peofs + PECOFF_HDR_SIZE, (caddr_t) sh, scnsiz)) != 0) goto fail; @@ -404,7 +406,7 @@ pecoff_load_file(struct proc * p, const char *file, u_long * addr, u_long * entr prot |= (sh[i].s_flags & COFF_STYP_EXEC) ? VM_PROT_EXECUTE : 0; sh[i].s_vaddr += wp->w_base; /* RVA --> VA */ - if ((error = pecoff_load_section(p, vmspace, imgp->vp, sh[i].s_scnptr + if ((error = pecoff_load_section(td, vmspace, imgp->vp, sh[i].s_scnptr ,(caddr_t) sh[i].s_vaddr, sh[i].s_paddr, sh[i].s_size ,prot)) != 0) @@ -457,7 +459,7 @@ exec_pecoff_coff_prep_zmagic(struct image_params * imgp, sh = malloc(scnsiz, M_TEMP, M_WAITOK); wp = (void *) ((char *) ap + sizeof(struct coff_aouthdr)); - error = pecoff_read_from(imgp->proc, imgp->vp, peofs + PECOFF_HDR_SIZE, + error = pecoff_read_from(&imgp->proc->p_thread, imgp->vp, peofs + PECOFF_HDR_SIZE, (caddr_t) sh, scnsiz); if ((error = exec_extract_strings(imgp)) != 0) goto fail; @@ -473,7 +475,7 @@ exec_pecoff_coff_prep_zmagic(struct image_params * imgp, continue; if ((sh[i].s_flags & COFF_STYP_TEXT) != 0) { - error = pecoff_load_section(imgp->proc, vmspace, + error = pecoff_load_section(&imgp->proc->p_thread, vmspace, imgp->vp, sh[i].s_scnptr ,(caddr_t) sh[i].s_vaddr, sh[i].s_paddr, sh[i].s_size ,prot); @@ -485,7 +487,7 @@ exec_pecoff_coff_prep_zmagic(struct image_params * imgp, } if ((sh[i].s_flags & (COFF_STYP_DATA|COFF_STYP_BSS)) != 0) { - if (pecoff_load_section(imgp->proc, + if (pecoff_load_section(&imgp->proc->p_thread, vmspace, imgp->vp, sh[i].s_scnptr ,(caddr_t) sh[i].s_vaddr, sh[i].s_paddr, sh[i].s_size, prot) != 0) @@ -510,7 +512,7 @@ exec_pecoff_coff_prep_zmagic(struct image_params * imgp, argp->a_entry = wp->w_base + ap->a_entry; argp->a_end = data_addr + data_size; argp->a_subsystem = wp->w_subvers; - error = pecoff_load_file(imgp->proc, "/usr/libexec/ld.so.dll", &ldbase, &imgp->entry_addr, &ldexport); + error = pecoff_load_file(&imgp->proc->p_thread, "/usr/libexec/ld.so.dll", &ldbase, &imgp->entry_addr, &ldexport); if (error) goto fail; @@ -570,8 +572,8 @@ exec_pecoff_coff_makecmds(struct image_params * imgp, } static int -pecoff_signature(p, vp, dp) - struct proc *p; +pecoff_signature(td, vp, dp) + struct thread *td; struct vnode *vp; const struct pecoff_dos_filehdr *dp; { @@ -581,7 +583,7 @@ pecoff_signature(p, vp, dp) if (DOS_BADMAG(dp)) { return ENOEXEC; } - error = pecoff_read_from(p, vp, dp->d_peofs, buf, sizeof(buf)); + error = pecoff_read_from(td, vp, dp->d_peofs, buf, sizeof(buf)); if (error) { return error; } @@ -592,8 +594,8 @@ pecoff_signature(p, vp, dp) return EFTYPE; } int -pecoff_read_from(p, vp, pos, buf, siz) - struct proc *p; +pecoff_read_from(td, vp, pos, buf, siz) + struct thread *td; struct vnode *vp; int pos; caddr_t buf; @@ -603,8 +605,8 @@ pecoff_read_from(p, vp, pos, buf, siz) size_t resid; error = vn_rdwr(UIO_READ, vp, buf, siz, pos, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, - &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, td->td_proc->p_ucred, + &resid, td); if (error) return error; @@ -621,13 +623,13 @@ imgact_pecoff(struct image_params * imgp) imgp->image_header; struct coff_filehdr *fp; int error, peofs; - error = pecoff_signature(imgp->proc, imgp->vp, dp); + error = pecoff_signature(&imgp->proc->p_thread, imgp->vp, dp); if (error) { return -1; } peofs = dp->d_peofs + sizeof(signature) - 1; fp = malloc(PECOFF_HDR_SIZE, M_TEMP, M_WAITOK); - error = pecoff_read_from(imgp->proc, imgp->vp, peofs, (caddr_t) fp, + error = pecoff_read_from(&imgp->proc->p_thread, imgp->vp, peofs, (caddr_t) fp, PECOFF_HDR_SIZE); if (error) { free(fp, M_TEMP); diff --git a/sys/compat/svr4/Makefile b/sys/compat/svr4/Makefile index 00f8264..6de19bc 100644 --- a/sys/compat/svr4/Makefile +++ b/sys/compat/svr4/Makefile @@ -5,14 +5,15 @@ MAINTAINER= newton@freebsd.org all: - @echo "make sysent only" + @echo "make syscallnames only" -syscallnames: svr4_sysent.c svr4_syscall.h svr4_proto.h +sysent: svr4_sysent.c svr4_syscall.h svr4_proto.h svr4_syscallnames.c svr4_sysent.c svr4_syscall.h svr4_proto.h: \ - ../kern/makesyscalls.sh syscalls.master syscalls.conf + ../../kern/makesyscalls.sh syscalls.master syscalls.conf -mv -f svr4_syscallnames.c svr4_syscallnames.c.bak -mv -f svr4_sysent.c svr4_sysent.c.bak -mv -f svr4_syscall.h svr4_syscall.h.bak -mv -f svr4_proto.h svr4_proto.h.bak - sh ../kern/makesyscalls.sh syscalls.master syscalls.conf + sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + diff --git a/sys/compat/svr4/svr4_exec.h b/sys/compat/svr4/svr4_exec.h index 716dad1..f15211b 100644 --- a/sys/compat/svr4/svr4_exec.h +++ b/sys/compat/svr4/svr4_exec.h @@ -65,6 +65,6 @@ #endif #endif -/*void svr4_setregs __P((struct proc *, struct exec_package *, u_long));*/ +/*void svr4_setregs __P((struct thread *, struct exec_package *, u_long));*/ #endif /* !_SVR4_EXEC_H_ */ diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index afa62b7..465bae5 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -55,8 +55,8 @@ static int svr4_to_bsd_flags __P((int)); static u_long svr4_to_bsd_cmd __P((u_long)); -static int fd_revoke __P((struct proc *, int)); -static int fd_truncate __P((struct proc *, int, struct flock *)); +static int fd_revoke __P((struct thread *, int)); +static int fd_truncate __P((struct thread *, int, struct flock *)); static int bsd_to_svr4_flags __P((int)); static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *)); static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *)); @@ -242,18 +242,18 @@ svr4_to_bsd_flock64(iflp, oflp) static int -fd_revoke(p, fd) - struct proc *p; +fd_revoke(td, fd) + struct thread *td; int fd; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp; struct vnode *vp; struct mount *mp; struct vattr vattr; int error, *retval; - retval = p->p_retval; + retval = td->td_retval; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) return EBADF; @@ -267,11 +267,11 @@ fd_revoke(p, fd) goto out; } - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) goto out; - if (p->p_ucred->cr_uid != vattr.va_uid && - (error = suser(p)) != 0) + if (td->td_proc->p_ucred->cr_uid != vattr.va_uid && + (error = suser_td(td)) != 0) goto out; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) @@ -286,12 +286,12 @@ out: static int -fd_truncate(p, fd, flp) - struct proc *p; +fd_truncate(td, fd, flp) + struct thread *td; int fd; struct flock *flp; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp; off_t start, length; struct vnode *vp; @@ -299,7 +299,7 @@ fd_truncate(p, fd, flp) int error, *retval; struct ftruncate_args ft; - retval = p->p_retval; + retval = td->td_retval; /* * We only support truncating the file. @@ -311,7 +311,7 @@ fd_truncate(p, fd, flp) if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) return ESPIPE; - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) return error; length = vattr.va_size; @@ -341,24 +341,25 @@ fd_truncate(p, fd, flp) SCARG(&ft, fd) = fd; SCARG(&ft, length) = start; - return ftruncate(p, &ft); + return ftruncate(td, &ft); } int -svr4_sys_open(p, uap) - register struct proc *p; +svr4_sys_open(td, uap) + register struct thread *td; struct svr4_sys_open_args *uap; { + struct proc *p = td->td_proc; int error, retval; struct open_args cup; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); (&cup)->path = uap->path; (&cup)->flags = svr4_to_bsd_flags(uap->flags); (&cup)->mode = uap->mode; - error = open(p, &cup); + error = open(td, &cup); if (error) { /* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path, @@ -366,19 +367,19 @@ svr4_sys_open(p, uap) return error; } - retval = p->p_retval[0]; + retval = td->td_retval[0]; PROC_LOCK(p); if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) && - !(p->p_flag & P_CONTROLT)) { + !(td->td_proc->p_flag & P_CONTROLT)) { #if defined(NOTYET) - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp = fdp->fd_ofiles[retval]; PROC_UNLOCK(p); /* ignore any error, just give it a try */ if (fp->f_type == DTYPE_VNODE) - fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); + fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); } else PROC_UNLOCK(p); #else @@ -389,41 +390,41 @@ svr4_sys_open(p, uap) } int -svr4_sys_open64(p, uap) - register struct proc *p; +svr4_sys_open64(td, uap) + register struct thread *td; struct svr4_sys_open64_args *uap; { - return svr4_sys_open(p, (struct svr4_sys_open_args *)uap); + return svr4_sys_open(td, (struct svr4_sys_open_args *)uap); } int -svr4_sys_creat(p, uap) - register struct proc *p; +svr4_sys_creat(td, uap) + register struct thread *td; struct svr4_sys_creat_args *uap; { struct open_args cup; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, mode) = SCARG(uap, mode); SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return open(p, &cup); + return open(td, &cup); } int -svr4_sys_creat64(p, uap) - register struct proc *p; +svr4_sys_creat64(td, uap) + register struct thread *td; struct svr4_sys_creat64_args *uap; { - return svr4_sys_creat(p, (struct svr4_sys_creat_args *)uap); + return svr4_sys_creat(td, (struct svr4_sys_creat_args *)uap); } int -svr4_sys_llseek(p, uap) - register struct proc *p; +svr4_sys_llseek(td, uap) + register struct thread *td; struct svr4_sys_llseek_args *uap; { struct lseek_args ap; @@ -439,32 +440,32 @@ svr4_sys_llseek(p, uap) #endif SCARG(&ap, whence) = SCARG(uap, whence); - return lseek(p, &ap); + return lseek(td, &ap); } int -svr4_sys_access(p, uap) - register struct proc *p; +svr4_sys_access(td, uap) + register struct thread *td; struct svr4_sys_access_args *uap; { struct access_args cup; int *retval; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); - retval = p->p_retval; + retval = td->td_retval; SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, flags) = SCARG(uap, flags); - return access(p, &cup); + return access(td, &cup); } #if defined(NOTYET) int -svr4_sys_pread(p, uap) - register struct proc *p; +svr4_sys_pread(td, uap) + register struct thread *td; struct svr4_sys_pread_args *uap; { struct pread_args pra; @@ -478,14 +479,14 @@ svr4_sys_pread(p, uap) SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, off); - return pread(p, &pra); + return pread(td, &pra); } #endif #if defined(NOTYET) int -svr4_sys_pread64(p, v, retval) - register struct proc *p; +svr4_sys_pread64(td, v, retval) + register struct thread *td; void *v; register_t *retval; { @@ -502,14 +503,14 @@ svr4_sys_pread64(p, v, retval) SCARG(&pra, nbyte) = SCARG(uap, nbyte); SCARG(&pra, offset) = SCARG(uap, off); - return (sys_pread(p, &pra, retval)); + return (sys_pread(td, &pra, retval)); } #endif /* NOTYET */ #if defined(NOTYET) int -svr4_sys_pwrite(p, uap) - register struct proc *p; +svr4_sys_pwrite(td, uap) + register struct thread *td; struct svr4_sys_pwrite_args *uap; { struct pwrite_args pwa; @@ -523,14 +524,14 @@ svr4_sys_pwrite(p, uap) SCARG(&pwa, nbyte) = SCARG(uap, nbyte); SCARG(&pwa, offset) = SCARG(uap, off); - return pwrite(p, &pwa); + return pwrite(td, &pwa); } #endif #if defined(NOTYET) int -svr4_sys_pwrite64(p, v, retval) - register struct proc *p; +svr4_sys_pwrite64(td, v, retval) + register struct thread *td; void *v; register_t *retval; { @@ -546,20 +547,20 @@ svr4_sys_pwrite64(p, v, retval) SCARG(&pwa, nbyte) = SCARG(uap, nbyte); SCARG(&pwa, offset) = SCARG(uap, off); - return (sys_pwrite(p, &pwa, retval)); + return (sys_pwrite(td, &pwa, retval)); } #endif /* NOTYET */ int -svr4_sys_fcntl(p, uap) - register struct proc *p; +svr4_sys_fcntl(td, uap) + register struct thread *td; struct svr4_sys_fcntl_args *uap; { int error; struct fcntl_args fa; int *retval; - retval = p->p_retval; + retval = td->td_retval; SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd)); @@ -569,11 +570,11 @@ svr4_sys_fcntl(p, uap) case F_GETFD: case F_SETFD: SCARG(&fa, arg) = (long) SCARG(uap, arg); - return fcntl(p, &fa); + return fcntl(td, &fa); case F_GETFL: SCARG(&fa, arg) = (long) SCARG(uap, arg); - error = fcntl(p, &fa); + error = fcntl(td, &fa); if (error) return error; *retval = bsd_to_svr4_flags(*retval); @@ -592,14 +593,14 @@ svr4_sys_fcntl(p, uap) cmd = SCARG(&fa, cmd); /* save it for a while */ SCARG(&fa, cmd) = F_GETFL; - if ((error = fcntl(p, &fa)) != 0) + if ((error = fcntl(td, &fa)) != 0) return error; flags = *retval; flags &= O_ASYNC; flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg)); SCARG(&fa, cmd) = cmd; SCARG(&fa, arg) = (long) flags; - return fcntl(p, &fa); + return fcntl(td, &fa); } case F_GETLK: @@ -623,7 +624,7 @@ svr4_sys_fcntl(p, uap) if (error) return error; - error = fcntl(p, &fa); + error = fcntl(td, &fa); if (error || SCARG(&fa, cmd) != F_GETLK) return error; @@ -643,7 +644,7 @@ svr4_sys_fcntl(p, uap) SCARG(&du, from) = SCARG(uap, fd); SCARG(&du, to) = (int)SCARG(uap, arg); - error = dup2(p, &du); + error = dup2(td, &du); if (error) return error; *retval = SCARG(&du, to); @@ -660,7 +661,7 @@ svr4_sys_fcntl(p, uap) if (error) return error; svr4_to_bsd_flock(&ifl, &fl); - return fd_truncate(p, SCARG(uap, fd), &fl); + return fd_truncate(td, SCARG(uap, fd), &fl); } case SVR4_F_GETLK64: @@ -685,7 +686,7 @@ svr4_sys_fcntl(p, uap) if (error) return error; - error = fcntl(p, &fa); + error = fcntl(td, &fa); if (error || SCARG(&fa, cmd) != F_GETLK) return error; @@ -709,11 +710,11 @@ svr4_sys_fcntl(p, uap) if (error) return error; svr4_to_bsd_flock64(&ifl, &fl); - return fd_truncate(p, SCARG(uap, fd), &fl); + return fd_truncate(td, SCARG(uap, fd), &fl); } case SVR4_F_REVOKE: - return fd_revoke(p, SCARG(uap, fd)); + return fd_revoke(td, SCARG(uap, fd)); default: return ENOSYS; diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c index c467dad..8d24788 100644 --- a/sys/compat/svr4/svr4_filio.c +++ b/sys/compat/svr4/svr4_filio.c @@ -51,8 +51,8 @@ /*#define GROTTY_READ_HACK*/ int -svr4_sys_poll(p, uap) - struct proc *p; +svr4_sys_poll(td, uap) + struct thread *td; struct svr4_sys_poll_args *uap; { int error; @@ -68,7 +68,7 @@ svr4_sys_poll(p, uap) siz = SCARG(uap, nfds) * sizeof(struct pollfd); pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK); - error = poll(p, (struct poll_args *)uap); + error = poll(td, (struct poll_args *)uap); if ((cerr = copyin(SCARG(uap, fds), pfd, siz)) != 0) { error = cerr; @@ -92,12 +92,12 @@ done: #if defined(READ_TEST) int -svr4_sys_read(p, uap) - struct proc *p; +svr4_sys_read(td, uap) + struct thread *td; struct svr4_sys_read_args *uap; { struct read_args ra; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp; struct socket *so = NULL; int so_state; @@ -126,15 +126,15 @@ svr4_sys_read(p, uap) #endif } - rv = read(p, &ra); + rv = read(td, &ra); DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n", SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv)); if (rv == EAGAIN) { - DPRINTF(("sigmask = 0x%x\n", p->p_sigmask)); - DPRINTF(("sigignore = 0x%x\n", p->p_sigignore)); - DPRINTF(("sigcaught = 0x%x\n", p->p_sigcatch)); - DPRINTF(("siglist = 0x%x\n", p->p_siglist)); + DPRINTF(("sigmask = 0x%x\n", td->td_proc->p_sigmask)); + DPRINTF(("sigignore = 0x%x\n", td->td_proc->p_sigignore)); + DPRINTF(("sigcaught = 0x%x\n", td->td_proc->p_sigcatch)); + DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist)); } #if defined(GROTTY_READ_HACK) @@ -149,8 +149,8 @@ svr4_sys_read(p, uap) #if defined(BOGUS) int -svr4_sys_write(p, uap) - struct proc *p; +svr4_sys_write(td, uap) + struct thread *td; struct svr4_sys_write_args *uap; { struct write_args wa; @@ -162,7 +162,7 @@ svr4_sys_write(p, uap) SCARG(&wa, buf) = SCARG(uap, buf); SCARG(&wa, nbyte) = SCARG(uap, nbyte); - rv = write(p, &wa); + rv = write(td, &wa); DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n", SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv)); @@ -172,9 +172,9 @@ svr4_sys_write(p, uap) #endif /* BOGUS */ int -svr4_fil_ioctl(fp, p, retval, fd, cmd, data) +svr4_fil_ioctl(fp, td, retval, fd, cmd, data) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -182,7 +182,7 @@ svr4_fil_ioctl(fp, p, retval, fd, cmd, data) { int error; int num; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; *retval = 0; @@ -214,7 +214,7 @@ svr4_fil_ioctl(fp, p, retval, fd, cmd, data) #ifdef SVR4_DEBUG if (cmd == FIOASYNC) DPRINTF(("FIOASYNC\n")); #endif - error = fo_ioctl(fp, cmd, (caddr_t) &num, p); + error = fo_ioctl(fp, cmd, (caddr_t) &num, td); if (error) return error; diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c index d93e2b8..e153713 100644 --- a/sys/compat/svr4/svr4_ioctl.c +++ b/sys/compat/svr4/svr4_ioctl.c @@ -78,15 +78,15 @@ svr4_decode_cmd(cmd, dir, c, num, argsiz) #endif int -svr4_sys_ioctl(p, uap) - register struct proc *p; +svr4_sys_ioctl(td, uap) + register struct thread *td; struct svr4_sys_ioctl_args *uap; { int *retval; struct file *fp; struct filedesc *fdp; u_long cmd; - int (*fun) __P((struct file *, struct proc *, register_t *, + int (*fun) __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); #ifdef DEBUG_SVR4 char dir[4]; @@ -99,8 +99,8 @@ svr4_sys_ioctl(p, uap) DPRINTF(("svr4_ioctl[%lx](%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, com), SCARG(uap, fd), dir, c, num, argsiz, SCARG(uap, data))); #endif - retval = p->p_retval; - fdp = p->p_fd; + retval = td->td_retval; + fdp = td->td_proc->p_fd; cmd = SCARG(uap, com); if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || @@ -157,5 +157,5 @@ svr4_sys_ioctl(p, uap) DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state)); } #endif - return (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data)); + return (*fun)(fp, td, retval, SCARG(uap, fd), cmd, SCARG(uap, data)); } diff --git a/sys/compat/svr4/svr4_ioctl.h b/sys/compat/svr4/svr4_ioctl.h index a5c6a53..2d7e136 100644 --- a/sys/compat/svr4/svr4_ioctl.h +++ b/sys/compat/svr4/svr4_ioctl.h @@ -46,17 +46,17 @@ #define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t)) #define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t)) -int svr4_stream_ti_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_stream_ti_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -int svr4_stream_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_stream_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -int svr4_term_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_term_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -int svr4_ttold_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_ttold_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -int svr4_fil_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_fil_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -int svr4_sock_ioctl __P((struct file *, struct proc *, register_t *, +int svr4_sock_ioctl __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); #endif /* !_SVR4_IOCTL_H_ */ diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 6865880..fd6c472 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -95,14 +95,14 @@ #define BSD_DIRENT(cp) ((struct dirent *)(cp)) -static int svr4_mknod __P((struct proc *, register_t *, char *, +static int svr4_mknod __P((struct thread *, register_t *, char *, svr4_mode_t, svr4_dev_t)); static __inline clock_t timeval_to_clock_t __P((struct timeval *)); static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *)); struct svr4_hrtcntl_args; -static int svr4_hrtcntl __P((struct proc *, struct svr4_hrtcntl_args *, +static int svr4_hrtcntl __P((struct thread *, struct svr4_hrtcntl_args *, register_t *)); static void bsd_statfs_to_svr4_statvfs __P((const struct statfs *, struct svr4_statvfs *)); @@ -113,22 +113,22 @@ static struct proc *svr4_pfind __P((pid_t pid)); /* BOGUS noop */ #if defined(BOGUS) int -svr4_sys_setitimer(p, uap) - register struct proc *p; +svr4_sys_setitimer(td, uap) + register struct thread *td; struct svr4_sys_setitimer_args *uap; { - p->p_retval[0] = 0; + td->td_retval[0] = 0; return 0; } #endif int -svr4_sys_wait(p, uap) - struct proc *p; +svr4_sys_wait(td, uap) + struct thread *td; struct svr4_sys_wait_args *uap; { struct wait_args w4; - int error, *retval = p->p_retval, st, sig; + int error, *retval = td->td_retval, st, sig; size_t sz = sizeof(*SCARG(&w4, status)); SCARG(&w4, rusage) = NULL; @@ -144,7 +144,7 @@ svr4_sys_wait(p, uap) SCARG(&w4, pid) = WAIT_ANY; - if ((error = wait4(p, &w4)) != 0) + if ((error = wait4(td, &w4)) != 0) return error; if ((error = copyin(SCARG(&w4, status), &st, sizeof(st))) != 0) @@ -174,44 +174,44 @@ svr4_sys_wait(p, uap) } int -svr4_sys_execv(p, uap) - struct proc *p; +svr4_sys_execv(td, uap) + struct thread *td; struct svr4_sys_execv_args *uap; { struct execve_args ap; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&ap, fname) = SCARG(uap, path); SCARG(&ap, argv) = SCARG(uap, argp); SCARG(&ap, envv) = NULL; - return execve(p, &ap); + return execve(td, &ap); } int -svr4_sys_execve(p, uap) - struct proc *p; +svr4_sys_execve(td, uap) + struct thread *td; struct svr4_sys_execve_args *uap; { struct execve_args ap; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, uap->path); + CHECKALTEXIST(td, &sg, uap->path); SCARG(&ap, fname) = SCARG(uap, path); SCARG(&ap, argv) = SCARG(uap, argp); SCARG(&ap, envv) = SCARG(uap, envp); - return execve(p, &ap); + return execve(td, &ap); } int -svr4_sys_time(p, v) - struct proc *p; +svr4_sys_time(td, v) + struct thread *td; struct svr4_sys_time_args *v; { struct svr4_sys_time_args *uap = v; @@ -222,7 +222,7 @@ svr4_sys_time(p, v) if (SCARG(uap, t)) error = copyout(&tv.tv_sec, SCARG(uap, t), sizeof(*(SCARG(uap, t)))); - p->p_retval[0] = (int) tv.tv_sec; + td->td_retval[0] = (int) tv.tv_sec; return error; } @@ -237,8 +237,8 @@ svr4_sys_time(p, v) * to adapt the NetBSD version. */ int -svr4_sys_getdents64(p, uap) - struct proc *p; +svr4_sys_getdents64(td, uap) + struct thread *td; struct svr4_sys_getdents64_args *uap; { register struct dirent *bdp; @@ -258,8 +258,8 @@ svr4_sys_getdents64(p, uap) int ncookies; DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", - p->p_pid, SCARG(uap, fd), SCARG(uap, nbytes))); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) { + td->td_proc->p_pid, SCARG(uap, fd), SCARG(uap, nbytes))); + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) { return (error); } @@ -271,7 +271,7 @@ svr4_sys_getdents64(p, uap) if (vp->v_type != VDIR) return (EINVAL); - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) { + if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td))) { return error; } @@ -288,7 +288,7 @@ svr4_sys_getdents64(p, uap) buflen = max(DIRBLKSIZ, nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; @@ -296,7 +296,7 @@ again: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = buflen; auio.uio_offset = off; @@ -398,19 +398,19 @@ again: nbytes = resid + svr4reclen; eof: - p->p_retval[0] = nbytes - resid; + td->td_retval[0] = nbytes - resid; out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return error; } int -svr4_sys_getdents(p, uap) - struct proc *p; +svr4_sys_getdents(td, uap) + struct thread *td; struct svr4_sys_getdents_args *uap; { struct dirent *bdp; @@ -426,9 +426,9 @@ svr4_sys_getdents(p, uap) off_t off; /* true file offset */ int buflen, error, eofflag; u_long *cookiebuf = NULL, *cookie; - int ncookies = 0, *retval = p->p_retval; + int ncookies = 0, *retval = td->td_retval; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) @@ -440,7 +440,7 @@ svr4_sys_getdents(p, uap) buflen = min(MAXBSIZE, SCARG(uap, nbytes)); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); off = fp->f_offset; again: aiov.iov_base = buf; @@ -449,7 +449,7 @@ again: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = buflen; auio.uio_offset = off; /* @@ -514,7 +514,7 @@ again: eof: *retval = SCARG(uap, nbytes) - resid; out: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (cookiebuf) free(cookiebuf, M_TEMP); free(buf, M_TEMP); @@ -523,14 +523,14 @@ out: int -svr4_sys_mmap(p, uap) - struct proc *p; +svr4_sys_mmap(td, uap) + struct thread *td; struct svr4_sys_mmap_args *uap; { struct mmap_args mm; int *retval; - retval = p->p_retval; + retval = td->td_retval; #define _MAP_NEW 0x80000000 /* * Verify the arguments. @@ -548,12 +548,12 @@ svr4_sys_mmap(p, uap) SCARG(&mm, addr) = SCARG(uap, addr); SCARG(&mm, pos) = SCARG(uap, pos); - return mmap(p, &mm); + return mmap(td, &mm); } int -svr4_sys_mmap64(p, uap) - struct proc *p; +svr4_sys_mmap64(td, uap) + struct thread *td; struct svr4_sys_mmap64_args *uap; { struct mmap_args mm; @@ -576,36 +576,36 @@ svr4_sys_mmap64(p, uap) SCARG(&mm, addr) = SCARG(uap, addr); SCARG(&mm, pos) = SCARG(uap, pos); - rp = (void *) round_page((vm_offset_t)(p->p_vmspace->vm_daddr + MAXDSIZ)); + rp = (void *) round_page((vm_offset_t)(td->td_proc->p_vmspace->vm_daddr + MAXDSIZ)); if ((SCARG(&mm, flags) & MAP_FIXED) == 0 && SCARG(&mm, addr) != 0 && (void *)SCARG(&mm, addr) < rp) SCARG(&mm, addr) = rp; - return mmap(p, &mm); + return mmap(td, &mm); } int -svr4_sys_fchroot(p, uap) - struct proc *p; +svr4_sys_fchroot(td, uap) + struct thread *td; struct svr4_sys_fchroot_args *uap; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct vnode *vp; struct file *fp; int error; - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return error; if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0) return error; vp = (struct vnode *) fp->f_data; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); if (error) return error; VREF(vp); @@ -617,8 +617,8 @@ svr4_sys_fchroot(p, uap) static int -svr4_mknod(p, retval, path, mode, dev) - struct proc *p; +svr4_mknod(td, retval, path, mode, dev) + struct thread *td; register_t *retval; char *path; svr4_mode_t mode; @@ -626,50 +626,50 @@ svr4_mknod(p, retval, path, mode, dev) { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, path); + CHECKALTEXIST(td, &sg, path); if (S_ISFIFO(mode)) { struct mkfifo_args ap; SCARG(&ap, path) = path; SCARG(&ap, mode) = mode; - return mkfifo(p, &ap); + return mkfifo(td, &ap); } else { struct mknod_args ap; SCARG(&ap, path) = path; SCARG(&ap, mode) = mode; SCARG(&ap, dev) = dev; - return mknod(p, &ap); + return mknod(td, &ap); } } int -svr4_sys_mknod(p, uap) - register struct proc *p; +svr4_sys_mknod(td, uap) + register struct thread *td; struct svr4_sys_mknod_args *uap; { - int *retval = p->p_retval; - return svr4_mknod(p, retval, + int *retval = td->td_retval; + return svr4_mknod(td, retval, SCARG(uap, path), SCARG(uap, mode), (svr4_dev_t)svr4_to_bsd_odev_t(SCARG(uap, dev))); } int -svr4_sys_xmknod(p, uap) - struct proc *p; +svr4_sys_xmknod(td, uap) + struct thread *td; struct svr4_sys_xmknod_args *uap; { - int *retval = p->p_retval; - return svr4_mknod(p, retval, + int *retval = td->td_retval; + return svr4_mknod(td, retval, SCARG(uap, path), SCARG(uap, mode), (svr4_dev_t)svr4_to_bsd_dev_t(SCARG(uap, dev))); } int -svr4_sys_vhangup(p, uap) - struct proc *p; +svr4_sys_vhangup(td, uap) + struct thread *td; struct svr4_sys_vhangup_args *uap; { return 0; @@ -677,13 +677,13 @@ svr4_sys_vhangup(p, uap) int -svr4_sys_sysconfig(p, uap) - struct proc *p; +svr4_sys_sysconfig(td, uap) + struct thread *td; struct svr4_sys_sysconfig_args *uap; { int *retval; - retval = &(p->p_retval[0]); + retval = &(td->td_retval[0]); switch (SCARG(uap, name)) { case SVR4_CONFIG_UNUSED: @@ -779,11 +779,11 @@ extern int swap_pager_full; /* ARGSUSED */ int -svr4_sys_break(p, uap) - struct proc *p; +svr4_sys_break(td, uap) + struct thread *td; struct svr4_sys_break_args *uap; { - struct vmspace *vm = p->p_vmspace; + struct vmspace *vm = td->td_proc->p_vmspace; vm_offset_t new, old, base, ns; int rv; @@ -793,7 +793,7 @@ svr4_sys_break(p, uap) /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); if (new > base) { - if ((new - base) > (unsigned) p->p_rlimit[RLIMIT_DATA].rlim_cur) { + if ((new - base) > (unsigned) td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) { return ENOMEM; } if (new >= VM_MAXUSER_ADDRESS) { @@ -842,11 +842,11 @@ timeval_to_clock_t(tv) int -svr4_sys_times(p, uap) - struct proc *p; +svr4_sys_times(td, uap) + struct thread *td; struct svr4_sys_times_args *uap; { - int error, *retval = p->p_retval; + int error, *retval = td->td_retval; struct tms tms; struct timeval t; struct rusage *ru; @@ -859,7 +859,7 @@ svr4_sys_times(p, uap) SCARG(&ga, who) = RUSAGE_SELF; SCARG(&ga, rusage) = ru; - error = getrusage(p, &ga); + error = getrusage(td, &ga); if (error) return error; @@ -870,7 +870,7 @@ svr4_sys_times(p, uap) tms.tms_stime = timeval_to_clock_t(&r.ru_stime); SCARG(&ga, who) = RUSAGE_CHILDREN; - error = getrusage(p, &ga); + error = getrusage(td, &ga); if (error) return error; @@ -888,17 +888,17 @@ svr4_sys_times(p, uap) int -svr4_sys_ulimit(p, uap) - struct proc *p; +svr4_sys_ulimit(td, uap) + struct thread *td; struct svr4_sys_ulimit_args *uap; { - int *retval = p->p_retval; + int *retval = td->td_retval; switch (SCARG(uap, cmd)) { case SVR4_GFILLIM: /* For p_rlimit below. */ mtx_assert(&Giant, MA_OWNED); - *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512; + *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512; if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -914,7 +914,7 @@ svr4_sys_ulimit(p, uap) krl.rlim_cur = SCARG(uap, newlimit) * 512; mtx_assert(&Giant, MA_OWNED); - krl.rlim_max = p->p_rlimit[RLIMIT_FSIZE].rlim_max; + krl.rlim_max = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_max; error = copyout(&krl, url, sizeof(*url)); if (error) @@ -923,12 +923,12 @@ svr4_sys_ulimit(p, uap) SCARG(&srl, which) = RLIMIT_FSIZE; SCARG(&srl, rlp) = url; - error = setrlimit(p, &srl); + error = setrlimit(td, &srl); if (error) return error; mtx_assert(&Giant, MA_OWNED); - *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur; + *retval = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur; if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -936,11 +936,11 @@ svr4_sys_ulimit(p, uap) case SVR4_GMEMLIM: { - struct vmspace *vm = p->p_vmspace; + struct vmspace *vm = td->td_proc->p_vmspace; register_t r; mtx_assert(&Giant, MA_OWNED); - r = p->p_rlimit[RLIMIT_DATA].rlim_cur; + r = td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur; if (r == -1) r = 0x7fffffff; @@ -953,7 +953,7 @@ svr4_sys_ulimit(p, uap) case SVR4_GDESLIM: mtx_assert(&Giant, MA_OWNED); - *retval = p->p_rlimit[RLIMIT_NOFILE].rlim_cur; + *retval = td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur; if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -979,11 +979,12 @@ svr4_pfind(pid) int -svr4_sys_pgrpsys(p, uap) - struct proc *p; +svr4_sys_pgrpsys(td, uap) + struct thread *td; struct svr4_sys_pgrpsys_args *uap; { - int *retval = p->p_retval; + int *retval = td->td_retval; + struct proc *p = td->td_proc; switch (SCARG(uap, cmd)) { case 1: /* setpgrp() */ @@ -994,7 +995,7 @@ svr4_sys_pgrpsys(p, uap) * setsid() for SVR4. (Under BSD, the difference is that * a setpgid(0,0) will not create a new session.) */ - setsid(p, NULL); + setsid(td, NULL); /*FALLTHROUGH*/ case 0: /* getpgrp() */ @@ -1014,7 +1015,7 @@ svr4_sys_pgrpsys(p, uap) return 0; case 3: /* setsid() */ - return setsid(p, NULL); + return setsid(td, NULL); case 4: /* getpgid(pid) */ @@ -1032,7 +1033,7 @@ svr4_sys_pgrpsys(p, uap) SCARG(&sa, pid) = SCARG(uap, pid); SCARG(&sa, pgid) = SCARG(uap, pgid); - return setpgid(p, &sa); + return setpgid(td, &sa); } default: @@ -1052,8 +1053,8 @@ struct svr4_hrtcntl_args { static int -svr4_hrtcntl(p, uap, retval) - struct proc *p; +svr4_hrtcntl(td, uap, retval) + struct thread *td; struct svr4_hrtcntl_args *uap; register_t *retval; { @@ -1098,15 +1099,15 @@ svr4_hrtcntl(p, uap, retval) int -svr4_sys_hrtsys(p, uap) - struct proc *p; +svr4_sys_hrtsys(td, uap) + struct thread *td; struct svr4_sys_hrtsys_args *uap; { - int *retval = p->p_retval; + int *retval = td->td_retval; switch (SCARG(uap, cmd)) { case SVR4_HRT_CNTL: - return svr4_hrtcntl(p, (struct svr4_hrtcntl_args *) uap, + return svr4_hrtcntl(td, (struct svr4_hrtcntl_args *) uap, retval); case SVR4_HRT_ALRM: @@ -1187,12 +1188,12 @@ svr4_setinfo(p, st, s) int -svr4_sys_waitsys(p, uap) - struct proc *p; +svr4_sys_waitsys(td, uap) + struct thread *td; struct svr4_sys_waitsys_args *uap; { int nfound; - int error, *retval = p->p_retval; + int error, *retval = td->td_retval; struct proc *q, *t; @@ -1201,7 +1202,7 @@ svr4_sys_waitsys(p, uap) break; case SVR4_P_PGID: - SCARG(uap, id) = -p->p_pgid; + SCARG(uap, id) = -td->td_proc->p_pgid; break; case SVR4_P_ALL: @@ -1219,7 +1220,7 @@ svr4_sys_waitsys(p, uap) loop: nfound = 0; sx_slock(&proctree_lock); - LIST_FOREACH(q, &p->p_children, p_sibling) { + LIST_FOREACH(q, &td->td_proc->p_children, p_sibling) { if (SCARG(uap, id) != WAIT_ANY && q->p_pid != SCARG(uap, id) && q->p_pgid != -SCARG(uap, id)) { @@ -1276,7 +1277,7 @@ loop: PROC_UNLOCK(q); sx_xunlock(&proctree_lock); q->p_xstat = 0; - ruadd(&p->p_stats->p_cru, q->p_ru); + ruadd(&td->td_proc->p_stats->p_cru, q->p_ru); FREE(q->p_ru, M_ZOMBIE); q->p_ru = 0; @@ -1320,7 +1321,7 @@ loop: PROC_LOCK(q); if (--q->p_procsig->ps_refcnt == 0) { - if (q->p_sigacts != &q->p_addr->u_sigacts) + if (q->p_sigacts != &q->p_uarea->u_sigacts) FREE(q->p_sigacts, M_SUBPROC); FREE(q->p_procsig, M_SUBPROC); q->p_procsig = NULL; @@ -1369,7 +1370,7 @@ loop: return 0; } - if ((error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0)) != 0) + if ((error = tsleep((caddr_t)td->td_proc, PWAIT | PCATCH, "svr4_wait", 0)) != 0) return error; goto loop; } @@ -1428,8 +1429,8 @@ bsd_statfs_to_svr4_statvfs64(bfs, sfs) int -svr4_sys_statvfs(p, uap) - struct proc *p; +svr4_sys_statvfs(td, uap) + struct thread *td; struct svr4_sys_statvfs_args *uap; { struct statfs_args fs_args; @@ -1439,11 +1440,11 @@ svr4_sys_statvfs(p, uap) struct svr4_statvfs sfs; int error; - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&fs_args, path) = SCARG(uap, path); SCARG(&fs_args, buf) = fs; - if ((error = statfs(p, &fs_args)) != 0) + if ((error = statfs(td, &fs_args)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) @@ -1456,8 +1457,8 @@ svr4_sys_statvfs(p, uap) int -svr4_sys_fstatvfs(p, uap) - struct proc *p; +svr4_sys_fstatvfs(td, uap) + struct thread *td; struct svr4_sys_fstatvfs_args *uap; { struct fstatfs_args fs_args; @@ -1470,7 +1471,7 @@ svr4_sys_fstatvfs(p, uap) SCARG(&fs_args, fd) = SCARG(uap, fd); SCARG(&fs_args, buf) = fs; - if ((error = fstatfs(p, &fs_args)) != 0) + if ((error = fstatfs(td, &fs_args)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) @@ -1483,8 +1484,8 @@ svr4_sys_fstatvfs(p, uap) int -svr4_sys_statvfs64(p, uap) - struct proc *p; +svr4_sys_statvfs64(td, uap) + struct thread *td; struct svr4_sys_statvfs64_args *uap; { struct statfs_args fs_args; @@ -1494,11 +1495,11 @@ svr4_sys_statvfs64(p, uap) struct svr4_statvfs64 sfs; int error; - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&fs_args, path) = SCARG(uap, path); SCARG(&fs_args, buf) = fs; - if ((error = statfs(p, &fs_args)) != 0) + if ((error = statfs(td, &fs_args)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) @@ -1511,8 +1512,8 @@ svr4_sys_statvfs64(p, uap) int -svr4_sys_fstatvfs64(p, uap) - struct proc *p; +svr4_sys_fstatvfs64(td, uap) + struct thread *td; struct svr4_sys_fstatvfs64_args *uap; { struct fstatfs_args fs_args; @@ -1525,7 +1526,7 @@ svr4_sys_fstatvfs64(p, uap) SCARG(&fs_args, fd) = SCARG(uap, fd); SCARG(&fs_args, buf) = fs; - if ((error = fstatfs(p, &fs_args)) != 0) + if ((error = fstatfs(td, &fs_args)) != 0) return error; if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) @@ -1537,8 +1538,8 @@ svr4_sys_fstatvfs64(p, uap) } int -svr4_sys_alarm(p, uap) - struct proc *p; +svr4_sys_alarm(td, uap) + struct thread *td; struct svr4_sys_alarm_args *uap; { int error; @@ -1555,19 +1556,19 @@ svr4_sys_alarm(p, uap) SCARG(&sa, which) = ITIMER_REAL; SCARG(&sa, itv) = itp; SCARG(&sa, oitv) = oitp; - error = setitimer(p, &sa); + error = setitimer(td, &sa); if (error) return error; if (oitp->it_value.tv_usec) oitp->it_value.tv_sec++; - p->p_retval[0] = oitp->it_value.tv_sec; + td->td_retval[0] = oitp->it_value.tv_sec; return 0; } int -svr4_sys_gettimeofday(p, uap) - struct proc *p; +svr4_sys_gettimeofday(td, uap) + struct thread *td; struct svr4_sys_gettimeofday_args *uap; { if (SCARG(uap, tp)) { @@ -1581,13 +1582,13 @@ svr4_sys_gettimeofday(p, uap) } int -svr4_sys_facl(p, uap) - struct proc *p; +svr4_sys_facl(td, uap) + struct thread *td; struct svr4_sys_facl_args *uap; { int *retval; - retval = p->p_retval; + retval = td->td_retval; *retval = 0; switch (SCARG(uap, cmd)) { @@ -1609,17 +1610,17 @@ svr4_sys_facl(p, uap) int -svr4_sys_acl(p, uap) - struct proc *p; +svr4_sys_acl(td, uap) + struct thread *td; struct svr4_sys_acl_args *uap; { /* XXX: for now the same */ - return svr4_sys_facl(p, (struct svr4_sys_facl_args *)uap); + return svr4_sys_facl(td, (struct svr4_sys_facl_args *)uap); } int -svr4_sys_auditsys(p, uap) - struct proc *p; +svr4_sys_auditsys(td, uap) + struct thread *td; struct svr4_sys_auditsys_args *uap; { /* @@ -1629,8 +1630,8 @@ svr4_sys_auditsys(p, uap) } int -svr4_sys_memcntl(p, uap) - struct proc *p; +svr4_sys_memcntl(td, uap) + struct thread *td; struct svr4_sys_memcntl_args *uap; { switch (SCARG(uap, cmd)) { @@ -1642,7 +1643,7 @@ svr4_sys_memcntl(p, uap) SCARG(&msa, len) = SCARG(uap, len); SCARG(&msa, flags) = (int)SCARG(uap, arg); - return msync(p, &msa); + return msync(td, &msa); } case SVR4_MC_ADVISE: { @@ -1652,7 +1653,7 @@ svr4_sys_memcntl(p, uap) SCARG(&maa, len) = SCARG(uap, len); SCARG(&maa, behav) = (int)SCARG(uap, arg); - return madvise(p, &maa); + return madvise(td, &maa); } case SVR4_MC_LOCK: case SVR4_MC_UNLOCK: @@ -1666,8 +1667,8 @@ svr4_sys_memcntl(p, uap) int -svr4_sys_nice(p, uap) - struct proc *p; +svr4_sys_nice(td, uap) + struct thread *td; struct svr4_sys_nice_args *uap; { struct setpriority_args ap; @@ -1677,26 +1678,26 @@ svr4_sys_nice(p, uap) SCARG(&ap, who) = 0; SCARG(&ap, prio) = SCARG(uap, prio); - if ((error = setpriority(p, &ap)) != 0) + if ((error = setpriority(td, &ap)) != 0) return error; /* the cast is stupid, but the structures are the same */ - if ((error = getpriority(p, (struct getpriority_args *)&ap)) != 0) + if ((error = getpriority(td, (struct getpriority_args *)&ap)) != 0) return error; return 0; } int -svr4_sys_resolvepath(p, uap) - struct proc *p; +svr4_sys_resolvepath(td, uap) + struct thread *td; struct svr4_sys_resolvepath_args *uap; { struct nameidata nd; - int error, *retval = p->p_retval; + int error, *retval = td->td_retval; NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return error; diff --git a/sys/compat/svr4/svr4_proto.h b/sys/compat/svr4/svr4_proto.h index 95a0ae7..d2a862f 100644 --- a/sys/compat/svr4/svr4_proto.h +++ b/sys/compat/svr4/svr4_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/svr4/syscalls.master,v 1.10 2000/07/29 10:05:24 peter Exp + * created from FreeBSD: src/sys/compat/svr4/syscalls.master,v 1.11 2000/08/31 22:54:05 obrien Exp */ #ifndef _SVR4_SYSPROTO_H_ @@ -15,6 +15,8 @@ struct proc; +struct thread; + #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 0 : sizeof(register_t) - sizeof(t)) @@ -381,86 +383,86 @@ struct svr4_sys_sendto_args { struct sockaddr * to; char to_[PAD_(struct sockaddr *)]; int tolen; char tolen_[PAD_(int)]; }; -int svr4_sys_open __P((struct proc *, struct svr4_sys_open_args *)); -int svr4_sys_wait __P((struct proc *, struct svr4_sys_wait_args *)); -int svr4_sys_creat __P((struct proc *, struct svr4_sys_creat_args *)); -int svr4_sys_execv __P((struct proc *, struct svr4_sys_execv_args *)); -int svr4_sys_time __P((struct proc *, struct svr4_sys_time_args *)); -int svr4_sys_mknod __P((struct proc *, struct svr4_sys_mknod_args *)); -int svr4_sys_break __P((struct proc *, struct svr4_sys_break_args *)); -int svr4_sys_stat __P((struct proc *, struct svr4_sys_stat_args *)); -int svr4_sys_alarm __P((struct proc *, struct svr4_sys_alarm_args *)); -int svr4_sys_fstat __P((struct proc *, struct svr4_sys_fstat_args *)); -int svr4_sys_pause __P((struct proc *, struct svr4_sys_pause_args *)); -int svr4_sys_utime __P((struct proc *, struct svr4_sys_utime_args *)); -int svr4_sys_access __P((struct proc *, struct svr4_sys_access_args *)); -int svr4_sys_nice __P((struct proc *, struct svr4_sys_nice_args *)); -int svr4_sys_kill __P((struct proc *, struct svr4_sys_kill_args *)); -int svr4_sys_pgrpsys __P((struct proc *, struct svr4_sys_pgrpsys_args *)); -int svr4_sys_times __P((struct proc *, struct svr4_sys_times_args *)); -int svr4_sys_signal __P((struct proc *, struct svr4_sys_signal_args *)); +int svr4_sys_open __P((struct thread *, struct svr4_sys_open_args *)); +int svr4_sys_wait __P((struct thread *, struct svr4_sys_wait_args *)); +int svr4_sys_creat __P((struct thread *, struct svr4_sys_creat_args *)); +int svr4_sys_execv __P((struct thread *, struct svr4_sys_execv_args *)); +int svr4_sys_time __P((struct thread *, struct svr4_sys_time_args *)); +int svr4_sys_mknod __P((struct thread *, struct svr4_sys_mknod_args *)); +int svr4_sys_break __P((struct thread *, struct svr4_sys_break_args *)); +int svr4_sys_stat __P((struct thread *, struct svr4_sys_stat_args *)); +int svr4_sys_alarm __P((struct thread *, struct svr4_sys_alarm_args *)); +int svr4_sys_fstat __P((struct thread *, struct svr4_sys_fstat_args *)); +int svr4_sys_pause __P((struct thread *, struct svr4_sys_pause_args *)); +int svr4_sys_utime __P((struct thread *, struct svr4_sys_utime_args *)); +int svr4_sys_access __P((struct thread *, struct svr4_sys_access_args *)); +int svr4_sys_nice __P((struct thread *, struct svr4_sys_nice_args *)); +int svr4_sys_kill __P((struct thread *, struct svr4_sys_kill_args *)); +int svr4_sys_pgrpsys __P((struct thread *, struct svr4_sys_pgrpsys_args *)); +int svr4_sys_times __P((struct thread *, struct svr4_sys_times_args *)); +int svr4_sys_signal __P((struct thread *, struct svr4_sys_signal_args *)); #if defined(NOTYET) -int svr4_sys_msgsys __P((struct proc *, struct svr4_sys_msgsys_args *)); +int svr4_sys_msgsys __P((struct thread *, struct svr4_sys_msgsys_args *)); #else #endif -int svr4_sys_sysarch __P((struct proc *, struct svr4_sys_sysarch_args *)); -int svr4_sys_ioctl __P((struct proc *, struct svr4_sys_ioctl_args *)); -int svr4_sys_utssys __P((struct proc *, struct svr4_sys_utssys_args *)); -int svr4_sys_execve __P((struct proc *, struct svr4_sys_execve_args *)); -int svr4_sys_fcntl __P((struct proc *, struct svr4_sys_fcntl_args *)); -int svr4_sys_ulimit __P((struct proc *, struct svr4_sys_ulimit_args *)); -int svr4_sys_getdents __P((struct proc *, struct svr4_sys_getdents_args *)); -int svr4_sys_getmsg __P((struct proc *, struct svr4_sys_getmsg_args *)); -int svr4_sys_putmsg __P((struct proc *, struct svr4_sys_putmsg_args *)); -int svr4_sys_poll __P((struct proc *, struct svr4_sys_poll_args *)); -int svr4_sys_lstat __P((struct proc *, struct svr4_sys_lstat_args *)); -int svr4_sys_sigprocmask __P((struct proc *, struct svr4_sys_sigprocmask_args *)); -int svr4_sys_sigsuspend __P((struct proc *, struct svr4_sys_sigsuspend_args *)); -int svr4_sys_sigaltstack __P((struct proc *, struct svr4_sys_sigaltstack_args *)); -int svr4_sys_sigaction __P((struct proc *, struct svr4_sys_sigaction_args *)); -int svr4_sys_sigpending __P((struct proc *, struct svr4_sys_sigpending_args *)); -int svr4_sys_context __P((struct proc *, struct svr4_sys_context_args *)); -int svr4_sys_statvfs __P((struct proc *, struct svr4_sys_statvfs_args *)); -int svr4_sys_fstatvfs __P((struct proc *, struct svr4_sys_fstatvfs_args *)); -int svr4_sys_waitsys __P((struct proc *, struct svr4_sys_waitsys_args *)); -int svr4_sys_hrtsys __P((struct proc *, struct svr4_sys_hrtsys_args *)); -int svr4_sys_pathconf __P((struct proc *, struct svr4_sys_pathconf_args *)); -int svr4_sys_mmap __P((struct proc *, struct svr4_sys_mmap_args *)); -int svr4_sys_fpathconf __P((struct proc *, struct svr4_sys_fpathconf_args *)); -int svr4_sys_xstat __P((struct proc *, struct svr4_sys_xstat_args *)); -int svr4_sys_lxstat __P((struct proc *, struct svr4_sys_lxstat_args *)); -int svr4_sys_fxstat __P((struct proc *, struct svr4_sys_fxstat_args *)); -int svr4_sys_xmknod __P((struct proc *, struct svr4_sys_xmknod_args *)); -int svr4_sys_setrlimit __P((struct proc *, struct svr4_sys_setrlimit_args *)); -int svr4_sys_getrlimit __P((struct proc *, struct svr4_sys_getrlimit_args *)); -int svr4_sys_memcntl __P((struct proc *, struct svr4_sys_memcntl_args *)); -int svr4_sys_uname __P((struct proc *, struct svr4_sys_uname_args *)); -int svr4_sys_sysconfig __P((struct proc *, struct svr4_sys_sysconfig_args *)); -int svr4_sys_systeminfo __P((struct proc *, struct svr4_sys_systeminfo_args *)); -int svr4_sys_fchroot __P((struct proc *, struct svr4_sys_fchroot_args *)); -int svr4_sys_utimes __P((struct proc *, struct svr4_sys_utimes_args *)); -int svr4_sys_vhangup __P((struct proc *, struct svr4_sys_vhangup_args *)); -int svr4_sys_gettimeofday __P((struct proc *, struct svr4_sys_gettimeofday_args *)); -int svr4_sys_llseek __P((struct proc *, struct svr4_sys_llseek_args *)); -int svr4_sys_acl __P((struct proc *, struct svr4_sys_acl_args *)); -int svr4_sys_auditsys __P((struct proc *, struct svr4_sys_auditsys_args *)); -int svr4_sys_facl __P((struct proc *, struct svr4_sys_facl_args *)); -int svr4_sys_resolvepath __P((struct proc *, struct svr4_sys_resolvepath_args *)); -int svr4_sys_getdents64 __P((struct proc *, struct svr4_sys_getdents64_args *)); -int svr4_sys_mmap64 __P((struct proc *, struct svr4_sys_mmap64_args *)); -int svr4_sys_stat64 __P((struct proc *, struct svr4_sys_stat64_args *)); -int svr4_sys_lstat64 __P((struct proc *, struct svr4_sys_lstat64_args *)); -int svr4_sys_fstat64 __P((struct proc *, struct svr4_sys_fstat64_args *)); -int svr4_sys_statvfs64 __P((struct proc *, struct svr4_sys_statvfs64_args *)); -int svr4_sys_fstatvfs64 __P((struct proc *, struct svr4_sys_fstatvfs64_args *)); -int svr4_sys_setrlimit64 __P((struct proc *, struct svr4_sys_setrlimit64_args *)); -int svr4_sys_getrlimit64 __P((struct proc *, struct svr4_sys_getrlimit64_args *)); -int svr4_sys_creat64 __P((struct proc *, struct svr4_sys_creat64_args *)); -int svr4_sys_open64 __P((struct proc *, struct svr4_sys_open64_args *)); -int svr4_sys_socket __P((struct proc *, struct svr4_sys_socket_args *)); -int svr4_sys_recv __P((struct proc *, struct svr4_sys_recv_args *)); -int svr4_sys_send __P((struct proc *, struct svr4_sys_send_args *)); -int svr4_sys_sendto __P((struct proc *, struct svr4_sys_sendto_args *)); +int svr4_sys_sysarch __P((struct thread *, struct svr4_sys_sysarch_args *)); +int svr4_sys_ioctl __P((struct thread *, struct svr4_sys_ioctl_args *)); +int svr4_sys_utssys __P((struct thread *, struct svr4_sys_utssys_args *)); +int svr4_sys_execve __P((struct thread *, struct svr4_sys_execve_args *)); +int svr4_sys_fcntl __P((struct thread *, struct svr4_sys_fcntl_args *)); +int svr4_sys_ulimit __P((struct thread *, struct svr4_sys_ulimit_args *)); +int svr4_sys_getdents __P((struct thread *, struct svr4_sys_getdents_args *)); +int svr4_sys_getmsg __P((struct thread *, struct svr4_sys_getmsg_args *)); +int svr4_sys_putmsg __P((struct thread *, struct svr4_sys_putmsg_args *)); +int svr4_sys_poll __P((struct thread *, struct svr4_sys_poll_args *)); +int svr4_sys_lstat __P((struct thread *, struct svr4_sys_lstat_args *)); +int svr4_sys_sigprocmask __P((struct thread *, struct svr4_sys_sigprocmask_args *)); +int svr4_sys_sigsuspend __P((struct thread *, struct svr4_sys_sigsuspend_args *)); +int svr4_sys_sigaltstack __P((struct thread *, struct svr4_sys_sigaltstack_args *)); +int svr4_sys_sigaction __P((struct thread *, struct svr4_sys_sigaction_args *)); +int svr4_sys_sigpending __P((struct thread *, struct svr4_sys_sigpending_args *)); +int svr4_sys_context __P((struct thread *, struct svr4_sys_context_args *)); +int svr4_sys_statvfs __P((struct thread *, struct svr4_sys_statvfs_args *)); +int svr4_sys_fstatvfs __P((struct thread *, struct svr4_sys_fstatvfs_args *)); +int svr4_sys_waitsys __P((struct thread *, struct svr4_sys_waitsys_args *)); +int svr4_sys_hrtsys __P((struct thread *, struct svr4_sys_hrtsys_args *)); +int svr4_sys_pathconf __P((struct thread *, struct svr4_sys_pathconf_args *)); +int svr4_sys_mmap __P((struct thread *, struct svr4_sys_mmap_args *)); +int svr4_sys_fpathconf __P((struct thread *, struct svr4_sys_fpathconf_args *)); +int svr4_sys_xstat __P((struct thread *, struct svr4_sys_xstat_args *)); +int svr4_sys_lxstat __P((struct thread *, struct svr4_sys_lxstat_args *)); +int svr4_sys_fxstat __P((struct thread *, struct svr4_sys_fxstat_args *)); +int svr4_sys_xmknod __P((struct thread *, struct svr4_sys_xmknod_args *)); +int svr4_sys_setrlimit __P((struct thread *, struct svr4_sys_setrlimit_args *)); +int svr4_sys_getrlimit __P((struct thread *, struct svr4_sys_getrlimit_args *)); +int svr4_sys_memcntl __P((struct thread *, struct svr4_sys_memcntl_args *)); +int svr4_sys_uname __P((struct thread *, struct svr4_sys_uname_args *)); +int svr4_sys_sysconfig __P((struct thread *, struct svr4_sys_sysconfig_args *)); +int svr4_sys_systeminfo __P((struct thread *, struct svr4_sys_systeminfo_args *)); +int svr4_sys_fchroot __P((struct thread *, struct svr4_sys_fchroot_args *)); +int svr4_sys_utimes __P((struct thread *, struct svr4_sys_utimes_args *)); +int svr4_sys_vhangup __P((struct thread *, struct svr4_sys_vhangup_args *)); +int svr4_sys_gettimeofday __P((struct thread *, struct svr4_sys_gettimeofday_args *)); +int svr4_sys_llseek __P((struct thread *, struct svr4_sys_llseek_args *)); +int svr4_sys_acl __P((struct thread *, struct svr4_sys_acl_args *)); +int svr4_sys_auditsys __P((struct thread *, struct svr4_sys_auditsys_args *)); +int svr4_sys_facl __P((struct thread *, struct svr4_sys_facl_args *)); +int svr4_sys_resolvepath __P((struct thread *, struct svr4_sys_resolvepath_args *)); +int svr4_sys_getdents64 __P((struct thread *, struct svr4_sys_getdents64_args *)); +int svr4_sys_mmap64 __P((struct thread *, struct svr4_sys_mmap64_args *)); +int svr4_sys_stat64 __P((struct thread *, struct svr4_sys_stat64_args *)); +int svr4_sys_lstat64 __P((struct thread *, struct svr4_sys_lstat64_args *)); +int svr4_sys_fstat64 __P((struct thread *, struct svr4_sys_fstat64_args *)); +int svr4_sys_statvfs64 __P((struct thread *, struct svr4_sys_statvfs64_args *)); +int svr4_sys_fstatvfs64 __P((struct thread *, struct svr4_sys_fstatvfs64_args *)); +int svr4_sys_setrlimit64 __P((struct thread *, struct svr4_sys_setrlimit64_args *)); +int svr4_sys_getrlimit64 __P((struct thread *, struct svr4_sys_getrlimit64_args *)); +int svr4_sys_creat64 __P((struct thread *, struct svr4_sys_creat64_args *)); +int svr4_sys_open64 __P((struct thread *, struct svr4_sys_open64_args *)); +int svr4_sys_socket __P((struct thread *, struct svr4_sys_socket_args *)); +int svr4_sys_recv __P((struct thread *, struct svr4_sys_recv_args *)); +int svr4_sys_send __P((struct thread *, struct svr4_sys_send_args *)); +int svr4_sys_sendto __P((struct thread *, struct svr4_sys_sendto_args *)); #ifdef COMPAT_43 diff --git a/sys/compat/svr4/svr4_resource.c b/sys/compat/svr4/svr4_resource.c index 2b52140..976475d 100644 --- a/sys/compat/svr4/svr4_resource.c +++ b/sys/compat/svr4/svr4_resource.c @@ -128,8 +128,8 @@ svr4_to_native_rl(rl) ((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_MAX) int -svr4_sys_getrlimit(p, uap) - register struct proc *p; +svr4_sys_getrlimit(td, uap) + register struct thread *td; struct svr4_sys_getrlimit_args *uap; { int rl = svr4_to_native_rl(SCARG(uap, which)); @@ -141,7 +141,7 @@ svr4_sys_getrlimit(p, uap) /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - blim = p->p_rlimit[rl]; + blim = td->td_proc->p_rlimit[rl]; /* * Our infinity, is their maxfiles. @@ -175,8 +175,8 @@ svr4_sys_getrlimit(p, uap) int -svr4_sys_setrlimit(p, uap) - register struct proc *p; +svr4_sys_setrlimit(td, uap) + register struct thread *td; struct svr4_sys_setrlimit_args *uap; { int rl = svr4_to_native_rl(SCARG(uap, which)); @@ -189,7 +189,7 @@ svr4_sys_setrlimit(p, uap) /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - limp = &p->p_rlimit[rl]; + limp = &td->td_proc->p_rlimit[rl]; if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0) return error; @@ -221,13 +221,13 @@ svr4_sys_setrlimit(p, uap) else if (slim.rlim_cur == SVR4_RLIM_SAVED_CUR) blim.rlim_cur = limp->rlim_cur; - return dosetrlimit(p, rl, &blim); + return dosetrlimit(td, rl, &blim); } int -svr4_sys_getrlimit64(p, uap) - register struct proc *p; +svr4_sys_getrlimit64(td, uap) + register struct thread *td; struct svr4_sys_getrlimit64_args *uap; { int rl = svr4_to_native_rl(SCARG(uap, which)); @@ -239,7 +239,7 @@ svr4_sys_getrlimit64(p, uap) /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - blim = p->p_rlimit[rl]; + blim = td->td_proc->p_rlimit[rl]; /* * Our infinity, is their maxfiles. @@ -273,8 +273,8 @@ svr4_sys_getrlimit64(p, uap) int -svr4_sys_setrlimit64(p, uap) - register struct proc *p; +svr4_sys_setrlimit64(td, uap) + register struct thread *td; struct svr4_sys_setrlimit64_args *uap; { int rl = svr4_to_native_rl(SCARG(uap, which)); @@ -287,7 +287,7 @@ svr4_sys_setrlimit64(p, uap) /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - limp = &p->p_rlimit[rl]; + limp = &td->td_proc->p_rlimit[rl]; if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0) return error; @@ -319,5 +319,5 @@ svr4_sys_setrlimit64(p, uap) else if (slim.rlim_cur == SVR4_RLIM64_SAVED_CUR) blim.rlim_cur = limp->rlim_cur; - return dosetrlimit(p, rl, &blim); + return dosetrlimit(td, rl, &blim); } diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c index 0273a7a..d4bf8e9 100644 --- a/sys/compat/svr4/svr4_signal.c +++ b/sys/compat/svr4/svr4_signal.c @@ -260,8 +260,8 @@ bsd_to_svr4_sigaltstack(bss, sss) } int -svr4_sys_sigaction(p, uap) - register struct proc *p; +svr4_sys_sigaction(td, uap) + register struct thread *td; struct svr4_sys_sigaction_args *uap; { struct svr4_sigaction *nisa, *oisa, tmpisa; @@ -270,7 +270,7 @@ svr4_sys_sigaction(p, uap) caddr_t sg; int error; - DPRINTF(("@@@ svr4_sys_sigaction(%d, %d, %d)\n", p->p_pid, + DPRINTF(("@@@ svr4_sys_sigaction(%d, %d, %d)\n", td->td_proc->p_pid, SCARG(uap, signum), SVR4_SVR42BSD_SIG(SCARG(uap, signum)))); @@ -307,7 +307,7 @@ svr4_sys_sigaction(p, uap) SCARG(&sa, act) = nbsa; SCARG(&sa, oact) = obsa; - if ((error = sigaction(p, &sa)) != 0) + if ((error = sigaction(td, &sa)) != 0) return error; if (oisa != NULL) { @@ -322,8 +322,8 @@ svr4_sys_sigaction(p, uap) } int -svr4_sys_sigaltstack(p, uap) - register struct proc *p; +svr4_sys_sigaltstack(td, uap) + register struct thread *td; struct svr4_sys_sigaltstack_args *uap; { struct svr4_sigaltstack *nsss, *osss, tmpsss; @@ -332,7 +332,7 @@ svr4_sys_sigaltstack(p, uap) caddr_t sg; int error, *retval; - retval = p->p_retval; + retval = td->td_retval; sg = stackgap_init(); nsss = SCARG(uap, nss); osss = SCARG(uap, oss); @@ -355,7 +355,7 @@ svr4_sys_sigaltstack(p, uap) SCARG(&sa, ss) = nbss; SCARG(&sa, oss) = obss; - if ((error = sigaltstack(p, &sa)) != 0) + if ((error = sigaltstack(td, &sa)) != 0) return error; if (obss != NULL) { @@ -373,15 +373,15 @@ svr4_sys_sigaltstack(p, uap) * Stolen from the ibcs2 one */ int -svr4_sys_signal(p, uap) - register struct proc *p; +svr4_sys_signal(td, uap) + register struct thread *td; struct svr4_sys_signal_args *uap; { int signum; - int error, *retval = p->p_retval; + int error, *retval = td->td_retval; caddr_t sg = stackgap_init(); - DPRINTF(("@@@ svr4_sys_signal(%d)\n", p->p_pid)); + DPRINTF(("@@@ svr4_sys_signal(%d)\n", td->td_proc->p_pid)); signum = SVR4_SVR42BSD_SIG(SVR4_SIGNO(SCARG(uap, signum))); if (signum <= 0 || signum > SVR4_NSIG) @@ -413,7 +413,7 @@ svr4_sys_signal(p, uap) if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0) return error; - if ((error = sigaction(p, &sa_args)) != 0) { + if ((error = sigaction(td, &sa_args)) != 0) { DPRINTF(("signal: sigaction failed: %d\n", error)); *retval = (int)SVR4_SIG_ERR; @@ -437,7 +437,7 @@ sighold: SCARG(&sa, how) = SIG_BLOCK; SCARG(&sa, set) = set; SCARG(&sa, oset) = NULL; - return sigprocmask(p, &sa); + return sigprocmask(td, &sa); } case SVR4_SIGRELSE_MASK: @@ -451,7 +451,7 @@ sighold: SCARG(&sa, how) = SIG_UNBLOCK; SCARG(&sa, set) = set; SCARG(&sa, oset) = NULL; - return sigprocmask(p, &sa); + return sigprocmask(td, &sa); } case SVR4_SIGIGNORE_MASK: @@ -469,7 +469,7 @@ sighold: sa.sa_flags = 0; if ((error = copyout(&sa, bsa, sizeof(sa))) != 0) return error; - if ((error = sigaction(p, &sa_args)) != 0) { + if ((error = sigaction(td, &sa_args)) != 0) { DPRINTF(("sigignore: sigaction failed\n")); return error; } @@ -482,12 +482,12 @@ sighold: sigset_t *set; set = stackgap_alloc(&sg, sizeof(sigset_t)); - PROC_LOCK(p); - *set = p->p_sigmask; - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + *set = td->td_proc->p_sigmask; + PROC_UNLOCK(td->td_proc); SIGDELSET(*set, signum); SCARG(&sa, sigmask) = set; - return sigsuspend(p, &sa); + return sigsuspend(td, &sa); } default: @@ -497,20 +497,20 @@ sighold: int -svr4_sys_sigprocmask(p, uap) - struct proc *p; +svr4_sys_sigprocmask(td, uap) + struct thread *td; struct svr4_sys_sigprocmask_args *uap; { svr4_sigset_t sss; sigset_t bss; int error = 0, *retval; - retval = p->p_retval; + retval = td->td_retval; if (SCARG(uap, oset) != NULL) { /* Fix the return value first if needed */ - PROC_LOCK(p); - bsd_to_svr4_sigset(&p->p_sigmask, &sss); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + bsd_to_svr4_sigset(&td->td_proc->p_sigmask, &sss); + PROC_UNLOCK(td->td_proc); if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0) return error; } @@ -524,50 +524,50 @@ svr4_sys_sigprocmask(p, uap) svr4_to_bsd_sigset(&sss, &bss); - PROC_LOCK(p); + PROC_LOCK(td->td_proc); switch (SCARG(uap, how)) { case SVR4_SIG_BLOCK: - SIGSETOR(p->p_sigmask, bss); - SIG_CANTMASK(p->p_sigmask); + SIGSETOR(td->td_proc->p_sigmask, bss); + SIG_CANTMASK(td->td_proc->p_sigmask); break; case SVR4_SIG_UNBLOCK: - SIGSETNAND(p->p_sigmask, bss); + SIGSETNAND(td->td_proc->p_sigmask, bss); break; case SVR4_SIG_SETMASK: - p->p_sigmask = bss; - SIG_CANTMASK(p->p_sigmask); + td->td_proc->p_sigmask = bss; + SIG_CANTMASK(td->td_proc->p_sigmask); break; default: error = EINVAL; break; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); return error; } int -svr4_sys_sigpending(p, uap) - struct proc *p; +svr4_sys_sigpending(td, uap) + struct thread *td; struct svr4_sys_sigpending_args *uap; { sigset_t bss; int *retval; svr4_sigset_t sss; - DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", p->p_pid)); - retval = p->p_retval; + DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", td->td_proc->p_pid)); + retval = td->td_retval; switch (SCARG(uap, what)) { case 1: /* sigpending */ if (SCARG(uap, mask) == NULL) return 0; - PROC_LOCK(p); - bss = p->p_siglist; - SIGSETAND(bss, p->p_sigmask); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + bss = td->td_proc->p_siglist; + SIGSETAND(bss, td->td_proc->p_sigmask); + PROC_UNLOCK(td->td_proc); bsd_to_svr4_sigset(&bss, &sss); break; @@ -590,8 +590,8 @@ svr4_sys_sigpending(p, uap) } int -svr4_sys_sigsuspend(p, uap) - register struct proc *p; +svr4_sys_sigsuspend(td, uap) + register struct thread *td; struct svr4_sys_sigsuspend_args *uap; { svr4_sigset_t sss; @@ -607,26 +607,26 @@ svr4_sys_sigsuspend(p, uap) svr4_to_bsd_sigset(&sss, bss); SCARG(&sa, sigmask) = bss; - return sigsuspend(p, &sa); + return sigsuspend(td, &sa); } int -svr4_sys_kill(p, uap) - register struct proc *p; +svr4_sys_kill(td, uap) + register struct thread *td; struct svr4_sys_kill_args *uap; { struct kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); SCARG(&ka, signum) = SVR4_SVR42BSD_SIG(SCARG(uap, signum)); - return kill(p, &ka); + return kill(td, &ka); } int -svr4_sys_context(p, uap) - register struct proc *p; +svr4_sys_context(td, uap) + register struct thread *td; struct svr4_sys_context_args *uap; { struct svr4_ucontext uc; @@ -634,11 +634,11 @@ svr4_sys_context(p, uap) switch (uap->func) { case 0: - PROC_LOCK(p); + PROC_LOCK(td->td_proc); DPRINTF(("getcontext(%p)\n", uap->uc)); - svr4_getcontext(p, &uc, &p->p_sigmask, - sigonstack(cpu_getstack(p))); - PROC_UNLOCK(p); + svr4_getcontext(td, &uc, &td->td_proc->p_sigmask, + sigonstack(cpu_getstack(td))); + PROC_UNLOCK(td->td_proc); return copyout(&uc, uap->uc, sizeof(uc)); case 1: @@ -654,7 +654,7 @@ svr4_sys_context(p, uap) uc.uc_sigmask.bits[i])); } #endif - return svr4_setcontext(p, &uc); + return svr4_setcontext(td, &uc); default: DPRINTF(("context(%d, %p)\n", uap->func, @@ -665,12 +665,12 @@ svr4_sys_context(p, uap) } int -svr4_sys_pause(p, uap) - register struct proc *p; +svr4_sys_pause(td, uap) + register struct thread *td; struct svr4_sys_pause_args *uap; { struct sigsuspend_args bsa; - SCARG(&bsa, sigmask) = &p->p_sigmask; - return sigsuspend(p, &bsa); + SCARG(&bsa, sigmask) = &td->td_proc->p_sigmask; + return sigsuspend(td, &bsa); } diff --git a/sys/compat/svr4/svr4_socket.c b/sys/compat/svr4/svr4_socket.c index bd14556..b4f2b55 100644 --- a/sys/compat/svr4/svr4_socket.c +++ b/sys/compat/svr4/svr4_socket.c @@ -75,8 +75,8 @@ extern TAILQ_HEAD(svr4_sockcache_head, svr4_sockcache_entry) svr4_head; extern int svr4_str_initialized; struct sockaddr_un * -svr4_find_socket(p, fp, dev, ino) - struct proc *p; +svr4_find_socket(td, fp, dev, ino) + struct thread *td; struct file *fp; udev_t dev; ino_t ino; @@ -87,7 +87,7 @@ svr4_find_socket(p, fp, dev, ino) if (svr4_str_initialized != 2) { if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) { DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n", - p, dev, ino)); + td, dev, ino)); TAILQ_INIT(&svr4_head); atomic_store_rel_int(&svr4_str_initialized, 2); } @@ -95,9 +95,9 @@ svr4_find_socket(p, fp, dev, ino) } - DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino)); + DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", td, dev, ino)); TAILQ_FOREACH(e, &svr4_head, entries) - if (e->p == p && e->dev == dev && e->ino == ino) { + if (e->p == td->td_proc && e->dev == dev && e->ino == ino) { #ifdef DIAGNOSTIC if (e->cookie != NULL && e->cookie != cookie) panic("svr4 socket cookie mismatch"); @@ -117,8 +117,8 @@ svr4_find_socket(p, fp, dev, ino) * the streams "soo_close()" routine). */ int -svr4_add_socket(p, path, st) - struct proc *p; +svr4_add_socket(td, path, st) + struct thread *td; const char *path; struct stat *st; { @@ -142,7 +142,7 @@ svr4_add_socket(p, path, st) e->cookie = NULL; e->dev = st->st_dev; e->ino = st->st_ino; - e->p = p; + e->p = td->td_proc; if ((error = copyinstr(path, e->sock.sun_path, sizeof(e->sock.sun_path), &len)) != 0) { @@ -156,14 +156,14 @@ svr4_add_socket(p, path, st) TAILQ_INSERT_HEAD(&svr4_head, e, entries); DPRINTF(("svr4_add_socket: %s [%p,%d,%d]\n", e->sock.sun_path, - p, e->dev, e->ino)); + td->td_proc, e->dev, e->ino)); return 0; } int -svr4_sys_socket(p, uap) - struct proc *p; +svr4_sys_socket(td, uap) + struct thread *td; struct svr4_sys_socket_args *uap; { switch (SCARG(uap, type)) { @@ -189,5 +189,5 @@ svr4_sys_socket(p, uap) default: return EINVAL; } - return socket(p, (struct socket_args *)uap); + return socket(td, (struct socket_args *)uap); } diff --git a/sys/compat/svr4/svr4_socket.h b/sys/compat/svr4/svr4_socket.h index 96e3582..e860392 100644 --- a/sys/compat/svr4/svr4_socket.h +++ b/sys/compat/svr4/svr4_socket.h @@ -38,6 +38,7 @@ struct sockaddr_un; struct proc; +struct thread; struct file; struct svr4_sockaddr_in { @@ -47,9 +48,9 @@ struct svr4_sockaddr_in { u_char sin_zero[8]; }; -struct sockaddr_un *svr4_find_socket __P((struct proc *, struct file *, +struct sockaddr_un *svr4_find_socket __P((struct thread *, struct file *, udev_t, ino_t)); void svr4_delete_socket __P((struct proc *, struct file *)); -int svr4_add_socket __P((struct proc *, const char *, struct stat *)); +int svr4_add_socket __P((struct thread *, const char *, struct stat *)); #endif /* _SVR4_SOCKET_H_ */ diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c index b96be4d..65cf49a 100644 --- a/sys/compat/svr4/svr4_sockio.c +++ b/sys/compat/svr4/svr4_sockio.c @@ -70,9 +70,9 @@ bsd_to_svr4_flags(bf) } int -svr4_sock_ioctl(fp, p, retval, fd, cmd, data) +svr4_sock_ioctl(fp, td, retval, fd, cmd, data) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -125,7 +125,7 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data) (void) strncpy(br.ifr_name, sr.svr4_ifr_name, sizeof(br.ifr_name)); if ((error = fo_ioctl(fp, SIOCGIFFLAGS, - (caddr_t) &br, p)) != 0) { + (caddr_t) &br, td)) != 0) { DPRINTF(("SIOCGIFFLAGS (%s) %s: error %d\n", br.ifr_name, sr.svr4_ifr_name, error)); return error; @@ -149,7 +149,7 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data) sc.svr4_ifc_len)); if ((error = fo_ioctl(fp, OSIOCGIFCONF, - (caddr_t) &sc, p)) != 0) + (caddr_t) &sc, td)) != 0) return error; DPRINTF(("SIOCGIFCONF\n")); diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c index a3f22c8..d44a51b 100644 --- a/sys/compat/svr4/svr4_stat.c +++ b/sys/compat/svr4/svr4_stat.c @@ -73,7 +73,7 @@ struct svr4_ustat_args { static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *)); static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *)); -int svr4_ustat __P((struct proc *, struct svr4_ustat_args *)); +int svr4_ustat __P((struct thread *, struct svr4_ustat_args *)); static int svr4_to_bsd_pathconf __P((int)); /* @@ -153,8 +153,8 @@ bsd_to_svr4_stat64(st, st4) } int -svr4_sys_stat(p, uap) - struct proc *p; +svr4_sys_stat(td, uap) + struct thread *td; struct svr4_sys_stat_args *uap; { struct stat st; @@ -163,13 +163,13 @@ svr4_sys_stat(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = stat(p, &cup)) != 0) + if ((error = stat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -178,7 +178,7 @@ svr4_sys_stat(p, uap) bsd_to_svr4_stat(&st, &svr4_st); if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) return error; @@ -188,8 +188,8 @@ svr4_sys_stat(p, uap) int -svr4_sys_lstat(p, uap) - register struct proc *p; +svr4_sys_lstat(td, uap) + register struct thread *td; struct svr4_sys_lstat_args *uap; { struct stat st; @@ -198,12 +198,12 @@ svr4_sys_lstat(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = lstat(p, &cup)) != 0) + if ((error = lstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -212,7 +212,7 @@ svr4_sys_lstat(p, uap) bsd_to_svr4_stat(&st, &svr4_st); if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) return error; @@ -222,8 +222,8 @@ svr4_sys_lstat(p, uap) int -svr4_sys_fstat(p, uap) - register struct proc *p; +svr4_sys_fstat(td, uap) + register struct thread *td; struct svr4_sys_fstat_args *uap; { struct stat st; @@ -235,7 +235,7 @@ svr4_sys_fstat(p, uap) SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = fstat(p, &cup)) != 0) + if ((error = fstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) @@ -251,8 +251,8 @@ svr4_sys_fstat(p, uap) int -svr4_sys_xstat(p, uap) - register struct proc *p; +svr4_sys_xstat(td, uap) + register struct thread *td; struct svr4_sys_xstat_args *uap; { struct stat st; @@ -261,12 +261,12 @@ svr4_sys_xstat(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = stat(p, &cup)) != 0) + if ((error = stat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -276,7 +276,7 @@ svr4_sys_xstat(p, uap) #if defined(SOCKET_NOTYET) if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); #endif if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) @@ -286,8 +286,8 @@ svr4_sys_xstat(p, uap) } int -svr4_sys_lxstat(p, uap) - register struct proc *p; +svr4_sys_lxstat(td, uap) + register struct thread *td; struct svr4_sys_lxstat_args *uap; { struct stat st; @@ -295,12 +295,12 @@ svr4_sys_lxstat(p, uap) struct lstat_args cup; int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = lstat(p, &cup)) != 0) + if ((error = lstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -310,7 +310,7 @@ svr4_sys_lxstat(p, uap) #if defined(SOCKET_NOTYET) if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); #endif if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) return error; @@ -320,8 +320,8 @@ svr4_sys_lxstat(p, uap) int -svr4_sys_fxstat(p, uap) - register struct proc *p; +svr4_sys_fxstat(td, uap) + register struct thread *td; struct svr4_sys_fxstat_args *uap; { struct stat st; @@ -334,7 +334,7 @@ svr4_sys_fxstat(p, uap) SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = fstat(p, &cup)) != 0) + if ((error = fstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) @@ -349,8 +349,8 @@ svr4_sys_fxstat(p, uap) } int -svr4_sys_stat64(p, uap) - register struct proc *p; +svr4_sys_stat64(td, uap) + register struct thread *td; struct svr4_sys_stat64_args *uap; { struct stat st; @@ -359,12 +359,12 @@ svr4_sys_stat64(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = stat(p, &cup)) != 0) + if ((error = stat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -373,7 +373,7 @@ svr4_sys_stat64(p, uap) bsd_to_svr4_stat64(&st, &svr4_st); if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0) return error; @@ -383,8 +383,8 @@ svr4_sys_stat64(p, uap) int -svr4_sys_lstat64(p, uap) - register struct proc *p; +svr4_sys_lstat64(td, uap) + register struct thread *td; struct svr4_sys_lstat64_args *uap; { struct stat st; @@ -393,12 +393,12 @@ svr4_sys_lstat64(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path)); + CHECKALTEXIST(td, &sg, (char *) SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = lstat(p, (struct lstat_args *)&cup)) != 0) + if ((error = lstat(td, (struct lstat_args *)&cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) @@ -407,7 +407,7 @@ svr4_sys_lstat64(p, uap) bsd_to_svr4_stat64(&st, &svr4_st); if (S_ISSOCK(st.st_mode)) - (void) svr4_add_socket(p, SCARG(uap, path), &st); + (void) svr4_add_socket(td, SCARG(uap, path), &st); if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0) return error; @@ -417,8 +417,8 @@ svr4_sys_lstat64(p, uap) int -svr4_sys_fstat64(p, uap) - register struct proc *p; +svr4_sys_fstat64(td, uap) + register struct thread *td; struct svr4_sys_fstat64_args *uap; { struct stat st; @@ -430,7 +430,7 @@ svr4_sys_fstat64(p, uap) SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); - if ((error = fstat(p, &cup)) != 0) + if ((error = fstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) @@ -446,8 +446,8 @@ svr4_sys_fstat64(p, uap) int -svr4_ustat(p, uap) - register struct proc *p; +svr4_ustat(td, uap) + register struct thread *td; struct svr4_ustat_args *uap; { struct svr4_ustat us; @@ -468,8 +468,8 @@ svr4_ustat(p, uap) /*extern char ostype[], hostname[], osrelease[], version[], machine[];*/ int -svr4_sys_uname(p, uap) - register struct proc *p; +svr4_sys_uname(td, uap) + register struct thread *td; struct svr4_sys_uname_args *uap; { struct svr4_utsname sut; @@ -497,13 +497,13 @@ svr4_sys_uname(p, uap) } int -svr4_sys_systeminfo(p, uap) - struct proc *p; +svr4_sys_systeminfo(td, uap) + struct thread *td; struct svr4_sys_systeminfo_args *uap; { char *str = NULL; int error = 0; - register_t *retval = p->p_retval; + register_t *retval = td->td_retval; size_t len = 0; char buf[1]; /* XXX NetBSD uses 256, but that seems like awfully excessive kstack usage @@ -563,13 +563,13 @@ svr4_sys_systeminfo(p, uap) if ((error = suser(p)) != 0) return error; name = KERN_HOSTNAME; - return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, td); case SVR4_SI_SET_SRPC_DOMAIN: if ((error = suser(p)) != 0) return error; name = KERN_NISDOMAINNAME; - return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, td); #else case SVR4_SI_SET_HOSTNAME: case SVR4_SI_SET_SRPC_DOMAIN: @@ -607,8 +607,8 @@ svr4_sys_systeminfo(p, uap) } int -svr4_sys_utssys(p, uap) - register struct proc *p; +svr4_sys_utssys(td, uap) + register struct thread *td; struct svr4_sys_utssys_args *uap; { switch (SCARG(uap, sel)) { @@ -616,7 +616,7 @@ svr4_sys_utssys(p, uap) { struct svr4_sys_uname_args ua; SCARG(&ua, name) = SCARG(uap, a1); - return svr4_sys_uname(p, &ua); + return svr4_sys_uname(td, &ua); } case 2: /* ustat(2) */ @@ -624,7 +624,7 @@ svr4_sys_utssys(p, uap) struct svr4_ustat_args ua; SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2); SCARG(&ua, name) = SCARG(uap, a1); - return svr4_ustat(p, &ua); + return svr4_ustat(td, &ua); } case 3: /* fusers(2) */ @@ -638,8 +638,8 @@ svr4_sys_utssys(p, uap) int -svr4_sys_utime(p, uap) - register struct proc *p; +svr4_sys_utime(td, uap) + register struct thread *td; struct svr4_sys_utime_args *uap; { struct svr4_utimbuf ub; @@ -649,7 +649,7 @@ svr4_sys_utime(p, uap) caddr_t sg = stackgap_init(); void *ttp; - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&ap, path) = SCARG(uap, path); if (SCARG(uap, ubuf) != NULL) { if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0) @@ -666,18 +666,18 @@ svr4_sys_utime(p, uap) } else SCARG(&ap, tptr) = NULL; - return utimes(p, &ap); + return utimes(td, &ap); } int -svr4_sys_utimes(p, uap) - register struct proc *p; +svr4_sys_utimes(td, uap) + register struct thread *td; struct svr4_sys_utimes_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return utimes(p, (struct utimes_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return utimes(td, (struct utimes_args *)uap); } static int @@ -730,14 +730,14 @@ svr4_to_bsd_pathconf(name) int -svr4_sys_pathconf(p, uap) - register struct proc *p; +svr4_sys_pathconf(td, uap) + register struct thread *td; struct svr4_sys_pathconf_args *uap; { caddr_t sg = stackgap_init(); - register_t *retval = p->p_retval; + register_t *retval = td->td_retval; - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); @@ -749,17 +749,17 @@ svr4_sys_pathconf(p, uap) *retval = 0; return 0; default: - return pathconf(p, (struct pathconf_args *)uap); + return pathconf(td, (struct pathconf_args *)uap); } } int -svr4_sys_fpathconf(p, uap) - register struct proc *p; +svr4_sys_fpathconf(td, uap) + register struct thread *td; struct svr4_sys_fpathconf_args *uap; { - register_t *retval = p->p_retval; + register_t *retval = td->td_retval; SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name)); @@ -771,6 +771,6 @@ svr4_sys_fpathconf(p, uap) *retval = 0; return 0; default: - return fpathconf(p, (struct fpathconf_args *)uap); + return fpathconf(td, (struct fpathconf_args *)uap); } } diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c index 45a2a5e..cb19305 100644 --- a/sys/compat/svr4/svr4_stream.c +++ b/sys/compat/svr4/svr4_stream.c @@ -75,7 +75,7 @@ #include <compat/svr4/svr4_socket.h> /* Utils */ -static int clean_pipe __P((struct proc *, const char *)); +static int clean_pipe __P((struct thread *, const char *)); static void getparm __P((struct file *, struct svr4_si_sockparms *)); /* Address Conversions */ @@ -89,48 +89,48 @@ static void netaddr_to_sockaddr_un __P((struct sockaddr_un *, const struct svr4_strmcmd *)); /* stream ioctls */ -static int i_nread __P((struct file *, struct proc *, register_t *, int, +static int i_nread __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int i_fdinsert __P((struct file *, struct proc *, register_t *, int, +static int i_fdinsert __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int i_str __P((struct file *, struct proc *, register_t *, int, +static int i_str __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int i_setsig __P((struct file *, struct proc *, register_t *, int, +static int i_setsig __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int i_getsig __P((struct file *, struct proc *, register_t *, int, +static int i_getsig __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int _i_bind_rsvd __P((struct file *, struct proc *, register_t *, int, +static int _i_bind_rsvd __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); -static int _i_rele_rsvd __P((struct file *, struct proc *, register_t *, int, +static int _i_rele_rsvd __P((struct file *, struct thread *, register_t *, int, u_long, caddr_t)); /* i_str sockmod calls */ static int sockmod __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int si_listen __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int si_ogetudata __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int si_sockparams __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int si_shutdown __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int si_getudata __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); /* i_str timod calls */ static int timod __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int ti_getinfo __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); static int ti_bind __P((struct file *, int, struct svr4_strioctl *, - struct proc *)); + struct thread *)); /* infrastructure */ -static int svr4_sendit __P((struct proc *p, int s, struct msghdr *mp, +static int svr4_sendit __P((struct thread *td, int s, struct msghdr *mp, int flags)); -static int svr4_recvit __P((struct proc *p, int s, struct msghdr *mp, +static int svr4_recvit __P((struct thread *td, int s, struct msghdr *mp, caddr_t namelenp)); /* <sigh> Ok, so we shouldn't use sendit() in uipc_syscalls.c because @@ -144,8 +144,8 @@ static int svr4_recvit __P((struct proc *p, int s, struct msghdr *mp, * I will take out all the #ifdef COMPAT_OLDSOCK gumph, though. */ static int -svr4_sendit(p, s, mp, flags) - register struct proc *p; +svr4_sendit(td, s, mp, flags) + register struct thread *td; int s; register struct msghdr *mp; int flags; @@ -163,27 +163,27 @@ svr4_sendit(p, s, mp, flags) struct uio ktruio; #endif - error = holdsock(p->p_fd, s, &fp); + error = holdsock(td->td_proc->p_fd, s, &fp); if (error) return (error); auio.uio_iov = mp->msg_iov; auio.uio_iovcnt = mp->msg_iovlen; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = UIO_WRITE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { if ((auio.uio_resid += iov->iov_len) < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } } if (mp->msg_name) { error = getsockaddr(&to, mp->msg_name, mp->msg_namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } } else { @@ -202,7 +202,7 @@ svr4_sendit(p, s, mp, flags) control = 0; } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -213,25 +213,25 @@ svr4_sendit(p, s, mp, flags) len = auio.uio_resid; so = (struct socket *)fp->f_data; error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control, - flags, p); + flags, td); if (error) { if (auio.uio_resid != len && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; if (error == EPIPE) { - PROC_LOCK(p); - psignal(p, SIGPIPE); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGPIPE); + PROC_UNLOCK(td->td_proc); } } if (error == 0) - p->p_retval[0] = len - auio.uio_resid; + td->td_retval[0] = len - auio.uio_resid; #ifdef KTRACE if (ktriov != NULL) { if (error == 0) { ktruio.uio_iov = ktriov; - ktruio.uio_resid = p->p_retval[0]; - ktrgenio(p->p_tracep, s, UIO_WRITE, &ktruio, error); + ktruio.uio_resid = td->td_retval[0]; + ktrgenio(td->td_proc->p_tracep, s, UIO_WRITE, &ktruio, error); } FREE(ktriov, M_TEMP); } @@ -239,13 +239,13 @@ svr4_sendit(p, s, mp, flags) bad: if (to) FREE(to, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); return (error); } static int -svr4_recvit(p, s, mp, namelenp) - register struct proc *p; +svr4_recvit(td, s, mp, namelenp) + register struct thread *td; int s; register struct msghdr *mp; caddr_t namelenp; @@ -264,25 +264,25 @@ svr4_recvit(p, s, mp, namelenp) struct uio ktruio; #endif - error = holdsock(p->p_fd, s, &fp); + error = holdsock(td->td_proc->p_fd, s, &fp); if (error) return (error); auio.uio_iov = mp->msg_iov; auio.uio_iovcnt = mp->msg_iovlen; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { if ((auio.uio_resid += iov->iov_len) < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -305,14 +305,14 @@ svr4_recvit(p, s, mp, namelenp) if (error == 0) { ktruio.uio_iov = ktriov; ktruio.uio_resid = len - auio.uio_resid; - ktrgenio(p->p_tracep, s, UIO_READ, &ktruio, error); + ktrgenio(td->td_proc->p_tracep, s, UIO_READ, &ktruio, error); } FREE(ktriov, M_TEMP); } #endif if (error) goto out; - p->p_retval[0] = len - auio.uio_resid; + td->td_retval[0] = len - auio.uio_resid; if (mp->msg_name) { len = mp->msg_namelen; if (len <= 0 || fromsa == 0) @@ -365,7 +365,7 @@ out: FREE(fromsa, M_SONAME); if (control) m_freem(control); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -499,8 +499,8 @@ show_msg(str, fd, ctl, dat, flags) * to avoid code duplication. */ static int -clean_pipe(p, path) - struct proc *p; +clean_pipe(td, path) + struct thread *td; const char *path; { struct lstat_args la; @@ -519,7 +519,7 @@ clean_pipe(p, path) SCARG(&la, path) = tpath; - if ((error = lstat(p, &la)) != 0) + if ((error = lstat(td, &la)) != 0) return 0; if ((error = copyin(SCARG(&la, ub), &st, sizeof(st))) != 0) @@ -536,7 +536,7 @@ clean_pipe(p, path) SCARG(&ua, path) = SCARG(&la, path); - if ((error = unlink(p, &ua)) != 0) { + if ((error = unlink(td, &ua)) != 0) { DPRINTF(("clean_pipe: unlink failed %d\n", error)); return error; } @@ -662,11 +662,11 @@ getparm(fp, pa) static int -si_ogetudata(fp, fd, ioc, p) +si_ogetudata(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct svr4_si_oudata ud; @@ -719,11 +719,11 @@ si_ogetudata(fp, fd, ioc, p) static int -si_sockparams(fp, fd, ioc, p) +si_sockparams(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { struct svr4_si_sockparms pa; @@ -733,11 +733,11 @@ si_sockparams(fp, fd, ioc, p) static int -si_listen(fp, fd, ioc, p) +si_listen(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct svr4_strm *st = svr4_stream_get(fp); @@ -762,7 +762,7 @@ si_listen(fp, fd, ioc, p) DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); SCARG(&la, backlog) = 5; - if ((error = listen(p, &la)) != 0) { + if ((error = listen(td, &la)) != 0) { DPRINTF(("SI_LISTEN: listen failed %d\n", error)); return error; } @@ -797,11 +797,11 @@ si_listen(fp, fd, ioc, p) static int -si_getudata(fp, fd, ioc, p) +si_getudata(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct svr4_si_udata ud; @@ -856,11 +856,11 @@ si_getudata(fp, fd, ioc, p) static int -si_shutdown(fp, fd, ioc, p) +si_shutdown(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct shutdown_args ap; @@ -876,29 +876,29 @@ si_shutdown(fp, fd, ioc, p) SCARG(&ap, s) = fd; - return shutdown(p, &ap); + return shutdown(td, &ap); } static int -sockmod(fp, fd, ioc, p) +sockmod(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { switch (ioc->cmd) { case SVR4_SI_OGETUDATA: DPRINTF(("SI_OGETUDATA\n")); - return si_ogetudata(fp, fd, ioc, p); + return si_ogetudata(fp, fd, ioc, td); case SVR4_SI_SHUTDOWN: DPRINTF(("SI_SHUTDOWN\n")); - return si_shutdown(fp, fd, ioc, p); + return si_shutdown(fp, fd, ioc, td); case SVR4_SI_LISTEN: DPRINTF(("SI_LISTEN\n")); - return si_listen(fp, fd, ioc, p); + return si_listen(fp, fd, ioc, td); case SVR4_SI_SETMYNAME: DPRINTF(("SI_SETMYNAME\n")); @@ -922,11 +922,11 @@ sockmod(fp, fd, ioc, p) case SVR4_SI_SOCKPARAMS: DPRINTF(("SI_SOCKPARAMS\n")); - return si_sockparams(fp, fd, ioc, p); + return si_sockparams(fp, fd, ioc, td); case SVR4_SI_GETUDATA: DPRINTF(("SI_GETUDATA\n")); - return si_getudata(fp, fd, ioc, p); + return si_getudata(fp, fd, ioc, td); default: DPRINTF(("Unknown sockmod ioctl %lx\n", ioc->cmd)); @@ -937,11 +937,11 @@ sockmod(fp, fd, ioc, p) static int -ti_getinfo(fp, fd, ioc, p) +ti_getinfo(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct svr4_infocmd info; @@ -975,11 +975,11 @@ ti_getinfo(fp, fd, ioc, p) static int -ti_bind(fp, fd, ioc, p) +ti_bind(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { int error; struct svr4_strm *st = svr4_stream_get(fp); @@ -1033,7 +1033,7 @@ ti_bind(fp, fd, ioc, p) DPRINTF(("TI_BIND: fam %d, path %s\n", saun.sun_family, saun.sun_path)); - if ((error = clean_pipe(p, saun.sun_path)) != 0) + if ((error = clean_pipe(td, saun.sun_path)) != 0) return error; bnd.pad[28] = 0x00001000; /* magic again */ @@ -1056,7 +1056,7 @@ ti_bind(fp, fd, ioc, p) SCARG(&ba, name) = (void *) sup; SCARG(&ba, namelen) = sasize; - if ((error = bind(p, &ba)) != 0) { + if ((error = bind(td, &ba)) != 0) { DPRINTF(("TI_BIND: bind failed %d\n", error)); return error; } @@ -1078,16 +1078,16 @@ reply: static int -timod(fp, fd, ioc, p) +timod(fp, fd, ioc, td) struct file *fp; int fd; struct svr4_strioctl *ioc; - struct proc *p; + struct thread *td; { switch (ioc->cmd) { case SVR4_TI_GETINFO: DPRINTF(("TI_GETINFO\n")); - return ti_getinfo(fp, fd, ioc, p); + return ti_getinfo(fp, fd, ioc, td); case SVR4_TI_OPTMGMT: DPRINTF(("TI_OPTMGMT\n")); @@ -1095,7 +1095,7 @@ timod(fp, fd, ioc, p) case SVR4_TI_BIND: DPRINTF(("TI_BIND\n")); - return ti_bind(fp, fd, ioc, p); + return ti_bind(fp, fd, ioc, td); case SVR4_TI_UNBIND: DPRINTF(("TI_UNBIND\n")); @@ -1109,9 +1109,9 @@ timod(fp, fd, ioc, p) int -svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) +svr4_stream_ti_ioctl(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1174,7 +1174,7 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) SCARG(&ap, fdes) = fd; SCARG(&ap, asa) = sup; SCARG(&ap, alen) = lenp; - if ((error = getsockname(p, &ap)) != 0) { + if ((error = getsockname(td, &ap)) != 0) { DPRINTF(("ti_ioctl: getsockname error\n")); return error; } @@ -1188,7 +1188,7 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) SCARG(&ap, fdes) = fd; SCARG(&ap, asa) = sup; SCARG(&ap, alen) = lenp; - if ((error = getpeername(p, &ap)) != 0) { + if ((error = getpeername(td, &ap)) != 0) { DPRINTF(("ti_ioctl: getpeername error\n")); return error; } @@ -1251,9 +1251,9 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) static int -i_nread(fp, p, retval, fd, cmd, dat) +i_nread(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1269,7 +1269,7 @@ i_nread(fp, p, retval, fd, cmd, dat) * for us, and if we do, then we assume that we have at least one * message waiting for us. */ - if ((error = fo_ioctl(fp, FIONREAD, (caddr_t) &nread, p)) != 0) + if ((error = fo_ioctl(fp, FIONREAD, (caddr_t) &nread, td)) != 0) return error; if (nread != 0) @@ -1281,9 +1281,9 @@ i_nread(fp, p, retval, fd, cmd, dat) } static int -i_fdinsert(fp, p, retval, fd, cmd, dat) +i_fdinsert(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1321,7 +1321,7 @@ i_fdinsert(fp, p, retval, fd, cmd, dat) SCARG(&d2p, from) = st->s_afd; SCARG(&d2p, to) = fdi.fd; - if ((error = dup2(p, &d2p)) != 0) { + if ((error = dup2(td, &d2p)) != 0) { DPRINTF(("fdinsert: dup2(%d, %d) failed %d\n", st->s_afd, fdi.fd, error)); return error; @@ -1329,7 +1329,7 @@ i_fdinsert(fp, p, retval, fd, cmd, dat) SCARG(&clp, fd) = st->s_afd; - if ((error = close(p, &clp)) != 0) { + if ((error = close(td, &clp)) != 0) { DPRINTF(("fdinsert: close(%d) failed %d\n", st->s_afd, error)); return error; @@ -1343,9 +1343,9 @@ i_fdinsert(fp, p, retval, fd, cmd, dat) static int -_i_bind_rsvd(fp, p, retval, fd, cmd, dat) +_i_bind_rsvd(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1363,13 +1363,13 @@ _i_bind_rsvd(fp, p, retval, fd, cmd, dat) SCARG(&ap, path) = dat; SCARG(&ap, mode) = S_IFIFO; - return mkfifo(p, &ap); + return mkfifo(td, &ap); } static int -_i_rele_rsvd(fp, p, retval, fd, cmd, dat) +_i_rele_rsvd(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1383,13 +1383,13 @@ _i_rele_rsvd(fp, p, retval, fd, cmd, dat) */ SCARG(&ap, path) = dat; - return unlink(p, &ap); + return unlink(td, &ap); } static int -i_str(fp, p, retval, fd, cmd, dat) +i_str(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1408,12 +1408,12 @@ i_str(fp, p, retval, fd, cmd, dat) switch (ioc.cmd & 0xff00) { case SVR4_SIMOD: - if ((error = sockmod(fp, fd, &ioc, p)) != 0) + if ((error = sockmod(fp, fd, &ioc, td)) != 0) return error; break; case SVR4_TIMOD: - if ((error = timod(fp, fd, &ioc, p)) != 0) + if ((error = timod(fp, fd, &ioc, td)) != 0) return error; break; @@ -1431,9 +1431,9 @@ i_str(fp, p, retval, fd, cmd, dat) } static int -i_setsig(fp, p, retval, fd, cmd, dat) +i_setsig(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1459,10 +1459,10 @@ i_setsig(fp, p, retval, fd, cmd, dat) /* get old status flags */ SCARG(&fa, fd) = fd; SCARG(&fa, cmd) = F_GETFL; - if ((error = fcntl(p, &fa)) != 0) + if ((error = fcntl(td, &fa)) != 0) return error; - oflags = p->p_retval[0]; + oflags = td->td_retval[0]; /* update the flags */ if (dat != NULL) { @@ -1488,24 +1488,24 @@ i_setsig(fp, p, retval, fd, cmd, dat) if (flags != oflags) { SCARG(&fa, cmd) = F_SETFL; SCARG(&fa, arg) = (long) flags; - if ((error = fcntl(p, &fa)) != 0) + if ((error = fcntl(td, &fa)) != 0) return error; - flags = p->p_retval[0]; + flags = td->td_retval[0]; } /* set up SIGIO receiver if needed */ if (dat != NULL) { SCARG(&fa, cmd) = F_SETOWN; - SCARG(&fa, arg) = (long) p->p_pid; - return fcntl(p, &fa); + SCARG(&fa, arg) = (long) td->td_proc->p_pid; + return fcntl(td, &fa); } return 0; } static int -i_getsig(fp, p, retval, fd, cmd, dat) +i_getsig(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1530,9 +1530,9 @@ i_getsig(fp, p, retval, fd, cmd, dat) } int -svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) +svr4_stream_ioctl(fp, td, retval, fd, cmd, dat) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -1546,7 +1546,7 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) switch (cmd) { case SVR4_I_NREAD: DPRINTF(("I_NREAD\n")); - return i_nread(fp, p, retval, fd, cmd, dat); + return i_nread(fp, td, retval, fd, cmd, dat); case SVR4_I_PUSH: DPRINTF(("I_PUSH %p\n", dat)); @@ -1577,15 +1577,15 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) case SVR4_I_STR: DPRINTF(("I_STR\n")); - return i_str(fp, p, retval, fd, cmd, dat); + return i_str(fp, td, retval, fd, cmd, dat); case SVR4_I_SETSIG: DPRINTF(("I_SETSIG\n")); - return i_setsig(fp, p, retval, fd, cmd, dat); + return i_setsig(fp, td, retval, fd, cmd, dat); case SVR4_I_GETSIG: DPRINTF(("I_GETSIG\n")); - return i_getsig(fp, p, retval, fd, cmd, dat); + return i_getsig(fp, td, retval, fd, cmd, dat); case SVR4_I_FIND: DPRINTF(("I_FIND\n")); @@ -1614,7 +1614,7 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) case SVR4_I_FDINSERT: DPRINTF(("I_FDINSERT\n")); - return i_fdinsert(fp, p, retval, fd, cmd, dat); + return i_fdinsert(fp, td, retval, fd, cmd, dat); case SVR4_I_SENDFD: DPRINTF(("I_SENDFD\n")); @@ -1690,11 +1690,11 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) case SVR4__I_BIND_RSVD: DPRINTF(("_I_BIND_RSVD\n")); - return _i_bind_rsvd(fp, p, retval, fd, cmd, dat); + return _i_bind_rsvd(fp, td, retval, fd, cmd, dat); case SVR4__I_RELE_RSVD: DPRINTF(("_I_RELE_RSVD\n")); - return _i_rele_rsvd(fp, p, retval, fd, cmd, dat); + return _i_rele_rsvd(fp, td, retval, fd, cmd, dat); default: DPRINTF(("unimpl cmd = %lx\n", cmd)); @@ -1707,11 +1707,11 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) int -svr4_sys_putmsg(p, uap) - register struct proc *p; +svr4_sys_putmsg(td, uap) + register struct thread *td; struct svr4_sys_putmsg_args *uap; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp; struct svr4_strbuf dat, ctl; struct svr4_strmcmd sc; @@ -1723,7 +1723,7 @@ svr4_sys_putmsg(p, uap) int error; caddr_t sg; - retval = p->p_retval; + retval = td->td_retval; fp = fdp->fd_ofiles[SCARG(uap, fd)]; if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) { @@ -1802,7 +1802,7 @@ svr4_sys_putmsg(p, uap) SCARG(&wa, fd) = SCARG(uap, fd); SCARG(&wa, buf) = dat.buf; SCARG(&wa, nbyte) = dat.len; - return write(p, &wa); + return write(td, &wa); } DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len)); return EINVAL; @@ -1824,7 +1824,7 @@ svr4_sys_putmsg(p, uap) /* Maybe we've been given a device/inode pair */ udev_t *dev = SVR4_ADDROF(&sc); ino_t *ino = (ino_t *) &dev[1]; - skp = svr4_find_socket(p, fp, *dev, *ino); + skp = svr4_find_socket(td, fp, *dev, *ino); if (skp == NULL) { skp = &saun; /* I guess we have it by name */ @@ -1855,7 +1855,7 @@ svr4_sys_putmsg(p, uap) SCARG(&co, name) = (void *) sup; SCARG(&co, namelen) = (int) sasize; - return connect(p, &co); + return connect(td, &co); } case SVR4_TI_SENDTO_REQUEST: /* sendto */ @@ -1873,9 +1873,9 @@ svr4_sys_putmsg(p, uap) aiov.iov_len = dat.len; #if 0 error = so->so_proto->pr_usrreqs->pru_sosend(so, 0, - uio, 0, 0, 0, uio->uio_procp); + uio, 0, 0, 0, uio->uio_td); #endif - error = svr4_sendit(p, SCARG(uap, fd), &msg, + error = svr4_sendit(td, SCARG(uap, fd), &msg, SCARG(uap, flags)); DPRINTF(("sendto_request error: %d\n", error)); *retval = 0; @@ -1889,11 +1889,11 @@ svr4_sys_putmsg(p, uap) } int -svr4_sys_getmsg(p, uap) - register struct proc *p; +svr4_sys_getmsg(td, uap) + register struct thread *td; struct svr4_sys_getmsg_args *uap; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp; struct getpeername_args ga; struct accept_args aa; @@ -1911,7 +1911,7 @@ svr4_sys_getmsg(p, uap) int fl; caddr_t sg; - retval = p->p_retval; + retval = td->td_retval; fp = fdp->fd_ofiles[SCARG(uap, fd)]; if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) @@ -2010,7 +2010,7 @@ svr4_sys_getmsg(p, uap) SCARG(&ga, asa) = (void *) sup; SCARG(&ga, alen) = flen; - if ((error = getpeername(p, &ga)) != 0) { + if ((error = getpeername(td, &ga)) != 0) { DPRINTF(("getmsg: getpeername failed %d\n", error)); return error; } @@ -2069,7 +2069,7 @@ svr4_sys_getmsg(p, uap) SCARG(&aa, name) = (void *) sup; SCARG(&aa, anamelen) = flen; - if ((error = accept(p, &aa)) != 0) { + if ((error = accept(td, &aa)) != 0) { DPRINTF(("getmsg: accept failed %d\n", error)); return error; } @@ -2140,7 +2140,7 @@ svr4_sys_getmsg(p, uap) aiov.iov_len = dat.maxlen; msg.msg_flags = 0; - error = svr4_recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen); + error = svr4_recvit(td, SCARG(uap, fd), &msg, (caddr_t) flen); if (error) { DPRINTF(("getmsg: recvit failed %d\n", error)); @@ -2191,7 +2191,7 @@ svr4_sys_getmsg(p, uap) SCARG(&ra, fd) = SCARG(uap, fd); SCARG(&ra, buf) = dat.buf; SCARG(&ra, nbyte) = dat.maxlen; - if ((error = read(p, &ra)) != 0) { + if ((error = read(td, &ra)) != 0) { return error; } dat.len = *retval; @@ -2231,8 +2231,8 @@ svr4_sys_getmsg(p, uap) return error; } -int svr4_sys_send(p, uap) - struct proc *p; +int svr4_sys_send(td, uap) + struct thread *td; struct svr4_sys_send_args *uap; { struct osend_args osa; @@ -2240,11 +2240,11 @@ int svr4_sys_send(p, uap) SCARG(&osa, buf) = SCARG(uap, buf); SCARG(&osa, len) = SCARG(uap, len); SCARG(&osa, flags) = SCARG(uap, flags); - return osend(p, &osa); + return osend(td, &osa); } -int svr4_sys_recv(p, uap) - struct proc *p; +int svr4_sys_recv(td, uap) + struct thread *td; struct svr4_sys_recv_args *uap; { struct orecv_args ora; @@ -2252,7 +2252,7 @@ int svr4_sys_recv(p, uap) SCARG(&ora, buf) = SCARG(uap, buf); SCARG(&ora, len) = SCARG(uap, len); SCARG(&ora, flags) = SCARG(uap, flags); - return orecv(p, &ora); + return orecv(td, &ora); } /* @@ -2260,8 +2260,8 @@ int svr4_sys_recv(p, uap) * sendto(). Let's leave it here for now... */ int -svr4_sys_sendto(p, uap) - struct proc *p; +svr4_sys_sendto(td, uap) + struct thread *td; struct svr4_sys_sendto_args *uap; { struct sendto_args sa; @@ -2274,6 +2274,6 @@ svr4_sys_sendto(p, uap) SCARG(&sa, tolen) = SCARG(uap, tolen); DPRINTF(("calling sendto()\n")); - return sendto(p, &sa); + return sendto(td, &sa); } diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h index 9d25526..b1898b5 100644 --- a/sys/compat/svr4/svr4_syscall.h +++ b/sys/compat/svr4/svr4_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/svr4/syscalls.master,v 1.10 2000/07/29 10:05:24 peter Exp + * created from FreeBSD: src/sys/compat/svr4/syscalls.master,v 1.11 2000/08/31 22:54:05 obrien Exp */ #define SVR4_SYS_exit 1 diff --git a/sys/compat/svr4/svr4_syscallnames.c b/sys/compat/svr4/svr4_syscallnames.c index 479a6b7..1f9add4 100644 --- a/sys/compat/svr4/svr4_syscallnames.c +++ b/sys/compat/svr4/svr4_syscallnames.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/svr4/syscalls.master,v 1.10 2000/07/29 10:05:24 peter Exp + * created from FreeBSD: src/sys/compat/svr4/syscalls.master,v 1.11 2000/08/31 22:54:05 obrien Exp */ char *svr4_syscallnames[] = { diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c index bad9e4e..2bb003e 100644 --- a/sys/compat/svr4/svr4_sysent.c +++ b/sys/compat/svr4/svr4_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/svr4/syscalls.master,v 1.10 2000/07/29 10:05:24 peter Exp + * created from FreeBSD: src/sys/compat/svr4/syscalls.master,v 1.11 2000/08/31 22:54:05 obrien Exp */ #include <sys/types.h> diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c index 9137e0c..39aa904 100644 --- a/sys/compat/svr4/svr4_sysvec.c +++ b/sys/compat/svr4/svr4_sysvec.c @@ -238,14 +238,15 @@ svr4_fixup(register_t **stack_base, struct image_params *imgp) * Code shamelessly stolen by Mark Newton from IBCS2 emulation code. */ int -svr4_emul_find(p, sgp, prefix, path, pbuf, cflag) - struct proc *p; +svr4_emul_find(td, sgp, prefix, path, pbuf, cflag) + struct thread *td; caddr_t *sgp; /* Pointer to stackgap memory */ const char *prefix; char *path; char **pbuf; int cflag; { + struct proc *p = td->td_proc; struct nameidata nd; struct nameidata ndroot; struct vattr vat; @@ -292,7 +293,7 @@ svr4_emul_find(p, sgp, prefix, path, pbuf, cflag) for (cp = &ptr[len] - 1; *cp != '/'; cp--); *cp = '\0'; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -303,7 +304,7 @@ svr4_emul_find(p, sgp, prefix, path, pbuf, cflag) *cp = '/'; } else { - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -320,7 +321,7 @@ svr4_emul_find(p, sgp, prefix, path, pbuf, cflag) * to the emulation root directory. This is expensive :-( */ NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, svr4_emul_path, - p); + td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -330,11 +331,11 @@ svr4_emul_find(p, sgp, prefix, path, pbuf, cflag) } NDFREE(&ndroot, NDF_ONLY_PNBUF); - if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { + if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, td)) != 0) { goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, td)) != 0) { goto done; } diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c index d50f97f..981aef8 100644 --- a/sys/compat/svr4/svr4_termios.c +++ b/sys/compat/svr4/svr4_termios.c @@ -478,9 +478,9 @@ svr4_termios_to_termio(ts, t) } int -svr4_term_ioctl(fp, p, retval, fd, cmd, data) +svr4_term_ioctl(fp, td, retval, fd, cmd, data) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -499,7 +499,7 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data) case SVR4_TCGETA: case SVR4_TCGETS: DPRINTF(("ioctl(TCGET%c);\n", cmd == SVR4_TCGETA ? 'A' : 'S')); - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, td)) != 0) return error; memset(&st, 0, sizeof(st)); @@ -526,7 +526,7 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data) case SVR4_TCSETSF: DPRINTF(("TCSET{A,S,AW,SW,AF,SF}\n")); /* get full BSD termios so we don't lose information */ - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, td)) != 0) return error; switch (cmd) { @@ -577,14 +577,14 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data) print_svr4_termios(&st); #endif /* DEBUG_SVR4 */ - return fo_ioctl(fp, cmd, (caddr_t) &bt, p); + return fo_ioctl(fp, cmd, (caddr_t) &bt, td); case SVR4_TIOCGWINSZ: DPRINTF(("TIOCGWINSZ\n")); { struct svr4_winsize ws; - error = fo_ioctl(fp, TIOCGWINSZ, (caddr_t) &ws, p); + error = fo_ioctl(fp, TIOCGWINSZ, (caddr_t) &ws, td); if (error) return error; return copyout(&ws, data, sizeof(ws)); @@ -597,11 +597,11 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data) if ((error = copyin(data, &ws, sizeof(ws))) != 0) return error; - return fo_ioctl(fp, TIOCSWINSZ, (caddr_t) &ws, p); + return fo_ioctl(fp, TIOCSWINSZ, (caddr_t) &ws, td); } default: DPRINTF(("teleport to STREAMS ioctls...\n")); - return svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, data); + return svr4_stream_ti_ioctl(fp, td, retval, fd, cmd, data); } } diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c index e139016..90cdae1 100644 --- a/sys/compat/svr4/svr4_ttold.c +++ b/sys/compat/svr4/svr4_ttold.c @@ -175,9 +175,9 @@ bsd_ltchars_to_svr4_ltchars(bl, sl) int -svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) +svr4_ttold_ioctl(fp, td, retval, fd, cmd, data) struct file *fp; - struct proc *p; + struct thread *td; register_t *retval; int fd; u_long cmd; @@ -192,7 +192,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) { pid_t pid; - if ((error = fo_ioctl(fp, TIOCGPGRP, (caddr_t) &pid, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGPGRP, (caddr_t) &pid, td)) != 0) return error; DPRINTF(("TIOCGPGRP %d\n", pid)); @@ -211,21 +211,21 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) DPRINTF(("TIOCSPGRP %d\n", pid)); - return fo_ioctl(fp, TIOCSPGRP, (caddr_t) &pid, p); + return fo_ioctl(fp, TIOCSPGRP, (caddr_t) &pid, td); } case SVR4_TIOCGSID: { #if defined(TIOCGSID) pid_t pid; - if ((error = fo_ioctl(fp, TIOCGSID, (caddr_t) &pid, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGSID, (caddr_t) &pid, td)) != 0) return error; DPRINTF(("TIOCGSID %d\n", pid)); return copyout(&pid, data, sizeof(pid)); #else - uprintf("ioctl(TIOCGSID) for pid %d unsupported\n", p->p_pid); + uprintf("ioctl(TIOCGSID) for pid %d unsupported\n", td->td_proc->p_pid); return EINVAL; #endif } @@ -235,7 +235,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct sgttyb bs; struct svr4_sgttyb ss; - error = fo_ioctl(fp, TIOCGETP, (caddr_t) &bs, p); + error = fo_ioctl(fp, TIOCGETP, (caddr_t) &bs, td); if (error) return error; @@ -260,7 +260,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss); #endif /* DEBUG_SVR4 */ cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN; - return fo_ioctl(fp, cmd, (caddr_t) &bs, p); + return fo_ioctl(fp, cmd, (caddr_t) &bs, td); } case SVR4_TIOCGETC: @@ -268,7 +268,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct tchars bt; struct svr4_tchars st; - error = fo_ioctl(fp, TIOCGETC, (caddr_t) &bt, p); + error = fo_ioctl(fp, TIOCGETC, (caddr_t) &bt, td); if (error) return error; @@ -291,7 +291,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) #ifdef DEBUG_SVR4 print_svr4_tchars("SVR4_TIOCSETC", &st); #endif /* DEBUG_SVR4 */ - return fo_ioctl(fp, TIOCSETC, (caddr_t) &bt, p); + return fo_ioctl(fp, TIOCSETC, (caddr_t) &bt, td); } case SVR4_TIOCGLTC: @@ -299,7 +299,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct ltchars bl; struct svr4_ltchars sl; - error = fo_ioctl(fp, TIOCGLTC, (caddr_t) &bl, p); + error = fo_ioctl(fp, TIOCGLTC, (caddr_t) &bl, td); if (error) return error; @@ -322,13 +322,13 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) #ifdef DEBUG_SVR4 print_svr4_ltchars("SVR4_TIOCSLTC", &sl); #endif /* DEBUG_SVR4 */ - return fo_ioctl(fp, TIOCSLTC, (caddr_t) &bl, p); + return fo_ioctl(fp, TIOCSLTC, (caddr_t) &bl, td); } case SVR4_TIOCLGET: { int flags; - if ((error = fo_ioctl(fp, TIOCLGET, (caddr_t) &flags, p)) != 0) + if ((error = fo_ioctl(fp, TIOCLGET, (caddr_t) &flags, td)) != 0) return error; DPRINTF(("SVR4_TIOCLGET %o\n", flags)); return copyout(&flags, data, sizeof(flags)); @@ -356,7 +356,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) } DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags)); - return fo_ioctl(fp, cmd, (caddr_t) &flags, p); + return fo_ioctl(fp, cmd, (caddr_t) &flags, td); } default: diff --git a/sys/compat/svr4/svr4_util.h b/sys/compat/svr4/svr4_util.h index 629edd6..9429c0f 100644 --- a/sys/compat/svr4/svr4_util.h +++ b/sys/compat/svr4/svr4_util.h @@ -53,7 +53,7 @@ static __inline void *stackgap_alloc(caddr_t *, size_t); static __inline caddr_t stackgap_init() { -#define szsigcode (*(curproc->p_sysent->sv_szsigcode)) +#define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode)) return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE); } @@ -68,7 +68,7 @@ stackgap_alloc(sgp, sz) } extern const char svr4_emul_path[]; -int svr4_emul_find __P((struct proc *, caddr_t *, const char *, char *, +int svr4_emul_find __P((struct thread *, caddr_t *, const char *, char *, char **, int)); #define CHECKALT(p, sgp, path, i) \ diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 83bf89a..a707b0f 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -84,7 +84,7 @@ options BLKDEV_IOSIZE=8192 # Options for the VM subsystem options PQ_CACHESIZE=512 # color for 512k/16k cache -options UPAGES=3 # number of 4k stack pages per process +options KSTACK_PAGES=3 # number of 4k stack pages per process # Deprecated options supported for backwards compatibility #options PQ_NOOPT # No coloring #options PQ_LARGECACHE # color for 512k/16k cache @@ -442,7 +442,7 @@ options IPX #IPX/SPX communications protocols options IPXIP #IPX in IP encapsulation (not available) options IPTUNNEL #IP in IPX encapsulation (not available) -options NCP #NetWare Core protocol +#options NCP #NetWare Core protocol options NETATALK #Appletalk communications protocols options NETATALKDEBUG #Appletalk debugging @@ -692,7 +692,7 @@ options HPFS #OS/2 File system options MSDOSFS #MS DOS File System (FAT, FAT32) options NTFS #NT File System options NULLFS #NULL filesystem -options NWFS #NetWare filesystem +#options NWFS #NetWare filesystem options PORTALFS #Portal filesystem options PROCFS #Process filesystem options PSEUDOFS #Pseudo-filesystem framework diff --git a/sys/conf/options.i386 b/sys/conf/options.i386 index 8f89b01..dc83994 100644 --- a/sys/conf/options.i386 +++ b/sys/conf/options.i386 @@ -20,7 +20,7 @@ WLCACHE opt_wavelan.h WLDEBUG opt_wavelan.h COMPAT_OLDISA BROKEN_KEYBOARD_RESET opt_reset.h -UPAGES +KSTACK_PAGES # Options for emulators. These should only be used at config time, so # they are handled like options for static file systems diff --git a/sys/conf/options.pc98 b/sys/conf/options.pc98 index 10909f8..8114e8d 100644 --- a/sys/conf/options.pc98 +++ b/sys/conf/options.pc98 @@ -21,7 +21,7 @@ WLCACHE opt_wavelan.h WLDEBUG opt_wavelan.h COMPAT_OLDISA BROKEN_KEYBOARD_RESET opt_reset.h -UPAGES +KSTACK_PAGES # Options for emulators. These should only be used at config time, so # they are handled like options for static file systems diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c index 6f758de..7298244 100644 --- a/sys/contrib/dev/fla/fla.c +++ b/sys/contrib/dev/fla/fla.c @@ -112,7 +112,7 @@ static struct fla_s { } softc[8]; static int -flaopen(dev_t dev, int flag, int fmt, struct proc *p) +flaopen(dev_t dev, int flag, int fmt, struct thread *td) { struct fla_s *sc; int error; @@ -120,7 +120,7 @@ flaopen(dev_t dev, int flag, int fmt, struct proc *p) if (fla_debug) printf("flaopen(%s %x %x %p)\n", - devtoname(dev), flag, fmt, p); + devtoname(dev), flag, fmt, td); sc = dev->si_drv1; @@ -142,14 +142,14 @@ flaopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -flaclose(dev_t dev, int flags, int fmt, struct proc *p) +flaclose(dev_t dev, int flags, int fmt, struct thread *td) { int error; struct fla_s *sc; if (fla_debug) printf("flaclose(%s %x %x %p)\n", - devtoname(dev), flags, fmt, p); + devtoname(dev), flags, fmt, td); sc = dev->si_drv1; @@ -162,12 +162,12 @@ flaclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -flaioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +flaioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { if (fla_debug) printf("flaioctl(%s %lx %p %x %p)\n", - devtoname(dev), cmd, addr, flags, p); + devtoname(dev), cmd, addr, flags, td); return (ENOIOCTL); } diff --git a/sys/contrib/ipfilter/netinet/ip_fil.c b/sys/contrib/ipfilter/netinet/ip_fil.c index 82778db..149d0c7 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil.c +++ b/sys/contrib/ipfilter/netinet/ip_fil.c @@ -469,8 +469,8 @@ int IPL_EXTERN(ioctl)(dev, cmd, data, mode # if (defined(_KERNEL) && ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || \ (NetBSD >= 199511) || (__FreeBSD_version >= 220000) || \ defined(__OpenBSD__))) -, p) -struct proc *p; +, td) +struct thread *td; # else ) # endif @@ -903,9 +903,9 @@ int IPL_EXTERN(open)(dev_t dev, int flags) int IPL_EXTERN(open)(dev, flags # if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \ (__FreeBSD_version >= 220000) || defined(__OpenBSD__)) && defined(_KERNEL) -, devtype, p) +, devtype, td) int devtype; -struct proc *p; +struct thread *td; # else ) # endif @@ -933,9 +933,9 @@ int IPL_EXTERN(close)(dev_t dev, int flags, int devtype, cred_t *cp) int IPL_EXTERN(close)(dev, flags # if ((_BSDI_VERSION >= 199510) || (BSD >= 199506) || (NetBSD >= 199511) || \ (__FreeBSD_version >= 220000) || defined(__OpenBSD__)) && defined(_KERNEL) -, devtype, p) +, devtype, td) int devtype; -struct proc *p; +struct thread *td; # else ) # endif diff --git a/sys/contrib/ipfilter/netinet/ip_fil.h b/sys/contrib/ipfilter/netinet/ip_fil.h index e53c65e..2934f7d 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil.h +++ b/sys/contrib/ipfilter/netinet/ip_fil.h @@ -558,12 +558,12 @@ extern int iplidentify __P((char *)); (NetBSD >= 199511) || defined(__OpenBSD__) # if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \ defined(__OpenBSD__) || (__FreeBSD_version >= 300000) -extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); +extern int iplioctl __P((dev_t, u_long, caddr_t, int, struct thread *)); # else -extern int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); +extern int iplioctl __P((dev_t, int, caddr_t, int, struct thread *)); # endif -extern int iplopen __P((dev_t, int, int, struct proc *)); -extern int iplclose __P((dev_t, int, int, struct proc *)); +extern int iplopen __P((dev_t, int, int, struct thread *)); +extern int iplclose __P((dev_t, int, int, struct thread *)); # else # ifndef linux extern int iplopen __P((dev_t, int)); diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index cbedb1e..92e0fe6 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -94,16 +94,38 @@ db_ps(dummy1, dummy2, dummy3, dummy4) pp = p; db_printf("%5d %8p %8p %4d %5d %5d %06x %d", - p->p_pid, (volatile void *)p, (void *)p->p_addr, - p->p_ucred ? p->p_ucred->cr_ruid : 0, pp->p_pid, - p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flag, p->p_stat); - if (p->p_wchan) { - db_printf(" %6s %8p", p->p_wmesg, (void *)p->p_wchan); + p->p_pid, + (volatile void *)p, + (void *)p->p_uarea, + p->p_ucred ? p->p_ucred->cr_ruid : 0, + pp->p_pid, + p->p_pgrp ? p->p_pgrp->pg_id : 0, + p->p_flag, + p->p_stat); + if (p->p_flag & P_KSES) { + struct thread *td; + db_printf("(threaded) %s\n", + p->p_comm ? p->p_comm : ""); + FOREACH_THREAD_IN_PROC(p, td) { + db_printf( ". . . . . . . " + ". . . . . . . . "); + if (td->td_wchan) { + db_printf("%6s %8p", + td->td_wmesg, (void *)td->td_wchan); + } else { + db_printf("--not blocked--"); + } + } } else { - db_printf(" "); + if (p->p_thread.td_wchan) { + db_printf(" %6s %8p", + p->p_thread.td_wmesg, + (void *)p->p_thread.td_wchan); + } else { + db_printf(" "); + } + db_printf(" %s\n", p->p_comm ? p->p_comm : ""); } - db_printf(" %s\n", p->p_comm ? p->p_comm : ""); - p = LIST_NEXT(p, p_list); if (p == NULL && np > 0) p = LIST_FIRST(&zombproc); diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index 5f0ef28..4eef4e7 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -2058,7 +2058,7 @@ aac_describe_code(struct aac_code_lookup *table, u_int32_t code) */ static int -aac_open(dev_t dev, int flags, int fmt, struct proc *p) +aac_open(dev_t dev, int flags, int fmt, struct thread *td) { struct aac_softc *sc; @@ -2076,7 +2076,7 @@ aac_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -aac_close(dev_t dev, int flags, int fmt, struct proc *p) +aac_close(dev_t dev, int flags, int fmt, struct thread *td) { struct aac_softc *sc; @@ -2091,7 +2091,7 @@ aac_close(dev_t dev, int flags, int fmt, struct proc *p) } static int -aac_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) +aac_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { union aac_statrequest *as; struct aac_softc *sc; @@ -2427,20 +2427,20 @@ SYSUNINIT(aac_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, MODULE_DEPEND(aac, linux, 1, 1, 1); static int -aac_linux_ioctl(struct proc *p, struct linux_ioctl_args *args) +aac_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) { struct file *fp; u_long cmd; debug_called(2); - fp = p->p_fd->fd_ofiles[args->fd]; + fp = td->td_proc->p_fd->fd_ofiles[args->fd]; cmd = args->cmd; /* * Pass the ioctl off to our standard handler. */ - return(fo_ioctl(fp, cmd, (caddr_t)args->arg, p)); + return(fo_ioctl(fp, cmd, (caddr_t)args->arg, td)); } #endif diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c index 3917fa1..77f8469 100644 --- a/sys/dev/aac/aac_disk.c +++ b/sys/dev/aac/aac_disk.c @@ -127,7 +127,7 @@ SYSCTL_UINT(_hw_aac, OID_AUTO, iosize_max, CTLFLAG_RD, &aac_iosize_max, 0, * basic device geometry paramters. */ static int -aac_disk_open(dev_t dev, int flags, int fmt, struct proc *p) +aac_disk_open(dev_t dev, int flags, int fmt, struct thread *td) { struct aac_disk *sc; struct disklabel *label; @@ -162,7 +162,7 @@ aac_disk_open(dev_t dev, int flags, int fmt, struct proc *p) * Handle last close of the disk device. */ static int -aac_disk_close(dev_t dev, int flags, int fmt, struct proc *p) +aac_disk_close(dev_t dev, int flags, int fmt, struct thread *td) { struct aac_disk *sc; diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 49c6266..3edd3f8 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1590,19 +1590,19 @@ acpi_deregister_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg } static int -acpiopen(dev_t dev, int flag, int fmt, struct proc *p) +acpiopen(dev_t dev, int flag, int fmt, struct thread *td) { return(0); } static int -acpiclose(dev_t dev, int flag, int fmt, struct proc *p) +acpiclose(dev_t dev, int flag, int fmt, struct thread *td) { return(0); } static int -acpiioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +acpiioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct acpi_softc *sc; struct acpi_ioctl_hook *hp; diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 333c4c8..138fe45 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -270,7 +270,7 @@ agp_generic_detach(device_t dev) { struct agp_softc *sc = device_get_softc(dev); bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture); - lockmgr(&sc->as_lock, LK_DRAIN, 0, curproc); + lockmgr(&sc->as_lock, LK_DRAIN, 0, curthread); lockdestroy(&sc->as_lock); destroy_dev(sc->as_devnode); agp_flush_cache(); @@ -389,7 +389,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, vm_page_t m; int error; - lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curthread); if (mem->am_is_bound) { device_printf(dev, "memory already bound\n"); @@ -450,7 +450,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, OFF_TO_IDX(k)); vm_page_unwire(m, 0); } - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return error; } } @@ -471,7 +471,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, mem->am_offset = offset; mem->am_is_bound = 1; - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return 0; } @@ -483,7 +483,7 @@ agp_generic_unbind_memory(device_t dev, struct agp_memory *mem) vm_page_t m; int i; - lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curthread); if (!mem->am_is_bound) { device_printf(dev, "memory is not bound\n"); @@ -508,7 +508,7 @@ agp_generic_unbind_memory(device_t dev, struct agp_memory *mem) mem->am_offset = 0; mem->am_is_bound = 0; - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return 0; } @@ -645,7 +645,7 @@ agp_unbind_user(device_t dev, agp_unbind *unbind) } static int -agp_open(dev_t kdev, int oflags, int devtype, struct proc *p) +agp_open(dev_t kdev, int oflags, int devtype, struct thread *td) { device_t dev = KDEV2DEV(kdev); struct agp_softc *sc = device_get_softc(dev); @@ -659,7 +659,7 @@ agp_open(dev_t kdev, int oflags, int devtype, struct proc *p) } static int -agp_close(dev_t kdev, int fflag, int devtype, struct proc *p) +agp_close(dev_t kdev, int fflag, int devtype, struct thread *td) { device_t dev = KDEV2DEV(kdev); struct agp_softc *sc = device_get_softc(dev); @@ -676,7 +676,7 @@ agp_close(dev_t kdev, int fflag, int devtype, struct proc *p) } static int -agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct proc *p) +agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct thread *td) { device_t dev = KDEV2DEV(kdev); diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index a8be136..2b5eca1 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -340,7 +340,7 @@ amr_submit_bio(struct amr_softc *sc, struct bio *bio) * Accept an open operation on the control device. */ int -amr_open(dev_t dev, int flags, int fmt, struct proc *p) +amr_open(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct amr_softc *sc = devclass_get_softc(amr_devclass, unit); @@ -355,7 +355,7 @@ amr_open(dev_t dev, int flags, int fmt, struct proc *p) * Accept the last close on the control device. */ int -amr_close(dev_t dev, int flags, int fmt, struct proc *p) +amr_close(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct amr_softc *sc = devclass_get_softc(amr_devclass, unit); @@ -370,7 +370,7 @@ amr_close(dev_t dev, int flags, int fmt, struct proc *p) * Handle controller-specific control operations. */ int -amr_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +amr_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { struct amr_softc *sc = (struct amr_softc *)dev->si_drv1; int *arg = (int *)addr; diff --git a/sys/dev/amr/amr_disk.c b/sys/dev/amr/amr_disk.c index e6f016a..38784d3 100644 --- a/sys/dev/amr/amr_disk.c +++ b/sys/dev/amr/amr_disk.c @@ -100,7 +100,7 @@ static driver_t amrd_driver = { DRIVER_MODULE(amrd, amr, amrd_driver, amrd_devclass, 0, 0); static int -amrd_open(dev_t dev, int flags, int fmt, struct proc *p) +amrd_open(dev_t dev, int flags, int fmt, struct thread *td) { struct amrd_softc *sc = (struct amrd_softc *)dev->si_drv1; struct disklabel *label; @@ -129,7 +129,7 @@ amrd_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -amrd_close(dev_t dev, int flags, int fmt, struct proc *p) +amrd_close(dev_t dev, int flags, int fmt, struct thread *td) { struct amrd_softc *sc = (struct amrd_softc *)dev->si_drv1; @@ -142,7 +142,7 @@ amrd_close(dev_t dev, int flags, int fmt, struct proc *p) } static int -amrd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +amrd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { return (ENOTTY); diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 87ad7b1..ed34c4a 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -94,6 +94,7 @@ #include <sys/systm.h> #include <sys/sockio.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/kernel.h> #include <sys/socket.h> #ifdef ANCACHE diff --git a/sys/dev/asr/asr.c b/sys/dev/asr/asr.c index f755c54..32062a0 100644 --- a/sys/dev/asr/asr.c +++ b/sys/dev/asr/asr.c @@ -216,6 +216,7 @@ static dpt_sig_S ASR_sig = { #include <sys/malloc.h> #include <sys/conf.h> #include <sys/disklabel.h> +#include <sys/proc.h> #include <sys/bus.h> #include <machine/resource.h> #include <machine/bus.h> @@ -457,17 +458,17 @@ STATIC int asr_ioctl __P(( IN u_long cmd, INOUT caddr_t data, int flag, - struct proc * proc)); + struct thread * td)); STATIC int asr_open __P(( IN dev_t dev, int32_t flags, int32_t ifmt, - IN struct proc * proc)); + IN struct thread * td)); STATIC int asr_close __P(( dev_t dev, int flags, int ifmt, - struct proc * proc)); + struct thread * td)); STATIC int asr_intr __P(( IN Asr_softc_t * sc)); STATIC void asr_timeout __P(( @@ -3863,7 +3864,7 @@ asr_open( IN dev_t dev, int32_t flags, int32_t ifmt, - IN struct proc * proc) + IN struct thread * td) { int s; OUT int error; @@ -3876,7 +3877,7 @@ asr_open( s = splcam (); if (ASR_ctlr_held) { error = EBUSY; - } else if ((error = suser(proc)) == 0) { + } else if ((error = suser(td->td_proc)) == 0) { ++ASR_ctlr_held; } splx(s); @@ -3888,12 +3889,12 @@ asr_close( dev_t dev, int flags, int ifmt, - struct proc * proc) + struct thread * td) { UNREFERENCED_PARAMETER(dev); UNREFERENCED_PARAMETER(flags); UNREFERENCED_PARAMETER(ifmt); - UNREFERENCED_PARAMETER(proc); + UNREFERENCED_PARAMETER(td); ASR_ctlr_held = 0; return (0); @@ -4387,13 +4388,13 @@ asr_ioctl( IN u_long cmd, INOUT caddr_t data, int flag, - struct proc * proc) + struct thread * td) { int i, j; OUT int error = 0; Asr_softc_t * sc = ASR_get_sc (dev); UNREFERENCED_PARAMETER(flag); - UNREFERENCED_PARAMETER(proc); + UNREFERENCED_PARAMETER(td); if (sc != (Asr_softc_t *)NULL) switch(cmd) { diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index b6544d8..50a59c3 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -285,7 +285,7 @@ ata_resume(device_t dev) } static int -ataioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +ataioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { struct ata_cmd *iocmd = (struct ata_cmd *)addr; device_t device; diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 59aa250..7e5470a 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -252,7 +252,7 @@ ad_detach(struct ad_softc *adp, int flush) } static int -adopen(dev_t dev, int flags, int fmt, struct proc *p) +adopen(dev_t dev, int flags, int fmt, struct thread *td) { struct ad_softc *adp = dev->si_drv1; @@ -262,7 +262,7 @@ adopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -adclose(dev_t dev, int flags, int fmt, struct proc *p) +adclose(dev_t dev, int flags, int fmt, struct thread *td) { struct ad_softc *adp = dev->si_drv1; diff --git a/sys/dev/ata/ata-raid.c b/sys/dev/ata/ata-raid.c index 161d6b8..121110f 100644 --- a/sys/dev/ata/ata-raid.c +++ b/sys/dev/ata/ata-raid.c @@ -137,7 +137,7 @@ ar_attach(struct ar_softc *raid) } static int -aropen(dev_t dev, int flags, int fmt, struct proc *p) +aropen(dev_t dev, int flags, int fmt, struct thread *td) { struct ar_softc *rdp = dev->si_drv1; struct disklabel *dl; diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 31d86e9..f69e7e7 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -33,6 +33,7 @@ #include <sys/ata.h> #include <sys/kernel.h> #include <sys/malloc.h> +#include <sys/proc.h> #include <sys/bio.h> #include <sys/bus.h> #include <sys/disklabel.h> @@ -499,7 +500,7 @@ msf2lba(u_int8_t m, u_int8_t s, u_int8_t f) } static int -acdopen(dev_t dev, int flags, int fmt, struct proc *p) +acdopen(dev_t dev, int flags, int fmt, struct thread *td) { struct acd_softc *cdp = dev->si_drv1; @@ -523,7 +524,7 @@ acdopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -acdclose(dev_t dev, int flags, int fmt, struct proc *p) +acdclose(dev_t dev, int flags, int fmt, struct thread *td) { struct acd_softc *cdp = dev->si_drv1; @@ -542,7 +543,7 @@ acdclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct acd_softc *cdp = dev->si_drv1; int error = 0; @@ -595,7 +596,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) break; case CDIOCRESET: - error = suser(p); + error = suser(td->td_proc); if (error) break; error = atapi_test_ready(cdp->atp); diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index a419d2b..ba47781 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -239,7 +239,7 @@ afd_describe(struct afd_softc *fdp) } static int -afdopen(dev_t dev, int flags, int fmt, struct proc *p) +afdopen(dev_t dev, int flags, int fmt, struct thread *td) { struct afd_softc *fdp = dev->si_drv1; struct disklabel *label = &fdp->disk.d_label; @@ -266,7 +266,7 @@ afdopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -afdclose(dev_t dev, int flags, int fmt, struct proc *p) +afdclose(dev_t dev, int flags, int fmt, struct thread *td) { struct afd_softc *fdp = dev->si_drv1; @@ -276,7 +276,7 @@ afdclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -afdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +afdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct afd_softc *fdp = dev->si_drv1; diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 98114c3..cb8b893 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -255,7 +255,7 @@ ast_describe(struct ast_softc *stp) } static int -astopen(dev_t dev, int flags, int fmt, struct proc *p) +astopen(dev_t dev, int flags, int fmt, struct thread *td) { struct ast_softc *stp = dev->si_drv1; @@ -281,7 +281,7 @@ astopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -astclose(dev_t dev, int flags, int fmt, struct proc *p) +astclose(dev_t dev, int flags, int fmt, struct thread *td) { struct ast_softc *stp = dev->si_drv1; @@ -310,7 +310,7 @@ astclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -astioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +astioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct ast_softc *stp = dev->si_drv1; int error = 0; diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 1bb5b71..1fb37ea 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -1164,7 +1164,7 @@ psmdetach(device_t dev) } static int -psmopen(dev_t dev, int flag, int fmt, struct proc *p) +psmopen(dev_t dev, int flag, int fmt, struct thread *td) { int unit = PSM_UNIT(dev); struct psm_softc *sc; @@ -1248,7 +1248,7 @@ psmopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -psmclose(dev_t dev, int flag, int fmt, struct proc *p) +psmclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit = PSM_UNIT(dev); struct psm_softc *sc = PSM_SOFTC(unit); @@ -1516,7 +1516,7 @@ unblock_mouse_data(struct psm_softc *sc, int c) } static int -psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); mousemode_t mode; @@ -2237,7 +2237,7 @@ psmintr(void *arg) } static int -psmpoll(dev_t dev, int events, struct proc *p) +psmpoll(dev_t dev, int events, struct thread *td) { struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); int s; @@ -2249,7 +2249,7 @@ psmpoll(dev_t dev, int events, struct proc *p) if (sc->queue.count > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->rsel); + selrecord(td, &sc->rsel); } splx(s); diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c index 17c58ba..ab76ea0 100644 --- a/sys/dev/awi/awi.c +++ b/sys/dev/awi/awi.c @@ -99,6 +99,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/malloc.h> #include <sys/socket.h> #include <sys/sockio.h> diff --git a/sys/dev/awi/awi_wep.c b/sys/dev/awi/awi_wep.c index d826d32..f9347c5 100644 --- a/sys/dev/awi/awi_wep.c +++ b/sys/dev/awi/awi_wep.c @@ -54,6 +54,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/malloc.h> #include <sys/socket.h> #include <sys/errno.h> diff --git a/sys/dev/awi/awi_wicfg.c b/sys/dev/awi/awi_wicfg.c index e0554d7..97f9fce 100644 --- a/sys/dev/awi/awi_wicfg.c +++ b/sys/dev/awi/awi_wicfg.c @@ -45,6 +45,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/malloc.h> #include <sys/socket.h> #include <sys/errno.h> diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c index 50e8511..528f09a 100644 --- a/sys/dev/bktr/bktr_core.c +++ b/sys/dev/bktr/bktr_core.c @@ -1277,7 +1277,7 @@ vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) * video ioctls */ int -video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct proc* pr ) +video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct thread* td ) { volatile u_char c_temp; unsigned int temp; @@ -1565,7 +1565,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro break; } bktr->signal = *(int *) arg; - bktr->proc = pr; + bktr->proc = td->td_proc; break; case METEORGSIGNAL: @@ -1886,7 +1886,7 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro * tuner ioctls */ int -tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct proc* pr ) +tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct thread* td ) { int tmp_int; unsigned int temp, temp1; diff --git a/sys/dev/bktr/bktr_core.h b/sys/dev/bktr/bktr_core.h index bf41a99..5948ab6 100644 --- a/sys/dev/bktr/bktr_core.h +++ b/sys/dev/bktr/bktr_core.h @@ -82,13 +82,13 @@ int video_open( bktr_ptr_t bktr ); int video_close( bktr_ptr_t bktr ); int video_read( bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio ); int video_ioctl( bktr_ptr_t bktr, int unit, - ioctl_cmd_t cmd, caddr_t arg, struct proc* pr ); + ioctl_cmd_t cmd, caddr_t arg, struct thread* pr ); int tuner_open( bktr_ptr_t bktr ); int tuner_close( bktr_ptr_t bktr ); int tuner_ioctl( bktr_ptr_t bktr, int unit, - ioctl_cmd_t cmd, caddr_t arg, struct proc* pr ); + ioctl_cmd_t cmd, caddr_t arg, struct thread* pr ); int vbi_open( bktr_ptr_t bktr ); int vbi_close( bktr_ptr_t bktr ); diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c index f916864..cc79745 100644 --- a/sys/dev/bktr/bktr_os.c +++ b/sys/dev/bktr/bktr_os.c @@ -559,7 +559,7 @@ get_bktr_mem( int unit, unsigned size ) * */ int -bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) +bktr_open( dev_t dev, int flags, int fmt, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -639,7 +639,7 @@ bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) * */ int -bktr_close( dev_t dev, int flags, int fmt, struct proc *p ) +bktr_close( dev_t dev, int flags, int fmt, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -716,7 +716,7 @@ bktr_write( dev_t dev, struct uio *uio, int ioflag ) * */ int -bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) +bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -735,9 +735,9 @@ bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) switch ( FUNCTION( minor(dev) ) ) { case VIDEO_DEV: - return( video_ioctl( bktr, unit, cmd, arg, pr ) ); + return( video_ioctl( bktr, unit, cmd, arg, td ) ); case TUNER_DEV: - return( tuner_ioctl( bktr, unit, cmd, arg, pr ) ); + return( tuner_ioctl( bktr, unit, cmd, arg, td ) ); } return( ENXIO ); @@ -777,7 +777,7 @@ bktr_mmap( dev_t dev, vm_offset_t offset, int nprot ) return( atop(vtophys(bktr->bigbuf) + offset) ); } -int bktr_poll( dev_t dev, int events, struct proc *p) +int bktr_poll( dev_t dev, int events, struct thread *td) { int unit; bktr_ptr_t bktr; @@ -800,7 +800,7 @@ int bktr_poll( dev_t dev, int events, struct proc *p) switch ( FUNCTION( minor(dev) ) ) { case VBI_DEV: if(bktr->vbisize == 0) - selrecord(p, &bktr->vbi_select); + selrecord(td, &bktr->vbi_select); else revents |= events & (POLLIN | POLLRDNORM); break; @@ -1064,7 +1064,7 @@ get_bktr_mem( int unit, unsigned size ) * */ int -bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) +bktr_open( dev_t dev, int flags, int fmt, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -1127,7 +1127,7 @@ bktr_open( dev_t dev, int flags, int fmt, struct proc *p ) * */ int -bktr_close( dev_t dev, int flags, int fmt, struct proc *p ) +bktr_close( dev_t dev, int flags, int fmt, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -1188,7 +1188,7 @@ bktr_write( dev_t dev, struct uio *uio, int ioflag ) * */ int -bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) +bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thread *td ) { bktr_ptr_t bktr; int unit; @@ -1204,9 +1204,9 @@ bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr ) switch ( FUNCTION( minor(dev) ) ) { case VIDEO_DEV: - return( video_ioctl( bktr, unit, cmd, arg, pr ) ); + return( video_ioctl( bktr, unit, cmd, arg, td ) ); case TUNER_DEV: - return( tuner_ioctl( bktr, unit, cmd, arg, pr ) ); + return( tuner_ioctl( bktr, unit, cmd, arg, td ) ); } return( ENXIO ); @@ -1242,7 +1242,7 @@ int bktr_mmap( dev_t dev, vm_offset_t offset, int nprot ) return( i386_btop(vtophys(bktr->bigbuf) + offset) ); } -int bktr_poll( dev_t dev, int events, struct proc *p) +int bktr_poll( dev_t dev, int events, struct thread *td) { int unit; bktr_ptr_t bktr; @@ -1605,7 +1605,7 @@ free_bktr_mem(bktr, dmap, kva) * */ int -bktr_open(dev_t dev, int flags, int fmt, struct proc *p) +bktr_open(dev_t dev, int flags, int fmt, struct thread *td) { bktr_ptr_t bktr; int unit; @@ -1638,7 +1638,7 @@ bktr_open(dev_t dev, int flags, int fmt, struct proc *p) * */ int -bktr_close(dev_t dev, int flags, int fmt, struct proc *p) +bktr_close(dev_t dev, int flags, int fmt, struct thread *td) { bktr_ptr_t bktr; int unit; @@ -1697,7 +1697,7 @@ bktr_write(dev_t dev, struct uio *uio, int ioflag) * */ int -bktr_ioctl(dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr) +bktr_ioctl(dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thread *td) { bktr_ptr_t bktr; int unit; diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index 68df08e..090087b 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -202,8 +202,8 @@ static void ccdiodone(struct bio *bp); static void ccdstart(struct ccd_s *, struct bio *); static void ccdinterleave(struct ccd_s *, int); static void ccdintr(struct ccd_s *, struct bio *); -static int ccdinit(struct ccd_s *, char **, struct proc *); -static int ccdlookup(char *, struct proc *p, struct vnode **); +static int ccdinit(struct ccd_s *, char **, struct thread *); +static int ccdlookup(char *, struct thread *p, struct vnode **); static void ccdbuffer(struct ccdbuf **ret, struct ccd_s *, struct bio *, daddr_t, caddr_t, long); static void ccdgetdisklabel(dev_t); @@ -381,7 +381,7 @@ ccd_modevent(module_t mod, int type, void *data) DEV_MODULE(ccd, ccd_modevent, NULL); static int -ccdinit(struct ccd_s *cs, char **cpaths, struct proc *p) +ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) { struct ccdcinfo *ci = NULL; /* XXX */ size_t size; @@ -438,7 +438,7 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct proc *p) * Get partition information for the component. */ if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, p->p_ucred, p)) != 0) { + FREAD, td->td_proc->p_ucred, td)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccd%d: %s: ioctl failed, error = %d\n", @@ -701,7 +701,7 @@ ccdinterleave(struct ccd_s *cs, int unit) /* ARGSUSED */ static int -ccdopen(dev_t dev, int flags, int fmt, struct proc *p) +ccdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit = ccdunit(dev); struct ccd_s *cs; @@ -746,7 +746,7 @@ ccdopen(dev_t dev, int flags, int fmt, struct proc *p) /* ARGSUSED */ static int -ccdclose(dev_t dev, int flags, int fmt, struct proc *p) +ccdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit = ccdunit(dev); struct ccd_s *cs; @@ -770,7 +770,7 @@ ccdclose(dev_t dev, int flags, int fmt, struct proc *p) cs->sc_openmask &= ~(1 << part); /* collect "garbage" if possible */ if (!IS_INITED(cs) && (cs->sc_flags & CCDF_WANTED) == 0) - ccddestroy(cs, p); + ccddestroy(cs, td->td_proc); else ccdunlock(cs); return (0); @@ -1238,7 +1238,7 @@ ccdiodone(struct bio *ibp) } static int -ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit = ccdunit(dev); int i, j, lookedup = 0, error = 0; @@ -1317,10 +1317,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (ccddebug & CCDB_INIT) printf("ccdioctl: lookedup = %d\n", lookedup); #endif - if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) { + if ((error = ccdlookup(cpp[i], td, &vpp[i])) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); @@ -1334,10 +1334,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) /* * Initialize the ccd. Fills in the softc for us. */ - if ((error = ccdinit(cs, cpp, p)) != 0) { + if ((error = ccdinit(cs, cpp, td)) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); /* * We can't ccddestroy() cs just yet, because nothing * prevents user-level app to do another ioctl() @@ -1398,7 +1398,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) cs->sc_cinfo[i].ci_vp); #endif (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); free(cs->sc_cinfo[i].ci_path, M_DEVBUF); } @@ -1557,7 +1557,7 @@ ccdsize(dev_t dev) struct ccd_s *cs; int part, size; - if (ccdopen(dev, 0, S_IFCHR, curproc)) + if (ccdopen(dev, 0, S_IFCHR, curthread)) return (-1); cs = ccdfind(ccdunit(dev)); @@ -1571,7 +1571,7 @@ ccdsize(dev_t dev) else size = cs->sc_label.d_partitions[part].p_size; - if (ccdclose(dev, 0, S_IFCHR, curproc)) + if (ccdclose(dev, 0, S_IFCHR, curthread)) return (-1); return (size); @@ -1591,13 +1591,13 @@ ccddump(dev_t dev) * set *vpp to the file's vnode. */ static int -ccdlookup(char *path, struct proc *p, struct vnode **vpp) +ccdlookup(char *path, struct thread *td, struct vnode **vpp) { struct nameidata nd; struct vnode *vp; int error, flags; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, td); flags = FREAD | FWRITE; if ((error = vn_open(&nd, &flags, 0)) != 0) { #ifdef DEBUG @@ -1621,15 +1621,15 @@ ccdlookup(char *path, struct proc *p, struct vnode **vpp) vprint("ccdlookup: vnode info", vp); #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); bad: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); /* vn_close does vrele() for vp */ - (void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p); + (void)vn_close(vp, FREAD|FWRITE, td->td_proc->p_ucred, td); return (error); } diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 9d6f2bb..728ea0a 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -662,11 +662,11 @@ cyattach_common(cy_iobase, cy_align) } static int -sioopen(dev, flag, mode, p) +sioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -718,7 +718,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -847,11 +847,11 @@ out: } static int -sioclose(dev, flag, mode, p) +sioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int mynor; @@ -1605,12 +1605,12 @@ siointr1(com) #endif static int -sioioctl(dev, cmd, data, flag, p) +sioioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -1639,7 +1639,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1689,7 +1689,7 @@ sioioctl(dev, cmd, data, flag, p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); s = spltty(); @@ -1738,7 +1738,7 @@ sioioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 9d6f2bb..728ea0a 100644 --- a/sys/dev/cy/cy_isa.c +++ b/sys/dev/cy/cy_isa.c @@ -662,11 +662,11 @@ cyattach_common(cy_iobase, cy_align) } static int -sioopen(dev, flag, mode, p) +sioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -718,7 +718,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -847,11 +847,11 @@ out: } static int -sioclose(dev, flag, mode, p) +sioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int mynor; @@ -1605,12 +1605,12 @@ siointr1(com) #endif static int -sioioctl(dev, cmd, data, flag, p) +sioioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -1639,7 +1639,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1689,7 +1689,7 @@ sioioctl(dev, cmd, data, flag, p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); s = spltty(); @@ -1738,7 +1738,7 @@ sioioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/dgb/dgb.c b/sys/dev/dgb/dgb.c index c675485..fa27d31 100644 --- a/sys/dev/dgb/dgb.c +++ b/sys/dev/dgb/dgb.c @@ -959,11 +959,11 @@ load_fep: /* ARGSUSED */ static int -dgbopen(dev, flag, mode, p) +dgbopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct dgb_softc *sc; struct tty *tp; @@ -1049,7 +1049,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -1139,11 +1139,11 @@ out: /*ARGSUSED*/ static int -dgbclose(dev, flag, mode, p) +dgbclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { int mynor; struct tty *tp; @@ -1499,12 +1499,12 @@ dgbpoll(unit_c) } static int -dgbioctl(dev, cmd, data, flag, p) +dgbioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct dgb_softc *sc; int unit, pnum; @@ -1547,7 +1547,7 @@ dgbioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1622,7 +1622,7 @@ dgbioctl(dev, cmd, data, flag, p) if(cmd==TIOCSETAW || cmd==TIOCSETAF) port->mustdrain=1; - error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, p); + error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; s = spltty(); @@ -1769,7 +1769,7 @@ dgbioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/digi/digi.c b/sys/dev/digi/digi.c index 6b29a5a..cab0a17 100644 --- a/sys/dev/digi/digi.c +++ b/sys/dev/digi/digi.c @@ -723,7 +723,7 @@ digi_disc_optim(struct tty *tp, struct termios *t, struct digi_p *port) } int -digiopen(dev_t dev, int flag, int mode, struct proc *p) +digiopen(dev_t dev, int flag, int mode, struct thread *td) { struct digi_softc *sc; struct tty *tp; @@ -801,7 +801,7 @@ open_top: } goto open_top; } - if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) { + if (tp->t_state & TS_XCLUDE && td->td_proc->p_ucred->cr_uid != 0) { error = EBUSY; goto out; } @@ -888,7 +888,7 @@ out: } int -digiclose(dev_t dev, int flag, int mode, struct proc *p) +digiclose(dev_t dev, int flag, int mode, struct thread *td) { int mynor; struct tty *tp; @@ -1090,7 +1090,7 @@ digi_loadmoduledata(struct digi_softc *sc) } static int -digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit, pnum, mynor, error, s; struct digi_softc *sc; @@ -1164,7 +1164,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1285,7 +1285,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, p); + error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, td); if (error == 0 && cmd == TIOCGETA) ((struct termios *)data)->c_iflag |= port->c_iflag; @@ -1335,7 +1335,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) *(int *)data = digimctl(port, 0, DMGET); break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c index 75d9b44..5bfd303 100644 --- a/sys/dev/fb/fb.c +++ b/sys/dev/fb/fb.c @@ -439,7 +439,7 @@ fb_detach(dev_t dev, video_adapter_t *adp, struct cdevsw *cdevsw) } static int -fbopen(dev_t dev, int flag, int mode, struct proc *p) +fbopen(dev_t dev, int flag, int mode, struct thread *td) { int unit; @@ -449,11 +449,11 @@ fbopen(dev_t dev, int flag, int mode, struct proc *p) if (vidcdevsw[unit] == NULL) return ENXIO; return (*vidcdevsw[unit]->d_open)(makedev(0, adapter[unit]->va_minor), - flag, mode, p); + flag, mode, td); } static int -fbclose(dev_t dev, int flag, int mode, struct proc *p) +fbclose(dev_t dev, int flag, int mode, struct thread *td) { int unit; @@ -461,7 +461,7 @@ fbclose(dev_t dev, int flag, int mode, struct proc *p) if (vidcdevsw[unit] == NULL) return ENXIO; return (*vidcdevsw[unit]->d_close)(makedev(0, adapter[unit]->va_minor), - flag, mode, p); + flag, mode, td); } static int @@ -489,7 +489,7 @@ fbwrite(dev_t dev, struct uio *uio, int flag) } static int -fbioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) +fbioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { int unit; @@ -497,7 +497,7 @@ fbioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) if (vidcdevsw[unit] == NULL) return ENXIO; return (*vidcdevsw[unit]->d_ioctl)(makedev(0, adapter[unit]->va_minor), - cmd, arg, flag, p); + cmd, arg, flag, td); } static int @@ -523,7 +523,7 @@ DEV_DRIVER_MODULE(fb, ???, fb_driver, fb_devclass, fb_cdevsw, 0, 0); */ int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode, - struct proc *p) + struct thread *td) { int s; @@ -535,7 +535,7 @@ int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode, } int genfbclose(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode, - struct proc *p) + struct thread *td) { int s; @@ -578,7 +578,7 @@ int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio, } int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd, - caddr_t arg, int flag, struct proc *p) + caddr_t arg, int flag, struct thread *td) { int error; diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h index e8a8513..1fcaf13 100644 --- a/sys/dev/fb/fbreg.h +++ b/sys/dev/fb/fbreg.h @@ -184,15 +184,15 @@ typedef struct genfb_softc { } genfb_softc_t; int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, - int flag, int mode, struct proc *p); + int flag, int mode, struct thread *td); int genfbclose(genfb_softc_t *sc, video_adapter_t *adp, - int flag, int mode, struct proc *p); + int flag, int mode, struct thread *td); int genfbread(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio, int flag); int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio, int flag); int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, - u_long cmd, caddr_t arg, int flag, struct proc *p); + u_long cmd, caddr_t arg, int flag, struct thread *td); int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_offset_t offset, int prot); diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c index 838228b..19d6f1f 100644 --- a/sys/dev/fb/vga.c +++ b/sys/dev/fb/vga.c @@ -96,20 +96,20 @@ vga_attach_unit(int unit, vga_softc_t *sc, int flags) #ifdef FB_INSTALL_CDEV int -vga_open(dev_t dev, vga_softc_t *sc, int flag, int mode, struct proc *p) +vga_open(dev_t dev, vga_softc_t *sc, int flag, int mode, struct thread *td) { if (sc == NULL) return ENXIO; if (mode & (O_CREAT | O_APPEND | O_TRUNC)) return ENODEV; - return genfbopen(&sc->gensc, sc->adp, flag, mode, p); + return genfbopen(&sc->gensc, sc->adp, flag, mode, td); } int -vga_close(dev_t dev, vga_softc_t *sc, int flag, int mode, struct proc *p) +vga_close(dev_t dev, vga_softc_t *sc, int flag, int mode, struct thread *td) { - return genfbclose(&sc->gensc, sc->adp, flag, mode, p); + return genfbclose(&sc->gensc, sc->adp, flag, mode, td); } int @@ -126,9 +126,9 @@ vga_write(dev_t dev, vga_softc_t *sc, struct uio *uio, int flag) int vga_ioctl(dev_t dev, vga_softc_t *sc, u_long cmd, caddr_t arg, int flag, - struct proc *p) + struct thread *td) { - return genfbioctl(&sc->gensc, sc->adp, cmd, arg, flag, p); + return genfbioctl(&sc->gensc, sc->adp, cmd, arg, flag, td); } int diff --git a/sys/dev/fb/vgareg.h b/sys/dev/fb/vgareg.h index d50e5f2..f59c7ee 100644 --- a/sys/dev/fb/vgareg.h +++ b/sys/dev/fb/vgareg.h @@ -79,13 +79,13 @@ int vga_attach_unit(int unit, vga_softc_t *sc, int flags); #ifdef FB_INSTALL_CDEV int vga_open(dev_t dev, vga_softc_t *sc, int flag, int mode, - struct proc *p); + struct thread *td); int vga_close(dev_t dev, vga_softc_t *sc, int flag, int mode, - struct proc *p); + struct thread *td); int vga_read(dev_t dev, vga_softc_t *sc, struct uio *uio, int flag); int vga_write(dev_t dev, vga_softc_t *sc, struct uio *uio, int flag); int vga_ioctl(dev_t dev, vga_softc_t *sc, u_long cmd, caddr_t arg, - int flag, struct proc *p); + int flag, struct thread *td); int vga_mmap(dev_t dev, vga_softc_t *sc, vm_offset_t offset, int prot); #endif diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index f896b33..845f520 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -1519,7 +1519,7 @@ out_fdc(struct fdc_data *fdc, int x) * auxiliary functions). */ int -Fdopen(dev_t dev, int flags, int mode, struct proc *p) +Fdopen(dev_t dev, int flags, int mode, struct thread *td) { fdu_t fdu = FDUNIT(minor(dev)); int type = FDTYPE(minor(dev)); @@ -1614,7 +1614,7 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p) } int -fdclose(dev_t dev, int flags, int mode, struct proc *p) +fdclose(dev_t dev, int flags, int mode, struct thread *td) { fdu_t fdu = FDUNIT(minor(dev)); struct fd_data *fd; @@ -2473,7 +2473,7 @@ fdmisccmd(dev_t dev, u_int cmd, void *data) } static int -fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { fdu_t fdu; fd_p fd; @@ -2545,7 +2545,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) case FD_STYPE: /* set drive type */ /* this is considered harmful; only allow for superuser */ - if (suser(p) != 0) + if (suser_td(td) != 0) return (EPERM); *fd->ft = *(struct fd_type *)addr; break; @@ -2569,7 +2569,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) #endif case FD_CLRERR: - if (suser(p) != 0) + if (suser_td(td) != 0) return (EPERM); fd->fdc->fdc_errs = 0; break; diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c index 5358e5d..a545cf2 100644 --- a/sys/dev/ida/ida_disk.c +++ b/sys/dev/ida/ida_disk.c @@ -110,7 +110,7 @@ idad_getsoftc(dev_t dev) } static int -idad_open(dev_t dev, int flags, int fmt, struct proc *p) +idad_open(dev_t dev, int flags, int fmt, struct thread *td) { struct idad_softc *drv; struct disklabel *label; @@ -133,7 +133,7 @@ idad_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -idad_close(dev_t dev, int flags, int fmt, struct proc *p) +idad_close(dev_t dev, int flags, int fmt, struct thread *td) { struct idad_softc *drv; diff --git a/sys/dev/iicbus/iic.c b/sys/dev/iicbus/iic.c index 1f07f25..42c3ee0 100644 --- a/sys/dev/iicbus/iic.c +++ b/sys/dev/iicbus/iic.c @@ -133,7 +133,7 @@ iic_attach(device_t dev) } static int -iicopen (dev_t dev, int flags, int fmt, struct proc *p) +iicopen (dev_t dev, int flags, int fmt, struct thread *td) { struct iic_softc *sc = IIC_SOFTC(minor(dev)); @@ -149,7 +149,7 @@ iicopen (dev_t dev, int flags, int fmt, struct proc *p) } static int -iicclose(dev_t dev, int flags, int fmt, struct proc *p) +iicclose(dev_t dev, int flags, int fmt, struct thread *td) { struct iic_softc *sc = IIC_SOFTC(minor(dev)); @@ -227,7 +227,7 @@ iicread(dev_t dev, struct uio * uio, int ioflag) } static int -iicioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +iicioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { device_t iicdev = IIC_DEVICE(minor(dev)); struct iic_softc *sc = IIC_SOFTC(minor(dev)); diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 4a92a01..32e0151 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -233,7 +233,7 @@ isp_attach(struct ispsoftc *isp) } static int -ispioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +ispioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct ispsoftc *isp; int retval = ENOTTY; diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index beda4de..0f3f11d 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -159,7 +159,7 @@ DRIVER_MODULE(joy, isa, joy_isa_driver, joy_devclass, 0, 0); DRIVER_MODULE(joy, acpi, joy_isa_driver, joy_devclass, 0, 0); static int -joyopen(dev_t dev, int flags, int fmt, struct proc *p) +joyopen(dev_t dev, int flags, int fmt, struct thread *td) { int i = joypart (dev); struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); @@ -172,7 +172,7 @@ joyopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -joyclose(dev_t dev, int flags, int fmt, struct proc *p) +joyclose(dev_t dev, int flags, int fmt, struct thread *td) { int i = joypart (dev); struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); @@ -240,7 +240,7 @@ joyread(dev_t dev, struct uio *uio, int flag) } static int -joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); int i = joypart (dev); diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index e53015b..1a1c132 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -491,7 +491,7 @@ kbd_detach(keyboard_t *kbd) static kbd_callback_func_t genkbd_event; static int -genkbdopen(dev_t dev, int mode, int flag, struct proc *p) +genkbdopen(dev_t dev, int mode, int flag, struct thread *td) { keyboard_t *kbd; genkbd_softc_t *sc; @@ -531,7 +531,7 @@ genkbdopen(dev_t dev, int mode, int flag, struct proc *p) } static int -genkbdclose(dev_t dev, int mode, int flag, struct proc *p) +genkbdclose(dev_t dev, int mode, int flag, struct thread *td) { keyboard_t *kbd; genkbd_softc_t *sc; @@ -621,7 +621,7 @@ genkbdwrite(dev_t dev, struct uio *uio, int flag) } static int -genkbdioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) +genkbdioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { keyboard_t *kbd; int error; @@ -636,7 +636,7 @@ genkbdioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) } static int -genkbdpoll(dev_t dev, int events, struct proc *p) +genkbdpoll(dev_t dev, int events, struct thread *td) { keyboard_t *kbd; genkbd_softc_t *sc; @@ -653,7 +653,7 @@ genkbdpoll(dev_t dev, int events, struct proc *p) if (sc->gkb_q.c_cc > 0) revents = events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->gkb_rsel); + selrecord(td, &sc->gkb_rsel); } splx(s); return revents; diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c index 6f8c0f7..f295a43 100644 --- a/sys/dev/mcd/mcd.c +++ b/sys/dev/mcd/mcd.c @@ -270,7 +270,7 @@ int mcd_attach(struct isa_device *dev) return 1; } -int mcdopen(dev_t dev, int flags, int fmt, struct proc *p) +int mcdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys,r,retry; struct mcd_data *cd; @@ -362,7 +362,7 @@ MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n", return ENXIO; } -int mcdclose(dev_t dev, int flags, int fmt, struct proc *p) +int mcdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part; struct mcd_data *cd; @@ -504,7 +504,7 @@ static void mcd_start(int unit) return; } -int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct mcd_data *cd; int unit,part,retry,r; diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 3f16777..9666ef3 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -180,14 +180,14 @@ struct md_s { }; static int -mdopen(dev_t dev, int flag, int fmt, struct proc *p) +mdopen(dev_t dev, int flag, int fmt, struct thread *td) { struct md_s *sc; struct disklabel *dl; if (md_debug) printf("mdopen(%s %x %x %p)\n", - devtoname(dev), flag, fmt, p); + devtoname(dev), flag, fmt, td->td_proc); sc = dev->si_drv1; @@ -204,7 +204,7 @@ mdopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -mdclose(dev_t dev, int flags, int fmt, struct proc *p) +mdclose(dev_t dev, int flags, int fmt, struct thread *td) { struct md_s *sc = dev->si_drv1; @@ -213,12 +213,12 @@ mdclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -mdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +mdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { if (md_debug) printf("mdioctl(%s %lx %p %x %p)\n", - devtoname(dev), cmd, addr, flags, p); + devtoname(dev), cmd, addr, flags, td); return (ENOIOCTL); } @@ -385,19 +385,19 @@ mdstart_vnode(struct md_s *sc) else auio.uio_rw = UIO_WRITE; auio.uio_resid = bp->bio_bcount; - auio.uio_procp = curproc; + auio.uio_td = curthread; if (VOP_ISLOCKED(sc->vnode, NULL)) vprint("unexpected md driver lock", sc->vnode); if (bp->bio_cmd == BIO_READ) { - vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curthread); error = VOP_READ(sc->vnode, &auio, 0, sc->cred); } else { (void) vn_start_write(sc->vnode, &mp, V_WAIT); - vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curthread); error = VOP_WRITE(sc->vnode, &auio, 0, sc->cred); vn_finished_write(mp); } - VOP_UNLOCK(sc->vnode, 0, curproc); + VOP_UNLOCK(sc->vnode, 0, curthread); bp->bio_resid = auio.uio_resid; biofinish(bp, &sc->stats, error); } @@ -633,17 +633,18 @@ mdsetcred(struct md_s *sc, struct ucred *cred) auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; auio.uio_resid = aiov.iov_len; - vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY, curthread); error = VOP_READ(sc->vnode, &auio, 0, sc->cred); - VOP_UNLOCK(sc->vnode, 0, curproc); + VOP_UNLOCK(sc->vnode, 0, curthread); free(tmpbuf, M_TEMP); } return (error); } static int -mdcreate_vnode(struct md_ioctl *mdio, struct proc *p) +mdcreate_vnode(struct md_ioctl *mdio, struct thread *td) { + struct proc *p = td->td_proc; struct md_s *sc; struct vattr vattr; struct nameidata nd; @@ -662,26 +663,26 @@ mdcreate_vnode(struct md_ioctl *mdio, struct proc *p) sc->flags = mdio->md_options & MD_FORCE; flags = FREAD|FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); error = vn_open(&nd, &flags, 0); if (error) { if (error != EACCES && error != EPERM && error != EROFS) return (error); flags &= ~FWRITE; sc->flags |= MD_READONLY; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); error = vn_open(&nd, &flags, 0); if (error) return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_vp->v_type != VREG || - (error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p))) { - VOP_UNLOCK(nd.ni_vp, 0, p); - (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + (error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, td))) { + VOP_UNLOCK(nd.ni_vp, 0, td); + (void) vn_close(nd.ni_vp, flags, p->p_ucred, td); return (error ? error : EINVAL); } - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); sc->secsize = DEV_BSIZE; sc->vnode = nd.ni_vp; @@ -693,12 +694,12 @@ mdcreate_vnode(struct md_ioctl *mdio, struct proc *p) else sc->nsect = vattr.va_size / sc->secsize; /* XXX: round up ? */ if (sc->nsect == 0) { - (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + (void) vn_close(nd.ni_vp, flags, p->p_ucred, td); return (EINVAL); } error = mdsetcred(sc, p->p_ucred); if (error) { - (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + (void) vn_close(nd.ni_vp, flags, p->p_ucred, td); return (error); } mdinit(sc); @@ -706,7 +707,7 @@ mdcreate_vnode(struct md_ioctl *mdio, struct proc *p) } static int -mddestroy(struct md_s *sc, struct proc *p) +mddestroy(struct md_s *sc, struct thread *td) { unsigned u; @@ -718,7 +719,7 @@ mddestroy(struct md_s *sc, struct proc *p) } if (sc->vnode != NULL) (void)vn_close(sc->vnode, sc->flags & MD_READONLY ? - FREAD : (FREAD|FWRITE), sc->cred, p); + FREAD : (FREAD|FWRITE), sc->cred, td); if (sc->cred != NULL) crfree(sc->cred); if (sc->object != NULL) { @@ -739,7 +740,7 @@ mddestroy(struct md_s *sc, struct proc *p) } static int -mdcreate_swap(struct md_ioctl *mdio, struct proc *p) +mdcreate_swap(struct md_ioctl *mdio, struct thread *td) { int error; struct md_s *sc; @@ -763,7 +764,7 @@ mdcreate_swap(struct md_ioctl *mdio, struct proc *p) */ if (mdio->md_size == 0) { - mddestroy(sc, p); + mddestroy(sc, td); return (EDOM); } @@ -784,20 +785,20 @@ mdcreate_swap(struct md_ioctl *mdio, struct proc *p) if (swap_pager_reserve(sc->object, 0, sc->nsect) < 0) { vm_pager_deallocate(sc->object); sc->object = NULL; - mddestroy(sc, p); + mddestroy(sc, td); return (EDOM); } } - error = mdsetcred(sc, p->p_ucred); + error = mdsetcred(sc, td->td_proc->p_ucred); if (error) - mddestroy(sc, p); + mddestroy(sc, td); else mdinit(sc); return (error); } static int -mddetach(int unit, struct proc *p) +mddetach(int unit, struct thread *td) { struct md_s *sc; @@ -811,21 +812,21 @@ mddetach(int unit, struct proc *p) case MD_SWAP: case MD_MALLOC: case MD_PRELOAD: - return (mddestroy(sc, p)); + return (mddestroy(sc, td)); default: return (EOPNOTSUPP); } } static int -mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct md_ioctl *mdio; struct md_s *sc; if (md_debug) printf("mdctlioctl(%s %lx %p %x %p)\n", - devtoname(dev), cmd, addr, flags, p); + devtoname(dev), cmd, addr, flags, td); mdio = (struct md_ioctl *)addr; switch (cmd) { @@ -836,9 +837,9 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) case MD_PRELOAD: return (mdcreate_preload(mdio)); case MD_VNODE: - return (mdcreate_vnode(mdio, p)); + return (mdcreate_vnode(mdio, td)); case MD_SWAP: - return (mdcreate_swap(mdio, p)); + return (mdcreate_swap(mdio, td)); default: return (EINVAL); } @@ -846,7 +847,7 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) if (mdio->md_file != NULL || mdio->md_size != 0 || mdio->md_options != 0) return (EINVAL); - return (mddetach(mdio->md_unit, p)); + return (mddetach(mdio->md_unit, td)); case MDIOCQUERY: sc = mdfind(mdio->md_unit); if (sc == NULL) @@ -941,7 +942,7 @@ md_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: LIST_FOREACH(sc, &md_softc_list, list) { - error = mddetach(sc->unit, curproc); + error = mddetach(sc->unit, curthread); if (error != 0) return (error); } diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index b6ff7ea..c5c2392 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -714,7 +714,7 @@ mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp) * Accept an open operation on the control device. */ int -mlx_open(dev_t dev, int flags, int fmt, struct proc *p) +mlx_open(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); @@ -727,7 +727,7 @@ mlx_open(dev_t dev, int flags, int fmt, struct proc *p) * Accept the last close on the control device. */ int -mlx_close(dev_t dev, int flags, int fmt, struct proc *p) +mlx_close(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); @@ -740,7 +740,7 @@ mlx_close(dev_t dev, int flags, int fmt, struct proc *p) * Handle controller-specific control operations. */ int -mlx_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +mlx_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { int unit = minor(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); @@ -927,7 +927,7 @@ mlx_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) */ int mlx_submit_ioctl(struct mlx_softc *sc, struct mlx_sysdrive *drive, u_long cmd, - caddr_t addr, int32_t flag, struct proc *p) + caddr_t addr, int32_t flag, struct thread *td) { int *arg = (int *)addr; int error, result; diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c index 40c7263..49005b1 100644 --- a/sys/dev/mlx/mlx_disk.c +++ b/sys/dev/mlx/mlx_disk.c @@ -95,7 +95,7 @@ static driver_t mlxd_driver = { DRIVER_MODULE(mlxd, mlx, mlxd_driver, mlxd_devclass, 0, 0); static int -mlxd_open(dev_t dev, int flags, int fmt, struct proc *p) +mlxd_open(dev_t dev, int flags, int fmt, struct thread *td) { struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1; struct disklabel *label; @@ -124,7 +124,7 @@ mlxd_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -mlxd_close(dev_t dev, int flags, int fmt, struct proc *p) +mlxd_close(dev_t dev, int flags, int fmt, struct thread *td) { struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1; @@ -137,7 +137,7 @@ mlxd_close(dev_t dev, int flags, int fmt, struct proc *p) } static int -mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1; int error; @@ -147,7 +147,7 @@ mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) if (sc == NULL) return (ENXIO); - if ((error = mlx_submit_ioctl(sc->mlxd_controller, sc->mlxd_drive, cmd, addr, flag, p)) != ENOIOCTL) { + if ((error = mlx_submit_ioctl(sc->mlxd_controller, sc->mlxd_drive, cmd, addr, flag, td)) != ENOIOCTL) { debug(0, "mlx_submit_ioctl returned %d\n", error); return(error); } diff --git a/sys/dev/mlx/mlxvar.h b/sys/dev/mlx/mlxvar.h index a4de085..58c7a4b 100644 --- a/sys/dev/mlx/mlxvar.h +++ b/sys/dev/mlx/mlxvar.h @@ -240,8 +240,9 @@ struct mlxd_softc * Interface between driver core and disk driver (should be using a bus?) */ extern int mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp); -extern int mlx_submit_ioctl(struct mlx_softc *sc, struct mlx_sysdrive *drive, u_long cmd, - caddr_t addr, int32_t flag, struct proc *p); +extern int mlx_submit_ioctl(struct mlx_softc *sc, + struct mlx_sysdrive *drive, u_long cmd, + caddr_t addr, int32_t flag, struct thread *td); extern void mlxd_intr(void *data); diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c index 78e41e3..9063cce 100644 --- a/sys/dev/mly/mly.c +++ b/sys/dev/mly/mly.c @@ -2790,7 +2790,7 @@ mly_print_controller(int controller) * Accept an open operation on the control device. */ static int -mly_user_open(dev_t dev, int flags, int fmt, struct proc *p) +mly_user_open(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct mly_softc *sc = devclass_get_softc(devclass_find("mly"), unit); @@ -2803,7 +2803,7 @@ mly_user_open(dev_t dev, int flags, int fmt, struct proc *p) * Accept the last close on the control device. */ static int -mly_user_close(dev_t dev, int flags, int fmt, struct proc *p) +mly_user_close(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct mly_softc *sc = devclass_get_softc(devclass_find("mly"), unit); @@ -2816,7 +2816,8 @@ mly_user_close(dev_t dev, int flags, int fmt, struct proc *p) * Handle controller-specific control operations. */ static int -mly_user_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +mly_user_ioctl(dev_t dev, u_long cmd, caddr_t addr, + int32_t flag, struct thread *td) { struct mly_softc *sc = (struct mly_softc *)dev->si_drv1; struct mly_user_command *uc = (struct mly_user_command *)addr; diff --git a/sys/dev/mse/mse.c b/sys/dev/mse/mse.c index 073ea7a..915bc3f 100644 --- a/sys/dev/mse/mse.c +++ b/sys/dev/mse/mse.c @@ -394,11 +394,11 @@ mse_detach(dev) * Exclusive open the mouse, initialize it and enable interrupts. */ static int -mseopen(dev, flags, fmt, p) +mseopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { mse_softc_t *sc; int s; @@ -434,11 +434,11 @@ mseopen(dev, flags, fmt, p) * mseclose: just turn off mouse innterrupts. */ static int -mseclose(dev, flags, fmt, p) +mseclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); int s; @@ -525,12 +525,12 @@ mseread(dev, uio, ioflag) * mseioctl: process ioctl commands. */ static int -mseioctl(dev, cmd, addr, flag, p) +mseioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); mousestatus_t status; @@ -642,10 +642,10 @@ mseioctl(dev, cmd, addr, flag, p) * msepoll: check for mouse input to be processed. */ static int -msepoll(dev, events, p) +msepoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); int s; @@ -662,7 +662,7 @@ msepoll(dev, events, p) * Since this is an exclusive open device, any previous * proc pointer is trash now, so we can just assign it. */ - selrecord(p, &sc->sc_selp); + selrecord(td, &sc->sc_selp); } } splx(s); diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c index c705e06..743a9dd 100644 --- a/sys/dev/nmdm/nmdm.c +++ b/sys/dev/nmdm/nmdm.c @@ -152,10 +152,10 @@ nmdminit(n) /*ARGSUSED*/ static int -nmdmopen(dev, flag, devtype, p) +nmdmopen(dev, flag, devtype, td) dev_t dev; int flag, devtype; - struct proc *p; + struct thread *td; { register struct tty *tp, *tp2; int error; @@ -203,9 +203,9 @@ nmdmopen(dev, flag, devtype, p) tp->t_lflag = TTYDEF_LFLAG; tp->t_cflag = TTYDEF_CFLAG; tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - } else if (tp->t_state & TS_XCLUDE && suser(p)) { + } else if (tp->t_state & TS_XCLUDE && suser_td(td)) { return (EBUSY); - } else if (pti->pt_prison != p->p_ucred->cr_prison) { + } else if (pti->pt_prison != td->td_proc->p_ucred->cr_prison) { return (EBUSY); } @@ -255,10 +255,10 @@ nmdmopen(dev, flag, devtype, p) } static int -nmdmclose(dev, flag, mode, p) +nmdmclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct tty *tp, *tp2; int err; @@ -485,12 +485,12 @@ nmdmstop(tp, flush) /*ARGSUSED*/ static int -nmdmioctl(dev, cmd, data, flag, p) +nmdmioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { register struct tty *tp = dev->si_tty; struct nm_softc *pti = dev->si_drv1; @@ -502,7 +502,7 @@ nmdmioctl(dev, cmd, data, flag, p) GETPARTS(tp, ourpart, otherpart); tp2 = &otherpart->nm_tty; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error == ENOIOCTL) error = ttioctl(tp, cmd, data, flag); if (error == ENOIOCTL) { diff --git a/sys/dev/ofw/ofw_console.c b/sys/dev/ofw/ofw_console.c index ff5bd3f..282a442 100644 --- a/sys/dev/ofw/ofw_console.c +++ b/sys/dev/ofw/ofw_console.c @@ -86,7 +86,7 @@ static int stdin; static int stdout; static int -ofw_dev_open(dev_t dev, int flag, int mode, struct proc *p) +ofw_dev_open(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; int unit; @@ -114,7 +114,7 @@ ofw_dev_open(dev_t dev, int flag, int mode, struct proc *p) ttsetwater(tp); setuptimeout = 1; - } else if ((tp->t_state & TS_XCLUDE) && suser(p)) { + } else if ((tp->t_state & TS_XCLUDE) && suser_td(td)) { return (EBUSY); } @@ -133,7 +133,7 @@ ofw_dev_open(dev_t dev, int flag, int mode, struct proc *p) } static int -ofw_dev_close(dev_t dev, int flag, int mode, struct proc *p) +ofw_dev_close(dev_t dev, int flag, int mode, struct thread *td) { int unit; struct tty *tp; @@ -152,7 +152,7 @@ ofw_dev_close(dev_t dev, int flag, int mode, struct proc *p) } static int -ofw_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +ofw_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit; struct tty *tp; @@ -165,7 +165,7 @@ ofw_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) return (ENXIO); } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) { return (error); } diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index d8debc3..6968241 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -60,11 +60,11 @@ * This is the user interface to PCI configuration space. */ -static int pci_open(dev_t dev, int oflags, int devtype, struct proc *p); -static int pci_close(dev_t dev, int flag, int devtype, struct proc *p); +static d_open_t pci_open; +static d_close_t pci_close; static int pci_conf_match(struct pci_match_conf *matches, int num_matches, struct pci_conf *match_buf); -static int pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p); +static d_ioctl_t pci_ioctl; #define PCI_CDEV 78 @@ -85,7 +85,7 @@ struct cdevsw pcicdev = { }; static int -pci_open(dev_t dev, int oflags, int devtype, struct proc *p) +pci_open(dev_t dev, int oflags, int devtype, struct thread *td) { if ((oflags & FWRITE) && securelevel > 0) { return EPERM; @@ -94,7 +94,7 @@ pci_open(dev_t dev, int oflags, int devtype, struct proc *p) } static int -pci_close(dev_t dev, int flag, int devtype, struct proc *p) +pci_close(dev_t dev, int flag, int devtype, struct thread *td) { return 0; } @@ -167,7 +167,7 @@ pci_conf_match(struct pci_match_conf *matches, int num_matches, } static int -pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { device_t pci, pcib; struct pci_io *io; diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index 20fc816..ef0fe1e 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -455,7 +455,7 @@ lptout(void *arg) */ static int -lptopen(dev_t dev, int flags, int fmt, struct proc *p) +lptopen(dev_t dev, int flags, int fmt, struct thread *td) { int s; int trys, err; @@ -575,7 +575,7 @@ lptopen(dev_t dev, int flags, int fmt, struct proc *p) */ static int -lptclose(dev_t dev, int flags, int fmt, struct proc *p) +lptclose(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = LPTUNIT(minor(dev)); struct lpt_data *sc = UNITOSOFTC(unit); @@ -897,7 +897,7 @@ lptintr(device_t dev) } static int -lptioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +lptioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int error = 0; u_int unit = LPTUNIT(minor(dev)); diff --git a/sys/dev/ppbus/pcfclock.c b/sys/dev/ppbus/pcfclock.c index c0e6275..d7af2ae 100644 --- a/sys/dev/ppbus/pcfclock.c +++ b/sys/dev/ppbus/pcfclock.c @@ -153,7 +153,7 @@ pcfclock_attach(device_t dev) } static int -pcfclock_open(dev_t dev, int flag, int fms, struct proc *p) +pcfclock_open(dev_t dev, int flag, int fms, struct thread *td) { u_int unit = minor(dev); struct pcfclock_data *sc = UNITOSOFTC(unit); @@ -174,7 +174,7 @@ pcfclock_open(dev_t dev, int flag, int fms, struct proc *p) } static int -pcfclock_close(dev_t dev, int flags, int fmt, struct proc *p) +pcfclock_close(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = minor(dev); struct pcfclock_data *sc = UNITOSOFTC(unit); diff --git a/sys/dev/ppbus/ppi.c b/sys/dev/ppbus/ppi.c index 5e851f0..d4e4968 100644 --- a/sys/dev/ppbus/ppi.c +++ b/sys/dev/ppbus/ppi.c @@ -255,7 +255,7 @@ ppiintr(void *arg) #endif /* PERIPH_1284 */ static int -ppiopen(dev_t dev, int flags, int fmt, struct proc *p) +ppiopen(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = minor(dev); struct ppi_data *ppi = UNITOSOFTC(unit); @@ -288,7 +288,7 @@ ppiopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -ppiclose(dev_t dev, int flags, int fmt, struct proc *p) +ppiclose(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = minor(dev); struct ppi_data *ppi = UNITOSOFTC(unit); @@ -501,7 +501,7 @@ error: } static int -ppiioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +ppiioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { u_int unit = minor(dev); device_t ppidev = UNITODEVICE(unit); diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c index c79d965..3b69097 100644 --- a/sys/dev/ppbus/pps.c +++ b/sys/dev/ppbus/pps.c @@ -125,7 +125,7 @@ ppsattach(device_t dev) } static int -ppsopen(dev_t dev, int flags, int fmt, struct proc *p) +ppsopen(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = minor(dev); struct pps_data *sc = UNITOSOFTC(unit); @@ -154,7 +154,7 @@ ppsopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -ppsclose(dev_t dev, int flags, int fmt, struct proc *p) +ppsclose(dev_t dev, int flags, int fmt, struct thread *td) { u_int unit = minor(dev); struct pps_data *sc = UNITOSOFTC(unit); @@ -193,7 +193,7 @@ ppsintr(void *arg) } static int -ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { u_int unit = minor(dev); struct pps_data *sc = UNITOSOFTC(unit); diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index a99fe6d..868d72f 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -39,6 +39,7 @@ #include <sys/module.h> #include <sys/mutex.h> #include <sys/poll.h> +#include <sys/proc.h> #include <sys/queue.h> #include <sys/random.h> #include <sys/selinfo.h> @@ -138,18 +139,18 @@ SYSCTL_PROC(_kern_random_sys_harvest, OID_AUTO, interrupt, random_check_boolean, "I", "Harvest IRQ entropy"); static int -random_open(dev_t dev, int flags, int fmt, struct proc *p) +random_open(dev_t dev, int flags, int fmt, struct thread *td) { - if ((flags & FWRITE) && (securelevel > 0 || suser(p))) + if ((flags & FWRITE) && (securelevel > 0 || suser(td->td_proc))) return EPERM; else return 0; } static int -random_close(dev_t dev, int flags, int fmt, struct proc *p) +random_close(dev_t dev, int flags, int fmt, struct thread *td) { - if ((flags & FWRITE) && !(securelevel > 0 || suser(p))) + if ((flags & FWRITE) && !(securelevel > 0 || suser(td->td_proc))) random_reseed(); return 0; } @@ -201,7 +202,7 @@ random_write(dev_t dev, struct uio *uio, int flag) } static int -random_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +random_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { switch (cmd) { /* Really handled in upper layer */ @@ -214,7 +215,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) } static int -random_poll(dev_t dev, int events, struct proc *p) +random_poll(dev_t dev, int events, struct thread *td) { int revents; @@ -223,7 +224,7 @@ random_poll(dev_t dev, int events, struct proc *p) if (random_systat.seeded) revents = events & (POLLIN | POLLRDNORM); else - selrecord(p, &random_systat.rsel); + selrecord(curthread, &random_systat.rsel); } return revents; } diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c index e4252e0..59e8dff 100644 --- a/sys/dev/rc/rc.c +++ b/sys/dev/rc/rc.c @@ -715,10 +715,10 @@ rc_stop(tp, rw) } static int -rcopen(dev, flag, mode, p) +rcopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct rc_chans *rc; register struct tty *tp; @@ -764,7 +764,7 @@ again: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -810,10 +810,10 @@ out: } static int -rcclose(dev, flag, mode, p) +rcclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct rc_chans *rc; register struct tty *tp; @@ -1064,18 +1064,18 @@ struct rc_softc *rcb; } static int -rcioctl(dev, cmd, data, flag, p) +rcioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; int flag; caddr_t data; -struct proc *p; +struct thread *td; { register struct rc_chans *rc = &rc_chans[GET_UNIT(dev)]; register int s, error; struct tty *tp = rc->rc_tp; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); error = ttioctl(tp, cmd, data, flag); @@ -1118,7 +1118,7 @@ struct proc *p; break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c index f9391f3..9c49f20 100644 --- a/sys/dev/rp/rp.c +++ b/sys/dev/rp/rp.c @@ -954,10 +954,10 @@ rp_releaseresource(CONTROLLER_t *ctlp) } int -rpopen(dev, flag, mode, p) +rpopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { struct rp_port *rp; int unit, port, mynor, umynor, flags; /* SG */ @@ -1008,7 +1008,7 @@ open_top: goto open_top; } } - if(tp->t_state & TS_XCLUDE && suser(p) != 0) { + if(tp->t_state & TS_XCLUDE && suser_td(td) != 0) { splx(oldspl); error = EBUSY; goto out2; @@ -1113,10 +1113,10 @@ out2: } int -rpclose(dev, flag, mode, p) +rpclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { int oldspl, unit, mynor, umynor, port; /* SG */ struct rp_port *rp; @@ -1228,12 +1228,12 @@ rpdtrwakeup(void *chan) } int -rpioctl(dev, cmd, data, flag, p) +rpioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct rp_port *rp; CHANNEL_t *cp; @@ -1265,7 +1265,7 @@ rpioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if(error != 0) return(error); *ct = *(struct termios *)data; @@ -1322,7 +1322,7 @@ rpioctl(dev, cmd, data, flag, p) t = &tp->t_termios; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if(error != ENOIOCTL) { return(error); } @@ -1410,7 +1410,7 @@ rpioctl(dev, cmd, data, flag, p) *(int *)data = result; break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser_td(td); if(error != 0) { splx(oldspl); return(error); diff --git a/sys/dev/scd/scd.c b/sys/dev/scd/scd.c index 1ab5afa..4561d90 100644 --- a/sys/dev/scd/scd.c +++ b/sys/dev/scd/scd.c @@ -232,7 +232,7 @@ scd_attach(struct isa_device *dev) } static int -scdopen(dev_t dev, int flags, int fmt, struct proc *p) +scdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys; int rc; @@ -286,7 +286,7 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -scdclose(dev_t dev, int flags, int fmt, struct proc *p) +scdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys; struct scd_data *cd; @@ -418,7 +418,7 @@ scd_start(int unit) } static int -scdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +scdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct scd_data *cd; int unit,part; diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index 0f42692..dc1858f 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -93,7 +93,7 @@ enum si_mctl { GET, SET, BIS, BIC }; static void si_command(struct si_port *, int, int); static int si_modem(struct si_port *, enum si_mctl, int); static void si_write_enable(struct si_port *, int); -static int si_Sioctl(dev_t, u_long, caddr_t, int, struct proc *); +static int si_Sioctl(dev_t, u_long, caddr_t, int, struct thread *); static void si_start(struct tty *); static void si_stop(struct tty *, int); static timeout_t si_lstart; @@ -595,7 +595,7 @@ try_next2: } static int -siopen(dev_t dev, int flag, int mode, struct proc *p) +siopen(dev_t dev, int flag, int mode, struct thread *td) { int oldspl, error; int card, port; @@ -607,7 +607,7 @@ siopen(dev_t dev, int flag, int mode, struct proc *p) /* quickly let in /dev/si_control */ if (IS_CONTROLDEV(mynor)) { - if ((error = suser(p))) + if ((error = suser_td(td))) return(error); return(0); } @@ -650,7 +650,7 @@ siopen(dev_t dev, int flag, int mode, struct proc *p) dev->si_tty = tp; ccbp = pp->sp_ccb; /* Find control block */ DPRINT((pp, DBG_ENTRY|DBG_OPEN, "siopen(%s,%x,%x,%x)\n", - devtoname(dev), flag, mode, p)); + devtoname(dev), flag, mode, td)); oldspl = spltty(); /* Keep others out */ error = 0; @@ -686,7 +686,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { DPRINT((pp, DBG_OPEN|DBG_FAIL, "already open and EXCLUSIVE set\n")); error = EBUSY; @@ -764,7 +764,7 @@ out: } static int -siclose(dev_t dev, int flag, int mode, struct proc *p) +siclose(dev_t dev, int flag, int mode, struct thread *td) { struct si_port *pp; struct tty *tp; @@ -781,7 +781,7 @@ siclose(dev_t dev, int flag, int mode, struct proc *p) tp = pp->sp_tty; DPRINT((pp, DBG_ENTRY|DBG_CLOSE, "siclose(%s,%x,%x,%x) sp_state:%x\n", - devtoname(dev), flag, mode, p, pp->sp_state)); + devtoname(dev), flag, mode, td, pp->sp_state)); /* did we sleep and loose a race? */ if (pp->sp_state & SS_CLOSING) { @@ -915,7 +915,7 @@ out: static int -siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct si_port *pp; struct tty *tp; @@ -929,7 +929,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) #endif if (IS_SI_IOCTL(cmd)) - return(si_Sioctl(dev, cmd, data, flag, p)); + return(si_Sioctl(dev, cmd, data, flag, td)); pp = MINOR2PP(mynor); tp = pp->sp_tty; @@ -951,7 +951,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1023,7 +1023,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) si_write_enable(pp, 0); } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) goto out; @@ -1064,7 +1064,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error == 0) pp->sp_dtr_wait = *(int *)data * hz / 100; break; @@ -1087,7 +1087,7 @@ out: * Handle the Specialix ioctls. All MUST be called via the CONTROL device */ static int -si_Sioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +si_Sioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct si_softc *xsc; struct si_port *xpp; @@ -1117,7 +1117,7 @@ si_Sioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) ip = (int *)data; -#define SUCHECK if ((error = suser(p))) goto out +#define SUCHECK if ((error = suser_td(td))) goto out switch (cmd) { case TCSIPORTS: diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 3c68d7c..05d8f35 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -1378,11 +1378,11 @@ determined_type: ; } static int -sioopen(dev, flag, mode, p) +sioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -1440,7 +1440,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -1560,11 +1560,11 @@ out: } static int -sioclose(dev, flag, mode, p) +sioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int mynor; @@ -2114,12 +2114,12 @@ cont: } static int -sioioctl(dev, cmd, data, flag, p) +sioioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -2150,7 +2150,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -2200,7 +2200,7 @@ sioioctl(dev, cmd, data, flag, p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); s = spltty(); @@ -2241,7 +2241,7 @@ sioioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c index 7eac3cc..beb3c4a 100644 --- a/sys/dev/smbus/smb.c +++ b/sys/dev/smbus/smb.c @@ -134,7 +134,7 @@ smb_attach(device_t dev) } static int -smbopen (dev_t dev, int flags, int fmt, struct proc *p) +smbopen (dev_t dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = IIC_SOFTC(minor(dev)); @@ -150,7 +150,7 @@ smbopen (dev_t dev, int flags, int fmt, struct proc *p) } static int -smbclose(dev_t dev, int flags, int fmt, struct proc *p) +smbclose(dev_t dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = IIC_SOFTC(minor(dev)); @@ -182,7 +182,7 @@ smbread(dev_t dev, struct uio * uio, int ioflag) } static int -smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { device_t smbdev = IIC_DEVICE(minor(dev)); struct smb_softc *sc = IIC_SOFTC(minor(dev)); diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 08eae23..93c1947 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -162,7 +162,7 @@ snplwrite(tp, uio, flag) uio2.uio_resid = ilen; uio2.uio_segflg = UIO_SYSSPACE; uio2.uio_rw = UIO_WRITE; - uio2.uio_procp = uio->uio_procp; + uio2.uio_td = uio->uio_td; error = ttwrite(tp, &uio2, flag); if (error != 0) break; @@ -375,15 +375,15 @@ snp_in(snp, buf, n) } static int -snpopen(dev, flag, mode, p) +snpopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { struct snoop *snp; int error; - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); if (dev->si_drv1 == NULL) { @@ -455,11 +455,11 @@ detach_notty: } static int -snpclose(dev, flags, fmt, p) +snpclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { struct snoop *snp; @@ -490,12 +490,12 @@ snp_down(snp) } static int -snpioctl(dev, cmd, data, flags, p) +snpioctl(dev, cmd, data, flags, td) dev_t dev; u_long cmd; caddr_t data; int flags; - struct proc *p; + struct thread *td; { struct snoop *snp; struct tty *tp, *tpo; @@ -579,10 +579,10 @@ snpioctl(dev, cmd, data, flags, p) } static int -snppoll(dev, events, p) +snppoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { struct snoop *snp; int revents; @@ -598,7 +598,7 @@ snppoll(dev, events, p) if (snp->snp_flags & SNOOP_DOWN || snp->snp_len > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &snp->snp_sel); + selrecord(td, &snp->snp_sel); } return (revents); } diff --git a/sys/dev/sound/isa/emu8000.c b/sys/dev/sound/isa/emu8000.c index 7067a8f..ea434e6 100644 --- a/sys/dev/sound/isa/emu8000.c +++ b/sys/dev/sound/isa/emu8000.c @@ -743,19 +743,19 @@ emupnp_attach(device_t dev) } static int -emu_open(dev_t i_dev, int flags, int mode, struct proc *p) +emu_open(dev_t i_dev, int flags, int mode, struct thread *td) { return (0); } static int -emu_close(dev_t i_dev, int flags, int mode, struct proc *p) +emu_close(dev_t i_dev, int flags, int mode, struct thread *td) { return (0); } static int -emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; diff --git a/sys/dev/sound/isa/gusmidi.c b/sys/dev/sound/isa/gusmidi.c index 88193bf..797d168 100644 --- a/sys/dev/sound/isa/gusmidi.c +++ b/sys/dev/sound/isa/gusmidi.c @@ -214,7 +214,7 @@ gusmidi_init(device_t dev) } static int -gusmidi_open(dev_t i_dev, int flags, int mode, struct proc *p) +gusmidi_open(dev_t i_dev, int flags, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; @@ -242,7 +242,7 @@ gusmidi_open(dev_t i_dev, int flags, int mode, struct proc *p) } static int -gusmidi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +gusmidi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; diff --git a/sys/dev/sound/isa/mpu.c b/sys/dev/sound/isa/mpu.c index a8cf490..14d1653 100644 --- a/sys/dev/sound/isa/mpu.c +++ b/sys/dev/sound/isa/mpu.c @@ -408,7 +408,7 @@ mpusbc_attach(device_t dev) } static int -mpu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +mpu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; diff --git a/sys/dev/sound/isa/opl.c b/sys/dev/sound/isa/opl.c index a4a0e66..5ebf974 100644 --- a/sys/dev/sound/isa/opl.c +++ b/sys/dev/sound/isa/opl.c @@ -764,7 +764,7 @@ oplsbc_attach(device_t dev) } static int -opl_open(dev_t i_dev, int flags, int mode, struct proc *p) +opl_open(dev_t i_dev, int flags, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; @@ -805,7 +805,7 @@ opl_open(dev_t i_dev, int flags, int mode, struct proc *p) } static int -opl_close(dev_t i_dev, int flags, int mode, struct proc *p) +opl_close(dev_t i_dev, int flags, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; @@ -838,7 +838,7 @@ opl_close(dev_t i_dev, int flags, int mode, struct proc *p) } static int -opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; diff --git a/sys/dev/sound/isa/sb16.c b/sys/dev/sound/isa/sb16.c index cfc2363..53c4242 100644 --- a/sys/dev/sound/isa/sb16.c +++ b/sys/dev/sound/isa/sb16.c @@ -150,7 +150,7 @@ sb_dspwr(struct sb_info *sb, u_char val) } } #if __FreeBSD_version > 500000 - if (curproc->p_intr_nesting_level == 0) + if (curthread->td_intr_nesting_level == 0) printf("sb_dspwr(0x%02x) timed out.\n", val); #endif return 0; diff --git a/sys/dev/sound/isa/uartsio.c b/sys/dev/sound/isa/uartsio.c index 297e986..3577ce5 100644 --- a/sys/dev/sound/isa/uartsio.c +++ b/sys/dev/sound/isa/uartsio.c @@ -261,7 +261,7 @@ uartsio_attach(device_t dev) } static int -uartsio_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +uartsio_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { sc_p scp; mididev_info *devinfo; diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index ad62804..e577398 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -268,16 +268,16 @@ mididev_info_number(void) */ static int -midiopen(dev_t i_dev, int flags, int mode, struct proc * p) +midiopen(dev_t i_dev, int flags, int mode, struct thread *td) { int ret; switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: - ret = midi_open(i_dev, flags, mode, p); + ret = midi_open(i_dev, flags, mode, td); break; case MIDI_DEV_STATUS: - ret = midistat_open(i_dev, flags, mode, p); + ret = midistat_open(i_dev, flags, mode, td); break; default: ret = ENXIO; @@ -288,16 +288,16 @@ midiopen(dev_t i_dev, int flags, int mode, struct proc * p) } static int -midiclose(dev_t i_dev, int flags, int mode, struct proc * p) +midiclose(dev_t i_dev, int flags, int mode, struct thread *td) { int ret; switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: - ret = midi_close(i_dev, flags, mode, p); + ret = midi_close(i_dev, flags, mode, td); break; case MIDI_DEV_STATUS: - ret = midistat_close(i_dev, flags, mode, p); + ret = midistat_close(i_dev, flags, mode, td); break; default: ret = ENXIO; @@ -345,13 +345,13 @@ midiwrite(dev_t i_dev, struct uio * buf, int flag) } static int -midiioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) +midiioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { int ret; switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: - ret = midi_ioctl(i_dev, cmd, arg, mode, p); + ret = midi_ioctl(i_dev, cmd, arg, mode, td); break; default: ret = ENXIO; @@ -362,13 +362,13 @@ midiioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) } static int -midipoll(dev_t i_dev, int events, struct proc * p) +midipoll(dev_t i_dev, int events, struct thread *td) { int ret; switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: - ret = midi_poll(i_dev, events, p); + ret = midi_poll(i_dev, events, td); break; default: ret = ENXIO; @@ -383,7 +383,7 @@ midipoll(dev_t i_dev, int events, struct proc * p) */ int -midi_open(dev_t i_dev, int flags, int mode, struct proc * p) +midi_open(dev_t i_dev, int flags, int mode, struct thread *td) { int dev, unit, ret; mididev_info *d; @@ -422,13 +422,13 @@ midi_open(dev_t i_dev, int flags, int mode, struct proc * p) if (d->open == NULL) ret = 0; else - ret = d->open(i_dev, flags, mode, p); + ret = d->open(i_dev, flags, mode, td); return (ret); } int -midi_close(dev_t i_dev, int flags, int mode, struct proc * p) +midi_close(dev_t i_dev, int flags, int mode, struct thread *td) { int dev, unit, ret; mididev_info *d; @@ -468,7 +468,7 @@ midi_close(dev_t i_dev, int flags, int mode, struct proc * p) if (d->close == NULL) ret = 0; else - ret = d->close(i_dev, flags, mode, p); + ret = d->close(i_dev, flags, mode, td); return (ret); } @@ -570,7 +570,7 @@ midi_write(dev_t i_dev, struct uio * buf, int flag) */ int -midi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) +midi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { int ret = ENOSYS, dev, unit; mididev_info *d; @@ -583,7 +583,7 @@ midi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) return (ENXIO); if (d->ioctl) - ret = d->ioctl(i_dev, cmd, arg, mode, p); + ret = d->ioctl(i_dev, cmd, arg, mode, td); if (ret != ENOSYS) return ret; @@ -715,7 +715,7 @@ midi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) } int -midi_poll(dev_t i_dev, int events, struct proc * p) +midi_poll(dev_t i_dev, int events, struct thread *td) { int unit, dev, ret, lim; mididev_info *d; @@ -742,7 +742,7 @@ midi_poll(dev_t i_dev, int events, struct proc * p) lim = d->midi_dbuf_out.unit_size; if (d->midi_dbuf_out.fl < lim) /* No enough space, record select. */ - selrecord(p, &d->midi_dbuf_out.sel); + selrecord(td, &d->midi_dbuf_out.sel); else /* We can write now. */ ret |= events & (POLLOUT | POLLWRNORM); @@ -758,7 +758,7 @@ midi_poll(dev_t i_dev, int events, struct proc * p) lim = d->midi_dbuf_in.unit_size; if (d->midi_dbuf_in.rl < lim) /* No data ready, record select. */ - selrecord(p, &d->midi_dbuf_in.sel); + selrecord(td, &d->midi_dbuf_in.sel); else /* We can write now. */ ret |= events & (POLLIN | POLLRDNORM); @@ -811,7 +811,7 @@ midi_sync(mididev_info *d) */ int -midistat_open(dev_t i_dev, int flags, int mode, struct proc * p) +midistat_open(dev_t i_dev, int flags, int mode, struct thread *td) { if (midistatbusy) return (EBUSY); @@ -827,7 +827,7 @@ midistat_open(dev_t i_dev, int flags, int mode, struct proc * p) } int -midistat_close(dev_t i_dev, int flags, int mode, struct proc * p) +midistat_close(dev_t i_dev, int flags, int mode, struct thread *td) { midistatbusy = 0; diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index d8beba2..ab35f81 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -131,7 +131,7 @@ struct seq_softc { */ int output_threshould; /* Sequence output threshould */ snd_sync_parm sync_parm; /* AIOSYNC parameter set */ - struct proc *sync_proc; /* AIOSYNCing process */ + struct thread *sync_thread; /* AIOSYNCing thread */ }; typedef struct seq_softc *sc_p; @@ -187,8 +187,8 @@ static int seq_local(sc_p scp, u_char *event); static int seq_sysex(sc_p scp, u_char *event); static void seq_timer(void *arg); static int seq_reset(sc_p scp); -static int seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p); -static int seq_closemidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p); +static int seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct thread *p); +static int seq_closemidi(sc_p scp, mididev_info *md, int flags, int mode, struct thread *p); static void seq_panic(sc_p scp); static int seq_sync(sc_p scp); @@ -268,7 +268,7 @@ seq_initunit(int unit) } int -seq_open(dev_t i_dev, int flags, int mode, struct proc *p) +seq_open(dev_t i_dev, int flags, int mode, struct thread *td) { int unit; sc_p scp; @@ -319,7 +319,7 @@ seq_open(dev_t i_dev, int flags, int mode, struct proc *p) } int -seq_close(dev_t i_dev, int flags, int mode, struct proc *p) +seq_close(dev_t i_dev, int flags, int mode, struct thread *td) { int unit; sc_p scp; @@ -551,7 +551,7 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) } int -seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { int unit, midiunit, ret, tmp, arg2; sc_p scp; @@ -644,7 +644,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) TAILQ_FOREACH(md, &scp->midi_open, md_linkseq) { if ((md->flags & MIDI_F_WRITING) != 0) { arg2 = *(int *)arg; - midi_ioctl(MIDIMKDEV(major(i_dev), md->unit, SND_DEV_MIDIN), cmd, (caddr_t)&arg2, mode, p); + midi_ioctl(MIDIMKDEV(major(i_dev), md->unit, SND_DEV_MIDIN), cmd, (caddr_t)&arg2, mode, td); } } @@ -661,7 +661,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) TAILQ_FOREACH(md, &scp->midi_open, md_linkseq) { if ((md->flags & MIDI_F_WRITING) != 0) { arg2 = *(int *)arg; - midi_ioctl(MIDIMKDEV(major(i_dev), md->unit, SND_DEV_MIDIN), cmd, (caddr_t)&arg2, mode, p); + midi_ioctl(MIDIMKDEV(major(i_dev), md->unit, SND_DEV_MIDIN), cmd, (caddr_t)&arg2, mode, td); } } @@ -773,7 +773,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_SEQ_NRSYNTHS: *(int *)arg = mididev_info_number(); @@ -790,7 +790,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_FM_4OP_ENABLE: midiunit = *(int *)arg; @@ -799,7 +799,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_SYNTH_INFO: synthinfo = (struct synth_info *)arg; @@ -809,7 +809,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_SEQ_OUTOFBAND: event = (struct seq_event_rec *)arg; @@ -825,7 +825,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_PMGR_IFACE: patinfo = (struct patmgr_info *)arg; @@ -835,7 +835,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_PMGR_ACCESS: patinfo = (struct patmgr_info *)arg; @@ -845,7 +845,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), midiunit, SND_DEV_MIDIN), cmd, arg, mode, td); break; case SNDCTL_SEQ_THRESHOLD: tmp = *(int *)arg; @@ -871,7 +871,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); if (ret != 0) break; - ret = midi_ioctl(MIDIMKDEV(major(i_dev), 0, SND_DEV_MIDIN), cmd, arg, mode, p); + ret = midi_ioctl(MIDIMKDEV(major(i_dev), 0, SND_DEV_MIDIN), cmd, arg, mode, td); break; } @@ -879,7 +879,7 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) } int -seq_poll(dev_t i_dev, int events, struct proc *p) +seq_poll(dev_t i_dev, int events, struct thread *td) { int unit, ret, lim; sc_p scp; @@ -916,7 +916,7 @@ seq_poll(dev_t i_dev, int events, struct proc *p) lim = sd->midi_dbuf_out.unit_size; if (sd->midi_dbuf_out.fl < lim) /* No enough space, record select. */ - selrecord(p, &sd->midi_dbuf_out.sel); + selrecord(td, &sd->midi_dbuf_out.sel); else /* We can write now. */ ret |= events & (POLLOUT | POLLWRNORM); @@ -932,7 +932,7 @@ seq_poll(dev_t i_dev, int events, struct proc *p) lim = sd->midi_dbuf_in.unit_size; if (sd->midi_dbuf_in.rl < lim) /* No data ready, record select. */ - selrecord(p, &sd->midi_dbuf_in.sel); + selrecord(td, &sd->midi_dbuf_in.sel); else /* We can write now. */ ret |= events & (POLLIN | POLLRDNORM); @@ -1849,7 +1849,7 @@ seq_timer(void *arg) } static int -seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p) +seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct thread *td) { int midiunit, err, insync; @@ -1859,7 +1859,7 @@ seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p) DEB(printf("seq_openmidi: opening midi unit %d.\n", midiunit)); - err = midi_open(MIDIMKDEV(MIDI_CDEV_MAJOR, midiunit, SND_DEV_MIDIN), flags, mode, p); + err = midi_open(MIDIMKDEV(MIDI_CDEV_MAJOR, midiunit, SND_DEV_MIDIN), flags, mode, td); if (err != 0) { printf("seq_openmidi: failed to open midi device %d.\n", midiunit); return (err); @@ -1887,7 +1887,7 @@ seq_openmidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p) } static int -seq_closemidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p) +seq_closemidi(sc_p scp, mididev_info *md, int flags, int mode, struct thread *td) { int midiunit, insync; @@ -1901,7 +1901,7 @@ seq_closemidi(sc_p scp, mididev_info *md, int flags, int mode, struct proc *p) DEB(printf("seq_closemidi: closing midi unit %d.\n", midiunit)); - midi_close(MIDIMKDEV(MIDI_CDEV_MAJOR, midiunit, SND_DEV_MIDIN), flags, mode, p); + midi_close(MIDIMKDEV(MIDI_CDEV_MAJOR, midiunit, SND_DEV_MIDIN), flags, mode, td); mtx_lock(&md->flagqueue_mtx); md->intr = NULL; md->intrarg = NULL; @@ -2152,7 +2152,7 @@ lookup_mididev(sc_p scp, int unit, int mode, mididev_info **mdp) if (md->unit == unit) { *mdp = md; if (mode == LOOKUP_CLOSE) - return seq_closemidi(scp, md, scp->fflags, MIDIDEV_MODE, curproc); + return seq_closemidi(scp, md, scp->fflags, MIDIDEV_MODE, curthread); return (md != NULL && MIDICONFED(md)) ? 0 : ENXIO; } @@ -2162,7 +2162,7 @@ lookup_mididev(sc_p scp, int unit, int mode, mididev_info **mdp) md = get_mididev_info_unit(unit); if (md != NULL) { *mdp = md; - ret = seq_openmidi(scp, md, scp->fflags, MIDIDEV_MODE, curproc); + ret = seq_openmidi(scp, md, scp->fflags, MIDIDEV_MODE, curthread); return ret; } } @@ -2172,22 +2172,22 @@ lookup_mididev(sc_p scp, int unit, int mode, mididev_info **mdp) /* XXX These functions are actually redundant. */ static int -seqopen(dev_t i_dev, int flags, int mode, struct proc * p) +seqopen(dev_t i_dev, int flags, int mode, struct thread *td) { switch (MIDIDEV(i_dev)) { case MIDI_DEV_SEQ: - return seq_open(i_dev, flags, mode, p); + return seq_open(i_dev, flags, mode, td); } return (ENXIO); } static int -seqclose(dev_t i_dev, int flags, int mode, struct proc * p) +seqclose(dev_t i_dev, int flags, int mode, struct thread *td) { switch (MIDIDEV(i_dev)) { case MIDI_DEV_SEQ: - return seq_close(i_dev, flags, mode, p); + return seq_close(i_dev, flags, mode, td); } return (ENXIO); @@ -2216,22 +2216,22 @@ seqwrite(dev_t i_dev, struct uio * buf, int flag) } static int -seqioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) +seqioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { switch (MIDIDEV(i_dev)) { case MIDI_DEV_SEQ: - return seq_ioctl(i_dev, cmd, arg, mode, p); + return seq_ioctl(i_dev, cmd, arg, mode, td); } return (ENXIO); } static int -seqpoll(dev_t i_dev, int events, struct proc * p) +seqpoll(dev_t i_dev, int events, struct thread *td) { switch (MIDIDEV(i_dev)) { case MIDI_DEV_SEQ: - return seq_poll(i_dev, events, p); + return seq_poll(i_dev, events, td); } return (ENXIO); diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 8cf2d88..dc843ee 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -498,7 +498,7 @@ chn_sync(struct pcm_channel *c, int threshold) /* called externally, handle locking */ int -chn_poll(struct pcm_channel *c, int ev, struct proc *p) +chn_poll(struct pcm_channel *c, int ev, struct thread *td) { struct snd_dbuf *bs = c->bufsoft; int ret; @@ -510,7 +510,7 @@ chn_poll(struct pcm_channel *c, int ev, struct proc *p) if (chn_polltrigger(c) && chn_pollreset(c)) ret = ev; else - selrecord(p, sndbuf_getsel(bs)); + selrecord(curthread, sndbuf_getsel(bs)); return ret; } diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index 6743f4a..118cf5d 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -73,7 +73,7 @@ int chn_read(struct pcm_channel *c, struct uio *buf); u_int32_t chn_start(struct pcm_channel *c, int force); int chn_sync(struct pcm_channel *c, int threshold); int chn_flush(struct pcm_channel *c); -int chn_poll(struct pcm_channel *c, int ev, struct proc *p); +int chn_poll(struct pcm_channel *c, int ev, struct thread *td); int chn_init(struct pcm_channel *c, void *devinfo, int dir); int chn_kill(struct pcm_channel *c); diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 6a4bfc6..4ae4e67 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -169,7 +169,7 @@ relchns(dev_t dev, struct pcm_channel *rdch, struct pcm_channel *wrch, u_int32_t } static int -dsp_open(dev_t i_dev, int flags, int mode, struct proc *p) +dsp_open(dev_t i_dev, int flags, int mode, struct thread *td) { struct pcm_channel *rdch, *wrch; struct snddev_info *d; @@ -229,9 +229,9 @@ dsp_open(dev_t i_dev, int flags, int mode, struct proc *p) if (rdch == NULL) { /* not already open, try to get a channel */ if (devtype == SND_DEV_DSPREC) - rdch = pcm_chnalloc(d, PCMDIR_REC, p->p_pid, PCMCHAN(i_dev)); + rdch = pcm_chnalloc(d, PCMDIR_REC, td->td_proc->p_pid, PCMCHAN(i_dev)); else - rdch = pcm_chnalloc(d, PCMDIR_REC, p->p_pid, -1); + rdch = pcm_chnalloc(d, PCMDIR_REC, td->td_proc->p_pid, -1); if (!rdch) { /* no channel available, exit */ pcm_unlock(d); @@ -251,7 +251,7 @@ dsp_open(dev_t i_dev, int flags, int mode, struct proc *p) /* open for write */ if (wrch == NULL) { /* not already open, try to get a channel */ - wrch = pcm_chnalloc(d, PCMDIR_PLAY, p->p_pid, -1); + wrch = pcm_chnalloc(d, PCMDIR_PLAY, td->td_proc->p_pid, -1); if (!wrch) { /* no channel available */ if (rdch && (flags & FREAD)) { @@ -310,7 +310,7 @@ dsp_open(dev_t i_dev, int flags, int mode, struct proc *p) } static int -dsp_close(dev_t i_dev, int flags, int mode, struct proc *p) +dsp_close(dev_t i_dev, int flags, int mode, struct thread *td) { struct pcm_channel *rdch, *wrch; struct snddev_info *d; @@ -429,7 +429,7 @@ dsp_write(dev_t i_dev, struct uio *buf, int flag) } static int -dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { struct pcm_channel *wrch, *rdch; struct snddev_info *d; @@ -446,7 +446,7 @@ dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) dev_t pdev; pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(PCMUNIT(i_dev), SND_DEV_CTL, 0)); - return mixer_ioctl(pdev, cmd, arg, mode, p); + return mixer_ioctl(pdev, cmd, arg, mode, td); } s = spltty(); @@ -961,7 +961,7 @@ dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) } static int -dsp_poll(dev_t i_dev, int events, struct proc *p) +dsp_poll(dev_t i_dev, int events, struct thread *td) { struct pcm_channel *wrch = NULL, *rdch = NULL; intrmask_t s; @@ -974,12 +974,12 @@ dsp_poll(dev_t i_dev, int events, struct proc *p) if (wrch) { e = (events & (POLLOUT | POLLWRNORM)); if (e) - ret |= chn_poll(wrch, e, p); + ret |= chn_poll(wrch, e, td); } if (rdch) { e = (events & (POLLIN | POLLRDNORM)); if (e) - ret |= chn_poll(rdch, e, p); + ret |= chn_poll(rdch, e, td); } relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR); diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index cddb515..d4894a5 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -392,7 +392,7 @@ mixer_hwvol_step(device_t dev, int left_step, int right_step) /* ----------------------------------------------------------------------- */ static int -mixer_open(dev_t i_dev, int flags, int mode, struct proc *p) +mixer_open(dev_t i_dev, int flags, int mode, struct thread *td) { struct snd_mixer *m; intrmask_t s; @@ -409,7 +409,7 @@ mixer_open(dev_t i_dev, int flags, int mode, struct proc *p) } static int -mixer_close(dev_t i_dev, int flags, int mode, struct proc *p) +mixer_close(dev_t i_dev, int flags, int mode, struct thread *td) { struct snd_mixer *m; intrmask_t s; @@ -431,7 +431,7 @@ mixer_close(dev_t i_dev, int flags, int mode, struct proc *p) } int -mixer_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) +mixer_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { struct snd_mixer *m; intrmask_t s; diff --git a/sys/dev/sound/pcm/mixer.h b/sys/dev/sound/pcm/mixer.h index 054d79d..4f51bf2 100644 --- a/sys/dev/sound/pcm/mixer.h +++ b/sys/dev/sound/pcm/mixer.h @@ -29,7 +29,7 @@ int mixer_init(device_t dev, kobj_class_t cls, void *devinfo); int mixer_uninit(device_t dev); int mixer_reinit(device_t dev); -int mixer_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p); +int mixer_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td); int mixer_hwvol_init(device_t dev); void mixer_hwvol_mute(device_t dev); diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index dd786e9..b3b0999 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -109,7 +109,7 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, verbose, CTLTYPE_INT | CTLFLAG_RW, 0, sizeof(int), sysctl_hw_sndverbose, "I", ""); static int -sndstat_open(dev_t i_dev, int flags, int mode, struct proc *p) +sndstat_open(dev_t i_dev, int flags, int mode, struct thread *td) { intrmask_t s; int err; @@ -137,7 +137,7 @@ sndstat_open(dev_t i_dev, int flags, int mode, struct proc *p) } static int -sndstat_close(dev_t i_dev, int flags, int mode, struct proc *p) +sndstat_close(dev_t i_dev, int flags, int mode, struct thread *td) { intrmask_t s; diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index 0fadea8..e0986de 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -460,11 +460,11 @@ static int spkr_active = FALSE; /* exclusion flag */ static char *spkr_inbuf; /* incoming buf */ int -spkropen(dev, flags, fmt, p) +spkropen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkropen: entering with dev = %s\n", devtoname(dev)); @@ -519,11 +519,11 @@ spkrwrite(dev, uio, ioflag) } int -spkrclose(dev, flags, fmt, p) +spkrclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev)); @@ -542,12 +542,12 @@ spkrclose(dev, flags, fmt, p) } int -spkrioctl(dev, cmd, cmdarg, flags, p) +spkrioctl(dev, cmd, cmdarg, flags, td) dev_t dev; unsigned long cmd; caddr_t cmdarg; int flags; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkrioctl: entering with dev = %s, cmd = %lx\n", diff --git a/sys/dev/streams/streams.c b/sys/dev/streams/streams.c index b1ccc35..8d02576 100644 --- a/sys/dev/streams/streams.c +++ b/sys/dev/streams/streams.c @@ -61,8 +61,8 @@ #include <compat/svr4/svr4_stropts.h> #include <compat/svr4/svr4_socket.h> -static int svr4_soo_close __P((struct file *, struct proc *)); -static int svr4_ptm_alloc __P((struct proc *)); +static int svr4_soo_close __P((struct file *, struct thread *)); +static int svr4_ptm_alloc __P((struct thread *)); static d_open_t streamsopen; struct svr4_sockcache_entry { @@ -198,7 +198,7 @@ MODULE_VERSION(streams, 1); * routine. */ static int -streamsopen(dev_t dev, int oflags, int devtype, struct proc *p) +streamsopen(dev_t dev, int oflags, int devtype, struct thread *td) { int type, protocol; int fd; @@ -206,9 +206,10 @@ streamsopen(dev_t dev, int oflags, int devtype, struct proc *p) struct socket *so; int error; int family; + struct proc *p = td->td_proc; PROC_LOCK(p); - if (p->p_dupfd >= 0) { + if (td->td_dupfd >= 0) { PROC_UNLOCK(p); return ENODEV; } @@ -254,16 +255,16 @@ streamsopen(dev_t dev, int oflags, int devtype, struct proc *p) break; case dev_ptm: - return svr4_ptm_alloc(p); + return svr4_ptm_alloc(td); default: return EOPNOTSUPP; } - if ((error = falloc(p, &fp, &fd)) != 0) + if ((error = falloc(td, &fp, &fd)) != 0) return error; - if ((error = socreate(family, &so, type, protocol, p)) != 0) { + if ((error = socreate(family, &so, type, protocol, td)) != 0) { p->p_fd->fd_ofiles[fd] = 0; ffree(fp); return error; @@ -276,15 +277,16 @@ streamsopen(dev_t dev, int oflags, int devtype, struct proc *p) (void)svr4_stream_get(fp); PROC_LOCK(p); - p->p_dupfd = fd; + td->td_dupfd = fd; PROC_UNLOCK(p); return ENXIO; } static int -svr4_ptm_alloc(p) - struct proc *p; +svr4_ptm_alloc(td) + struct thread *td; { + struct proc *p = td->td_proc; /* * XXX this is very, very ugly. But I can't find a better * way that won't duplicate a big amount of code from @@ -319,13 +321,13 @@ svr4_ptm_alloc(p) if ((error = copyout(ptyname, path, sizeof(ptyname))) != 0) return error; - switch (error = open(p, &oa)) { + switch (error = open(td, &oa)) { case ENOENT: case ENXIO: return error; case 0: PROC_LOCK(p); - p->p_dupfd = p->p_retval[0]; + td->td_dupfd = td->td_retval[0]; PROC_UNLOCK(p); return ENXIO; default: @@ -394,14 +396,14 @@ svr4_delete_socket(p, fp) } static int -svr4_soo_close(struct file *fp, struct proc *p) +svr4_soo_close(struct file *fp, struct thread *td) { struct socket *so = (struct socket *)fp->f_data; /* CHECKUNIT_DIAG(ENXIO);*/ - svr4_delete_socket(p, fp); + svr4_delete_socket(td->td_proc, fp); free(so->so_emuldata, M_TEMP); - return soo_close(fp, p); + return soo_close(fp, td); return (0); } diff --git a/sys/dev/syscons/schistory.c b/sys/dev/syscons/schistory.c index bd9b1d2..3df7682 100644 --- a/sys/dev/syscons/schistory.c +++ b/sys/dev/syscons/schistory.c @@ -278,7 +278,7 @@ sc_hist_down_line(scr_stat *scp) int sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { scr_stat *scp; int error; diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c index b8bb5d1..92ced7d 100644 --- a/sys/dev/syscons/scmouse.c +++ b/sys/dev/syscons/scmouse.c @@ -600,7 +600,7 @@ sc_mouse_paste(scr_stat *scp) int sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { mouse_info_t *mouse; mouse_info_t buf; @@ -658,8 +658,8 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, case MOUSE_MODE: if (ISSIGVALID(mouse->u.mode.signal)) { scp->mouse_signal = mouse->u.mode.signal; - scp->mouse_proc = p; - scp->mouse_pid = p->p_pid; + scp->mouse_proc = td->td_proc; + scp->mouse_pid = td->td_proc->p_pid; } else { scp->mouse_signal = 0; diff --git a/sys/dev/syscons/scterm-sc.c b/sys/dev/syscons/scterm-sc.c index fb02b92..1b9b979 100644 --- a/sys/dev/syscons/scterm-sc.c +++ b/sys/dev/syscons/scterm-sc.c @@ -711,7 +711,7 @@ outloop: static int scterm_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p) + int flag, struct thread *td) { term_stat *tcp = scp->ts; vid_info_t *vi; diff --git a/sys/dev/syscons/scvesactl.c b/sys/dev/syscons/scvesactl.c index a9ff4ad..7a92d33f 100644 --- a/sys/dev/syscons/scvesactl.c +++ b/sys/dev/syscons/scvesactl.c @@ -46,7 +46,7 @@ static d_ioctl_t *prev_user_ioctl; static int -vesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +vesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { scr_stat *scp; struct tty *tp; @@ -106,7 +106,7 @@ vesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } if (prev_user_ioctl) - return (*prev_user_ioctl)(dev, cmd, data, flag, p); + return (*prev_user_ioctl)(dev, cmd, data, flag, td); else return ENOIOCTL; } diff --git a/sys/dev/syscons/scvidctl.c b/sys/dev/syscons/scvidctl.c index b75e545..b28752b 100644 --- a/sys/dev/syscons/scvidctl.c +++ b/sys/dev/syscons/scvidctl.c @@ -435,7 +435,7 @@ sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize, (*vidsw[(a)->va_index]->ioctl)((a), (c), (caddr_t)(d))) int -sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) +sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) { scr_stat *scp; video_adapter_t *adp; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index fe5176f..644864e 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -442,7 +442,7 @@ scdevtounit(dev_t dev) } int -scopen(dev_t dev, int flag, int mode, struct proc *p) +scopen(dev_t dev, int flag, int mode, struct thread *td) { int unit = scdevtounit(dev); sc_softc_t *sc; @@ -481,7 +481,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) (*linesw[tp->t_line].l_modem)(tp, 1); } else - if (tp->t_state & TS_XCLUDE && suser(p)) + if (tp->t_state & TS_XCLUDE && suser_td(td)) return(EBUSY); error = (*linesw[tp->t_line].l_open)(dev, tp); @@ -501,7 +501,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) } int -scclose(dev_t dev, int flag, int mode, struct proc *p) +scclose(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp = dev->si_tty; scr_stat *scp; @@ -634,7 +634,7 @@ scparam(struct tty *tp, struct termios *t) } int -scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int error; int i; @@ -647,23 +647,23 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) /* If there is a user_ioctl function call that first */ if (sc_user_ioctl) { - error = (*sc_user_ioctl)(dev, cmd, data, flag, p); + error = (*sc_user_ioctl)(dev, cmd, data, flag, td); if (error != ENOIOCTL) return error; } - error = sc_vid_ioctl(tp, cmd, data, flag, p); + error = sc_vid_ioctl(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; #ifndef SC_NO_HISTORY - error = sc_hist_ioctl(tp, cmd, data, flag, p); + error = sc_hist_ioctl(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; #endif #ifndef SC_NO_SYSMOUSE - error = sc_mouse_ioctl(tp, cmd, data, flag, p); + error = sc_mouse_ioctl(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; #endif @@ -674,7 +674,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) sc = scp->sc; if (scp->tsw) { - error = (*scp->tsw->te_ioctl)(scp, tp, cmd, data, flag, p); + error = (*scp->tsw->te_ioctl)(scp, tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; } @@ -855,7 +855,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) DPRINTF(5, ("sc%d: VT_SETMODE ", sc->unit)); if (scp->smode.mode == VT_PROCESS) { p1 = pfind(scp->pid); - if (scp->proc == p1 && scp->proc != p) { + if (scp->proc == p1 && scp->proc != td->td_proc) { if (p1) PROC_UNLOCK(p1); DPRINTF(5, ("error EPERM\n")); @@ -884,9 +884,9 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) DPRINTF(5, ("error EINVAL\n")); return EINVAL; } - DPRINTF(5, ("VT_PROCESS %d, ", p->p_pid)); + DPRINTF(5, ("VT_PROCESS %d, ", td->td_proc->p_pid)); bcopy(data, &scp->smode, sizeof(struct vt_mode)); - scp->proc = p; + scp->proc = td->td_proc; scp->pid = scp->proc->p_pid; if ((scp == sc->cur_scp) && (sc->unit == sc_console_unit)) cons_unavail = TRUE; @@ -911,7 +911,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) return EINVAL; } /* ...and this process is controlling it. */ - if (scp->proc != p) { + if (scp->proc != td->td_proc) { splx(s); return EPERM; } @@ -977,19 +977,19 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) return 0; case KDENABIO: /* allow io operations */ - error = suser(p); + error = suser_td(td); if (error != 0) return error; if (securelevel > 0) return EPERM; #ifdef __i386__ - p->p_frame->tf_eflags |= PSL_IOPL; + td->td_frame->tf_eflags |= PSL_IOPL; #endif return 0; case KDDISABIO: /* disallow io operations (default) */ #ifdef __i386__ - p->p_frame->tf_eflags &= ~PSL_IOPL; + td->td_frame->tf_eflags &= ~PSL_IOPL; #endif return 0; @@ -1270,7 +1270,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) break; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return(error); error = ttioctl(tp, cmd, data, flag); diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index 7a353f8..b5e206a 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -338,7 +338,7 @@ typedef int sc_term_init_t(scr_stat *scp, void **tcp, int code); typedef int sc_term_term_t(scr_stat *scp, void **tcp); typedef void sc_term_puts_t(scr_stat *scp, u_char *buf, int len); typedef int sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd, - caddr_t data, int flag, struct proc *p); + caddr_t data, int flag, struct thread *td); typedef int sc_term_reset_t(scr_stat *scp, int code); #define SC_TE_HARD_RESET 0 #define SC_TE_SOFT_RESET 1 @@ -508,7 +508,7 @@ typedef struct { /* syscons.c */ extern int (*sc_user_ioctl)(dev_t dev, u_long cmd, caddr_t data, - int flag, struct proc *p); + int flag, struct thread *td); int sc_probe_unit(int unit, int flags); int sc_attach_unit(int unit, int flags); @@ -550,7 +550,7 @@ void sc_hist_end(scr_stat *scp); int sc_hist_up_line(scr_stat *scp); int sc_hist_down_line(scr_stat *scp); int sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p); + int flag, struct thread *td); #endif /* SC_NO_HISTORY */ /* scmouse.c */ @@ -575,7 +575,7 @@ void sc_mouse_paste(scr_stat *scp); #ifndef SC_NO_SYSMOUSE void sc_mouse_move(scr_stat *scp, int x, int y); int sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p); + int flag, struct thread *td); #endif /* SC_NO_SYSMOUSE */ /* scvidctl.c */ @@ -585,7 +585,7 @@ int sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode); int sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize, int fontsize); int sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, - struct proc *p); + struct thread *td); int sc_render_add(sc_renderer_t *rndr); int sc_render_remove(sc_renderer_t *rndr); diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c index bb38cfe..80eac8e 100644 --- a/sys/dev/syscons/sysmouse.c +++ b/sys/dev/syscons/sysmouse.c @@ -72,7 +72,7 @@ static void smstart(struct tty *tp); static int smparam(struct tty *tp, struct termios *t); static int -smopen(dev_t dev, int flag, int mode, struct proc *p) +smopen(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; @@ -99,7 +99,7 @@ smopen(dev_t dev, int flag, int mode, struct proc *p) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; smparam(tp, &tp->t_termios); (*linesw[tp->t_line].l_modem)(tp, 1); - } else if (tp->t_state & TS_XCLUDE && suser(p)) { + } else if (tp->t_state & TS_XCLUDE && suser_td(td)) { return EBUSY; } @@ -107,7 +107,7 @@ smopen(dev_t dev, int flag, int mode, struct proc *p) } static int -smclose(dev_t dev, int flag, int mode, struct proc *p) +smclose(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; int s; @@ -151,7 +151,7 @@ smparam(struct tty *tp, struct termios *t) } static int -smioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +smioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct tty *tp; mousehw_t *hw; @@ -239,7 +239,7 @@ smioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) return ENODEV; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; error = ttioctl(tp, cmd, data, flag); diff --git a/sys/dev/tdfx/tdfx_pci.c b/sys/dev/tdfx/tdfx_pci.c index 7ffee6f..5594a13 100644 --- a/sys/dev/tdfx/tdfx_pci.c +++ b/sys/dev/tdfx/tdfx_pci.c @@ -407,7 +407,7 @@ tdfx_setmtrr(device_t dev) { } static int -tdfx_open(dev_t dev, int flags, int fmt, struct proc *p) +tdfx_open(dev_t dev, int flags, int fmt, struct thread *td) { /* * The open cdev method handles open(2) calls to /dev/3dfx[n] @@ -417,7 +417,7 @@ tdfx_open(dev_t dev, int flags, int fmt, struct proc *p) UNIT(minor(dev))); if(tdfx_info->busy != 0) return EBUSY; #ifdef DEBUG - printf("3dfx: Opened by #%d\n", p->p_pid); + printf("3dfx: Opened by #%d\n", td->td_proc->p_pid); #endif /* Set the driver as busy */ tdfx_info->busy++; @@ -425,7 +425,7 @@ tdfx_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -tdfx_close(dev_t dev, int fflag, int devtype, struct proc* p) +tdfx_close(dev_t dev, int fflag, int devtype, struct thread *td) { /* * The close cdev method handles close(2) calls to /dev/3dfx[n] @@ -436,7 +436,7 @@ tdfx_close(dev_t dev, int fflag, int devtype, struct proc* p) if(tdfx_info->busy == 0) return EBADF; tdfx_info->busy = 0; #ifdef DEBUG - printf("Closed by #%d\n", p->p_pid); + printf("Closed by #%d\n", td->td_proc->p_pid); #endif return 0; } @@ -790,37 +790,37 @@ tdfx_do_pio(u_int cmd, struct tdfx_pio_data *piod) * want to distinguish errors from useful data, and maintain compatibility. * * There is this portion of the proc struct called p_retval[], we can store a - * return value in p->p_retval[0] and place the return value if it is positive + * return value in td->td_retval[0] and place the return value if it is positive * in there, then we can return 0 (good). If the return value is negative, we * can return -retval and the error should be properly handled. */ static int -tdfx_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc * p) +tdfx_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int retval = 0; struct tdfx_pio_data *piod = (struct tdfx_pio_data*)data; #ifdef DEBUG - printf("IOCTL'd by #%d, cmd: 0x%x, data: 0x%x\n", p->p_pid, (u_int32_t)cmd, + printf("IOCTL'd by #%d, cmd: 0x%x, data: 0x%x\n", td->td_proc->p_pid, (u_int32_t)cmd, (unsigned int)piod); #endif switch(_IOC_TYPE(cmd)) { /* Return the real error if negative, or simply stick the valid return - * in p->p_retval */ + * in td->td_retval */ case 0x33: /* The '3'(0x33) type IOCTL is for querying the installed cards */ - if((retval = tdfx_do_query(cmd, piod)) > 0) p->p_retval[0] = retval; + if((retval = tdfx_do_query(cmd, piod)) > 0) td->td_retval[0] = retval; else return -retval; break; case 0: /* The 0 type IOCTL is for programmed I/O methods */ - if((tdfx_do_pio(cmd, piod)) > 0) p->p_retval[0] = retval; + if((tdfx_do_pio(cmd, piod)) > 0) td->td_retval[0] = retval; else return -retval; break; default: /* Technically, we won't reach this from linux emu, but when glide * finally gets ported, watch out! */ #ifdef DEBUG - printf("Bad IOCTL from #%d\n", p->p_pid); + printf("Bad IOCTL from #%d\n", td->td_proc->p_pid); #endif return ENXIO; } @@ -833,7 +833,7 @@ tdfx_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc * p) * Linux emulation IOCTL for /dev/tdfx */ static int -linux_ioctl_tdfx(struct proc* p, struct linux_ioctl_args* args) +linux_ioctl_tdfx(struct thread *td, struct linux_ioctl_args* args) { int error = 0; u_long cmd = args->cmd & 0xffff; @@ -842,11 +842,11 @@ linux_ioctl_tdfx(struct proc* p, struct linux_ioctl_args* args) and one void*. */ char d_pio[2*sizeof(short) + sizeof(int) + sizeof(void*)]; - struct file *fp = p->p_fd->fd_ofiles[args->fd]; + struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd]; /* We simply copy the data and send it right to ioctl */ copyin((caddr_t)args->arg, &d_pio, sizeof(d_pio)); - error = fo_ioctl(fp, cmd, (caddr_t)&d_pio, p); + error = fo_ioctl(fp, cmd, (caddr_t)&d_pio, td); return error; } #endif /* TDFX_LINUX */ diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c index e77e11f..3543913 100644 --- a/sys/dev/twe/twe_freebsd.c +++ b/sys/dev/twe/twe_freebsd.c @@ -90,7 +90,7 @@ static struct cdevsw twe_cdevsw = { * Accept an open operation on the control device. */ static int -twe_open(dev_t dev, int flags, int fmt, struct proc *p) +twe_open(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); @@ -103,7 +103,7 @@ twe_open(dev_t dev, int flags, int fmt, struct proc *p) * Accept the last close on the control device. */ static int -twe_close(dev_t dev, int flags, int fmt, struct proc *p) +twe_close(dev_t dev, int flags, int fmt, struct thread *td) { int unit = minor(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); @@ -116,7 +116,7 @@ twe_close(dev_t dev, int flags, int fmt, struct proc *p) * Handle controller-specific control operations. */ static int -twe_ioctl_wrapper(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p) +twe_ioctl_wrapper(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { struct twe_softc *sc = (struct twe_softc *)dev->si_drv1; @@ -599,7 +599,7 @@ static int disks_registered = 0; * for opens on subdevices (eg. slices, partitions). */ static int -twed_open(dev_t dev, int flags, int fmt, struct proc *p) +twed_open(dev_t dev, int flags, int fmt, struct thread *td) { struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; struct disklabel *label; @@ -632,7 +632,7 @@ twed_open(dev_t dev, int flags, int fmt, struct proc *p) * Handle last close of the disk device. */ static int -twed_close(dev_t dev, int flags, int fmt, struct proc *p) +twed_close(dev_t dev, int flags, int fmt, struct thread *td) { struct twed_softc *sc = (struct twed_softc *)dev->si_drv1; diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 38dab89..14d8f3a 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1887,7 +1887,7 @@ ohci_abort_xfer(xfer, status) timeout(ohci_abort_xfer_end, xfer, hz / USB_FRAMES_PER_SECOND); } else { #if defined(DIAGNOSTIC) && defined(__i386__) && defined(__FreeBSD__) - KASSERT(curproc->p_intr_nesting_level == 0, + KASSERT(curthread->td_intr_nesting_level == 0, ("ohci_abort_req in interrupt context")); #endif usb_delay_ms(opipe->pipe.device->bus, 1); diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 637c7a0..2f65a8a 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -157,7 +157,7 @@ Static void ugen_isoc_rintr(usbd_xfer_handle xfer, usbd_private_handle addr, Static int ugen_do_read(struct ugen_softc *, int, struct uio *, int); Static int ugen_do_write(struct ugen_softc *, int, struct uio *, int); Static int ugen_do_ioctl(struct ugen_softc *, int, u_long, - caddr_t, int, struct proc *); + caddr_t, int, struct thread *); #if defined(__FreeBSD__) Static void ugen_make_devnodes(struct ugen_softc *sc); Static void ugen_destroy_devnodes(struct ugen_softc *sc); @@ -358,7 +358,7 @@ ugen_set_config(struct ugen_softc *sc, int configno) } int -ugenopen(dev_t dev, int flag, int mode, struct proc *p) +ugenopen(dev_t dev, int flag, int mode, struct thread *td) { struct ugen_softc *sc; int unit = UGENUNIT(dev); @@ -490,7 +490,7 @@ ugenopen(dev_t dev, int flag, int mode, struct proc *p) } int -ugenclose(dev_t dev, int flag, int mode, struct proc *p) +ugenclose(dev_t dev, int flag, int mode, struct thread *td) { int endpt = UGENENDPOINT(dev); struct ugen_softc *sc; @@ -1034,7 +1034,7 @@ ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx) Static int ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, - caddr_t addr, int flag, struct proc *p) + caddr_t addr, int flag, struct thread *td) { struct ugen_endpoint *sce; usbd_status err; @@ -1223,7 +1223,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, uio.uio_offset = 0; uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; #if defined(__NetBSD__) || defined(__OpenBSD__) error = uiomove((caddr_t)cdesc, len, &uio); #elif defined(__FreeBSD__) @@ -1273,7 +1273,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, uio.uio_rw = ur->request.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); @@ -1310,7 +1310,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, } int -ugenioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +ugenioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { int endpt = UGENENDPOINT(dev); struct ugen_softc *sc; @@ -1319,14 +1319,14 @@ ugenioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) USB_GET_SC(ugen, UGENUNIT(dev), sc); sc->sc_refcnt++; - error = ugen_do_ioctl(sc, endpt, cmd, addr, flag, p); + error = ugen_do_ioctl(sc, endpt, cmd, addr, flag, td); if (--sc->sc_refcnt < 0) usb_detach_wakeup(USBDEV(sc->sc_dev)); return (error); } int -ugenpoll(dev_t dev, int events, struct proc *p) +ugenpoll(dev_t dev, int events, struct thread *td) { struct ugen_softc *sc; struct ugen_endpoint *sce; @@ -1350,7 +1350,7 @@ ugenpoll(dev_t dev, int events, struct proc *p) if (sce->q.c_cc > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sce->rsel); + selrecord(td, &sce->rsel); } break; case UE_ISOCHRONOUS: @@ -1358,7 +1358,7 @@ ugenpoll(dev_t dev, int events, struct proc *p) if (sce->cur != sce->fill) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sce->rsel); + selrecord(td, &sce->rsel); } break; case UE_BULK: diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 5ae6070..7358fe1 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1613,7 +1613,7 @@ uhci_abort_xfer(usbd_xfer_handle xfer, usbd_status status) timeout(uhci_abort_xfer_end, xfer, hz / USB_FRAMES_PER_SECOND); } else { #if defined(DIAGNOSTIC) && defined(__i386__) && defined(__FreeBSD__) - KASSERT(curproc->p_intr_nesting_level == 0, + KASSERT(curthread->td_intr_nesting_level == 0, ("ohci_abort_req in interrupt context")); #endif usb_delay_ms(xfer->pipe->device->bus, 1); diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index cffc5e5..7914cb3 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -163,7 +163,7 @@ Static void uhid_intr(usbd_xfer_handle, usbd_private_handle, Static int uhid_do_read(struct uhid_softc *, struct uio *uio, int); Static int uhid_do_write(struct uhid_softc *, struct uio *uio, int); Static int uhid_do_ioctl(struct uhid_softc *, u_long, caddr_t, int, - struct proc *); + struct thread *); USB_DECLARE_DRIVER(uhid); @@ -373,11 +373,11 @@ uhid_intr(xfer, addr, status) } int -uhidopen(dev, flag, mode, p) +uhidopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct uhid_softc *sc; usbd_status err; @@ -422,11 +422,11 @@ uhidopen(dev, flag, mode, p) } int -uhidclose(dev, flag, mode, p) +uhidclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct uhid_softc *sc; @@ -588,12 +588,12 @@ uhidwrite(dev, uio, flag) } int -uhid_do_ioctl(sc, cmd, addr, flag, p) +uhid_do_ioctl(sc, cmd, addr, flag, td) struct uhid_softc *sc; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { struct usb_ctl_report_desc *rd; struct usb_ctl_report *re; @@ -614,8 +614,8 @@ uhid_do_ioctl(sc, cmd, addr, flag, p) if (*(int *)addr) { if (sc->sc_async != NULL) return (EBUSY); - sc->sc_async = p; - DPRINTF(("uhid_do_ioctl: FIOASYNC %p\n", p)); + sc->sc_async = td->td_proc; /* XXXKSE */ + DPRINTF(("uhid_do_ioctl: FIOASYNC %p\n", td->td_proc)); } else sc->sc_async = NULL; break; @@ -703,12 +703,12 @@ uhid_do_ioctl(sc, cmd, addr, flag, p) } int -uhidioctl(dev, cmd, addr, flag, p) +uhidioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { struct uhid_softc *sc; int error; @@ -716,17 +716,17 @@ uhidioctl(dev, cmd, addr, flag, p) USB_GET_SC(uhid, UHIDUNIT(dev), sc); sc->sc_refcnt++; - error = uhid_do_ioctl(sc, cmd, addr, flag, p); + error = uhid_do_ioctl(sc, cmd, addr, flag, td); if (--sc->sc_refcnt < 0) usb_detach_wakeup(USBDEV(sc->sc_dev)); return (error); } int -uhidpoll(dev, events, p) +uhidpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { struct uhid_softc *sc; int revents = 0; @@ -744,7 +744,7 @@ uhidpoll(dev, events, p) if (sc->sc_q.c_cc > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->sc_rsel); + selrecord(td, &sc->sc_rsel); } splx(s); diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c index 524bc83..052583b 100644 --- a/sys/dev/usb/ulpt.c +++ b/sys/dev/usb/ulpt.c @@ -467,7 +467,7 @@ int ulptusein = 1; * Reset the printer, then wait until it's selected and not busy. */ int -ulptopen(dev_t dev, int flag, int mode, struct proc *p) +ulptopen(dev_t dev, int flag, int mode, struct thread *td) { u_char flags = ULPTFLAGS(dev); struct ulpt_softc *sc; @@ -586,7 +586,7 @@ ulpt_statusmsg(u_char status, struct ulpt_softc *sc) } int -ulptclose(dev_t dev, int flag, int mode, struct proc *p) +ulptclose(dev_t dev, int flag, int mode, struct thread *td) { struct ulpt_softc *sc; @@ -676,7 +676,7 @@ ulptwrite(dev_t dev, struct uio *uio, int flags) } int -ulptioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +ulptioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int error = 0; diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c index 05c9a47..ad24d94 100644 --- a/sys/dev/usb/umodem.c +++ b/sys/dev/usb/umodem.c @@ -571,10 +571,10 @@ umodemparam(tp, t) } int -umodemopen(dev, flag, mode, p) +umodemopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { int unit = UMODEMUNIT(dev); struct umodem_softc *sc; @@ -599,7 +599,7 @@ umodemopen(dev, flag, mode, p) if (ISSET(tp->t_state, TS_ISOPEN) && ISSET(tp->t_state, TS_XCLUDE) && - suser(p)) + suser_td(td)) return (EBUSY); /* @@ -781,10 +781,10 @@ umodemreadcb(xfer, p, status) } int -umodemclose(dev, flag, mode, p) +umodemclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { struct umodem_softc *sc; struct tty *tp; @@ -924,12 +924,12 @@ umodemtty(dev) } int -umodemioctl(dev, cmd, data, flag, p) +umodemioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct umodem_softc *sc; struct tty *tp; @@ -946,12 +946,12 @@ umodemioctl(dev, cmd, data, flag, p) DPRINTF(("umodemioctl: cmd=0x%08lx\n", cmd)); - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error >= 0) return (error); #if defined(__NetBSD__) || defined(__OpenBSD__) - error = ttioctl(tp, cmd, data, flag, p); + error = ttioctl(tp, cmd, data, flag, td); #elif defined(__FreeBSD__) error = ttioctl(tp, cmd, data, flag); #endif diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index ffabb7b..2a72120 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -586,7 +586,7 @@ ums_disable(priv) } Static int -ums_open(dev_t dev, int flag, int fmt, struct proc *p) +ums_open(dev_t dev, int flag, int fmt, struct thread *td) { struct ums_softc *sc; @@ -596,7 +596,7 @@ ums_open(dev_t dev, int flag, int fmt, struct proc *p) } Static int -ums_close(dev_t dev, int flag, int fmt, struct proc *p) +ums_close(dev_t dev, int flag, int fmt, struct thread *td) { struct ums_softc *sc; @@ -682,7 +682,7 @@ ums_read(dev_t dev, struct uio *uio, int flag) } Static int -ums_poll(dev_t dev, int events, struct proc *p) +ums_poll(dev_t dev, int events, struct thread *td) { struct ums_softc *sc; int revents = 0; @@ -699,7 +699,7 @@ ums_poll(dev_t dev, int events, struct proc *p) revents = events & (POLLIN | POLLRDNORM); } else { sc->state |= UMS_SELECT; - selrecord(p, &sc->rsel); + selrecord(td, &sc->rsel); } } splx(s); @@ -708,7 +708,7 @@ ums_poll(dev_t dev, int events, struct proc *p) } int -ums_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +ums_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct ums_softc *sc; int error = 0; diff --git a/sys/dev/usb/urio.c b/sys/dev/usb/urio.c index 1e86195..e1ad11b 100644 --- a/sys/dev/usb/urio.c +++ b/sys/dev/usb/urio.c @@ -291,11 +291,11 @@ USB_ATTACH(urio) int -urioopen(dev, flag, mode, p) +urioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { #if (USBDI >= 1) struct urio_softc * sc; @@ -335,11 +335,11 @@ urioopen(dev, flag, mode, p) } int -urioclose(dev, flag, mode, p) +urioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { #if (USBDI >= 1) struct urio_softc * sc; @@ -509,12 +509,12 @@ uriowrite(dev, uio, flag) int -urioioctl(dev, cmd, addr, flag, p) +urioioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { #if (USBDI >= 1) struct urio_softc * sc; @@ -584,7 +584,7 @@ urioioctl(dev, cmd, addr, flag, p) uio.uio_rw = req.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 2b4ad42..9457ef2 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -129,7 +129,7 @@ d_open_t usbopen; d_close_t usbclose; d_read_t usbread; d_ioctl_t usbioctl; -int usbpoll(dev_t, int, struct proc *); +d_poll_t usbpoll; struct cdevsw usb_cdevsw = { /* open */ usbopen, @@ -336,10 +336,10 @@ usbctlprint(aux, pnp) #endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ int -usbopen(dev, flag, mode, p) +usbopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { int unit = USBUNIT(dev); struct usb_softc *sc; @@ -398,10 +398,10 @@ usbread(dev, uio, flag) } int -usbclose(dev, flag, mode, p) +usbclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { int unit = USBUNIT(dev); @@ -414,12 +414,12 @@ usbclose(dev, flag, mode, p) } int -usbioctl(devt, cmd, data, flag, p) +usbioctl(devt, cmd, data, flag, td) dev_t devt; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct usb_softc *sc; int unit = USBUNIT(devt); @@ -432,7 +432,7 @@ usbioctl(devt, cmd, data, flag, p) case FIOASYNC: if (*(int *)data) - usb_async_proc = p; + usb_async_proc = td->td_proc; else usb_async_proc = 0; return (0); @@ -492,7 +492,7 @@ usbioctl(devt, cmd, data, flag, p) uio.uio_rw = ur->request.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); @@ -545,10 +545,10 @@ usbioctl(devt, cmd, data, flag, p) } int -usbpoll(dev, events, p) +usbpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { int revents, mask, s; int unit = USBUNIT(dev); @@ -562,7 +562,7 @@ usbpoll(dev, events, p) revents |= events & mask; if (revents == 0 && (events & mask)) { DPRINTFN(2,("usb: sleeping on %p\n", &usb_selevent)); - selrecord(p, &usb_selevent); + selrecord(curthread, &usb_selevent); } splx(s); diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 9acffce..20d6a03 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -931,7 +931,7 @@ usbd_do_request_flags(dev, req, data, flags, actlen) #ifdef DIAGNOSTIC #if defined(__i386__) && defined(__FreeBSD__) - KASSERT(curproc->p_intr_nesting_level == 0, + KASSERT(curthread->td_intr_nesting_level == 0, ("usbd_do_request: in interrupt context")); #endif if (dev->bus->intr_context) { diff --git a/sys/dev/usb/uscanner.c b/sys/dev/usb/uscanner.c index 46728bc..bd33a20 100644 --- a/sys/dev/usb/uscanner.c +++ b/sys/dev/usb/uscanner.c @@ -325,11 +325,11 @@ USB_ATTACH(uscanner) } int -uscanneropen(dev, flag, mode, p) +uscanneropen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct uscanner_softc *sc; int unit = USCANNERUNIT(dev); @@ -388,11 +388,11 @@ uscanneropen(dev, flag, mode, p) } int -uscannerclose(dev, flag, mode, p) +uscannerclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct uscanner_softc *sc; @@ -639,10 +639,10 @@ USB_DETACH(uscanner) } int -uscannerpoll(dev, events, p) +uscannerpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { struct uscanner_softc *sc; int revents = 0; diff --git a/sys/dev/vinum/vinum.c b/sys/dev/vinum/vinum.c index 5824d84..8ac6afa 100644 --- a/sys/dev/vinum/vinum.c +++ b/sys/dev/vinum/vinum.c @@ -238,7 +238,7 @@ vinum_modevent(module_t mod, modeventtype_t type, void *unused) if (!vinum_inactive(1)) /* is anything open? */ return EBUSY; /* yes, we can't do it */ vinum_conf.flags |= VF_STOPPING; /* note that we want to stop */ - sync(curproc, &dummyarg); /* write out buffers */ + sync(curthread, &dummyarg); /* write out buffers */ free_vinum(0); /* clean up */ #ifdef VINUMDEBUG if (total_malloced) { @@ -293,7 +293,7 @@ int vinumopen(dev_t dev, int flags, int fmt, - struct proc *p) + struct thread *td) { int error; unsigned int index; @@ -378,7 +378,7 @@ vinumopen(dev_t dev, } case VINUM_SUPERDEV_TYPE: - error = suser(p); /* are we root? */ + error = suser_td(td); /* are we root? */ if (error == 0) { /* yes, can do */ if (devminor == VINUM_DAEMON_DEV) /* daemon device */ vinum_conf.flags |= VF_DAEMONOPEN; /* we're open */ @@ -402,7 +402,7 @@ int vinumclose(dev_t dev, int flags, int fmt, - struct proc *p) + struct thread *td) { unsigned int index; struct volume *vol; diff --git a/sys/dev/vinum/vinumext.h b/sys/dev/vinum/vinumext.h index 9b96df8..9d98ee8 100644 --- a/sys/dev/vinum/vinumext.h +++ b/sys/dev/vinum/vinumext.h @@ -62,7 +62,7 @@ extern int debug; /* debug flags */ } #ifndef _KERNEL struct vnode; -struct proc; +struct thread; #endif #ifdef _KERNEL @@ -117,7 +117,7 @@ void remove_plex_entry(int plexno, int force, int recurse); void remove_volume_entry(int volno, int force, int recurse); void checkdiskconfig(char *); -int open_drive(struct drive *, struct proc *, int); +int open_drive(struct drive *, struct thread *, int); void close_drive(struct drive *drive); void close_locked_drive(struct drive *drive); int driveio(struct drive *, char *, size_t, off_t, int); @@ -245,7 +245,7 @@ void FFree(void *mem, char *, int); #define LOCKDRIVE(d) lockdrive (d, __FILE__, __LINE__) #else #define Malloc(x) malloc((x), M_DEVBUF, \ - curproc->p_intr_nesting_level == 0? M_WAITOK: M_NOWAIT) + curthread->td_proc->p_intr_nesting_level == 0? M_WAITOK: M_NOWAIT) #define Free(x) free((x), M_DEVBUF) #define LOCKDRIVE(d) lockdrive (d) #endif diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 564d21c..f329137 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -49,7 +49,7 @@ static int drivecmp(const void *va, const void *vb); * Return an error number */ int -open_drive(struct drive *drive, struct proc *p, int verbose) +open_drive(struct drive *drive, struct thread *td, int verbose) { int devmajor; /* major devs for disk device */ int devminor; /* minor devs for disk device */ @@ -216,7 +216,7 @@ init_drive(struct drive *drive, int verbose) log(LOG_ERR, "vinum: Can't open drive without drive name\n"); return EINVAL; } - drive->lasterror = open_drive(drive, curproc, verbose); /* open the drive */ + drive->lasterror = open_drive(drive, curthread, verbose); /* open the drive */ if (drive->lasterror) return drive->lasterror; @@ -224,7 +224,7 @@ init_drive(struct drive *drive, int verbose) DIOCGPART, (caddr_t) & drive->partinfo, FREAD, - curproc); + curthread); if (drive->lasterror) { if (verbose) log(LOG_WARNING, @@ -669,7 +669,7 @@ daemon_save_config(void) DIOCWLABEL, (caddr_t) & wlabel_on, FWRITE, - curproc); + curthread); if (error == 0) error = write_drive(drive, (char *) vhdr, VINUMHEADERLEN, VINUM_LABEL_OFFSET); if (error == 0) @@ -682,7 +682,7 @@ daemon_save_config(void) DIOCWLABEL, (caddr_t) & wlabel_on, FWRITE, - curproc); + curthread); unlockdrive(drive); if (error) { log(LOG_ERR, diff --git a/sys/dev/vinum/vinumioctl.c b/sys/dev/vinum/vinumioctl.c index bef310b..aeafdd2 100644 --- a/sys/dev/vinum/vinumioctl.c +++ b/sys/dev/vinum/vinumioctl.c @@ -66,7 +66,7 @@ vinumioctl(dev_t dev, u_long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { unsigned int objno; int error = 0; @@ -319,8 +319,8 @@ vinumioctl(dev_t dev, default: log(LOG_WARNING, "vinumioctl: invalid ioctl from process %d (%s): %lx\n", - curproc->p_pid, - curproc->p_comm, + curthread->td_proc->p_pid, + curthread->td_proc->p_comm, cmd); return EINVAL; diff --git a/sys/dev/vinum/vinummemory.c b/sys/dev/vinum/vinummemory.c index 5a2093b..6936e48 100644 --- a/sys/dev/vinum/vinummemory.c +++ b/sys/dev/vinum/vinummemory.c @@ -152,7 +152,7 @@ MMalloc(int size, char *file, int line) /* Wait for malloc if we can */ result = malloc(size, M_DEVBUF, - curproc->p_intr_nesting_level == 0 ? M_WAITOK : M_NOWAIT); + curthread->td_intr_nesting_level == 0 ? M_WAITOK : M_NOWAIT); if (result == NULL) log(LOG_ERR, "vinum: can't allocate %d bytes from %s:%d\n", size, file, line); else { diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index 9c7230f..19394c8 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -72,6 +72,7 @@ #include <sys/systm.h> #include <sys/sockio.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/kernel.h> #include <sys/socket.h> #include <sys/module.h> diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c index 0267d93..5ce3dc2 100644 --- a/sys/dev/wl/if_wl.c +++ b/sys/dev/wl/if_wl.c @@ -1145,7 +1145,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) short base = sc->base; short mode = 0; int opri, error = 0; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int irq, irqval, i, isroot; caddr_t up; #ifdef WLCACHE @@ -1254,7 +1254,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* pointer to buffer in user space */ up = (void *)ifr->ifr_data; /* work out if they're root */ - isroot = (suser(p) == 0); + isroot = (suser_td(td) == 0); for (i = 0; i < 0x40; i++) { /* don't hand the DES key out to non-root users */ @@ -1269,7 +1269,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* copy the PSA in from the caller; we only copy _some_ values */ case SIOCSWLPSA: /* root only */ - if ((error = suser(p))) + if ((error = suser_td(td))) break; error = EINVAL; /* assume the worst */ /* pointer to buffer in user space containing data */ @@ -1323,7 +1323,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ case SIOCSWLCNWID: /* root only */ - if ((error = suser(p))) + if ((error = suser_td(td))) break; if (!(ifp->if_flags & IFF_UP)) { error = EIO; /* only allowed while up */ @@ -1341,7 +1341,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* copy the EEPROM in 2.4 Gz WaveMODEM out to the caller */ case SIOCGWLEEPROM: /* root only */ - if ((error = suser(p))) + if ((error = suser_td(td))) break; /* pointer to buffer in user space */ up = (void *)ifr->ifr_data; @@ -1364,7 +1364,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* zero (Delete) the wl cache */ case SIOCDWLCACHE: /* root only */ - if ((error = suser(p))) + if ((error = suser_td(td))) break; wl_cache_zero(unit); break; diff --git a/sys/fs/cd9660/cd9660_lookup.c b/sys/fs/cd9660/cd9660_lookup.c index b2d5057..979c0bd 100644 --- a/sys/fs/cd9660/cd9660_lookup.c +++ b/sys/fs/cd9660/cd9660_lookup.c @@ -120,7 +120,7 @@ cd9660_lookup(ap) struct componentname *cnp = ap->a_cnp; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; bp = NULL; *vpp = NULL; @@ -351,16 +351,16 @@ found: * it's a relocated directory. */ if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp, dp->i_ino != ino, ep); brelse(bp); if (error) { - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (lockparent && (flags & ISLASTCN)) { - if ((error = vn_lock(pdp, LK_EXCLUSIVE, p)) != 0) { + if ((error = vn_lock(pdp, LK_EXCLUSIVE, td)) != 0) { cnp->cn_flags |= PDIRUNLOCK; vput(tdp); return (error); @@ -380,7 +380,7 @@ found: return (error); if (!lockparent || !(flags & ISLASTCN)) { cnp->cn_flags |= PDIRUNLOCK; - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); } *vpp = tdp; } diff --git a/sys/fs/cd9660/cd9660_node.c b/sys/fs/cd9660/cd9660_node.c index 00f79e8..53ffeca 100644 --- a/sys/fs/cd9660/cd9660_node.c +++ b/sys/fs/cd9660/cd9660_node.c @@ -97,7 +97,7 @@ cd9660_ihashget(dev, inum) dev_t dev; ino_t inum; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct iso_node *ip; struct vnode *vp; @@ -108,7 +108,7 @@ loop: vp = ITOV(ip); mtx_lock(&vp->v_interlock); mtx_unlock(&cd9660_ihash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -124,7 +124,6 @@ void cd9660_ihashins(ip) struct iso_node *ip; { - struct proc *p = curproc; /* XXX */ struct iso_node **ipp, *iq; mtx_lock(&cd9660_ihash_mtx); @@ -136,7 +135,7 @@ cd9660_ihashins(ip) *ipp = ip; mtx_unlock(&cd9660_ihash_mtx); - lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p); + lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, curthread); } /* @@ -167,11 +166,11 @@ int cd9660_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; register struct iso_node *ip = VTOI(vp); int error = 0; @@ -179,13 +178,13 @@ cd9660_inactive(ap) vprint("cd9660_inactive: pushing active", vp); ip->i_flag = 0; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * If we are done with the inode, reclaim it * so that it can be reused immediately. */ if (ip->inode.iso_mode == 0) - vrecycle(vp, NULL, p); + vrecycle(vp, NULL, td); return error; } @@ -196,7 +195,7 @@ int cd9660_reclaim(ap) struct vop_reclaim_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 0b42933..73a5bce 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -65,10 +65,10 @@ MALLOC_DEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure"); MALLOC_DEFINE(M_ISOFSNODE, "ISOFS node", "ISOFS vnode private part"); static int cd9660_mount __P((struct mount *, - char *, caddr_t, struct nameidata *, struct proc *)); -static int cd9660_unmount __P((struct mount *, int, struct proc *)); + char *, caddr_t, struct nameidata *, struct thread *)); +static int cd9660_unmount __P((struct mount *, int, struct thread *)); static int cd9660_root __P((struct mount *, struct vnode **)); -static int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); +static int cd9660_statfs __P((struct mount *, struct statfs *, struct thread *)); static int cd9660_vget __P((struct mount *, ino_t, struct vnode **)); static int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **)); static int cd9660_vptofh __P((struct vnode *, struct fid *)); @@ -97,9 +97,9 @@ MODULE_VERSION(cd9660, 1); * Called by vfs_mountroot when iso is going to be mounted as root. */ -static int iso_get_ssector __P((dev_t dev, struct proc *p)); +static int iso_get_ssector __P((dev_t dev, struct thread *td)); static int iso_mountfs __P((struct vnode *devvp, struct mount *mp, - struct proc *p, struct iso_args *argp)); + struct thread *td, struct iso_args *argp)); /* * Try to find the start of the last data track on this CD-ROM. This @@ -107,9 +107,9 @@ static int iso_mountfs __P((struct vnode *devvp, struct mount *mp, * and return 0 if we fail, this is always a safe bet. */ static int -iso_get_ssector(dev, p) +iso_get_ssector(dev, td) dev_t dev; - struct proc *p; + struct thread *td; { struct ioc_toc_header h; struct ioc_read_toc_single_entry t; @@ -122,13 +122,13 @@ iso_get_ssector(dev, p) if (ioctlp == NULL) return 0; - if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p) != 0) + if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, td) != 0) return 0; for (i = h.ending_track; i >= 0; i--) { t.address_format = CD_LBA_FORMAT; t.track = i; - if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, p) != 0) + if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, td) != 0) return 0; if ((t.entry.control & 4) != 0) /* found a data track */ @@ -141,12 +141,12 @@ iso_get_ssector(dev, p) return ntohl(t.entry.addr.lba); } -static int iso_mountroot __P((struct mount *mp, struct proc *p)); +static int iso_mountroot __P((struct mount *mp, struct thread *td)); static int -iso_mountroot(mp, p) +iso_mountroot(mp, td) struct mount *mp; - struct proc *p; + struct thread *td; { struct iso_args args; int error; @@ -156,14 +156,14 @@ iso_mountroot(mp, p) return (error); } args.flags = ISOFSMNT_ROOT; - args.ssector = iso_get_ssector(rootdev, p); + args.ssector = iso_get_ssector(rootdev, td); if (bootverbose) printf("iso_mountroot(): using session at block %d\n", args.ssector); - if ((error = iso_mountfs(rootvp, mp, p, &args)) != 0) + if ((error = iso_mountfs(rootvp, mp, td, &args)) != 0) return (error); - (void)cd9660_statfs(mp, &mp->mnt_stat, p); + (void)cd9660_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -173,12 +173,12 @@ iso_mountroot(mp, p) * mount system call */ static int -cd9660_mount(mp, path, data, ndp, p) +cd9660_mount(mp, path, data, ndp, td) register struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *devvp; struct iso_args args; @@ -188,7 +188,7 @@ cd9660_mount(mp, path, data, ndp, p) struct iso_mnt *imp = 0; if ((mp->mnt_flag & MNT_ROOTFS) != 0) { - return (iso_mountroot(mp, p)); + return (iso_mountroot(mp, td)); } if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args)))) return (error); @@ -209,7 +209,7 @@ cd9660_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); if ((error = namei(ndp))) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -225,18 +225,18 @@ cd9660_mount(mp, path, data, ndp, p) * or has superuser abilities */ accessmode = VREAD; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td); if (error) - error = suser(p); + error = suser_td(td); if (error) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = iso_mountfs(devvp, mp, p, &args); + error = iso_mountfs(devvp, mp, td, &args); } else { if (devvp != imp->im_devvp) error = EINVAL; /* needs translation */ @@ -251,7 +251,7 @@ cd9660_mount(mp, path, data, ndp, p) (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) cd9660_statfs(mp, &mp->mnt_stat, p); + (void) cd9660_statfs(mp, &mp->mnt_stat, td); return 0; } @@ -259,10 +259,10 @@ cd9660_mount(mp, path, data, ndp, p) * Common code for mount and mountroot */ static int -iso_mountfs(devvp, mp, p, argp) +iso_mountfs(devvp, mp, td, argp) register struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; struct iso_args *argp; { register struct iso_mnt *isomp = (struct iso_mnt *)0; @@ -295,12 +295,12 @@ iso_mountfs(devvp, mp, p, argp) return error; if (vcount(devvp) > 1 && devvp != rootvp) return EBUSY; - if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))) + if ((error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0))) return (error); - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, FREAD, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, FREAD, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return error; @@ -510,7 +510,7 @@ out: if (supbp) brelse(supbp); if (needclose) - (void)VOP_CLOSE(devvp, FREAD, NOCRED, p); + (void)VOP_CLOSE(devvp, FREAD, NOCRED, td); if (isomp) { free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; @@ -522,10 +522,10 @@ out: * unmount system call */ static int -cd9660_unmount(mp, mntflags, p) +cd9660_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct iso_mnt *isomp; int error, flags = 0; @@ -543,7 +543,7 @@ cd9660_unmount(mp, mntflags, p) isomp = VFSTOISOFS(mp); isomp->im_devvp->v_rdev->si_mountpoint = NULL; - error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p); + error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, td); vrele(isomp->im_devvp); free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; @@ -576,10 +576,10 @@ cd9660_root(mp, vpp) * Get file system statistics. */ int -cd9660_statfs(mp, sbp, p) +cd9660_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { register struct iso_mnt *isomp; diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 702823e..a902b58 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -87,7 +87,7 @@ cd9660_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -128,7 +128,7 @@ cd9660_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -162,7 +162,7 @@ cd9660_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -197,7 +197,7 @@ cd9660_getattr(ap) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = ap->a_p; + auio.uio_td = ap->a_td; auio.uio_resid = MAXPATHLEN; rdlnk.a_uio = &auio; rdlnk.a_vp = ap->a_vp; @@ -226,7 +226,7 @@ cd9660_ioctl(ap) caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; diff --git a/sys/fs/coda/coda_psdev.c b/sys/fs/coda/coda_psdev.c index 0d8560f..2346c7c 100644 --- a/sys/fs/coda/coda_psdev.c +++ b/sys/fs/coda/coda_psdev.c @@ -117,11 +117,11 @@ vcodaattach(n) } int -vc_nb_open(dev, flag, mode, p) +vc_nb_open(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; /* NetBSD only */ + struct thread *td; /* NetBSD only */ { register struct vcomm *vcp; @@ -149,11 +149,11 @@ vc_nb_open(dev, flag, mode, p) } int -vc_nb_close (dev, flag, mode, p) +vc_nb_close (dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { register struct vcomm *vcp; register struct vmsg *vmp, *nvmp = NULL; @@ -225,7 +225,7 @@ vc_nb_close (dev, flag, mode, p) #endif } - err = dounmount(mi->mi_vfsp, flag, p); + err = dounmount(mi->mi_vfsp, flag, td); if (err) myprintf(("Error %d unmounting vfs in vcclose(%d)\n", err, minor(dev))); @@ -387,12 +387,12 @@ vc_nb_write(dev, uiop, flag) } int -vc_nb_ioctl(dev, cmd, addr, flag, p) +vc_nb_ioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { ENTRY; @@ -441,10 +441,10 @@ vc_nb_ioctl(dev, cmd, addr, flag, p) } int -vc_nb_poll(dev, events, p) +vc_nb_poll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { register struct vcomm *vcp; int event_msk = 0; @@ -463,7 +463,7 @@ vc_nb_poll(dev, events, p) if (!EMPTY(vcp->vc_requests)) return(events & (POLLIN|POLLRDNORM)); - selrecord(p, &(vcp->vc_selproc)); + selrecord(curthread, &(vcp->vc_selproc)); return(0); } @@ -490,7 +490,8 @@ coda_call(mntinfo, inSize, outSize, buffer) struct vmsg *vmp; int error; #ifdef CTL_C - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; sigset_t psig_omask; sigset_t tempset; int i; diff --git a/sys/fs/coda/coda_psdev.h b/sys/fs/coda/coda_psdev.h index c6276f3..c6ecf7f 100644 --- a/sys/fs/coda/coda_psdev.h +++ b/sys/fs/coda/coda_psdev.h @@ -31,9 +31,9 @@ * */ -int vc_nb_open(dev_t dev, int flag, int mode, struct proc *p); -int vc_nb_close (dev_t dev, int flag, int mode, struct proc *p); +int vc_nb_open(dev_t dev, int flag, int mode, struct thread *p); +int vc_nb_close (dev_t dev, int flag, int mode, struct thread *p); int vc_nb_read(dev_t dev, struct uio *uiop, int flag); int vc_nb_write(dev_t dev, struct uio *uiop, int flag); -int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p); -int vc_nb_poll(dev_t dev, int events, struct proc *p); +int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *p); +int vc_nb_poll(dev_t dev, int events, struct thread *p); diff --git a/sys/fs/coda/coda_vfsops.c b/sys/fs/coda/coda_vfsops.c index 8bcd36f..d01d5a7 100644 --- a/sys/fs/coda/coda_vfsops.c +++ b/sys/fs/coda/coda_vfsops.c @@ -83,7 +83,7 @@ struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE]; #define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++) extern int coda_nc_initialized; /* Set if cache has been initialized */ -extern int vc_nb_open __P((dev_t, int, int, struct proc *)); +extern int vc_nb_open __P((dev_t, int, int, struct thread *)); int coda_vfsopstats_init(void) @@ -107,12 +107,12 @@ coda_vfsopstats_init(void) */ /*ARGSUSED*/ int -coda_mount(vfsp, path, data, ndp, p) +coda_mount(vfsp, path, data, ndp, td) struct mount *vfsp; /* Allocated and initialized by mount(2) */ char *path; /* path covered: ignored by the fs-layer */ caddr_t data; /* Need to define a data type for this in netbsd? */ struct nameidata *ndp; /* Clobber this to lookup the device name */ - struct proc *p; /* The ever-famous proc pointer */ + struct thread *td; /* The ever-famous proc pointer */ { struct vnode *dvp; struct cnode *cp; @@ -135,7 +135,7 @@ coda_mount(vfsp, path, data, ndp, p) } /* Validate mount device. Similar to getmdev(). */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, td); error = namei(ndp); dvp = ndp->ni_vp; @@ -233,10 +233,10 @@ coda_mount(vfsp, path, data, ndp, p) } int -coda_unmount(vfsp, mntflags, p) +coda_unmount(vfsp, mntflags, td) struct mount *vfsp; int mntflags; - struct proc *p; + struct thread *td; { struct coda_mntinfo *mi = vftomi(vfsp); int active, error = 0; @@ -292,8 +292,12 @@ coda_root(vfsp, vpp) struct coda_mntinfo *mi = vftomi(vfsp); struct vnode **result; int error; - struct proc *p = curproc; /* XXX - bnoble */ + struct thread *td = curthread; /* XXX - bnoble */ + struct proc *p = td->td_proc; ViceFid VFid; + + ENTRY; + ENTRY; MARK_ENTRY(CODA_ROOT_STATS); @@ -308,9 +312,9 @@ coda_root(vfsp, vpp) /* On Mach, this is vref. On NetBSD, VOP_LOCK */ #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_SAT(CODA_ROOT_STATS); return(0); @@ -331,9 +335,9 @@ coda_root(vfsp, vpp) *vpp = mi->mi_rootvp; #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_SAT(CODA_ROOT_STATS); @@ -351,9 +355,9 @@ coda_root(vfsp, vpp) *vpp = mi->mi_rootvp; #if 1 vref(*vpp); - vn_lock(*vpp, LK_EXCLUSIVE, p); + vn_lock(*vpp, LK_EXCLUSIVE, td); #else - vget(*vpp, LK_EXCLUSIVE, p); + vget(*vpp, LK_EXCLUSIVE, td); #endif MARK_INT_FAIL(CODA_ROOT_STATS); @@ -374,10 +378,10 @@ coda_root(vfsp, vpp) * Get file system statistics. */ int -coda_nb_statfs(vfsp, sbp, p) +coda_nb_statfs(vfsp, sbp, td) register struct mount *vfsp; struct statfs *sbp; - struct proc *p; + struct thread *td; { ENTRY; /* MARK_ENTRY(CODA_STATFS_STATS); */ @@ -412,11 +416,11 @@ coda_nb_statfs(vfsp, sbp, p) * Flush any pending I/O. */ int -coda_sync(vfsp, waitfor, cred, p) +coda_sync(vfsp, waitfor, cred, td) struct mount *vfsp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { ENTRY; MARK_ENTRY(CODA_SYNC_STATS); @@ -441,7 +445,8 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) struct cfid *cfid = (struct cfid *)fhp; struct cnode *cp = 0; int error; - struct proc *p = curproc; /* XXX -mach */ + struct thread *td = curthread; /* XXX -mach */ + struct proc *p = td->td_proc; ViceFid VFid; int vtype; diff --git a/sys/fs/coda/coda_vfsops.h b/sys/fs/coda/coda_vfsops.h index 7fc9adf..57b9a5a 100644 --- a/sys/fs/coda/coda_vfsops.h +++ b/sys/fs/coda/coda_vfsops.h @@ -48,13 +48,13 @@ struct mount; int coda_vfsopstats_init(void); int coda_mount(struct mount *, char *, caddr_t, struct nameidata *, - struct proc *); -int coda_start(struct mount *, int, struct proc *); -int coda_unmount(struct mount *, int, struct proc *); + struct thread *); +int coda_start(struct mount *, int, struct thread *); +int coda_unmount(struct mount *, int, struct thread *); int coda_root(struct mount *, struct vnode **); -int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *); -int coda_nb_statfs(struct mount *, struct statfs *, struct proc *); -int coda_sync(struct mount *, int, struct ucred *, struct proc *); +int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *); +int coda_nb_statfs(struct mount *, struct statfs *, struct thread *); +int coda_sync(struct mount *, int, struct ucred *, struct thread *); int coda_vget(struct mount *, ino_t, struct vnode **); int coda_fhtovp(struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **); diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c index dd0a96e..8fd7170d 100644 --- a/sys/fs/coda/coda_vnops.c +++ b/sys/fs/coda/coda_vnops.c @@ -235,7 +235,7 @@ coda_open(v) struct cnode *cp = VTOC(*vpp); int flag = ap->a_mode & (~O_EXCL); struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; struct vnode *vp; @@ -256,7 +256,7 @@ coda_open(v) return(0); } - error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, p, &dev, &inode); + error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode); if (error) return (error); if (!error) { @@ -272,7 +272,7 @@ coda_open(v) return (error); /* We get the vnode back locked. Needs unlocked */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* Keep a reference until the close comes in. */ vref(*vpp); @@ -297,14 +297,14 @@ coda_open(v) cp->c_inode = inode; /* Open the cache file. */ - error = VOP_OPEN(vp, flag, cred, p); + error = VOP_OPEN(vp, flag, cred, td); if (error) { printf("coda_open: VOP_OPEN on container failed %d\n", error); return (error); } /* grab (above) does this when it calls newvnode unless it's in the cache*/ if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_open: vfs_object_create() returns %d\n", error); vput(vp); @@ -327,7 +327,7 @@ coda_close(v) struct cnode *cp = VTOC(vp); int flag = ap->a_fflag; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -348,7 +348,7 @@ coda_close(v) #ifdef hmm vgone(cp->c_ovp); #else - VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */ + VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */ vrele(cp->c_ovp); #endif } else { @@ -358,7 +358,7 @@ coda_close(v) } return ENODEV; } else { - VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */ + VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */ vrele(cp->c_ovp); } @@ -368,7 +368,7 @@ coda_close(v) if (flag & FWRITE) /* file was opened for write */ --cp->c_owrite; - error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, p); + error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc); vrele(CTOV(cp)); CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); ) @@ -383,7 +383,7 @@ coda_read(v) ENTRY; return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ, - ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp)); + ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td)); } int @@ -394,24 +394,25 @@ coda_write(v) ENTRY; return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE, - ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp)); + ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td)); } int -coda_rdwr(vp, uiop, rw, ioflag, cred, p) +coda_rdwr(vp, uiop, rw, ioflag, cred, td) struct vnode *vp; struct uio *uiop; enum uio_rw rw; int ioflag; struct ucred *cred; - struct proc *p; + struct thread *td; { /* upcall decl */ /* NOTE: container file operation!!! */ /* locals */ struct cnode *cp = VTOC(vp); struct vnode *cfvp = cp->c_ovp; - struct proc *lp = p; + struct proc *p = td->td_proc; + struct thread *ltd = td; int igot_internally = 0; int opened_internally = 0; int error = 0; @@ -448,7 +449,7 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) PROC_UNLOCK(p); } else - lp = curproc; + ltd = curthread; if (cp->c_inode != 0 && !iscore) { igot_internally = 1; @@ -458,23 +459,23 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) return(error); } /* - * We get the vnode back locked by curproc in both Mach and + * We get the vnode back locked by curthread in both Mach and * NetBSD. Needs unlocked */ - VOP_UNLOCK(cfvp, 0, lp); + VOP_UNLOCK(cfvp, 0, ltd); } else { opened_internally = 1; MARK_INT_GEN(CODA_OPEN_STATS); error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE), - cred, p); + cred, td); printf("coda_rdwr: Internally Opening %p\n", vp); if (error) { printf("coda_rdwr: VOP_OPEN on container failed %d\n", error); return (error); } if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_rdwr: vfs_object_create() returns %d\n", error); vput(vp); @@ -501,7 +502,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp); { struct vattr attr; - if (VOP_GETATTR(cfvp, &attr, cred, p) == 0) { + if (VOP_GETATTR(cfvp, &attr, cred, td) == 0) { vnode_pager_setsize(vp, attr.va_size); } } @@ -515,7 +516,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp); /* Do an internal close if necessary. */ if (opened_internally) { MARK_INT_GEN(CODA_CLOSE_STATS); - (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, p); + (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td); } /* Invalidate cached attributes if writing. */ @@ -537,7 +538,7 @@ coda_ioctl(v) caddr_t data = ap->a_data; int flag = ap->a_fflag; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; struct vnode *tvp; @@ -562,7 +563,7 @@ coda_ioctl(v) /* Should we use the name cache here? It would get it from lookupname sooner or later anyway, right? */ - NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, p); + NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, td); error = namei(&ndp); tvp = ndp.ni_vp; @@ -591,7 +592,7 @@ coda_ioctl(v) NDFREE(&ndp, 0); return(EINVAL); } - error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, p); + error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, td->td_proc); if (error) MARK_INT_FAIL(CODA_IOCTL_STATS); @@ -622,7 +623,7 @@ coda_getattr(v) struct cnode *cp = VTOC(vp); struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -651,7 +652,7 @@ coda_getattr(v) return(0); } - error = venus_getattr(vtomi(vp), &cp->c_fid, cred, p, vap); + error = venus_getattr(vtomi(vp), &cp->c_fid, cred, td->td_proc, vap); if (!error) { CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n", @@ -689,7 +690,7 @@ coda_setattr(v) struct cnode *cp = VTOC(vp); register struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -704,7 +705,7 @@ coda_setattr(v) if (codadebug & CODADBGMSK(CODA_SETATTR)) { print_vattr(vap); } - error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, p); + error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, td->td_proc); if (!error) cp->c_flags &= ~C_VATTR; @@ -729,7 +730,7 @@ coda_access(v) struct cnode *cp = VTOC(vp); int mode = ap->a_mode; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ int error; @@ -758,7 +759,7 @@ coda_access(v) } } - error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, p); + error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, td->td_proc); return(error); } @@ -773,7 +774,7 @@ coda_readlink(v) struct cnode *cp = VTOC(vp); struct uio *uiop = ap->a_uio; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; /* locals */ int error; char *str; @@ -797,7 +798,7 @@ coda_readlink(v) return(error); } - error = venus_readlink(vtomi(vp), &cp->c_fid, cred, p, &str, &len); + error = venus_readlink(vtomi(vp), &cp->c_fid, cred, td->td_proc, &str, &len); if (!error) { uiop->uio_rw = UIO_READ; @@ -824,7 +825,7 @@ coda_fsync(v) struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* locals */ struct vnode *convp = cp->c_ovp; int error; @@ -847,7 +848,7 @@ coda_fsync(v) } if (convp) - VOP_FSYNC(convp, cred, MNT_WAIT, p); + VOP_FSYNC(convp, cred, MNT_WAIT, td); /* * We see fsyncs with usecount == 1 then usecount == 0. @@ -873,7 +874,7 @@ coda_fsync(v) /* needs research */ return 0; - error = venus_fsync(vtomi(vp), &cp->c_fid, cred, p); + error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc); CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); ); return(error); @@ -890,7 +891,7 @@ coda_inactive(v) struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); struct ucred *cred __attribute__((unused)) = NULL; - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -930,7 +931,7 @@ coda_inactive(v) printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n", vp->v_usecount, vp, cp); #endif - lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, p); + lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, td); } else { #ifdef OLD_DIAGNOSTIC if (CTOV(cp)->v_usecount) { @@ -940,7 +941,7 @@ coda_inactive(v) panic("coda_inactive: cp->ovp != NULL"); } #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vgone(vp); } @@ -972,7 +973,7 @@ coda_lookup(v) */ struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ struct cnode *cp; const char *nm = cnp->cn_nameptr; @@ -1015,7 +1016,7 @@ coda_lookup(v) } else { /* The name wasn't cached, so we need to contact Venus */ - error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, p, &VFid, &vtype); + error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc, &VFid, &vtype); if (error) { MARK_INT_FAIL(CODA_LOOKUP_STATS); @@ -1086,7 +1087,7 @@ coda_lookup(v) */ if (!error || (error == EJUSTRETURN)) { if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) { - if ((error = VOP_UNLOCK(dvp, 0, p))) { + if ((error = VOP_UNLOCK(dvp, 0, td))) { return error; } /* @@ -1094,7 +1095,7 @@ coda_lookup(v) * lock it without bothering to check anything else. */ if (*ap->a_vpp) { - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_lookup: "); panic("unlocked parent but couldn't lock child"); } @@ -1103,7 +1104,7 @@ coda_lookup(v) /* The parent is locked, and may be the same as the child */ if (*ap->a_vpp && (*ap->a_vpp != dvp)) { /* Different, go ahead and lock it. */ - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_lookup: "); panic("unlocked parent but couldn't lock child"); } @@ -1132,7 +1133,7 @@ coda_create(v) struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; struct cnode *cp; @@ -1153,7 +1154,7 @@ coda_create(v) return(EACCES); } - error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, p, &VFid, &attr); + error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, td->td_proc, &VFid, &attr); if (!error) { @@ -1192,7 +1193,7 @@ coda_create(v) if (!error) { if (cnp->cn_flags & LOCKLEAF) { - if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) { + if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) { printf("coda_create: "); panic("unlocked parent but couldn't lock child"); } @@ -1216,7 +1217,7 @@ coda_remove(v) struct cnode *cp = VTOC(dvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1259,7 +1260,7 @@ coda_remove(v) return(ENOENT); } - error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, p); + error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, td->td_proc); CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); ) @@ -1278,7 +1279,7 @@ coda_link(v) struct cnode *tdcp = VTOC(tdvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1308,7 +1309,7 @@ coda_link(v) return(EACCES); } - error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, p); + error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, td->td_proc); /* Invalidate the parent's attr cache, the modification time has changed */ VTOC(tdvp)->c_flags &= ~C_VATTR; @@ -1332,7 +1333,7 @@ coda_rename(v) struct cnode *ndcp = VTOC(ndvp); struct componentname *tcnp = ap->a_tcnp; struct ucred *cred = fcnp->cn_cred; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; /* true args */ int error; const char *fnm = fcnp->cn_nameptr; @@ -1346,7 +1347,7 @@ coda_rename(v) This could be Bad. XXX */ #ifdef OLD_DIAGNOSTIC if ((fcnp->cn_cred != tcnp->cn_cred) - || (fcnp->cn_proc != tcnp->cn_proc)) + || (fcnp->cn_thread != tcnp->cn_thread)) { panic("coda_rename: component names don't agree"); } @@ -1389,7 +1390,7 @@ coda_rename(v) goto exit; } - error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, p); + error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, td->td_proc); exit: CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));) @@ -1426,7 +1427,7 @@ coda_mkdir(v) register struct vattr *va = ap->a_vap; struct vnode **vpp = ap->a_vpp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1450,7 +1451,7 @@ coda_mkdir(v) return(EACCES); } - error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, p, &VFid, &ova); + error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, td->td_proc, &VFid, &ova); if (!error) { if (coda_find(&VFid) != NULL) @@ -1495,7 +1496,7 @@ coda_rmdir(v) struct cnode *dcp = VTOC(dvp); struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* true args */ int error; const char *nm = cnp->cn_nameptr; @@ -1527,7 +1528,7 @@ coda_rmdir(v) /* Invalidate the parent's attr cache, the modification time has changed */ dcp->c_flags &= ~C_VATTR; - error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, p); + error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc); CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); ) @@ -1546,7 +1547,7 @@ coda_symlink(v) struct vattr *tva = ap->a_vap; char *path = ap->a_target; struct ucred *cred = cnp->cn_cred; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode **vpp = ap->a_vpp; /* locals */ int error; @@ -1589,7 +1590,7 @@ coda_symlink(v) goto exit; } - error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, p); + error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, td->td_proc); /* Invalidate the parent's attr cache, the modification time has changed */ tdcp->c_flags &= ~C_VATTR; @@ -1618,7 +1619,7 @@ coda_readdir(v) int *eofflag = ap->a_eofflag; u_long **cookies = ap->a_cookies; int *ncookies = ap->a_ncookies; - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; /* upcall decl */ /* locals */ int error = 0; @@ -1643,14 +1644,14 @@ coda_readdir(v) if (cp->c_ovp == NULL) { opened_internally = 1; MARK_INT_GEN(CODA_OPEN_STATS); - error = VOP_OPEN(vp, FREAD, cred, p); + error = VOP_OPEN(vp, FREAD, cred, td); printf("coda_readdir: Internally Opening %p\n", vp); if (error) { printf("coda_readdir: VOP_OPEN on container failed %d\n", error); return (error); } if (vp->v_type == VREG) { - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error != 0) { printf("coda_readdir: vfs_object_create() returns %d\n", error); vput(vp); @@ -1672,7 +1673,7 @@ printf("coda_readdir: Internally Opening %p\n", vp); /* Do an "internal close" if necessary. */ if (opened_internally) { MARK_INT_GEN(CODA_CLOSE_STATS); - (void)VOP_CLOSE(vp, FREAD, cred, p); + (void)VOP_CLOSE(vp, FREAD, cred, td); } } @@ -1693,7 +1694,7 @@ coda_bmap(v) daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */ struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */ daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */ - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -1731,7 +1732,7 @@ coda_strategy(v) /* true args */ struct vop_strategy_args *ap = v; register struct buf *bp __attribute__((unused)) = ap->a_bp; - struct proc *p __attribute__((unused)) = curproc; + struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ /* locals */ @@ -1786,7 +1787,7 @@ coda_lock(v) struct vop_lock_args *ap = v; struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* upcall decl */ /* locals */ @@ -1798,9 +1799,9 @@ coda_lock(v) } #ifndef DEBUG_LOCKS - return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p)); + return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td)); #else - return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p, + return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td, "coda_lock", vp->filename, vp->line)); #endif } @@ -1813,7 +1814,7 @@ coda_unlock(v) struct vop_unlock_args *ap = v; struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; /* upcall decl */ /* locals */ @@ -1823,7 +1824,7 @@ coda_unlock(v) cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique)); } - return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, td)); } int @@ -1835,7 +1836,7 @@ coda_islocked(v) struct cnode *cp = VTOC(ap->a_vp); ENTRY; - return (lockstatus(&cp->c_lock, ap->a_p)); + return (lockstatus(&cp->c_lock, ap->a_td)); } /* How one looks up a vnode given a device/inode pair: */ diff --git a/sys/fs/coda/coda_vnops.h b/sys/fs/coda/coda_vnops.h index 9fcd978..663d357 100644 --- a/sys/fs/coda/coda_vnops.h +++ b/sys/fs/coda/coda_vnops.h @@ -82,7 +82,7 @@ int coda_fbsd_getpages __P((void *)); int (**coda_vnodeop_p)(void *); int coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, - int ioflag, struct ucred *cred, struct proc *p); + int ioflag, struct ucred *cred, struct thread *td); int coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp); void print_vattr(struct vattr *attr); void print_cred(struct ucred *cred); diff --git a/sys/fs/devfs/devfs.h b/sys/fs/devfs/devfs.h index 28640ce..598fbf0 100644 --- a/sys/fs/devfs/devfs.h +++ b/sys/fs/devfs/devfs.h @@ -104,7 +104,7 @@ struct devfs_mount { extern vop_t **devfs_vnodeop_p; extern vop_t **devfs_specop_p; -int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct proc *p); +int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td); dev_t *devfs_itod (int inode); struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode); int devfs_populate (struct devfs_mount *dm); diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 9f19fca..6b406be 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -283,7 +283,7 @@ devfs_populate(struct devfs_mount *dm) if (dm->dm_generation == devfs_generation) return (0); - lockmgr(&dm->dm_lock, LK_UPGRADE, 0, curproc); + lockmgr(&dm->dm_lock, LK_UPGRADE, 0, curthread); if (devfs_noverflow && dm->dm_overflow == NULL) { i = devfs_noverflow * sizeof (struct devfs_dirent *); MALLOC(dm->dm_overflow, struct devfs_dirent **, i, @@ -358,7 +358,7 @@ devfs_populate(struct devfs_mount *dm) #endif } } - lockmgr(&dm->dm_lock, LK_DOWNGRADE, 0, curproc); + lockmgr(&dm->dm_lock, LK_DOWNGRADE, 0, curthread); return (0); } diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c index 2d1aa90..e970c5a 100644 --- a/sys/fs/devfs/devfs_vfsops.c +++ b/sys/fs/devfs/devfs_vfsops.c @@ -52,23 +52,23 @@ MALLOC_DEFINE(M_DEVFS, "DEVFS", "DEVFS data"); static int devfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int devfs_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); static int devfs_root __P((struct mount *mp, struct vnode **vpp)); static int devfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); /* * Mount the filesystem */ static int -devfs_mount(mp, path, data, ndp, p) +devfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error; struct devfs_mount *fmp; @@ -101,20 +101,20 @@ devfs_mount(mp, path, data, ndp, p) FREE(fmp, M_DEVFS); return (error); } - VOP_UNLOCK(rvp, 0, p); + VOP_UNLOCK(rvp, 0, td); bzero(mp->mnt_stat.f_mntfromname, MNAMELEN); bcopy("devfs", mp->mnt_stat.f_mntfromname, sizeof("devfs")); - (void)devfs_statfs(mp, &mp->mnt_stat, p); + (void)devfs_statfs(mp, &mp->mnt_stat, td); return (0); } static int -devfs_unmount(mp, mntflags, p) +devfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error; int flags = 0; @@ -142,13 +142,13 @@ devfs_root(mp, vpp) struct vnode **vpp; { int error; - struct proc *p; + struct thread *td; struct vnode *vp; struct devfs_mount *dmp; - p = curproc; /* XXX */ + td = curthread; /* XXX */ dmp = VFSTODEVFS(mp); - error = devfs_allocv(dmp->dm_rootdir, mp, &vp, p); + error = devfs_allocv(dmp->dm_rootdir, mp, &vp, td); if (error) return (error); vp->v_flag |= VROOT; @@ -157,10 +157,10 @@ devfs_root(mp, vpp) } static int -devfs_statfs(mp, sbp, p) +devfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { sbp->f_flags = 0; diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index bafc3b3..ba6231c 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -111,18 +111,18 @@ devfs_fqpn(char *buf, struct vnode *dvp, struct componentname *cnp) } int -devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct proc *p) +devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td) { int error; struct vnode *vp; dev_t dev; - if (p == NULL) - p = curproc; /* XXX */ + if (td == NULL) + td = curthread; /* XXX */ loop: vp = de->de_vnode; if (vp != NULL) { - if (vget(vp, LK_EXCLUSIVE, p ? p : curproc)) + if (vget(vp, LK_EXCLUSIVE, td ? td : curthread)) goto loop; *vpp = vp; return (0); @@ -153,7 +153,7 @@ loop: } vp->v_data = de; de->de_vnode = vp; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = vp; return (0); } @@ -164,7 +164,7 @@ devfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -184,7 +184,7 @@ devfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -252,7 +252,7 @@ devfs_lookupx(ap) { struct componentname *cnp; struct vnode *dvp, **vpp; - struct proc *p; + struct thread *td; struct devfs_dirent *de, *dd; struct devfs_mount *dmp; dev_t cdev, *cpdev; @@ -263,7 +263,7 @@ devfs_lookupx(ap) vpp = ap->a_vpp; dvp = ap->a_dvp; pname = cnp->cn_nameptr; - p = cnp->cn_proc; + td = cnp->cn_thread; flags = cnp->cn_flags; nameiop = cnp->cn_nameiop; dmp = VFSTODEVFS(dvp->v_mount); @@ -281,7 +281,7 @@ devfs_lookupx(ap) if ((flags & ISDOTDOT) && (dvp->v_flag & VROOT)) return (EIO); - error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td); if (error) return (error); @@ -296,17 +296,17 @@ devfs_lookupx(ap) if (flags & ISDOTDOT) { if (nameiop != LOOKUP) return (EINVAL); - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); de = TAILQ_FIRST(&dd->de_dlist); /* "." */ de = TAILQ_NEXT(de, de_list); /* ".." */ de = de->de_dir; - error = devfs_allocv(de, dvp->v_mount, vpp, p); + error = devfs_allocv(de, dvp->v_mount, vpp, td); if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if ((flags & LOCKPARENT) && (flags & ISLASTCN)) - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error) vput(*vpp); return (error); @@ -357,7 +357,7 @@ notfound: (flags & (LOCKPARENT | WANTPARENT)) && (flags & ISLASTCN)) { cnp->cn_flags |= SAVENAME; if (!(flags & LOCKPARENT)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); return (EJUSTRETURN); } return (ENOENT); @@ -366,7 +366,7 @@ notfound: found: if ((cnp->cn_nameiop == DELETE) && (flags & ISLASTCN)) { - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, p); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td); if (error) return (error); if (*vpp == dvp) { @@ -374,18 +374,18 @@ found: *vpp = dvp; return (0); } - error = devfs_allocv(de, dvp->v_mount, vpp, p); + error = devfs_allocv(de, dvp->v_mount, vpp, td); if (error) return (error); if (!(flags & LOCKPARENT)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); return (0); } - error = devfs_allocv(de, dvp->v_mount, vpp, p); + error = devfs_allocv(de, dvp->v_mount, vpp, td); if (error) return (error); if (!(flags & LOCKPARENT) || !(flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); return (0); } @@ -396,9 +396,9 @@ devfs_lookup(struct vop_lookup_args *ap) struct devfs_mount *dmp; dmp = VFSTODEVFS(ap->a_dvp->v_mount); - lockmgr(&dmp->dm_lock, LK_SHARED, 0, curproc); + lockmgr(&dmp->dm_lock, LK_SHARED, 0, curthread); j = devfs_lookupx(ap); - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); return (j); } @@ -416,7 +416,7 @@ struct vop_mknod_args { { struct componentname *cnp; struct vnode *dvp, **vpp; - struct proc *p; + struct thread *td; struct devfs_dirent *dd, *de; struct devfs_mount *dmp; int cloned, flags, nameiop; @@ -424,11 +424,11 @@ struct vop_mknod_args { dvp = ap->a_dvp; dmp = VFSTODEVFS(dvp->v_mount); - lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curthread); cnp = ap->a_cnp; vpp = ap->a_vpp; - p = cnp->cn_proc; + td = cnp->cn_thread; flags = cnp->cn_flags; nameiop = cnp->cn_nameiop; cloned = 0; @@ -448,9 +448,9 @@ struct vop_mknod_args { if (de == NULL) goto notfound; de->de_flags &= ~DE_WHITEOUT; - error = devfs_allocv(de, dvp->v_mount, vpp, p); + error = devfs_allocv(de, dvp->v_mount, vpp, td); notfound: - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); return (error); } @@ -512,7 +512,7 @@ devfs_readdir(ap) return (EINVAL); dmp = VFSTODEVFS(ap->a_vp->v_mount); - lockmgr(&dmp->dm_lock, LK_SHARED, 0, curproc); + lockmgr(&dmp->dm_lock, LK_SHARED, 0, curthread); devfs_populate(dmp); error = 0; de = ap->a_vp->v_data; @@ -553,7 +553,7 @@ devfs_readdir(ap) *ap->a_ncookies = ncookies; *ap->a_cookies = cookiebuf; } - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); uio->uio_offset = off; return (error); } @@ -610,11 +610,11 @@ devfs_remove(ap) struct devfs_dirent *de; struct devfs_mount *dmp = VFSTODEVFS(vp->v_mount); - lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curthread); dd = ap->a_dvp->v_data; de = vp->v_data; de->de_flags |= DE_WHITEOUT; - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); return (0); } @@ -683,7 +683,7 @@ devfs_setattr(ap) if (uid != de->de_uid || gid != de->de_gid) { if (((ap->a_cred->cr_uid != de->de_uid) || uid != de->de_uid || (gid != de->de_gid && !groupmember(gid, ap->a_cred))) && - (error = suser(ap->a_p)) != 0) + (error = suser(ap->a_td->td_proc)) != 0) return (error); de->de_uid = uid; de->de_gid = gid; @@ -691,21 +691,21 @@ devfs_setattr(ap) } if (vap->va_mode != (mode_t)VNOVAL) { if ((ap->a_cred->cr_uid != de->de_uid) && - (error = suser(ap->a_p))) + (error = suser(ap->a_td->td_proc))) return (error); de->de_mode = vap->va_mode; c = 1; } if (vap->va_atime.tv_sec != VNOVAL) { if ((ap->a_cred->cr_uid != de->de_uid) && - (error = suser(ap->a_p))) + (error = suser(ap->a_td->td_proc))) return (error); de->de_atime = vap->va_atime; c = 1; } if (vap->va_mtime.tv_sec != VNOVAL) { if ((ap->a_cred->cr_uid != de->de_uid) && - (error = suser(ap->a_p))) + (error = suser(ap->a_td->td_proc))) return (error); de->de_mtime = vap->va_mtime; c = 1; @@ -731,7 +731,7 @@ devfs_symlink(ap) struct devfs_dirent *de; struct devfs_mount *dmp; - error = suser(ap->a_cnp->cn_proc); + error = suser(ap->a_cnp->cn_thread->td_proc); if (error) return(error); dmp = VFSTODEVFS(ap->a_dvp->v_mount); @@ -745,10 +745,10 @@ devfs_symlink(ap) i = strlen(ap->a_target) + 1; MALLOC(de->de_symlink, char *, i, M_DEVFS, M_WAITOK); bcopy(ap->a_target, de->de_symlink, i); - lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curthread); TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list); devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, 0); - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curproc); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); return (0); } diff --git a/sys/fs/fdescfs/fdesc.h b/sys/fs/fdescfs/fdesc.h index b78d132..f90ea8d 100644 --- a/sys/fs/fdescfs/fdesc.h +++ b/sys/fs/fdescfs/fdesc.h @@ -65,5 +65,5 @@ struct fdescnode { extern int fdesc_init __P((struct vfsconf *)); extern int fdesc_root __P((struct mount *, struct vnode **)); extern int fdesc_allocvp __P((fdntype, int, struct mount *, struct vnode **, - struct proc *)); + struct thread *)); #endif /* _KERNEL */ diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c index ed16306..11da211 100644 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -59,22 +59,22 @@ static MALLOC_DEFINE(M_FDESCMNT, "FDESC mount", "FDESC mount structure"); static int fdesc_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int fdesc_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); static int fdesc_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); /* * Mount the per-process file descriptors (/dev/fd) */ static int -fdesc_mount(mp, path, data, ndp, p) +fdesc_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error = 0; struct fdescmount *fmp; @@ -86,7 +86,7 @@ fdesc_mount(mp, path, data, ndp, p) if (mp->mnt_flag & MNT_UPDATE) return (EOPNOTSUPP); - error = fdesc_allocvp(Froot, FD_ROOT, mp, &rvp, p); + error = fdesc_allocvp(Froot, FD_ROOT, mp, &rvp, td); if (error) return (error); @@ -102,15 +102,15 @@ fdesc_mount(mp, path, data, ndp, p) bzero(mp->mnt_stat.f_mntfromname, MNAMELEN); bcopy("fdesc", mp->mnt_stat.f_mntfromname, sizeof("fdesc")); - (void)fdesc_statfs(mp, &mp->mnt_stat, p); + (void)fdesc_statfs(mp, &mp->mnt_stat, td); return (0); } static int -fdesc_unmount(mp, mntflags, p) +fdesc_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error; int flags = 0; @@ -143,7 +143,7 @@ fdesc_root(mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; /* @@ -151,16 +151,16 @@ fdesc_root(mp, vpp) */ vp = VFSTOFDESC(mp)->f_root; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = vp; return (0); } static int -fdesc_statfs(mp, sbp, p) +fdesc_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { struct filedesc *fdp; int lim; @@ -174,8 +174,8 @@ fdesc_statfs(mp, sbp, p) * limit is ever reduced below the current number * of open files... ] */ - lim = p->p_rlimit[RLIMIT_NOFILE].rlim_cur; - fdp = p->p_fd; + lim = td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur; + fdp = td->td_proc->p_fd; last = min(fdp->fd_nfiles, lim); freefd = 0; for (i = fdp->fd_freefile; i < last; i++) diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 8d5b95e..6a9f897 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -95,12 +95,12 @@ fdesc_init(vfsp) } int -fdesc_allocvp(ftype, ix, mp, vpp, p) +fdesc_allocvp(ftype, ix, mp, vpp, td) fdntype ftype; int ix; struct mount *mp; struct vnode **vpp; - struct proc *p; + struct thread *td; { struct fdhashhead *fc; struct fdescnode *fd; @@ -110,7 +110,7 @@ fdesc_allocvp(ftype, ix, mp, vpp, p) loop: LIST_FOREACH(fd, fc, fd_hash) { if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) { - if (vget(fd->fd_vnode, 0, p)) + if (vget(fd->fd_vnode, 0, td)) goto loop; *vpp = fd->fd_vnode; return (error); @@ -174,9 +174,9 @@ fdesc_lookup(ap) struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; char *pname = cnp->cn_nameptr; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int nlen = cnp->cn_namelen; - int nfiles = p->p_fd->fd_nfiles; + int nfiles = td->td_proc->p_fd->fd_nfiles; u_int fd; int error; struct vnode *fvp; @@ -186,11 +186,11 @@ fdesc_lookup(ap) goto bad; } - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); if (cnp->cn_namelen == 1 && *pname == '.') { *vpp = dvp; VREF(dvp); - vn_lock(dvp, LK_SHARED | LK_RETRY, p); + vn_lock(dvp, LK_SHARED | LK_RETRY, td); return (0); } @@ -213,21 +213,21 @@ fdesc_lookup(ap) fd = 10 * fd + *pname++ - '0'; } - if (fd >= nfiles || p->p_fd->fd_ofiles[fd] == NULL) { + if (fd >= nfiles || td->td_proc->p_fd->fd_ofiles[fd] == NULL) { error = EBADF; goto bad; } - error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp, p); + error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp, td); if (error) goto bad; VTOFDESC(fvp)->fd_fd = fd; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); + vn_lock(fvp, LK_SHARED | LK_RETRY, td); *vpp = fvp; return (0); bad: - vn_lock(dvp, LK_SHARED | LK_RETRY, p); + vn_lock(dvp, LK_SHARED | LK_RETRY, td); *vpp = NULL; return (error); } @@ -238,7 +238,7 @@ fdesc_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -247,14 +247,14 @@ fdesc_open(ap) return (0); /* - * XXX Kludge: set p->p_dupfd to contain the value of the the file + * XXX Kludge: set td->td_proc->p_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. */ - ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ + ap->a_td->td_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ return (ENODEV); } @@ -264,12 +264,12 @@ fdesc_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - struct filedesc *fdp = ap->a_p->p_fd; + struct filedesc *fdp = ap->a_td->td_proc->p_fd; struct file *fp; struct stat stb; u_int fd; @@ -304,7 +304,7 @@ fdesc_getattr(ap) return (EBADF); bzero(&stb, sizeof(stb)); - error = fo_stat(fp, &stb, ap->a_p); + error = fo_stat(fp, &stb, ap->a_td); if (error == 0) { VATTR_NULL(vap); vap->va_type = IFTOVT(stb.st_mode); @@ -360,7 +360,7 @@ fdesc_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vattr *vap = ap->a_vap; @@ -381,7 +381,7 @@ fdesc_setattr(ap) /* * Allow setattr where there is an underlying vnode. */ - error = getvnode(ap->a_p->p_fd, fd, &fp); + error = getvnode(ap->a_td->td_proc->p_fd, fd, &fp); if (error) { /* * getvnode() returns EINVAL if the file descriptor is not @@ -399,7 +399,7 @@ fdesc_setattr(ap) vp = (struct vnode *)fp->f_data; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - error = VOP_SETATTR(vp, ap->a_vap, ap->a_cred, ap->a_p); + error = VOP_SETATTR(vp, ap->a_vap, ap->a_cred, ap->a_td); vn_finished_write(mp); return (error); } @@ -438,7 +438,7 @@ fdesc_readdir(ap) uio->uio_resid < UIO_MX) return (EINVAL); i = (u_int)off / UIO_MX; - fdp = uio->uio_procp->p_fd; + fdp = uio->uio_td->td_proc->p_fd; error = 0; fcnt = i - 2; /* The first two nodes are `.' and `..' */ @@ -488,17 +488,17 @@ fdesc_poll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { - return seltrue(0, ap->a_events, ap->a_p); + return seltrue(0, ap->a_events, ap->a_td); } static int fdesc_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -507,7 +507,7 @@ fdesc_inactive(ap) * Clear out the v_type field to avoid * nasty things happening in vgone(). */ - VOP_UNLOCK(vp, 0, ap->a_p); + VOP_UNLOCK(vp, 0, ap->a_td); vp->v_type = VNON; return (0); } diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 5fadba2..baddfa4 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -41,6 +41,7 @@ #include <sys/lock.h> #include <sys/malloc.h> #include <sys/vnode.h> +#include <sys/proc.h> /* XXXKSE */ #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/filio.h> @@ -161,26 +162,26 @@ fifo_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct fifoinfo *fip; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct socket *rso, *wso; int error; if ((fip = vp->v_fifoinfo) == NULL) { MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); vp->v_fifoinfo = fip; - error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, ap->a_p); + error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, ap->a_td); if (error) { free(fip, M_VNODE); vp->v_fifoinfo = NULL; return (error); } fip->fi_readsock = rso; - error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, ap->a_p); + error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, ap->a_td); if (error) { (void)soclose(rso); free(fip, M_VNODE); @@ -222,10 +223,10 @@ fifo_open(ap) } if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) { while (fip->fi_writers == 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = tsleep((caddr_t)&fip->fi_readers, PCATCH | PSOCK, "fifoor", 0); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error) goto bad; } @@ -238,10 +239,10 @@ fifo_open(ap) } } else { while (fip->fi_readers == 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = tsleep((caddr_t)&fip->fi_writers, PCATCH | PSOCK, "fifoow", 0); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error) goto bad; } @@ -249,7 +250,7 @@ fifo_open(ap) } return (0); bad: - VOP_CLOSE(vp, ap->a_mode, ap->a_cred, p); + VOP_CLOSE(vp, ap->a_mode, ap->a_cred, td); return (error); } @@ -268,7 +269,7 @@ fifo_read(ap) { struct uio *uio = ap->a_uio; struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock; - struct proc *p = uio->uio_procp; + struct thread *td = uio->uio_td; int error, startresid; #ifdef DIAGNOSTIC @@ -280,10 +281,10 @@ fifo_read(ap) if (ap->a_ioflag & IO_NDELAY) rso->so_state |= SS_NBIO; startresid = uio->uio_resid; - VOP_UNLOCK(ap->a_vp, 0, p); + VOP_UNLOCK(ap->a_vp, 0, td); error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0); - vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); if (ap->a_ioflag & IO_NDELAY) rso->so_state &= ~SS_NBIO; return (error); @@ -303,7 +304,7 @@ fifo_write(ap) } */ *ap; { struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock; - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; int error; #ifdef DIAGNOSTIC @@ -312,10 +313,10 @@ fifo_write(ap) #endif if (ap->a_ioflag & IO_NDELAY) wso->so_state |= SS_NBIO; - VOP_UNLOCK(ap->a_vp, 0, p); + VOP_UNLOCK(ap->a_vp, 0, td); error = sosend(wso, (struct sockaddr *)0, ap->a_uio, 0, - (struct mbuf *)0, 0, p); - vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p); + (struct mbuf *)0, 0, td); + vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); if (ap->a_ioflag & IO_NDELAY) wso->so_state &= ~SS_NBIO; return (error); @@ -333,7 +334,7 @@ fifo_ioctl(ap) caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct file filetmp; @@ -343,13 +344,13 @@ fifo_ioctl(ap) return (0); if (ap->a_fflag & FREAD) { filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; - error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_p); + error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); if (error) return (error); } if (ap->a_fflag & FWRITE) { filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; - error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_p); + error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); if (error) return (error); } @@ -446,7 +447,7 @@ fifo_poll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct file filetmp; @@ -456,13 +457,13 @@ fifo_poll(ap) filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; if (filetmp.f_data) revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, - ap->a_p); + ap->a_td); } if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; if (filetmp.f_data) revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, - ap->a_p); + ap->a_td); } return (revents); } @@ -477,7 +478,7 @@ fifo_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; diff --git a/sys/fs/hpfs/hpfs.h b/sys/fs/hpfs/hpfs.h index f354b6b..f0253d5 100644 --- a/sys/fs/hpfs/hpfs.h +++ b/sys/fs/hpfs/hpfs.h @@ -417,7 +417,7 @@ void hpfs_hphashinit __P((void)); void hpfs_hphashdestroy __P((void)); struct hpfsnode *hpfs_hphashlookup __P((dev_t, lsn_t)); struct hpfsnode *hpfs_hphashget __P((dev_t, lsn_t)); -struct vnode *hpfs_hphashvget __P((dev_t, lsn_t, struct proc *)); +struct vnode *hpfs_hphashvget __P((dev_t, lsn_t, struct thread *)); void hpfs_hphashins __P((register struct hpfsnode *)); void hpfs_hphashrem __P((register struct hpfsnode *)); extern struct lock hpfs_hphash_lock; diff --git a/sys/fs/hpfs/hpfs_hash.c b/sys/fs/hpfs/hpfs_hash.c index 791680c..fd8eeca 100644 --- a/sys/fs/hpfs/hpfs_hash.c +++ b/sys/fs/hpfs/hpfs_hash.c @@ -123,10 +123,10 @@ loop: #endif struct vnode * -hpfs_hphashvget(dev, ino, p) +hpfs_hphashvget(dev, ino, td) dev_t dev; lsn_t ino; - struct proc *p; + struct thread *td; { struct hpfsnode *hp; struct vnode *vp; @@ -138,7 +138,7 @@ loop: vp = HPTOV(hp); mtx_lock(&vp->v_interlock); mtx_unlock(&hpfs_hphash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index 46e197d..e83f356 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -64,37 +64,37 @@ MALLOC_DEFINE(M_HPFSNO, "HPFS node", "HPFS node structure"); static int hpfs_root __P((struct mount *, struct vnode **)); static int hpfs_statfs __P((struct mount *, struct statfs *, - struct proc *)); -static int hpfs_unmount __P((struct mount *, int, struct proc *)); + struct thread *)); +static int hpfs_unmount __P((struct mount *, int, struct thread *)); static int hpfs_vget __P((struct mount *mp, ino_t ino, struct vnode **vpp)); static int hpfs_mountfs __P((register struct vnode *, struct mount *, - struct hpfs_args *, struct proc *)); + struct hpfs_args *, struct thread *)); static int hpfs_vptofh __P((struct vnode *, struct fid *)); static int hpfs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); #if !defined(__FreeBSD__) static int hpfs_quotactl __P((struct mount *, int, uid_t, caddr_t, - struct proc *)); -static int hpfs_start __P((struct mount *, int, struct proc *)); + struct lwp *)); +static int hpfs_start __P((struct mount *, int, struct lwp *)); static int hpfs_sync __P((struct mount *, int, struct ucred *, - struct proc *)); + struct lwp *)); #endif #if defined(__FreeBSD__) struct sockaddr; static int hpfs_mount __P((struct mount *, char *, caddr_t, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static int hpfs_init __P((struct vfsconf *)); static int hpfs_uninit __P((struct vfsconf *)); #else /* defined(__NetBSD__) */ static int hpfs_mount __P((struct mount *, const char *, void *, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static void hpfs_init __P((void)); static int hpfs_mountroot __P((void)); static int hpfs_sysctl __P((int *, u_int, void *, size_t *, void *, - size_t, struct proc *)); + size_t, struct thread *)); static int hpfs_checkexp __P((struct mount *, struct mbuf *, int *, struct ucred **)); #endif @@ -127,14 +127,14 @@ hpfs_checkexp(mp, nam, exflagsp, credanonp) #if !defined(__FreeBSD__) /*ARGSUSED*/ static int -hpfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) +hpfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, td) int *name; u_int namelen; void *oldp; size_t *oldlenp; void *newp; size_t newlen; - struct proc *p; + struct lwp *td; { return (EINVAL); } @@ -179,12 +179,14 @@ hpfs_mount ( #if defined(__FreeBSD__) char *path, caddr_t data, + struct nameidata *ndp, + struct thread *td ) #else /* defined(__NetBSD__) */ const char *path, void *data, -#endif struct nameidata *ndp, - struct proc *p ) + struct lwp *l ) +#endif { u_int size; int err = 0; @@ -237,7 +239,11 @@ hpfs_mount ( * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); +#ifdef __FreeBSD__ + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); +#else + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, l); +#endif err = namei(ndp); if (err) { /* can't get devvp!*/ @@ -282,7 +288,7 @@ hpfs_mount ( &size); /* real size*/ bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - err = hpfs_mountfs(devvp, mp, &args, p); + err = hpfs_mountfs(devvp, mp, &args, td); if (err) goto error_2; @@ -292,7 +298,7 @@ hpfs_mount ( * * This code is common to root and non-root mounts */ - (void)VFS_STATFS(mp, &mp->mnt_stat, p); + (void)VFS_STATFS(mp, &mp->mnt_stat, td); goto success; @@ -312,11 +318,11 @@ success: * Common code for mount and mountroot */ int -hpfs_mountfs(devvp, mp, argsp, p) +hpfs_mountfs(devvp, mp, argsp, td) register struct vnode *devvp; struct mount *mp; struct hpfs_args *argsp; - struct proc *p; + struct thread *td; { int error, ncount, ronly; struct sublock *sup; @@ -345,19 +351,19 @@ hpfs_mountfs(devvp, mp, argsp, p) return (EBUSY); #if defined(__FreeBSD__) - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); - VOP__UNLOCK(devvp, 0, p); + VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0); + VOP__UNLOCK(devvp, 0, td); #else - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); + error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0); #endif if (error) return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP__UNLOCK(devvp, 0, p); + VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP__UNLOCK(devvp, 0, td); if (error) return (error); @@ -443,7 +449,7 @@ failed: #else devvp->v_specflags &= ~SI_MOUNTEDON; #endif - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); return (error); } @@ -452,7 +458,7 @@ static int hpfs_start ( struct mount *mp, int flags, - struct proc *p ) + struct lwp *td ) { return (0); } @@ -462,7 +468,7 @@ static int hpfs_unmount( struct mount *mp, int mntflags, - struct proc *p) + struct thread *td) { int error, flags, ronly; register struct hpfsmount *hpmp = VFSTOHPFS(mp); @@ -489,9 +495,9 @@ hpfs_unmount( hpmp->hpm_devvp->v_specflags &= ~SI_MOUNTEDON; #endif - vinvalbuf(hpmp->hpm_devvp, V_SAVE, NOCRED, p, 0, 0); + vinvalbuf(hpmp->hpm_devvp, V_SAVE, NOCRED, td, 0, 0); error = VOP_CLOSE(hpmp->hpm_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); + NOCRED, td); vrele(hpmp->hpm_devvp); @@ -527,7 +533,7 @@ static int hpfs_statfs( struct mount *mp, struct statfs *sbp, - struct proc *p) + struct thread *td) { struct hpfsmount *hpmp = VFSTOHPFS(mp); @@ -562,7 +568,7 @@ hpfs_sync ( struct mount *mp, int waitfor, struct ucred *cred, - struct proc *p) + struct lwp *td) { return (0); } @@ -573,7 +579,7 @@ hpfs_quotactl ( int cmds, uid_t uid, caddr_t arg, - struct proc *p) + struct lwp *td) { printf("hpfs_quotactl():\n"); return (EOPNOTSUPP); @@ -628,7 +634,7 @@ hpfs_vget( struct vnode *vp; struct hpfsnode *hp; struct buf *bp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int error; dprintf(("hpfs_vget(0x%x): ",ino)); @@ -637,7 +643,7 @@ hpfs_vget( hp = NULL; vp = NULL; - if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, p)) != NULL) { + if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, td)) != NULL) { dprintf(("hashed\n")); return (0); } @@ -686,14 +692,14 @@ hpfs_vget( hp->h_devvp = hpmp->hpm_devvp; VREF(hp->h_devvp); - error = VN_LOCK(vp, LK_EXCLUSIVE, p); + error = VN_LOCK(vp, LK_EXCLUSIVE, td); if (error) { vput(vp); return (error); } do { - if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, p)) != NULL) { + if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, td)) != NULL) { dprintf(("hashed2\n")); vput(vp); return (0); diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c index 0e2a4b7..e612a24 100644 --- a/sys/fs/hpfs/hpfs_vnops.c +++ b/sys/fs/hpfs/hpfs_vnops.c @@ -102,7 +102,7 @@ hpfs_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -153,7 +153,7 @@ hpfs_ioctl ( caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap) { register struct vnode *vp = ap->a_vp; @@ -465,7 +465,7 @@ hpfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -517,14 +517,14 @@ hpfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct hpfsnode *hp = VTOHP(vp); struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int error; dprintf(("hpfs_setattr(0x%x):\n", hp->h_no)); @@ -563,9 +563,9 @@ hpfs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != hp->h_uid && - (error = suser_xxx(cred, p, PRISON_ROOT)) && + (error = suser_xxx(cred, td->td_proc, PRISON_ROOT)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(vp, VWRITE, cred, p)))) + (error = VOP_ACCESS(vp, VWRITE, cred, td)))) return (error); if (vap->va_atime.tv_sec != VNOVAL) hp->h_atime = vap->va_atime.tv_sec; @@ -590,7 +590,7 @@ hpfs_setattr(ap) if (vap->va_size < hp->h_fn.fn_size) { #if defined(__FreeBSD__) - error = vtruncbuf(vp, cred, p, vap->va_size, DEV_BSIZE); + error = vtruncbuf(vp, cred, td, vap->va_size, DEV_BSIZE); if (error) return (error); #else /* defined(__NetBSD__) */ @@ -646,16 +646,16 @@ hpfs_inactive(ap) vprint("hpfs_inactive: pushing active", vp); if (hp->h_flag & H_INVAL) { - VOP__UNLOCK(vp,0,ap->a_p); + VOP__UNLOCK(vp,0,ap->a_td); #if defined(__FreeBSD__) - vrecycle(vp, NULL, ap->a_p); + vrecycle(vp, NULL, ap->a_td); #else /* defined(__NetBSD__) */ vgone(vp); #endif return (0); } - VOP__UNLOCK(vp,0,ap->a_p); + VOP__UNLOCK(vp,0,ap->a_td); return (0); } @@ -759,7 +759,7 @@ hpfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -800,7 +800,7 @@ hpfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #if HPFS_DEBUG @@ -829,7 +829,7 @@ hpfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #if HPFS_DEBUG @@ -1131,7 +1131,7 @@ hpfs_lookup(ap) return (EOPNOTSUPP); } - error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_thread); if(error) return (error); @@ -1148,17 +1148,17 @@ hpfs_lookup(ap) dprintf(("hpfs_lookup(0x%x,...): .. faked (0x%x)\n", dhp->h_no, dhp->h_fn.fn_parent)); - VOP__UNLOCK(dvp,0,cnp->cn_proc); + VOP__UNLOCK(dvp,0,cnp->cn_thread); error = VFS_VGET(hpmp->hpm_mp, dhp->h_fn.fn_parent, ap->a_vpp); if(error) { - VOP__LOCK(dvp, 0, cnp->cn_proc); + VOP__LOCK(dvp, 0, cnp->cn_thread); return(error); } if( lockparent && (flags & ISLASTCN) && - (error = VOP__LOCK(dvp, 0, cnp->cn_proc)) ) { + (error = VOP__LOCK(dvp, 0, cnp->cn_thread)) ) { vput( *(ap->a_vpp) ); return (error); } @@ -1174,7 +1174,7 @@ hpfs_lookup(ap) if ((error == ENOENT) && (flags & ISLASTCN) && (nameiop == CREATE || nameiop == RENAME)) { if(!lockparent) - VOP__UNLOCK(dvp, 0, cnp->cn_proc); + VOP__UNLOCK(dvp, 0, cnp->cn_thread); cnp->cn_flags |= SAVENAME; return (EJUSTRETURN); } @@ -1186,7 +1186,7 @@ hpfs_lookup(ap) dep->de_fnode, dep->de_cpid)); if (nameiop == DELETE && (flags & ISLASTCN)) { - error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_thread); if (error) { brelse(bp); return (error); @@ -1220,7 +1220,7 @@ hpfs_lookup(ap) brelse(bp); if(!lockparent || !(flags & ISLASTCN)) - VOP__UNLOCK(dvp, 0, cnp->cn_proc); + VOP__UNLOCK(dvp, 0, cnp->cn_thread); if ((flags & MAKEENTRY) && (!(flags & ISLASTCN) || (nameiop != DELETE && nameiop != CREATE))) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index f7ba83b..6083de6 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -280,6 +280,6 @@ int dosdirempty __P((struct denode *dep)); int createde __P((struct denode *dep, struct denode *ddep, struct denode **depp, struct componentname *cnp)); int deupdat __P((struct denode *dep, int waitfor)); int removede __P((struct denode *pdep, struct denode *dep)); -int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct proc *p)); +int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct thread *td)); int doscheckpath __P(( struct denode *source, struct denode *target)); #endif /* _KERNEL */ diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index bf176bd..8ab7f11 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -125,7 +125,7 @@ msdosfs_hashget(dev, dirclust, diroff) u_long dirclust; u_long diroff; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct denode *dep; struct vnode *vp; @@ -139,7 +139,7 @@ loop: vp = DETOV(dep); mtx_lock(&vp->v_interlock); mtx_unlock(&dehash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (dep); } @@ -209,7 +209,7 @@ deget(pmp, dirclust, diroffset, depp) struct denode *ldep; struct vnode *nvp; struct buf *bp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct timeval tv; #ifdef MSDOSFS_DEBUG @@ -278,7 +278,7 @@ deget(pmp, dirclust, diroffset, depp) * of at the start of msdosfs_hashins() so that reinsert() can * call msdosfs_hashins() with a locked denode. */ - if (VOP_LOCK(nvp, LK_EXCLUSIVE, p) != 0) + if (VOP_LOCK(nvp, LK_EXCLUSIVE, td) != 0) panic("deget: unexpected lock failure"); /* @@ -414,12 +414,12 @@ deupdat(dep, waitfor) * Truncate the file described by dep to the length specified by length. */ int -detrunc(dep, length, flags, cred, p) +detrunc(dep, length, flags, cred, td) struct denode *dep; u_long length; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; { int error; int allerror; @@ -520,7 +520,7 @@ detrunc(dep, length, flags, cred, p) dep->de_FileSize = length; if (!isadir) dep->de_flag |= DE_UPDATE|DE_MODIFIED; - allerror = vtruncbuf(DETOV(dep), cred, p, length, pmp->pm_bpcluster); + allerror = vtruncbuf(DETOV(dep), cred, td, length, pmp->pm_bpcluster); #ifdef MSDOSFS_DEBUG if (allerror) printf("detrunc(): vtruncbuf error %d\n", allerror); @@ -671,12 +671,12 @@ int msdosfs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int error = 0; #ifdef MSDOSFS_DEBUG @@ -702,14 +702,14 @@ msdosfs_inactive(ap) dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY); #endif if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - error = detrunc(dep, (u_long) 0, 0, NOCRED, p); + error = detrunc(dep, (u_long) 0, 0, NOCRED, td); dep->de_flag |= DE_UPDATE; dep->de_Name[0] = SLOT_DELETED; } deupdat(dep, 0); out: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * If we are done with the denode, reclaim it * so that it can be reused immediately. @@ -719,6 +719,6 @@ out: dep->de_Name[0]); #endif if (dep->de_Name[0] == SLOT_DELETED) - vrecycle(vp, NULL, p); + vrecycle(vp, NULL, td); return (error); } diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 987ac3b..3f0bb76 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -110,7 +110,7 @@ msdosfs_lookup(ap) u_char dosfilename[12]; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int unlen; int wincnt = 1; @@ -340,7 +340,7 @@ notfound: * Access for write is interpreted as allowing * creation of files in the directory. */ - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) return (error); /* @@ -365,7 +365,7 @@ notfound: */ cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (EJUSTRETURN); @@ -438,7 +438,7 @@ foundroot: /* * Write access to directory required to delete files. */ - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) return (error); @@ -456,7 +456,7 @@ foundroot: return (error); *vpp = DETOV(tdp); if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); @@ -473,7 +473,7 @@ foundroot: if (blkoff == MSDOSFSROOT_OFS) return EROFS; /* really? XXX */ - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) return (error); @@ -489,7 +489,7 @@ foundroot: *vpp = DETOV(tdp); cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); @@ -516,16 +516,16 @@ foundroot: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; error = deget(pmp, cluster, blkoff, &tdp); if (error) { - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); cnp->cn_flags &= ~PDIRUNLOCK; return (error); } if (lockparent && (flags & ISLASTCN)) { - error = vn_lock(pdp, LK_EXCLUSIVE, p); + error = vn_lock(pdp, LK_EXCLUSIVE, td); if (error) { vput(DETOV(tdp)); return (error); @@ -540,7 +540,7 @@ foundroot: if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) return (error); if (!lockparent || !(flags & ISLASTCN)) { - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } *vpp = DETOV(tdp); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 1962daf..cd1e404 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -88,17 +88,17 @@ static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table static int update_mp __P((struct mount *mp, struct msdosfs_args *argp)); static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp, - struct proc *p, struct msdosfs_args *argp)); + struct thread *td, struct msdosfs_args *argp)); static int msdosfs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); static int msdosfs_mount __P((struct mount *, char *, caddr_t, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static int msdosfs_root __P((struct mount *, struct vnode **)); static int msdosfs_statfs __P((struct mount *, struct statfs *, - struct proc *)); + struct thread *)); static int msdosfs_sync __P((struct mount *, int, struct ucred *, - struct proc *)); -static int msdosfs_unmount __P((struct mount *, int, struct proc *)); + struct thread *)); +static int msdosfs_unmount __P((struct mount *, int, struct thread *)); static int msdosfs_vptofh __P((struct vnode *, struct fid *)); static int @@ -159,7 +159,7 @@ int msdosfs_mountroot() { register struct mount *mp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ size_t size; int error; struct msdosfs_args args; @@ -189,13 +189,13 @@ msdosfs_mountroot() } if ((error = update_mp(mp, &args)) != 0) { - (void)msdosfs_unmount(mp, 0, p); + (void)msdosfs_unmount(mp, 0, td); free(mp, M_MOUNT); return (error); } if ((error = vfs_lock(mp)) != 0) { - (void)msdosfs_unmount(mp, 0, p); + (void)msdosfs_unmount(mp, 0, td); free(mp, M_MOUNT); return (error); } @@ -208,7 +208,7 @@ msdosfs_mountroot() (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)msdosfs_statfs(mp, &mp->mnt_stat, p); + (void)msdosfs_statfs(mp, &mp->mnt_stat, td); vfs_unlock(mp); return (0); } @@ -220,12 +220,12 @@ msdosfs_mountroot() * special file to treat as a filesystem. */ static int -msdosfs_mount(mp, path, data, ndp, p) +msdosfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *devvp; /* vnode for blk device to mount */ struct msdosfs_args args; /* will hold data from mount request */ @@ -263,16 +263,16 @@ msdosfs_mount(mp, path, data, ndp, p) * If upgrade to read-write by non-root, then verify * that user has necessary permissions on the device. */ - if (p->p_ucred->cr_uid != 0) { + if (td->td_proc->p_ucred->cr_uid != 0) { devvp = pmp->pm_devvp; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_ACCESS(devvp, VREAD | VWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); if (error) { - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } pmp->pm_flags &= ~MSDOSFSMNT_RONLY; } @@ -295,7 +295,7 @@ msdosfs_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); error = namei(ndp); if (error) return (error); @@ -310,20 +310,20 @@ msdosfs_mount(mp, path, data, ndp, p) * If mount by non-root, then verify that user has necessary * permissions on the device. */ - if (p->p_ucred->cr_uid != 0) { + if (td->td_proc->p_ucred->cr_uid != 0) { accessmode = VREAD; if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td); if (error) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = mountmsdosfs(devvp, mp, p, &args); + error = mountmsdosfs(devvp, mp, td, &args); #ifdef MSDOSFS_DEBUG /* only needed for the printf below */ pmp = VFSTOMSDOSFS(mp); #endif @@ -340,13 +340,13 @@ msdosfs_mount(mp, path, data, ndp, p) error = update_mp(mp, &args); if (error) { - msdosfs_unmount(mp, MNT_FORCE, p); + msdosfs_unmount(mp, MNT_FORCE, td); return error; } (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) msdosfs_statfs(mp, &mp->mnt_stat, p); + (void) msdosfs_statfs(mp, &mp->mnt_stat, td); #ifdef MSDOSFS_DEBUG printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap); #endif @@ -354,10 +354,10 @@ msdosfs_mount(mp, path, data, ndp, p) } static int -mountmsdosfs(devvp, mp, p, argp) +mountmsdosfs(devvp, mp, td, argp) struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; struct msdosfs_args *argp; { struct msdosfsmount *pmp; @@ -386,16 +386,16 @@ mountmsdosfs(devvp, mp, p, argp) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); @@ -415,7 +415,7 @@ mountmsdosfs(devvp, mp, p, argp) * Let's check it... */ error = VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, - FREAD, NOCRED, p); + FREAD, NOCRED, td); if (error) goto error_exit; tmp = dpart.part->p_fstype; @@ -724,7 +724,7 @@ mountmsdosfs(devvp, mp, p, argp) error_exit: if (bp) brelse(bp); - (void) VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, p); + (void) VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, td); if (pmp) { if (pmp->pm_inusemap) free(pmp->pm_inusemap, M_MSDOSFSFAT); @@ -738,10 +738,10 @@ error_exit: * Unmount the filesystem described by mp. */ static int -msdosfs_unmount(mp, mntflags, p) +msdosfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { struct msdosfsmount *pmp; int error, flags; @@ -778,7 +778,7 @@ msdosfs_unmount(mp, mntflags, p) #endif error = VOP_CLOSE(pmp->pm_devvp, (pmp->pm_flags&MSDOSFSMNT_RONLY) ? FREAD : FREAD | FWRITE, - NOCRED, p); + NOCRED, td); vrele(pmp->pm_devvp); free(pmp->pm_inusemap, M_MSDOSFSFAT); free(pmp, M_MSDOSFSMNT); @@ -807,10 +807,10 @@ msdosfs_root(mp, vpp) } static int -msdosfs_statfs(mp, sbp, p) +msdosfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { struct msdosfsmount *pmp; @@ -832,11 +832,11 @@ msdosfs_statfs(mp, sbp, p) } static int -msdosfs_sync(mp, waitfor, cred, p) +msdosfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *vp, *nvp; struct denode *dep; @@ -879,17 +879,17 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { mtx_lock(&mntvnode_mtx); if (error == ENOENT) goto loop; continue; } - error = VOP_FSYNC(vp, cred, waitfor, p); + error = VOP_FSYNC(vp, cred, waitfor, td); if (error) allerror = error; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(vp); mtx_lock(&mntvnode_mtx); } @@ -899,11 +899,11 @@ loop: * Flush filesystem control info. */ if (waitfor != MNT_LAZY) { - vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p); + vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, td); if (error) allerror = error; - VOP_UNLOCK(pmp->pm_devvp, 0, p); + VOP_UNLOCK(pmp->pm_devvp, 0, td); } return (allerror); } diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 77d2760..bbdcecb 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -211,7 +211,7 @@ msdosfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -233,7 +233,7 @@ msdosfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -273,7 +273,7 @@ msdosfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct denode *dep = VTODE(ap->a_vp); @@ -339,7 +339,7 @@ msdosfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -351,7 +351,7 @@ msdosfs_setattr(ap) #ifdef MSDOSFS_DEBUG printf("msdosfs_setattr(): vp %p, vap %p, cred %p, p %p\n", - ap->a_vp, vap, cred, ap->a_p); + ap->a_vp, vap, cred, ap->a_td); #endif /* @@ -376,7 +376,7 @@ msdosfs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && - (error = suser_xxx(cred, ap->a_p, PRISON_ROOT))) + (error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT))) return (error); /* * We are very inconsistent about handling unsupported @@ -417,7 +417,7 @@ msdosfs_setattr(ap) gid = pmp->pm_gid; if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid || (gid != pmp->pm_gid && !groupmember(gid, cred))) && - (error = suser_xxx(cred, ap->a_p, PRISON_ROOT))) + (error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT))) return error; if (uid != pmp->pm_uid || gid != pmp->pm_gid) return EINVAL; @@ -441,7 +441,7 @@ msdosfs_setattr(ap) default: break; } - error = detrunc(dep, vap->va_size, 0, cred, ap->a_p); + error = detrunc(dep, vap->va_size, 0, cred, ap->a_td); if (error) return error; } @@ -449,9 +449,9 @@ msdosfs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && - (error = suser_xxx(cred, ap->a_p, PRISON_ROOT)) && + (error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_p)))) + (error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_td)))) return (error); if (vp->v_type != VDIR) { if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 && @@ -472,7 +472,7 @@ msdosfs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && - (error = suser_xxx(cred, ap->a_p, PRISON_ROOT))) + (error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT))) return (error); if (vp->v_type != VDIR) { /* We ignore the read and execute bits. */ @@ -601,7 +601,7 @@ msdosfs_write(ap) struct buf *bp; int ioflag = ap->a_ioflag; struct uio *uio = ap->a_uio; - struct proc *p = uio->uio_procp; + struct thread *td = uio->uio_td; struct vnode *vp = ap->a_vp; struct vnode *thisvp; struct denode *dep = VTODE(vp); @@ -636,12 +636,12 @@ msdosfs_write(ap) /* * If they've exceeded their filesize limit, tell them about it. */ - if (p && + if (td && ((uoff_t)uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) { - PROC_LOCK(p); - psignal(p, SIGXFSZ); - PROC_UNLOCK(p); + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur)) { + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); return (EFBIG); } @@ -795,7 +795,7 @@ msdosfs_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -931,7 +931,7 @@ msdosfs_rename(ap) struct vnode *tvp = ap->a_tvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; struct denode *ip, *xp, *dp, *zp; u_char toname[11], oldname[11]; u_long from_diroffset, to_diroffset; @@ -987,7 +987,7 @@ abortit: goto abortit; } - error = vn_lock(fvp, LK_EXCLUSIVE, p); + error = vn_lock(fvp, LK_EXCLUSIVE, td); if (error) goto abortit; dp = VTODE(fdvp); @@ -1008,7 +1008,7 @@ abortit: (fcnp->cn_flags & ISDOTDOT) || (tcnp->cn_flags & ISDOTDOT) || (ip->de_flag & DE_RENAME)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EINVAL; goto abortit; } @@ -1038,8 +1038,8 @@ abortit: * to namei, as the parent directory is unlocked by the * call to doscheckpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - VOP_UNLOCK(fvp, 0, p); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + VOP_UNLOCK(fvp, 0, td); if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) newparent = 1; if (doingdirectory && newparent) { @@ -1108,7 +1108,7 @@ abortit: if ((fcnp->cn_flags & SAVESTART) == 0) panic("msdosfs_rename: lost from startdir"); if (!newparent) - VOP_UNLOCK(tdvp, 0, p); + VOP_UNLOCK(tdvp, 0, td); if (relookup(fdvp, &fvp, fcnp) == 0) vrele(fdvp); if (fvp == NULL) { @@ -1119,7 +1119,7 @@ abortit: panic("rename: lost dir entry"); vrele(ap->a_fvp); if (newparent) - VOP_UNLOCK(tdvp, 0, p); + VOP_UNLOCK(tdvp, 0, td); vrele(tdvp); return 0; } @@ -1139,9 +1139,9 @@ abortit: if (doingdirectory) panic("rename: lost dir entry"); vrele(ap->a_fvp); - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); if (newparent) - VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); xp = NULL; } else { vrele(fvp); @@ -1163,8 +1163,8 @@ abortit: if (error) { bcopy(oldname, ip->de_Name, 11); if (newparent) - VOP_UNLOCK(fdvp, 0, p); - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); + VOP_UNLOCK(fvp, 0, td); goto bad; } ip->de_refcnt++; @@ -1173,8 +1173,8 @@ abortit: if (error) { /* XXX should really panic here, fs is corrupt */ if (newparent) - VOP_UNLOCK(fdvp, 0, p); - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); + VOP_UNLOCK(fvp, 0, td); goto bad; } if (!doingdirectory) { @@ -1183,8 +1183,8 @@ abortit: if (error) { /* XXX should really panic here, fs is corrupt */ if (newparent) - VOP_UNLOCK(fdvp, 0, p); - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); + VOP_UNLOCK(fvp, 0, td); goto bad; } if (ip->de_dirclust == MSDOSFSROOT) @@ -1194,7 +1194,7 @@ abortit: } reinsert(ip); if (newparent) - VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); } /* @@ -1213,7 +1213,7 @@ abortit: if (error) { /* XXX should really panic here, fs is corrupt */ brelse(bp); - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); goto bad; } dotdotp = (struct direntry *)bp->b_data + 1; @@ -1223,12 +1223,12 @@ abortit: error = bwrite(bp); if (error) { /* XXX should really panic here, fs is corrupt */ - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); goto bad; } } - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); bad: if (xp) vput(tvp); @@ -1392,7 +1392,7 @@ msdosfs_rmdir(ap) register struct vnode *dvp = ap->a_dvp; register struct componentname *cnp = ap->a_cnp; register struct denode *ip, *dp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int error; ip = VTODE(vp); @@ -1427,14 +1427,14 @@ msdosfs_rmdir(ap) * the name cache. */ cache_purge(dvp); - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); /* * Truncate the directory that is being deleted. */ - error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, p); + error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, td); cache_purge(vp); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); out: return (error); } diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c index e1e6006..c215741 100644 --- a/sys/fs/ntfs/ntfs_subr.c +++ b/sys/fs/ntfs/ntfs_subr.c @@ -227,7 +227,7 @@ ntfs_ntvattrget( vget() */ error = ntfs_vgetex(ntmp->ntm_mountp, aalp->al_inumber, NTFS_A_DATA, NULL, LK_EXCLUSIVE, - VG_EXT, curproc, &newvp); + VG_EXT, curthread, &newvp); if (error) { printf("ntfs_ntvattrget: CAN'T VGET INO: %d\n", aalp->al_inumber); diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index 26a09b8..19e6925 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -76,36 +76,36 @@ MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer"); static int ntfs_root __P((struct mount *, struct vnode **)); static int ntfs_statfs __P((struct mount *, struct statfs *, - struct proc *)); -static int ntfs_unmount __P((struct mount *, int, struct proc *)); + struct thread *)); +static int ntfs_unmount __P((struct mount *, int, struct thread *)); static int ntfs_vget __P((struct mount *mp, ino_t ino, struct vnode **vpp)); static int ntfs_mountfs __P((register struct vnode *, struct mount *, - struct ntfs_args *, struct proc *)); + struct ntfs_args *, struct thread *)); static int ntfs_vptofh __P((struct vnode *, struct fid *)); static int ntfs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); #if !defined (__FreeBSD__) static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t, - struct proc *)); -static int ntfs_start __P((struct mount *, int, struct proc *)); + struct thread *)); +static int ntfs_start __P((struct mount *, int, struct thread *)); static int ntfs_sync __P((struct mount *, int, struct ucred *, - struct proc *)); + struct thread *)); #endif #if defined(__FreeBSD__) struct sockaddr; static int ntfs_mount __P((struct mount *, char *, caddr_t, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static int ntfs_init __P((struct vfsconf *)); #elif defined(__NetBSD__) static int ntfs_mount __P((struct mount *, const char *, void *, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static void ntfs_init __P((void)); static int ntfs_mountroot __P((void)); static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *, - size_t, struct proc *)); + size_t, struct thread *)); static int ntfs_checkexp __P((struct mount *, struct mbuf *, int *, struct ucred **)); #endif @@ -180,7 +180,7 @@ ntfs_mountroot() args.gid = 0; args.mode = 0777; - if ((error = ntfs_mountfs(rootvp, mp, &args, p)) != 0) { + if ((error = ntfs_mountfs(rootvp, mp, &args, td)) != 0) { mp->mnt_op->vfs_refcount--; vfs_unbusy(mp); free(mp, M_MOUNT); @@ -191,7 +191,7 @@ ntfs_mountroot() mtx_lock(&mountlist_mtx); TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); - (void)ntfs_statfs(mp, &mp->mnt_stat, p); + (void)ntfs_statfs(mp, &mp->mnt_stat, td); vfs_unbusy(mp); return (0); } @@ -236,7 +236,7 @@ ntfs_mount ( void *data, #endif struct nameidata *ndp, - struct proc *p ) + struct thread *td ) { size_t size; int err = 0; @@ -266,7 +266,7 @@ ntfs_mount ( /* * Attempt mount */ - if( ( err = ntfs_mountfs(rootvp, mp, &args, p)) != 0) { + if( ( err = ntfs_mountfs(rootvp, mp, &args, td)) != 0) { /* fs specific cleanup (if any)*/ goto error_1; } @@ -316,7 +316,7 @@ ntfs_mount ( * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); err = namei(ndp); if (err) { /* can't get devvp!*/ @@ -385,7 +385,7 @@ ntfs_mount ( &size); /* real size*/ bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - err = ntfs_mountfs(devvp, mp, &args, p); + err = ntfs_mountfs(devvp, mp, &args, td); } if (err) { goto error_2; @@ -400,7 +400,7 @@ dostatfs: * * This code is common to root and non-root mounts */ - (void)VFS_STATFS(mp, &mp->mnt_stat, p); + (void)VFS_STATFS(mp, &mp->mnt_stat, td); goto success; @@ -420,11 +420,11 @@ success: * Common code for mount and mountroot */ int -ntfs_mountfs(devvp, mp, argsp, p) +ntfs_mountfs(devvp, mp, argsp, td) register struct vnode *devvp; struct mount *mp; struct ntfs_args *argsp; - struct proc *p; + struct thread *td; { struct buf *bp; struct ntfsmount *ntmp; @@ -449,19 +449,19 @@ ntfs_mountfs(devvp, mp, argsp, p) if (ncount > 1 && devvp != rootvp) return (EBUSY); #if defined(__FreeBSD__) - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); - VOP__UNLOCK(devvp, 0, p); + VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0); + VOP__UNLOCK(devvp, 0, td); #else - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); + error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0); #endif if (error) return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP__UNLOCK(devvp, 0, p); + VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP__UNLOCK(devvp, 0, td); if (error) return (error); @@ -624,11 +624,11 @@ out: #if defined __NetBSD__ /* lock the device vnode before calling VOP_CLOSE() */ - VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); - VOP__UNLOCK(devvp, 0, p); + VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); + VOP__UNLOCK(devvp, 0, td); #else - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); #endif return (error); @@ -639,7 +639,7 @@ static int ntfs_start ( struct mount *mp, int flags, - struct proc *p ) + struct thread *td ) { return (0); } @@ -649,7 +649,7 @@ static int ntfs_unmount( struct mount *mp, int mntflags, - struct proc *p) + struct thread *td) { register struct ntfsmount *ntmp; int error, ronly = 0, flags, i; @@ -689,17 +689,17 @@ ntfs_unmount( if (ntmp->ntm_devvp->v_type != VBAD) ntmp->ntm_devvp->v_rdev->si_mountpoint = NULL; - vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0); + vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, td, 0, 0); #if defined(__NetBSD__) /* lock the device vnode before calling VOP_CLOSE() */ VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); - VOP__UNLOCK(ntmp->ntm_devvp, 0, p); + NOCRED, td); + VOP__UNLOCK(ntmp->ntm_devvp, 0, td); #else error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); + NOCRED, td); #endif vrele(ntmp->ntm_devvp); @@ -744,7 +744,7 @@ ntfs_quotactl ( int cmds, uid_t uid, caddr_t arg, - struct proc *p) + struct thread *td) { printf("\nntfs_quotactl():\n"); return EOPNOTSUPP; @@ -787,7 +787,7 @@ static int ntfs_statfs( struct mount *mp, struct statfs *sbp, - struct proc *p) + struct thread *td) { struct ntfsmount *ntmp = VFSTONTFS(mp); u_int64_t mftsize,mftallocated; @@ -831,7 +831,7 @@ ntfs_sync ( struct mount *mp, int waitfor, struct ucred *cred, - struct proc *p) + struct thread *td) { /*dprintf(("ntfs_sync():\n"));*/ return (0); @@ -888,7 +888,7 @@ ntfs_vgetex( char *attrname, u_long lkflags, u_long flags, - struct proc *p, + struct thread *td, struct vnode **vpp) { int error; @@ -953,7 +953,7 @@ ntfs_vgetex( } if (FTOV(fp)) { - VGET(FTOV(fp), lkflags, p); + VGET(FTOV(fp), lkflags, td); *vpp = FTOV(fp); ntfs_ntput(ip); return (0); @@ -980,7 +980,7 @@ ntfs_vgetex( ntfs_ntput(ip); if (lkflags & LK_TYPE_MASK) { - error = VN_LOCK(vp, lkflags, p); + error = VN_LOCK(vp, lkflags, td); if (error) { vput(vp); return (error); @@ -999,7 +999,7 @@ ntfs_vget( struct vnode **vpp) { return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL, - LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp); + LK_EXCLUSIVE | LK_RETRY, 0, curthread, vpp); } #if defined(__FreeBSD__) diff --git a/sys/fs/ntfs/ntfs_vfsops.h b/sys/fs/ntfs/ntfs_vfsops.h index c05686f..b82877a 100644 --- a/sys/fs/ntfs/ntfs_vfsops.h +++ b/sys/fs/ntfs/ntfs_vfsops.h @@ -36,9 +36,9 @@ struct mount; struct ntfsmount; -struct proc; +struct thread; struct vnode; int ntfs_vgetex(struct mount *, ino_t, u_int32_t, char *, u_long, u_long, - struct proc *, struct vnode **); + struct thread *, struct vnode **); int ntfs_calccfree(struct ntfsmount *, cn_t *); diff --git a/sys/fs/ntfs/ntfs_vnops.c b/sys/fs/ntfs/ntfs_vnops.c index 5c2297f..baad440 100644 --- a/sys/fs/ntfs/ntfs_vnops.c +++ b/sys/fs/ntfs/ntfs_vnops.c @@ -191,7 +191,7 @@ ntfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -245,7 +245,7 @@ ntfs_inactive(ap) if (ntfs_prtactive && vp->v_usecount != 0) vprint("ntfs_inactive: pushing active", vp); - VOP__UNLOCK(vp, 0, ap->a_p); + VOP__UNLOCK(vp, 0, ap->a_td); /* XXX since we don't support any filesystem changes * right now, nothing more needs to be done @@ -423,7 +423,7 @@ ntfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -471,7 +471,7 @@ ntfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #if NTFS_DEBUG @@ -500,7 +500,7 @@ ntfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #if NTFS_DEBUG @@ -674,7 +674,7 @@ ntfs_lookup(ap) (int)cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_namelen, dip->i_number, lockparent, wantparent)); - error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_thread); if(error) return (error); @@ -713,7 +713,7 @@ ntfs_lookup(ap) if(error) return (error); - VOP__UNLOCK(dvp,0,cnp->cn_proc); + VOP__UNLOCK(dvp,0,cnp->cn_thread); cnp->cn_flags |= PDIRUNLOCK; dprintf(("ntfs_lookup: parentdir: %d\n", @@ -722,13 +722,13 @@ ntfs_lookup(ap) vap->va_a_name->n_pnumber,ap->a_vpp); ntfs_ntvattrrele(vap); if (error) { - if (VN_LOCK(dvp,LK_EXCLUSIVE|LK_RETRY,cnp->cn_proc)==0) + if (VN_LOCK(dvp,LK_EXCLUSIVE|LK_RETRY,cnp->cn_thread)==0) cnp->cn_flags &= ~PDIRUNLOCK; return (error); } if (lockparent && (cnp->cn_flags & ISLASTCN)) { - error = VN_LOCK(dvp, LK_EXCLUSIVE, cnp->cn_proc); + error = VN_LOCK(dvp, LK_EXCLUSIVE, cnp->cn_thread); if (error) { vput( *(ap->a_vpp) ); return (error); @@ -746,7 +746,7 @@ ntfs_lookup(ap) VTONT(*ap->a_vpp)->i_number)); if(!lockparent || !(cnp->cn_flags & ISLASTCN)) - VOP__UNLOCK(dvp, 0, cnp->cn_proc); + VOP__UNLOCK(dvp, 0, cnp->cn_thread); } if (cnp->cn_flags & MAKEENTRY) @@ -768,7 +768,7 @@ ntfs_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { return (0); diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index 97aa492..add959e 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -110,7 +110,7 @@ null_node_find(mp, lowervp) struct mount *mp; struct vnode *lowervp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct null_node_hashhead *hd; struct null_node *a; struct vnode *vp; @@ -123,17 +123,17 @@ null_node_find(mp, lowervp) */ hd = NULL_NHASH(lowervp); loop: - lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, td); LIST_FOREACH(a, hd, null_hash) { if (a->null_lowervp == lowervp && NULLTOV(a)->v_mount == mp) { vp = NULLTOV(a); - lockmgr(&null_hashlock, LK_RELEASE, NULL, p); + lockmgr(&null_hashlock, LK_RELEASE, NULL, td); /* * We need vget for the VXLOCK * stuff, but we don't want to lock * the lower node. */ - if (vget(vp, LK_EXCLUSIVE | LK_CANRECURSE, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_CANRECURSE, td)) { printf ("null_node_find: vget failed.\n"); goto loop; }; @@ -141,11 +141,11 @@ loop: * Now we got both vnodes locked, so release the * lower one. */ - VOP_UNLOCK(lowervp, 0, p); + VOP_UNLOCK(lowervp, 0, td); return (vp); } } - lockmgr(&null_hashlock, LK_RELEASE, NULL, p); + lockmgr(&null_hashlock, LK_RELEASE, NULL, td); return NULLVP; } @@ -162,7 +162,7 @@ null_node_alloc(mp, lowervp, vpp) struct vnode *lowervp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct null_node_hashhead *hd; struct null_node *xp; struct vnode *othervp, *vp; @@ -211,16 +211,16 @@ null_node_alloc(mp, lowervp, vpp) * NULL, then we copy that up and manually lock the new vnode. */ - lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, td); vp->v_vnlock = lowervp->v_vnlock; - error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_THISLAYER, p); + error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_THISLAYER, td); if (error) panic("null_node_alloc: can't lock new vnode\n"); VREF(lowervp); hd = NULL_NHASH(lowervp); LIST_INSERT_HEAD(hd, xp, null_hash); - lockmgr(&null_hashlock, LK_RELEASE, NULL, p); + lockmgr(&null_hashlock, LK_RELEASE, NULL, td); return 0; } diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index f707751..1ab0aaa 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -63,33 +63,33 @@ static int nullfs_fhtovp(struct mount *mp, struct fid *fidp, static int nullfs_checkexp(struct mount *mp, struct sockaddr *nam, int *extflagsp, struct ucred **credanonp); static int nullfs_mount(struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p); + struct nameidata *ndp, struct thread *td); static int nullfs_quotactl(struct mount *mp, int cmd, uid_t uid, - caddr_t arg, struct proc *p); + caddr_t arg, struct thread *td); static int nullfs_root(struct mount *mp, struct vnode **vpp); -static int nullfs_start(struct mount *mp, int flags, struct proc *p); +static int nullfs_start(struct mount *mp, int flags, struct thread *td); static int nullfs_statfs(struct mount *mp, struct statfs *sbp, - struct proc *p); + struct thread *td); static int nullfs_sync(struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p); -static int nullfs_unmount(struct mount *mp, int mntflags, struct proc *p); + struct ucred *cred, struct thread *td); +static int nullfs_unmount(struct mount *mp, int mntflags, struct thread *td); static int nullfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp); static int nullfs_vptofh(struct vnode *vp, struct fid *fhp); static int nullfs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, int namespace, const char *attrname, - struct proc *p); + struct thread *td); /* * Mount null layer */ static int -nullfs_mount(mp, path, data, ndp, p) +nullfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error = 0; struct null_args args; @@ -106,7 +106,7 @@ nullfs_mount(mp, path, data, ndp, p) */ if (mp->mnt_flag & MNT_UPDATE) { return (EOPNOTSUPP); - /* return VFS_MOUNT(MOUNTTONULLMOUNT(mp)->nullm_vfs, path, data, ndp, p);*/ + /* return VFS_MOUNT(MOUNTTONULLMOUNT(mp)->nullm_vfs, path, data, ndp, td);*/ } /* @@ -122,20 +122,20 @@ nullfs_mount(mp, path, data, ndp, p) */ if ((mp->mnt_vnodecovered->v_op == null_vnodeop_p) && VOP_ISLOCKED(mp->mnt_vnodecovered, NULL)) { - VOP_UNLOCK(mp->mnt_vnodecovered, 0, p); + VOP_UNLOCK(mp->mnt_vnodecovered, 0, td); isvnunlocked = 1; } /* * Find lower node */ NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT|LOCKLEAF, - UIO_USERSPACE, args.target, p); + UIO_USERSPACE, args.target, td); error = namei(ndp); /* * Re-lock vnode. */ if (isvnunlocked && !VOP_ISLOCKED(mp->mnt_vnodecovered, NULL)) - vn_lock(mp->mnt_vnodecovered, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(mp->mnt_vnodecovered, LK_EXCLUSIVE | LK_RETRY, td); if (error) return (error); @@ -174,7 +174,7 @@ nullfs_mount(mp, path, data, ndp, p) /* * Unlock the node (either the lower or the alias) */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * Make sure the node alias worked */ @@ -199,7 +199,7 @@ nullfs_mount(mp, path, data, ndp, p) (void) copyinstr(args.target, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)nullfs_statfs(mp, &mp->mnt_stat, p); + (void)nullfs_statfs(mp, &mp->mnt_stat, td); NULLFSDEBUG("nullfs_mount: lower %s, alias at %s\n", mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname); return (0); @@ -211,23 +211,23 @@ nullfs_mount(mp, path, data, ndp, p) * when that filesystem was mounted. */ static int -nullfs_start(mp, flags, p) +nullfs_start(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { return (0); - /* return VFS_START(MOUNTTONULLMOUNT(mp)->nullm_vfs, flags, p); */ + /* return VFS_START(MOUNTTONULLMOUNT(mp)->nullm_vfs, flags, td); */ } /* * Free reference to null layer */ static int -nullfs_unmount(mp, mntflags, p) +nullfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { void *mntdata; int error; @@ -257,7 +257,7 @@ nullfs_root(mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; NULLFSDEBUG("nullfs_root(mp = %p, vp = %p->%p)\n", (void *)mp, @@ -277,27 +277,27 @@ nullfs_root(mp, vpp) return (EDEADLK); } #endif - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = vp; return 0; } static int -nullfs_quotactl(mp, cmd, uid, arg, p) +nullfs_quotactl(mp, cmd, uid, arg, td) struct mount *mp; int cmd; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { - return VFS_QUOTACTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, uid, arg, p); + return VFS_QUOTACTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, uid, arg, td); } static int -nullfs_statfs(mp, sbp, p) +nullfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { int error; struct statfs mstat; @@ -308,7 +308,7 @@ nullfs_statfs(mp, sbp, p) bzero(&mstat, sizeof(mstat)); - error = VFS_STATFS(MOUNTTONULLMOUNT(mp)->nullm_vfs, &mstat, p); + error = VFS_STATFS(MOUNTTONULLMOUNT(mp)->nullm_vfs, &mstat, td); if (error) return (error); @@ -331,11 +331,11 @@ nullfs_statfs(mp, sbp, p) } static int -nullfs_sync(mp, waitfor, cred, p) +nullfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { /* * XXX - Assumes no data cached at null layer. @@ -392,16 +392,16 @@ nullfs_vptofh(vp, fhp) } static int -nullfs_extattrctl(mp, cmd, filename_vp, namespace, attrname, p) +nullfs_extattrctl(mp, cmd, filename_vp, namespace, attrname, td) struct mount *mp; int cmd; struct vnode *filename_vp; int namespace; const char *attrname; - struct proc *p; + struct thread *td; { return VFS_EXTATTRCTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, filename_vp, - namespace, attrname, p); + namespace, attrname, td); } diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 0801c0b..3683ac1 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -320,7 +320,7 @@ null_bypass(ap) *(vps_p[i]) = old_vps[i]; #if 0 if (reles & VDESC_VP0_WILLUNLOCK) - VOP_UNLOCK(*(vps_p[i]), LK_THISLAYER, curproc); + VOP_UNLOCK(*(vps_p[i]), LK_THISLAYER, curthread); #endif if (reles & VDESC_VP0_WILLRELE) vrele(*(vps_p[i])); @@ -368,7 +368,7 @@ null_lookup(ap) { struct componentname *cnp = ap->a_cnp; struct vnode *dvp = ap->a_dvp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int flags = cnp->cn_flags; struct vnode *vp, *ldvp, *lvp; int error; @@ -393,7 +393,7 @@ null_lookup(ap) * tracked by underlying filesystem. */ if (cnp->cn_flags & PDIRUNLOCK) - VOP_UNLOCK(dvp, LK_THISLAYER, p); + VOP_UNLOCK(dvp, LK_THISLAYER, td); if ((error == 0 || error == EJUSTRETURN) && lvp != NULL) { if (ldvp == lvp) { *ap->a_vpp = dvp; @@ -418,7 +418,7 @@ null_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -464,7 +464,7 @@ null_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { int error; @@ -485,7 +485,7 @@ null_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -520,7 +520,7 @@ null_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -581,12 +581,12 @@ null_lock(ap) struct vop_lock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; int flags = ap->a_flags; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *lvp; int error; @@ -594,7 +594,7 @@ null_lock(ap) if (vp->v_vnlock != NULL) return 0; /* lock is shared across layers */ error = lockmgr(&vp->v_lock, flags & ~LK_THISLAYER, - &vp->v_interlock, p); + &vp->v_interlock, td); return (error); } @@ -611,9 +611,9 @@ null_lock(ap) NULLFSDEBUG("null_lock: avoiding LK_DRAIN\n"); return(lockmgr(vp->v_vnlock, (flags & ~LK_TYPE_MASK) | LK_EXCLUSIVE, - &vp->v_interlock, p)); + &vp->v_interlock, td)); } - return(lockmgr(vp->v_vnlock, flags, &vp->v_interlock, p)); + return(lockmgr(vp->v_vnlock, flags, &vp->v_interlock, td)); } else { /* * To prevent race conditions involving doing a lookup @@ -625,21 +625,21 @@ null_lock(ap) */ lvp = NULLVPTOLOWERVP(vp); if (lvp == NULL) - return (lockmgr(&vp->v_lock, flags, &vp->v_interlock, p)); + return (lockmgr(&vp->v_lock, flags, &vp->v_interlock, td)); if (flags & LK_INTERLOCK) { mtx_unlock(&vp->v_interlock); flags &= ~LK_INTERLOCK; } if ((flags & LK_TYPE_MASK) == LK_DRAIN) { error = VOP_LOCK(lvp, - (flags & ~LK_TYPE_MASK) | LK_EXCLUSIVE, p); + (flags & ~LK_TYPE_MASK) | LK_EXCLUSIVE, td); } else - error = VOP_LOCK(lvp, flags, p); + error = VOP_LOCK(lvp, flags, td); if (error) return (error); - error = lockmgr(&vp->v_lock, flags, &vp->v_interlock, p); + error = lockmgr(&vp->v_lock, flags, &vp->v_interlock, td); if (error) - VOP_UNLOCK(lvp, 0, p); + VOP_UNLOCK(lvp, 0, td); return (error); } } @@ -654,12 +654,12 @@ null_unlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; int flags = ap->a_flags; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *lvp; if (vp->v_vnlock != NULL) { @@ -667,35 +667,35 @@ null_unlock(ap) return 0; /* the lock is shared across layers */ flags &= ~LK_THISLAYER; return (lockmgr(vp->v_vnlock, flags | LK_RELEASE, - &vp->v_interlock, p)); + &vp->v_interlock, td)); } lvp = NULLVPTOLOWERVP(vp); if (lvp == NULL) - return (lockmgr(&vp->v_lock, flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&vp->v_lock, flags | LK_RELEASE, &vp->v_interlock, td)); if ((flags & LK_THISLAYER) == 0) { if (flags & LK_INTERLOCK) { mtx_unlock(&vp->v_interlock); flags &= ~LK_INTERLOCK; } - VOP_UNLOCK(lvp, flags & ~LK_INTERLOCK, p); + VOP_UNLOCK(lvp, flags & ~LK_INTERLOCK, td); } else flags &= ~LK_THISLAYER; - return (lockmgr(&vp->v_lock, flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&vp->v_lock, flags | LK_RELEASE, &vp->v_interlock, td)); } static int null_islocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; if (vp->v_vnlock != NULL) - return (lockstatus(vp->v_vnlock, p)); - return (lockstatus(&vp->v_lock, p)); + return (lockstatus(vp->v_vnlock, td)); + return (lockstatus(&vp->v_lock, td)); } /* @@ -707,23 +707,23 @@ static int null_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct null_node *xp = VTONULL(vp); struct vnode *lowervp = xp->null_lowervp; - lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, td); LIST_REMOVE(xp, null_hash); - lockmgr(&null_hashlock, LK_RELEASE, NULL, p); + lockmgr(&null_hashlock, LK_RELEASE, NULL, td); xp->null_lowervp = NULLVP; if (vp->v_vnlock != NULL) { vp->v_vnlock = &vp->v_lock; /* we no longer share the lock */ } else - VOP_UNLOCK(vp, LK_THISLAYER, p); + VOP_UNLOCK(vp, LK_THISLAYER, td); vput(lowervp); /* @@ -743,7 +743,7 @@ static int null_reclaim(ap) struct vop_reclaim_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -774,7 +774,7 @@ null_createvobject(ap) struct vop_createvobject_args /* { struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -783,7 +783,7 @@ null_createvobject(ap) if (vp->v_type == VNON || lowervp == NULL) return 0; - error = VOP_CREATEVOBJECT(lowervp, ap->a_cred, ap->a_p); + error = VOP_CREATEVOBJECT(lowervp, ap->a_cred, ap->a_td); if (error) return (error); vp->v_flag |= VOBJBUF; diff --git a/sys/fs/nwfs/nwfs.h b/sys/fs/nwfs/nwfs.h index 41b25ae..3d2a262 100644 --- a/sys/fs/nwfs/nwfs.h +++ b/sys/fs/nwfs/nwfs.h @@ -75,9 +75,9 @@ struct nwmount { int ncp_conn_logged_in(struct nwmount *); int nwfs_ioctl(struct vop_ioctl_args *ap); -int nwfs_doio(struct buf *bp, struct ucred *cr, struct proc *p); +int nwfs_doio(struct buf *bp, struct ucred *cr, struct thread *td); int nwfs_vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, - struct proc *p, int intrflg); + struct thread *td, int intrflg); #endif /* _KERNEL */ #endif /* _NWFS_H_ */ diff --git a/sys/fs/nwfs/nwfs_io.c b/sys/fs/nwfs/nwfs_io.c index 0529158..7325ac3 100644 --- a/sys/fs/nwfs/nwfs_io.c +++ b/sys/fs/nwfs/nwfs_io.c @@ -92,7 +92,7 @@ nwfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) { count = 0; i = uio->uio_offset / DE_SIZE; /* offset in directory */ if (i == 0) { - error = ncp_initsearch(vp, uio->uio_procp, cred); + error = ncp_initsearch(vp, uio->uio_td, cred); if (error) { NCPVNDEBUG("cannot initialize search, error=%d",error); return( error ); @@ -114,7 +114,7 @@ nwfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) { dp.d_type = DT_DIR; break; default: - error = ncp_search_for_file_or_subdir(nmp, &np->n_seq, &fattr, uio->uio_procp, cred); + error = ncp_search_for_file_or_subdir(nmp, &np->n_seq, &fattr, uio->uio_td, cred); if (error && error < 0x80) break; dp.d_fileno = fattr.dirEntNum; dp.d_type = (fattr.attributes & aDIR) ? DT_DIR : DT_REG; @@ -158,7 +158,7 @@ int nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) { struct nwmount *nmp = VFSTONWFS(vp->v_mount); struct nwnode *np = VTONW(vp); - struct proc *p; + struct thread *td; struct vattr vattr; int error, biosize; @@ -170,7 +170,7 @@ nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) { if (uiop->uio_offset < 0) return EINVAL; /* if (uiop->uio_offset + uiop->uio_resid > nmp->nm_maxfilesize) return (EFBIG);*/ - p = uiop->uio_procp; + td = uiop->uio_td; if (vp->v_type == VDIR) { error = nwfs_readvdir(vp, uiop, cred); return error; @@ -178,14 +178,14 @@ nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) { biosize = NWFSTOCONN(nmp)->buffer_size; if (np->n_flag & NMODIFIED) { nwfs_attr_cacheremove(vp); - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { - error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nwfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } @@ -203,7 +203,7 @@ nwfs_writevnode(vp, uiop, cred, ioflag) { struct nwmount *nmp = VTONWFS(vp); struct nwnode *np = VTONW(vp); - struct proc *p; + struct thread *td; /* struct vattr vattr;*/ int error = 0; @@ -215,11 +215,11 @@ nwfs_writevnode(vp, uiop, cred, ioflag) if (uiop->uio_offset < 0) return EINVAL; /* if (uiop->uio_offset + uiop->uio_resid > nmp->nm_maxfilesize) return (EFBIG);*/ - p = uiop->uio_procp; + td = uiop->uio_td; if (ioflag & (IO_APPEND | IO_SYNC)) { if (np->n_flag & NMODIFIED) { nwfs_attr_cacheremove(vp); - error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nwfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } if (ioflag & IO_APPEND) { @@ -228,17 +228,18 @@ nwfs_writevnode(vp, uiop, cred, ioflag) * the correct size. */ #if notyet nwfs_attr_cacheremove(vp); - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); #endif uiop->uio_offset = np->n_size; } } if (uiop->uio_resid == 0) return 0; - if (p && uiop->uio_offset + uiop->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - PROC_LOCK(p); - psignal(p, SIGXFSZ); - PROC_UNLOCK(p); + if (td && uiop->uio_offset + uiop->uio_resid + > td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); return (EFBIG); } error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cred); @@ -256,10 +257,10 @@ nwfs_writevnode(vp, uiop, cred, ioflag) * Do an I/O operation to/from a cache block. */ int -nwfs_doio(bp, cr, p) +nwfs_doio(bp, cr, td) struct buf *bp; struct ucred *cr; - struct proc *p; + struct thread *td; { struct uio *uiop; struct vnode *vp; @@ -276,7 +277,7 @@ nwfs_doio(bp, cr, p) uiop->uio_iov = &io; uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = p; + uiop->uio_td = td; if (bp->b_iocmd == BIO_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; @@ -399,14 +400,14 @@ nwfs_getpages(ap) vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; struct nwmount *nmp; struct nwnode *np; vm_page_t *pages; vp = ap->a_vp; - p = curproc; /* XXX */ + td = curthread; /* XXX */ cred = curproc->p_ucred; /* XXX */ np = VTONW(vp); nmp = VFSTONWFS(vp->v_mount); @@ -431,7 +432,7 @@ nwfs_getpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, &uio,cred); pmap_qremove(kva, npages); @@ -511,15 +512,15 @@ nwfs_putpages(ap) { int error; struct vnode *vp = ap->a_vp; - struct proc *p; + struct thread *td; struct ucred *cred; #ifndef NWFS_RWCACHE - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ - VOP_OPEN(vp, FWRITE, cred, p); + td = curthread; /* XXX */ + cred = td->td_proc->p_ucred; /* XXX */ + VOP_OPEN(vp, FWRITE, cred, td); error = vop_stdputpages(ap); - VOP_CLOSE(vp, FWRITE, cred, p); + VOP_CLOSE(vp, FWRITE, cred, td); return error; #else struct uio uio; @@ -532,9 +533,9 @@ nwfs_putpages(ap) struct nwnode *np; vm_page_t *pages; - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ -/* VOP_OPEN(vp, FWRITE, cred, p);*/ + td = curthread; /* XXX */ + cred = td->td_proc->p_ucred; /* XXX */ +/* VOP_OPEN(vp, FWRITE, cred, td);*/ np = VTONW(vp); nmp = VFSTONWFS(vp->v_mount); pages = ap->a_m; @@ -558,11 +559,11 @@ nwfs_putpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; NCPVNDEBUG("ofs=%d,resid=%d\n",(int)uio.uio_offset, uio.uio_resid); error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, &uio, cred); -/* VOP_CLOSE(vp, FWRITE, cred, p);*/ +/* VOP_CLOSE(vp, FWRITE, cred, td);*/ NCPVNDEBUG("paged write done: %d\n", error); pmap_qremove(kva, npages); @@ -583,11 +584,11 @@ nwfs_putpages(ap) * doing the flush, just wait for completion. */ int -nwfs_vinvalbuf(vp, flags, cred, p, intrflg) +nwfs_vinvalbuf(vp, flags, cred, td, intrflg) struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; int intrflg; { struct nwnode *np = VTONW(vp); @@ -607,12 +608,12 @@ nwfs_vinvalbuf(vp, flags, cred, p, intrflg) while (np->n_flag & NFLUSHINPROG) { np->n_flag |= NFLUSHWANT; error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nwfsvinv", slptimeo); - error = ncp_chkintr(NWFSTOCONN(VTONWFS(vp)), p); + error = ncp_chkintr(NWFSTOCONN(VTONWFS(vp)), td->td_proc); if (error == EINTR && intrflg) return EINTR; } np->n_flag |= NFLUSHINPROG; - error = vinvalbuf(vp, flags, cred, p, slpflag, 0); + error = vinvalbuf(vp, flags, cred, td, slpflag, 0); while (error) { if (intrflg && (error == ERESTART || error == EINTR)) { np->n_flag &= ~NFLUSHINPROG; @@ -622,7 +623,7 @@ nwfs_vinvalbuf(vp, flags, cred, p, intrflg) } return EINTR; } - error = vinvalbuf(vp, flags, cred, p, slpflag, 0); + error = vinvalbuf(vp, flags, cred, td, slpflag, 0); } np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); if (np->n_flag & NFLUSHWANT) { diff --git a/sys/fs/nwfs/nwfs_ioctl.c b/sys/fs/nwfs/nwfs_ioctl.c index 41c956c..fd8b944 100644 --- a/sys/fs/nwfs/nwfs_ioctl.c +++ b/sys/fs/nwfs/nwfs_ioctl.c @@ -53,11 +53,11 @@ nwfs_ioctl(ap) caddr_t a_data; int fflag; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { int error; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; struct vnode *vp = ap->a_vp; struct nwnode *np = VTONW(vp); @@ -69,23 +69,23 @@ nwfs_ioctl(ap) switch (ap->a_command) { case NWFSIOC_GETCONN: - error = ncp_conn_lock(conn, p, cred, NCPM_READ); + error = ncp_conn_lock(conn, td, cred, NCPM_READ); if (error) break; - error = ncp_conn_gethandle(conn, p, &hp); - ncp_conn_unlock(conn, p); + error = ncp_conn_gethandle(conn, td, &hp); + ncp_conn_unlock(conn, td); if (error) break; *(int*)data = hp->nh_id; break; case NWFSIOC_GETEINFO: - if ((error = VOP_ACCESS(vp, VEXEC, cred, p))) break; + if ((error = VOP_ACCESS(vp, VEXEC, cred, td))) break; fap = data; error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, fap, - ap->a_p,ap->a_cred); + ap->a_td,ap->a_cred); strcpy(fap->entryName, np->n_name); fap->nameLen = np->n_nmlen; break; case NWFSIOC_GETNS: - if ((error = VOP_ACCESS(vp, VEXEC, cred, p))) break; + if ((error = VOP_ACCESS(vp, VEXEC, cred, td))) break; *(int*)data = nmp->name_space; break; default: diff --git a/sys/fs/nwfs/nwfs_node.c b/sys/fs/nwfs/nwfs_node.c index c708e1d..8fce6ac 100644 --- a/sys/fs/nwfs/nwfs_node.c +++ b/sys/fs/nwfs/nwfs_node.c @@ -139,7 +139,7 @@ static int nwfs_allocvp(struct mount *mp, ncpfid fid, struct nw_entry_info *fap, struct vnode *dvp, struct vnode **vpp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct nwnode *np; struct nwnode_hash_head *nhpp; struct nwmount *nmp = VFSTONWFS(mp); @@ -147,20 +147,20 @@ nwfs_allocvp(struct mount *mp, ncpfid fid, struct nw_entry_info *fap, int error; loop: - lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td); rescan: if (nwfs_hashlookup(nmp, fid, &np) == 0) { vp = NWTOV(np); mtx_lock(&vp->v_interlock); - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; if (fap) np->n_attr = fap->attributes; *vpp = vp; return(0); } - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); if (fap == NULL || ((fap->attributes & aDIR) == 0 && dvp == NULL)) panic("nwfs_allocvp: fap = %p, dvp = %p\n", fap, dvp); @@ -186,7 +186,7 @@ rescan: np->n_parent = VTONW(dvp)->n_fid; } lockinit(&vp->v_lock, PINOD, "nwnode", 0, LK_CANRECURSE); - lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td); /* * Another process can create vnode while we blocked in malloc() or * getnewvnode(). Rescan list again. @@ -201,8 +201,8 @@ rescan: *vpp = vp; nhpp = NWNOHASH(fid); LIST_INSERT_HEAD(nhpp, np, n_hash); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); if (vp->v_type == VDIR && dvp && (dvp->v_flag & VROOT) == 0) { np->n_flag |= NREFPARENT; @@ -229,14 +229,14 @@ nwfs_nget(struct mount *mp, ncpfid fid, struct nw_entry_info *fap, } int -nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct proc *p, +nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td, struct nwnode **npp) { int error; - lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td); error = nwfs_hashlookup(nmp, fid, npp); - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); return error; } @@ -247,26 +247,26 @@ int nwfs_reclaim(ap) struct vop_reclaim_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *dvp = NULL, *vp = ap->a_vp; struct nwnode *dnp, *np = VTONW(vp); struct nwmount *nmp = VTONWFS(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; NCPVNDEBUG("%s,%d\n", np->n_name, vp->v_usecount); if (np->n_flag & NREFPARENT) { np->n_flag &= ~NREFPARENT; - if (nwfs_lookupnp(nmp, np->n_parent, p, &dnp) == 0) { + if (nwfs_lookupnp(nmp, np->n_parent, td, &dnp) == 0) { dvp = dnp->n_vnode; } else { NCPVNDEBUG("%s: has no parent ?\n",np->n_name); } } - lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td); LIST_REMOVE(np, n_hash); - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); cache_purge(vp); if (nmp->n_root == np) { nmp->n_root = NULL; @@ -283,22 +283,22 @@ int nwfs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { - struct proc *p = ap->a_p; - struct ucred *cred = p->p_ucred; + struct thread *td = ap->a_td; + struct ucred *cred = td->td_proc->p_ucred; struct vnode *vp = ap->a_vp; struct nwnode *np = VTONW(vp); int error; NCPVNDEBUG("%s: %d\n", VTONW(vp)->n_name, vp->v_usecount); if (np->opened) { - error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1); - error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, p, cred); + error = nwfs_vinvalbuf(vp, V_SAVE, cred, td, 1); + error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, td, cred); np->opened = 0; } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (np->n_flag & NSHOULDFREE) { cache_purge(vp); vgone(vp); diff --git a/sys/fs/nwfs/nwfs_node.h b/sys/fs/nwfs/nwfs_node.h index 34c693d..fa5de92 100644 --- a/sys/fs/nwfs/nwfs_node.h +++ b/sys/fs/nwfs/nwfs_node.h @@ -83,7 +83,7 @@ struct uio; void nwfs_hash_init(void); void nwfs_hash_free(void); -int nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct proc *p, +int nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td, struct nwnode **npp); int nwfs_inactive(struct vop_inactive_args *); int nwfs_reclaim(struct vop_reclaim_args *); diff --git a/sys/fs/nwfs/nwfs_subr.c b/sys/fs/nwfs/nwfs_subr.c index b83e89b..4755891 100644 --- a/sys/fs/nwfs/nwfs_subr.c +++ b/sys/fs/nwfs/nwfs_subr.c @@ -71,7 +71,7 @@ ncp_extract_file_info(struct nwmount *nmp, struct ncp_rq *rqp, } int -ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred) +ncp_initsearch(struct vnode *dvp, struct thread *td, struct ucred *cred) { struct nwmount *nmp = VTONWFS(dvp); struct ncp_conn *conn = NWFSTOCONN(nmp); @@ -82,7 +82,7 @@ ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred) int error; NCPNDEBUG("vol=%d,dir=%d\n", volnum, dirent); - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 2); /* subfunction */ @@ -102,13 +102,13 @@ int ncp_search_for_file_or_subdir(struct nwmount *nmp, struct nw_search_seq *seq, struct nw_entry_info *target, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_conn *conn = NWFSTOCONN(nmp); struct ncp_rq *rqp; int error; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 3); /* subfunction */ @@ -138,7 +138,7 @@ ncp_search_for_file_or_subdir(struct nwmount *nmp, int ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, int namelen, char *path, struct nw_entry_info *target, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_conn *conn=NWFSTOCONN(nmp); struct ncp_rq *rqp; @@ -150,7 +150,7 @@ ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, return EINVAL; } ns = (path == NULL || path[0] == 0) ? NW_NS_DOS : nmp->name_space; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 6); /* subfunction */ @@ -173,7 +173,7 @@ ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, */ int ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct nwmount *nmp; struct nwnode *dnp = VTONW(dvp); @@ -190,10 +190,10 @@ ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, if (len == 1 && name[0] == '.') { if (dnp->n_flag & NVOLUME) { error = ncp_obtain_info(nmp, dnp->n_fid.f_id, 0, NULL, - fap, p, cred); + fap, td, cred); } else { error = ncp_obtain_info(nmp, dnp->n_fid.f_parent, - dnp->n_nmlen, dnp->n_name, fap, p, cred); + dnp->n_nmlen, dnp->n_name, fap, td, cred); } return error; } else if (len == 2 && name[0] == '.' && name[1] == '.') { @@ -201,7 +201,7 @@ ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, return EIO; } else { error = ncp_obtain_info(nmp, dnp->n_fid.f_id, - len, name, fap, p, cred); + len, name, fap, td, cred); } return error; } @@ -221,7 +221,7 @@ int ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen, char *name, int open_create_mode, u_int32_t create_attributes, int desired_acc_rights, struct ncp_open_info *nop, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_conn *conn=NWFSTOCONN(nmp); @@ -231,7 +231,7 @@ ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen u_int32_t dirent; int error; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; volnum = nmp->n_volume; @@ -267,12 +267,12 @@ ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen } int -ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct proc *p,struct ucred *cred) +ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct thread *td,struct ucred *cred) { struct ncp_rq *rqp; int error; - error = ncp_rq_alloc(66, conn, p, cred, &rqp); + error = ncp_rq_alloc(66, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 0); @@ -286,13 +286,13 @@ ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct proc *p,struct ucred *cr int ncp_DeleteNSEntry(struct nwmount *nmp, u_int32_t dirent, - int namelen,char *name,struct proc *p,struct ucred *cred) + int namelen,char *name,struct thread *td,struct ucred *cred) { struct ncp_rq *rqp; int error; struct ncp_conn *conn=NWFSTOCONN(nmp); - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 8); /* subfunction */ @@ -311,12 +311,12 @@ ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype, struct ncp_nlstables *nt, nwdirent fdir, char *old_name, int oldlen, nwdirent tdir, char *new_name, int newlen, - struct proc *p, struct ucred *cred) + struct thread *td, struct ucred *cred) { struct ncp_rq *rqp; int error; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 4); @@ -345,7 +345,7 @@ int ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, u_int32_t info_mask, struct nw_modify_dos_info *info, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct nwnode *np=VTONW(vp); struct ncp_rq *rqp; @@ -354,7 +354,7 @@ ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, struct ncp_conn *conn=NWFSTOCONN(nmp); int error; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 7); /* subfunction */ @@ -371,11 +371,11 @@ ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, } int -ncp_setattr(vp, vap, cred, procp) +ncp_setattr(vp, vap, cred, td) struct vnode *vp; struct vattr *vap; struct ucred *cred; - struct proc *procp; + struct thread *td; { struct nwmount *nmp=VTONWFS(vp); struct nwnode *np=VTONW(vp); @@ -387,12 +387,12 @@ ncp_setattr(vp, vap, cred, procp) if (vap->va_size != VNOVAL) { error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0, - AR_WRITE | AR_READ, &nwn,procp,cred); + AR_WRITE | AR_READ, &nwn,td,cred); if (error) return error; - error = ncp_rq_alloc(73, conn, procp, cred, &rqp); + error = ncp_rq_alloc(73, conn, td, cred, &rqp); if (error) { - ncp_close_file(conn, &nwn.fh, procp, cred); + ncp_close_file(conn, &nwn.fh, td, cred); return error; } mb_put_uint8(&rqp->rq, 0); @@ -403,7 +403,7 @@ ncp_setattr(vp, vap, cred, procp) np->n_vattr.va_size = np->n_size = vap->va_size; if (!error) ncp_rq_done(rqp); - ncp_close_file(conn, &nwn.fh, procp, cred); + ncp_close_file(conn, &nwn.fh, td, cred); if (error) return error; } @@ -419,7 +419,7 @@ ncp_setattr(vp, vap, cred, procp) ncp_unix2dostime(&vap->va_atime, nmp->m.tz, &info.lastAccessDate, NULL, NULL); } if (info_mask) { - error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,procp,cred); + error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,td,cred); } return (error); } @@ -427,14 +427,14 @@ ncp_setattr(vp, vap, cred, procp) int ncp_get_volume_info_with_number(struct ncp_conn *conn, int n, struct ncp_volume_info *target, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_rq *rqp; u_int32_t tmp32; u_int8_t len; int error; - error = ncp_rq_alloc_subfn(22, 44, conn, p, cred, &rqp); + error = ncp_rq_alloc_subfn(22, 44, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq,n); @@ -462,14 +462,14 @@ ncp_get_volume_info_with_number(struct ncp_conn *conn, int ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_rq *rqp; int error; u_int8_t ns; u_int16_t nscnt; - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 24); /* Subfunction: Get Loaded Name Spaces */ @@ -491,14 +491,14 @@ ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf, int ncp_lookup_volume(struct ncp_conn *conn, char *volname, u_char *volNum, u_int32_t *dirEnt, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { struct ncp_rq *rqp; u_int32_t tmp32; int error; NCPNDEBUG("looking up vol %s\n", volname); - error = ncp_rq_alloc(87, conn, p, cred, &rqp); + error = ncp_rq_alloc(87, conn, td, cred, &rqp); if (error) return error; mb_put_uint8(&rqp->rq, 22); /* Subfunction: Generate dir handle */ diff --git a/sys/fs/nwfs/nwfs_subr.h b/sys/fs/nwfs/nwfs_subr.h index b603c76..4fece8a 100644 --- a/sys/fs/nwfs/nwfs_subr.h +++ b/sys/fs/nwfs/nwfs_subr.h @@ -46,48 +46,48 @@ struct ncp_open_info; struct nw_entry_info; struct nw_search_info; struct nwmount; -struct proc; +struct thread; struct timespec; struct ucred; struct vattr; struct vnode; -int ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred); +int ncp_initsearch(struct vnode *dvp,struct thread *td, struct ucred *cred); int ncp_search_for_file_or_subdir(struct nwmount *nmp,struct nw_search_seq *seq, struct nw_entry_info *target, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_lookup_volume(struct ncp_conn *conn, char *volname, u_char *volNum, u_int32_t *dirEnt, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_close_file(struct ncp_conn *conn, ncp_fh *fh, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp, int namelen,char *name, int open_create_mode, u_int32_t create_attributes, int desired_acc_rights, struct ncp_open_info *nop, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_DeleteNSEntry(struct nwmount *nmp, u_int32_t dirent, int namelen, char *name, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype, struct ncp_nlstables *nt, nwdirent fdir, char *old_name, int oldlen, nwdirent tdir, char *new_name, int newlen, - struct proc *p, struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, int namelen, char *path, struct nw_entry_info *target, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, u_int32_t info_mask, struct nw_modify_dos_info *info, - struct proc *p,struct ucred *cred); -int ncp_setattr(struct vnode *,struct vattr *,struct ucred *,struct proc *); + struct thread *td, struct ucred *cred); +int ncp_setattr(struct vnode *,struct vattr *,struct ucred *,struct thread *td); int ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); int ncp_get_volume_info_with_number(struct ncp_conn *conn, int n, struct ncp_volume_info *target, - struct proc *p,struct ucred *cred); + struct thread *td, struct ucred *cred); void ncp_unix2dostime (struct timespec *tsp, int tz, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp); diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c index 2fb0752..de5ae2f 100644 --- a/sys/fs/nwfs/nwfs_vfsops.c +++ b/sys/fs/nwfs/nwfs_vfsops.c @@ -71,13 +71,13 @@ MODULE_DEPEND(nwfs, ncp, 1, 1, 1); MODULE_DEPEND(nwfs, libmchain, 1, 1, 1); static int nwfs_mount(struct mount *, char *, caddr_t, - struct nameidata *, struct proc *); -static int nwfs_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *); + struct nameidata *, struct thread *); +static int nwfs_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *); static int nwfs_root(struct mount *, struct vnode **); -static int nwfs_start(struct mount *, int, struct proc *); -static int nwfs_statfs(struct mount *, struct statfs *, struct proc *); -static int nwfs_sync(struct mount *, int, struct ucred *, struct proc *); -static int nwfs_unmount(struct mount *, int, struct proc *); +static int nwfs_start(struct mount *, int, struct thread *); +static int nwfs_statfs(struct mount *, struct statfs *, struct thread *); +static int nwfs_sync(struct mount *, int, struct ucred *, struct thread *); +static int nwfs_unmount(struct mount *, int, struct thread *); static int nwfs_init(struct vfsconf *vfsp); static int nwfs_uninit(struct vfsconf *vfsp); @@ -144,7 +144,7 @@ nwfs_initnls(struct nwmount *nmp) { * data - addr in user space of mount params */ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p) + struct nameidata *ndp, struct thread *td) { struct nwfs_args args; /* will hold data from mount request */ int error; @@ -169,7 +169,7 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, nwfs_printf("mount version mismatch: kernel=%d, mount=%d\n",NWFS_VERSION,args.version); return (1); } - error = ncp_conn_getbyref(args.connRef,p,p->p_ucred,NCPM_EXECUTE,&conn); + error = ncp_conn_getbyref(args.connRef, td , td->td_proc->p_ucred,NCPM_EXECUTE,&conn); if (error) { nwfs_printf("invalid connection refernce %d\n",args.connRef); return (error); @@ -179,7 +179,7 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, nwfs_printf("can't get connection handle\n"); return (error); } - ncp_conn_unlock(conn,p); /* we keep the ref */ + ncp_conn_unlock(conn, td); /* we keep the ref */ mp->mnt_stat.f_iosize = conn->buffer_size; /* We must malloc our own mount info */ MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE | M_ZERO); @@ -220,7 +220,7 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, /* * Lose the lock but keep the ref. */ - VOP_UNLOCK(vp, 0, curproc); + VOP_UNLOCK(vp, 0, curthread); NCPVODEBUG("rootvp.vrefcnt=%d\n",vp->v_usecount); return error; bad: @@ -233,7 +233,7 @@ bad: /* Unmount the filesystem described by mp. */ static int -nwfs_unmount(struct mount *mp, int mntflags, struct proc *p) +nwfs_unmount(struct mount *mp, int mntflags, struct thread *td) { struct nwmount *nmp = VFSTONWFS(mp); struct ncp_conn *conn; @@ -249,9 +249,9 @@ nwfs_unmount(struct mount *mp, int mntflags, struct proc *p) return (error); conn = NWFSTOCONN(nmp); ncp_conn_puthandle(nmp->connh,NULL,0); - if (ncp_conn_lock(conn,p,p->p_ucred,NCPM_WRITE | NCPM_EXECUTE) == 0) { + if (ncp_conn_lock(conn, td, td->td_proc->p_ucred,NCPM_WRITE | NCPM_EXECUTE) == 0) { if(ncp_conn_free(conn)) - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn, td); } mp->mnt_data = (qaddr_t)0; if (nmp->m.flags & NWFS_MOUNT_HAVE_NLS) @@ -269,8 +269,8 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { struct nwnode *np; struct ncp_conn *conn; struct nw_entry_info fattr; - struct proc *p = curproc; - struct ucred *cred = p->p_ucred; + struct thread *td = curthread; + struct ucred *cred = td->td_proc->p_ucred; int error, nsf, opt; u_char vol; @@ -278,16 +278,16 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { conn = NWFSTOCONN(nmp); if (nmp->n_root) { *vpp = NWTOV(nmp->n_root); - while (vget(*vpp, LK_EXCLUSIVE, curproc) != 0) + while (vget(*vpp, LK_EXCLUSIVE, curthread) != 0) ; return 0; } error = ncp_lookup_volume(conn, nmp->m.mounted_vol, &vol, - &nmp->n_rootent.f_id, p, cred); + &nmp->n_rootent.f_id, td, cred); if (error) return ENOENT; nmp->n_volume = vol; - error = ncp_get_namespaces(conn, vol, &nsf, p, cred); + error = ncp_get_namespaces(conn, vol, &nsf, td, cred); if (error) return ENOENT; if (nsf & NW_NSB_OS2) { @@ -313,7 +313,7 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { if (nmp->m.root_path[0]) { nmp->m.root_path[0]--; error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - -nmp->m.root_path[0], nmp->m.root_path, &fattr, p, cred); + -nmp->m.root_path[0], nmp->m.root_path, &fattr, td, cred); if (error) { NCPFATAL("Invalid root path specified\n"); return ENOENT; @@ -321,7 +321,7 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { nmp->n_rootent.f_parent = fattr.dirEntNum; nmp->m.root_path[0]++; error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - -nmp->m.root_path[0], nmp->m.root_path, &fattr, p, cred); + -nmp->m.root_path[0], nmp->m.root_path, &fattr, td, cred); if (error) { NCPFATAL("Invalid root path specified\n"); return ENOENT; @@ -329,7 +329,7 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { nmp->n_rootent.f_id = fattr.dirEntNum; } else { error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - 0, NULL, &fattr, p, cred); + 0, NULL, &fattr, td, cred); if (error) { NCPFATAL("Can't obtain volume info\n"); return ENOENT; @@ -345,7 +345,7 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { if (nmp->m.root_path[0] == 0) np->n_flag |= NVOLUME; nmp->n_root = np; -/* error = VOP_GETATTR(vp, &vattr, cred, p); +/* error = VOP_GETATTR(vp, &vattr, cred, td); if (error) { vput(vp); NCPFATAL("Can't get root directory entry\n"); @@ -360,10 +360,10 @@ nwfs_root(struct mount *mp, struct vnode **vpp) { */ /* ARGSUSED */ static int -nwfs_start(mp, flags, p) +nwfs_start(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { NCPVODEBUG("flags=%04x\n",flags); return (0); @@ -374,12 +374,12 @@ nwfs_start(mp, flags, p) */ /* ARGSUSED */ static int -nwfs_quotactl(mp, cmd, uid, arg, p) +nwfs_quotactl(mp, cmd, uid, arg, td) struct mount *mp; int cmd; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { NCPVODEBUG("return EOPNOTSUPP\n"); return (EOPNOTSUPP); @@ -395,7 +395,7 @@ nwfs_init(struct vfsconf *vfsp) name[0] = CTL_HW; name[1] = HW_NCPU; - error = kernel_sysctl(curproc, name, 2, &ncpu, &olen, NULL, 0, &plen); + error = kernel_sysctl(curthread, name, 2, &ncpu, &olen, NULL, 0, &plen); if (error == 0 && ncpu > 1) printf("warning: nwfs module compiled without SMP support."); #endif @@ -419,10 +419,10 @@ nwfs_uninit(struct vfsconf *vfsp) * nwfs_statfs call */ int -nwfs_statfs(mp, sbp, p) +nwfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { struct nwmount *nmp = VFSTONWFS(mp); int error = 0, secsize; @@ -430,7 +430,8 @@ nwfs_statfs(mp, sbp, p) struct ncp_volume_info vi; if (np == NULL) return EINVAL; - error = ncp_get_volume_info_with_number(NWFSTOCONN(nmp), nmp->n_volume, &vi,p,p->p_ucred); + error = ncp_get_volume_info_with_number(NWFSTOCONN(nmp), + nmp->n_volume, &vi, td, td->td_proc->p_ucred); if (error) return error; secsize = 512; /* XXX how to get real value ??? */ sbp->f_spare2=0; /* placeholder */ @@ -465,11 +466,11 @@ nwfs_statfs(mp, sbp, p) */ /* ARGSUSED */ static int -nwfs_sync(mp, waitfor, cred, p) +nwfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *vp, *nvp; int error, allerror = 0; @@ -496,11 +497,11 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { mtx_lock(&mntvnode_mtx); goto loop; } - error = VOP_FSYNC(vp, cred, waitfor, p); + error = VOP_FSYNC(vp, cred, waitfor, td); if (error) allerror = error; vput(vp); diff --git a/sys/fs/nwfs/nwfs_vnops.c b/sys/fs/nwfs/nwfs_vnops.c index dc83b3d..9d773f8 100644 --- a/sys/fs/nwfs/nwfs_vnops.c +++ b/sys/fs/nwfs/nwfs_vnops.c @@ -132,7 +132,7 @@ nwfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -170,7 +170,7 @@ nwfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -181,24 +181,24 @@ nwfs_open(ap) struct vattr vattr; int error, nwm; - NCPVNDEBUG("%s,%d\n",np->n_name, np->opened); + NCPVNDEBUG("%s,%d\n", np->n_name, np->opened); if (vp->v_type != VREG && vp->v_type != VDIR) { NCPFATAL("open vtype = %d\n", vp->v_type); return (EACCES); } if (vp->v_type == VDIR) return 0; /* nothing to do now */ if (np->n_flag & NMODIFIED) { - if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1)) == EINTR) + if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1)) == EINTR) return (error); np->n_atime = 0; - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { - if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1)) == EINTR) + if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1)) == EINTR) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } @@ -211,13 +211,13 @@ nwfs_open(ap) if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) nwm |= AR_WRITE; error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, - 0, nwm, &no, ap->a_p, ap->a_cred); + 0, nwm, &no, ap->a_td, ap->a_cred); if (error) { if (mode & FWRITE) return EACCES; nwm = AR_READ; error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0, - nwm, &no, ap->a_p,ap->a_cred); + nwm, &no, ap->a_td, ap->a_cred); } if (!error) { np->opened++; @@ -235,14 +235,15 @@ nwfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; struct nwnode *np = VTONW(vp); int error; - NCPVNDEBUG("name=%s,pid=%d,c=%d\n",np->n_name,ap->a_p->p_pid,np->opened); + NCPVNDEBUG("name=%s,pid=%d,c=%d\n", np->n_name, ap->a_td->td_proc->p_pid, + np->opened); if (vp->v_type == VDIR) return 0; /* nothing to do now */ error = 0; @@ -252,7 +253,7 @@ nwfs_close(ap) return 0; } mtx_unlock(&vp->v_interlock); - error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1); + error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1); mtx_lock(&vp->v_interlock); if (np->opened == 0) { mtx_unlock(&vp->v_interlock); @@ -261,7 +262,7 @@ nwfs_close(ap) if (--np->opened == 0) { mtx_unlock(&vp->v_interlock); error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, - ap->a_p, ap->a_cred); + ap->a_td, ap->a_cred); } else mtx_unlock(&vp->v_interlock); np->n_atime = 0; @@ -277,7 +278,7 @@ nwfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -289,16 +290,16 @@ nwfs_getattr(ap) u_int32_t oldsize; NCPVNDEBUG("%lx:%d: '%s' %d\n", (long)vp, nmp->n_volume, np->n_name, (vp->v_flag & VROOT) != 0); - error = nwfs_attr_cachelookup(vp,va); + error = nwfs_attr_cachelookup(vp, va); if (!error) return 0; NCPVNDEBUG("not in cache\n"); oldsize = np->n_size; if (np->n_flag & NVOLUME) { error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, &fattr, - ap->a_p,ap->a_cred); + ap->a_td, ap->a_cred); } else { error = ncp_obtain_info(nmp, np->n_fid.f_parent, np->n_nmlen, - np->n_name, &fattr, ap->a_p, ap->a_cred); + np->n_name, &fattr, ap->a_td, ap->a_cred); } if (error) { NCPVNDEBUG("error %d\n", error); @@ -319,7 +320,7 @@ nwfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -357,13 +358,13 @@ nwfs_setattr(ap) return EINVAL; }; } - error = ncp_setattr(vp, vap, ap->a_cred, ap->a_p); + error = ncp_setattr(vp, vap, ap->a_cred, ap->a_td); if (error && vap->va_size != VNOVAL) { np->n_size = tsize; vnode_pager_setsize(vp, (u_long)tsize); } np->n_atime = 0; /* invalidate cache */ - VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p); + VOP_GETATTR(vp, vap, ap->a_cred, ap->a_td); np->n_mtime = vap->va_mtime.tv_sec; return (0); } @@ -403,11 +404,11 @@ nwfs_write(ap) struct uio *uio = ap->a_uio; int error; - NCPVNDEBUG("%d,ofs=%d,sz=%d\n",vp->v_type, (int)uio->uio_offset, uio->uio_resid); + NCPVNDEBUG("%d,ofs=%d,sz=%d\n", vp->v_type, (int)uio->uio_offset, uio->uio_resid); if (vp->v_type != VREG) return (EPERM); - error = nwfs_writevnode(vp, uio, ap->a_cred,ap->a_ioflag); + error = nwfs_writevnode(vp, uio, ap->a_cred, ap->a_ioflag); return(error); } /* @@ -443,18 +444,18 @@ nwfs_create(ap) *vpp = NULL; if (vap->va_type == VSOCK) return (EOPNOTSUPP); - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc))) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread))) { return (error); } fmode = AR_READ | AR_WRITE; /* if (vap->va_vaflags & VA_EXCLUSIVE) fmode |= AR_DENY_READ | AR_DENY_WRITE;*/ - error = ncp_open_create_file_or_subdir(nmp,dvp,cnp->cn_namelen,cnp->cn_nameptr, + error = ncp_open_create_file_or_subdir(nmp, dvp, cnp->cn_namelen, cnp->cn_nameptr, OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE, - 0, fmode, &no, cnp->cn_proc, cnp->cn_cred); + 0, fmode, &no, cnp->cn_thread, cnp->cn_cred); if (!error) { - error = ncp_close_file(NWFSTOCONN(nmp), &no.fh, cnp->cn_proc,cnp->cn_cred); + error = ncp_close_file(NWFSTOCONN(nmp), &no.fh, cnp->cn_thread, cnp->cn_cred); fid.f_parent = VTONW(dvp)->n_fid.f_id; fid.f_id = no.fattr.dirEntNum; error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &vp); @@ -493,7 +494,7 @@ nwfs_remove(ap) return EPERM; cache_purge(vp); error = ncp_DeleteNSEntry(nmp, VTONW(dvp)->n_fid.f_id, - cnp->cn_namelen,cnp->cn_nameptr,cnp->cn_proc,cnp->cn_cred); + cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_thread, cnp->cn_cred); if (error == 0) np->n_flag |= NSHOULDFREE; else if (error == 0x899c) @@ -539,7 +540,7 @@ nwfs_rename(ap) if (tvp && tvp != fvp) { error = ncp_DeleteNSEntry(nmp, VTONW(tdvp)->n_fid.f_id, tcnp->cn_namelen, tcnp->cn_nameptr, - tcnp->cn_proc, tcnp->cn_cred); + tcnp->cn_thread, tcnp->cn_cred); if (error == 0x899c) error = EACCES; if (error) goto out; @@ -554,7 +555,7 @@ nwfs_rename(ap) oldtype, &nmp->m.nls, VTONW(fdvp)->n_fid.f_id, fcnp->cn_nameptr, fcnp->cn_namelen, VTONW(tdvp)->n_fid.f_id, tcnp->cn_nameptr, tcnp->cn_namelen, - tcnp->cn_proc,tcnp->cn_cred); + tcnp->cn_thread, tcnp->cn_cred); if (error == 0x8992) error = EEXIST; @@ -648,15 +649,15 @@ nwfs_mkdir(ap) struct vattr vattr; char *name=cnp->cn_nameptr; - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc))) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread))) { return (error); } if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) { return EEXIST; } - if (ncp_open_create_file_or_subdir(VTONWFS(dvp),dvp, cnp->cn_namelen, - cnp->cn_nameptr,OC_MODE_CREATE, aDIR, 0xffff, - &no, cnp->cn_proc, cnp->cn_cred) != 0) { + if (ncp_open_create_file_or_subdir(VTONWFS(dvp), dvp, cnp->cn_namelen, + cnp->cn_nameptr, OC_MODE_CREATE, aDIR, 0xffff, + &no, cnp->cn_thread, cnp->cn_cred) != 0) { error = EACCES; } else { error = 0; @@ -697,7 +698,7 @@ nwfs_rmdir(ap) return EINVAL; error = ncp_DeleteNSEntry(nmp, dnp->n_fid.f_id, - cnp->cn_namelen, cnp->cn_nameptr,cnp->cn_proc,cnp->cn_cred); + cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_thread, cnp->cn_cred); if (error == 0) np->n_flag |= NSHOULDFREE; else if (error == NWE_DIR_NOT_EMPTY) @@ -745,10 +746,10 @@ nwfs_fsync(ap) struct vnode * a_vp; struct ucred * a_cred; int a_waitfor; - struct proc * a_p; + struct thread *a_td; } */ *ap; { -/* return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1));*/ +/* return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1));*/ return (0); } @@ -800,16 +801,16 @@ static int nwfs_strategy (ap) { struct buf *bp=ap->a_bp; struct ucred *cr; - struct proc *p; + struct thread *td; int error = 0; NCPVNDEBUG("\n"); if (bp->b_flags & B_PHYS) panic("nwfs physio"); if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; + td = (struct thread *)0; else - p = curproc; /* XXX */ + td = curthread; /* XXX */ if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; else @@ -820,7 +821,7 @@ static int nwfs_strategy (ap) * otherwise just do it ourselves. */ if ((bp->b_flags & B_ASYNC) == 0 ) - error = nwfs_doio(bp, cr, p); + error = nwfs_doio(bp, cr, td); return (error); } @@ -851,9 +852,9 @@ nwfs_lookup(ap) ncpfid fid; int nameiop=cnp->cn_nameiop, islastcn; int lockparent, wantparent, error = 0, notfound; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; char _name[cnp->cn_namelen+1]; - bcopy(cnp->cn_nameptr,_name,cnp->cn_namelen); + bcopy(cnp->cn_nameptr, _name, cnp->cn_namelen); _name[cnp->cn_namelen]=0; if (dvp->v_type != VDIR) @@ -869,7 +870,7 @@ nwfs_lookup(ap) islastcn = flags & ISLASTCN; if (islastcn && (mp->mnt_flag & MNT_RDONLY) && (nameiop != LOOKUP)) return (EROFS); - if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p))) + if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td))) return (error); lockparent = flags & LOCKPARENT; wantparent = flags & (LOCKPARENT|WANTPARENT); @@ -884,7 +885,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO return ENOENT; error = cache_lookup(dvp, vpp, cnp); - NCPVNDEBUG("cache_lookup returned %d\n",error); + NCPVNDEBUG("cache_lookup returned %d\n", error); if (error > 0) return error; if (error) { /* name was found */ @@ -898,18 +899,18 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO error = 0; NCPVNDEBUG("cached '.'"); } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); /* unlock parent */ - error = vget(vp, LK_EXCLUSIVE, p); + VOP_UNLOCK(dvp, 0, td); /* unlock parent */ + error = vget(vp, LK_EXCLUSIVE, td); if (!error && lockparent && islastcn) - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); } else { - error = vget(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (!lockparent || error || !islastcn) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } if (!error) { if (vpid == vp->v_id) { - if (!VOP_GETATTR(vp, &vattr, cnp->cn_cred, p) + if (!VOP_GETATTR(vp, &vattr, cnp->cn_cred, td) && vattr.va_ctime.tv_sec == VTONW(vp)->n_ctime) { if (nameiop != LOOKUP && islastcn) cnp->cn_flags |= SAVENAME; @@ -920,9 +921,9 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO } vput(vp); if (lockparent && dvp != vp && islastcn) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); *vpp = NULLVP; if (error) return (error); @@ -937,7 +938,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO fap = NULL; notfound = 0; } else { - error = nwfs_lookupnp(nmp, dnp->n_parent, p, &npp); + error = nwfs_lookupnp(nmp, dnp->n_parent, td, &npp); if (error) { return error; } @@ -945,18 +946,18 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO fap = &fattr; /*np = *npp;*/ notfound = ncp_obtain_info(nmp, npp->n_dosfid, - 0, NULL, fap, p, cnp->cn_cred); + 0, NULL, fap, td, cnp->cn_cred); } } else { fap = &fattr; notfound = ncp_lookup(dvp, cnp->cn_namelen, cnp->cn_nameptr, - fap, p, cnp->cn_cred); + fap, td, cnp->cn_cred); fid.f_id = fap->dirEntNum; if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { fid.f_parent = dnp->n_fid.f_parent; } else fid.f_parent = dnp->n_fid.f_id; - NCPVNDEBUG("call to ncp_lookup returned=%d\n",notfound); + NCPVNDEBUG("call to ncp_lookup returned=%d\n", notfound); } if (notfound && notfound < 0x80 ) return (notfound); /* hard error */ @@ -965,7 +966,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO if ((nameiop == CREATE || nameiop == RENAME) && wantparent && islastcn) { cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); return (EJUSTRETURN); } return ENOENT; @@ -974,7 +975,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO }*/ /* handle DELETE case ... */ if (nameiop == DELETE && islastcn) { /* delete last component */ - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) return (error); if (NWCMPF(&dnp->n_fid, &fid)) { /* we found ourselfs */ VREF(dvp); @@ -985,11 +986,11 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO if (error) return (error); *vpp = vp; cnp->cn_flags |= SAVENAME; /* I free it later */ - if (!lockparent) VOP_UNLOCK(dvp,0,p); + if (!lockparent) VOP_UNLOCK(dvp, 0, td); return (0); } if (nameiop == RENAME && islastcn && wantparent) { - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) return (error); if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR; error = nwfs_nget(mp, fid, fap, dvp, &vp); @@ -997,18 +998,18 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO *vpp = vp; cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(dvp,0,p); + VOP_UNLOCK(dvp, 0, td); return (0); } if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); /* race to get the inode */ + VOP_UNLOCK(dvp, 0, td); /* race to get the inode */ error = nwfs_nget(mp, fid, NULL, NULL, &vp); if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (lockparent && islastcn && - (error = vn_lock(dvp, LK_EXCLUSIVE, p))) { + (error = vn_lock(dvp, LK_EXCLUSIVE, td))) { vput(vp); return (error); } @@ -1022,7 +1023,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDO *vpp = vp; NCPVNDEBUG("lookup: getnewvp!\n"); if (!lockparent || !islastcn) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } if ((cnp->cn_flags & MAKEENTRY)/* && !islastcn*/) { VTONW(*vpp)->n_ctime = VTONW(*vpp)->n_vattr.va_ctime.tv_sec; diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c index 5c47e72..80356e4 100644 --- a/sys/fs/portalfs/portal_vfsops.c +++ b/sys/fs/portalfs/portal_vfsops.c @@ -62,23 +62,23 @@ static MALLOC_DEFINE(M_PORTALFSMNT, "PORTAL mount", "PORTAL mount structure"); static int portal_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int portal_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); static int portal_root __P((struct mount *mp, struct vnode **vpp)); static int portal_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); /* * Mount the per-process file descriptors (/dev/fd) */ static int -portal_mount(mp, path, data, ndp, p) +portal_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct file *fp; struct portal_args args; @@ -99,12 +99,12 @@ portal_mount(mp, path, data, ndp, p) if (error) return (error); - error = holdsock(p->p_fd, args.pa_socket, &fp); + error = holdsock(td->td_proc->p_fd, args.pa_socket, &fp); if (error) return (error); so = (struct socket *) fp->f_data; if (so->so_proto->pr_domain->dom_family != AF_UNIX) { - fdrop(fp, p); + fdrop(fp, td); return (ESOCKTNOSUPPORT); } @@ -118,7 +118,7 @@ portal_mount(mp, path, data, ndp, p) if (error) { FREE(fmp, M_PORTALFSMNT); FREE(pn, M_TEMP); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -144,16 +144,16 @@ portal_mount(mp, path, data, ndp, p) bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal")); #endif - (void)portal_statfs(mp, &mp->mnt_stat, p); - fdrop(fp, p); + (void)portal_statfs(mp, &mp->mnt_stat, td); + fdrop(fp, td); return (0); } static int -portal_unmount(mp, mntflags, p) +portal_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error, flags = 0; @@ -186,7 +186,7 @@ portal_unmount(mp, mntflags, p) * Discard reference to underlying file. Must call closef because * this may be the last reference. */ - closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0); + closef(VFSTOPORTAL(mp)->pm_server, (struct thread *) 0); /* * Finally, throw away the portalmount structure */ @@ -200,7 +200,7 @@ portal_root(mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; /* @@ -208,16 +208,16 @@ portal_root(mp, vpp) */ vp = VFSTOPORTAL(mp)->pm_root; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = vp; return (0); } static int -portal_statfs(mp, sbp, p) +portal_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { sbp->f_flags = 0; diff --git a/sys/fs/portalfs/portal_vnops.c b/sys/fs/portalfs/portal_vnops.c index 03deb34..0e20d13 100644 --- a/sys/fs/portalfs/portal_vnops.c +++ b/sys/fs/portalfs/portal_vnops.c @@ -65,7 +65,7 @@ static int portal_fileid = PORTAL_ROOTFILEID+1; -static void portal_closefd __P((struct proc *p, int fd)); +static void portal_closefd __P((struct thread *td, int fd)); static int portal_connect __P((struct socket *so, struct socket *so2)); static int portal_getattr __P((struct vop_getattr_args *ap)); static int portal_lookup __P((struct vop_lookup_args *ap)); @@ -76,15 +76,15 @@ static int portal_reclaim __P((struct vop_reclaim_args *ap)); static int portal_setattr __P((struct vop_setattr_args *ap)); static void -portal_closefd(p, fd) - struct proc *p; +portal_closefd(td, fd) + struct thread *td; int fd; { int error; struct close_args ua; ua.fd = fd; - error = close(p, &ua); + error = close(td, &ua); /* * We should never get an error, and there isn't anything * we could do if we got one, so just print a message. @@ -204,12 +204,12 @@ portal_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct socket *so = 0; struct portalnode *pt; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *vp = ap->a_vp; int s; struct uio auio; @@ -237,7 +237,7 @@ portal_open(ap) * to deal with the side effects. Check for this * by testing whether the p_dupfd has been set. */ - if (p->p_dupfd >= 0) + if (td->td_dupfd >= 0) return (ENODEV); pt = VTOPORTAL(vp); @@ -246,7 +246,7 @@ portal_open(ap) /* * Create a new socket. */ - error = socreate(AF_UNIX, &so, SOCK_STREAM, 0, ap->a_p); + error = socreate(AF_UNIX, &so, SOCK_STREAM, 0, ap->a_td); if (error) goto bad; @@ -315,12 +315,12 @@ portal_open(ap) auio.uio_iovcnt = 2; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len; error = sosend(so, (struct sockaddr *) 0, &auio, - (struct mbuf *) 0, (struct mbuf *) 0, 0, p); + (struct mbuf *) 0, (struct mbuf *) 0, 0 , td); if (error) goto bad; @@ -392,7 +392,7 @@ portal_open(ap) int i; printf("portal_open: %d extra fds\n", newfds - 1); for (i = 1; i < newfds; i++) { - portal_closefd(p, *ip); + portal_closefd(td, *ip); ip++; } } @@ -401,9 +401,9 @@ portal_open(ap) * Check that the mode the file is being opened for is a subset * of the mode of the existing descriptor. */ - fp = p->p_fd->fd_ofiles[fd]; + fp = td->td_proc->p_fd->fd_ofiles[fd]; if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) { - portal_closefd(p, fd); + portal_closefd(td, fd); error = EACCES; goto bad; } @@ -413,7 +413,7 @@ portal_open(ap) * special error code (ENXIO) which causes magic things to * happen in vn_open. The whole concept is, well, hmmm. */ - p->p_dupfd = fd; + td->td_dupfd = fd; error = ENXIO; bad:; @@ -437,7 +437,7 @@ portal_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -482,7 +482,7 @@ portal_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { diff --git a/sys/fs/procfs/procfs.h b/sys/fs/procfs/procfs.h index b46b9c0..d97f825 100644 --- a/sys/fs/procfs/procfs.h +++ b/sys/fs/procfs/procfs.h @@ -119,14 +119,14 @@ void procfs_exit __P((struct proc *)); int procfs_freevp __P((struct vnode *)); int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); struct vnode *procfs_findtextvp __P((struct proc *)); -int procfs_sstep __P((struct proc *)); -void procfs_fix_sstep __P((struct proc *)); -int procfs_read_regs __P((struct proc *, struct reg *)); -int procfs_write_regs __P((struct proc *, struct reg *)); -int procfs_read_fpregs __P((struct proc *, struct fpreg *)); -int procfs_write_fpregs __P((struct proc *, struct fpreg *)); -int procfs_read_dbregs __P((struct proc *, struct dbreg *)); -int procfs_write_dbregs __P((struct proc *, struct dbreg *)); +int procfs_sstep __P((struct thread *)); +void procfs_fix_sstep __P((struct thread *)); +int procfs_read_regs __P((struct thread *, struct reg *)); +int procfs_write_regs __P((struct thread *, struct reg *)); +int procfs_read_fpregs __P((struct thread *, struct fpreg *)); +int procfs_write_fpregs __P((struct thread *, struct fpreg *)); +int procfs_read_dbregs __P((struct thread *, struct dbreg *)); +int procfs_write_dbregs __P((struct thread *, struct dbreg *)); int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); @@ -140,12 +140,12 @@ int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *pfsp, st int procfs_dorlimit __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); /* functions to check whether or not files should be displayed */ -int procfs_validfile __P((struct proc *)); -int procfs_validfpregs __P((struct proc *)); -int procfs_validregs __P((struct proc *)); -int procfs_validdbregs __P((struct proc *)); -int procfs_validmap __P((struct proc *)); -int procfs_validtype __P((struct proc *)); +int procfs_validfile __P((struct thread *)); +int procfs_validfpregs __P((struct thread *)); +int procfs_validregs __P((struct thread *)); +int procfs_validdbregs __P((struct thread *)); +int procfs_validmap __P((struct thread *)); +int procfs_validtype __P((struct thread *)); #define PROCFS_LOCKED 0x01 #define PROCFS_WANT 0x02 diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c index 30b61f2..eacf32a 100644 --- a/sys/fs/procfs/procfs_ctl.c +++ b/sys/fs/procfs/procfs_ctl.c @@ -190,7 +190,7 @@ out: /* * do single-step fixup if needed */ - FIX_SSTEP(p); + FIX_SSTEP(&p->p_thread); /* XXXKSE */ #endif /* @@ -246,7 +246,7 @@ out: case PROCFS_CTL_STEP: _PHOLD(p); PROC_UNLOCK(p); - error = procfs_sstep(p); + error = procfs_sstep(&p->p_thread); /* XXXKSE */ PRELE(p); if (error) return (error); @@ -300,7 +300,7 @@ out: mtx_lock_spin(&sched_lock); if (p->p_stat == SSTOP) - setrunnable(p); + setrunnable(&p->p_thread); /* XXXKSE */ mtx_unlock_spin(&sched_lock); return (0); } @@ -347,9 +347,9 @@ procfs_doctl(curp, p, pfs, uio) if (TRACE_WAIT_P(curp, p)) { p->p_xstat = nm->nm_val; #ifdef FIX_SSTEP - FIX_SSTEP(p); + FIX_SSTEP(&p->p_thread); /* XXXKSE */ #endif - setrunnable(p); + setrunnable(&p->p_thread); /* XXXKSE */ mtx_unlock_spin(&sched_lock); } else { mtx_unlock_spin(&sched_lock); diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c index d61b8c9..5de041a 100644 --- a/sys/fs/procfs/procfs_dbregs.c +++ b/sys/fs/procfs/procfs_dbregs.c @@ -83,14 +83,14 @@ procfs_dodbregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_dbregs(p, &r); + error = procfs_read_dbregs(&p->p_thread, &r); /* XXXKSE */ if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_dbregs(p, &r); + error = procfs_write_dbregs(&p->p_thread, &r); /* XXXKSE */ } PRELE(p); @@ -99,9 +99,8 @@ procfs_dodbregs(curp, p, pfs, uio) } int -procfs_validdbregs(p) - struct proc *p; +procfs_validdbregs(struct thread *td) { - return ((p->p_flag & P_SYSTEM) == 0); + return ((td->td_proc->p_flag & P_SYSTEM) == 0); } diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c index 9b6cd3a..2b68693 100644 --- a/sys/fs/procfs/procfs_fpregs.c +++ b/sys/fs/procfs/procfs_fpregs.c @@ -80,14 +80,14 @@ procfs_dofpregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_fpregs(p, &r); + error = procfs_read_fpregs(&p->p_thread, &r); if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_fpregs(p, &r); + error = procfs_write_fpregs(&p->p_thread, &r); } PRELE(p); @@ -96,9 +96,8 @@ procfs_dofpregs(curp, p, pfs, uio) } int -procfs_validfpregs(p) - struct proc *p; +procfs_validfpregs(struct thread *td) { - return ((p->p_flag & P_SYSTEM) == 0); + return (( td->td_proc->p_flag & P_SYSTEM) == 0); } diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c index 692594d..945639a 100644 --- a/sys/fs/procfs/procfs_map.c +++ b/sys/fs/procfs/procfs_map.c @@ -182,8 +182,7 @@ case OBJT_DEVICE: } int -procfs_validmap(p) - struct proc *p; +procfs_validmap(struct thread *td) { - return ((p->p_flag & P_SYSTEM) == 0); + return ((td->td_proc->p_flag & P_SYSTEM) == 0); } diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c index 6a00ecd..f590075 100644 --- a/sys/fs/procfs/procfs_regs.c +++ b/sys/fs/procfs/procfs_regs.c @@ -81,14 +81,14 @@ procfs_doregs(curp, p, pfs, uio) if (kl < 0) error = EINVAL; else - error = procfs_read_regs(p, &r); + error = procfs_read_regs(&p->p_thread, &r); /* XXXKSE */ if (error == 0) error = uiomove(kv, kl, uio); if (error == 0 && uio->uio_rw == UIO_WRITE) { if (p->p_stat != SSTOP) error = EBUSY; else - error = procfs_write_regs(p, &r); + error = procfs_write_regs(&p->p_thread, &r); /* XXXKSE */ } PRELE(p); @@ -97,9 +97,8 @@ procfs_doregs(curp, p, pfs, uio) } int -procfs_validregs(p) - struct proc *p; +procfs_validregs(struct thread *td) { - return ((p->p_flag & P_SYSTEM) == 0); + return ((td->td_proc->p_flag & P_SYSTEM) == 0); } diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 3a2a814..c75294b 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -145,8 +145,14 @@ procfs_dostatus(curp, p, pfs, uio) } DOCHECK(); - ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, " %s", - (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan"); + if (p->p_flag & P_KSES) { + ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, " %s", + "-kse- "); + } else { + ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, " %s", + (p->p_thread.td_wchan && p->p_thread.td_wmesg) ? + p->p_thread.td_wmesg : "nochan"); + } DOCHECK(); cr = p->p_ucred; diff --git a/sys/fs/procfs/procfs_subr.c b/sys/fs/procfs/procfs_subr.c index 8575058..a411546 100644 --- a/sys/fs/procfs/procfs_subr.c +++ b/sys/fs/procfs/procfs_subr.c @@ -88,7 +88,7 @@ procfs_allocvp(mp, vpp, pid, pfs_type) long pid; pfstype pfs_type; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct pfsnode *pfs; struct vnode *vp; struct pfsnode **pp; @@ -100,7 +100,7 @@ loop: if (pfs->pfs_pid == pid && pfs->pfs_type == pfs_type && vp->v_mount == mp) { - if (vget(vp, 0, p)) + if (vget(vp, 0, td)) goto loop; *vpp = vp; return (0); @@ -246,7 +246,7 @@ procfs_rw(ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct proc *curp = uio->uio_procp; + struct proc *curp = uio->uio_td->td_proc; struct pfsnode *pfs = VTOPFS(vp); struct proc *p; int rtval; diff --git a/sys/fs/procfs/procfs_type.c b/sys/fs/procfs/procfs_type.c index 3919c88..31cbcf0 100644 --- a/sys/fs/procfs/procfs_type.c +++ b/sys/fs/procfs/procfs_type.c @@ -78,8 +78,7 @@ procfs_dotype(curp, p, pfs, uio) } int -procfs_validtype(p) - struct proc *p; +procfs_validtype(struct thread *td) { - return ((p->p_flag & P_SYSTEM) == 0); + return ((td->td_proc->p_flag & P_SYSTEM) == 0); } diff --git a/sys/fs/procfs/procfs_vfsops.c b/sys/fs/procfs/procfs_vfsops.c index c0d7add..2442022 100644 --- a/sys/fs/procfs/procfs_vfsops.c +++ b/sys/fs/procfs/procfs_vfsops.c @@ -52,11 +52,11 @@ #include <fs/procfs/procfs.h> static int procfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int procfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); static int procfs_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); /* * VFS Operations. @@ -65,12 +65,12 @@ static int procfs_unmount __P((struct mount *mp, int mntflags, */ /* ARGSUSED */ static int -procfs_mount(mp, path, data, ndp, p) +procfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { size_t size; int error; @@ -90,7 +90,7 @@ procfs_mount(mp, path, data, ndp, p) size = sizeof("procfs") - 1; bcopy("procfs", mp->mnt_stat.f_mntfromname, size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)procfs_statfs(mp, &mp->mnt_stat, p); + (void)procfs_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -99,10 +99,10 @@ procfs_mount(mp, path, data, ndp, p) * unmount system call */ static int -procfs_unmount(mp, mntflags, p) +procfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error; int flags = 0; @@ -133,10 +133,10 @@ procfs_root(mp, vpp) * Get file system statistics. */ static int -procfs_statfs(mp, sbp, p) +procfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { sbp->f_bsize = PAGE_SIZE; sbp->f_iosize = PAGE_SIZE; diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c index 206f3e5..5367078 100644 --- a/sys/fs/procfs/procfs_vnops.c +++ b/sys/fs/procfs/procfs_vnops.c @@ -91,7 +91,7 @@ static struct proc_target { u_char pt_namlen; char *pt_name; pfstype pt_pfstype; - int (*pt_valid) __P((struct proc *p)); + int (*pt_valid) __P((struct thread *p)); } proc_targets[] = { #define N(s) sizeof(s)-1, s /* name type validp */ @@ -133,7 +133,7 @@ procfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); @@ -143,7 +143,7 @@ procfs_open(ap) p2 = PFIND(pfs->pfs_pid); if (p2 == NULL) return (ENOENT); - if (pfs->pfs_pid && p_cansee(ap->a_p, p2)) { + if (pfs->pfs_pid && p_cansee(ap->a_td->td_proc, p2)) { error = ENOENT; goto out; } @@ -156,7 +156,7 @@ procfs_open(ap) goto out; } - p1 = ap->a_p; + p1 = ap->a_td->td_proc; error = p_candebug(p1, p2); if (error) return (error); @@ -185,7 +185,7 @@ procfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); @@ -235,7 +235,7 @@ procfs_ioctl(ap) struct procfs_status *psp; unsigned char flags; - p = ap->a_p; + p = ap->a_td->td_proc; procp = pfind(pfs->pfs_pid); if (procp == NULL) { return ENOTTY; @@ -380,7 +380,7 @@ procfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); @@ -407,7 +407,7 @@ procfs_getattr(ap) return (ENOENT); } - if (p_cansee(ap->a_p, procp)) { + if (p_cansee(ap->a_td->td_proc, procp)) { PROC_UNLOCK(procp); return (ENOENT); } @@ -569,7 +569,7 @@ procfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -603,7 +603,7 @@ procfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); @@ -621,7 +621,7 @@ procfs_access(ap) procp = PFIND(pfs->pfs_pid); if (procp == NULL) return (ENOENT); - if (p_cansee(ap->a_p, procp)) { + if (p_cansee(ap->a_td->td_proc, procp)) { PROC_UNLOCK(procp); return (ENOENT); } @@ -629,7 +629,7 @@ procfs_access(ap) } vap = &vattr; - error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_td); if (error) return (error); @@ -658,12 +658,13 @@ procfs_lookup(ap) struct vnode **vpp = ap->a_vpp; struct vnode *dvp = ap->a_dvp; char *pname = cnp->cn_nameptr; - struct proc *curp = cnp->cn_proc; + struct proc *curp = cnp->cn_thread->td_proc; struct proc_target *pt; pid_t pid; struct pfsnode *pfs; struct proc *p; int i; + struct thread *td; *vpp = NULL; @@ -708,13 +709,14 @@ procfs_lookup(ap) return (procfs_root(dvp->v_mount, vpp)); p = PFIND(pfs->pfs_pid); + td = &p->p_thread; /* XXXKSE */ if (p == NULL) break; for (pt = proc_targets, i = 0; i < nproc_targets; pt++, i++) { if (cnp->cn_namelen == pt->pt_namlen && bcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 && - (pt->pt_valid == NULL || (*pt->pt_valid)(p))) + (pt->pt_valid == NULL || (*pt->pt_valid)(td))) goto found; } PROC_UNLOCK(p); @@ -735,11 +737,11 @@ procfs_lookup(ap) * Does this process have a text file? */ int -procfs_validfile(p) - struct proc *p; +procfs_validfile(td) + struct thread *td; { - return (procfs_findtextvp(p) != NULLVP); + return (procfs_findtextvp(td->td_proc) != NULLVP); } /* @@ -765,6 +767,7 @@ procfs_readdir(ap) struct pfsnode *pfs; int count, error, i, off; static u_int delen; + struct thread *td; if (!delen) { @@ -794,16 +797,17 @@ procfs_readdir(ap) struct proc_target *pt; p = PFIND(pfs->pfs_pid); + td = &p->p_thread; /* XXXKSE */ if (p == NULL) break; - if (p_cansee(curproc, p)) { + if (p_cansee(curthread->td_proc, p)) { PROC_UNLOCK(p); break; } for (pt = &proc_targets[i]; uio->uio_resid >= delen && i < nproc_targets; pt++, i++) { - if (pt->pt_valid && (*pt->pt_valid)(p) == 0) + if (pt->pt_valid && (*pt->pt_valid)(td) == 0) continue; dp->d_reclen = delen; @@ -864,11 +868,11 @@ procfs_readdir(ap) p = LIST_NEXT(p, p_list); if (p == NULL) goto done; - if (p_cansee(curproc, p)) + if (p_cansee(curthread->td_proc, p)) continue; pcnt++; } - while (p_cansee(curproc, p)) { + while (p_cansee(curthread->td_proc, p)) { p = LIST_NEXT(p, p_list); if (p == NULL) goto done; diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index e74c683..45117ac 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -51,7 +51,7 @@ SYSCTL_NODE(_vfs, OID_AUTO, pfs, CTLFLAG_RW, 0, */ int pfs_mount(struct pfs_info *pi, struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p) + struct nameidata *ndp, struct thread *td) { struct statfs *sbp; @@ -79,7 +79,7 @@ pfs_mount(struct pfs_info *pi, struct mount *mp, char *path, caddr_t data, * Unmount a pseudofs instance */ int -pfs_unmount(struct mount *mp, int mntflags, struct proc *p) +pfs_unmount(struct mount *mp, int mntflags, struct thread *td) { struct pfs_info *pi; int error; @@ -108,7 +108,7 @@ pfs_root(struct mount *mp, struct vnode **vpp) * Return filesystem stats */ int -pfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) +pfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { bcopy(&mp->mnt_stat, sbp, sizeof *sbp); return (0); diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h index cfe3d9e..474f442 100644 --- a/sys/fs/pseudofs/pseudofs.h +++ b/sys/fs/pseudofs/pseudofs.h @@ -56,7 +56,7 @@ struct pfs_node; struct pfs_bitmap; #define PFS_FILL_ARGS \ - struct proc *curp, struct proc *p, struct pfs_node *pn, struct sbuf *sb + struct thread *td, struct proc *p, struct pfs_node *pn, struct sbuf *sb #define PFS_FILL_PROTO(name) \ int name(PFS_FILL_ARGS); typedef int (*pfs_fill_t)(PFS_FILL_ARGS); @@ -122,12 +122,12 @@ struct pfs_node { */ int pfs_mount (struct pfs_info *pi, struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p); + struct nameidata *ndp, struct thread *td); int pfs_unmount (struct mount *mp, int mntflags, - struct proc *p); + struct thread *td); int pfs_root (struct mount *mp, struct vnode **vpp); int pfs_statfs (struct mount *mp, struct statfs *sbp, - struct proc *p); + struct thread *td); int pfs_init (struct pfs_info *pi, struct vfsconf *vfc); int pfs_uninit (struct pfs_info *pi, struct vfsconf *vfc); @@ -143,8 +143,8 @@ static struct pfs_info name##_info = { \ \ static int \ _##name##_mount(struct mount *mp, char *path, caddr_t data, \ - struct nameidata *ndp, struct proc *p) { \ - return pfs_mount(&name##_info, mp, path, data, ndp, p); \ + struct nameidata *ndp, struct thread *td) { \ + return pfs_mount(&name##_info, mp, path, data, ndp, td); \ } \ \ static int \ diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c index 465bfcd..3ff33d7 100644 --- a/sys/fs/pseudofs/pseudofs_vncache.c +++ b/sys/fs/pseudofs/pseudofs_vncache.c @@ -98,7 +98,7 @@ pfs_vncache_alloc(struct mount *mp, struct vnode **vpp, for (pv = pfs_vncache; pv; pv = pv->pv_next) { pvd = (struct pfs_vdata *)pv->pv_vnode->v_data; if (pvd->pvd_pn == pn && pvd->pvd_pid == pid) { - if (vget(pv->pv_vnode, 0, curproc) == 0) { + if (vget(pv->pv_vnode, 0, curthread) == 0) { ++pfs_vncache_hits; *vpp = pv->pv_vnode; mtx_unlock(&pfs_vncache_mutex); diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index ea26435..db62cbd 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -56,7 +56,7 @@ pfs_access(struct vop_access_args *va) struct vattr vattr; int error; - error = VOP_GETATTR(vn, &vattr, va->a_cred, va->a_p); + error = VOP_GETATTR(vn, &vattr, va->a_cred, va->a_td); if (error) return (error); error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid, @@ -230,7 +230,7 @@ pfs_read(struct vop_read_args *va) return (EIO); } - error = (pn->pn_func)(curproc, proc, pn, sb); + error = (pn->pn_func)(curthread, proc, pn, sb); if (proc != NULL) PRELE(proc); @@ -392,7 +392,7 @@ pfs_readlink(struct vop_readlink_args *va) /* sbuf_new() can't fail with a static buffer */ sbuf_new(&sb, buf, sizeof buf, 0); - error = (pn->pn_func)(curproc, proc, pn, &sb); + error = (pn->pn_func)(curthread, proc, pn, &sb); if (proc != NULL) PRELE(proc); diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index f2b1c34..0cdfd26 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -131,10 +131,10 @@ spec_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *vp = ap->a_vp; dev_t dev = vp->v_rdev; int error; @@ -191,9 +191,9 @@ spec_open(ap) if (dsw->d_flags & D_TTY) vp->v_flag |= VISTTY; - VOP_UNLOCK(vp, 0, p); - error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_UNLOCK(vp, 0, td); + error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, td); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error) return (error); @@ -238,7 +238,7 @@ spec_read(ap) } */ *ap; { struct vnode *vp; - struct proc *p; + struct thread *td; struct uio *uio; dev_t dev; int error, resid; @@ -246,15 +246,15 @@ spec_read(ap) vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; - p = uio->uio_procp; + td = uio->uio_td; resid = uio->uio_resid; if (resid == 0) return (0); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = (*devsw(dev)->d_read) (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (uio->uio_resid != resid || (error == 0 && resid != 0)) getnanotime(&dev->si_atime); return (error); @@ -274,7 +274,7 @@ spec_write(ap) } */ *ap; { struct vnode *vp; - struct proc *p; + struct thread *td; struct uio *uio; dev_t dev; int error, resid; @@ -282,12 +282,12 @@ spec_write(ap) vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; - p = uio->uio_procp; + td = uio->uio_td; resid = uio->uio_resid; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = (*devsw(dev)->d_write) (dev, uio, ap->a_ioflag); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (uio->uio_resid != resid || (error == 0 && resid != 0)) { getnanotime(&dev->si_ctime); dev->si_mtime = dev->si_ctime; @@ -307,14 +307,14 @@ spec_ioctl(ap) caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { dev_t dev; dev = ap->a_vp->v_rdev; return ((*devsw(dev)->d_ioctl)(dev, ap->a_command, - ap->a_data, ap->a_fflag, ap->a_p)); + ap->a_data, ap->a_fflag, ap->a_td)); } /* ARGSUSED */ @@ -324,13 +324,13 @@ spec_poll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { dev_t dev; dev = ap->a_vp->v_rdev; - return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_p); + return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_td); } /* ARGSUSED */ @@ -359,7 +359,7 @@ spec_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -563,11 +563,11 @@ spec_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; dev_t dev = vp->v_rdev; /* @@ -579,10 +579,10 @@ spec_close(ap) * if the reference count is 2 (this last descriptor * plus the session), release the reference from the session. */ - if (vcount(vp) == 2 && p && (vp->v_flag & VXLOCK) == 0 && - vp == p->p_session->s_ttyvp) { + if (vcount(vp) == 2 && td && (vp->v_flag & VXLOCK) == 0 && + vp == td->td_proc->p_session->s_ttyvp) { vrele(vp); - p->p_session->s_ttyvp = NULL; + td->td_proc->p_session->s_ttyvp = NULL; } /* * We do not want to really close the device if it @@ -600,7 +600,7 @@ spec_close(ap) } else if (vcount(vp) > 1) { return (0); } - return (devsw(dev)->d_close(dev, ap->a_fflag, S_IFCHR, p)); + return (devsw(dev)->d_close(dev, ap->a_fflag, S_IFCHR, td)); } /* @@ -716,7 +716,7 @@ spec_getpages(ap) bp->b_iodone = spec_getpages_iodone; /* B_PHYS is not set, but it is nice to fill this in. */ - bp->b_rcred = bp->b_wcred = curproc->p_ucred; + bp->b_rcred = bp->b_wcred = curthread->td_proc->p_ucred; if (bp->b_rcred != NOCRED) crhold(bp->b_rcred); if (bp->b_wcred != NOCRED) diff --git a/sys/fs/umapfs/umap_subr.c b/sys/fs/umapfs/umap_subr.c index afcaceb..c61fe7c 100644 --- a/sys/fs/umapfs/umap_subr.c +++ b/sys/fs/umapfs/umap_subr.c @@ -141,7 +141,7 @@ umap_node_find(mp, targetvp) struct mount *mp; struct vnode *targetvp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct umap_node_hashhead *hd; struct umap_node *a; struct vnode *vp; @@ -168,7 +168,7 @@ loop: * stuff, but we don't want to lock * the lower node. */ - if (vget(vp, 0, p)) { + if (vget(vp, 0, td)) { #ifdef DEBUG printf ("umap_node_find: vget failed.\n"); #endif diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c index 116ce16..a22b8df 100644 --- a/sys/fs/umapfs/umap_vfsops.c +++ b/sys/fs/umapfs/umap_vfsops.c @@ -62,35 +62,35 @@ static int umapfs_fhtovp __P((struct mount *mp, struct fid *fidp, static int umapfs_checkexp __P((struct mount *mp, struct sockaddr *nam, int *extflagsp, struct ucred **credanonp)); static int umapfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int umapfs_quotactl __P((struct mount *mp, int cmd, uid_t uid, - caddr_t arg, struct proc *p)); + caddr_t arg, struct thread *td)); static int umapfs_root __P((struct mount *mp, struct vnode **vpp)); -static int umapfs_start __P((struct mount *mp, int flags, struct proc *p)); +static int umapfs_start __P((struct mount *mp, int flags, struct thread *td)); static int umapfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); static int umapfs_sync __P((struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); static int umapfs_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); static int umapfs_vget __P((struct mount *mp, ino_t ino, struct vnode **vpp)); static int umapfs_vptofh __P((struct vnode *vp, struct fid *fhp)); static int umapfs_extattrctl __P((struct mount *mp, int cmd, struct vnode *filename_vp, int namespace, const char *attrname, - struct proc *p)); + struct thread *td)); /* * Mount umap layer */ static int -umapfs_mount(mp, path, data, ndp, p) +umapfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct umap_args args; struct vnode *lowerrootvp, *vp; @@ -105,7 +105,7 @@ umapfs_mount(mp, path, data, ndp, p) /* * Only for root */ - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); #ifdef DEBUG @@ -117,7 +117,7 @@ umapfs_mount(mp, path, data, ndp, p) */ if (mp->mnt_flag & MNT_UPDATE) { return (EOPNOTSUPP); - /* return (VFS_MOUNT(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, path, data, ndp, p));*/ + /* return (VFS_MOUNT(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, path, data, ndp, td));*/ } /* @@ -131,7 +131,7 @@ umapfs_mount(mp, path, data, ndp, p) * Find lower node */ NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT|LOCKLEAF, - UIO_USERSPACE, args.target, p); + UIO_USERSPACE, args.target, td); error = namei(ndp); if (error) return (error); @@ -209,7 +209,7 @@ umapfs_mount(mp, path, data, ndp, p) /* * Unlock the node (either the lower or the alias) */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * Make sure the node alias worked */ @@ -234,7 +234,7 @@ umapfs_mount(mp, path, data, ndp, p) (void) copyinstr(args.target, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)umapfs_statfs(mp, &mp->mnt_stat, p); + (void)umapfs_statfs(mp, &mp->mnt_stat, td); #ifdef DEBUG printf("umapfs_mount: lower %s, alias at %s\n", mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname); @@ -248,23 +248,23 @@ umapfs_mount(mp, path, data, ndp, p) * when that filesystem was mounted. */ static int -umapfs_start(mp, flags, p) +umapfs_start(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { return (0); - /* return (VFS_START(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, flags, p)); */ + /* return (VFS_START(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, flags, td)); */ } /* * Free reference to umap layer */ static int -umapfs_unmount(mp, mntflags, p) +umapfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error; int flags = 0; @@ -304,7 +304,7 @@ umapfs_root(mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; #ifdef DEBUG @@ -318,27 +318,27 @@ umapfs_root(mp, vpp) */ vp = MOUNTTOUMAPMOUNT(mp)->umapm_rootvp; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = vp; return (0); } static int -umapfs_quotactl(mp, cmd, uid, arg, p) +umapfs_quotactl(mp, cmd, uid, arg, td) struct mount *mp; int cmd; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { - return (VFS_QUOTACTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, uid, arg, p)); + return (VFS_QUOTACTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, uid, arg, td)); } static int -umapfs_statfs(mp, sbp, p) +umapfs_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { int error; struct statfs mstat; @@ -351,7 +351,7 @@ umapfs_statfs(mp, sbp, p) bzero(&mstat, sizeof(mstat)); - error = VFS_STATFS(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, &mstat, p); + error = VFS_STATFS(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, &mstat, td); if (error) return (error); @@ -374,11 +374,11 @@ umapfs_statfs(mp, sbp, p) } static int -umapfs_sync(mp, waitfor, cred, p) +umapfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { /* * XXX - Assumes no data cached at umap layer. @@ -427,16 +427,16 @@ umapfs_vptofh(vp, fhp) } static int -umapfs_extattrctl(mp, cmd, filename_vp, namespace, attrname, p) +umapfs_extattrctl(mp, cmd, filename_vp, namespace, attrname, td) struct mount *mp; int cmd; struct vnode *filename_vp; int namespace; const char *attrname; - struct proc *p; + struct thread *td; { return (VFS_EXTATTRCTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, - filename_vp, namespace, attrname, p)); + filename_vp, namespace, attrname, td)); } diff --git a/sys/fs/umapfs/umap_vnops.c b/sys/fs/umapfs/umap_vnops.c index b73ff2c..77a8a14 100644 --- a/sys/fs/umapfs/umap_vnops.c +++ b/sys/fs/umapfs/umap_vnops.c @@ -283,7 +283,7 @@ umap_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { short uid, gid; @@ -359,7 +359,7 @@ umap_lock(ap) struct vop_lock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -380,7 +380,7 @@ umap_unlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { vop_nounlock(ap); @@ -392,7 +392,7 @@ static int umap_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -405,8 +405,8 @@ umap_inactive(ap) * cache and reusable. * */ - VOP_INACTIVE(lowervp, ap->a_p); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + VOP_INACTIVE(lowervp, ap->a_td); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); return (0); } diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h index 63a881c..0caff1a 100644 --- a/sys/fs/unionfs/union.h +++ b/sys/fs/unionfs/union.h @@ -119,22 +119,22 @@ extern int union_allocvp __P((struct vnode **, struct mount *, struct componentname *, struct vnode *, struct vnode *, int)); extern int union_freevp __P((struct vnode *)); -extern struct vnode *union_dircache __P((struct vnode *, struct proc *)); +extern struct vnode *union_dircache __P((struct vnode *, struct thread *)); extern int union_copyup __P((struct union_node *, int, struct ucred *, - struct proc *)); + struct thread *)); extern int union_dowhiteout __P((struct union_node *, struct ucred *, - struct proc *)); + struct thread *)); extern int union_mkshadow __P((struct union_mount *, struct vnode *, struct componentname *, struct vnode **)); extern int union_mkwhiteout __P((struct union_mount *, struct vnode *, struct componentname *, char *)); extern int union_cn_close __P((struct vnode *, int, struct ucred *, - struct proc *)); + struct thread *)); extern void union_removed_upper __P((struct union_node *un)); extern struct vnode *union_lowervp __P((struct vnode *)); extern void union_newsize __P((struct vnode *, off_t, off_t)); -extern int (*union_dircheckp) __P((struct proc *, struct vnode **, +extern int (*union_dircheckp) __P((struct thread *, struct vnode **, struct file *)); #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 52a5483..5919672 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -89,11 +89,11 @@ static void union_updatevp __P((struct union_node *un, static void union_newlower __P((struct union_node *, struct vnode *)); static void union_newupper __P((struct union_node *, struct vnode *)); static int union_copyfile __P((struct vnode *, struct vnode *, - struct ucred *, struct proc *)); + struct ucred *, struct thread *)); static int union_vn_create __P((struct vnode **, struct union_node *, - struct proc *)); + struct thread *)); static int union_vn_close __P((struct vnode *, int, struct ucred *, - struct proc *)); + struct thread *)); int union_init() @@ -351,7 +351,7 @@ union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache) int error; struct union_node *un = 0; struct union_mount *um = MOUNTTOUNIONMOUNT(mp); - struct proc *p = (cnp) ? cnp->cn_proc : curproc; + struct thread *td = (cnp) ? cnp->cn_thread : curthread; int hash = 0; int vflag; int try; @@ -410,7 +410,7 @@ loop: un->un_uppervp == NULLVP) && (UNIONTOV(un)->v_mount == mp)) { if (vget(UNIONTOV(un), 0, - cnp ? cnp->cn_proc : NULL)) { + cnp ? cnp->cn_thread : NULL)) { union_list_unlock(hash); goto loop; } @@ -450,21 +450,21 @@ loop: * while moving up the tree). */ VREF(dvp); - VOP_UNLOCK(dvp, 0, p); - error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_UNLOCK(dvp, 0, td); + error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); vrele(dvp); } else { /* * our new un is under dvp */ - error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p); + error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td); } } else if (dvp == NULLVP) { /* * dvp is NULL, we need to lock un. */ - error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p); + error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td); } else { /* * dvp == un->un_vnode, we are already locked. @@ -573,7 +573,7 @@ loop: bzero(un, sizeof(*un)); lockinit(&un->un_lock, PVFS, "unlock", 0, 0); - vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td); un->un_vnode = *vpp; un->un_uppervp = uppervp; @@ -656,11 +656,11 @@ union_freevp(vp) * haven't been bumped at all. */ static int -union_copyfile(fvp, tvp, cred, p) +union_copyfile(fvp, tvp, cred, td) struct vnode *fvp; struct vnode *tvp; struct ucred *cred; - struct proc *p; + struct thread *td; { char *buf; struct uio uio; @@ -677,12 +677,12 @@ union_copyfile(fvp, tvp, cred, p) bzero(&uio, sizeof(uio)); - uio.uio_procp = p; + uio.uio_td = td; uio.uio_segflg = UIO_SYSSPACE; uio.uio_offset = 0; - VOP_LEASE(fvp, p, cred, LEASE_READ); - VOP_LEASE(tvp, p, cred, LEASE_WRITE); + VOP_LEASE(fvp, td, cred, LEASE_READ); + VOP_LEASE(tvp, td, cred, LEASE_WRITE); buf = malloc(MAXBSIZE, M_TEMP, M_WAITOK); @@ -743,11 +743,11 @@ union_copyfile(fvp, tvp, cred, p) */ int -union_copyup(un, docopy, cred, p) +union_copyup(un, docopy, cred, td) struct union_node *un; int docopy; struct ucred *cred; - struct proc *p; + struct thread *td; { int error; struct mount *mp; @@ -757,15 +757,15 @@ union_copyup(un, docopy, cred, p) * If the user does not have read permission, the vnode should not * be copied to upper layer. */ - vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p); - VOP_UNLOCK(un->un_lowervp, 0, p); + vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_ACCESS(un->un_lowervp, VREAD, cred, td); + VOP_UNLOCK(un->un_lowervp, 0, td); if (error) return (error); if ((error = vn_start_write(un->un_dirvp, &mp, V_WAIT | PCATCH)) != 0) return (error); - if ((error = union_vn_create(&uvp, un, p)) != 0) { + if ((error = union_vn_create(&uvp, un, td)) != 0) { vn_finished_write(mp); return (error); } @@ -778,24 +778,24 @@ union_copyup(un, docopy, cred, p) * XX - should not ignore errors * from VOP_CLOSE */ - vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(lvp, FREAD, cred, p); + vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(lvp, FREAD, cred, td); if (error == 0 && vn_canvmio(lvp) == TRUE) - error = vfs_object_create(lvp, p, cred); + error = vfs_object_create(lvp, td, cred); if (error == 0) { - error = union_copyfile(lvp, uvp, cred, p); - VOP_UNLOCK(lvp, 0, p); - (void) VOP_CLOSE(lvp, FREAD, cred, p); + error = union_copyfile(lvp, uvp, cred, td); + VOP_UNLOCK(lvp, 0, td); + (void) VOP_CLOSE(lvp, FREAD, cred, td); } if (error == 0) UDEBUG(("union: copied up %s\n", un->un_path)); } - VOP_UNLOCK(uvp, 0, p); + VOP_UNLOCK(uvp, 0, td); vn_finished_write(mp); union_newupper(un, uvp); KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount)); - union_vn_close(uvp, FWRITE, cred, p); + union_vn_close(uvp, FWRITE, cred, td); KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount)); /* * Subsequent IOs will go to the top layer, so @@ -809,12 +809,12 @@ union_copyup(un, docopy, cred, p) int i; for (i = 0; i < un->un_openl; i++) { - (void) VOP_CLOSE(lvp, FREAD, cred, p); - (void) VOP_OPEN(uvp, FREAD, cred, p); + (void) VOP_CLOSE(lvp, FREAD, cred, td); + (void) VOP_OPEN(uvp, FREAD, cred, td); } if (un->un_openl) { if (vn_canvmio(uvp) == TRUE) - error = vfs_object_create(uvp, p, cred); + error = vfs_object_create(uvp, td, cred); } un->un_openl = 0; } @@ -862,7 +862,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) cn->cn_nameiop = CREATE; cn->cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN); - cn->cn_proc = cnp->cn_proc; + cn->cn_thread = cnp->cn_thread; if (um->um_op == UNMNT_ABOVE) cn->cn_cred = cnp->cn_cred; else @@ -871,7 +871,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) cn->cn_consume = cnp->cn_consume; VREF(dvp); - VOP_UNLOCK(dvp, 0, cnp->cn_proc); + VOP_UNLOCK(dvp, 0, cnp->cn_thread); /* * Pass dvp unlocked and referenced on call to relookup(). @@ -880,7 +880,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) */ if ((error = relookup(dvp, vpp, cn)) != 0) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread); return(error); } @@ -916,7 +916,7 @@ union_mkshadow(um, dvp, cnp, vpp) { int error; struct vattr va; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct componentname cn; struct mount *mp; @@ -955,7 +955,7 @@ union_mkshadow(um, dvp, cnp, vpp) va.va_mode = um->um_cmode; /* VOP_LEASE: dvp is locked */ - VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE); + VOP_LEASE(dvp, td, cn.cn_cred, LEASE_WRITE); error = VOP_MKDIR(dvp, vpp, &cn, &va); if (cn.cn_flags & HASBUF) { @@ -984,7 +984,7 @@ union_mkwhiteout(um, dvp, cnp, path) char *path; { int error; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *wvp; struct componentname cn; struct mount *mp; @@ -1011,7 +1011,7 @@ union_mkwhiteout(um, dvp, cnp, path) } /* VOP_LEASE: dvp is locked */ - VOP_LEASE(dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_WHITEOUT(dvp, &cn, CREATE); if (cn.cn_flags & HASBUF) { @@ -1037,18 +1037,18 @@ union_mkwhiteout(um, dvp, cnp, path) * use. If an error occurs *vpp iis undefined. */ static int -union_vn_create(vpp, un, p) +union_vn_create(vpp, un, td) struct vnode **vpp; struct union_node *un; - struct proc *p; + struct thread *td; { struct vnode *vp; - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; struct vattr vat; struct vattr *vap = &vat; int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL); int error; - int cmode = UN_FILEMODE & ~p->p_fd->fd_cmask; + int cmode = UN_FILEMODE & ~td->td_proc->p_fd->fd_cmask; struct componentname cn; *vpp = NULLVP; @@ -1067,8 +1067,8 @@ union_vn_create(vpp, un, p) bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1); cn.cn_nameiop = CREATE; cn.cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN); - cn.cn_proc = p; - cn.cn_cred = p->p_ucred; + cn.cn_thread = td; + cn.cn_cred = td->td_proc->p_ucred; cn.cn_nameptr = cn.cn_pnbuf; cn.cn_consume = 0; @@ -1112,7 +1112,7 @@ union_vn_create(vpp, un, p) VATTR_NULL(vap); vap->va_type = VREG; vap->va_mode = cmode; - VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE); + VOP_LEASE(un->un_dirvp, td, cred, LEASE_WRITE); error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap); if (cn.cn_flags & HASBUF) { zfree(namei_zone, cn.cn_pnbuf); @@ -1122,9 +1122,9 @@ union_vn_create(vpp, un, p) if (error) return (error); - error = VOP_OPEN(vp, fmode, cred, p); + error = VOP_OPEN(vp, fmode, cred, td); if (error == 0 && vn_canvmio(vp) == TRUE) - error = vfs_object_create(vp, p, cred); + error = vfs_object_create(vp, td, cred); if (error) { vput(vp); return (error); @@ -1135,16 +1135,16 @@ union_vn_create(vpp, un, p) } static int -union_vn_close(vp, fmode, cred, p) +union_vn_close(vp, fmode, cred, td) struct vnode *vp; int fmode; struct ucred *cred; - struct proc *p; + struct thread *td; { if (fmode & FWRITE) --vp->v_writecount; - return (VOP_CLOSE(vp, fmode, cred, p)); + return (VOP_CLOSE(vp, fmode, cred, td)); } #if 0 @@ -1159,7 +1159,7 @@ void union_removed_upper(un) struct union_node *un; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode **vpp; /* @@ -1188,17 +1188,17 @@ union_removed_upper(un) * during a remove/rmdir operation. */ int -union_dowhiteout(un, cred, p) +union_dowhiteout(un, cred, td) struct union_node *un; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vattr va; if (un->un_lowervp != NULLVP) return (1); - if (VOP_GETATTR(un->un_uppervp, &va, cred, p) == 0 && + if (VOP_GETATTR(un->un_uppervp, &va, cred, td) == 0 && (va.va_flags & OPAQUE)) return (1); @@ -1234,9 +1234,9 @@ union_dircache_r(vp, vppp, cntp) } struct vnode * -union_dircache(vp, p) +union_dircache(vp, td) struct vnode *vp; - struct proc *p; + struct thread *td; { int cnt; struct vnode *nvp; @@ -1245,7 +1245,7 @@ union_dircache(vp, p) struct union_node *un; int error; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); dircache = VTOUNION(vp)->un_dircache; nvp = NULLVP; @@ -1271,7 +1271,7 @@ union_dircache(vp, p) if (*vpp == NULLVP) goto out; - /*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);*/ + /*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);*/ UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? (*vpp)->v_usecount : -99))); VREF(*vpp); error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0); @@ -1284,7 +1284,7 @@ union_dircache(vp, p) un->un_dircache = dircache; out: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (nvp); } @@ -1292,14 +1292,14 @@ out: * Module glue to remove #ifdef UNION from vfs_syscalls.c */ static int -union_dircheck(struct proc *p, struct vnode **vp, struct file *fp) +union_dircheck(struct thread *td, struct vnode **vp, struct file *fp) { int error = 0; if ((*vp)->v_op == union_vnodeop_p) { struct vnode *lvp; - lvp = union_dircache(*vp, p); + lvp = union_dircache(*vp, td); if (lvp != NULLVP) { struct vattr va; @@ -1307,7 +1307,7 @@ union_dircheck(struct proc *p, struct vnode **vp, struct file *fp) * If the directory is opaque, * then don't show lower entries */ - error = VOP_GETATTR(*vp, &va, fp->f_cred, p); + error = VOP_GETATTR(*vp, &va, fp->f_cred, td); if (va.va_flags & OPAQUE) { vput(lvp); lvp = NULL; @@ -1315,17 +1315,17 @@ union_dircheck(struct proc *p, struct vnode **vp, struct file *fp) } if (lvp != NULLVP) { - error = VOP_OPEN(lvp, FREAD, fp->f_cred, p); + error = VOP_OPEN(lvp, FREAD, fp->f_cred, td); if (error == 0 && vn_canvmio(lvp) == TRUE) - error = vfs_object_create(lvp, p, fp->f_cred); + error = vfs_object_create(lvp, td, fp->f_cred); if (error) { vput(lvp); return (error); } - VOP_UNLOCK(lvp, 0, p); + VOP_UNLOCK(lvp, 0, td); fp->f_data = (caddr_t) lvp; fp->f_offset = 0; - error = vn_close(*vp, FREAD, fp->f_cred, p); + error = vn_close(*vp, FREAD, fp->f_cred, td); if (error) return (error); *vp = lvp; diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index aa4986c..7f616cb 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -59,23 +59,23 @@ static MALLOC_DEFINE(M_UNIONFSMNT, "UNION mount", "UNION mount structure"); extern int union_init __P((struct vfsconf *)); static int union_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int union_root __P((struct mount *mp, struct vnode **vpp)); static int union_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); static int union_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); /* * Mount union filesystem */ static int -union_mount(mp, path, data, ndp, p) +union_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error = 0; struct union_args args; @@ -127,7 +127,7 @@ union_mount(mp, path, data, ndp, p) * Unlock lower node to avoid deadlock. */ if (lowerrootvp->v_op == union_vnodeop_p) - VOP_UNLOCK(lowerrootvp, 0, p); + VOP_UNLOCK(lowerrootvp, 0, td); #endif /* @@ -135,13 +135,13 @@ union_mount(mp, path, data, ndp, p) * upperrootvp will be turned referenced but not locked. */ NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT, - UIO_USERSPACE, args.target, p); + UIO_USERSPACE, args.target, td); error = namei(ndp); #if 0 if (lowerrootvp->v_op == union_vnodeop_p) - vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY, td); #endif if (error) goto bad; @@ -223,9 +223,9 @@ union_mount(mp, path, data, ndp, p) goto bad; } - um->um_cred = p->p_ucred; + um->um_cred = td->td_proc->p_ucred; crhold(um->um_cred); - um->um_cmode = UN_DIRMODE &~ p->p_fd->fd_cmask; + um->um_cmode = UN_DIRMODE &~ td->td_proc->p_fd->fd_cmask; /* * Depending on what you think the MNT_LOCAL flag might mean, @@ -275,7 +275,7 @@ union_mount(mp, path, data, ndp, p) (void) copyinstr(args.target, cp, len - 1, &size); bzero(cp + size, len - size); - (void)union_statfs(mp, &mp->mnt_stat, p); + (void)union_statfs(mp, &mp->mnt_stat, td); UDEBUG(("union_mount: from %s, on %s\n", mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname)); @@ -303,10 +303,10 @@ bad: * Free reference to union layer */ static int -union_unmount(mp, mntflags, p) +union_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { struct union_mount *um = MOUNTTOUNIONMOUNT(mp); int error; @@ -396,10 +396,10 @@ union_root(mp, vpp) } static int -union_statfs(mp, sbp, p) +union_statfs(mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { int error; struct union_mount *um = MOUNTTOUNIONMOUNT(mp); @@ -412,7 +412,7 @@ union_statfs(mp, sbp, p) bzero(&mstat, sizeof(mstat)); if (um->um_lowervp) { - error = VFS_STATFS(um->um_lowervp->v_mount, &mstat, p); + error = VFS_STATFS(um->um_lowervp->v_mount, &mstat, td); if (error) return (error); } @@ -431,7 +431,7 @@ union_statfs(mp, sbp, p) sbp->f_files = mstat.f_files; sbp->f_ffree = mstat.f_ffree; - error = VFS_STATFS(um->um_uppervp->v_mount, &mstat, p); + error = VFS_STATFS(um->um_uppervp->v_mount, &mstat, td); if (error) return (error); diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index b5abfa7..aca606b 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -109,13 +109,13 @@ static int union_write __P((struct vop_read_args *ap)); static __inline struct vnode * -union_lock_upper(struct union_node *un, struct proc *p) +union_lock_upper(struct union_node *un, struct thread *td) { struct vnode *uppervp; if ((uppervp = un->un_uppervp) != NULL) { VREF(uppervp); - vn_lock(uppervp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, p); + vn_lock(uppervp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, td); } KASSERT((uppervp == NULL || uppervp->v_usecount > 0), ("uppervp usecount is 0")); return(uppervp); @@ -123,29 +123,29 @@ union_lock_upper(struct union_node *un, struct proc *p) static __inline void -union_unlock_upper(struct vnode *uppervp, struct proc *p) +union_unlock_upper(struct vnode *uppervp, struct thread *td) { vput(uppervp); } static __inline struct vnode * -union_lock_other(struct union_node *un, struct proc *p) +union_lock_other(struct union_node *un, struct thread *td) { struct vnode *vp; if (un->un_uppervp != NULL) { - vp = union_lock_upper(un, p); + vp = union_lock_upper(un, td); } else if ((vp = un->un_lowervp) != NULL) { VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, td); } return(vp); } static __inline void -union_unlock_other(struct vnode *vp, struct proc *p) +union_unlock_other(struct vnode *vp, struct thread *td) { vput(vp); } @@ -178,7 +178,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) struct componentname *cnp; { int error; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *dvp = *pdvp; struct vnode *tdvp; struct mount *mp; @@ -201,7 +201,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) dvp = dvp->v_mount->mnt_vnodecovered; VREF(dvp); vput(tdvp); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); } } @@ -232,7 +232,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) UDEBUG(("parentdir %p result %p flag %lx\n", dvp, tdvp, cnp->cn_flags)); if (dvp != tdvp && (cnp->cn_flags & ISLASTCN) == 0) - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); /* * Lastly check if the current node is a mount point in @@ -252,7 +252,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) ) { int relock_pdvp = 0; - if (vfs_busy(mp, 0, 0, p)) + if (vfs_busy(mp, 0, 0, td)) continue; if (dvp == *pdvp) @@ -261,10 +261,10 @@ union_lookup1(udvp, pdvp, vpp, cnp) dvp = NULL; error = VFS_ROOT(mp, &dvp); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); if (relock_pdvp) - vn_lock(*pdvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(*pdvp, LK_EXCLUSIVE | LK_RETRY, td); if (error) { *vpp = NULL; @@ -291,7 +291,7 @@ union_lookup(ap) struct vnode *dvp = ap->a_dvp; /* starting dir */ struct union_node *dun = VTOUNION(dvp); /* associated union node */ struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int lockparent = cnp->cn_flags & LOCKPARENT; struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount); struct ucred *saved_cred = NULL; @@ -329,7 +329,7 @@ union_lookup(ap) * We must lock upperdvp while holding our lock on dvp * to avoid a deadlock. */ - upperdvp = union_lock_upper(dun, p); + upperdvp = union_lock_upper(dun, td); /* * do the lookup in the upper level. @@ -403,7 +403,7 @@ union_lookup(ap) int terror; terror = VOP_GETATTR(upperdvp, &va, - cnp->cn_cred, cnp->cn_proc); + cnp->cn_cred, cnp->cn_thread); if (terror == 0 && (va.va_flags & OPAQUE)) iswhiteout = 1; } @@ -446,7 +446,7 @@ union_lookup(ap) * to us so we NULL it out. */ VREF(lowerdvp); - vn_lock(lowerdvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(lowerdvp, LK_EXCLUSIVE | LK_RETRY, td); lerror = union_lookup1(um->um_lowervp, &lowerdvp, &lowervp, cnp); if (lowerdvp == lowervp) vrele(lowerdvp); @@ -470,7 +470,7 @@ union_lookup(ap) if ((cnp->cn_flags & ISDOTDOT) && dun->un_pvp != NULLVP) { if ((lowervp = LOWERVP(dun->un_pvp)) != NULL) { VREF(lowervp); - vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY, td); lerror = 0; } } @@ -533,11 +533,11 @@ union_lookup(ap) */ if (uppervp && uppervp != upperdvp) - VOP_UNLOCK(uppervp, 0, p); + VOP_UNLOCK(uppervp, 0, td); if (lowervp) - VOP_UNLOCK(lowervp, 0, p); + VOP_UNLOCK(lowervp, 0, td); if (upperdvp) - VOP_UNLOCK(upperdvp, 0, p); + VOP_UNLOCK(upperdvp, 0, td); error = union_allocvp(ap->a_vpp, dvp->v_mount, dvp, upperdvp, cnp, uppervp, lowervp, 1); @@ -600,7 +600,7 @@ out: if (*ap->a_vpp != dvp) { if ((error == 0 || error == EJUSTRETURN) && (!lockparent || (cnp->cn_flags & ISLASTCN) == 0)) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } } @@ -637,24 +637,24 @@ union_create(ap) { struct union_node *dun = VTOUNION(ap->a_dvp); struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *dvp; int error = EROFS; - if ((dvp = union_lock_upper(dun, p)) != NULL) { + if ((dvp = union_lock_upper(dun, td)) != NULL) { struct vnode *vp; struct mount *mp; error = VOP_CREATE(dvp, &vp, cnp, ap->a_vap); if (error == 0) { mp = ap->a_dvp->v_mount; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); UDEBUG(("ALLOCVP-1 FROM %p REFS %d\n", vp, vp->v_usecount)); error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP, cnp, vp, NULLVP, 1); UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vp->v_usecount)); } - union_unlock_upper(dvp, p); + union_unlock_upper(dvp, td); } return (error); } @@ -672,9 +672,9 @@ union_whiteout(ap) struct vnode *uppervp; int error = EOPNOTSUPP; - if ((uppervp = union_lock_upper(un, cnp->cn_proc)) != NULLVP) { + if ((uppervp = union_lock_upper(un, cnp->cn_thread)) != NULLVP) { error = VOP_WHITEOUT(un->un_uppervp, cnp, ap->a_flags); - union_unlock_upper(uppervp, cnp->cn_proc); + union_unlock_upper(uppervp, cnp->cn_thread); } return(error); } @@ -700,9 +700,9 @@ union_mknod(ap) struct vnode *dvp; int error = EROFS; - if ((dvp = union_lock_upper(dun, cnp->cn_proc)) != NULL) { + if ((dvp = union_lock_upper(dun, cnp->cn_thread)) != NULL) { error = VOP_MKNOD(dvp, ap->a_vpp, cnp, ap->a_vap); - union_unlock_upper(dvp, cnp->cn_proc); + union_unlock_upper(dvp, cnp->cn_thread); } return (error); } @@ -723,14 +723,14 @@ union_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); struct vnode *tvp; int mode = ap->a_mode; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int error = 0; int tvpisupper = 1; @@ -742,7 +742,7 @@ union_open(ap) * * At the end of this section tvp will be left locked. */ - if ((tvp = union_lock_upper(un, p)) == NULLVP) { + if ((tvp = union_lock_upper(un, td)) == NULLVP) { /* * If the lower vnode is being opened for writing, then * copy the file contents to the upper vnode and open that, @@ -751,12 +751,12 @@ union_open(ap) tvp = un->un_lowervp; if ((ap->a_mode & FWRITE) && (tvp->v_type == VREG)) { int docopy = !(mode & O_TRUNC); - error = union_copyup(un, docopy, cred, p); - tvp = union_lock_upper(un, p); + error = union_copyup(un, docopy, cred, td); + tvp = union_lock_upper(un, td); } else { un->un_openl++; VREF(tvp); - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, td); tvpisupper = 0; } } @@ -766,13 +766,13 @@ union_open(ap) */ if (error == 0) - error = VOP_OPEN(tvp, mode, cred, p); + error = VOP_OPEN(tvp, mode, cred, td); /* * Absolutely necessary or UFS will blowup */ if (error == 0 && vn_canvmio(tvp) == TRUE) { - error = vfs_object_create(tvp, p, cred); + error = vfs_object_create(tvp, td, cred); } /* @@ -780,7 +780,7 @@ union_open(ap) */ if (tvpisupper) { if (tvp) - union_unlock_upper(tvp, p); + union_unlock_upper(tvp, td); } else { vput(tvp); } @@ -800,7 +800,7 @@ union_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); @@ -833,11 +833,11 @@ union_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int error = EACCES; struct vnode *vp; @@ -856,15 +856,15 @@ union_access(ap) } } - if ((vp = union_lock_upper(un, p)) != NULLVP) { + if ((vp = union_lock_upper(un, td)) != NULLVP) { ap->a_vp = vp; error = VCALL(vp, VOFFSET(vop_access), ap); - union_unlock_upper(vp, p); + union_unlock_upper(vp, td); return(error); } if ((vp = un->un_lowervp) != NULLVP) { - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); ap->a_vp = vp; /* @@ -885,7 +885,7 @@ union_access(ap) error = VCALL(vp, VOFFSET(vop_access), ap); } } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } return(error); } @@ -912,7 +912,7 @@ union_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { int error; @@ -933,7 +933,7 @@ union_getattr(ap) vap = ap->a_vap; if ((vp = un->un_uppervp) != NULLVP) { - error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_td); if (error) return (error); /* XXX isn't this dangerouso without a lock? */ @@ -950,7 +950,7 @@ union_getattr(ap) } if (vp != NULLVP) { - error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_td); if (error) return (error); /* XXX isn't this dangerous without a lock? */ @@ -968,11 +968,11 @@ union_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vattr *vap = ap->a_vap; struct vnode *uppervp; int error; @@ -995,7 +995,7 @@ union_setattr(ap) */ if (un->un_uppervp == NULLVP && (un->un_lowervp->v_type == VREG)) { error = union_copyup(un, (ap->a_vap->va_size != 0), - ap->a_cred, ap->a_p); + ap->a_cred, ap->a_td); if (error) return (error); } @@ -1005,12 +1005,12 @@ union_setattr(ap) * otherwise return read-only filesystem error. */ error = EROFS; - if ((uppervp = union_lock_upper(un, p)) != NULLVP) { + if ((uppervp = union_lock_upper(un, td)) != NULLVP) { error = VOP_SETATTR(un->un_uppervp, ap->a_vap, - ap->a_cred, ap->a_p); + ap->a_cred, ap->a_td); if ((error == 0) && (ap->a_vap->va_size != VNOVAL)) union_newsize(ap->a_vp, ap->a_vap->va_size, VNOVAL); - union_unlock_upper(uppervp, p); + union_unlock_upper(uppervp, td); } return (error); } @@ -1025,15 +1025,15 @@ union_read(ap) } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; struct vnode *uvp; int error; - uvp = union_lock_other(un, p); + uvp = union_lock_other(un, td); KASSERT(uvp != NULL, ("union_read: backing vnode missing!")); error = VOP_READ(uvp, ap->a_uio, ap->a_ioflag, ap->a_cred); - union_unlock_other(uvp, p); + union_unlock_other(uvp, td); /* * XXX @@ -1066,11 +1066,11 @@ union_write(ap) } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; struct vnode *uppervp; int error; - if ((uppervp = union_lock_upper(un, p)) == NULLVP) + if ((uppervp = union_lock_upper(un, td)) == NULLVP) panic("union: missing upper layer in write"); error = VOP_WRITE(uppervp, ap->a_uio, ap->a_ioflag, ap->a_cred); @@ -1085,7 +1085,7 @@ union_write(ap) if (cur > un->un_uppersz) union_newsize(ap->a_vp, cur, VNOVAL); } - union_unlock_upper(uppervp, p); + union_unlock_upper(uppervp, td); return (error); } @@ -1093,7 +1093,7 @@ static int union_lease(ap) struct vop_lease_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; struct ucred *a_cred; int a_flag; } */ *ap; @@ -1112,7 +1112,7 @@ union_ioctl(ap) caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *ovp = OTHERVP(ap->a_vp); @@ -1127,7 +1127,7 @@ union_poll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *ovp = OTHERVP(ap->a_vp); @@ -1141,7 +1141,7 @@ union_revoke(ap) struct vop_revoke_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -1160,17 +1160,17 @@ union_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { int error = 0; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *targetvp; struct union_node *un = VTOUNION(ap->a_vp); - if ((targetvp = union_lock_other(un, p)) != NULLVP) { - error = VOP_FSYNC(targetvp, ap->a_cred, ap->a_waitfor, p); - union_unlock_other(targetvp, p); + if ((targetvp = union_lock_other(un, td)) != NULLVP) { + error = VOP_FSYNC(targetvp, ap->a_cred, ap->a_waitfor, td); + union_unlock_other(targetvp, td); } return (error); @@ -1194,16 +1194,16 @@ union_remove(ap) struct union_node *dun = VTOUNION(ap->a_dvp); struct union_node *un = VTOUNION(ap->a_vp); struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *uppervp; struct vnode *upperdvp; int error; - if ((upperdvp = union_lock_upper(dun, p)) == NULLVP) + if ((upperdvp = union_lock_upper(dun, td)) == NULLVP) panic("union remove: null upper vnode"); - if ((uppervp = union_lock_upper(un, p)) != NULLVP) { - if (union_dowhiteout(un, cnp->cn_cred, p)) + if ((uppervp = union_lock_upper(un, td)) != NULLVP) { + if (union_dowhiteout(un, cnp->cn_cred, td)) cnp->cn_flags |= DOWHITEOUT; error = VOP_REMOVE(upperdvp, uppervp, cnp); #if 0 @@ -1211,13 +1211,13 @@ union_remove(ap) if (!error) union_removed_upper(un); #endif - union_unlock_upper(uppervp, p); + union_unlock_upper(uppervp, td); } else { error = union_mkwhiteout( MOUNTTOUNIONMOUNT(ap->a_dvp->v_mount), upperdvp, ap->a_cnp, un->un_path); } - union_unlock_upper(upperdvp, p); + union_unlock_upper(upperdvp, td); return (error); } @@ -1238,7 +1238,7 @@ union_link(ap) } */ *ap; { struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct union_node *dun = VTOUNION(ap->a_tdvp); struct vnode *vp; struct vnode *tdvp; @@ -1250,24 +1250,24 @@ union_link(ap) struct union_node *tun = VTOUNION(ap->a_vp); if (tun->un_uppervp == NULLVP) { - vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); #if 0 if (dun->un_uppervp == tun->un_dirvp) { if (dun->un_flags & UN_ULOCK) { dun->un_flags &= ~UN_ULOCK; - VOP_UNLOCK(dun->un_uppervp, 0, p); + VOP_UNLOCK(dun->un_uppervp, 0, td); } } #endif - error = union_copyup(tun, 1, cnp->cn_cred, p); + error = union_copyup(tun, 1, cnp->cn_cred, td); #if 0 if (dun->un_uppervp == tun->un_dirvp) { vn_lock(dun->un_uppervp, - LK_EXCLUSIVE | LK_RETRY, p); + LK_EXCLUSIVE | LK_RETRY, td); dun->un_flags |= UN_ULOCK; } #endif - VOP_UNLOCK(ap->a_vp, 0, p); + VOP_UNLOCK(ap->a_vp, 0, td); } vp = tun->un_uppervp; } @@ -1282,18 +1282,18 @@ union_link(ap) * is expected to be locked on return. */ - if ((tdvp = union_lock_upper(dun, p)) == NULLVP) + if ((tdvp = union_lock_upper(dun, td)) == NULLVP) return (EROFS); - VOP_UNLOCK(ap->a_tdvp, 0, p); /* unlock calling node */ + VOP_UNLOCK(ap->a_tdvp, 0, td); /* unlock calling node */ error = VOP_LINK(tdvp, vp, cnp); /* call link on upper */ /* * We have to unlock tdvp prior to relocking our calling node in * order to avoid a deadlock. */ - union_unlock_upper(tdvp, p); - vn_lock(ap->a_tdvp, LK_EXCLUSIVE | LK_RETRY, p); + union_unlock_upper(tdvp, td); + vn_lock(ap->a_tdvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } @@ -1350,9 +1350,9 @@ union_rename(ap) if (un->un_uppervp == NULLVP) { switch(fvp->v_type) { case VREG: - vn_lock(un->un_vnode, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_proc); - error = union_copyup(un, 1, ap->a_fcnp->cn_cred, ap->a_fcnp->cn_proc); - VOP_UNLOCK(un->un_vnode, 0, ap->a_fcnp->cn_proc); + vn_lock(un->un_vnode, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_thread); + error = union_copyup(un, 1, ap->a_fcnp->cn_cred, ap->a_fcnp->cn_thread); + VOP_UNLOCK(un->un_vnode, 0, ap->a_fcnp->cn_thread); if (error) goto bad; break; @@ -1368,12 +1368,12 @@ union_rename(ap) #if 0 vrele(fvp); fvp = NULL; - vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_proc); + vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_thread); error = union_mkshadow(um, fdvp, ap->a_fcnp, &un->un_uppervp); - VOP_UNLOCK(fdvp, 0, ap->a_fcnp->cn_proc); + VOP_UNLOCK(fdvp, 0, ap->a_fcnp->cn_thread); if (un->un_uppervp) - VOP_UNLOCK(un->un_uppervp, 0, ap->a_fcnp->cn_proc); + VOP_UNLOCK(un->un_uppervp, 0, ap->a_fcnp->cn_thread); if (error) goto bad; break; @@ -1417,7 +1417,7 @@ union_rename(ap) * new tdvp is a lock and reference on uppervp, put away * the old tdvp. */ - tdvp = union_lock_upper(un, ap->a_tcnp->cn_proc); + tdvp = union_lock_upper(un, ap->a_tcnp->cn_thread); vput(ap->a_tdvp); } @@ -1432,7 +1432,7 @@ union_rename(ap) if (tvp != NULLVP && tvp->v_op == union_vnodeop_p) { struct union_node *un = VTOUNION(tvp); - tvp = union_lock_upper(un, ap->a_tcnp->cn_proc); + tvp = union_lock_upper(un, ap->a_tcnp->cn_thread); vput(ap->a_tvp); /* note: tvp may be NULL */ } @@ -1473,18 +1473,18 @@ union_mkdir(ap) { struct union_node *dun = VTOUNION(ap->a_dvp); struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *upperdvp; int error = EROFS; - if ((upperdvp = union_lock_upper(dun, p)) != NULLVP) { + if ((upperdvp = union_lock_upper(dun, td)) != NULLVP) { struct vnode *vp; error = VOP_MKDIR(upperdvp, &vp, cnp, ap->a_vap); - union_unlock_upper(upperdvp, p); + union_unlock_upper(upperdvp, td); if (error == 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); UDEBUG(("ALLOCVP-2 FROM %p REFS %d\n", vp, vp->v_usecount)); error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount, ap->a_dvp, NULLVP, cnp, vp, NULLVP, 1); @@ -1505,25 +1505,25 @@ union_rmdir(ap) struct union_node *dun = VTOUNION(ap->a_dvp); struct union_node *un = VTOUNION(ap->a_vp); struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *upperdvp; struct vnode *uppervp; int error; - if ((upperdvp = union_lock_upper(dun, p)) == NULLVP) + if ((upperdvp = union_lock_upper(dun, td)) == NULLVP) panic("union rmdir: null upper vnode"); - if ((uppervp = union_lock_upper(un, p)) != NULLVP) { - if (union_dowhiteout(un, cnp->cn_cred, p)) + if ((uppervp = union_lock_upper(un, td)) != NULLVP) { + if (union_dowhiteout(un, cnp->cn_cred, td)) cnp->cn_flags |= DOWHITEOUT; error = VOP_RMDIR(upperdvp, uppervp, ap->a_cnp); - union_unlock_upper(uppervp, p); + union_unlock_upper(uppervp, td); } else { error = union_mkwhiteout( MOUNTTOUNIONMOUNT(ap->a_dvp->v_mount), dun->un_uppervp, ap->a_cnp, un->un_path); } - union_unlock_upper(upperdvp, p); + union_unlock_upper(upperdvp, td); return (error); } @@ -1546,14 +1546,14 @@ union_symlink(ap) { struct union_node *dun = VTOUNION(ap->a_dvp); struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *dvp; int error = EROFS; - if ((dvp = union_lock_upper(dun, p)) != NULLVP) { + if ((dvp = union_lock_upper(dun, td)) != NULLVP) { error = VOP_SYMLINK(dvp, ap->a_vpp, cnp, ap->a_vap, ap->a_target); - union_unlock_upper(dvp, p); + union_unlock_upper(dvp, td); } return (error); } @@ -1577,14 +1577,14 @@ union_readdir(ap) } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); - struct proc *p = ap->a_uio->uio_procp; + struct thread *td = ap->a_uio->uio_td; struct vnode *uvp; int error = 0; - if ((uvp = union_lock_upper(un, p)) != NULLVP) { + if ((uvp = union_lock_upper(un, td)) != NULLVP) { ap->a_vp = uvp; error = VCALL(uvp, VOFFSET(vop_readdir), ap); - union_unlock_upper(uvp, p); + union_unlock_upper(uvp, td); } return(error); } @@ -1600,15 +1600,15 @@ union_readlink(ap) int error; struct union_node *un = VTOUNION(ap->a_vp); struct uio *uio = ap->a_uio; - struct proc *p = uio->uio_procp; + struct thread *td = uio->uio_td; struct vnode *vp; - vp = union_lock_other(un, p); + vp = union_lock_other(un, td); KASSERT(vp != NULL, ("union_readlink: backing vnode missing!")); ap->a_vp = vp; error = VCALL(vp, VOFFSET(vop_readlink), ap); - union_unlock_other(vp, p); + union_unlock_other(vp, td); return (error); } @@ -1645,11 +1645,11 @@ static int union_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct union_node *un = VTOUNION(vp); struct vnode **vpp; @@ -1676,11 +1676,11 @@ union_inactive(ap) #if 0 if ((un->un_flags & UN_ULOCK) && un->un_uppervp) { un->un_flags &= ~UN_ULOCK; - VOP_UNLOCK(un->un_uppervp, 0, p); + VOP_UNLOCK(un->un_uppervp, 0, td); } #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((un->un_flags & UN_CACHED) == 0) vgone(vp); @@ -1705,7 +1705,7 @@ union_lock(ap) { #if 0 struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int flags = ap->a_flags; struct union_node *un; #endif @@ -1723,12 +1723,12 @@ union_lock(ap) if (un->un_uppervp != NULLVP && (flags & LK_TYPE_MASK) == LK_EXCLUSIVE) { if ((un->un_flags & UN_ULOCK) == 0 && vp->v_usecount) { - error = vn_lock(un->un_uppervp, flags, p); + error = vn_lock(un->un_uppervp, flags, td); if (error) { struct vop_unlock_args uap = { 0 }; uap.a_vp = ap->a_vp; uap.a_flags = ap->a_flags; - uap.a_p = ap->a_p; + uap.a_td = ap->a_td; vop_stdunlock(&uap); return (error); } @@ -1750,7 +1750,7 @@ union_unlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #if 0 @@ -1773,7 +1773,7 @@ union_unlock(ap) if ((un->un_flags & UN_ULOCK) && lockstatus(&un->un_lock, NULL) != LK_EXCLUSIVE) { un->un_flags &= ~UN_ULOCK; - VOP_UNLOCK(un->un_uppervp, LK_EXCLUSIVE, p); + VOP_UNLOCK(un->un_uppervp, LK_EXCLUSIVE, td); } #endif return(error); @@ -1788,7 +1788,7 @@ union_createvobject(ap) struct vop_createvobject_args /* { struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -1856,16 +1856,16 @@ union_pathconf(ap) } */ *ap; { int error; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct union_node *un = VTOUNION(ap->a_vp); struct vnode *vp; - vp = union_lock_other(un, p); + vp = union_lock_other(un, td); KASSERT(vp != NULL, ("union_pathconf: backing vnode missing!")); ap->a_vp = vp; error = VCALL(vp, VOFFSET(vop_pathconf), ap); - union_unlock_other(vp, p); + union_unlock_other(vp, td); return (error); } diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 68df08e..090087b 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -202,8 +202,8 @@ static void ccdiodone(struct bio *bp); static void ccdstart(struct ccd_s *, struct bio *); static void ccdinterleave(struct ccd_s *, int); static void ccdintr(struct ccd_s *, struct bio *); -static int ccdinit(struct ccd_s *, char **, struct proc *); -static int ccdlookup(char *, struct proc *p, struct vnode **); +static int ccdinit(struct ccd_s *, char **, struct thread *); +static int ccdlookup(char *, struct thread *p, struct vnode **); static void ccdbuffer(struct ccdbuf **ret, struct ccd_s *, struct bio *, daddr_t, caddr_t, long); static void ccdgetdisklabel(dev_t); @@ -381,7 +381,7 @@ ccd_modevent(module_t mod, int type, void *data) DEV_MODULE(ccd, ccd_modevent, NULL); static int -ccdinit(struct ccd_s *cs, char **cpaths, struct proc *p) +ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) { struct ccdcinfo *ci = NULL; /* XXX */ size_t size; @@ -438,7 +438,7 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct proc *p) * Get partition information for the component. */ if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, p->p_ucred, p)) != 0) { + FREAD, td->td_proc->p_ucred, td)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccd%d: %s: ioctl failed, error = %d\n", @@ -701,7 +701,7 @@ ccdinterleave(struct ccd_s *cs, int unit) /* ARGSUSED */ static int -ccdopen(dev_t dev, int flags, int fmt, struct proc *p) +ccdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit = ccdunit(dev); struct ccd_s *cs; @@ -746,7 +746,7 @@ ccdopen(dev_t dev, int flags, int fmt, struct proc *p) /* ARGSUSED */ static int -ccdclose(dev_t dev, int flags, int fmt, struct proc *p) +ccdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit = ccdunit(dev); struct ccd_s *cs; @@ -770,7 +770,7 @@ ccdclose(dev_t dev, int flags, int fmt, struct proc *p) cs->sc_openmask &= ~(1 << part); /* collect "garbage" if possible */ if (!IS_INITED(cs) && (cs->sc_flags & CCDF_WANTED) == 0) - ccddestroy(cs, p); + ccddestroy(cs, td->td_proc); else ccdunlock(cs); return (0); @@ -1238,7 +1238,7 @@ ccdiodone(struct bio *ibp) } static int -ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit = ccdunit(dev); int i, j, lookedup = 0, error = 0; @@ -1317,10 +1317,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (ccddebug & CCDB_INIT) printf("ccdioctl: lookedup = %d\n", lookedup); #endif - if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) { + if ((error = ccdlookup(cpp[i], td, &vpp[i])) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); @@ -1334,10 +1334,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) /* * Initialize the ccd. Fills in the softc for us. */ - if ((error = ccdinit(cs, cpp, p)) != 0) { + if ((error = ccdinit(cs, cpp, td)) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); /* * We can't ccddestroy() cs just yet, because nothing * prevents user-level app to do another ioctl() @@ -1398,7 +1398,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) cs->sc_cinfo[i].ci_vp); #endif (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); free(cs->sc_cinfo[i].ci_path, M_DEVBUF); } @@ -1557,7 +1557,7 @@ ccdsize(dev_t dev) struct ccd_s *cs; int part, size; - if (ccdopen(dev, 0, S_IFCHR, curproc)) + if (ccdopen(dev, 0, S_IFCHR, curthread)) return (-1); cs = ccdfind(ccdunit(dev)); @@ -1571,7 +1571,7 @@ ccdsize(dev_t dev) else size = cs->sc_label.d_partitions[part].p_size; - if (ccdclose(dev, 0, S_IFCHR, curproc)) + if (ccdclose(dev, 0, S_IFCHR, curthread)) return (-1); return (size); @@ -1591,13 +1591,13 @@ ccddump(dev_t dev) * set *vpp to the file's vnode. */ static int -ccdlookup(char *path, struct proc *p, struct vnode **vpp) +ccdlookup(char *path, struct thread *td, struct vnode **vpp) { struct nameidata nd; struct vnode *vp; int error, flags; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, td); flags = FREAD | FWRITE; if ((error = vn_open(&nd, &flags, 0)) != 0) { #ifdef DEBUG @@ -1621,15 +1621,15 @@ ccdlookup(char *path, struct proc *p, struct vnode **vpp) vprint("ccdlookup: vnode info", vp); #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); bad: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); /* vn_close does vrele() for vp */ - (void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p); + (void)vn_close(vp, FREAD|FWRITE, td->td_proc->p_ucred, td); return (error); } diff --git a/sys/gnu/ext2fs/ext2_extern.h b/sys/gnu/ext2fs/ext2_extern.h index b37b3ec..580683b 100644 --- a/sys/gnu/ext2fs/ext2_extern.h +++ b/sys/gnu/ext2fs/ext2_extern.h @@ -62,7 +62,7 @@ int ext2_init __P((struct vfsconf *)); int ext2_reallocblks __P((struct vop_reallocblks_args *)); int ext2_reclaim __P((struct vop_reclaim_args *)); void ext2_setblock __P((struct ext2_sb_info *, u_char *, daddr_t)); -int ext2_truncate __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); +int ext2_truncate __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); int ext2_update __P((struct vnode *, int)); int ext2_valloc __P((struct vnode *, int, struct ucred *, struct vnode **)); int ext2_vfree __P((struct vnode *, ino_t, int)); diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c index 1fd39e9..d1537af 100644 --- a/sys/gnu/ext2fs/ext2_ihash.c +++ b/sys/gnu/ext2fs/ext2_ihash.c @@ -40,6 +40,7 @@ #include <sys/lock.h> #include <sys/vnode.h> #include <sys/malloc.h> +#include <sys/proc.h> #include <sys/mutex.h> #include <ufs/ufs/quota.h> @@ -97,7 +98,7 @@ ufs_ihashget(dev, inum) dev_t dev; ino_t inum; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct inode *ip; struct vnode *vp; @@ -108,7 +109,7 @@ loop: vp = ITOV(ip); mtx_lock(&vp->v_interlock); mtx_unlock(&ufs_ihash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -124,11 +125,11 @@ void ufs_ihashins(ip) struct inode *ip; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct ihashhead *ipp; /* lock the inode, then put it on the appropriate hash list */ - lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p); + lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, td); mtx_lock(&ufs_ihash_mtx); ipp = INOHASH(ip->i_dev, ip->i_number); diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index 5a60006..6a3e011 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -129,12 +129,12 @@ ext2_update(vp, waitfor) * disk blocks. */ int -ext2_truncate(vp, length, flags, cred, p) +ext2_truncate(vp, length, flags, cred, td) struct vnode *vp; off_t length; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *ovp = vp; register daddr_t lastblock; @@ -268,7 +268,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length); bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks); bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks); oip->i_size = osize; - error = vtruncbuf(ovp, cred, p, length, (int)fs->s_blocksize); + error = vtruncbuf(ovp, cred, td, length, (int)fs->s_blocksize); if (error && (allerror == 0)) allerror = error; diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c index 4804ff1..b2e1511 100644 --- a/sys/gnu/ext2fs/ext2_lookup.c +++ b/sys/gnu/ext2fs/ext2_lookup.c @@ -322,7 +322,7 @@ ext2_lookup(ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize; @@ -503,7 +503,7 @@ searchloop: * Access for write is interpreted as allowing * creation of files in the directory. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Return an indication of where the new directory @@ -541,7 +541,7 @@ searchloop: */ cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (EJUSTRETURN); } /* @@ -584,7 +584,7 @@ found: /* * Write access to directory required to delete files. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Return pointer to current entry in dp->i_offset, @@ -618,7 +618,7 @@ found: } *vpp = tdp; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (0); } @@ -630,7 +630,7 @@ found: */ if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) { - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Careful about locking second inode. @@ -643,7 +643,7 @@ found: *vpp = tdp; cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (0); } @@ -668,13 +668,13 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) { - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (lockparent && (flags & ISLASTCN) && - (error = vn_lock(pdp, LK_EXCLUSIVE, p))) { + (error = vn_lock(pdp, LK_EXCLUSIVE, td))) { vput(tdp); return (error); } @@ -686,7 +686,7 @@ found: if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); *vpp = tdp; } @@ -799,7 +799,7 @@ ext2_direnter(ip, dvp, cnp) auio.uio_iovcnt = 1; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred); if (DIRBLKSIZ > VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize) @@ -880,7 +880,7 @@ ext2_direnter(ip, dvp, cnp) dp->i_flag |= IN_CHANGE | IN_UPDATE; if (!error && dp->i_endoff && dp->i_endoff < dp->i_size) error = UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, - cnp->cn_cred, cnp->cn_proc); + cnp->cn_cred, cnp->cn_thread); return (error); } @@ -983,7 +983,7 @@ ext2_dirempty(ip, parentino, cred) for (off = 0; off < ip->i_size; off += dp->rec_len) { error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, - UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); + UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct thread *)0); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. @@ -1047,7 +1047,7 @@ ext2_checkpath(source, target, cred) } error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf, sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, (int *)0, (struct proc *)0); + IO_NODELOCKED, cred, (int *)0, (struct thread *)0); if (error != 0) break; namlen = dirbuf.dotdot_type; /* like ufs little-endian */ diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h index 4c73aa3..85c9866 100644 --- a/sys/gnu/ext2fs/ext2_mount.h +++ b/sys/gnu/ext2fs/ext2_mount.h @@ -88,7 +88,7 @@ struct ufsmount { int um_i_effnlink_valid; /* i_effnlink valid? */ int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **)); int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **)); - int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); + int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); int (*um_update) __P((struct vnode *, int)); int (*um_valloc) __P((struct vnode *, int, struct ucred *, struct vnode **)); int (*um_vfree) __P((struct vnode *, ino_t, int)); diff --git a/sys/gnu/ext2fs/ext2_readwrite.c b/sys/gnu/ext2fs/ext2_readwrite.c index 62bc27a..2772f7b 100644 --- a/sys/gnu/ext2fs/ext2_readwrite.c +++ b/sys/gnu/ext2fs/ext2_readwrite.c @@ -172,7 +172,7 @@ WRITE(ap) register struct inode *ip; register FS *fs; struct buf *bp; - struct proc *p; + struct thread *td; daddr_t lbn; off_t osize; int seqcount; @@ -216,15 +216,15 @@ WRITE(ap) * Maybe this should be above the vnode op call, but so long as * file servers have no limits, I don't think it matters. */ - p = uio->uio_procp; + td = uio->uio_td; /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - if (vp->v_type == VREG && p && + if (vp->v_type == VREG && td && uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - PROC_LOCK(p); - psignal(p, SIGXFSZ); - PROC_UNLOCK(p); + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); return (EFBIG); } @@ -302,7 +302,7 @@ WRITE(ap) if (error) { if (ioflag & IO_UNIT) { (void)UFS_TRUNCATE(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_procp); + ioflag & IO_SYNC, ap->a_cred, uio->uio_td); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 7263615..713a0cb 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -71,16 +71,16 @@ #include <gnu/ext2fs/ext2_fs_sb.h> static int ext2_fhtovp __P((struct mount *, struct fid *, struct vnode **)); -static int ext2_flushfiles __P((struct mount *mp, int flags, struct proc *p)); +static int ext2_flushfiles __P((struct mount *mp, int flags, struct thread *td)); static int ext2_mount __P((struct mount *, - char *, caddr_t, struct nameidata *, struct proc *)); -static int ext2_mountfs __P((struct vnode *, struct mount *, struct proc *)); + char *, caddr_t, struct nameidata *, struct thread *)); +static int ext2_mountfs __P((struct vnode *, struct mount *, struct thread *)); static int ext2_reload __P((struct mount *mountp, struct ucred *cred, - struct proc *p)); + struct thread *td)); static int ext2_sbupdate __P((struct ufsmount *, int)); -static int ext2_statfs __P((struct mount *, struct statfs *, struct proc *)); -static int ext2_sync __P((struct mount *, int, struct ucred *, struct proc *)); -static int ext2_unmount __P((struct mount *, int, struct proc *)); +static int ext2_statfs __P((struct mount *, struct statfs *, struct thread *)); +static int ext2_sync __P((struct mount *, int, struct ucred *, struct thread *)); +static int ext2_unmount __P((struct mount *, int, struct thread *)); static int ext2_vget __P((struct mount *, ino_t, struct vnode **)); static int ext2_vptofh __P((struct vnode *, struct fid *)); @@ -130,7 +130,7 @@ ext2_mountroot() { register struct ext2_sb_info *fs; register struct mount *mp; - struct proc *p = curproc; + struct thread *td = curthread; struct ufsmount *ump; u_int size; int error; @@ -143,12 +143,12 @@ ext2_mountroot() bzero((char *)mp, (u_long)sizeof(struct mount)); mp->mnt_op = &ext2fs_vfsops; mp->mnt_flag = MNT_RDONLY; - if (error = ext2_mountfs(rootvp, mp, p)) { + if (error = ext2_mountfs(rootvp, mp, td)) { bsd_free(mp, M_MOUNT); return (error); } if (error = vfs_lock(mp)) { - (void)ext2_unmount(mp, 0, p); + (void)ext2_unmount(mp, 0, td); bsd_free(mp, M_MOUNT); return (error); } @@ -164,7 +164,7 @@ ext2_mountroot() (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)ext2_statfs(mp, &mp->mnt_stat, p); + (void)ext2_statfs(mp, &mp->mnt_stat, td); vfs_unlock(mp); inittodr(fs->s_es->s_wtime); /* this helps to set the time */ return (0); @@ -177,12 +177,12 @@ ext2_mountroot() * mount system call */ static int -ext2_mount(mp, path, data, ndp, p) +ext2_mount(mp, path, data, ndp, td) register struct mount *mp; char *path; caddr_t data; /* this is actually a (struct ufs_args *) */ struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *devvp; struct ufs_args args; @@ -210,10 +210,10 @@ ext2_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (vfs_busy(mp, LK_NOWAIT, 0, p)) + if (vfs_busy(mp, LK_NOWAIT, 0, td)) return (EBUSY); - error = ext2_flushfiles(mp, flags, p); - vfs_unbusy(mp, p); + error = ext2_flushfiles(mp, flags, td); + vfs_unbusy(mp, td); if (!error && fs->s_wasvalid) { fs->s_es->s_state |= EXT2_VALID_FS; ext2_sbupdate(ump, MNT_WAIT); @@ -221,7 +221,7 @@ ext2_mount(mp, path, data, ndp, p) fs->s_rd_only = 1; } if (!error && (mp->mnt_flag & MNT_RELOAD)) - error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p); + error = ext2_reload(mp, ndp->ni_cnd.cn_cred, td); if (error) return (error); devvp = ump->um_devvp; @@ -233,14 +233,14 @@ ext2_mount(mp, path, data, ndp, p) * If upgrade to read-write by non-root, then verify * that user has necessary permissions on the device. */ - if (suser(p)) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); + if (suser_td(td)) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, - p->p_ucred, p)) != 0) { - VOP_UNLOCK(devvp, 0, p); + td->td_proc->p_ucred, td)) != 0) { + VOP_UNLOCK(devvp, 0, td); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 || @@ -271,7 +271,7 @@ ext2_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); if ((error = namei(ndp)) != 0) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -286,20 +286,20 @@ ext2_mount(mp, path, data, ndp, p) * If mount by non-root, then verify that user has necessary * permissions on the device. */ - if (suser(p)) { + if (suser_td(td)) { accessmode = VREAD; if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td)) != 0) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = ext2_mountfs(devvp, mp, p); + error = ext2_mountfs(devvp, mp, td); } else { if (devvp != ump->um_devvp) error = EINVAL; /* needs translation */ @@ -321,7 +321,7 @@ ext2_mount(mp, path, data, ndp, p) (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)ext2_statfs(mp, &mp->mnt_stat, p); + (void)ext2_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -522,10 +522,10 @@ static int compute_sb_data(devvp, es, fs) * 6) re-read inode data for all active vnodes. */ static int -ext2_reload(mountp, cred, p) +ext2_reload(mountp, cred, td) register struct mount *mountp; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *vp, *nvp, *devvp; struct inode *ip; @@ -540,7 +540,7 @@ ext2_reload(mountp, cred, p) * Step 1: invalidate all cached meta-data. */ devvp = VFSTOUFS(mountp)->um_devvp; - if (vinvalbuf(devvp, 0, cred, p, 0, 0)) + if (vinvalbuf(devvp, 0, cred, td, 0, 0)) panic("ext2_reload: dirty1"); /* * Step 2: re-read superblock from disk. @@ -578,16 +578,16 @@ loop: /* * Step 4: invalidate all inactive vnodes. */ - if (vrecycle(vp, NULL, p)) + if (vrecycle(vp, NULL, td)) goto loop; /* * Step 5: invalidate all cached file data. */ mtx_lock(&vp->v_interlock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { goto loop; } - if (vinvalbuf(vp, 0, cred, p, 0, 0)) + if (vinvalbuf(vp, 0, cred, td, 0, 0)) panic("ext2_reload: dirty2"); /* * Step 6: re-read inode data for all active vnodes. @@ -615,10 +615,10 @@ loop: * Common code for mount and mountroot */ static int -ext2_mountfs(devvp, mp, p) +ext2_mountfs(devvp, mp, td) register struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; struct buf *bp; @@ -640,7 +640,7 @@ ext2_mountfs(devvp, mp, p) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) + if ((error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0)) != 0) return (error); #ifdef READONLY /* turn on this to force it to be read-only */ @@ -648,12 +648,12 @@ ext2_mountfs(devvp, mp, p) #endif ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); - if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) + if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, td) != 0) size = DEV_BSIZE; else { havepart = 1; @@ -739,7 +739,7 @@ ext2_mountfs(devvp, mp, p) out: if (bp) brelse(bp); - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); if (ump) { bsd_free(ump->um_e2fs->s_es, M_UFSMNT); bsd_free(ump->um_e2fs, M_UFSMNT); @@ -753,10 +753,10 @@ out: * unmount system call */ static int -ext2_unmount(mp, mntflags, p) +ext2_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; register struct ext2_sb_info *fs; @@ -768,7 +768,7 @@ ext2_unmount(mp, mntflags, p) return (EINVAL); flags |= FORCECLOSE; } - if ((error = ext2_flushfiles(mp, flags, p)) != 0) + if ((error = ext2_flushfiles(mp, flags, td)) != 0) return (error); ump = VFSTOUFS(mp); fs = ump->um_e2fs; @@ -795,7 +795,7 @@ ext2_unmount(mp, mntflags, p) ump->um_devvp->v_rdev->si_mountpoint = NULL; error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); + NOCRED, td); vrele(ump->um_devvp); bsd_free(fs->s_es, M_UFSMNT); bsd_free(fs, M_UFSMNT); @@ -809,10 +809,10 @@ ext2_unmount(mp, mntflags, p) * Flush out all the files in a filesystem. */ static int -ext2_flushfiles(mp, flags, p) +ext2_flushfiles(mp, flags, td) register struct mount *mp; int flags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; int error; @@ -828,7 +828,7 @@ ext2_flushfiles(mp, flags, p) for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] == NULLVP) continue; - quotaoff(p, mp, i); + quotaoff(td, mp, i); } /* * Here we fall through to vflush again to ensure @@ -845,10 +845,10 @@ ext2_flushfiles(mp, flags, p) * taken from ext2/super.c ext2_statfs */ static int -ext2_statfs(mp, sbp, p) +ext2_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { unsigned long overhead; register struct ufsmount *ump; @@ -904,11 +904,11 @@ ext2_statfs(mp, sbp, p) * Note: we are always called with the filesystem marked `MPBUSY'. */ static int -ext2_sync(mp, waitfor, cred, p) +ext2_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *nvp, *vp; struct inode *ip; @@ -945,16 +945,16 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { mtx_lock(&mntvnode_mtx); if (error == ENOENT) goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0) + if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(vp); mtx_lock(&mntvnode_mtx); } @@ -963,10 +963,10 @@ loop: * Force stale file system control information to be flushed. */ if (waitfor != MNT_LAZY) { - vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) != 0) + vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(ump->um_devvp, 0, p); + VOP_UNLOCK(ump->um_devvp, 0, td); } #if QUOTA qsync(mp); diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c index 2bd494b..ad60728 100644 --- a/sys/gnu/ext2fs/ext2_vnops.c +++ b/sys/gnu/ext2fs/ext2_vnops.c @@ -191,7 +191,7 @@ ext2_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -335,7 +335,7 @@ ext2_link(ap) struct vnode *vp = ap->a_vp; struct vnode *tdvp = ap->a_tdvp; struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct inode *ip; int error; @@ -347,7 +347,7 @@ ext2_link(ap) error = EXDEV; goto out2; } - if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) { + if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, td))) { goto out2; } ip = VTOI(vp); @@ -370,7 +370,7 @@ ext2_link(ap) } out1: if (tdvp != vp) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); out2: return (error); } @@ -396,7 +396,7 @@ ext2_rename(ap) struct vnode *fdvp = ap->a_fdvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; struct inode *ip, *xp, *dp; struct dirtemplate dirbuf; int doingdirectory = 0, oldparent = 0, newparent = 0; @@ -487,18 +487,18 @@ abortit: vput(fvp); return (error); } - if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0) + if ((error = vn_lock(fvp, LK_EXCLUSIVE, td)) != 0) goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); if (ip->i_nlink >= LINK_MAX) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EMLINK; goto abortit; } if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || (dp->i_flags & APPEND)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EPERM; goto abortit; } @@ -509,7 +509,7 @@ abortit: if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || dp == ip || (fcnp->cn_flags | tcnp->cn_flags) & ISDOTDOT || (ip->i_flag & IN_RENAME)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EINVAL; goto abortit; } @@ -537,7 +537,7 @@ abortit: ip->i_nlink++; ip->i_flag |= IN_CHANGE; if ((error = UFS_UPDATE(fvp, 1)) != 0) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); goto bad; } @@ -551,8 +551,8 @@ abortit: * to namei, as the parent directory is unlocked by the * call to checkpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - VOP_UNLOCK(fvp, 0, p); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + VOP_UNLOCK(fvp, 0, td); if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { @@ -678,7 +678,7 @@ abortit: if (--xp->i_nlink != 0) panic("ufs_rename: linked directory"); error = UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC, - tcnp->cn_cred, tcnp->cn_proc); + tcnp->cn_cred, tcnp->cn_thread); } xp->i_flag |= IN_CHANGE; vput(tvp); @@ -732,7 +732,7 @@ abortit: error = vn_rdwr(UIO_READ, fvp, (caddr_t)&dirbuf, sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, IO_NODELOCKED, - tcnp->cn_cred, (int *)0, (struct proc *)0); + tcnp->cn_cred, (int *)0, (struct thread *)0); if (error == 0) { /* Like ufs little-endian: */ namlen = dirbuf.dotdot_type; @@ -749,7 +749,7 @@ abortit: (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_SYNC, tcnp->cn_cred, (int *)0, - (struct proc *)0); + (struct thread *)0); cache_purge(fdvp); } } @@ -775,7 +775,7 @@ bad: out: if (doingdirectory) ip->i_flag &= ~IN_RENAME; - if (vn_lock(fvp, LK_EXCLUSIVE, p) == 0) { + if (vn_lock(fvp, LK_EXCLUSIVE, td) == 0) { ip->i_nlink--; ip->i_flag |= IN_CHANGE; ip->i_flag &= ~IN_RENAME; @@ -920,7 +920,7 @@ ext2_mkdir(ap) dirtemplate.dotdot_reclen = DIRBLKSIZ - 12; error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate, sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0); + IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct thread *)0); if (error) { dp->i_nlink--; dp->i_flag |= IN_CHANGE; @@ -970,7 +970,7 @@ ext2_rmdir(ap) struct vnode *vp = ap->a_vp; struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct inode *ip, *dp; int error; @@ -1005,7 +1005,7 @@ ext2_rmdir(ap) dp->i_nlink--; dp->i_flag |= IN_CHANGE; cache_purge(dvp); - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); /* * Truncate inode. The only stuff left * in the directory is "." and "..". The @@ -1018,9 +1018,9 @@ ext2_rmdir(ap) * worry about them later. */ ip->i_nlink -= 2; - error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, p); + error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, td); cache_purge(ITOV(ip)); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); out: return (error); } @@ -1056,7 +1056,7 @@ ext2_symlink(ap) } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, (int *)0, - (struct proc *)0); + (struct thread *)0); if (error) vput(vp); return (error); diff --git a/sys/gnu/ext2fs/fs.h b/sys/gnu/ext2fs/fs.h index 8bedb05..c7e96c9 100644 --- a/sys/gnu/ext2fs/fs.h +++ b/sys/gnu/ext2fs/fs.h @@ -153,8 +153,8 @@ extern u_char *fragtbl[]; * I think I'll try a VOP_LOCK/VOP_UNLOCK on the device vnode */ #define DEVVP(inode) (VFSTOUFS(ITOV(inode)->v_mount)->um_devvp) -#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curproc) -#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curproc) +#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curthread) +#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curthread) /* * To lock a buffer, set the B_LOCKED flag and then brelse() it. To unlock, diff --git a/sys/gnu/fs/ext2fs/ext2_extern.h b/sys/gnu/fs/ext2fs/ext2_extern.h index b37b3ec..580683b 100644 --- a/sys/gnu/fs/ext2fs/ext2_extern.h +++ b/sys/gnu/fs/ext2fs/ext2_extern.h @@ -62,7 +62,7 @@ int ext2_init __P((struct vfsconf *)); int ext2_reallocblks __P((struct vop_reallocblks_args *)); int ext2_reclaim __P((struct vop_reclaim_args *)); void ext2_setblock __P((struct ext2_sb_info *, u_char *, daddr_t)); -int ext2_truncate __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); +int ext2_truncate __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); int ext2_update __P((struct vnode *, int)); int ext2_valloc __P((struct vnode *, int, struct ucred *, struct vnode **)); int ext2_vfree __P((struct vnode *, ino_t, int)); diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index 5a60006..6a3e011 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -129,12 +129,12 @@ ext2_update(vp, waitfor) * disk blocks. */ int -ext2_truncate(vp, length, flags, cred, p) +ext2_truncate(vp, length, flags, cred, td) struct vnode *vp; off_t length; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *ovp = vp; register daddr_t lastblock; @@ -268,7 +268,7 @@ printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length); bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks); bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks); oip->i_size = osize; - error = vtruncbuf(ovp, cred, p, length, (int)fs->s_blocksize); + error = vtruncbuf(ovp, cred, td, length, (int)fs->s_blocksize); if (error && (allerror == 0)) allerror = error; diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c index 4804ff1..b2e1511 100644 --- a/sys/gnu/fs/ext2fs/ext2_lookup.c +++ b/sys/gnu/fs/ext2fs/ext2_lookup.c @@ -322,7 +322,7 @@ ext2_lookup(ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize; @@ -503,7 +503,7 @@ searchloop: * Access for write is interpreted as allowing * creation of files in the directory. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Return an indication of where the new directory @@ -541,7 +541,7 @@ searchloop: */ cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (EJUSTRETURN); } /* @@ -584,7 +584,7 @@ found: /* * Write access to directory required to delete files. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Return pointer to current entry in dp->i_offset, @@ -618,7 +618,7 @@ found: } *vpp = tdp; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (0); } @@ -630,7 +630,7 @@ found: */ if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) { - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Careful about locking second inode. @@ -643,7 +643,7 @@ found: *vpp = tdp; cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); return (0); } @@ -668,13 +668,13 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) { - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (lockparent && (flags & ISLASTCN) && - (error = vn_lock(pdp, LK_EXCLUSIVE, p))) { + (error = vn_lock(pdp, LK_EXCLUSIVE, td))) { vput(tdp); return (error); } @@ -686,7 +686,7 @@ found: if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); *vpp = tdp; } @@ -799,7 +799,7 @@ ext2_direnter(ip, dvp, cnp) auio.uio_iovcnt = 1; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred); if (DIRBLKSIZ > VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize) @@ -880,7 +880,7 @@ ext2_direnter(ip, dvp, cnp) dp->i_flag |= IN_CHANGE | IN_UPDATE; if (!error && dp->i_endoff && dp->i_endoff < dp->i_size) error = UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, - cnp->cn_cred, cnp->cn_proc); + cnp->cn_cred, cnp->cn_thread); return (error); } @@ -983,7 +983,7 @@ ext2_dirempty(ip, parentino, cred) for (off = 0; off < ip->i_size; off += dp->rec_len) { error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, - UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); + UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct thread *)0); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. @@ -1047,7 +1047,7 @@ ext2_checkpath(source, target, cred) } error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf, sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, (int *)0, (struct proc *)0); + IO_NODELOCKED, cred, (int *)0, (struct thread *)0); if (error != 0) break; namlen = dirbuf.dotdot_type; /* like ufs little-endian */ diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h index 4c73aa3..85c9866 100644 --- a/sys/gnu/fs/ext2fs/ext2_mount.h +++ b/sys/gnu/fs/ext2fs/ext2_mount.h @@ -88,7 +88,7 @@ struct ufsmount { int um_i_effnlink_valid; /* i_effnlink valid? */ int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **)); int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **)); - int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); + int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); int (*um_update) __P((struct vnode *, int)); int (*um_valloc) __P((struct vnode *, int, struct ucred *, struct vnode **)); int (*um_vfree) __P((struct vnode *, ino_t, int)); diff --git a/sys/gnu/fs/ext2fs/ext2_readwrite.c b/sys/gnu/fs/ext2fs/ext2_readwrite.c index 62bc27a..2772f7b 100644 --- a/sys/gnu/fs/ext2fs/ext2_readwrite.c +++ b/sys/gnu/fs/ext2fs/ext2_readwrite.c @@ -172,7 +172,7 @@ WRITE(ap) register struct inode *ip; register FS *fs; struct buf *bp; - struct proc *p; + struct thread *td; daddr_t lbn; off_t osize; int seqcount; @@ -216,15 +216,15 @@ WRITE(ap) * Maybe this should be above the vnode op call, but so long as * file servers have no limits, I don't think it matters. */ - p = uio->uio_procp; + td = uio->uio_td; /* For p_rlimit. */ mtx_assert(&Giant, MA_OWNED); - if (vp->v_type == VREG && p && + if (vp->v_type == VREG && td && uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - PROC_LOCK(p); - psignal(p, SIGXFSZ); - PROC_UNLOCK(p); + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); return (EFBIG); } @@ -302,7 +302,7 @@ WRITE(ap) if (error) { if (ioflag & IO_UNIT) { (void)UFS_TRUNCATE(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_procp); + ioflag & IO_SYNC, ap->a_cred, uio->uio_td); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 7263615..713a0cb 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -71,16 +71,16 @@ #include <gnu/ext2fs/ext2_fs_sb.h> static int ext2_fhtovp __P((struct mount *, struct fid *, struct vnode **)); -static int ext2_flushfiles __P((struct mount *mp, int flags, struct proc *p)); +static int ext2_flushfiles __P((struct mount *mp, int flags, struct thread *td)); static int ext2_mount __P((struct mount *, - char *, caddr_t, struct nameidata *, struct proc *)); -static int ext2_mountfs __P((struct vnode *, struct mount *, struct proc *)); + char *, caddr_t, struct nameidata *, struct thread *)); +static int ext2_mountfs __P((struct vnode *, struct mount *, struct thread *)); static int ext2_reload __P((struct mount *mountp, struct ucred *cred, - struct proc *p)); + struct thread *td)); static int ext2_sbupdate __P((struct ufsmount *, int)); -static int ext2_statfs __P((struct mount *, struct statfs *, struct proc *)); -static int ext2_sync __P((struct mount *, int, struct ucred *, struct proc *)); -static int ext2_unmount __P((struct mount *, int, struct proc *)); +static int ext2_statfs __P((struct mount *, struct statfs *, struct thread *)); +static int ext2_sync __P((struct mount *, int, struct ucred *, struct thread *)); +static int ext2_unmount __P((struct mount *, int, struct thread *)); static int ext2_vget __P((struct mount *, ino_t, struct vnode **)); static int ext2_vptofh __P((struct vnode *, struct fid *)); @@ -130,7 +130,7 @@ ext2_mountroot() { register struct ext2_sb_info *fs; register struct mount *mp; - struct proc *p = curproc; + struct thread *td = curthread; struct ufsmount *ump; u_int size; int error; @@ -143,12 +143,12 @@ ext2_mountroot() bzero((char *)mp, (u_long)sizeof(struct mount)); mp->mnt_op = &ext2fs_vfsops; mp->mnt_flag = MNT_RDONLY; - if (error = ext2_mountfs(rootvp, mp, p)) { + if (error = ext2_mountfs(rootvp, mp, td)) { bsd_free(mp, M_MOUNT); return (error); } if (error = vfs_lock(mp)) { - (void)ext2_unmount(mp, 0, p); + (void)ext2_unmount(mp, 0, td); bsd_free(mp, M_MOUNT); return (error); } @@ -164,7 +164,7 @@ ext2_mountroot() (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)ext2_statfs(mp, &mp->mnt_stat, p); + (void)ext2_statfs(mp, &mp->mnt_stat, td); vfs_unlock(mp); inittodr(fs->s_es->s_wtime); /* this helps to set the time */ return (0); @@ -177,12 +177,12 @@ ext2_mountroot() * mount system call */ static int -ext2_mount(mp, path, data, ndp, p) +ext2_mount(mp, path, data, ndp, td) register struct mount *mp; char *path; caddr_t data; /* this is actually a (struct ufs_args *) */ struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *devvp; struct ufs_args args; @@ -210,10 +210,10 @@ ext2_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (vfs_busy(mp, LK_NOWAIT, 0, p)) + if (vfs_busy(mp, LK_NOWAIT, 0, td)) return (EBUSY); - error = ext2_flushfiles(mp, flags, p); - vfs_unbusy(mp, p); + error = ext2_flushfiles(mp, flags, td); + vfs_unbusy(mp, td); if (!error && fs->s_wasvalid) { fs->s_es->s_state |= EXT2_VALID_FS; ext2_sbupdate(ump, MNT_WAIT); @@ -221,7 +221,7 @@ ext2_mount(mp, path, data, ndp, p) fs->s_rd_only = 1; } if (!error && (mp->mnt_flag & MNT_RELOAD)) - error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p); + error = ext2_reload(mp, ndp->ni_cnd.cn_cred, td); if (error) return (error); devvp = ump->um_devvp; @@ -233,14 +233,14 @@ ext2_mount(mp, path, data, ndp, p) * If upgrade to read-write by non-root, then verify * that user has necessary permissions on the device. */ - if (suser(p)) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); + if (suser_td(td)) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, - p->p_ucred, p)) != 0) { - VOP_UNLOCK(devvp, 0, p); + td->td_proc->p_ucred, td)) != 0) { + VOP_UNLOCK(devvp, 0, td); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 || @@ -271,7 +271,7 @@ ext2_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); if ((error = namei(ndp)) != 0) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -286,20 +286,20 @@ ext2_mount(mp, path, data, ndp, p) * If mount by non-root, then verify that user has necessary * permissions on the device. */ - if (suser(p)) { + if (suser_td(td)) { accessmode = VREAD; if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td)) != 0) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = ext2_mountfs(devvp, mp, p); + error = ext2_mountfs(devvp, mp, td); } else { if (devvp != ump->um_devvp) error = EINVAL; /* needs translation */ @@ -321,7 +321,7 @@ ext2_mount(mp, path, data, ndp, p) (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)ext2_statfs(mp, &mp->mnt_stat, p); + (void)ext2_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -522,10 +522,10 @@ static int compute_sb_data(devvp, es, fs) * 6) re-read inode data for all active vnodes. */ static int -ext2_reload(mountp, cred, p) +ext2_reload(mountp, cred, td) register struct mount *mountp; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *vp, *nvp, *devvp; struct inode *ip; @@ -540,7 +540,7 @@ ext2_reload(mountp, cred, p) * Step 1: invalidate all cached meta-data. */ devvp = VFSTOUFS(mountp)->um_devvp; - if (vinvalbuf(devvp, 0, cred, p, 0, 0)) + if (vinvalbuf(devvp, 0, cred, td, 0, 0)) panic("ext2_reload: dirty1"); /* * Step 2: re-read superblock from disk. @@ -578,16 +578,16 @@ loop: /* * Step 4: invalidate all inactive vnodes. */ - if (vrecycle(vp, NULL, p)) + if (vrecycle(vp, NULL, td)) goto loop; /* * Step 5: invalidate all cached file data. */ mtx_lock(&vp->v_interlock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { goto loop; } - if (vinvalbuf(vp, 0, cred, p, 0, 0)) + if (vinvalbuf(vp, 0, cred, td, 0, 0)) panic("ext2_reload: dirty2"); /* * Step 6: re-read inode data for all active vnodes. @@ -615,10 +615,10 @@ loop: * Common code for mount and mountroot */ static int -ext2_mountfs(devvp, mp, p) +ext2_mountfs(devvp, mp, td) register struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; struct buf *bp; @@ -640,7 +640,7 @@ ext2_mountfs(devvp, mp, p) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) + if ((error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0)) != 0) return (error); #ifdef READONLY /* turn on this to force it to be read-only */ @@ -648,12 +648,12 @@ ext2_mountfs(devvp, mp, p) #endif ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); - if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) + if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, td) != 0) size = DEV_BSIZE; else { havepart = 1; @@ -739,7 +739,7 @@ ext2_mountfs(devvp, mp, p) out: if (bp) brelse(bp); - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); if (ump) { bsd_free(ump->um_e2fs->s_es, M_UFSMNT); bsd_free(ump->um_e2fs, M_UFSMNT); @@ -753,10 +753,10 @@ out: * unmount system call */ static int -ext2_unmount(mp, mntflags, p) +ext2_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; register struct ext2_sb_info *fs; @@ -768,7 +768,7 @@ ext2_unmount(mp, mntflags, p) return (EINVAL); flags |= FORCECLOSE; } - if ((error = ext2_flushfiles(mp, flags, p)) != 0) + if ((error = ext2_flushfiles(mp, flags, td)) != 0) return (error); ump = VFSTOUFS(mp); fs = ump->um_e2fs; @@ -795,7 +795,7 @@ ext2_unmount(mp, mntflags, p) ump->um_devvp->v_rdev->si_mountpoint = NULL; error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); + NOCRED, td); vrele(ump->um_devvp); bsd_free(fs->s_es, M_UFSMNT); bsd_free(fs, M_UFSMNT); @@ -809,10 +809,10 @@ ext2_unmount(mp, mntflags, p) * Flush out all the files in a filesystem. */ static int -ext2_flushfiles(mp, flags, p) +ext2_flushfiles(mp, flags, td) register struct mount *mp; int flags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; int error; @@ -828,7 +828,7 @@ ext2_flushfiles(mp, flags, p) for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] == NULLVP) continue; - quotaoff(p, mp, i); + quotaoff(td, mp, i); } /* * Here we fall through to vflush again to ensure @@ -845,10 +845,10 @@ ext2_flushfiles(mp, flags, p) * taken from ext2/super.c ext2_statfs */ static int -ext2_statfs(mp, sbp, p) +ext2_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { unsigned long overhead; register struct ufsmount *ump; @@ -904,11 +904,11 @@ ext2_statfs(mp, sbp, p) * Note: we are always called with the filesystem marked `MPBUSY'. */ static int -ext2_sync(mp, waitfor, cred, p) +ext2_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *nvp, *vp; struct inode *ip; @@ -945,16 +945,16 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { mtx_lock(&mntvnode_mtx); if (error == ENOENT) goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0) + if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(vp); mtx_lock(&mntvnode_mtx); } @@ -963,10 +963,10 @@ loop: * Force stale file system control information to be flushed. */ if (waitfor != MNT_LAZY) { - vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) != 0) + vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(ump->um_devvp, 0, p); + VOP_UNLOCK(ump->um_devvp, 0, td); } #if QUOTA qsync(mp); diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c index 2bd494b..ad60728 100644 --- a/sys/gnu/fs/ext2fs/ext2_vnops.c +++ b/sys/gnu/fs/ext2fs/ext2_vnops.c @@ -191,7 +191,7 @@ ext2_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -335,7 +335,7 @@ ext2_link(ap) struct vnode *vp = ap->a_vp; struct vnode *tdvp = ap->a_tdvp; struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct inode *ip; int error; @@ -347,7 +347,7 @@ ext2_link(ap) error = EXDEV; goto out2; } - if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) { + if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, td))) { goto out2; } ip = VTOI(vp); @@ -370,7 +370,7 @@ ext2_link(ap) } out1: if (tdvp != vp) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); out2: return (error); } @@ -396,7 +396,7 @@ ext2_rename(ap) struct vnode *fdvp = ap->a_fdvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; struct inode *ip, *xp, *dp; struct dirtemplate dirbuf; int doingdirectory = 0, oldparent = 0, newparent = 0; @@ -487,18 +487,18 @@ abortit: vput(fvp); return (error); } - if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0) + if ((error = vn_lock(fvp, LK_EXCLUSIVE, td)) != 0) goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); if (ip->i_nlink >= LINK_MAX) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EMLINK; goto abortit; } if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || (dp->i_flags & APPEND)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EPERM; goto abortit; } @@ -509,7 +509,7 @@ abortit: if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || dp == ip || (fcnp->cn_flags | tcnp->cn_flags) & ISDOTDOT || (ip->i_flag & IN_RENAME)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EINVAL; goto abortit; } @@ -537,7 +537,7 @@ abortit: ip->i_nlink++; ip->i_flag |= IN_CHANGE; if ((error = UFS_UPDATE(fvp, 1)) != 0) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); goto bad; } @@ -551,8 +551,8 @@ abortit: * to namei, as the parent directory is unlocked by the * call to checkpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - VOP_UNLOCK(fvp, 0, p); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + VOP_UNLOCK(fvp, 0, td); if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { @@ -678,7 +678,7 @@ abortit: if (--xp->i_nlink != 0) panic("ufs_rename: linked directory"); error = UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC, - tcnp->cn_cred, tcnp->cn_proc); + tcnp->cn_cred, tcnp->cn_thread); } xp->i_flag |= IN_CHANGE; vput(tvp); @@ -732,7 +732,7 @@ abortit: error = vn_rdwr(UIO_READ, fvp, (caddr_t)&dirbuf, sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, IO_NODELOCKED, - tcnp->cn_cred, (int *)0, (struct proc *)0); + tcnp->cn_cred, (int *)0, (struct thread *)0); if (error == 0) { /* Like ufs little-endian: */ namlen = dirbuf.dotdot_type; @@ -749,7 +749,7 @@ abortit: (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_SYNC, tcnp->cn_cred, (int *)0, - (struct proc *)0); + (struct thread *)0); cache_purge(fdvp); } } @@ -775,7 +775,7 @@ bad: out: if (doingdirectory) ip->i_flag &= ~IN_RENAME; - if (vn_lock(fvp, LK_EXCLUSIVE, p) == 0) { + if (vn_lock(fvp, LK_EXCLUSIVE, td) == 0) { ip->i_nlink--; ip->i_flag |= IN_CHANGE; ip->i_flag &= ~IN_RENAME; @@ -920,7 +920,7 @@ ext2_mkdir(ap) dirtemplate.dotdot_reclen = DIRBLKSIZ - 12; error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate, sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0); + IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct thread *)0); if (error) { dp->i_nlink--; dp->i_flag |= IN_CHANGE; @@ -970,7 +970,7 @@ ext2_rmdir(ap) struct vnode *vp = ap->a_vp; struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct inode *ip, *dp; int error; @@ -1005,7 +1005,7 @@ ext2_rmdir(ap) dp->i_nlink--; dp->i_flag |= IN_CHANGE; cache_purge(dvp); - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); /* * Truncate inode. The only stuff left * in the directory is "." and "..". The @@ -1018,9 +1018,9 @@ ext2_rmdir(ap) * worry about them later. */ ip->i_nlink -= 2; - error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, p); + error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, td); cache_purge(ITOV(ip)); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); out: return (error); } @@ -1056,7 +1056,7 @@ ext2_symlink(ap) } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, (int *)0, - (struct proc *)0); + (struct thread *)0); if (error) vput(vp); return (error); diff --git a/sys/gnu/fs/ext2fs/fs.h b/sys/gnu/fs/ext2fs/fs.h index 8bedb05..c7e96c9 100644 --- a/sys/gnu/fs/ext2fs/fs.h +++ b/sys/gnu/fs/ext2fs/fs.h @@ -153,8 +153,8 @@ extern u_char *fragtbl[]; * I think I'll try a VOP_LOCK/VOP_UNLOCK on the device vnode */ #define DEVVP(inode) (VFSTOUFS(ITOV(inode)->v_mount)->um_devvp) -#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curproc) -#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curproc) +#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curthread) +#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curthread) /* * To lock a buffer, set the B_LOCKED flag and then brelse() it. To unlock, diff --git a/sys/gnu/i386/fpemul/fpu_entry.c b/sys/gnu/i386/fpemul/fpu_entry.c index 77cee77..ec75bee 100644 --- a/sys/gnu/i386/fpemul/fpu_entry.c +++ b/sys/gnu/i386/fpemul/fpu_entry.c @@ -211,10 +211,10 @@ math_emulate(struct trapframe * tframe) REENTRANT_CHECK(ON); #endif /* PARANOID */ - if ((((struct pcb *) curproc->p_addr)->pcb_flags & FP_SOFTFP) == 0) { + if ((curthread->td_pcb->pcb_flags & FP_SOFTFP) == 0) { finit(); control_word = __INITIAL_NPXCW__; - ((struct pcb *) curproc->p_addr)->pcb_flags |= FP_SOFTFP; + curthread->td_pcb->pcb_flags |= FP_SOFTFP; } FPU_info = tframe; FPU_ORIG_EIP = FPU_EIP; /* --pink-- */ @@ -232,10 +232,10 @@ math_emulate(struct trapframe * tframe) #endif FPU_lookahead = FPU_LOOKAHEAD; - PROC_LOCK(curproc); + PROC_LOCK(curthread->td_proc); if (curproc->p_flag & P_TRACED) FPU_lookahead = 0; - PROC_UNLOCK(curproc); + PROC_UNLOCK(curthread->td_proc); do_another_FPU_instruction: diff --git a/sys/gnu/i386/fpemul/fpu_system.h b/sys/gnu/i386/fpemul/fpu_system.h index a77f0c2..f4927c8 100644 --- a/sys/gnu/i386/fpemul/fpu_system.h +++ b/sys/gnu/i386/fpemul/fpu_system.h @@ -69,7 +69,7 @@ #include <linux/kernel.h> */ -#define I387 (*(union i387_union *)&(((struct pcb *)curproc->p_addr)->pcb_save.sv_87)) +#define I387 (*(union i387_union *)&(curthread->td_pcb->pcb_save.sv_87)) #define FPU_info (I387.soft.frame) #define FPU_CS (*(unsigned short *) &(FPU_info->tf_cs)) diff --git a/sys/i386/apm/apm.c b/sys/i386/apm/apm.c index 4d8f188..1b7cbc5 100644 --- a/sys/i386/apm/apm.c +++ b/sys/i386/apm/apm.c @@ -1047,7 +1047,7 @@ apm_attach(device_t dev) } static int -apmopen(dev_t dev, int flag, int fmt, struct proc *p) +apmopen(dev_t dev, int flag, int fmt, struct thread *td) { struct apm_softc *sc = &apm_softc; int ctl = APMDEV(dev); @@ -1075,7 +1075,7 @@ apmopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -apmclose(dev_t dev, int flag, int fmt, struct proc *p) +apmclose(dev_t dev, int flag, int fmt, struct thread *td) { struct apm_softc *sc = &apm_softc; int ctl = APMDEV(dev); @@ -1098,7 +1098,7 @@ apmclose(dev_t dev, int flag, int fmt, struct proc *p) } static int -apmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +apmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct apm_softc *sc = &apm_softc; struct apm_bios_arg *args; @@ -1282,7 +1282,7 @@ apmwrite(dev_t dev, struct uio *uio, int ioflag) } static int -apmpoll(dev_t dev, int events, struct proc *p) +apmpoll(dev_t dev, int events, struct thread *td) { struct apm_softc *sc = &apm_softc; int revents = 0; @@ -1291,7 +1291,7 @@ apmpoll(dev_t dev, int events, struct proc *p) if (sc->event_count) { revents |= events & (POLLIN | POLLRDNORM); } else { - selrecord(p, &sc->sc_rsel); + selrecord(td, &sc->sc_rsel); } } diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index 4d8f188..1b7cbc5 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -1047,7 +1047,7 @@ apm_attach(device_t dev) } static int -apmopen(dev_t dev, int flag, int fmt, struct proc *p) +apmopen(dev_t dev, int flag, int fmt, struct thread *td) { struct apm_softc *sc = &apm_softc; int ctl = APMDEV(dev); @@ -1075,7 +1075,7 @@ apmopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -apmclose(dev_t dev, int flag, int fmt, struct proc *p) +apmclose(dev_t dev, int flag, int fmt, struct thread *td) { struct apm_softc *sc = &apm_softc; int ctl = APMDEV(dev); @@ -1098,7 +1098,7 @@ apmclose(dev_t dev, int flag, int fmt, struct proc *p) } static int -apmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +apmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct apm_softc *sc = &apm_softc; struct apm_bios_arg *args; @@ -1282,7 +1282,7 @@ apmwrite(dev_t dev, struct uio *uio, int ioflag) } static int -apmpoll(dev_t dev, int events, struct proc *p) +apmpoll(dev_t dev, int events, struct thread *td) { struct apm_softc *sc = &apm_softc; int revents = 0; @@ -1291,7 +1291,7 @@ apmpoll(dev_t dev, int events, struct proc *p) if (sc->event_count) { revents |= events & (POLLIN | POLLRDNORM); } else { - selrecord(p, &sc->sc_rsel); + selrecord(td, &sc->sc_rsel); } } diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 83bf89a..a707b0f 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -84,7 +84,7 @@ options BLKDEV_IOSIZE=8192 # Options for the VM subsystem options PQ_CACHESIZE=512 # color for 512k/16k cache -options UPAGES=3 # number of 4k stack pages per process +options KSTACK_PAGES=3 # number of 4k stack pages per process # Deprecated options supported for backwards compatibility #options PQ_NOOPT # No coloring #options PQ_LARGECACHE # color for 512k/16k cache @@ -442,7 +442,7 @@ options IPX #IPX/SPX communications protocols options IPXIP #IPX in IP encapsulation (not available) options IPTUNNEL #IP in IPX encapsulation (not available) -options NCP #NetWare Core protocol +#options NCP #NetWare Core protocol options NETATALK #Appletalk communications protocols options NETATALKDEBUG #Appletalk debugging @@ -692,7 +692,7 @@ options HPFS #OS/2 File system options MSDOSFS #MS DOS File System (FAT, FAT32) options NTFS #NT File System options NULLFS #NULL filesystem -options NWFS #NetWare filesystem +#options NWFS #NetWare filesystem options PORTALFS #Portal filesystem options PROCFS #Process filesystem options PSEUDOFS #Pseudo-filesystem framework diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s index 5c68f81..8096d3c 100644 --- a/sys/i386/i386/apic_vector.s +++ b/sys/i386/i386/apic_vector.s @@ -48,10 +48,10 @@ IDTVEC(vec_name) ; \ movl $KPSEL,%eax ; \ mov %ax,%fs ; \ FAKE_MCOUNT(13*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ - call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ + call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ addl $4, %esp ; \ movl $0, lapic+LA_EOI ; \ lock ; \ @@ -59,7 +59,7 @@ IDTVEC(vec_name) ; \ movl intr_countp + (irq_num) * 4, %eax ; \ lock ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -152,8 +152,8 @@ IDTVEC(vec_name) ; \ MASK_LEVEL_IRQ(irq_num) ; \ EOI_IRQ(irq_num) ; \ 0: ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ ; \ /* entry point used by doreti_unpend for HWIs. */ \ __CONCAT(Xresume,irq_num): ; \ @@ -162,7 +162,7 @@ __CONCAT(Xresume,irq_num): ; \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -227,10 +227,10 @@ Xhardclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_hardclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti @@ -252,10 +252,10 @@ Xstatclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ FAKE_MCOUNT(13*4(%esp)) - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_statclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c index a2e5018..7e78088 100644 --- a/sys/i386/i386/db_interface.c +++ b/sys/i386/i386/db_interface.c @@ -351,23 +351,24 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu) gd = GLOBALDATA; #endif db_printf("cpuid = %d\n", gd->gd_cpuid); - db_printf("curproc = "); - if (gd->gd_curproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_curproc, - gd->gd_curproc->p_pid, gd->gd_curproc->p_comm); + db_printf("curthread = "); + if (gd->gd_curthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread, + gd->gd_curthread->td_proc->p_pid, gd->gd_curthread->td_proc->p_comm); else db_printf("none\n"); db_printf("curpcb = %p\n", gd->gd_curpcb); - db_printf("npxproc = "); - if (gd->gd_npxproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_npxproc, - gd->gd_npxproc->p_pid, gd->gd_npxproc->p_comm); + db_printf("npxthread = "); + if (gd->gd_npxthread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_npxthread, + gd->gd_npxthread->td_proc->p_pid, gd->gd_npxthread->td_proc->p_comm); else db_printf("none\n"); - db_printf("idleproc = "); - if (gd->gd_idleproc != NULL) - db_printf("%p: pid %d \"%s\"\n", gd->gd_idleproc, - gd->gd_idleproc->p_pid, gd->gd_idleproc->p_comm); + db_printf("idlethread = "); + if (gd->gd_idlethread != NULL) + db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread, + gd->gd_idlethread->td_proc->p_pid, + gd->gd_idlethread->td_proc->p_comm); else db_printf("none\n"); diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index dc1e2f0..3a07050 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -291,13 +291,15 @@ db_stack_trace_cmd(addr, have_addr, count, modif) boolean_t first; struct pcb *pcb; struct proc *p; + struct thread *td; pid_t pid; if (count == -1) count = 1024; if (!have_addr) { - p = curproc; + td = curthread; + p = td->td_proc; frame = (struct i386_frame *)ddb_regs.tf_ebp; if (frame == NULL) frame = (struct i386_frame *)(ddb_regs.tf_esp - 4); @@ -310,8 +312,9 @@ db_stack_trace_cmd(addr, have_addr, count, modif) * The pcb for curproc is not valid at this point, * so fall back to the default case. */ - if (pid == curproc->p_pid) { - p = curproc; + if (pid == curthread->td_proc->p_pid) { + td = curthread; + p = td->td_proc; frame = (struct i386_frame *)ddb_regs.tf_ebp; if (frame == NULL) frame = (struct i386_frame *) @@ -333,7 +336,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("pid %d swapped out\n", pid); return; } - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread.td_pcb; /* XXXKSE */ frame = (struct i386_frame *)pcb->pcb_ebp; if (frame == NULL) frame = (struct i386_frame *) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 0704db7..8f4be92 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -37,7 +37,7 @@ * $FreeBSD$ */ -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -50,6 +50,7 @@ #include <sys/mutex.h> #include <sys/socket.h> #include <sys/resourcevar.h> +#include <sys/user.h> /* XXX */ #ifdef KTR_PERCPU #include <sys/ktr.h> @@ -79,21 +80,31 @@ ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); -ASSYM(P_INTR_NESTING_LEVEL, offsetof(struct proc, p_intr_nesting_level)); ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_WCHAN, offsetof(struct proc, p_wchan)); +ASSYM(P_UAREA, offsetof(struct proc, p_uarea)); + +/*ASSYM(TD_STAT, offsetof(struct thread, td__stat));*/ +ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); +ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); +ASSYM(TD_KSE, offsetof(struct thread, td_kse)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level)); + +ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags)); -ASSYM(PS_ASTPENDING, PS_ASTPENDING); -ASSYM(PS_NEEDRESCHED, PS_NEEDRESCHED); +ASSYM(KEF_ASTPENDING, KEF_ASTPENDING); +ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED); ASSYM(SSLEEP, SSLEEP); ASSYM(SRUN, SRUN); ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); -ASSYM(UPAGES, UPAGES); +/* ASSYM(UPAGES, UPAGES);*/ +ASSYM(UAREA_PAGES, UAREA_PAGES); +ASSYM(KSTACK_PAGES, KSTACK_PAGES); ASSYM(PAGE_SIZE, PAGE_SIZE); ASSYM(NPTEPG, NPTEPG); ASSYM(NPDEPG, NPDEPG); @@ -133,9 +144,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -#ifdef SMP ASSYM(PCB_SIZE, sizeof(struct pcb)); -#endif ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); @@ -166,9 +175,9 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_PRVSPACE, offsetof(struct globaldata, gd_prvspace)); -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); -ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc)); -ASSYM(GD_IDLEPROC, offsetof(struct globaldata, gd_idleproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); +ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); +ASSYM(GD_IDLETHREAD, offsetof(struct globaldata, gd_idlethread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 97a1e16..ab3dad5 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -147,9 +147,11 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */ #endif KPTphys: .long 0 /* phys addr of kernel page tables */ - .globl proc0paddr -proc0paddr: .long 0 /* address of proc 0 address space */ -p0upa: .long 0 /* phys addr of proc0's UPAGES */ + .globl proc0uarea, proc0kstack +proc0uarea: .long 0 /* address of proc 0 uarea space */ +proc0kstack: .long 0 /* address of proc 0 kstack space */ +p0upa: .long 0 /* phys addr of proc0's UAREA */ +p0kpa: .long 0 /* phys addr of proc0's STACK */ vm86phystk: .long 0 /* PA of vm86/bios stack */ @@ -369,13 +371,14 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: /* set up bootstrap stack */ - movl proc0paddr,%eax /* location of in-kernel pages */ - leal UPAGES*PAGE_SIZE(%eax),%esp /* bootstrap stack end location */ + movl proc0kstack,%eax /* location of in-kernel stack */ + /* bootstrap stack end location */ + leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp xorl %ebp,%ebp /* mark end of frames */ movl IdlePTD,%esi - movl %esi,PCB_CR3(%eax) + movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax) testl $CPUID_PGE, R(cpu_feature) jz 1f @@ -762,10 +765,15 @@ no_kernend: movl %esi,R(IdlePTD) /* Allocate UPAGES */ - ALLOCPAGES(UPAGES) + ALLOCPAGES(UAREA_PAGES) movl %esi,R(p0upa) addl $KERNBASE, %esi - movl %esi, R(proc0paddr) + movl %esi, R(proc0uarea) + + ALLOCPAGES(KSTACK_PAGES) + movl %esi,R(p0kpa) + addl $KERNBASE, %esi + movl %esi, R(proc0kstack) ALLOCPAGES(1) /* vm86/bios stack */ movl %esi,R(vm86phystk) @@ -833,7 +841,12 @@ map_read_write: /* Map proc0's UPAGES in the physical way ... */ movl R(p0upa), %eax - movl $UPAGES, %ecx + movl $(UAREA_PAGES), %ecx + fillkptphys($PG_RW) + +/* Map proc0's KSTACK in the physical way ... */ + movl R(p0kpa), %eax + movl $(KSTACK_PAGES), %ecx fillkptphys($PG_RW) /* Map ISA hole */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index e0dade2..6711515 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -49,7 +49,7 @@ #include "opt_msgbuf.h" #include "opt_npx.h" #include "opt_perfmon.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" /* #include "opt_userconfig.h" */ #include <sys/param.h> @@ -289,14 +289,16 @@ osendsig(catcher, sig, mask, code) struct osigframe sf; struct osigframe *fp; struct proc *p; + struct thread *td; struct sigacts *psp; struct trapframe *regs; int oonstack; - p = curproc; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); /* Allocate and validate space for the signal handler context. */ @@ -386,7 +388,7 @@ osendsig(catcher, sig, mask, code) if (regs->tf_eflags & PSL_VM) { /* XXX confusing names: `tf' isn't a trapframe; `regs' is. */ struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; @@ -409,7 +411,7 @@ osendsig(catcher, sig, mask, code) * ...Kill the process. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -434,12 +436,14 @@ sendsig(catcher, sig, mask, code) { struct sigframe sf; struct proc *p; + struct thread *td; struct sigacts *psp; struct trapframe *regs; struct sigframe *sfp; int oonstack; - p = curproc; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; #ifdef COMPAT_43 @@ -448,7 +452,7 @@ sendsig(catcher, sig, mask, code) return; } #endif - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); /* Save user context. */ @@ -528,7 +532,7 @@ sendsig(catcher, sig, mask, code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; @@ -561,7 +565,7 @@ sendsig(catcher, sig, mask, code) * ...Kill the process. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -586,17 +590,18 @@ sendsig(catcher, sig, mask, code) */ #ifdef COMPAT_43 int -osigreturn(p, uap) - struct proc *p; +osigreturn(td, uap) + struct thread *td; struct osigreturn_args /* { struct osigcontext *sigcntxp; } */ *uap; { struct trapframe *regs; struct osigcontext *scp; + struct proc *p = td->td_proc; int eflags; - regs = p->p_frame; + regs = td->td_frame; scp = uap->sigcntxp; if (!useracc((caddr_t)scp, sizeof(*scp), VM_PROT_READ)) return (EFAULT); @@ -609,9 +614,9 @@ osigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (td->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &td->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -697,12 +702,13 @@ osigreturn(p, uap) #endif int -sigreturn(p, uap) - struct proc *p; +sigreturn(td, uap) + struct thread *td; struct sigreturn_args /* { ucontext_t *sigcntxp; } */ *uap; { + struct proc *p = td->td_proc; struct trapframe *regs; ucontext_t *ucp; int cs, eflags; @@ -712,7 +718,7 @@ sigreturn(p, uap) if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ)) return (EFAULT); if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516) - return (osigreturn(p, (struct osigreturn_args *)uap)); + return (osigreturn(td, (struct osigreturn_args *)uap)); /* * Since ucp is not an osigcontext but a ucontext_t, we have to * check again if all of it is accessible. A ucontext_t is @@ -724,7 +730,7 @@ sigreturn(p, uap) if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ)) return (EFAULT); - regs = p->p_frame; + regs = td->td_frame; eflags = ucp->uc_mcontext.mc_eflags; if (eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; @@ -734,9 +740,9 @@ sigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (td->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &td->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -865,14 +871,14 @@ cpu_idle(void) * Clear registers on exec */ void -setregs(p, entry, stack, ps_strings) - struct proc *p; +setregs(td, entry, stack, ps_strings) + struct thread *td; u_long entry; u_long stack; u_long ps_strings; { - struct trapframe *regs = p->p_frame; - struct pcb *pcb = &p->p_addr->u_pcb; + struct trapframe *regs = td->td_frame; + struct pcb *pcb = td->td_pcb; if (pcb->pcb_ldt) user_ldt_free(pcb); @@ -925,7 +931,7 @@ setregs(p, entry, stack, ps_strings) * traps to the emulator (if it is done at all) mainly because * emulators don't provide an entry point for initialization. */ - p->p_addr->u_pcb.pcb_flags &= ~FP_SOFTFP; + td->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * Arrange to trap the next npx or `fwait' instruction (see npx.c @@ -948,7 +954,7 @@ setregs(p, entry, stack, ps_strings) * Make sure sure edx is 0x0 on entry. Linux binaries depend * on it. */ - p->p_retval[1] = 0; + td->td_retval[1] = 0; } void @@ -1016,7 +1022,8 @@ extern int has_f00f_bug; static struct i386tss dblfault_tss; static char dblfault_stack[PAGE_SIZE]; -extern struct user *proc0paddr; +extern struct user *proc0uarea; +extern vm_offset_t proc0kstack; /* software prototypes -- in more palatable form */ @@ -1661,8 +1668,12 @@ init386(first) struct region_descriptor r_gdt, r_idt; #endif - proc0.p_addr = proc0paddr; - + proc_linkup(&proc0); + proc0.p_uarea = proc0uarea; + thread0 = &proc0.p_thread; + thread0->td_kstack = proc0kstack; + thread0->td_pcb = (struct pcb *) + (thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; atdevbase = ISA_HOLE_START + KERNBASE; metadata_missing = 0; @@ -1721,10 +1732,11 @@ init386(first) lgdt(&r_gdt); /* setup curproc so that mutexes work */ - PCPU_SET(curproc, &proc0); + + PCPU_SET(curthread, thread0); PCPU_SET(spinlocks, NULL); - LIST_INIT(&proc0.p_contested); + LIST_INIT(&thread0->td_contested); /* * Initialize mutexes. @@ -1828,8 +1840,9 @@ init386(first) initializecpu(); /* Initialize CPU registers */ /* make an initial tss so cpu can get interrupt stack on syscall! */ - PCPU_SET(common_tss.tss_esp0, - (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16); + /* Note: -16 is so we can grow the trapframe if we came from vm86 */ + PCPU_SET(common_tss.tss_esp0, thread0->td_kstack + + KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16); PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL)); gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; @@ -1884,10 +1897,10 @@ init386(first) _udatasel = LSEL(LUDATA_SEL, SEL_UPL); /* setup proc 0's pcb */ - proc0.p_addr->u_pcb.pcb_flags = 0; - proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD; - proc0.p_addr->u_pcb.pcb_ext = 0; - proc0.p_frame = &proc0_tf; + thread0->td_pcb->pcb_flags = 0; /* XXXKSE */ + thread0->td_pcb->pcb_cr3 = (int)IdlePTD; + thread0->td_pcb->pcb_ext = 0; + thread0->td_frame = &proc0_tf; } #if defined(I586_CPU) && !defined(NO_F00F_HACK) @@ -1930,31 +1943,26 @@ f00f_hack(void *unused) { #endif /* defined(I586_CPU) && !NO_F00F_HACK */ int -ptrace_set_pc(p, addr) - struct proc *p; - unsigned long addr; +ptrace_set_pc(struct thread *td, unsigned long addr) { - p->p_frame->tf_eip = addr; + td->td_frame->tf_eip = addr; return (0); } int -ptrace_single_step(p) - struct proc *p; +ptrace_single_step(struct thread *td) { - p->p_frame->tf_eflags |= PSL_T; + td->td_frame->tf_eflags |= PSL_T; return (0); } int -fill_regs(p, regs) - struct proc *p; - struct reg *regs; +fill_regs(struct thread *td, struct reg *regs) { struct pcb *pcb; struct trapframe *tp; - tp = p->p_frame; + tp = td->td_frame; regs->r_fs = tp->tf_fs; regs->r_es = tp->tf_es; regs->r_ds = tp->tf_ds; @@ -1970,20 +1978,18 @@ fill_regs(p, regs) regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; regs->r_gs = pcb->pcb_gs; return (0); } int -set_regs(p, regs) - struct proc *p; - struct reg *regs; +set_regs(struct thread *td, struct reg *regs) { struct pcb *pcb; struct trapframe *tp; - tp = p->p_frame; + tp = td->td_frame; if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) || !CS_SECURE(regs->r_cs)) return (EINVAL); @@ -2002,7 +2008,7 @@ set_regs(p, regs) tp->tf_eflags = regs->r_eflags; tp->tf_esp = regs->r_esp; tp->tf_ss = regs->r_ss; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; pcb->pcb_gs = regs->r_gs; return (0); } @@ -2062,45 +2068,39 @@ set_fpregs_xmm(sv_87, sv_xmm) #endif /* CPU_ENABLE_SSE */ int -fill_fpregs(p, fpregs) - struct proc *p; - struct fpreg *fpregs; +fill_fpregs(struct thread *td, struct fpreg *fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - fill_fpregs_xmm(&p->p_addr->u_pcb.pcb_save.sv_xmm, + fill_fpregs_xmm(&td->td_pcb->pcb_save.sv_xmm, (struct save87 *)fpregs); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(&p->p_addr->u_pcb.pcb_save.sv_87, fpregs, sizeof *fpregs); + bcopy(&td->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs); return (0); } int -set_fpregs(p, fpregs) - struct proc *p; - struct fpreg *fpregs; +set_fpregs(struct thread *td, struct fpreg *fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { set_fpregs_xmm((struct save87 *)fpregs, - &p->p_addr->u_pcb.pcb_save.sv_xmm); + &td->td_pcb->pcb_save.sv_xmm); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &p->p_addr->u_pcb.pcb_save.sv_87, sizeof *fpregs); + bcopy(fpregs, &td->td_pcb->pcb_save.sv_87, sizeof *fpregs); return (0); } int -fill_dbregs(p, dbregs) - struct proc *p; - struct dbreg *dbregs; +fill_dbregs(struct thread *td, struct dbreg *dbregs) { struct pcb *pcb; - if (p == NULL) { + if (td == NULL) { dbregs->dr0 = rdr0(); dbregs->dr1 = rdr1(); dbregs->dr2 = rdr2(); @@ -2109,9 +2109,8 @@ fill_dbregs(p, dbregs) dbregs->dr5 = rdr5(); dbregs->dr6 = rdr6(); dbregs->dr7 = rdr7(); - } - else { - pcb = &p->p_addr->u_pcb; + } else { + pcb = td->td_pcb; dbregs->dr0 = pcb->pcb_dr0; dbregs->dr1 = pcb->pcb_dr1; dbregs->dr2 = pcb->pcb_dr2; @@ -2125,15 +2124,13 @@ fill_dbregs(p, dbregs) } int -set_dbregs(p, dbregs) - struct proc *p; - struct dbreg *dbregs; +set_dbregs(struct thread *td, struct dbreg *dbregs) { struct pcb *pcb; int i; u_int32_t mask1, mask2; - if (p == NULL) { + if (td == NULL) { load_dr0(dbregs->dr0); load_dr1(dbregs->dr1); load_dr2(dbregs->dr2); @@ -2142,8 +2139,7 @@ set_dbregs(p, dbregs) load_dr5(dbregs->dr5); load_dr6(dbregs->dr6); load_dr7(dbregs->dr7); - } - else { + } else { /* * Don't let an illegal value for dr7 get set. Specifically, * check for undefined settings. Setting these bit patterns @@ -2155,7 +2151,7 @@ set_dbregs(p, dbregs) if ((dbregs->dr7 & mask1) == mask2) return (EINVAL); - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; /* * Don't let a process set a breakpoint that is not within the @@ -2172,7 +2168,7 @@ set_dbregs(p, dbregs) * from within kernel mode? */ - if (suser(p) != 0) { + if (suser_td(td) != 0) { if (dbregs->dr7 & 0x3) { /* dr0 is enabled */ if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) diff --git a/sys/i386/i386/math_emu.h b/sys/i386/i386/math_emu.h index 545a87d..bc28dc1 100644 --- a/sys/i386/i386/math_emu.h +++ b/sys/i386/i386/math_emu.h @@ -69,7 +69,7 @@ struct i387_struct { int32_t st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ }; -#define I387 (*(struct i387_struct *)&(((struct pcb *)curproc->p_addr)->pcb_save.sv_87)) +#define I387 (*(struct i387_struct *)&(curthread->td_pcb->pcb_save.sv_87)) #define SWD (*(struct swd *) &I387.swd) #define ROUNDING ((I387.cwd >> 10) & 3) #define PRECISION ((I387.cwd >> 8) & 3) diff --git a/sys/i386/i386/math_emulate.c b/sys/i386/i386/math_emulate.c index 94f32b1..e7da93e 100644 --- a/sys/i386/i386/math_emulate.c +++ b/sys/i386/i386/math_emulate.c @@ -98,8 +98,8 @@ math_emulate(struct trapframe * info) u_int32_t oldeip; /* ever used fp? */ - if ((((struct pcb *)curproc->p_addr)->pcb_flags & FP_SOFTFP) == 0) { - ((struct pcb *)curproc->p_addr)->pcb_flags |= FP_SOFTFP; + if ((curthread->td_pcb->pcb_flags & FP_SOFTFP) == 0) { + curthread->td_pcb->pcb_flags |= FP_SOFTFP; I387.cwd = 0x037f; I387.swd = 0x0000; I387.twd = 0x0000; @@ -604,7 +604,7 @@ static int __regoffset[] = { tEAX, tECX, tEDX, tEBX, tESP, tEBP, tESI, tEDI }; -#define REG(x) (((int *)curproc->p_frame)[__regoffset[(x)]]) +#define REG(x) (((int *)curthread->td_frame)[__regoffset[(x)]]) static char * sib(struct trapframe * info, int mod) diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index 5eded32..48ecff8 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -98,17 +98,17 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors"); struct mem_range_softc mem_range_softc; static int -mmclose(dev_t dev, int flags, int fmt, struct proc *p) +mmclose(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { case 14: - p->p_frame->tf_eflags &= ~PSL_IOPL; + td->td_frame->tf_eflags &= ~PSL_IOPL; } return (0); } static int -mmopen(dev_t dev, int flags, int fmt, struct proc *p) +mmopen(dev_t dev, int flags, int fmt, struct thread *td) { int error; @@ -119,12 +119,12 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p) return (EPERM); break; case 14: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); if (securelevel > 0) return (EPERM); - p->p_frame->tf_eflags |= PSL_IOPL; + td->td_frame->tf_eflags |= PSL_IOPL; break; } return (0); @@ -235,7 +235,7 @@ memmmap(dev_t dev, vm_offset_t offset, int prot) * and mem_range_attr_set. */ static int -mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int nd, error = 0; struct mem_range_op *mo = (struct mem_range_op *)data; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index d912e0c..f558524 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index d912e0c..f558524 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/i386/i386/perfmon.c b/sys/i386/i386/perfmon.c index 2d38312..ed0b53e 100644 --- a/sys/i386/i386/perfmon.c +++ b/sys/i386/i386/perfmon.c @@ -288,7 +288,7 @@ static int writer; static int writerpmc; static int -perfmon_open(dev_t dev, int flags, int fmt, struct proc *p) +perfmon_open(dev_t dev, int flags, int fmt, struct thread *td) { if (!perfmon_cpuok) return ENXIO; @@ -305,7 +305,7 @@ perfmon_open(dev_t dev, int flags, int fmt, struct proc *p) } static int -perfmon_close(dev_t dev, int flags, int fmt, struct proc *p) +perfmon_close(dev_t dev, int flags, int fmt, struct thread *td) { if (flags & FWRITE) { int i; @@ -320,7 +320,7 @@ perfmon_close(dev_t dev, int flags, int fmt, struct proc *p) } static int -perfmon_ioctl(dev_t dev, u_long cmd, caddr_t param, int flags, struct proc *p) +perfmon_ioctl(dev_t dev, u_long cmd, caddr_t param, int flags, struct thread *td) { struct pmc *pmc; struct pmc_data *pmcd; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 3ce91ab..b41b11f 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -71,7 +71,7 @@ #include "opt_disable_pse.h" #include "opt_pmap.h" #include "opt_msgbuf.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -171,7 +171,7 @@ vm_offset_t kernel_vm_end; static vm_zone_t pvzone; static struct vm_zone pvzone_store; static struct vm_object pvzone_obj; -static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0; +static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; static int pmap_pagedaemon_waken = 0; static struct pv_entry *pvinit; @@ -183,7 +183,7 @@ static pt_entry_t *CMAP2, *ptmmap; caddr_t CADDR1 = 0, ptvmmap = 0; static caddr_t CADDR2; static pt_entry_t *msgbufmap; -struct msgbuf *msgbufp=0; +struct msgbuf *msgbufp = 0; /* * Crashdump maps. @@ -819,7 +819,7 @@ retry: } /* - * Create the UPAGES for a new process. + * Create the Uarea stack for a new process. * This routine directly affects the fork perf for a process. */ void @@ -840,22 +840,22 @@ pmap_new_proc(p) */ upobj = p->p_upages_obj; if (upobj == NULL) { - upobj = vm_object_allocate(OBJT_DEFAULT, UPAGES); + upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES); p->p_upages_obj = upobj; } - /* get a kernel virtual address for the UPAGES for this proc */ - up = (vm_offset_t)p->p_addr; + /* get a kernel virtual address for the U area for this proc */ + up = (vm_offset_t)p->p_uarea; if (up == 0) { - up = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); + up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE); if (up == 0) panic("pmap_new_proc: upage allocation failed"); - p->p_addr = (struct user *)up; + p->p_uarea = (struct user *)up; } ptek = (unsigned *)vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { /* * Get a kernel stack page */ @@ -892,7 +892,7 @@ pmap_new_proc(p) } /* - * Dispose the UPAGES for a process that has exited. + * Dispose the U-Area for a process that has exited. * This routine directly impacts the exit perf of a process. */ void @@ -906,9 +906,9 @@ pmap_dispose_proc(p) unsigned *ptek, oldpte; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; + up = (vm_offset_t)p->p_uarea; ptek = (unsigned *)vtopte(up); - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_dispose_proc: upage already missing?"); @@ -927,7 +927,7 @@ pmap_dispose_proc(p) } /* - * Allow the UPAGES for a process to be prejudicially paged out. + * Allow the U_AREA for a process to be prejudicially paged out. */ void pmap_swapout_proc(p) @@ -939,8 +939,8 @@ pmap_swapout_proc(p) vm_page_t m; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_swapout_proc: upage already missing?"); @@ -951,7 +951,7 @@ pmap_swapout_proc(p) } /* - * Bring the UPAGES for a specified process back in. + * Bring the U-Area for a specified process back in. */ void pmap_swapin_proc(p) @@ -963,8 +963,8 @@ pmap_swapin_proc(p) vm_page_t m; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); if (m->valid != VM_PAGE_BITS_ALL) { @@ -980,6 +980,191 @@ pmap_swapin_proc(p) } } +/* + * Create the kernel stack (including pcb for i386) for a new thread. + * This routine directly affects the fork perf for a process and + * create performance for a thread. + */ +void +pmap_new_thread(td) + struct thread *td; +{ +#ifdef I386_CPU + int updateneeded = 0; +#endif + int i; + vm_object_t ksobj; + vm_page_t m; + vm_offset_t ks; + unsigned *ptek, oldpte; + + /* + * allocate object for the kstack + */ + ksobj = td->td_kstack_obj; + if (ksobj == NULL) { + ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES); + td->td_kstack_obj = ksobj; + } + +#ifdef KSTACK_GUARD + /* get a kernel virtual address for the kstack for this proc */ + ks = (vm_offset_t)td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, + (KSTACK_PAGES + 1) * PAGE_SIZE); + if (ks == 0) + panic("pmap_new_thread: kstack allocation failed"); + ks += PAGE_SIZE; + td->td_kstack = ks; + } + + ptek = (unsigned *)vtopte(ks - PAGE_SIZE); + oldpte = *ptek; + *ptek = 0; + if (oldpte) { +#ifdef I386_CPU + updateneeded = 1; +#else + invlpg(ks - PAGE_SIZE); +#endif + } + ptek++; +#else + /* get a kernel virtual address for the kstack for this proc */ + ks = (vm_offset_t)td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE); + if (ks == 0) + panic("pmap_new_thread: kstack allocation failed"); + td->td_kstack = ks; + } +#endif + for (i = 0; i < KSTACK_PAGES; i++) { + /* + * Get a kernel stack page + */ + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + + /* + * Wire the page + */ + m->wire_count++; + cnt.v_wire_count++; + + oldpte = *(ptek + i); + /* + * Enter the page into the kernel address space. + */ + *(ptek + i) = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag; + if (oldpte) { +#ifdef I386_CPU + updateneeded = 1; +#else + invlpg(ks + i * PAGE_SIZE); +#endif + } + + vm_page_wakeup(m); + vm_page_flag_clear(m, PG_ZERO); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + m->valid = VM_PAGE_BITS_ALL; + } +#ifdef I386_CPU + if (updateneeded) + invltlb(); +#endif +} + +/* + * Dispose the kernel stack for a thread that has exited. + * This routine directly impacts the exit perf of a process and thread. + */ +void +pmap_dispose_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + unsigned *ptek, oldpte; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + ptek = (unsigned *)vtopte(ks); + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_dispose_thread: kstack already missing?"); + vm_page_busy(m); + oldpte = *(ptek + i); + *(ptek + i) = 0; +#ifndef I386_CPU + invlpg(ks + i * PAGE_SIZE); +#endif + vm_page_unwire(m, 0); + vm_page_free(m); + } +#ifdef I386_CPU + invltlb(); +#endif +} + +/* + * Allow the Kernel stack for a thread to be prejudicially paged out. + */ +void +pmap_swapout_thread(td) + struct thread *td; +{ + int i; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_swapout_thread: kstack already missing?"); + vm_page_dirty(m); + vm_page_unwire(m, 0); + pmap_kremove(ks + i * PAGE_SIZE); + } +} + +/* + * Bring the kernel stack for a specified thread back in. + */ +void +pmap_swapin_thread(td) + struct thread *td; +{ + int i, rv; + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); + if (m->valid != VM_PAGE_BITS_ALL) { + rv = vm_pager_get_pages(ksobj, &m, 1, 0); + if (rv != VM_PAGER_OK) + panic("pmap_swapin_thread: cannot get kstack for proc: %d\n", td->td_proc->p_pid); + m = vm_page_lookup(ksobj, i); + m->valid = VM_PAGE_BITS_ALL; + } + vm_page_wire(m); + vm_page_wakeup(m); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + } +} + /*************************************************** * Page table page management routines..... ***************************************************/ @@ -1517,7 +1702,7 @@ pmap_collect() { int i; vm_page_t m; - static int warningdone=0; + static int warningdone = 0; if (pmap_pagedaemon_waken == 0) return; @@ -2333,7 +2518,7 @@ retry: pmap->pm_stats.resident_count += size >> PAGE_SHIFT; npdes = size >> PDRSHIFT; - for(i=0;i<npdes;i++) { + for(i = 0; i < npdes; i++) { pmap->pm_pdir[ptepindex] = (pd_entry_t) (ptepa | PG_U | PG_RW | PG_V | PG_PS); ptepa += NBPDR; @@ -2444,7 +2629,7 @@ pmap_prefault(pmap, addra, entry) vm_page_t m, mpte; vm_object_t object; - if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) + if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace))) return; object = entry->object.vm_object; @@ -2561,6 +2746,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) vm_offset_t pdnxt; unsigned src_frame, dst_frame; vm_page_t m; + pd_entry_t saved_pde; if (dst_addr != src_addr) return; @@ -2580,7 +2766,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) invltlb(); #endif } - + saved_pde = (pd_entry_t)((u_int32_t)APTDpde & (PG_FRAME|PG_RW | PG_V)); for(addr = src_addr; addr < end_addr; addr = pdnxt) { unsigned *src_pte, *dst_pte; vm_page_t dstmpte, srcmpte; @@ -2637,6 +2823,16 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * block. */ dstmpte = pmap_allocpte(dst_pmap, addr); + if (((u_int32_t)APTDpde & PG_FRAME) != + ((u_int32_t)saved_pde & PG_FRAME)) { + APTDpde = saved_pde; +printf ("IT HAPPENNED!"); +#if defined(SMP) + cpu_invltlb(); +#else + invltlb(); +#endif + } if ((*dst_pte == 0) && (ptetemp = *src_pte)) { /* * Clear the modified and @@ -2831,7 +3027,7 @@ pmap_remove_pages(pmap, sva, eva) vm_page_t m; #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY - if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) { + if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace))) { printf("warning: pmap_remove_pages called with non-current pmap\n"); return; } @@ -2839,8 +3035,8 @@ pmap_remove_pages(pmap, sva, eva) s = splvm(); for(pv = TAILQ_FIRST(&pmap->pm_pvlist); - pv; - pv = npv) { + pv; + pv = npv) { if (pv->pv_va >= eva || pv->pv_va < sva) { npv = TAILQ_NEXT(pv, pv_plist); @@ -2854,6 +3050,12 @@ pmap_remove_pages(pmap, sva, eva) #endif tpte = *pte; + if (tpte == 0) { + printf("TPTE at %p IS ZERO @ VA %08x\n", + pte, pv->pv_va); + panic("bad pte"); + } + /* * We cannot remove wired pages from a process' mapping at this time */ @@ -2861,15 +3063,19 @@ pmap_remove_pages(pmap, sva, eva) npv = TAILQ_NEXT(pv, pv_plist); continue; } - *pte = 0; m = PHYS_TO_VM_PAGE(tpte); + KASSERT(m->phys_addr == (tpte & PG_FRAME), + ("vm_page_t %p phys_addr mismatch %08x %08x", + m, m->phys_addr, tpte)); KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %x", tpte)); pv->pv_pmap->pm_stats.resident_count--; + *pte = 0; + /* * Update the vm_page_t clean and reference bits. */ @@ -2877,7 +3083,6 @@ pmap_remove_pages(pmap, sva, eva) vm_page_dirty(m); } - npv = TAILQ_NEXT(pv, pv_plist); TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); @@ -3255,11 +3460,13 @@ pmap_mincore(pmap, addr) } void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { + struct proc *p = td->td_proc; pmap_t pmap; + u_int32_t cr3; - pmap = vmspace_pmap(p->p_vmspace); + pmap = vmspace_pmap(td->td_proc->p_vmspace); #if defined(SMP) pmap->pm_active |= 1 << PCPU_GET(cpuid); #else @@ -3268,7 +3475,20 @@ pmap_activate(struct proc *p) #if defined(SWTCH_OPTIM_STATS) tlb_flush_count++; #endif - load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir)); + cr3 = vtophys(pmap->pm_pdir); + /* XXXKSE this is wrong. + * pmap_activate is for the current thread on the current cpu + */ + if (p->p_flag & P_KSES) { + /* Make sure all other cr3 entries are updated. */ + /* what if they are running? XXXKSE (maybe abort them) */ + FOREACH_THREAD_IN_PROC(p, td) { + td->td_pcb->pcb_cr3 = cr3; + } + } else { + td->td_pcb->pcb_cr3 = cr3; + } + load_cr3(cr3); } vm_offset_t @@ -3301,14 +3521,14 @@ pmap_pid_dump(int pid) int i,j; index = 0; pmap = vmspace_pmap(p->p_vmspace); - for(i=0;i<1024;i++) { + for(i = 0; i < 1024; i++) { pd_entry_t *pde; unsigned *pte; unsigned base = i << PDRSHIFT; pde = &pmap->pm_pdir[i]; if (pde && pmap_pde_v(pde)) { - for(j=0;j<1024;j++) { + for(j = 0; j < 1024; j++) { unsigned va = base + (j << PAGE_SHIFT); if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) { if (index) { diff --git a/sys/i386/i386/procfs_machdep.c b/sys/i386/i386/procfs_machdep.c index f951b0f..e8440b1 100644 --- a/sys/i386/i386/procfs_machdep.c +++ b/sys/i386/i386/procfs_machdep.c @@ -87,7 +87,7 @@ int error; \ \ mtx_lock_spin(&sched_lock); \ - if ((p->p_sflag & PS_INMEM) == 0) \ + if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ error = EIO; \ else \ error = (action); \ @@ -96,39 +96,39 @@ } while(0) int -procfs_read_regs(p, regs) - struct proc *p; +procfs_read_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(fill_regs(p, regs)); + PROCFS_ACTION(fill_regs(td, regs)); } int -procfs_write_regs(p, regs) - struct proc *p; +procfs_write_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(set_regs(p, regs)); + PROCFS_ACTION(set_regs(td, regs)); } int -procfs_read_dbregs(p, dbregs) - struct proc *p; +procfs_read_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { - PROCFS_ACTION(fill_dbregs(p, dbregs)); + PROCFS_ACTION(fill_dbregs(td, dbregs)); } int -procfs_write_dbregs(p, dbregs) - struct proc *p; +procfs_write_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { - PROCFS_ACTION(set_dbregs(p, dbregs)); + PROCFS_ACTION(set_dbregs(td, dbregs)); } /* @@ -137,27 +137,27 @@ procfs_write_dbregs(p, dbregs) */ int -procfs_read_fpregs(p, fpregs) - struct proc *p; +procfs_read_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(fill_fpregs(p, fpregs)); + PROCFS_ACTION(fill_fpregs(td, fpregs)); } int -procfs_write_fpregs(p, fpregs) - struct proc *p; +procfs_write_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(set_fpregs(p, fpregs)); + PROCFS_ACTION(set_fpregs(td, fpregs)); } int -procfs_sstep(p) - struct proc *p; +procfs_sstep(td) + struct thread *td; { - PROCFS_ACTION(ptrace_single_step(p)); + PROCFS_ACTION(ptrace_single_step(td)); } diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 55bc29c..81181cc 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -216,8 +216,8 @@ ENTRY(i586_bzero) * complicated since we avoid it if possible at all levels. We * want to localize the complications even when that increases them. * Here the extra work involves preserving CR0_TS in TS. - * `npxproc != NULL' is supposed to be the condition that all the - * FPU resources belong to an application, but npxproc and CR0_TS + * `npxthread != NULL' is supposed to be the condition that all the + * FPU resources belong to an application, but npxthread and CR0_TS * aren't set atomically enough for this condition to work in * interrupt handlers. * @@ -241,7 +241,7 @@ ENTRY(i586_bzero) * method. CR0_TS must be preserved although it is very likely to * always end up as clear. */ - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz1 /* @@ -303,7 +303,7 @@ fpureg_i586_bzero_loop: cmpl $8,%ecx jae fpureg_i586_bzero_loop - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bz3 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -517,7 +517,7 @@ ENTRY(i586_bcopy) sarb $1,kernel_fpu_lock jc small_i586_bcopy - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc1 /* XXX turn off handling of cases 1-2, as above. */ @@ -593,7 +593,7 @@ large_i586_bcopy_loop: cmpl $64,%ecx jae 4b - cmpl $0,PCPU(NPXPROC) + cmpl $0,PCPU(NPXTHREAD) je i586_bc2 /* XXX check that the condition for cases 1-2 stayed false. */ @@ -991,14 +991,14 @@ ENTRY(fastmove) /* XXX grab FPU context atomically. */ cli -/* if (npxproc != NULL) { */ - cmpl $0,PCPU(NPXPROC) +/* if (npxthread != NULL) { */ + cmpl $0,PCPU(NPXTHREAD) je 6f /* fnsave(&curpcb->pcb_savefpu); */ movl PCPU(CURPCB),%eax fnsave PCB_SAVEFPU(%eax) -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* NPXTHREAD = NULL; */ + movl $0,PCPU(NPXTHREAD) /* } */ 6: /* now we own the FPU. */ @@ -1026,9 +1026,9 @@ ENTRY(fastmove) movl -4(%ebp),%edi /* stop_emulating(); */ clts -/* npxproc = curproc; */ - movl PCPU(CURPROC),%eax - movl %eax,PCPU(NPXPROC) +/* npxthread = curthread; */ + movl PCPU(CURTHREAD),%eax + movl %eax,PCPU(NPXTHREAD) movl PCPU(CURPCB),%eax /* XXX end of atomic FPU context grab. */ @@ -1113,8 +1113,8 @@ fastmove_loop: smsw %ax orb $CR0_TS,%al lmsw %ax -/* npxproc = NULL; */ - movl $0,PCPU(NPXPROC) +/* npxthread = NULL; */ + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti @@ -1154,7 +1154,7 @@ fastmove_fault: smsw %ax orb $CR0_TS,%al lmsw %ax - movl $0,PCPU(NPXPROC) + movl $0,PCPU(NPXTHREAD) /* XXX end of atomic FPU context ungrab. */ sti diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 0f2f7a8..075aa36 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -77,17 +77,17 @@ ENTRY(cpu_throw) ENTRY(cpu_switch) /* switch to new process. first, save context as needed */ - movl PCPU(CURPROC),%ecx + movl PCPU(CURTHREAD),%ecx /* if no process to save, don't bother */ testl %ecx,%ecx jz sw1 - - movl P_VMSPACE(%ecx), %edx + movl TD_PROC(%ecx), %eax + movl P_VMSPACE(%eax), %edx movl PCPU(CPUID), %eax btrl %eax, VM_PMAP+PM_ACTIVE(%edx) - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx movl (%esp),%eax /* Hardware registers */ movl %eax,PCB_EIP(%edx) @@ -124,7 +124,7 @@ ENTRY(cpu_switch) #ifdef DEV_NPX /* have we used fp, and need a save? */ - cmpl %ecx,PCPU(NPXPROC) + cmpl %ecx,PCPU(NPXTHREAD) jne 1f addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ pushl %edx @@ -133,7 +133,11 @@ ENTRY(cpu_switch) 1: #endif /* DEV_NPX */ +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* save is done, now choose a new process */ + /* But still trashing space above the old "Top Of Stack".. */ sw1: #ifdef SMP @@ -143,17 +147,17 @@ sw1: cmpl $0,PCPU(CPUID) je 1f - movl PCPU(IDLEPROC), %eax - jmp sw1b + movl PCPU(IDLETHREAD), %eax + jmp sw1b /* Idle thread can run on any kernel context */ 1: #endif /* - * Choose a new process to schedule. chooseproc() returns idleproc + * Choose a new process to schedule. choosethread() returns idleproc * if it cannot find another process to run. */ sw1a: - call chooseproc /* trash ecx, edx, ret eax*/ + call choosethread /* trash ecx, edx, ret eax*/ #ifdef INVARIANTS testl %eax,%eax /* no process? */ @@ -163,15 +167,20 @@ sw1b: movl %eax,%ecx #ifdef INVARIANTS - cmpb $SRUN,P_STAT(%ecx) + movl TD_PROC(%ecx), %eax /* XXXKSE */ + cmpb $SRUN,P_STAT(%eax) jne badsw2 #endif - movl P_ADDR(%ecx),%edx + movl TD_PCB(%ecx),%edx #if defined(SWTCH_OPTIM_STATS) incl swtch_optim_stats #endif + +/*##########################################################################*/ +/*##########################################################################*/ +/*##########################################################################*/ /* switch address space */ movl %cr3,%ebx cmpl PCB_CR3(%edx),%ebx @@ -181,9 +190,8 @@ sw1b: incl tlb_flush_count #endif movl PCB_CR3(%edx),%ebx - movl %ebx,%cr3 + movl %ebx,%cr3 /* LOAD NEW PAGE TABLES */ 4: - movl PCPU(CPUID), %esi cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ je 1f @@ -191,12 +199,9 @@ sw1b: movl PCB_EXT(%edx), %edi /* new tss descriptor */ jmp 2f 1: - /* update common_tss.tss_esp0 pointer */ - movl %edx, %ebx /* pcb */ - addl $(UPAGES * PAGE_SIZE - 16), %ebx - movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 - + /* esp points to base of usable stack */ + movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */ btrl %esi, private_tss jae 3f PCPU_ADDR(COMMON_TSSD, %edi) @@ -210,7 +215,9 @@ sw1b: movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */ ltr %si 3: - movl P_VMSPACE(%ecx), %ebx + /* note in a vmspace that this cpu is using it */ + movl TD_PROC(%ecx),%eax /* get proc from thread XXXKSE */ + movl P_VMSPACE(%eax), %ebx /* get vmspace of proc */ movl PCPU(CPUID), %eax btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) @@ -233,22 +240,23 @@ sw1b: #endif /** GRAB_LOPRIO */ #endif /* SMP */ movl %edx, PCPU(CURPCB) - movl %ecx, PCPU(CURPROC) /* into next process */ + movl %ecx, PCPU(CURTHREAD) /* into next process */ #ifdef SMP /* XXX FIXME: we should be restoring the local APIC TPR */ #endif /* SMP */ - cmpl $0, PCB_USERLDT(%edx) - jnz 1f - movl _default_ldt,%eax - cmpl PCPU(CURRENTLDT),%eax - je 2f - lldt _default_ldt - movl %eax,PCPU(CURRENTLDT) + cmpl $0, PCB_USERLDT(%edx) /* if there is one */ + jnz 1f /* then use it */ + movl _default_ldt,%eax /* We will use the default */ + cmpl PCPU(CURRENTLDT),%eax /* check to see if already loaded */ + je 2f /* if so skip reload */ + lldt _default_ldt /* load the default... we trust it. */ + movl %eax,PCPU(CURRENTLDT) /* store what we have */ jmp 2f -1: pushl %edx - call set_user_ldt + +1: pushl %edx /* call a non-trusting routine */ + call set_user_ldt /* to check and load the ldt */ popl %edx 2: @@ -275,7 +283,7 @@ cpu_switch_load_gs: andl $0x0000fc00,%eax /* reserved bits */ pushl %ebx movl PCB_DR7(%edx),%ebx - andl $~0x0000fc00,%ebx + andl $~0x0000fc00,%ebx /* re-enable the restored watchpoints */ orl %ebx,%eax popl %ebx movl %eax,%dr7 @@ -322,25 +330,25 @@ ENTRY(savectx) #ifdef DEV_NPX /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the + * If npxthread == NULL, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps (the old book-keeping with FP flags in the pcb * always lost for dumps because the dump pcb has 0 flags). * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the + * If npxthread != NULL, then we have to save the npx h/w state to + * npxthread's pcb and copy it to the requested pcb, or save to the * requested pcb and reload. Copying is easier because we would * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ pushfl cli - movl PCPU(NPXPROC),%eax + movl PCPU(NPXTHREAD),%eax testl %eax,%eax je 1f pushl %ecx - movl P_ADDR(%eax),%eax + movl TD_PCB(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax pushl %eax diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index 23c1cdd..acca4e7 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -35,7 +35,7 @@ * */ -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -65,10 +65,10 @@ -static int i386_get_ldt __P((struct proc *, char *)); -static int i386_set_ldt __P((struct proc *, char *)); -static int i386_get_ioperm __P((struct proc *, char *)); -static int i386_set_ioperm __P((struct proc *, char *)); +static int i386_get_ldt __P((struct thread *, char *)); +static int i386_set_ldt __P((struct thread *, char *)); +static int i386_get_ioperm __P((struct thread *, char *)); +static int i386_set_ioperm __P((struct thread *, char *)); #ifdef SMP static void set_user_ldt_rv __P((struct pcb *)); #endif @@ -81,28 +81,28 @@ struct sysarch_args { #endif int -sysarch(p, uap) - struct proc *p; +sysarch(td, uap) + struct thread *td; register struct sysarch_args *uap; { int error = 0; switch(uap->op) { case I386_GET_LDT: - error = i386_get_ldt(p, uap->parms); + error = i386_get_ldt(td, uap->parms); break; case I386_SET_LDT: - error = i386_set_ldt(p, uap->parms); + error = i386_set_ldt(td, uap->parms); break; case I386_GET_IOPERM: - error = i386_get_ioperm(p, uap->parms); + error = i386_get_ioperm(td, uap->parms); break; case I386_SET_IOPERM: - error = i386_set_ioperm(p, uap->parms); + error = i386_set_ioperm(td, uap->parms); break; case I386_VM86: - error = vm86_sysarch(p, uap->parms); + error = vm86_sysarch(td, uap->parms); break; default: error = EOPNOTSUPP; @@ -112,7 +112,7 @@ sysarch(p, uap) } int -i386_extend_pcb(struct proc *p) +i386_extend_pcb(struct thread *td) { int i, offset; u_long *addr; @@ -127,12 +127,18 @@ i386_extend_pcb(struct proc *p) 0, /* default 32 size */ 0 /* granularity */ }; + struct proc *p = td->td_proc; + if (td->td_proc->p_flag & P_KSES) + return (EINVAL); /* XXXKSE */ +/* XXXKSE All the code below only works in 1:1 needs changing */ ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1)); if (ext == 0) return (ENOMEM); bzero(ext, sizeof(struct pcb_ext)); - ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16; + /* -16 is so we can convert a trapframe into vm86trapframe inplace */ + ext->ext_tss.tss_esp0 = td->td_kstack + ctob(KSTACK_PAGES) - + sizeof(struct pcb) - 16; ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); /* * The last byte of the i/o map must be followed by an 0xff byte. @@ -153,21 +159,21 @@ i386_extend_pcb(struct proc *p) ssd.ssd_limit -= ((unsigned)&ext->ext_tss - (unsigned)ext); ssdtosd(&ssd, &ext->ext_tssd); - KASSERT(p == curproc, ("giving a TSS to non-curproc")); - KASSERT(p->p_addr->u_pcb.pcb_ext == 0, ("already have a TSS!")); + KASSERT(p == curthread->td_proc, ("giving a TSS to non-curproc")); + KASSERT(td->td_pcb->pcb_ext == 0, ("already have a TSS!")); mtx_lock_spin(&sched_lock); - p->p_addr->u_pcb.pcb_ext = ext; + td->td_pcb->pcb_ext = ext; /* switch to the new TSS after syscall completes */ - p->p_sflag |= PS_NEEDRESCHED; + td->td_kse->ke_flags |= KEF_NEEDRESCHED; mtx_unlock_spin(&sched_lock); return 0; } static int -i386_set_ioperm(p, args) - struct proc *p; +i386_set_ioperm(td, args) + struct thread *td; char *args; { int i, error; @@ -177,7 +183,7 @@ i386_set_ioperm(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0) return (error); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); if (securelevel > 0) return (EPERM); @@ -188,10 +194,10 @@ i386_set_ioperm(p, args) * cause confusion. This probably requires a global 'usage registry'. */ - if (p->p_addr->u_pcb.pcb_ext == 0) - if ((error = i386_extend_pcb(p)) != 0) + if (td->td_pcb->pcb_ext == 0) + if ((error = i386_extend_pcb(td)) != 0) return (error); - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)td->td_pcb->pcb_ext->ext_iomap; if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); @@ -206,8 +212,8 @@ i386_set_ioperm(p, args) } static int -i386_get_ioperm(p, args) - struct proc *p; +i386_get_ioperm(td, args) + struct thread *td; char *args; { int i, state, error; @@ -219,12 +225,12 @@ i386_get_ioperm(p, args) if (ua.start >= IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); - if (p->p_addr->u_pcb.pcb_ext == 0) { + if (td->td_pcb->pcb_ext == 0) { ua.length = 0; goto done; } - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)td->td_pcb->pcb_ext->ext_iomap; i = ua.start; state = (iomap[i >> 3] >> (i & 7)) & 1; @@ -351,12 +357,12 @@ user_ldt_free(struct pcb *pcb) } static int -i386_get_ldt(p, args) - struct proc *p; +i386_get_ldt(td, args) + struct thread *td; char *args; { int error = 0; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; int nldt, num; union descriptor *lp; @@ -388,19 +394,19 @@ i386_get_ldt(p, args) error = copyout(lp, uap->descs, num * sizeof(union descriptor)); if (!error) - p->p_retval[0] = num; + td->td_retval[0] = num; return(error); } static int -i386_set_ldt(p, args) - struct proc *p; +i386_set_ldt(td, args) + struct thread *td; char *args; { int error = 0, i, n; int largest_ld; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; struct i386_ldt_args ua, *uap = &ua; caddr_t old_ldt_base; @@ -530,7 +536,7 @@ i386_set_ldt(p, args) &((union descriptor *)(pcb_ldt->ldt_base))[uap->start], uap->num * sizeof(union descriptor)); if (!error) - p->p_retval[0] = uap->start; + td->td_retval[0] = uap->start; critical_exit(savecrit); return(error); diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 4e72f9b..ee036c2 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -173,7 +173,8 @@ void trap(frame) struct trapframe frame; { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; u_int sticks = 0; int i = 0, ucode = 0, type, code; vm_offset_t eva; @@ -225,8 +226,8 @@ restart: ((frame.tf_eflags & PSL_VM) && !in_vm86call)) { /* user trap */ - sticks = p->p_sticks; - p->p_frame = &frame; + sticks = td->td_kse->ke_sticks; + td->td_frame = &frame; switch (type) { case T_PRIVINFLT: /* privileged instruction fault */ @@ -444,7 +445,7 @@ restart: if (in_vm86call) break; - if (p->p_intr_nesting_level != 0) + if (td->td_intr_nesting_level != 0) break; /* @@ -620,7 +621,7 @@ restart: #endif user: - userret(p, &frame, sticks); + userret(td, &frame, sticks); if (mtx_owned(&Giant)) /* XXX why would Giant be owned here? */ mtx_unlock(&Giant); out: @@ -660,7 +661,7 @@ trap_pfault(frame, usermode, eva) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (p->p_intr_nesting_level != 0 || + (td->td_intr_nesting_level != 0 || PCPU_GET(curpcb) == NULL || PCPU_GET(curpcb)->pcb_onfault == NULL))) { trap_fatal(frame, eva); @@ -696,7 +697,7 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) + if (!grow_stack (td, va)) rv = KERN_FAILURE; else /* Fault in the user page: */ @@ -728,7 +729,7 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (p->p_intr_nesting_level == 0 && + if (td->td_intr_nesting_level == 0 && PCPU_GET(curpcb) != NULL && PCPU_GET(curpcb)->pcb_onfault != NULL) { frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault; @@ -756,7 +757,8 @@ trap_pfault(frame, usermode, eva) vm_map_t map = 0; int rv = 0; vm_prot_t ftype; - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; va = trunc_page(eva); if (va >= KERNBASE) { @@ -839,7 +841,7 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (p->p_intr_nesting_level == 0 && + if (td->td_intr_nesting_level == 0 && PCPU_GET(curpcb) != NULL && PCPU_GET(curpcb)->pcb_onfault != NULL) { frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault; @@ -972,6 +974,7 @@ dblfault_handler() int trapwrite(addr) unsigned addr; { + struct thread *td; struct proc *p; vm_offset_t va; struct vmspace *vm; @@ -984,7 +987,8 @@ int trapwrite(addr) if (va >= VM_MAXUSER_ADDRESS) return (1); - p = curproc; + td = curthread; + p = td->td_proc; vm = p->p_vmspace; PROC_LOCK(p); @@ -1021,7 +1025,8 @@ syscall(frame) caddr_t params; int i; struct sysent *callp; - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; u_int sticks; int error; int narg; @@ -1039,8 +1044,8 @@ syscall(frame) } #endif - sticks = p->p_sticks; - p->p_frame = &frame; + sticks = td->td_kse->ke_sticks; + td->td_frame = &frame; params = (caddr_t)frame.tf_esp + sizeof(int); code = frame.tf_eax; @@ -1109,17 +1114,17 @@ syscall(frame) ktrsyscall(p->p_tracep, code, narg, args); } #endif - p->p_retval[0] = 0; - p->p_retval[1] = frame.tf_edx; + td->td_retval[0] = 0; + td->td_retval[1] = frame.tf_edx; STOPEVENT(p, S_SCE, narg); - error = (*callp->sy_call)(p, args); + error = (*callp->sy_call)(td, args); switch (error) { case 0: - frame.tf_eax = p->p_retval[0]; - frame.tf_edx = p->p_retval[1]; + frame.tf_eax = td->td_retval[0]; + frame.tf_edx = td->td_retval[1]; frame.tf_eflags &= ~PSL_C; break; @@ -1158,11 +1163,11 @@ bad: /* * Handle reschedule and other end-of-syscall issues */ - userret(p, &frame, sticks); + userret(td, &frame, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - ktrsysret(p->p_tracep, code, error, p->p_retval[0]); + ktrsysret(p->p_tracep, code, error, td->td_retval[0]); } #endif @@ -1183,7 +1188,7 @@ bad: STOPEVENT(p, S_SCX, code); #ifdef WITNESS - if (witness_list(p)) { + if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", syscallnames[code]); } diff --git a/sys/i386/i386/vm86.c b/sys/i386/i386/vm86.c index bf4a29a..bd7a0ca 100644 --- a/sys/i386/i386/vm86.c +++ b/sys/i386/i386/vm86.c @@ -655,10 +655,11 @@ vm86_getptr(vmc, kva, sel, off) } int -vm86_sysarch(p, args) - struct proc *p; +vm86_sysarch(td, args) + struct thread *td; char *args; { + struct proc *p = td->td_proc; int error = 0; struct i386_vm86_args ua; struct vm86_kernel *vm86; @@ -666,10 +667,10 @@ vm86_sysarch(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_vm86_args))) != 0) return (error); - if (p->p_addr->u_pcb.pcb_ext == 0) - if ((error = i386_extend_pcb(p)) != 0) + if (td->td_pcb->pcb_ext == 0) + if ((error = i386_extend_pcb(td)) != 0) return (error); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &td->td_pcb->pcb_ext->ext_vm86; switch (ua.sub_op) { case VM86_INIT: { diff --git a/sys/i386/i386/vm86bios.s b/sys/i386/i386/vm86bios.s index e12ac41..4cc0645 100644 --- a/sys/i386/i386/vm86bios.s +++ b/sys/i386/i386/vm86bios.s @@ -67,13 +67,13 @@ ENTRY(vm86_bioscall) #ifdef DEV_NPX pushfl cli - movl PCPU(CURPROC),%ecx - cmpl %ecx,PCPU(NPXPROC) /* do we need to save fp? */ + movl PCPU(CURTHREAD),%ecx + cmpl %ecx,PCPU(NPXTHREAD) /* do we need to save fp? */ jne 1f testl %ecx,%ecx je 1f /* no curproc/npxproc */ pushl %edx - movl P_ADDR(%ecx),%ecx + movl TD_PCB(%ecx),%ecx addl $PCB_SAVEFPU,%ecx pushl %ecx call npxsave diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 53cedff..83ddc21 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -47,7 +47,7 @@ #endif #include "opt_reset.h" #include "opt_isa.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -117,19 +117,24 @@ vm_fault_quick(v, prot) * ready to run and return to user mode. */ void -cpu_fork(p1, p2, flags) - register struct proc *p1, *p2; +cpu_fork(td1, p2, flags) + register struct thread *td1; + register struct proc *p2; int flags; { + register struct proc *p1; + struct thread *td2; struct pcb *pcb2; #ifdef DEV_NPX int savecrit; #endif + p1 = td1->td_proc; + td2 = &p2->p_thread; if ((flags & RFPROC) == 0) { if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = &p1->p_addr->u_pcb; + struct pcb *pcb1 = td1->td_pcb; struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt; if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) { pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len); @@ -145,30 +150,32 @@ cpu_fork(p1, p2, flags) /* Ensure that p1's pcb is up to date. */ #ifdef DEV_NPX - if (p1 == curproc) - p1->p_addr->u_pcb.pcb_gs = rgs(); + if (td1 == curthread) + td1->td_pcb->pcb_gs = rgs(); savecrit = critical_enter(); - if (PCPU_GET(npxproc) == p1) - npxsave(&p1->p_addr->u_pcb.pcb_save); + if (PCPU_GET(npxthread) == td1) + npxsave(&td1->td_pcb->pcb_save); critical_exit(savecrit); #endif + /* Point the pcb to the top of the stack */ + pcb2 = (struct pcb *)(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td2->td_pcb = pcb2; + /* Copy p1's pcb. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - pcb2 = &p2->p_addr->u_pcb; + bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); /* * Create a new fresh stack for the new process. * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ - p2->p_frame = (struct trapframe *) - ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1; - bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe)); + td2->td_frame = (struct trapframe *)td2->td_pcb - 1; + bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); - p2->p_frame->tf_eax = 0; /* Child returns zero */ - p2->p_frame->tf_eflags &= ~PSL_C; /* success */ - p2->p_frame->tf_edx = 1; + td2->td_frame->tf_eax = 0; /* Child returns zero */ + td2->td_frame->tf_eflags &= ~PSL_C; /* success */ + td2->td_frame->tf_edx = 1; /* * Set registers for trampoline to user mode. Leave space for the @@ -178,8 +185,8 @@ cpu_fork(p1, p2, flags) pcb2->pcb_edi = 0; pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */ pcb2->pcb_ebp = 0; - pcb2->pcb_esp = (int)p2->p_frame - sizeof(void *); - pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */ + pcb2->pcb_esp = (int)td2->td_frame - sizeof(void *); + pcb2->pcb_ebx = (int)td2; /* fork_trampoline argument */ pcb2->pcb_eip = (int)fork_trampoline; /*- * pcb2->pcb_dr*: cloned above. @@ -228,8 +235,8 @@ cpu_fork(p1, p2, flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(p, func, arg) - struct proc *p; +cpu_set_fork_handler(td, func, arg) + struct thread *td; void (*func) __P((void *)); void *arg; { @@ -237,18 +244,18 @@ cpu_set_fork_handler(p, func, arg) * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_addr->u_pcb.pcb_esi = (int) func; /* function */ - p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */ + td->td_pcb->pcb_esi = (int) func; /* function */ + td->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void -cpu_exit(p) - register struct proc *p; +cpu_exit(td) + register struct thread *td; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = td->td_pcb; #ifdef DEV_NPX - npxexit(p); + npxexit(td); #endif if (pcb->pcb_ext != 0) { /* @@ -280,25 +287,29 @@ cpu_wait(p) * Dump the machine specific header information at the start of a core dump. */ int -cpu_coredump(p, vp, cred) - struct proc *p; +cpu_coredump(td, vp, cred) + struct thread *td; struct vnode *vp; struct ucred *cred; { + struct proc *p = td->td_proc; int error; caddr_t tempuser; - tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK | M_ZERO); + tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, M_WAITOK | M_ZERO); if (!tempuser) return EINVAL; - bcopy(p->p_addr, tempuser, sizeof(struct user)); - bcopy(p->p_frame, - tempuser + ((caddr_t) p->p_frame - (caddr_t) p->p_addr), + bcopy(p->p_uarea, tempuser, sizeof(struct user)); +#if 0 /* XXXKSE - broken, fixme!!!!! td_frame is in kstack! */ + bcopy(td->td_frame, + tempuser + ((caddr_t) td->td_frame - (caddr_t) p->p_uarea), sizeof(struct trapframe)); +#endif - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UAREA_PAGES + KSTACK_PAGES), + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); free(tempuser, M_TEMP); diff --git a/sys/i386/ibcs2/ibcs2_fcntl.c b/sys/i386/ibcs2/ibcs2_fcntl.c index 971adce..6151c5d 100644 --- a/sys/i386/ibcs2/ibcs2_fcntl.c +++ b/sys/i386/ibcs2/ibcs2_fcntl.c @@ -169,73 +169,74 @@ oflags2ioflags(flags) } int -ibcs2_open(p, uap) - struct proc *p; +ibcs2_open(td, uap) + struct thread *td; struct ibcs2_open_args *uap; { + struct proc *p = td->td_proc; int noctty = SCARG(uap, flags) & IBCS2_O_NOCTTY; int ret; caddr_t sg = stackgap_init(); SCARG(uap, flags) = cvt_o_flags(SCARG(uap, flags)); if (SCARG(uap, flags) & O_CREAT) - CHECKALTCREAT(p, &sg, SCARG(uap, path)); + CHECKALTCREAT(td, &sg, SCARG(uap, path)); else - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - ret = open(p, (struct open_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + ret = open(td, (struct open_args *)uap); #ifdef SPX_HACK if (ret == ENXIO) { if (!strcmp(SCARG(uap, path), "/compat/ibcs2/dev/spx")) - ret = spx_open(p, uap); + ret = spx_open(td, uap); } else #endif /* SPX_HACK */ PROC_LOCK(p); if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; - struct file *fp = fdp->fd_ofiles[p->p_retval[0]]; + struct file *fp = fdp->fd_ofiles[td->td_retval[0]]; PROC_UNLOCK(p); /* ignore any error, just give it a try */ if (fp->f_type == DTYPE_VNODE) - fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); + fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); } else PROC_UNLOCK(p); return ret; } int -ibcs2_creat(p, uap) - struct proc *p; +ibcs2_creat(td, uap) + struct thread *td; struct ibcs2_creat_args *uap; { struct open_args cup; caddr_t sg = stackgap_init(); - CHECKALTCREAT(p, &sg, SCARG(uap, path)); + CHECKALTCREAT(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, mode) = SCARG(uap, mode); SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return open(p, &cup); + return open(td, &cup); } int -ibcs2_access(p, uap) - struct proc *p; +ibcs2_access(td, uap) + struct thread *td; struct ibcs2_access_args *uap; { struct access_args cup; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, flags) = SCARG(uap, flags); - return access(p, &cup); + return access(td, &cup); } int -ibcs2_fcntl(p, uap) - struct proc *p; +ibcs2_fcntl(td, uap) + struct thread *td; struct ibcs2_fcntl_args *uap; { int error; @@ -248,32 +249,32 @@ ibcs2_fcntl(p, uap) SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_DUPFD; SCARG(&fa, arg) = (/* XXX */ int)SCARG(uap, arg); - return fcntl(p, &fa); + return fcntl(td, &fa); case IBCS2_F_GETFD: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETFD; SCARG(&fa, arg) = (/* XXX */ int)SCARG(uap, arg); - return fcntl(p, &fa); + return fcntl(td, &fa); case IBCS2_F_SETFD: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETFD; SCARG(&fa, arg) = (/* XXX */ int)SCARG(uap, arg); - return fcntl(p, &fa); + return fcntl(td, &fa); case IBCS2_F_GETFL: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETFL; SCARG(&fa, arg) = (/* XXX */ int)SCARG(uap, arg); - error = fcntl(p, &fa); + error = fcntl(td, &fa); if (error) return error; - p->p_retval[0] = oflags2ioflags(p->p_retval[0]); + td->td_retval[0] = oflags2ioflags(td->td_retval[0]); return error; case IBCS2_F_SETFL: SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETFL; SCARG(&fa, arg) = (/* XXX */ int) ioflags2oflags((int)SCARG(uap, arg)); - return fcntl(p, &fa); + return fcntl(td, &fa); case IBCS2_F_GETLK: { @@ -287,7 +288,7 @@ ibcs2_fcntl(p, uap) SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_GETLK; SCARG(&fa, arg) = (/* XXX */ int)flp; - error = fcntl(p, &fa); + error = fcntl(td, &fa); if (error) return error; cvt_flock2iflock(flp, &ifl); @@ -308,7 +309,7 @@ ibcs2_fcntl(p, uap) SCARG(&fa, cmd) = F_SETLK; SCARG(&fa, arg) = (/* XXX */ int)flp; - return fcntl(p, &fa); + return fcntl(td, &fa); } case IBCS2_F_SETLKW: @@ -323,7 +324,7 @@ ibcs2_fcntl(p, uap) SCARG(&fa, fd) = SCARG(uap, fd); SCARG(&fa, cmd) = F_SETLKW; SCARG(&fa, arg) = (/* XXX */ int)flp; - return fcntl(p, &fa); + return fcntl(td, &fa); } } return ENOSYS; diff --git a/sys/i386/ibcs2/ibcs2_ioctl.c b/sys/i386/ibcs2/ibcs2_ioctl.c index 4dfa80b..39fdc99 100644 --- a/sys/i386/ibcs2/ibcs2_ioctl.c +++ b/sys/i386/ibcs2/ibcs2_ioctl.c @@ -57,7 +57,7 @@ static void stio2stios __P((struct ibcs2_termio *, struct ibcs2_termios *)); int -ibcs2_gtty(struct proc *p, struct ibcs2_gtty_args *args) +ibcs2_gtty(struct thread *td, struct ibcs2_gtty_args *args) { struct ioctl_args ioctl_arg; @@ -65,11 +65,11 @@ ibcs2_gtty(struct proc *p, struct ibcs2_gtty_args *args) ioctl_arg.com = TIOCGETC; ioctl_arg.data = (caddr_t)args->buf; - return ioctl(p, &ioctl_arg); + return ioctl(td, &ioctl_arg); } int -ibcs2_stty(struct proc *p, struct ibcs2_stty_args *args) +ibcs2_stty(struct thread *td, struct ibcs2_stty_args *args) { struct ioctl_args ioctl_arg; @@ -77,7 +77,7 @@ ibcs2_stty(struct proc *p, struct ibcs2_stty_args *args) ioctl_arg.com = TIOCSETC; ioctl_arg.data = (caddr_t)args->buf; - return ioctl(p, &ioctl_arg); + return ioctl(td, &ioctl_arg); } @@ -336,10 +336,11 @@ stio2stios(t, ts) } int -ibcs2_ioctl(p, uap) - struct proc *p; +ibcs2_ioctl(td, uap) + struct thread *td; struct ibcs2_ioctl_args *uap; { + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; int error; @@ -365,7 +366,7 @@ ibcs2_ioctl(p, uap) struct ibcs2_termios sts; struct ibcs2_termio st; - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) return error; btios2stios (&bts, &sts); @@ -401,7 +402,7 @@ ibcs2_ioctl(p, uap) } /* get full BSD termios so we don't lose information */ - if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) { + if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts, td)) != 0) { DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ", p->p_pid, SCARG(uap, fd))); return error; @@ -416,7 +417,7 @@ ibcs2_ioctl(p, uap) stios2btios(&sts, &bts); return fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA, - (caddr_t)&bts, p); + (caddr_t)&bts, td); } case IBCS2_XCSETA: @@ -432,7 +433,7 @@ ibcs2_ioctl(p, uap) } stios2btios (&sts, &bts); return fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA, - (caddr_t)&bts, p); + (caddr_t)&bts, td); } case IBCS2_OXCSETA: @@ -448,7 +449,7 @@ ibcs2_ioctl(p, uap) } stios2btios (&sts, &bts); return fo_ioctl(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA, - (caddr_t)&bts, p); + (caddr_t)&bts, td); } case IBCS2_TCSBRK: @@ -463,9 +464,9 @@ ibcs2_ioctl(p, uap) DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid)); return ENOSYS; case 2: - return fo_ioctl(fp, TIOCSTOP, (caddr_t)0, p); + return fo_ioctl(fp, TIOCSTOP, (caddr_t)0, td); case 3: - return fo_ioctl(fp, TIOCSTART, (caddr_t)1, p); + return fo_ioctl(fp, TIOCSTART, (caddr_t)1, td); default: return EINVAL; } @@ -488,16 +489,16 @@ ibcs2_ioctl(p, uap) default: return EINVAL; } - return fo_ioctl(fp, TIOCFLUSH, (caddr_t)&arg, p); + return fo_ioctl(fp, TIOCFLUSH, (caddr_t)&arg, td); } case IBCS2_TIOCGWINSZ: SCARG(uap, cmd) = TIOCGWINSZ; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_TIOCSWINSZ: SCARG(uap, cmd) = TIOCSWINSZ; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_TIOCGPGRP: PROC_LOCK(p); @@ -512,7 +513,7 @@ ibcs2_ioctl(p, uap) SCARG(&sa, pid) = 0; SCARG(&sa, pgid) = (int)SCARG(uap, data); - if ((error = setpgid(p, &sa)) != 0) + if ((error = setpgid(td, &sa)) != 0) return error; return 0; } @@ -548,96 +549,96 @@ ibcs2_ioctl(p, uap) case IBCS2_KDGKBMODE: /* get keyboard translation mode */ SCARG(uap, cmd) = KDGKBMODE; /* printf("ioctl KDGKBMODE = %x\n", SCARG(uap, cmd));*/ - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDSKBMODE: /* set keyboard translation mode */ SCARG(uap, cmd) = KDSKBMODE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDMKTONE: /* sound tone */ SCARG(uap, cmd) = KDMKTONE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDGETMODE: /* get text/graphics mode */ SCARG(uap, cmd) = KDGETMODE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDSETMODE: /* set text/graphics mode */ SCARG(uap, cmd) = KDSETMODE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDSBORDER: /* set ega color border */ SCARG(uap, cmd) = KDSBORDER; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDGKBSTATE: SCARG(uap, cmd) = KDGKBSTATE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDSETRAD: SCARG(uap, cmd) = KDSETRAD; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDENABIO: /* enable direct I/O to ports */ SCARG(uap, cmd) = KDENABIO; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDDISABIO: /* disable direct I/O to ports */ SCARG(uap, cmd) = KDDISABIO; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KIOCSOUND: /* start sound generation */ SCARG(uap, cmd) = KIOCSOUND; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDGKBTYPE: /* get keyboard type */ SCARG(uap, cmd) = KDGKBTYPE; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDGETLED: /* get keyboard LED status */ SCARG(uap, cmd) = KDGETLED; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_KDSETLED: /* set keyboard LED status */ SCARG(uap, cmd) = KDSETLED; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); /* Xenix keyboard and display ioctl's from sys/kd.h -- type 'k' */ case IBCS2_GETFKEY: /* Get function key */ SCARG(uap, cmd) = GETFKEY; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_SETFKEY: /* Set function key */ SCARG(uap, cmd) = SETFKEY; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_GIO_SCRNMAP: /* Get screen output map table */ SCARG(uap, cmd) = GIO_SCRNMAP; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_PIO_SCRNMAP: /* Set screen output map table */ SCARG(uap, cmd) = PIO_SCRNMAP; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_GIO_KEYMAP: /* Get keyboard map table */ SCARG(uap, cmd) = GIO_KEYMAP; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); case IBCS2_PIO_KEYMAP: /* Set keyboard map table */ SCARG(uap, cmd) = PIO_KEYMAP; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); /* socksys */ case IBCS2_SIOCSOCKSYS: - return ibcs2_socksys(p, (struct ibcs2_socksys_args *)uap); + return ibcs2_socksys(td, (struct ibcs2_socksys_args *)uap); case IBCS2_I_NREAD: /* STREAMS */ SCARG(uap, cmd) = FIONREAD; - return ioctl(p, (struct ioctl_args *)uap); + return ioctl(td, (struct ioctl_args *)uap); default: DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ", - p->p_pid, SCARG(uap, cmd))); + td->proc->p_pid, SCARG(uap, cmd))); return ENOSYS; } return ENOSYS; diff --git a/sys/i386/ibcs2/ibcs2_ipc.c b/sys/i386/ibcs2/ibcs2_ipc.c index 2acf3d2..804f82d 100644 --- a/sys/i386/ibcs2/ibcs2_ipc.c +++ b/sys/i386/ibcs2/ibcs2_ipc.c @@ -102,14 +102,14 @@ struct msqid_ds *bp; } int -ibcs2_msgsys(p, uap) - struct proc *p; +ibcs2_msgsys(td, uap) + struct thread *td; struct ibcs2_msgsys_args *uap; { switch (SCARG(uap, which)) { case 0: /* msgget */ SCARG(uap, which) = 1; - return msgsys(p, (struct msgsys_args *)uap); + return msgsys(td, (struct msgsys_args *)uap); case 1: { /* msgctl */ int error; struct msgsys_args margs; @@ -122,7 +122,7 @@ ibcs2_msgsys(p, uap) SCARG(&margs, a3) = SCARG(uap, a3); switch (SCARG(&margs, a3)) { case IBCS2_IPC_STAT: - error = msgsys(p, &margs); + error = msgsys(td, &margs); if (!error) cvt_msqid2imsqid( (struct msqid_ds *)SCARG(&margs, a4), @@ -132,18 +132,18 @@ ibcs2_msgsys(p, uap) cvt_imsqid2msqid((struct ibcs2_msqid_ds *)SCARG(uap, a4), (struct msqid_ds *)SCARG(&margs, a4)); - return msgsys(p, &margs); + return msgsys(td, &margs); case IBCS2_IPC_RMID: - return msgsys(p, &margs); + return msgsys(td, &margs); } return EINVAL; } case 2: /* msgrcv */ SCARG(uap, which) = 3; - return msgsys(p, (struct msgsys_args *)uap); + return msgsys(td, (struct msgsys_args *)uap); case 3: /* msgsnd */ SCARG(uap, which) = 2; - return msgsys(p, (struct msgsys_args *)uap); + return msgsys(td, (struct msgsys_args *)uap); default: return EINVAL; } @@ -233,8 +233,8 @@ struct semid_ds *bp; } int -ibcs2_semsys(p, uap) - struct proc *p; +ibcs2_semsys(td, uap) + struct thread *td; struct ibcs2_semsys_args *uap; { int error; @@ -255,7 +255,7 @@ ibcs2_semsys(p, uap) sup = stackgap_alloc(&sg, sizeof(union semun)); sup->buf = sp; SCARG(uap, a5) = (int)sup; - error = semsys(p, (struct semsys_args *)uap); + error = semsys(td, (struct semsys_args *)uap); if (!error) { SCARG(uap, a5) = (int)ssu.buf; isp = stackgap_alloc(&sg, sizeof(*isp)); @@ -280,7 +280,7 @@ ibcs2_semsys(p, uap) return error; cvt_isemid2semid(isp, sp); SCARG(uap, a5) = (int)sp; - return semsys(p, (struct semsys_args *)uap); + return semsys(td, (struct semsys_args *)uap); } case IBCS2_SETVAL: { @@ -290,17 +290,17 @@ ibcs2_semsys(p, uap) sp = stackgap_alloc(&sg, sizeof(*sp)); sp->val = (int) SCARG(uap, a5); SCARG(uap, a5) = (int)sp; - return semsys(p, (struct semsys_args *)uap); + return semsys(td, (struct semsys_args *)uap); } } - return semsys(p, (struct semsys_args *)uap); + return semsys(td, (struct semsys_args *)uap); case 1: /* semget */ - return semsys(p, (struct semsys_args *)uap); + return semsys(td, (struct semsys_args *)uap); case 2: /* semop */ - return semsys(p, (struct semsys_args *)uap); + return semsys(td, (struct semsys_args *)uap); } return EINVAL; } @@ -345,15 +345,15 @@ struct shmid_ds *bp; } int -ibcs2_shmsys(p, uap) - struct proc *p; +ibcs2_shmsys(td, uap) + struct thread *td; struct ibcs2_shmsys_args *uap; { int error; switch (SCARG(uap, which)) { case 0: /* shmat */ - return shmsys(p, (struct shmsys_args *)uap); + return shmsys(td, (struct shmsys_args *)uap); case 1: /* shmctl */ switch(SCARG(uap, a3)) { @@ -366,7 +366,7 @@ ibcs2_shmsys(p, uap) isp = (struct ibcs2_shmid_ds *)SCARG(uap, a4); sp = stackgap_alloc(&sg, sizeof(*sp)); SCARG(uap, a4) = (int)sp; - error = shmsys(p, (struct shmsys_args *)uap); + error = shmsys(td, (struct shmsys_args *)uap); if (!error) { SCARG(uap, a4) = (int)isp; isp = stackgap_alloc(&sg, sizeof(*isp)); @@ -391,17 +391,17 @@ ibcs2_shmsys(p, uap) return error; cvt_ishmid2shmid(isp, sp); SCARG(uap, a4) = (int)sp; - return shmsys(p, (struct shmsys_args *)uap); + return shmsys(td, (struct shmsys_args *)uap); } } - return shmsys(p, (struct shmsys_args *)uap); + return shmsys(td, (struct shmsys_args *)uap); case 2: /* shmdt */ - return shmsys(p, (struct shmsys_args *)uap); + return shmsys(td, (struct shmsys_args *)uap); case 3: /* shmget */ - return shmsys(p, (struct shmsys_args *)uap); + return shmsys(td, (struct shmsys_args *)uap); } return EINVAL; } diff --git a/sys/i386/ibcs2/ibcs2_isc.c b/sys/i386/ibcs2/ibcs2_isc.c index 9c690c9..31ebd0a 100644 --- a/sys/i386/ibcs2/ibcs2_isc.c +++ b/sys/i386/ibcs2/ibcs2_isc.c @@ -45,9 +45,9 @@ extern struct sysent isc_sysent[]; int -ibcs2_isc(struct proc *p, struct ibcs2_isc_args *uap) +ibcs2_isc(struct thread *td, struct ibcs2_isc_args *uap) { - struct trapframe *tf = p->p_frame; + struct trapframe *tf = td->td_frame; struct sysent *callp; u_int code; @@ -55,7 +55,7 @@ ibcs2_isc(struct proc *p, struct ibcs2_isc_args *uap) callp = &isc_sysent[code]; if(code < IBCS2_ISC_MAXSYSCALL) - return((*callp->sy_call)(p, (void *)uap)); + return((*callp->sy_call)(td, (void *)uap)); else return ENOSYS; } diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index c2e28b9..bbe32eb 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -85,8 +85,8 @@ #include <i386/ibcs2/ibcs2_xenix.h> int -ibcs2_ulimit(p, uap) - struct proc *p; +ibcs2_ulimit(td, uap) + struct thread *td; struct ibcs2_ulimit_args *uap; { #ifdef notyet @@ -104,31 +104,31 @@ ibcs2_ulimit(p, uap) switch (SCARG(uap, cmd)) { case IBCS2_GETFSIZE: - p->p_retval[0] = p->p_rlimit[RLIMIT_FSIZE].rlim_cur; - if (p->p_retval[0] == -1) p->p_retval[0] = 0x7fffffff; + td->td_retval[0] = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur; + if (td->td_retval[0] == -1) td->td_retval[0] = 0x7fffffff; return 0; case IBCS2_SETFSIZE: /* XXX - fix this */ #ifdef notyet rl.rlim_cur = SCARG(uap, newlimit); sra.resource = RLIMIT_FSIZE; sra.rlp = &rl; - error = setrlimit(p, &sra); + error = setrlimit(td, &sra); if (!error) - p->p_retval[0] = p->p_rlimit[RLIMIT_FSIZE].rlim_cur; + td->td_retval[0] = td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur; else DPRINTF(("failed ")); return error; #else - p->p_retval[0] = SCARG(uap, newlimit); + td->td_retval[0] = SCARG(uap, newlimit); return 0; #endif case IBCS2_GETPSIZE: mtx_assert(&Giant, MA_OWNED); - p->p_retval[0] = p->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */ + td->td_retval[0] = td->td_proc->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */ return 0; case IBCS2_GETDTABLESIZE: uap->cmd = IBCS2_SC_OPEN_MAX; - return ibcs2_sysconf(p, (struct ibcs2_sysconf_args *)uap); + return ibcs2_sysconf(td, (struct ibcs2_sysconf_args *)uap); default: return ENOSYS; } @@ -137,13 +137,13 @@ ibcs2_ulimit(p, uap) #define IBCS2_WSTOPPED 0177 #define IBCS2_STOPCODE(sig) ((sig) << 8 | IBCS2_WSTOPPED) int -ibcs2_wait(p, uap) - struct proc *p; +ibcs2_wait(td, uap) + struct thread *td; struct ibcs2_wait_args *uap; { int error, status; struct wait_args w4; - struct trapframe *tf = p->p_frame; + struct trapframe *tf = td->td_frame; SCARG(&w4, rusage) = NULL; if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V)) @@ -158,7 +158,7 @@ ibcs2_wait(p, uap) SCARG(&w4, status) = (int *)SCARG(uap, a1); SCARG(&w4, options) = 0; } - if ((error = wait4(p, &w4)) != 0) + if ((error = wait4(td, &w4)) != 0) return error; if (SCARG(&w4, status)) { /* this is real iBCS brain-damage */ error = copyin((caddr_t)SCARG(&w4, status), (caddr_t)&status, @@ -175,7 +175,7 @@ ibcs2_wait(p, uap) /* else exit status -- identical */ /* record result/status */ - p->p_retval[1] = status; + td->td_retval[1] = status; return copyout((caddr_t)&status, (caddr_t)SCARG(&w4, status), sizeof(SCARG(&w4, status))); } @@ -184,45 +184,45 @@ ibcs2_wait(p, uap) } int -ibcs2_execv(p, uap) - struct proc *p; +ibcs2_execv(td, uap) + struct thread *td; struct ibcs2_execv_args *uap; { struct execve_args ea; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&ea, fname) = SCARG(uap, path); SCARG(&ea, argv) = SCARG(uap, argp); SCARG(&ea, envv) = NULL; - return execve(p, &ea); + return execve(td, &ea); } int -ibcs2_execve(p, uap) - struct proc *p; +ibcs2_execve(td, uap) + struct thread *td; struct ibcs2_execve_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return execve(p, (struct execve_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return execve(td, (struct execve_args *)uap); } int -ibcs2_umount(p, uap) - struct proc *p; +ibcs2_umount(td, uap) + struct thread *td; struct ibcs2_umount_args *uap; { struct unmount_args um; SCARG(&um, path) = SCARG(uap, name); SCARG(&um, flags) = 0; - return unmount(p, &um); + return unmount(td, &um); } int -ibcs2_mount(p, uap) - struct proc *p; +ibcs2_mount(td, uap) + struct thread *td; struct ibcs2_mount_args *uap; { #ifdef notyet @@ -279,7 +279,7 @@ ibcs2_mount(p, uap) if (error = copyout(&na, SCARG(uap, data), sizeof na)) return (error); } - return (mount(p, uap)); + return (mount(td, uap)); #else return EINVAL; #endif @@ -294,8 +294,8 @@ ibcs2_mount(p, uap) */ int -ibcs2_getdents(p, uap) - struct proc *p; +ibcs2_getdents(td, uap) + struct thread *td; register struct ibcs2_getdents_args *uap; { register struct vnode *vp; @@ -314,7 +314,7 @@ ibcs2_getdents(p, uap) #define BSD_DIRENT(cp) ((struct dirent *)(cp)) #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short)) - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) return (EBADF); @@ -327,7 +327,7 @@ ibcs2_getdents(p, uap) buflen = max(DIRBLKSIZ, SCARG(uap, nbytes)); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; @@ -335,7 +335,7 @@ again: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = buflen; auio.uio_offset = off; @@ -425,18 +425,18 @@ again: goto again; fp->f_offset = off; /* update the vnode offset */ eof: - p->p_retval[0] = SCARG(uap, nbytes) - resid; + td->td_retval[0] = SCARG(uap, nbytes) - resid; out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } int -ibcs2_read(p, uap) - struct proc *p; +ibcs2_read(td, uap) + struct thread *td; struct ibcs2_read_args *uap; { register struct vnode *vp; @@ -456,9 +456,9 @@ ibcs2_read(p, uap) u_long *cookies = NULL, *cookiep; int ncookies; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) { + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) { if (error == EINVAL) - return read(p, (struct read_args *)uap); + return read(td, (struct read_args *)uap); else return error; } @@ -466,7 +466,7 @@ ibcs2_read(p, uap) return (EBADF); vp = (struct vnode *)fp->f_data; if (vp->v_type != VDIR) - return read(p, (struct read_args *)uap); + return read(td, (struct read_args *)uap); DPRINTF(("ibcs2_read: read directory\n")); @@ -474,7 +474,7 @@ ibcs2_read(p, uap) buflen = max(DIRBLKSIZ, SCARG(uap, nbytes)); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; @@ -482,7 +482,7 @@ again: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = buflen; auio.uio_offset = off; @@ -576,40 +576,40 @@ again: goto again; fp->f_offset = off; /* update the vnode offset */ eof: - p->p_retval[0] = SCARG(uap, nbytes) - resid; + td->td_retval[0] = SCARG(uap, nbytes) - resid; out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } int -ibcs2_mknod(p, uap) - struct proc *p; +ibcs2_mknod(td, uap) + struct thread *td; struct ibcs2_mknod_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTCREAT(p, &sg, SCARG(uap, path)); + CHECKALTCREAT(td, &sg, SCARG(uap, path)); if (S_ISFIFO(SCARG(uap, mode))) { struct mkfifo_args ap; SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, mode) = SCARG(uap, mode); - return mkfifo(p, &ap); + return mkfifo(td, &ap); } else { struct mknod_args ap; SCARG(&ap, path) = SCARG(uap, path); SCARG(&ap, mode) = SCARG(uap, mode); SCARG(&ap, dev) = SCARG(uap, dev); - return mknod(p, &ap); + return mknod(td, &ap); } } int -ibcs2_getgroups(p, uap) - struct proc *p; +ibcs2_getgroups(td, uap) + struct thread *td; struct ibcs2_getgroups_args *uap; { int error, i; @@ -625,23 +625,23 @@ ibcs2_getgroups(p, uap) iset = stackgap_alloc(&sg, SCARG(uap, gidsetsize) * sizeof(ibcs2_gid_t)); } - if ((error = getgroups(p, &sa)) != 0) + if ((error = getgroups(td, &sa)) != 0) return error; if (SCARG(uap, gidsetsize) == 0) return 0; - for (i = 0, gp = SCARG(&sa, gidset); i < p->p_retval[0]; i++) + for (i = 0, gp = SCARG(&sa, gidset); i < td->td_retval[0]; i++) iset[i] = (ibcs2_gid_t)*gp++; - if (p->p_retval[0] && (error = copyout((caddr_t)iset, + if (td->td_retval[0] && (error = copyout((caddr_t)iset, (caddr_t)SCARG(uap, gidset), - sizeof(ibcs2_gid_t) * p->p_retval[0]))) + sizeof(ibcs2_gid_t) * td->td_retval[0]))) return error; return 0; } int -ibcs2_setgroups(p, uap) - struct proc *p; +ibcs2_setgroups(td, uap) + struct thread *td; struct ibcs2_setgroups_args *uap; { int error, i; @@ -663,40 +663,40 @@ ibcs2_setgroups(p, uap) } for (i = 0, gp = SCARG(&sa, gidset); i < SCARG(&sa, gidsetsize); i++) *gp++ = (gid_t)iset[i]; - return setgroups(p, &sa); + return setgroups(td, &sa); } int -ibcs2_setuid(p, uap) - struct proc *p; +ibcs2_setuid(td, uap) + struct thread *td; struct ibcs2_setuid_args *uap; { struct setuid_args sa; SCARG(&sa, uid) = (uid_t)SCARG(uap, uid); - return setuid(p, &sa); + return setuid(td, &sa); } int -ibcs2_setgid(p, uap) - struct proc *p; +ibcs2_setgid(td, uap) + struct thread *td; struct ibcs2_setgid_args *uap; { struct setgid_args sa; SCARG(&sa, gid) = (gid_t)SCARG(uap, gid); - return setgid(p, &sa); + return setgid(td, &sa); } int -ibcs2_time(p, uap) - struct proc *p; +ibcs2_time(td, uap) + struct thread *td; struct ibcs2_time_args *uap; { struct timeval tv; microtime(&tv); - p->p_retval[0] = tv.tv_sec; + td->td_retval[0] = tv.tv_sec; if (SCARG(uap, tp)) return copyout((caddr_t)&tv.tv_sec, (caddr_t)SCARG(uap, tp), sizeof(ibcs2_time_t)); @@ -705,26 +705,26 @@ ibcs2_time(p, uap) } int -ibcs2_pathconf(p, uap) - struct proc *p; +ibcs2_pathconf(td, uap) + struct thread *td; struct ibcs2_pathconf_args *uap; { SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */ - return pathconf(p, (struct pathconf_args *)uap); + return pathconf(td, (struct pathconf_args *)uap); } int -ibcs2_fpathconf(p, uap) - struct proc *p; +ibcs2_fpathconf(td, uap) + struct thread *td; struct ibcs2_fpathconf_args *uap; { SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */ - return fpathconf(p, (struct fpathconf_args *)uap); + return fpathconf(td, (struct fpathconf_args *)uap); } int -ibcs2_sysconf(p, uap) - struct proc *p; +ibcs2_sysconf(td, uap) + struct thread *td; struct ibcs2_sysconf_args *uap; { int mib[2], value, len, error; @@ -742,14 +742,14 @@ ibcs2_sysconf(p, uap) SCARG(&ga, which) = RLIMIT_NPROC; SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *)); - if ((error = getrlimit(p, &ga)) != 0) + if ((error = getrlimit(td, &ga)) != 0) return error; - p->p_retval[0] = SCARG(&ga, rlp)->rlim_cur; + td->td_retval[0] = SCARG(&ga, rlp)->rlim_cur; return 0; } case IBCS2_SC_CLK_TCK: - p->p_retval[0] = hz; + td->td_retval[0] = hz; return 0; case IBCS2_SC_NGROUPS_MAX: @@ -762,9 +762,9 @@ ibcs2_sysconf(p, uap) SCARG(&ga, which) = RLIMIT_NOFILE; SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *)); - if ((error = getrlimit(p, &ga)) != 0) + if ((error = getrlimit(td, &ga)) != 0) return error; - p->p_retval[0] = SCARG(&ga, rlp)->rlim_cur; + td->td_retval[0] = SCARG(&ga, rlp)->rlim_cur; return 0; } @@ -781,11 +781,11 @@ ibcs2_sysconf(p, uap) break; case IBCS2_SC_PASS_MAX: - p->p_retval[0] = 128; /* XXX - should we create PASS_MAX ? */ + td->td_retval[0] = 128; /* XXX - should we create PASS_MAX ? */ return 0; case IBCS2_SC_XOPEN_VERSION: - p->p_retval[0] = 2; /* XXX: What should that be? */ + td->td_retval[0] = 2; /* XXX: What should that be? */ return 0; default: @@ -800,15 +800,15 @@ ibcs2_sysconf(p, uap) SCARG(&sa, oldlenp) = &len; SCARG(&sa, new) = NULL; SCARG(&sa, newlen) = 0; - if ((error = __sysctl(p, &sa)) != 0) + if ((error = __sysctl(td, &sa)) != 0) return error; - p->p_retval[0] = value; + td->td_retval[0] = value; return 0; } int -ibcs2_alarm(p, uap) - struct proc *p; +ibcs2_alarm(td, uap) + struct thread *td; struct ibcs2_alarm_args *uap; { int error; @@ -825,18 +825,18 @@ ibcs2_alarm(p, uap) SCARG(&sa, which) = ITIMER_REAL; SCARG(&sa, itv) = itp; SCARG(&sa, oitv) = oitp; - error = setitimer(p, &sa); + error = setitimer(td, &sa); if (error) return error; if (oitp->it_value.tv_usec) oitp->it_value.tv_sec++; - p->p_retval[0] = oitp->it_value.tv_sec; + td->td_retval[0] = oitp->it_value.tv_sec; return 0; } int -ibcs2_times(p, uap) - struct proc *p; +ibcs2_times(td, uap) + struct thread *td; struct ibcs2_times_args *uap; { int error; @@ -849,29 +849,29 @@ ibcs2_times(p, uap) SCARG(&ga, who) = RUSAGE_SELF; SCARG(&ga, rusage) = ru; - error = getrusage(p, &ga); + error = getrusage(td, &ga); if (error) return error; tms.tms_utime = CONVTCK(ru->ru_utime); tms.tms_stime = CONVTCK(ru->ru_stime); SCARG(&ga, who) = RUSAGE_CHILDREN; - error = getrusage(p, &ga); + error = getrusage(td, &ga); if (error) return error; tms.tms_cutime = CONVTCK(ru->ru_utime); tms.tms_cstime = CONVTCK(ru->ru_stime); microtime(&t); - p->p_retval[0] = CONVTCK(t); + td->td_retval[0] = CONVTCK(t); return copyout((caddr_t)&tms, (caddr_t)SCARG(uap, tp), sizeof(struct tms)); } int -ibcs2_stime(p, uap) - struct proc *p; +ibcs2_stime(td, uap) + struct thread *td; struct ibcs2_stime_args *uap; { int error; @@ -884,14 +884,14 @@ ibcs2_stime(p, uap) &(SCARG(&sa, tv)->tv_sec), sizeof(long))) != 0) return error; SCARG(&sa, tv)->tv_usec = 0; - if ((error = settimeofday(p, &sa)) != 0) + if ((error = settimeofday(td, &sa)) != 0) return EPERM; return 0; } int -ibcs2_utime(p, uap) - struct proc *p; +ibcs2_utime(td, uap) + struct thread *td; struct ibcs2_utime_args *uap; { int error; @@ -899,7 +899,7 @@ ibcs2_utime(p, uap) struct timeval *tp; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&sa, path) = SCARG(uap, path); if (SCARG(uap, buf)) { struct ibcs2_utimbuf ubuf; @@ -917,12 +917,12 @@ ibcs2_utime(p, uap) tp->tv_usec = 0; } else SCARG(&sa, tptr) = NULL; - return utimes(p, &sa); + return utimes(td, &sa); } int -ibcs2_nice(p, uap) - struct proc *p; +ibcs2_nice(td, uap) + struct thread *td; struct ibcs2_nice_args *uap; { int error; @@ -930,10 +930,10 @@ ibcs2_nice(p, uap) SCARG(&sa, which) = PRIO_PROCESS; SCARG(&sa, who) = 0; - SCARG(&sa, prio) = p->p_nice + SCARG(uap, incr); - if ((error = setpriority(p, &sa)) != 0) + SCARG(&sa, prio) = td->td_ksegrp->kg_nice + SCARG(uap, incr); + if ((error = setpriority(td, &sa)) != 0) return EPERM; - p->p_retval[0] = p->p_nice; + td->td_retval[0] = td->td_ksegrp->kg_nice; return 0; } @@ -942,14 +942,15 @@ ibcs2_nice(p, uap) */ int -ibcs2_pgrpsys(p, uap) - struct proc *p; +ibcs2_pgrpsys(td, uap) + struct thread *td; struct ibcs2_pgrpsys_args *uap; { + struct proc *p = td->td_proc; switch (SCARG(uap, type)) { case 0: /* getpgrp */ PROC_LOCK(p); - p->p_retval[0] = p->p_pgrp->pg_id; + td->td_retval[0] = p->p_pgrp->pg_id; PROC_UNLOCK(p); return 0; @@ -959,9 +960,9 @@ ibcs2_pgrpsys(p, uap) SCARG(&sa, pid) = 0; SCARG(&sa, pgid) = 0; - setpgid(p, &sa); + setpgid(td, &sa); PROC_LOCK(p); - p->p_retval[0] = p->p_pgrp->pg_id; + td->td_retval[0] = p->p_pgrp->pg_id; PROC_UNLOCK(p); return 0; } @@ -972,11 +973,11 @@ ibcs2_pgrpsys(p, uap) SCARG(&sa, pid) = SCARG(uap, pid); SCARG(&sa, pgid) = SCARG(uap, pgid); - return setpgid(p, &sa); + return setpgid(td, &sa); } case 3: /* setsid */ - return setsid(p, NULL); + return setsid(td, NULL); default: return EINVAL; @@ -988,8 +989,8 @@ ibcs2_pgrpsys(p, uap) */ int -ibcs2_plock(p, uap) - struct proc *p; +ibcs2_plock(td, uap) + struct thread *td; struct ibcs2_plock_args *uap; { int error; @@ -999,7 +1000,7 @@ ibcs2_plock(p, uap) #define IBCS2_DATALOCK 4 - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return EPERM; switch(SCARG(uap, cmd)) { case IBCS2_UNLOCK: @@ -1012,8 +1013,8 @@ ibcs2_plock(p, uap) } int -ibcs2_uadmin(p, uap) - struct proc *p; +ibcs2_uadmin(td, uap) + struct thread *td; struct ibcs2_uadmin_args *uap; { #define SCO_A_REBOOT 1 @@ -1034,7 +1035,7 @@ ibcs2_uadmin(p, uap) #define SCO_AD_GETBMAJ 0 #define SCO_AD_GETCMAJ 1 - if (suser(p)) + if (suser_td(td)) return EPERM; switch(SCARG(uap, cmd)) { @@ -1046,11 +1047,11 @@ ibcs2_uadmin(p, uap) case SCO_AD_PWRDOWN: case SCO_AD_PWRNAP: r.opt = RB_HALT; - reboot(p, &r); + reboot(td, &r); case SCO_AD_BOOT: case SCO_AD_IBOOT: r.opt = RB_AUTOBOOT; - reboot(p, &r); + reboot(td, &r); } return EINVAL; case SCO_A_REMOUNT: @@ -1064,8 +1065,8 @@ ibcs2_uadmin(p, uap) } int -ibcs2_sysfs(p, uap) - struct proc *p; +ibcs2_sysfs(td, uap) + struct thread *td; struct ibcs2_sysfs_args *uap; { #define IBCS2_GETFSIND 1 @@ -1082,102 +1083,102 @@ ibcs2_sysfs(p, uap) } int -ibcs2_unlink(p, uap) - struct proc *p; +ibcs2_unlink(td, uap) + struct thread *td; struct ibcs2_unlink_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return unlink(p, (struct unlink_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return unlink(td, (struct unlink_args *)uap); } int -ibcs2_chdir(p, uap) - struct proc *p; +ibcs2_chdir(td, uap) + struct thread *td; struct ibcs2_chdir_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return chdir(p, (struct chdir_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return chdir(td, (struct chdir_args *)uap); } int -ibcs2_chmod(p, uap) - struct proc *p; +ibcs2_chmod(td, uap) + struct thread *td; struct ibcs2_chmod_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return chmod(p, (struct chmod_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return chmod(td, (struct chmod_args *)uap); } int -ibcs2_chown(p, uap) - struct proc *p; +ibcs2_chown(td, uap) + struct thread *td; struct ibcs2_chown_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return chown(p, (struct chown_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return chown(td, (struct chown_args *)uap); } int -ibcs2_rmdir(p, uap) - struct proc *p; +ibcs2_rmdir(td, uap) + struct thread *td; struct ibcs2_rmdir_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return rmdir(p, (struct rmdir_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return rmdir(td, (struct rmdir_args *)uap); } int -ibcs2_mkdir(p, uap) - struct proc *p; +ibcs2_mkdir(td, uap) + struct thread *td; struct ibcs2_mkdir_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTCREAT(p, &sg, SCARG(uap, path)); - return mkdir(p, (struct mkdir_args *)uap); + CHECKALTCREAT(td, &sg, SCARG(uap, path)); + return mkdir(td, (struct mkdir_args *)uap); } int -ibcs2_symlink(p, uap) - struct proc *p; +ibcs2_symlink(td, uap) + struct thread *td; struct ibcs2_symlink_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - CHECKALTCREAT(p, &sg, SCARG(uap, link)); - return symlink(p, (struct symlink_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + CHECKALTCREAT(td, &sg, SCARG(uap, link)); + return symlink(td, (struct symlink_args *)uap); } int -ibcs2_rename(p, uap) - struct proc *p; +ibcs2_rename(td, uap) + struct thread *td; struct ibcs2_rename_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, from)); - CHECKALTCREAT(p, &sg, SCARG(uap, to)); - return rename(p, (struct rename_args *)uap); + CHECKALTEXIST(td, &sg, SCARG(uap, from)); + CHECKALTCREAT(td, &sg, SCARG(uap, to)); + return rename(td, (struct rename_args *)uap); } int -ibcs2_readlink(p, uap) - struct proc *p; +ibcs2_readlink(td, uap) + struct thread *td; struct ibcs2_readlink_args *uap; { caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - return readlink(p, (struct readlink_args *) uap); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + return readlink(td, (struct readlink_args *) uap); } diff --git a/sys/i386/ibcs2/ibcs2_msg.c b/sys/i386/ibcs2/ibcs2_msg.c index 6c36cf8..413859a 100644 --- a/sys/i386/ibcs2/ibcs2_msg.c +++ b/sys/i386/ibcs2/ibcs2_msg.c @@ -41,16 +41,16 @@ int -ibcs2_getmsg(p, uap) - struct proc *p; +ibcs2_getmsg(td, uap) + struct thread *td; struct ibcs2_getmsg_args *uap; { return 0; /* fake */ } int -ibcs2_putmsg(p, uap) - struct proc *p; +ibcs2_putmsg(td, uap) + struct thread *td; struct ibcs2_putmsg_args *uap; { return 0; /* fake */ @@ -58,8 +58,8 @@ ibcs2_putmsg(p, uap) int -ibcs2_poll(p, uap) - struct proc *p; +ibcs2_poll(td, uap) + struct thread *td; struct ibcs2_poll_args *uap; { int error, i; @@ -107,12 +107,12 @@ ibcs2_poll(p, uap) FD_SET(conv.fd, writefds); FD_SET(conv.fd, exceptfds); } - if ((error = select(p, &tmp_select)) != 0) + if ((error = select(td, &tmp_select)) != 0) return error; - if (p->p_retval[0] == 0) + if (td->td_retval[0] == 0) return 0; - p->p_retval[0] = 0; - for (p->p_retval[0] = 0, i = 0; i < uap->nfds; i++) { + td->td_retval[0] = 0; + for (td->td_retval[0] = 0, i = 0; i < uap->nfds; i++) { copyin(uap->fds + i*sizeof(struct ibcs2_poll), &conv, sizeof(conv)); conv.revents = 0; @@ -127,7 +127,7 @@ ibcs2_poll(p, uap) if (FD_ISSET(conv.fd, exceptfds)) conv.revents |= IBCS2_POLLERR; if (conv.revents) - ++p->p_retval[0]; + ++td->td_retval[0]; } if ((error = copyout(&conv, uap->fds + i*sizeof(struct ibcs2_poll), diff --git a/sys/i386/ibcs2/ibcs2_other.c b/sys/i386/ibcs2/ibcs2_other.c index 4f90159..2881f42 100644 --- a/sys/i386/ibcs2/ibcs2_other.c +++ b/sys/i386/ibcs2/ibcs2_other.c @@ -45,14 +45,14 @@ #define IBCS2_SECURE_SETLUID 2 int -ibcs2_secure(struct proc *p, struct ibcs2_secure_args *uap) +ibcs2_secure(struct thread *td, struct ibcs2_secure_args *uap) { switch (uap->cmd) { case IBCS2_SECURE_GETLUID: /* get login uid */ - PROC_LOCK(p); - p->p_retval[0] = p->p_ucred->cr_uid; - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + td->td_retval[0] = td->td_proc->p_ucred->cr_uid; + PROC_UNLOCK(td->td_proc); return 0; case IBCS2_SECURE_SETLUID: /* set login uid */ @@ -66,7 +66,7 @@ ibcs2_secure(struct proc *p, struct ibcs2_secure_args *uap) } int -ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap) +ibcs2_lseek(struct thread *td, register struct ibcs2_lseek_args *uap) { struct lseek_args largs; int error; @@ -74,7 +74,7 @@ ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap) largs.fd = uap->fd; largs.offset = uap->offset; largs.whence = uap->whence; - error = lseek(p, &largs); + error = lseek(td, &largs); return (error); } @@ -83,7 +83,7 @@ ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap) #include <sys/un.h> int -spx_open(struct proc *p, void *uap) +spx_open(struct thread *td, void *uap) { struct socket_args sock; struct connect_args conn; @@ -96,7 +96,7 @@ spx_open(struct proc *p, void *uap) sock.domain = AF_UNIX; sock.type = SOCK_STREAM; sock.protocol = 0; - error = socket(p, &sock); + error = socket(td, &sock); if (error) return error; @@ -108,17 +108,17 @@ spx_open(struct proc *p, void *uap) strlen(Xaddr->sun_path) + 1; copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18); - conn.s = fd = p->p_retval[0]; + conn.s = fd = td->td_retval[0]; conn.name = (caddr_t)Xaddr; conn.namelen = sizeof(struct sockaddr_un); - error = connect(p, &conn); + error = connect(td, &conn); if (error) { struct close_args cl; cl.fd = fd; - close(p, &cl); + close(td, &cl); return error; } - p->p_retval[0] = fd; + td->td_retval[0] = fd; return 0; } #endif /* SPX_HACK */ diff --git a/sys/i386/ibcs2/ibcs2_proto.h b/sys/i386/ibcs2/ibcs2_proto.h index a91c96d..c7ac3df 100644 --- a/sys/i386/ibcs2/ibcs2_proto.h +++ b/sys/i386/ibcs2/ibcs2_proto.h @@ -15,6 +15,8 @@ struct proc; +struct thread; + #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 0 : sizeof(register_t) - sizeof(t)) @@ -273,62 +275,62 @@ struct ibcs2_readlink_args { struct ibcs2_isc_args { register_t dummy; }; -int ibcs2_read __P((struct proc *, struct ibcs2_read_args *)); -int ibcs2_open __P((struct proc *, struct ibcs2_open_args *)); -int ibcs2_wait __P((struct proc *, struct ibcs2_wait_args *)); -int ibcs2_creat __P((struct proc *, struct ibcs2_creat_args *)); -int ibcs2_unlink __P((struct proc *, struct ibcs2_unlink_args *)); -int ibcs2_execv __P((struct proc *, struct ibcs2_execv_args *)); -int ibcs2_chdir __P((struct proc *, struct ibcs2_chdir_args *)); -int ibcs2_time __P((struct proc *, struct ibcs2_time_args *)); -int ibcs2_mknod __P((struct proc *, struct ibcs2_mknod_args *)); -int ibcs2_chmod __P((struct proc *, struct ibcs2_chmod_args *)); -int ibcs2_chown __P((struct proc *, struct ibcs2_chown_args *)); -int ibcs2_stat __P((struct proc *, struct ibcs2_stat_args *)); -int ibcs2_lseek __P((struct proc *, struct ibcs2_lseek_args *)); -int ibcs2_mount __P((struct proc *, struct ibcs2_mount_args *)); -int ibcs2_umount __P((struct proc *, struct ibcs2_umount_args *)); -int ibcs2_setuid __P((struct proc *, struct ibcs2_setuid_args *)); -int ibcs2_stime __P((struct proc *, struct ibcs2_stime_args *)); -int ibcs2_alarm __P((struct proc *, struct ibcs2_alarm_args *)); -int ibcs2_fstat __P((struct proc *, struct ibcs2_fstat_args *)); -int ibcs2_pause __P((struct proc *, struct ibcs2_pause_args *)); -int ibcs2_utime __P((struct proc *, struct ibcs2_utime_args *)); -int ibcs2_stty __P((struct proc *, struct ibcs2_stty_args *)); -int ibcs2_gtty __P((struct proc *, struct ibcs2_gtty_args *)); -int ibcs2_access __P((struct proc *, struct ibcs2_access_args *)); -int ibcs2_nice __P((struct proc *, struct ibcs2_nice_args *)); -int ibcs2_statfs __P((struct proc *, struct ibcs2_statfs_args *)); -int ibcs2_kill __P((struct proc *, struct ibcs2_kill_args *)); -int ibcs2_fstatfs __P((struct proc *, struct ibcs2_fstatfs_args *)); -int ibcs2_pgrpsys __P((struct proc *, struct ibcs2_pgrpsys_args *)); -int ibcs2_xenix __P((struct proc *, struct ibcs2_xenix_args *)); -int ibcs2_times __P((struct proc *, struct ibcs2_times_args *)); -int ibcs2_plock __P((struct proc *, struct ibcs2_plock_args *)); -int ibcs2_setgid __P((struct proc *, struct ibcs2_setgid_args *)); -int ibcs2_sigsys __P((struct proc *, struct ibcs2_sigsys_args *)); -int ibcs2_msgsys __P((struct proc *, struct ibcs2_msgsys_args *)); -int ibcs2_sysi86 __P((struct proc *, struct ibcs2_sysi86_args *)); -int ibcs2_shmsys __P((struct proc *, struct ibcs2_shmsys_args *)); -int ibcs2_semsys __P((struct proc *, struct ibcs2_semsys_args *)); -int ibcs2_ioctl __P((struct proc *, struct ibcs2_ioctl_args *)); -int ibcs2_uadmin __P((struct proc *, struct ibcs2_uadmin_args *)); -int ibcs2_utssys __P((struct proc *, struct ibcs2_utssys_args *)); -int ibcs2_execve __P((struct proc *, struct ibcs2_execve_args *)); -int ibcs2_fcntl __P((struct proc *, struct ibcs2_fcntl_args *)); -int ibcs2_ulimit __P((struct proc *, struct ibcs2_ulimit_args *)); -int ibcs2_rmdir __P((struct proc *, struct ibcs2_rmdir_args *)); -int ibcs2_mkdir __P((struct proc *, struct ibcs2_mkdir_args *)); -int ibcs2_getdents __P((struct proc *, struct ibcs2_getdents_args *)); -int ibcs2_sysfs __P((struct proc *, struct ibcs2_sysfs_args *)); -int ibcs2_getmsg __P((struct proc *, struct ibcs2_getmsg_args *)); -int ibcs2_putmsg __P((struct proc *, struct ibcs2_putmsg_args *)); -int ibcs2_poll __P((struct proc *, struct ibcs2_poll_args *)); -int ibcs2_secure __P((struct proc *, struct ibcs2_secure_args *)); -int ibcs2_symlink __P((struct proc *, struct ibcs2_symlink_args *)); -int ibcs2_lstat __P((struct proc *, struct ibcs2_lstat_args *)); -int ibcs2_readlink __P((struct proc *, struct ibcs2_readlink_args *)); -int ibcs2_isc __P((struct proc *, struct ibcs2_isc_args *)); +int ibcs2_read __P((struct thread *, struct ibcs2_read_args *)); +int ibcs2_open __P((struct thread *, struct ibcs2_open_args *)); +int ibcs2_wait __P((struct thread *, struct ibcs2_wait_args *)); +int ibcs2_creat __P((struct thread *, struct ibcs2_creat_args *)); +int ibcs2_unlink __P((struct thread *, struct ibcs2_unlink_args *)); +int ibcs2_execv __P((struct thread *, struct ibcs2_execv_args *)); +int ibcs2_chdir __P((struct thread *, struct ibcs2_chdir_args *)); +int ibcs2_time __P((struct thread *, struct ibcs2_time_args *)); +int ibcs2_mknod __P((struct thread *, struct ibcs2_mknod_args *)); +int ibcs2_chmod __P((struct thread *, struct ibcs2_chmod_args *)); +int ibcs2_chown __P((struct thread *, struct ibcs2_chown_args *)); +int ibcs2_stat __P((struct thread *, struct ibcs2_stat_args *)); +int ibcs2_lseek __P((struct thread *, struct ibcs2_lseek_args *)); +int ibcs2_mount __P((struct thread *, struct ibcs2_mount_args *)); +int ibcs2_umount __P((struct thread *, struct ibcs2_umount_args *)); +int ibcs2_setuid __P((struct thread *, struct ibcs2_setuid_args *)); +int ibcs2_stime __P((struct thread *, struct ibcs2_stime_args *)); +int ibcs2_alarm __P((struct thread *, struct ibcs2_alarm_args *)); +int ibcs2_fstat __P((struct thread *, struct ibcs2_fstat_args *)); +int ibcs2_pause __P((struct thread *, struct ibcs2_pause_args *)); +int ibcs2_utime __P((struct thread *, struct ibcs2_utime_args *)); +int ibcs2_stty __P((struct thread *, struct ibcs2_stty_args *)); +int ibcs2_gtty __P((struct thread *, struct ibcs2_gtty_args *)); +int ibcs2_access __P((struct thread *, struct ibcs2_access_args *)); +int ibcs2_nice __P((struct thread *, struct ibcs2_nice_args *)); +int ibcs2_statfs __P((struct thread *, struct ibcs2_statfs_args *)); +int ibcs2_kill __P((struct thread *, struct ibcs2_kill_args *)); +int ibcs2_fstatfs __P((struct thread *, struct ibcs2_fstatfs_args *)); +int ibcs2_pgrpsys __P((struct thread *, struct ibcs2_pgrpsys_args *)); +int ibcs2_xenix __P((struct thread *, struct ibcs2_xenix_args *)); +int ibcs2_times __P((struct thread *, struct ibcs2_times_args *)); +int ibcs2_plock __P((struct thread *, struct ibcs2_plock_args *)); +int ibcs2_setgid __P((struct thread *, struct ibcs2_setgid_args *)); +int ibcs2_sigsys __P((struct thread *, struct ibcs2_sigsys_args *)); +int ibcs2_msgsys __P((struct thread *, struct ibcs2_msgsys_args *)); +int ibcs2_sysi86 __P((struct thread *, struct ibcs2_sysi86_args *)); +int ibcs2_shmsys __P((struct thread *, struct ibcs2_shmsys_args *)); +int ibcs2_semsys __P((struct thread *, struct ibcs2_semsys_args *)); +int ibcs2_ioctl __P((struct thread *, struct ibcs2_ioctl_args *)); +int ibcs2_uadmin __P((struct thread *, struct ibcs2_uadmin_args *)); +int ibcs2_utssys __P((struct thread *, struct ibcs2_utssys_args *)); +int ibcs2_execve __P((struct thread *, struct ibcs2_execve_args *)); +int ibcs2_fcntl __P((struct thread *, struct ibcs2_fcntl_args *)); +int ibcs2_ulimit __P((struct thread *, struct ibcs2_ulimit_args *)); +int ibcs2_rmdir __P((struct thread *, struct ibcs2_rmdir_args *)); +int ibcs2_mkdir __P((struct thread *, struct ibcs2_mkdir_args *)); +int ibcs2_getdents __P((struct thread *, struct ibcs2_getdents_args *)); +int ibcs2_sysfs __P((struct thread *, struct ibcs2_sysfs_args *)); +int ibcs2_getmsg __P((struct thread *, struct ibcs2_getmsg_args *)); +int ibcs2_putmsg __P((struct thread *, struct ibcs2_putmsg_args *)); +int ibcs2_poll __P((struct thread *, struct ibcs2_poll_args *)); +int ibcs2_secure __P((struct thread *, struct ibcs2_secure_args *)); +int ibcs2_symlink __P((struct thread *, struct ibcs2_symlink_args *)); +int ibcs2_lstat __P((struct thread *, struct ibcs2_lstat_args *)); +int ibcs2_readlink __P((struct thread *, struct ibcs2_readlink_args *)); +int ibcs2_isc __P((struct thread *, struct ibcs2_isc_args *)); #ifdef COMPAT_43 diff --git a/sys/i386/ibcs2/ibcs2_signal.c b/sys/i386/ibcs2/ibcs2_signal.c index 6049142..197c295 100644 --- a/sys/i386/ibcs2/ibcs2_signal.c +++ b/sys/i386/ibcs2/ibcs2_signal.c @@ -188,8 +188,8 @@ bsd_to_ibcs2_sigaction(bsa, isa) } int -ibcs2_sigaction(p, uap) - register struct proc *p; +ibcs2_sigaction(td, uap) + register struct thread *td; struct ibcs2_sigaction_args *uap; { struct ibcs2_sigaction *nisa, *oisa, tmpisa; @@ -221,7 +221,7 @@ ibcs2_sigaction(p, uap) SCARG(&sa, act) = nbsa; SCARG(&sa, oact) = obsa; - if ((error = sigaction(p, &sa)) != 0) + if ((error = sigaction(td, &sa)) != 0) return error; if (oisa != NULL) { @@ -236,10 +236,11 @@ ibcs2_sigaction(p, uap) } int -ibcs2_sigsys(p, uap) - register struct proc *p; +ibcs2_sigsys(td, uap) + register struct thread *td; struct ibcs2_sigsys_args *uap; { + struct proc *p = td->td_proc; struct sigaction sa; int signum = ibcs2_to_bsd_sig[_SIG_IDX(IBCS2_SIGNO(SCARG(uap, sig)))]; int error; @@ -248,7 +249,7 @@ ibcs2_sigsys(p, uap) if (signum <= 0 || signum >= IBCS2_NSIG) { if (IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGNAL_MASK || IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGSET_MASK) - p->p_retval[0] = (int)IBCS2_SIG_ERR; + td->td_retval[0] = (int)IBCS2_SIG_ERR; return EINVAL; } @@ -275,7 +276,7 @@ ibcs2_sigsys(p, uap) SCARG(&sa, how) = SIG_BLOCK; SCARG(&sa, set) = &mask; SCARG(&sa, oset) = NULL; - return sigprocmask(p, &sa); + return sigprocmask(td, &sa); } case IBCS2_SIGNAL_MASK: @@ -305,19 +306,19 @@ ibcs2_sigsys(p, uap) if (signum != SIGALRM) sa.sa_flags |= SA_RESTART; #endif - p->p_retval[0] = (int)IBCS2_SIG_ERR; /* init error return */ + td->td_retval[0] = (int)IBCS2_SIG_ERR; /* init error return */ /* perform native sigaction() */ if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0) return error; - if ((error = sigaction(p, &sa_args)) != 0) { + if ((error = sigaction(td, &sa_args)) != 0) { DPRINTF(("signal: sigaction failed: %d\n", error)); return error; } if ((error = copyin(obsa, &sa, sizeof(sa))) != 0) return error; - p->p_retval[0] = (int)sa.sa_handler; + td->td_retval[0] = (int)sa.sa_handler; /* special sigset() check */ if(IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGSET_MASK) { @@ -325,7 +326,7 @@ ibcs2_sigsys(p, uap) /* check to make sure signal is not blocked */ if(sigismember(&p->p_sigmask, signum)) { /* return SIG_HOLD and unblock signal*/ - p->p_retval[0] = (int)IBCS2_SIG_HOLD; + td->td_retval[0] = (int)IBCS2_SIG_HOLD; SIGDELSET(p->p_sigmask, signum); } PROC_UNLOCK(p); @@ -344,7 +345,7 @@ ibcs2_sigsys(p, uap) SCARG(&sa, how) = SIG_UNBLOCK; SCARG(&sa, set) = &mask; SCARG(&sa, oset) = NULL; - return sigprocmask(p, &sa); + return sigprocmask(td, &sa); } case IBCS2_SIGIGNORE_MASK: @@ -362,7 +363,7 @@ ibcs2_sigsys(p, uap) sa.sa_flags = 0; if ((error = copyout(&sa, bsa, sizeof(sa))) != 0) return error; - if ((error = sigaction(p, &sa_args)) != 0) { + if ((error = sigaction(td, &sa_args)) != 0) { DPRINTF(("sigignore: sigaction failed\n")); return error; } @@ -379,7 +380,7 @@ ibcs2_sigsys(p, uap) PROC_UNLOCK(p); SIGDELSET(mask, signum); SCARG(&sa, sigmask) = &mask; - return sigsuspend(p, &sa); + return sigsuspend(td, &sa); } default: @@ -388,10 +389,11 @@ ibcs2_sigsys(p, uap) } int -ibcs2_sigprocmask(p, uap) - register struct proc *p; +ibcs2_sigprocmask(td, uap) + register struct thread *td; struct ibcs2_sigprocmask_args *uap; { + struct proc *p = td->td_proc; ibcs2_sigset_t iss; sigset_t bss; int error = 0; @@ -442,10 +444,11 @@ ibcs2_sigprocmask(p, uap) } int -ibcs2_sigpending(p, uap) - register struct proc *p; +ibcs2_sigpending(td, uap) + register struct thread *td; struct ibcs2_sigpending_args *uap; { + struct proc *p = td->td_proc; sigset_t bss; ibcs2_sigset_t iss; @@ -459,8 +462,8 @@ ibcs2_sigpending(p, uap) } int -ibcs2_sigsuspend(p, uap) - register struct proc *p; +ibcs2_sigsuspend(td, uap) + register struct thread *td; struct ibcs2_sigsuspend_args *uap; { ibcs2_sigset_t sss; @@ -473,32 +476,33 @@ ibcs2_sigsuspend(p, uap) ibcs2_to_bsd_sigset(&sss, &bss); SCARG(&sa, sigmask) = &bss; - return sigsuspend(p, &sa); + return sigsuspend(td, &sa); } int -ibcs2_pause(p, uap) - register struct proc *p; +ibcs2_pause(td, uap) + register struct thread *td; struct ibcs2_pause_args *uap; { + struct proc *p = td->td_proc; sigset_t mask; struct sigsuspend_args sa; PROC_LOCK(p); - mask = p->p_sigmask; + mask = td->td_proc->p_sigmask; PROC_UNLOCK(p); SCARG(&sa, sigmask) = &mask; - return sigsuspend(p, &sa); + return sigsuspend(td, &sa); } int -ibcs2_kill(p, uap) - register struct proc *p; +ibcs2_kill(td, uap) + register struct thread *td; struct ibcs2_kill_args *uap; { struct kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); SCARG(&ka, signum) = ibcs2_to_bsd_sig[_SIG_IDX(SCARG(uap, signo))]; - return kill(p, &ka); + return kill(td, &ka); } diff --git a/sys/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c index 16d964e..533b5c9 100644 --- a/sys/i386/ibcs2/ibcs2_socksys.c +++ b/sys/i386/ibcs2/ibcs2_socksys.c @@ -21,6 +21,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ #include <sys/param.h> @@ -44,9 +46,9 @@ struct setipdomainname_args { }; /* Local prototypes */ -static int ibcs2_getipdomainname __P((struct proc *, +static int ibcs2_getipdomainname __P((struct thread *, struct getipdomainname_args *)); -static int ibcs2_setipdomainname __P((struct proc *, +static int ibcs2_setipdomainname __P((struct thread *, struct setipdomainname_args *)); /* @@ -54,8 +56,8 @@ static int ibcs2_setipdomainname __P((struct proc *, */ int -ibcs2_socksys(p, uap) - register struct proc *p; +ibcs2_socksys(td, uap) + register struct thread *td; register struct ibcs2_socksys_args *uap; { int error; @@ -77,55 +79,55 @@ ibcs2_socksys(p, uap) passargs = (void *)(realargs + 1); switch (realargs[0]) { case SOCKSYS_ACCEPT: - return accept(p, passargs); + return accept(td, passargs); case SOCKSYS_BIND: - return bind(p, passargs); + return bind(td, passargs); case SOCKSYS_CONNECT: - return connect(p, passargs); + return connect(td, passargs); case SOCKSYS_GETPEERNAME: - return getpeername(p, passargs); + return getpeername(td, passargs); case SOCKSYS_GETSOCKNAME: - return getsockname(p, passargs); + return getsockname(td, passargs); case SOCKSYS_GETSOCKOPT: - return getsockopt(p, passargs); + return getsockopt(td, passargs); case SOCKSYS_LISTEN: - return listen(p, passargs); + return listen(td, passargs); case SOCKSYS_RECV: realargs[5] = realargs[6] = 0; /* FALLTHROUGH */ case SOCKSYS_RECVFROM: - return recvfrom(p, passargs); + return recvfrom(td, passargs); case SOCKSYS_SEND: realargs[5] = realargs[6] = 0; /* FALLTHROUGH */ case SOCKSYS_SENDTO: - return sendto(p, passargs); + return sendto(td, passargs); case SOCKSYS_SETSOCKOPT: - return setsockopt(p, passargs); + return setsockopt(td, passargs); case SOCKSYS_SHUTDOWN: - return shutdown(p, passargs); + return shutdown(td, passargs); case SOCKSYS_SOCKET: - return socket(p, passargs); + return socket(td, passargs); case SOCKSYS_SELECT: - return select(p, passargs); + return select(td, passargs); case SOCKSYS_GETIPDOMAIN: - return ibcs2_getipdomainname(p, passargs); + return ibcs2_getipdomainname(td, passargs); case SOCKSYS_SETIPDOMAIN: - return ibcs2_setipdomainname(p, passargs); + return ibcs2_setipdomainname(td, passargs); case SOCKSYS_ADJTIME: - return adjtime(p, passargs); + return adjtime(td, passargs); case SOCKSYS_SETREUID: - return setreuid(p, passargs); + return setreuid(td, passargs); case SOCKSYS_SETREGID: - return setregid(p, passargs); + return setregid(td, passargs); case SOCKSYS_GETTIME: - return gettimeofday(p, passargs); + return gettimeofday(td, passargs); case SOCKSYS_SETTIME: - return settimeofday(p, passargs); + return settimeofday(td, passargs); case SOCKSYS_GETITIMER: - return getitimer(p, passargs); + return getitimer(td, passargs); case SOCKSYS_SETITIMER: - return setitimer(p, passargs); + return setitimer(td, passargs); default: printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n", @@ -138,8 +140,8 @@ ibcs2_socksys(p, uap) /* ARGSUSED */ static int -ibcs2_getipdomainname(p, uap) - struct proc *p; +ibcs2_getipdomainname(td, uap) + struct thread *td; struct getipdomainname_args *uap; { char hname[MAXHOSTNAMELEN], *dptr; @@ -162,14 +164,14 @@ ibcs2_getipdomainname(p, uap) /* ARGSUSED */ static int -ibcs2_setipdomainname(p, uap) - struct proc *p; +ibcs2_setipdomainname(td, uap) + struct thread *td; struct setipdomainname_args *uap; { char hname[MAXHOSTNAMELEN], *ptr; int error, sctl[2], hlen; - if ((error = suser(p))) + if ((error = suser_td(td))) return (error); /* W/out a hostname a domain-name is nonsense */ @@ -200,5 +202,5 @@ ibcs2_setipdomainname(p, uap) sctl[0] = CTL_KERN; sctl[1] = KERN_HOSTNAME; hlen = strlen(hname) + 1; - return (kernel_sysctl(p, sctl, 2, 0, 0, hname, hlen, 0)); + return (kernel_sysctl(td, sctl, 2, 0, 0, hname, hlen, 0)); } diff --git a/sys/i386/ibcs2/ibcs2_socksys.h b/sys/i386/ibcs2/ibcs2_socksys.h index f6b212e..f0c72bd 100644 --- a/sys/i386/ibcs2/ibcs2_socksys.h +++ b/sys/i386/ibcs2/ibcs2_socksys.h @@ -21,6 +21,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef _I386_IBCS2_IBCS2_SOCKSYS_H_ @@ -121,6 +123,6 @@ struct ibcs2_socksys_args { caddr_t argsp; }; -int ibcs2_socksys __P((struct proc *, struct ibcs2_socksys_args *)); +int ibcs2_socksys __P((struct thread *, struct ibcs2_socksys_args *)); #endif /* !_I386_IBCS2_IBCS2_SOCKSYS_H_ */ diff --git a/sys/i386/ibcs2/ibcs2_stat.c b/sys/i386/ibcs2/ibcs2_stat.c index 824118f..fd39853 100644 --- a/sys/i386/ibcs2/ibcs2_stat.c +++ b/sys/i386/ibcs2/ibcs2_stat.c @@ -95,8 +95,8 @@ cvt_statfs(sp, buf, len) } int -ibcs2_statfs(p, uap) - struct proc *p; +ibcs2_statfs(td, uap) + struct thread *td; struct ibcs2_statfs_args *uap; { register struct mount *mp; @@ -105,23 +105,23 @@ ibcs2_statfs(p, uap) struct nameidata nd; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); mp = nd.ni_vp->v_mount; sp = &mp->mnt_stat; vrele(nd.ni_vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) + if ((error = VFS_STATFS(mp, sp, td)) != 0) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len)); } int -ibcs2_fstatfs(p, uap) - struct proc *p; +ibcs2_fstatfs(td, uap) + struct thread *td; struct ibcs2_fstatfs_args *uap; { struct file *fp; @@ -129,19 +129,19 @@ ibcs2_fstatfs(p, uap) register struct statfs *sp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; - if ((error = VFS_STATFS(mp, sp, p)) != 0) + if ((error = VFS_STATFS(mp, sp, td)) != 0) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len)); } int -ibcs2_stat(p, uap) - struct proc *p; +ibcs2_stat(td, uap) + struct thread *td; struct ibcs2_stat_args *uap; { struct stat st; @@ -150,11 +150,11 @@ ibcs2_stat(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st)); - if ((error = stat(p, &cup)) != 0) + if ((error = stat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0) @@ -165,8 +165,8 @@ ibcs2_stat(p, uap) } int -ibcs2_lstat(p, uap) - struct proc *p; +ibcs2_lstat(td, uap) + struct thread *td; struct ibcs2_lstat_args *uap; { struct stat st; @@ -175,11 +175,11 @@ ibcs2_lstat(p, uap) int error; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); SCARG(&cup, path) = SCARG(uap, path); SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st)); - if ((error = lstat(p, &cup)) != 0) + if ((error = lstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0) @@ -190,8 +190,8 @@ ibcs2_lstat(p, uap) } int -ibcs2_fstat(p, uap) - struct proc *p; +ibcs2_fstat(td, uap) + struct thread *td; struct ibcs2_fstat_args *uap; { struct stat st; @@ -203,7 +203,7 @@ ibcs2_fstat(p, uap) SCARG(&cup, fd) = SCARG(uap, fd); SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(st)); - if ((error = fstat(p, &cup)) != 0) + if ((error = fstat(td, &cup)) != 0) return error; if ((error = copyin(SCARG(&cup, sb), &st, sizeof(st))) != 0) @@ -214,8 +214,8 @@ ibcs2_fstat(p, uap) } int -ibcs2_utssys(p, uap) - struct proc *p; +ibcs2_utssys(td, uap) + struct thread *td; struct ibcs2_utssys_args *uap; { switch (SCARG(uap, flag)) { diff --git a/sys/i386/ibcs2/ibcs2_sysi86.c b/sys/i386/ibcs2/ibcs2_sysi86.c index bcc758b..ae5215f 100644 --- a/sys/i386/ibcs2/ibcs2_sysi86.c +++ b/sys/i386/ibcs2/ibcs2_sysi86.c @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * ibcs2_sysi86.c,v 1.1 1994/10/14 08:53:11 sos Exp + * $FreeBSD$ */ #include <sys/param.h> @@ -51,7 +51,7 @@ extern int hw_float; int -ibcs2_sysi86(struct proc *p, struct ibcs2_sysi86_args *args) +ibcs2_sysi86(struct thread *td, struct ibcs2_sysi86_args *args) { switch (SCARG(args, cmd)) { case SI86_FPHW: { /* Floating Point information */ @@ -73,16 +73,16 @@ ibcs2_sysi86(struct proc *p, struct ibcs2_sysi86_args *args) int name[2]; int error; - if ((error = suser(p))) + if ((error = suser_td(td))) return (error); name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - return (userland_sysctl(p, name, 2, 0, 0, 0, + return (userland_sysctl(td, name, 2, 0, 0, 0, SCARG(args, arg), 7, 0)); } case SI86_MEM: /* size of physical memory */ - p->p_retval[0] = ctob(physmem); + td->td_retval[0] = ctob(physmem); return 0; default: diff --git a/sys/i386/ibcs2/ibcs2_util.c b/sys/i386/ibcs2/ibcs2_util.c index bef94fd3..8b0720a 100644 --- a/sys/i386/ibcs2/ibcs2_util.c +++ b/sys/i386/ibcs2/ibcs2_util.c @@ -50,8 +50,8 @@ const char ibcs2_emul_path[] = "/compat/ibcs2"; * be in exists. */ int -ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) - struct proc *p; +ibcs2_emul_find(td, sgp, prefix, path, pbuf, cflag) + struct thread *td; caddr_t *sgp; /* Pointer to stackgap memory */ const char *prefix; char *path; @@ -104,7 +104,7 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) for (cp = &ptr[len] - 1; *cp != '/'; cp--); *cp = '\0'; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -114,7 +114,7 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) *cp = '/'; } else { - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); if ((error = namei(&nd)) != 0) { free(buf, M_TEMP); @@ -130,7 +130,7 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) * to the emulation root directory. This is expensive :-( */ NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, ibcs2_emul_path, - p); + td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -140,11 +140,11 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) return error; } - if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { + if ((error = VOP_GETATTR(nd.ni_vp, &vat, td->td_proc->p_ucred, td)) != 0) { goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, td->td_proc->p_ucred, td)) != 0) { goto done; } diff --git a/sys/i386/ibcs2/ibcs2_util.h b/sys/i386/ibcs2/ibcs2_util.h index 4ef390f..93382c4 100644 --- a/sys/i386/ibcs2/ibcs2_util.h +++ b/sys/i386/ibcs2/ibcs2_util.h @@ -29,6 +29,8 @@ * * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp + * + * $FreeBSD$ */ /* @@ -60,7 +62,7 @@ static __inline void *stackgap_alloc(caddr_t *, size_t); static __inline caddr_t stackgap_init() { -#define szsigcode (*(curproc->p_sysent->sv_szsigcode)) +#define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode)) return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE); } @@ -82,17 +84,17 @@ stackgap_alloc(sgp, sz) extern const char ibcs2_emul_path[]; -int ibcs2_emul_find __P((struct proc *, caddr_t *, const char *, char *, +int ibcs2_emul_find __P((struct thread *, caddr_t *, const char *, char *, char **, int)); #define CHECKALTEXIST(p, sgp, path) \ - ibcs2_emul_find(p, sgp, ibcs2_emul_path, path, &(path), 0) + ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 0) #define CHECKALTCREAT(p, sgp, path) \ - ibcs2_emul_find(p, sgp, ibcs2_emul_path, path, &(path), 1) + ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 1) #ifdef SPX_HACK -int spx_open __P((struct proc *p, void *uap)); +int spx_open __P((struct thread *td, void *uap)); #endif #endif /* !_IBCS2_UTIL_H_ */ diff --git a/sys/i386/ibcs2/ibcs2_xenix.c b/sys/i386/ibcs2/ibcs2_xenix.c index b11275c2..2f30195 100644 --- a/sys/i386/ibcs2/ibcs2_xenix.c +++ b/sys/i386/ibcs2/ibcs2_xenix.c @@ -53,9 +53,9 @@ extern struct sysent xenix_sysent[]; int -ibcs2_xenix(struct proc *p, struct ibcs2_xenix_args *uap) +ibcs2_xenix(struct thread *td, struct ibcs2_xenix_args *uap) { - struct trapframe *tf = p->p_frame; + struct trapframe *tf = td->td_frame; struct sysent *callp; u_int code; @@ -63,14 +63,14 @@ ibcs2_xenix(struct proc *p, struct ibcs2_xenix_args *uap) callp = &xenix_sysent[code]; if(code < IBCS2_XENIX_MAXSYSCALL) - return((*callp->sy_call)(p, (void *)uap)); + return((*callp->sy_call)(td, (void *)uap)); else return ENOSYS; } int -xenix_rdchk(p, uap) - struct proc *p; +xenix_rdchk(td, uap) + struct thread *td; struct xenix_rdchk_args *uap; { int error; @@ -81,15 +81,15 @@ xenix_rdchk(p, uap) SCARG(&sa, fd) = SCARG(uap, fd); SCARG(&sa, com) = FIONREAD; SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int)); - if ((error = ioctl(p, &sa)) != 0) + if ((error = ioctl(td, &sa)) != 0) return error; - p->p_retval[0] = (*((int*)SCARG(&sa, data))) ? 1 : 0; + td->td_retval[0] = (*((int*)SCARG(&sa, data))) ? 1 : 0; return 0; } int -xenix_chsize(p, uap) - struct proc *p; +xenix_chsize(td, uap) + struct thread *td; struct xenix_chsize_args *uap; { struct ftruncate_args sa; @@ -98,13 +98,13 @@ xenix_chsize(p, uap) SCARG(&sa, fd) = SCARG(uap, fd); SCARG(&sa, pad) = 0; SCARG(&sa, length) = SCARG(uap, size); - return ftruncate(p, &sa); + return ftruncate(td, &sa); } int -xenix_ftime(p, uap) - struct proc *p; +xenix_ftime(td, uap) + struct thread *td; struct xenix_ftime_args *uap; { struct timeval tv; @@ -127,7 +127,7 @@ xenix_ftime(p, uap) } int -xenix_nap(struct proc *p, struct xenix_nap_args *uap) +xenix_nap(struct thread *td, struct xenix_nap_args *uap) { long period; @@ -140,7 +140,7 @@ xenix_nap(struct proc *p, struct xenix_nap_args *uap) } int -xenix_utsname(struct proc *p, struct xenix_utsname_args *uap) +xenix_utsname(struct thread *td, struct xenix_utsname_args *uap) { struct ibcs2_sco_utsname { char sysname[9]; @@ -183,26 +183,26 @@ xenix_utsname(struct proc *p, struct xenix_utsname_args *uap) } int -xenix_scoinfo(struct proc *p, struct xenix_scoinfo_args *uap) +xenix_scoinfo(struct thread *td, struct xenix_scoinfo_args *uap) { /* scoinfo (not documented) */ - p->p_retval[0] = 0; + td->td_retval[0] = 0; return 0; } int -xenix_eaccess(struct proc *p, struct xenix_eaccess_args *uap) +xenix_eaccess(struct thread *td, struct xenix_eaccess_args *uap) { - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; struct vnode *vp; struct nameidata nd; int error, flags; caddr_t sg = stackgap_init(); - CHECKALTEXIST(p, &sg, SCARG(uap, path)); + CHECKALTEXIST(td, &sg, SCARG(uap, path)); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return error; vp = nd.ni_vp; @@ -217,7 +217,7 @@ xenix_eaccess(struct proc *p, struct xenix_eaccess_args *uap) if (SCARG(uap, flags) & IBCS2_X_OK) flags |= VEXEC; if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0) - error = VOP_ACCESS(vp, flags, cred, p); + error = VOP_ACCESS(vp, flags, cred, td); } NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); diff --git a/sys/i386/ibcs2/ibcs2_xenix.h b/sys/i386/ibcs2/ibcs2_xenix.h index 3d487ee..07e827f 100644 --- a/sys/i386/ibcs2/ibcs2_xenix.h +++ b/sys/i386/ibcs2/ibcs2_xenix.h @@ -15,6 +15,8 @@ struct proc; +struct thread; + #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 0 : sizeof(register_t) - sizeof(t)) @@ -80,23 +82,23 @@ struct ibcs2_rename_args { struct xenix_utsname_args { long addr; char addr_[PAD_(long)]; }; -int xenix_rdchk __P((struct proc *, struct xenix_rdchk_args *)); -int xenix_chsize __P((struct proc *, struct xenix_chsize_args *)); -int xenix_ftime __P((struct proc *, struct xenix_ftime_args *)); -int xenix_nap __P((struct proc *, struct xenix_nap_args *)); -int xenix_scoinfo __P((struct proc *, struct xenix_scoinfo_args *)); -int xenix_eaccess __P((struct proc *, struct xenix_eaccess_args *)); -int ibcs2_sigaction __P((struct proc *, struct ibcs2_sigaction_args *)); -int ibcs2_sigprocmask __P((struct proc *, struct ibcs2_sigprocmask_args *)); -int ibcs2_sigpending __P((struct proc *, struct ibcs2_sigpending_args *)); -int ibcs2_sigsuspend __P((struct proc *, struct ibcs2_sigsuspend_args *)); -int ibcs2_getgroups __P((struct proc *, struct ibcs2_getgroups_args *)); -int ibcs2_setgroups __P((struct proc *, struct ibcs2_setgroups_args *)); -int ibcs2_sysconf __P((struct proc *, struct ibcs2_sysconf_args *)); -int ibcs2_pathconf __P((struct proc *, struct ibcs2_pathconf_args *)); -int ibcs2_fpathconf __P((struct proc *, struct ibcs2_fpathconf_args *)); -int ibcs2_rename __P((struct proc *, struct ibcs2_rename_args *)); -int xenix_utsname __P((struct proc *, struct xenix_utsname_args *)); +int xenix_rdchk __P((struct thread *, struct xenix_rdchk_args *)); +int xenix_chsize __P((struct thread *, struct xenix_chsize_args *)); +int xenix_ftime __P((struct thread *, struct xenix_ftime_args *)); +int xenix_nap __P((struct thread *, struct xenix_nap_args *)); +int xenix_scoinfo __P((struct thread *, struct xenix_scoinfo_args *)); +int xenix_eaccess __P((struct thread *, struct xenix_eaccess_args *)); +int ibcs2_sigaction __P((struct thread *, struct ibcs2_sigaction_args *)); +int ibcs2_sigprocmask __P((struct thread *, struct ibcs2_sigprocmask_args *)); +int ibcs2_sigpending __P((struct thread *, struct ibcs2_sigpending_args *)); +int ibcs2_sigsuspend __P((struct thread *, struct ibcs2_sigsuspend_args *)); +int ibcs2_getgroups __P((struct thread *, struct ibcs2_getgroups_args *)); +int ibcs2_setgroups __P((struct thread *, struct ibcs2_setgroups_args *)); +int ibcs2_sysconf __P((struct thread *, struct ibcs2_sysconf_args *)); +int ibcs2_pathconf __P((struct thread *, struct ibcs2_pathconf_args *)); +int ibcs2_fpathconf __P((struct thread *, struct ibcs2_fpathconf_args *)); +int ibcs2_rename __P((struct thread *, struct ibcs2_rename_args *)); +int xenix_utsname __P((struct thread *, struct xenix_utsname_args *)); #ifdef COMPAT_43 diff --git a/sys/i386/ibcs2/imgact_coff.c b/sys/i386/ibcs2/imgact_coff.c index a2f624d..3ea816b 100644 --- a/sys/i386/ibcs2/imgact_coff.c +++ b/sys/i386/ibcs2/imgact_coff.c @@ -54,7 +54,7 @@ MODULE_DEPEND(coff, ibcs2, 1, 1, 1); extern struct sysentvec ibcs2_svr3_sysvec; -static int coff_load_file __P((struct proc *p, char *name)); +static int coff_load_file __P((struct thread *td, char *name)); static int exec_coff_imgact __P((struct image_params *imgp)); static int load_coff_section __P((struct vmspace *vmspace, struct vnode *vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot)); @@ -150,8 +150,9 @@ load_coff_section(struct vmspace *vmspace, struct vnode *vp, vm_offset_t offset, } static int -coff_load_file(struct proc *p, char *name) +coff_load_file(struct thread *td, char *name) { + struct proc *p = td->td_proc; struct vmspace *vmspace = p->p_vmspace; int error; struct nameidata nd; @@ -167,7 +168,7 @@ coff_load_file(struct proc *p, char *name) unsigned long bss_size = 0; int i; - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, p); + NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, td); error = namei(&nd); if (error) @@ -182,7 +183,7 @@ coff_load_file(struct proc *p, char *name) goto fail; } - if ((error = VOP_GETATTR(vp, &attr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &attr, p->p_ucred, td)) != 0) goto fail; if ((vp->v_mount->mnt_flag & MNT_NOEXEC) @@ -195,17 +196,17 @@ coff_load_file(struct proc *p, char *name) goto fail; } - if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0) + if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, td)) != 0) goto fail; - if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) + if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, td)) != 0) goto fail; /* * Lose the lock on the vnode. It's no longer needed, and must not * exist for the pagefault paging to work below. */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((error = vm_mmap(kernel_map, (vm_offset_t *) &ptr, @@ -278,7 +279,7 @@ coff_load_file(struct proc *p, char *name) panic(__FUNCTION__ " vm_map_remove failed"); fail: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); unlocked_fail: NDFREE(&nd, NDF_ONLY_PNBUF); vrele(nd.ni_vp); @@ -393,9 +394,9 @@ exec_coff_imgact(imgp) DPRINTF(("%s(%d): shared library %s\n", __FILE__, __LINE__, libname)); strcpy(&libbuf[emul_path_len], libname); - error = coff_load_file(imgp->proc, libbuf); +/* XXXKSE only 1:1 in coff */ error = coff_load_file(&imgp->proc->p_thread, libbuf); if (error) - error = coff_load_file(imgp->proc, + error = coff_load_file(&imgp->proc->p_thread, libname); if (error) break; diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h index 04ef7a0..a7783a0 100644 --- a/sys/i386/include/cpu.h +++ b/sys/i386/include/cpu.h @@ -56,8 +56,8 @@ #define cpu_exec(p) /* nothing */ #define cpu_swapin(p) /* nothing */ -#define cpu_getstack(p) ((p)->p_frame->tf_esp) -#define cpu_setstack(p, ap) ((p)->p_frame->tf_esp = (ap)) +#define cpu_getstack(td) ((td)->td_frame->tf_esp) +#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap)) #define TRAPF_USERMODE(framep) \ ((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM)) diff --git a/sys/i386/include/globaldata.h b/sys/i386/include/globaldata.h index 37388aa..f02354d 100644 --- a/sys/i386/include/globaldata.h +++ b/sys/i386/include/globaldata.h @@ -52,19 +52,19 @@ * other processors" */ struct globaldata { - struct globaldata *gd_prvspace; /* self-reference */ - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_npxproc; - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - struct i386tss gd_common_tss; - int gd_switchticks; - struct segment_descriptor gd_common_tssd; - struct segment_descriptor *gd_tss_gdt; - int gd_currentldt; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ + struct globaldata *gd_prvspace; /* self-reference */ + struct thread *gd_curthread; + struct thread *gd_npxthread; + struct pcb *gd_curpcb; + struct thread *gd_idlethread; + struct timeval gd_switchtime; + struct i386tss gd_common_tss; + int gd_switchticks; + struct segment_descriptor gd_common_tssd; + struct segment_descriptor *gd_tss_gdt; + int gd_currentldt; + u_int gd_cpuid; + u_int gd_other_cpus; SLIST_ENTRY(globaldata) gd_allcpu; struct lock_list_entry *gd_spinlocks; #ifdef KTR_PERCPU diff --git a/sys/i386/include/globals.h b/sys/i386/include/globals.h index 7613069..c3cc211 100644 --- a/sys/i386/include/globals.h +++ b/sys/i386/include/globals.h @@ -129,10 +129,12 @@ #define PCPU_PTR(member) __PCPU_PTR(gd_ ## member) #define PCPU_SET(member, val) __PCPU_SET(gd_ ## member, val) -#define CURPROC PCPU_GET(curproc) -#define CURTHD PCPU_GET(curproc) #define GLOBALDATA PCPU_GET(prvspace) -#define curproc PCPU_GET(curproc) +#define curthread PCPU_GET(curthread) +#define CURPROC (curthread->td_proc) +#define curproc (curthread->td_proc) +#define curksegrp (curthread->td_ksegrp) +#define curkse (curthread->td_kse) #endif /* _KERNEL */ diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index bc9cb75..c3564c2 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -61,7 +61,7 @@ extern char sigcode[]; extern int szsigcode, szosigcode; typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss)); -struct proc; +struct thread; struct reg; struct fpreg; struct dbreg; @@ -80,9 +80,9 @@ void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es)); void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault)); void doreti_popl_fs __P((void)) __asm(__STRING(doreti_popl_fs)); void doreti_popl_fs_fault __P((void)) __asm(__STRING(doreti_popl_fs_fault)); -int fill_fpregs __P((struct proc *, struct fpreg *)); -int fill_regs __P((struct proc *p, struct reg *regs)); -int fill_dbregs __P((struct proc *p, struct dbreg *dbregs)); +int fill_fpregs __P((struct thread *, struct fpreg *)); +int fill_regs __P((struct thread *p, struct reg *regs)); +int fill_dbregs __P((struct thread *p, struct dbreg *dbregs)); void fillw __P((int /*u_short*/ pat, void *base, size_t cnt)); void i486_bzero __P((void *buf, size_t len)); void i586_bcopy __P((const void *from, void *to, size_t len)); diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index d912e0c..f558524 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -26,7 +26,7 @@ */ #include "opt_cpu.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" #ifdef SMP #include <machine/smptests.h> @@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr) SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */ + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[pg + 1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE]; bootAP = x; /* attempt to start the Application Processor */ @@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr) */ /* Allocate and setup BSP idle stack */ - stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); - for (i = 0; i < UPAGES; i++) + stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + for (i = 0; i < KSTACK_PAGES; i++) SMPpt[1 + i] = (pt_entry_t) (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); @@ -2241,7 +2241,7 @@ ap_init(void) * Set curproc to our per-cpu idleproc so that mutexes have * something unique to lock with. */ - PCPU_SET(curproc, PCPU_GET(idleproc)); + PCPU_SET(curthread, PCPU_GET(idlethread)); PCPU_SET(spinlocks, NULL); /* lock against other AP's that are waking up */ @@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); + statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } @@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame) { mtx_lock_spin(&sched_lock); - hardclock_process(curproc, TRAPF_USERMODE(&frame)); + hardclock_process(curthread, TRAPF_USERMODE(&frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/i386/include/mutex.h b/sys/i386/include/mutex.h index b0fe512..ae37b23 100644 --- a/sys/i386/include/mutex.h +++ b/sys/i386/include/mutex.h @@ -250,7 +250,7 @@ extern struct mtx clock_lock; pushl %ecx ; \ pushl %ebx ; \ movl $(MTX_UNOWNED) , %eax ; \ - movl PCPU(CURPROC), %ebx ; \ + movl PCPU(CURTHREAD), %ebx ; \ pushfl ; \ popl %ecx ; \ cli ; \ diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h index 67ce661..589a4be 100644 --- a/sys/i386/include/npx.h +++ b/sys/i386/include/npx.h @@ -142,7 +142,7 @@ union savefpu { #ifdef _KERNEL int npxdna __P((void)); -void npxexit __P((struct proc *p)); +void npxexit __P((struct thread *td)); void npxinit __P((int control)); void npxsave __P((union savefpu *addr)); int npxtrap __P((void)); diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index 9f63c01..ba28cfb 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -111,9 +111,12 @@ #define IOPAGES 2 /* pages of i/o permission bitmap */ -#ifndef UPAGES -#define UPAGES 2 /* pages of u-area */ +#ifndef KSTACK_PAGES +#define KSTACK_PAGES 2 /* Includes pcb! */ #endif +#define UAREA_PAGES 1 /* holds struct user WITHOUT PCB (see def.) */ + +#define KSTACK_GUARD /* compile in the kstack guard page */ /* * Ceiling on amount of swblock kva space. diff --git a/sys/i386/include/pcb_ext.h b/sys/i386/include/pcb_ext.h index 7d6fb08..c6f9fc0 100644 --- a/sys/i386/include/pcb_ext.h +++ b/sys/i386/include/pcb_ext.h @@ -53,7 +53,7 @@ struct pcb_ldt { #ifdef _KERNEL -int i386_extend_pcb __P((struct proc *)); +int i386_extend_pcb __P((struct thread *)); void set_user_ldt __P((struct pcb *)); struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int)); void user_ldt_free __P((struct pcb *)); diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index 37388aa..f02354d 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -52,19 +52,19 @@ * other processors" */ struct globaldata { - struct globaldata *gd_prvspace; /* self-reference */ - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_npxproc; - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - struct i386tss gd_common_tss; - int gd_switchticks; - struct segment_descriptor gd_common_tssd; - struct segment_descriptor *gd_tss_gdt; - int gd_currentldt; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ + struct globaldata *gd_prvspace; /* self-reference */ + struct thread *gd_curthread; + struct thread *gd_npxthread; + struct pcb *gd_curpcb; + struct thread *gd_idlethread; + struct timeval gd_switchtime; + struct i386tss gd_common_tss; + int gd_switchticks; + struct segment_descriptor gd_common_tssd; + struct segment_descriptor *gd_tss_gdt; + int gd_currentldt; + u_int gd_cpuid; + u_int gd_other_cpus; SLIST_ENTRY(globaldata) gd_allcpu; struct lock_list_entry *gd_spinlocks; #ifdef KTR_PERCPU diff --git a/sys/i386/include/privatespace.h b/sys/i386/include/privatespace.h index 496c4b6..83320cf 100644 --- a/sys/i386/include/privatespace.h +++ b/sys/i386/include/privatespace.h @@ -39,9 +39,9 @@ struct privatespace { struct globaldata globaldata; char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; - /* page 1 - idle stack (UPAGES pages) */ - char idlestack[UPAGES * PAGE_SIZE]; - /* page 1+UPAGES... */ + /* page 1 - idle stack (KSTACK_PAGES pages) */ + char idlekstack[KSTACK_PAGES * PAGE_SIZE]; + /* page 1+KSTACK_PAGES... */ }; extern struct privatespace SMP_prvspace[]; diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h index 4217c4f..9e9e449 100644 --- a/sys/i386/include/proc.h +++ b/sys/i386/include/proc.h @@ -42,6 +42,9 @@ /* * Machine-dependent part of the proc structure for i386. */ +struct mdthread { +}; + struct mdproc { }; diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h index 47856a3..f4c6ae5 100644 --- a/sys/i386/include/reg.h +++ b/sys/i386/include/reg.h @@ -143,10 +143,10 @@ struct dbreg { /* * XXX these interfaces are MI, so they should be declared in a MI place. */ -int set_fpregs __P((struct proc *, struct fpreg *)); -int set_regs __P((struct proc *p, struct reg *regs)); -void setregs __P((struct proc *, u_long, u_long, u_long)); -int set_dbregs __P((struct proc *p, struct dbreg *dbregs)); +int set_fpregs __P((struct thread *, struct fpreg *)); +int set_regs __P((struct thread *p, struct reg *regs)); +void setregs __P((struct thread *, u_long, u_long, u_long)); +int set_dbregs __P((struct thread *p, struct dbreg *dbregs)); #endif #endif /* !_MACHINE_REG_H_ */ diff --git a/sys/i386/include/vm86.h b/sys/i386/include/vm86.h index 60c5615..fa77013 100644 --- a/sys/i386/include/vm86.h +++ b/sys/i386/include/vm86.h @@ -149,7 +149,7 @@ extern int vm86paddr; struct proc; extern int vm86_emulate __P((struct vm86frame *)); -extern int vm86_sysarch __P((struct proc *, char *)); +extern int vm86_sysarch __P((struct thread *, char *)); extern void vm86_trap __P((struct vm86frame *)); extern int vm86_intcall __P((int, struct vm86frame *)); extern int vm86_datacall __P((int, struct vm86frame *, struct vm86context *)); diff --git a/sys/i386/isa/apic_vector.s b/sys/i386/isa/apic_vector.s index 5c68f81..8096d3c 100644 --- a/sys/i386/isa/apic_vector.s +++ b/sys/i386/isa/apic_vector.s @@ -48,10 +48,10 @@ IDTVEC(vec_name) ; \ movl $KPSEL,%eax ; \ mov %ax,%fs ; \ FAKE_MCOUNT(13*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ - call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ + call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ addl $4, %esp ; \ movl $0, lapic+LA_EOI ; \ lock ; \ @@ -59,7 +59,7 @@ IDTVEC(vec_name) ; \ movl intr_countp + (irq_num) * 4, %eax ; \ lock ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -152,8 +152,8 @@ IDTVEC(vec_name) ; \ MASK_LEVEL_IRQ(irq_num) ; \ EOI_IRQ(irq_num) ; \ 0: ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ ; \ /* entry point used by doreti_unpend for HWIs. */ \ __CONCAT(Xresume,irq_num): ; \ @@ -162,7 +162,7 @@ __CONCAT(Xresume,irq_num): ; \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -227,10 +227,10 @@ Xhardclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_hardclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti @@ -252,10 +252,10 @@ Xstatclock: movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */ FAKE_MCOUNT(13*4(%esp)) - movl PCPU(CURPROC),%ebx - incl P_INTR_NESTING_LEVEL(%ebx) + movl PCPU(CURTHREAD),%ebx + incl TD_INTR_NESTING_LEVEL(%ebx) call forwarded_statclock - decl P_INTR_NESTING_LEVEL(%ebx) + decl TD_INTR_NESTING_LEVEL(%ebx) MEXITCOUNT jmp doreti diff --git a/sys/i386/isa/asc.c b/sys/i386/isa/asc.c index 2cc081e..9042fbc 100644 --- a/sys/i386/isa/asc.c +++ b/sys/i386/isa/asc.c @@ -552,7 +552,7 @@ ascintr(int unit) ***/ STATIC int -ascopen(dev_t dev, int flags, int fmt, struct proc *p) +ascopen(dev_t dev, int flags, int fmt, struct thread *td) { struct asc_unit *scu; int unit; @@ -647,7 +647,7 @@ asc_startread(struct asc_unit *scu) ***/ STATIC int -ascclose(dev_t dev, int flags, int fmt, struct proc *p) +ascclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit = UNIT(minor(dev)); struct asc_unit *scu = unittab + unit; @@ -794,7 +794,7 @@ ascread(dev_t dev, struct uio *uio, int ioflag) ***/ STATIC int -ascioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +ascioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int unit = UNIT(minor(dev)); struct asc_unit *scu = unittab + unit; @@ -859,7 +859,7 @@ ascioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) } STATIC int -ascpoll(dev_t dev, int events, struct proc *p) +ascpoll(dev_t dev, int events, struct thread *td) { int unit = UNIT(minor(dev)); struct asc_unit *scu = unittab + unit; @@ -875,7 +875,7 @@ ascpoll(dev_t dev, int events, struct proc *p) if (!(scu->flags & DMA_ACTIVE)) dma_restart(scu); - selrecord(p, &scu->selp); + selrecord(td, &scu->selp); } } splx(sps); diff --git a/sys/i386/isa/atpic_vector.s b/sys/i386/isa/atpic_vector.s index 6b48737..3a42af4 100644 --- a/sys/i386/isa/atpic_vector.s +++ b/sys/i386/isa/atpic_vector.s @@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \ mov $KPSEL,%ax ; \ mov %ax,%fs ; \ FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ @@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \ incl cnt+V_INTR ; /* book-keeping can wait */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \ movb %al,imen + IRQ_BYTE(irq_num) ; \ outb %al,$icu+ICU_IMR_OFFSET ; \ enable_icus ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ __CONCAT(Xresume,irq_num): ; \ FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \ pushl $irq_num; /* pass the IRQ */ \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ /* We could usually avoid the following jmp by inlining some of */ \ /* doreti, but it's probably better to use less cache. */ \ diff --git a/sys/i386/isa/ctx.c b/sys/i386/isa/ctx.c index 9a387fc..c755004 100644 --- a/sys/i386/isa/ctx.c +++ b/sys/i386/isa/ctx.c @@ -218,7 +218,7 @@ ctxattach(struct isa_device * devp) } static int -ctxopen(dev_t dev, int flags, int fmt, struct proc *p) +ctxopen(dev_t dev, int flags, int fmt, struct thread *td) { struct ctx_soft_registers *sr; u_char unit; @@ -273,7 +273,7 @@ ctxopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -ctxclose(dev_t dev, int flags, int fmt, struct proc *p) +ctxclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit; @@ -383,7 +383,7 @@ ctxread(dev_t dev, struct uio * uio, int ioflag) } static int -ctxioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +ctxioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int error; int unit, i; diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index 1c473e9..e9817d0 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -111,7 +111,7 @@ static void cxoproc (struct tty *tp); static void cxstop (struct tty *tp, int flag); static int cxparam (struct tty *tp, struct termios *t); -int cxopen (dev_t dev, int flag, int mode, struct proc *p) +int cxopen (dev_t dev, int flag, int mode, struct thread *td) { int unit = UNIT (dev); cx_chan_t *c = cxchan[unit]; @@ -162,7 +162,7 @@ int cxopen (dev_t dev, int flag, int mode, struct proc *p) tp = c->ttyp; tp->t_dev = dev; if ((tp->t_state & TS_ISOPEN) && (tp->t_state & TS_XCLUDE) && - suser(p)) + suser_td(td)) return (EBUSY); if (! (tp->t_state & TS_ISOPEN)) { ttychars (tp); @@ -247,7 +247,7 @@ int cxopen (dev_t dev, int flag, int mode, struct proc *p) return (error); } -int cxclose (dev_t dev, int flag, int mode, struct proc *p) +int cxclose (dev_t dev, int flag, int mode, struct thread *td) { int unit = UNIT (dev); cx_chan_t *c = cxchan[unit]; @@ -283,7 +283,7 @@ int cxclose (dev_t dev, int flag, int mode, struct proc *p) return (0); } -int cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +int cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit = UNIT (dev); cx_chan_t *c, *m; @@ -419,7 +419,7 @@ int cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (! tp) return (EINVAL); #if __FreeBSD__ >= 2 - error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, data, flag, td); #else error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, data, flag); #endif diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index 9d6f2bb..728ea0a 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -662,11 +662,11 @@ cyattach_common(cy_iobase, cy_align) } static int -sioopen(dev, flag, mode, p) +sioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -718,7 +718,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -847,11 +847,11 @@ out: } static int -sioclose(dev, flag, mode, p) +sioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int mynor; @@ -1605,12 +1605,12 @@ siointr1(com) #endif static int -sioioctl(dev, cmd, data, flag, p) +sioioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -1639,7 +1639,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1689,7 +1689,7 @@ sioioctl(dev, cmd, data, flag, p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); s = spltty(); @@ -1738,7 +1738,7 @@ sioioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/i386/isa/gpib.c b/sys/i386/isa/gpib.c index 8792395..4b96605 100644 --- a/sys/i386/isa/gpib.c +++ b/sys/i386/isa/gpib.c @@ -163,11 +163,11 @@ gpattach(isdp) * i.e. even if gpib5 is open, we can't open another minor device */ static int -gpopen(dev, flags, fmt, p) +gpopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { struct gpib_softc *sc = &gpib_sc; u_char unit; @@ -241,11 +241,11 @@ enableremote(unit); * Close gpib device. */ static int -gpclose(dev, flags, fmt, p) +gpclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { struct gpib_softc *sc = &gpib_sc; unsigned char unit; @@ -397,7 +397,7 @@ gpwrite(dev, uio, ioflag) write to using a minor device = its GPIB address */ static int -gpioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +gpioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { struct gpibdata *gd = (struct gpibdata *)data; int error,result; diff --git a/sys/i386/isa/gsc.c b/sys/i386/isa/gsc.c index 8d7ded3..29ad157 100644 --- a/sys/i386/isa/gsc.c +++ b/sys/i386/isa/gsc.c @@ -563,7 +563,7 @@ gscattach(struct isa_device *isdp) */ static int -gscopen (dev_t dev, int flags, int fmt, struct proc *p) +gscopen (dev_t dev, int flags, int fmt, struct thread *td) { struct gsc_unit *scu; int unit; @@ -630,7 +630,7 @@ gscopen (dev_t dev, int flags, int fmt, struct proc *p) */ static int -gscclose (dev_t dev, int flags, int fmt, struct proc *p) +gscclose (dev_t dev, int flags, int fmt, struct thread *td) { int unit = UNIT(minor(dev)); struct gsc_unit *scu = unittab + unit; @@ -753,7 +753,7 @@ gscread (dev_t dev, struct uio *uio, int ioflag) */ static int -gscioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +gscioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit = UNIT(minor(dev)); struct gsc_unit *scu = unittab + unit; diff --git a/sys/i386/isa/icu_vector.s b/sys/i386/isa/icu_vector.s index 6b48737..3a42af4 100644 --- a/sys/i386/isa/icu_vector.s +++ b/sys/i386/isa/icu_vector.s @@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \ mov $KPSEL,%ax ; \ mov %ax,%fs ; \ FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ pushl intr_unit + (irq_num) * 4 ; \ call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \ enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ @@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \ incl cnt+V_INTR ; /* book-keeping can wait */ \ movl intr_countp + (irq_num) * 4,%eax ; \ incl (%eax) ; \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ jmp doreti @@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \ movb %al,imen + IRQ_BYTE(irq_num) ; \ outb %al,$icu+ICU_IMR_OFFSET ; \ enable_icus ; \ - movl PCPU(CURPROC),%ebx ; \ - incl P_INTR_NESTING_LEVEL(%ebx) ; \ + movl PCPU(CURTHREAD),%ebx ; \ + incl TD_INTR_NESTING_LEVEL(%ebx) ; \ __CONCAT(Xresume,irq_num): ; \ FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \ pushl $irq_num; /* pass the IRQ */ \ call sched_ithd ; \ addl $4, %esp ; /* discard the parameter */ \ - decl P_INTR_NESTING_LEVEL(%ebx) ; \ + decl TD_INTR_NESTING_LEVEL(%ebx) ; \ MEXITCOUNT ; \ /* We could usually avoid the following jmp by inlining some of */ \ /* doreti, but it's probably better to use less cache. */ \ diff --git a/sys/i386/isa/ipl.s b/sys/i386/isa/ipl.s index d429f5a..c1b1d86 100644 --- a/sys/i386/isa/ipl.s +++ b/sys/i386/isa/ipl.s @@ -72,8 +72,9 @@ doreti_ast: * since we will be informed of any new ASTs by an IPI. */ cli - movl PCPU(CURPROC),%eax - testl $PS_ASTPENDING | PS_NEEDRESCHED,P_SFLAG(%eax) + movl PCPU(CURTHREAD),%eax + movl TD_KSE(%eax), %eax + testl $KEF_ASTPENDING | KEF_NEEDRESCHED,KE_FLAGS(%eax) je doreti_exit sti pushl %esp /* pass a pointer to the trapframe */ diff --git a/sys/i386/isa/istallion.c b/sys/i386/isa/istallion.c index b8ba4db..0b95211 100644 --- a/sys/i386/isa/istallion.c +++ b/sys/i386/isa/istallion.c @@ -573,7 +573,7 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); static int stli_memrw(dev_t dev, struct uio *uiop, int flag); static int stli_memioctl(dev_t dev, unsigned long cmd, caddr_t data, - int flag, struct proc *p); + int flag, struct thread *td); static int stli_getbrdstats(caddr_t data); static int stli_getportstats(stliport_t *portp, caddr_t data); static int stli_clrportstats(stliport_t *portp, caddr_t data); @@ -925,7 +925,7 @@ static int stliattach(struct isa_device *idp) /*****************************************************************************/ -STATIC int stliopen(dev_t dev, int flag, int mode, struct proc *p) +STATIC int stliopen(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; stliport_t *portp; @@ -933,7 +933,7 @@ STATIC int stliopen(dev_t dev, int flag, int mode, struct proc *p) #if DEBUG printf("stliopen(dev=%x,flag=%x,mode=%x,p=%x)\n", (int) dev, flag, - mode, (int) p); + mode, (int) td); #endif /* @@ -1010,7 +1010,7 @@ stliopen_restart: } } if ((tp->t_state & TS_XCLUDE) && - suser(p)) { + suser_td(td)) { error = EBUSY; goto stliopen_end; } @@ -1054,7 +1054,7 @@ stliopen_end: /*****************************************************************************/ -STATIC int stliclose(dev_t dev, int flag, int mode, struct proc *p) +STATIC int stliclose(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; stliport_t *portp; @@ -1062,7 +1062,7 @@ STATIC int stliclose(dev_t dev, int flag, int mode, struct proc *p) #if DEBUG printf("stliclose(dev=%s,flag=%x,mode=%x,p=%p)\n", - devtoname(dev), flag, mode, (void *) p); + devtoname(dev), flag, mode, (void *) td); #endif if (minor(dev) & STL_MEMDEV) @@ -1142,7 +1142,7 @@ STATIC int stliwrite(dev_t dev, struct uio *uiop, int flag) /*****************************************************************************/ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { struct termios *newtios, *localtios; struct tty *tp; @@ -1153,11 +1153,11 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, #if DEBUG printf("stliioctl(dev=%s,cmd=%lx,data=%p,flag=%x,p=%p)\n", - devtoname(dev), cmd, (void *) data, flag, (void *) p); + devtoname(dev), cmd, (void *) data, flag, (void *) td); #endif if (minor(dev) & STL_MEMDEV) - return(stli_memioctl(dev, cmd, data, flag, p)); + return(stli_memioctl(dev, cmd, data, flag, td)); portp = stli_dev2port(dev); if (portp == (stliport_t *) NULL) @@ -1182,7 +1182,7 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, switch (cmd) { case TIOCSETA: - if ((error = suser(p)) == 0) + if ((error = suser_td(td)) == 0) *localtios = *((struct termios *) data); break; case TIOCGETA: @@ -1249,7 +1249,7 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, * Call the line discipline and the common command processing to * process this command (if they can). */ - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return(error); @@ -1318,7 +1318,7 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, *((int *) data) = (portp->sigs | TIOCM_LE); break; case TIOCMSDTRWAIT: - if ((error = suser(p)) == 0) + if ((error = suser_td(td)) == 0) portp->dtrwait = *((int *) data) * hz / 100; break; case TIOCMGDTRWAIT: @@ -3799,7 +3799,7 @@ STATIC int stli_memrw(dev_t dev, struct uio *uiop, int flag) */ static int stli_memioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { stlibrd_t *brdp; int brdnr, rc; diff --git a/sys/i386/isa/loran.c b/sys/i386/isa/loran.c index cedcd0f..9ad1a4a 100644 --- a/sys/i386/isa/loran.c +++ b/sys/i386/isa/loran.c @@ -328,7 +328,7 @@ loranattach(struct isa_device *isdp) } static int -loranopen (dev_t dev, int flags, int fmt, struct proc *p) +loranopen (dev_t dev, int flags, int fmt, struct thread *td) { int idx; @@ -340,7 +340,7 @@ loranopen (dev_t dev, int flags, int fmt, struct proc *p) } static int -loranclose(dev_t dev, int flags, int fmt, struct proc *p) +loranclose(dev_t dev, int flags, int fmt, struct thread *td) { return(0); } diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c index 7c3e758..0ec1c2e 100644 --- a/sys/i386/isa/matcd/matcd.c +++ b/sys/i386/isa/matcd/matcd.c @@ -608,7 +608,7 @@ static int docmd(char * cmd, int ldrive, int cdrive, <15> the drive to be locked while being accessed. ---------------------------------------------------------------------------*/ int matcdopen(dev_t dev, int flags, int fmt, - struct proc *p) + struct thread *td) { int cdrive,ldrive,partition,controller,lock; struct matcd_data *cd; @@ -797,7 +797,7 @@ int matcdopen(dev_t dev, int flags, int fmt, ---------------------------------------------------------------------------*/ int matcdclose(dev_t dev, int flags, int fmt, - struct proc *p) + struct thread *td) { int ldrive,cdrive,port,partition,controller,lock; struct matcd_data *cd; @@ -985,7 +985,7 @@ static void matcd_start(int controller) ---------------------------------------------------------------------------*/ int matcdioctl(dev_t dev, u_long command, caddr_t addr, - int flags, struct proc *p) + int flags, struct thread *td) { struct matcd_data *cd; int ldrive,cdrive,partition; @@ -2062,7 +2062,7 @@ nextblock: int docmd(char * cmd, int ldrive, int cdrive, int controller, int port) { - int retries,i,z; + int retries,i=0,z; lockbus(controller, ldrive); /*Request bus*/ retries=3; diff --git a/sys/i386/isa/mcd.c b/sys/i386/isa/mcd.c index 6f8c0f7..f295a43 100644 --- a/sys/i386/isa/mcd.c +++ b/sys/i386/isa/mcd.c @@ -270,7 +270,7 @@ int mcd_attach(struct isa_device *dev) return 1; } -int mcdopen(dev_t dev, int flags, int fmt, struct proc *p) +int mcdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys,r,retry; struct mcd_data *cd; @@ -362,7 +362,7 @@ MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n", return ENXIO; } -int mcdclose(dev_t dev, int flags, int fmt, struct proc *p) +int mcdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part; struct mcd_data *cd; @@ -504,7 +504,7 @@ static void mcd_start(int unit) return; } -int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct mcd_data *cd; int unit,part,retry,r; diff --git a/sys/i386/isa/mse.c b/sys/i386/isa/mse.c index 073ea7a..915bc3f 100644 --- a/sys/i386/isa/mse.c +++ b/sys/i386/isa/mse.c @@ -394,11 +394,11 @@ mse_detach(dev) * Exclusive open the mouse, initialize it and enable interrupts. */ static int -mseopen(dev, flags, fmt, p) +mseopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { mse_softc_t *sc; int s; @@ -434,11 +434,11 @@ mseopen(dev, flags, fmt, p) * mseclose: just turn off mouse innterrupts. */ static int -mseclose(dev, flags, fmt, p) +mseclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); int s; @@ -525,12 +525,12 @@ mseread(dev, uio, ioflag) * mseioctl: process ioctl commands. */ static int -mseioctl(dev, cmd, addr, flag, p) +mseioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); mousestatus_t status; @@ -642,10 +642,10 @@ mseioctl(dev, cmd, addr, flag, p) * msepoll: check for mouse input to be processed. */ static int -msepoll(dev, events, p) +msepoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev)); int s; @@ -662,7 +662,7 @@ msepoll(dev, events, p) * Since this is an exclusive open device, any previous * proc pointer is trash now, so we can just assign it. */ - selrecord(p, &sc->sc_selp); + selrecord(td, &sc->sc_selp); } } splx(s); diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index 4fe3d04..84534ea 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -128,23 +128,23 @@ void stop_emulating __P((void)); #endif /* __GNUC__ */ #ifdef CPU_ENABLE_SSE -#define GET_FPU_CW(proc) \ +#define GET_FPU_CW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_cw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ (cpu_fxsr ? \ - (proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_sw : \ - (proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) + (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \ + (thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (cpu_fxsr ? \ &(pcb)->pcb_save.sv_xmm.sv_ex_sw : \ &(pcb)->pcb_save.sv_87.sv_ex_sw) #else /* CPU_ENABLE_SSE */ -#define GET_FPU_CW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw) -#define GET_FPU_SW(proc) \ - (proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw) +#define GET_FPU_CW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_cw) +#define GET_FPU_SW(thread) \ + (thread->td_pcb->pcb_save.sv_87.sv_env.en_sw) #define GET_FPU_EXSW_PTR(pcb) \ (&(pcb)->pcb_save.sv_87.sv_ex_sw) #endif /* CPU_ENABLE_SSE */ @@ -241,7 +241,7 @@ static void npx_intr(dummy) void *dummy; { - struct proc *p; + struct thread *td; /* * The BUSY# latch must be cleared in all cases so that the next @@ -250,22 +250,22 @@ npx_intr(dummy) outb(0xf0, 0); /* - * npxproc is normally non-null here. In that case, schedule an + * npxthread is normally non-null here. In that case, schedule an * AST to finish the exception handling in the correct context - * (this interrupt may occur after the process has entered the + * (this interrupt may occur after the thread has entered the * kernel via a syscall or an interrupt). Otherwise, the npx - * state of the process that caused this interrupt must have been - * pushed to the process' pcb, and clearing of the busy latch + * state of the thread that caused this interrupt must have been + * pushed to the thread' pcb, and clearing of the busy latch * above has finished the (essentially null) handling of this * interrupt. Control will eventually return to the instruction * that caused it and it will repeat. We will eventually (usually * soon) win the race to handle the interrupt properly. */ - p = PCPU_GET(npxproc); - if (p != NULL) { - p->p_addr->u_pcb.pcb_flags |= PCB_NPXTRAP; + td = PCPU_GET(npxthread); + if (td != NULL) { + td->td_pcb->pcb_flags |= PCB_NPXTRAP; mtx_lock_spin(&sched_lock); - p->p_sflag |= PS_ASTPENDING; + td->td_kse->ke_flags |= KEF_ASTPENDING; mtx_unlock_spin(&sched_lock); } } @@ -570,7 +570,7 @@ npxinit(control) /* * fninit has the same h/w bugs as fnsave. Use the detoxified * fnsave to throw away any junk in the fpu. npxsave() initializes - * the fpu and sets npxproc = NULL as important side effects. + * the fpu and sets npxthread = NULL as important side effects. */ savecrit = critical_enter(); npxsave(&dummy); @@ -586,13 +586,13 @@ npxinit(control) * Free coprocessor (if we have it). */ void -npxexit(p) - struct proc *p; +npxexit(td) + struct thread *td; { critical_t savecrit; savecrit = critical_enter(); - if (p == PCPU_GET(npxproc)) + if (td == PCPU_GET(npxthread)) npxsave(&PCPU_GET(curpcb)->pcb_save); critical_exit(savecrit); #ifdef NPX_DEBUG @@ -607,8 +607,9 @@ npxexit(p) */ if (masked_exceptions & 0x0d) log(LOG_ERR, - "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", - p->p_pid, p->p_comm, masked_exceptions); + "pid %d (%s) exited with masked floating" + " point exceptions 0x%02x\n", + td->td_proc->p_pid, td->td_proc->p_comm, masked_exceptions); } #endif } @@ -809,8 +810,8 @@ npxtrap() u_long *exstat; if (!npx_exists) { - printf("npxtrap: npxproc = %p, curproc = %p, npx_exists = %d\n", - PCPU_GET(npxproc), curproc, npx_exists); + printf("npxtrap: npxthread = %p, curthread = %p, npx_exists = %d\n", + PCPU_GET(npxthread), curthread, npx_exists); panic("npxtrap from nowhere"); } savecrit = critical_enter(); @@ -820,18 +821,18 @@ npxtrap() * state to memory. Fetch the relevant parts of the state from * wherever they are. */ - if (PCPU_GET(npxproc) != curproc) { - control = GET_FPU_CW(curproc); - status = GET_FPU_SW(curproc); + if (PCPU_GET(npxthread) != curthread) { + control = GET_FPU_CW(curthread); + status = GET_FPU_SW(curthread); } else { fnstcw(&control); fnstsw(&status); } - exstat = GET_FPU_EXSW_PTR(&curproc->p_addr->u_pcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); *exstat = status; - if (PCPU_GET(npxproc) != curproc) - GET_FPU_SW(curproc) &= ~0x80bf; + if (PCPU_GET(npxthread) != curthread) + GET_FPU_SW(curthread) &= ~0x80bf; else fnclex(); critical_exit(savecrit); @@ -841,7 +842,7 @@ npxtrap() /* * Implement device not available (DNA) exception * - * It would be better to switch FP context here (if curproc != npxproc) + * It would be better to switch FP context here (if curthread != npxthread) * and not necessarily for every context switch, but it is too hard to * access foreign pcb's. */ @@ -853,9 +854,9 @@ npxdna() if (!npx_exists) return (0); - if (PCPU_GET(npxproc) != NULL) { - printf("npxdna: npxproc = %p, curproc = %p\n", - PCPU_GET(npxproc), curproc); + if (PCPU_GET(npxthread) != NULL) { + printf("npxdna: npxthread = %p, curthread = %p\n", + PCPU_GET(npxthread), curthread); panic("npxdna"); } s = critical_enter(); @@ -863,7 +864,7 @@ npxdna() /* * Record new context early in case frstor causes an IRQ13. */ - PCPU_SET(npxproc, CURPROC); + PCPU_SET(npxthread, curthread); exstat = GET_FPU_EXSW_PTR(PCPU_GET(curpcb)); *exstat = 0; @@ -895,13 +896,13 @@ npxdna() * after the process has entered the kernel. It may even be delivered after * the fnsave here completes. A spurious IRQ13 for the fnsave is handled in * the same way as a very-late-arriving non-spurious IRQ13 from user mode: - * it is normally ignored at first because we set npxproc to NULL; it is + * it is normally ignored at first because we set npxthread to NULL; it is * normally retriggered in npxdna() after return to user mode. * * npxsave() must be called with interrupts disabled, so that it clears - * npxproc atomically with saving the state. We require callers to do the + * npxthread atomically with saving the state. We require callers to do the * disabling, since most callers need to disable interrupts anyway to call - * npxsave() atomically with checking npxproc. + * npxsave() atomically with checking npxthread. * * A previous version of npxsave() went to great lengths to excecute fnsave * with interrupts enabled in case executing it froze the CPU. This case @@ -917,7 +918,7 @@ npxsave(addr) fpusave(addr); start_emulating(); - PCPU_SET(npxproc, NULL); + PCPU_SET(npxthread, NULL); } static void diff --git a/sys/i386/isa/pcaudio.c b/sys/i386/isa/pcaudio.c index ebfce44..8002fcc 100644 --- a/sys/i386/isa/pcaudio.c +++ b/sys/i386/isa/pcaudio.c @@ -361,7 +361,7 @@ DRIVER_MODULE(pca, isa, pca_driver, pca_devclass, 0, 0); static int -pcaopen(dev_t dev, int flags, int fmt, struct proc *p) +pcaopen(dev_t dev, int flags, int fmt, struct thread *td) { /* audioctl device can always be opened */ if (minor(dev) == 128) @@ -389,7 +389,7 @@ pcaopen(dev_t dev, int flags, int fmt, struct proc *p) static int -pcaclose(dev_t dev, int flags, int fmt, struct proc *p) +pcaclose(dev_t dev, int flags, int fmt, struct thread *td) { /* audioctl device can always be closed */ if (minor(dev) == 128) @@ -460,7 +460,7 @@ pcawrite(dev_t dev, struct uio *uio, int flag) static int -pcaioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +pcaioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { audio_info_t *auptr; @@ -560,7 +560,7 @@ pcaintr(struct clockframe *frame) static int -pcapoll(dev_t dev, int events, struct proc *p) +pcapoll(dev_t dev, int events, struct thread *td) { int s; int revents = 0; @@ -572,7 +572,7 @@ pcapoll(dev_t dev, int events, struct proc *p) !pca_status.in_use[2]) revents |= events & (POLLOUT | POLLWRNORM); else - selrecord(p, &pca_status.wsel); + selrecord(td, &pca_status.wsel); } splx(s); return (revents); diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 3c1cdea..3b0a64f 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -280,7 +280,7 @@ pcvt_attach(device_t dev) * driver open *---------------------------------------------------------------------------*/ static int -pcvt_open(dev_t dev, int flag, int mode, struct proc *p) +pcvt_open(dev_t dev, int flag, int mode, struct thread *td) { register struct tty *tp; register struct video_state *vsx; @@ -316,7 +316,7 @@ pcvt_open(dev_t dev, int flag, int mode, struct proc *p) (*linesw[tp->t_line].l_modem)(tp, 1); /* fake connection */ winsz = 1; /* set winsize later */ } - else if (tp->t_state & TS_XCLUDE && suser(p)) + else if (tp->t_state & TS_XCLUDE && suser_td(td)) { return (EBUSY); } @@ -348,7 +348,7 @@ pcvt_open(dev_t dev, int flag, int mode, struct proc *p) * driver close *---------------------------------------------------------------------------*/ static int -pcvt_close(dev_t dev, int flag, int mode, struct proc *p) +pcvt_close(dev_t dev, int flag, int mode, struct thread *td) { register struct tty *tp; register struct video_state *vsx; @@ -378,7 +378,7 @@ pcvt_close(dev_t dev, int flag, int mode, struct proc *p) * driver ioctl *---------------------------------------------------------------------------*/ static int -pcvt_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +pcvt_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { register int error; register struct tty *tp; @@ -396,7 +396,7 @@ pcvt_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) */ #ifdef XSERVER - if((error = usl_vt_ioctl(dev, cmd, data, flag, p)) >= 0) + if((error = usl_vt_ioctl(dev, cmd, data, flag, td)) >= 0) return error; #endif /* XSERVER */ @@ -406,7 +406,7 @@ pcvt_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if((error = vgaioctl(dev,cmd,data,flag)) >= 0) return error; - if((error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p)) + if((error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td)) != ENOIOCTL) return (error); diff --git a/sys/i386/isa/pcvt/pcvt_ext.c b/sys/i386/isa/pcvt/pcvt_ext.c index 967c928..7c9ed5f 100644 --- a/sys/i386/isa/pcvt/pcvt_ext.c +++ b/sys/i386/isa/pcvt/pcvt_ext.c @@ -2392,8 +2392,9 @@ vgapage(int new_screen) * ioctl handling for VT_USL mode *---------------------------------------------------------------------------*/ int -usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) { + struct proc *p = td->td_proc; int i, j, error, opri; struct vt_mode newmode; @@ -2613,9 +2614,9 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) /* grant the process IO access; only allowed if euid == 0 */ /* and insecure */ { - struct trapframe *fp = p->p_frame; + struct trapframe *fp = td->td_frame; - error = suser(p); + error = suser_td(td); if (error != 0) return (error); if (securelevel > 0) @@ -2629,7 +2630,7 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case KDDISABIO: /* abandon IO access permission */ { - struct trapframe *fp = p->p_frame; + struct trapframe *fp = td->td_frame; fp->tf_eflags &= ~PSL_IOPL; return 0; } diff --git a/sys/i386/isa/pcvt/pcvt_hdr.h b/sys/i386/isa/pcvt/pcvt_hdr.h index 4c9f540..46ea500 100644 --- a/sys/i386/isa/pcvt/pcvt_hdr.h +++ b/sys/i386/isa/pcvt/pcvt_hdr.h @@ -994,7 +994,7 @@ void update_hp ( struct video_state *svsp ); void update_led ( void ); #ifdef XSERVER -int usl_vt_ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *); +int usl_vt_ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct thread *); #endif void vga10_vga10 ( u_char *invga, u_char *outvga ); diff --git a/sys/i386/isa/rc.c b/sys/i386/isa/rc.c index e4252e0..59e8dff 100644 --- a/sys/i386/isa/rc.c +++ b/sys/i386/isa/rc.c @@ -715,10 +715,10 @@ rc_stop(tp, rw) } static int -rcopen(dev, flag, mode, p) +rcopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct rc_chans *rc; register struct tty *tp; @@ -764,7 +764,7 @@ again: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -810,10 +810,10 @@ out: } static int -rcclose(dev, flag, mode, p) +rcclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct rc_chans *rc; register struct tty *tp; @@ -1064,18 +1064,18 @@ struct rc_softc *rcb; } static int -rcioctl(dev, cmd, data, flag, p) +rcioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; int flag; caddr_t data; -struct proc *p; +struct thread *td; { register struct rc_chans *rc = &rc_chans[GET_UNIT(dev)]; register int s, error; struct tty *tp = rc->rc_tp; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); error = ttioctl(tp, cmd, data, flag); @@ -1118,7 +1118,7 @@ struct proc *p; break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/i386/isa/scd.c b/sys/i386/isa/scd.c index 1ab5afa..4561d90 100644 --- a/sys/i386/isa/scd.c +++ b/sys/i386/isa/scd.c @@ -232,7 +232,7 @@ scd_attach(struct isa_device *dev) } static int -scdopen(dev_t dev, int flags, int fmt, struct proc *p) +scdopen(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys; int rc; @@ -286,7 +286,7 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -scdclose(dev_t dev, int flags, int fmt, struct proc *p) +scdclose(dev_t dev, int flags, int fmt, struct thread *td) { int unit,part,phys; struct scd_data *cd; @@ -418,7 +418,7 @@ scd_start(int unit) } static int -scdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +scdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct scd_data *cd; int unit,part; diff --git a/sys/i386/isa/spic.c b/sys/i386/isa/spic.c index 9593d73..a708658 100644 --- a/sys/i386/isa/spic.c +++ b/sys/i386/isa/spic.c @@ -362,7 +362,7 @@ spictimeout(void *arg) } static int -spicopen(dev_t dev, int flag, int fmt, struct proc *p) +spicopen(dev_t dev, int flag, int fmt, struct thread *td) { struct spic_softc *sc; @@ -380,7 +380,7 @@ spicopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -spicclose(dev_t dev, int flag, int fmt, struct proc *p) +spicclose(dev_t dev, int flag, int fmt, struct thread *td) { struct spic_softc *sc; @@ -427,7 +427,7 @@ spicread(dev_t dev, struct uio *uio, int flag) } static int -spicioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +spicioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct spic_softc *sc; @@ -437,7 +437,7 @@ spicioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) } static int -spicpoll(dev_t dev, int events, struct proc *p) +spicpoll(dev_t dev, int events, struct thread *td) { struct spic_softc *sc; int revents = 0, s; @@ -448,7 +448,7 @@ spicpoll(dev_t dev, int events, struct proc *p) if (sc->sc_count) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->sc_rsel); /* Who shall we wake? */ + selrecord(td, &sc->sc_rsel); /* Who shall we wake? */ } splx(s); diff --git a/sys/i386/isa/spigot.c b/sys/i386/isa/spigot.c index db4a926..0bd87ff 100644 --- a/sys/i386/isa/spigot.c +++ b/sys/i386/isa/spigot.c @@ -161,7 +161,7 @@ spigot_attach(struct isa_device *devp) } static int -spigot_open(dev_t dev, int flags, int fmt, struct proc *p) +spigot_open(dev_t dev, int flags, int fmt, struct thread *td) { int error; struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; @@ -179,7 +179,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; * require sufficient privilege soon and nothing much can be done * without them. */ - error = suser(p); + error = suser_td(td); if (error != 0) return error; if (securelevel > 0) @@ -194,7 +194,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; } static int -spigot_close(dev_t dev, int flags, int fmt, struct proc *p) +spigot_close(dev_t dev, int flags, int fmt, struct thread *td) { struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; @@ -221,7 +221,7 @@ spigot_read(dev_t dev, struct uio *uio, int ioflag) static int -spigot_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +spigot_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int error; struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; @@ -230,21 +230,21 @@ struct spigot_info *info; if(!data) return(EINVAL); switch(cmd){ case SPIGOT_SETINT: - ss->p = p; + ss->p = td->td_proc; ss->signal_num = *((int *)data); break; case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */ #if !defined(SPIGOT_UNSECURE) - error = suser(p); + error = suser_td(td); if (error != 0) return error; if (securelevel > 0) return EPERM; #endif - p->p_frame->tf_eflags |= PSL_IOPL; + td->td_frame->tf_eflags |= PSL_IOPL; break; case SPIGOT_IOPL_OFF: /* deny access to the IO PAGE */ - p->p_frame->tf_eflags &= ~PSL_IOPL; + td->td_frame->tf_eflags &= ~PSL_IOPL; break; case SPIGOT_GET_INFO: info = (struct spigot_info *)data; diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c index 0fadea8..e0986de 100644 --- a/sys/i386/isa/spkr.c +++ b/sys/i386/isa/spkr.c @@ -460,11 +460,11 @@ static int spkr_active = FALSE; /* exclusion flag */ static char *spkr_inbuf; /* incoming buf */ int -spkropen(dev, flags, fmt, p) +spkropen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkropen: entering with dev = %s\n", devtoname(dev)); @@ -519,11 +519,11 @@ spkrwrite(dev, uio, ioflag) } int -spkrclose(dev, flags, fmt, p) +spkrclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev)); @@ -542,12 +542,12 @@ spkrclose(dev, flags, fmt, p) } int -spkrioctl(dev, cmd, cmdarg, flags, p) +spkrioctl(dev, cmd, cmdarg, flags, td) dev_t dev; unsigned long cmd; caddr_t cmdarg; int flags; - struct proc *p; + struct thread *td; { #ifdef DEBUG (void) printf("spkrioctl: entering with dev = %s, cmd = %lx\n", diff --git a/sys/i386/isa/stallion.c b/sys/i386/isa/stallion.c index b77ec96..c9c0df5 100644 --- a/sys/i386/isa/stallion.c +++ b/sys/i386/isa/stallion.c @@ -484,7 +484,7 @@ static void stl_disableintrs(stlport_t *portp); static void stl_sendbreak(stlport_t *portp, long len); static void stl_flush(stlport_t *portp, int flag); static int stl_memioctl(dev_t dev, unsigned long cmd, caddr_t data, - int flag, struct proc *p); + int flag, struct thread *td); static int stl_getbrdstats(caddr_t data); static int stl_getportstats(stlport_t *portp, caddr_t data); static int stl_clrportstats(stlport_t *portp, caddr_t data); @@ -759,7 +759,7 @@ void stlpciattach(pcici_t tag, int unit) /*****************************************************************************/ -STATIC int stlopen(dev_t dev, int flag, int mode, struct proc *p) +STATIC int stlopen(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; stlport_t *portp; @@ -767,7 +767,7 @@ STATIC int stlopen(dev_t dev, int flag, int mode, struct proc *p) #if DEBUG printf("stlopen(dev=%x,flag=%x,mode=%x,p=%x)\n", (int) dev, flag, - mode, (int) p); + mode, (int) td); #endif /* @@ -832,7 +832,7 @@ stlopen_restart: } } if ((tp->t_state & TS_XCLUDE) && - suser(p)) { + suser_td(td)) { error = EBUSY; goto stlopen_end; } @@ -876,7 +876,7 @@ stlopen_end: /*****************************************************************************/ -STATIC int stlclose(dev_t dev, int flag, int mode, struct proc *p) +STATIC int stlclose(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; stlport_t *portp; @@ -884,7 +884,7 @@ STATIC int stlclose(dev_t dev, int flag, int mode, struct proc *p) #if DEBUG printf("stlclose(dev=%s,flag=%x,mode=%x,p=%p)\n", devtoname(dev), - flag, mode, (void *) p); + flag, mode, (void *) td); #endif if (minor(dev) & STL_MEMDEV) @@ -934,7 +934,7 @@ STATIC int stlstop(struct tty *tp, int rw) /*****************************************************************************/ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { struct termios *newtios, *localtios; struct tty *tp; @@ -943,11 +943,11 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, #if DEBUG printf("stlioctl(dev=%s,cmd=%lx,data=%p,flag=%x,p=%p)\n", - devtoname(dev), cmd, (void *) data, flag, (void *) p); + devtoname(dev), cmd, (void *) data, flag, (void *) td); #endif if (minor(dev) & STL_MEMDEV) - return(stl_memioctl(dev, cmd, data, flag, p)); + return(stl_memioctl(dev, cmd, data, flag, td)); portp = stl_dev2port(dev); if (portp == (stlport_t *) NULL) @@ -970,7 +970,7 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, switch (cmd) { case TIOCSETA: - if ((error = suser(p)) == 0) + if ((error = suser_td(td)) == 0) *localtios = *((struct termios *) data); break; case TIOCGETA: @@ -1037,7 +1037,7 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, * Call the line discipline and the common command processing to * process this command (if they can). */ - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return(error); @@ -1088,7 +1088,7 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, *((int *) data) = (stl_getsignals(portp) | TIOCM_LE); break; case TIOCMSDTRWAIT: - if ((error = suser(p)) == 0) + if ((error = suser_td(td)) == 0) portp->dtrwait = *((int *) data) * hz / 100; break; case TIOCMGDTRWAIT: @@ -3048,7 +3048,7 @@ static int stl_clrportstats(stlport_t *portp, caddr_t data) */ static int stl_memioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, - struct proc *p) + struct thread *td) { stlbrd_t *brdp; int brdnr, rc; diff --git a/sys/i386/isa/tw.c b/sys/i386/isa/tw.c index 4bb509d..5d68678 100644 --- a/sys/i386/isa/tw.c +++ b/sys/i386/isa/tw.c @@ -418,11 +418,11 @@ static int twattach(idp) return (1); } -int twopen(dev, flag, mode, p) +int twopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct tw_sc *sc = &tw_sc[TWUNIT(dev)]; int s; @@ -438,11 +438,11 @@ int twopen(dev, flag, mode, p) return(0); } -int twclose(dev, flag, mode, p) +int twclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct tw_sc *sc = &tw_sc[TWUNIT(dev)]; int s; @@ -544,10 +544,10 @@ int twwrite(dev, uio, ioflag) * Determine if there is data available for reading */ -int twpoll(dev, events, p) +int twpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { struct tw_sc *sc; int s; @@ -560,7 +560,7 @@ int twpoll(dev, events, p) if(sc->sc_nextin != sc->sc_nextout) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->sc_selp); + selrecord(td, &sc->sc_selp); } splx(s); return(revents); diff --git a/sys/i386/isa/vesa.c b/sys/i386/isa/vesa.c index 0fa16b5..09d2a7d 100644 --- a/sys/i386/isa/vesa.c +++ b/sys/i386/isa/vesa.c @@ -672,6 +672,8 @@ vesa_bios_init(void) continue; /* reject unsupported modes */ +#define DOTHIS 1 +#ifdef DOTHIS #if 0 if ((vmode.v_modeattr & (V_MODESUPP | V_MODEOPTINFO | V_MODENONVGA)) @@ -689,6 +691,7 @@ vesa_bios_init(void) continue; } #endif +#endif /* DOTHIS */ /* expand the array if necessary */ if (modes >= vesa_vmode_max) { diff --git a/sys/i386/isa/wt.c b/sys/i386/isa/wt.c index 0adf3c8..4dc9818 100644 --- a/sys/i386/isa/wt.c +++ b/sys/i386/isa/wt.c @@ -285,7 +285,7 @@ COMPAT_ISA_DRIVER(wt, wtdriver); * Open routine, called on every device open. */ static int -wtopen (dev_t dev, int flag, int fmt, struct proc *p) +wtopen (dev_t dev, int flag, int fmt, struct thread *td) { int u = minor (dev) & T_UNIT; wtinfo_t *t = wttab + u; @@ -367,7 +367,7 @@ wtopen (dev_t dev, int flag, int fmt, struct proc *p) * Close routine, called on last device close. */ static int -wtclose (dev_t dev, int flags, int fmt, struct proc *p) +wtclose (dev_t dev, int flags, int fmt, struct thread *td) { int u = minor (dev) & T_UNIT; wtinfo_t *t = wttab + u; @@ -416,7 +416,7 @@ done: * ioctl (int fd, MTIOCTOP, struct mtop *buf) -- do BSD-like op */ static int -wtioctl (dev_t dev, u_long cmd, caddr_t arg, int flags, struct proc *p) +wtioctl (dev_t dev, u_long cmd, caddr_t arg, int flags, struct thread *td) { int u = minor (dev) & T_UNIT; wtinfo_t *t = wttab + u; diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index 594ebfc..2b2a916 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -40,8 +40,8 @@ */ extern u_char linux_debug_map[]; #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)p->p_pid -#define LMSG(fmt) "linux(%ld): "fmt"\n", (long)p->p_pid +#define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid +#define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINUX); @@ -453,9 +453,9 @@ extern struct sysentvec elf_linux_sysvec; * Pluggable ioctl handlers */ struct linux_ioctl_args; -struct proc; +struct thread; -typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *); +typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *); struct linux_ioctl_handler { linux_ioctl_function_t *func; diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index dfae7f4..ba443bb 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -99,13 +99,13 @@ bsd_to_linux_sigaltstack(int bsa) } int -linux_execve(struct proc *p, struct linux_execve_args *args) +linux_execve(struct thread *td, struct linux_execve_args *args) { struct execve_args bsd; caddr_t sg; sg = stackgap_init(); - CHECKALTEXIST(p, &sg, args->path); + CHECKALTEXIST(td, &sg, args->path); #ifdef DEBUG if (ldebug(execve)) @@ -115,7 +115,7 @@ linux_execve(struct proc *p, struct linux_execve_args *args) bsd.fname = args->path; bsd.argv = args->argp; bsd.envv = args->envp; - return (execve(p, &bsd)); + return (execve(td, &bsd)); } struct l_ipc_kludge { @@ -124,7 +124,7 @@ struct l_ipc_kludge { }; int -linux_ipc(struct proc *p, struct linux_ipc_args *args) +linux_ipc(struct thread *td, struct linux_ipc_args *args) { switch (args->what & 0xFFFF) { @@ -134,7 +134,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.semid = args->arg1; a.tsops = args->ptr; a.nsops = args->arg2; - return (linux_semop(p, &a)); + return (linux_semop(td, &a)); } case LINUX_SEMGET: { struct linux_semget_args a; @@ -142,7 +142,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.key = args->arg1; a.nsems = args->arg2; a.semflg = args->arg3; - return (linux_semget(p, &a)); + return (linux_semget(td, &a)); } case LINUX_SEMCTL: { struct linux_semctl_args a; @@ -154,7 +154,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) error = copyin((caddr_t)args->ptr, &a.arg, sizeof(a.arg)); if (error) return (error); - return (linux_semctl(p, &a)); + return (linux_semctl(td, &a)); } case LINUX_MSGSND: { struct linux_msgsnd_args a; @@ -163,7 +163,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.msgp = args->ptr; a.msgsz = args->arg2; a.msgflg = args->arg3; - return (linux_msgsnd(p, &a)); + return (linux_msgsnd(td, &a)); } case LINUX_MSGRCV: { struct linux_msgrcv_args a; @@ -186,14 +186,14 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.msgp = args->ptr; a.msgtyp = args->arg5; } - return (linux_msgrcv(p, &a)); + return (linux_msgrcv(td, &a)); } case LINUX_MSGGET: { struct linux_msgget_args a; a.key = args->arg1; a.msgflg = args->arg2; - return (linux_msgget(p, &a)); + return (linux_msgget(td, &a)); } case LINUX_MSGCTL: { struct linux_msgctl_args a; @@ -201,7 +201,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.msqid = args->arg1; a.cmd = args->arg2; a.buf = args->ptr; - return (linux_msgctl(p, &a)); + return (linux_msgctl(td, &a)); } case LINUX_SHMAT: { struct linux_shmat_args a; @@ -210,13 +210,13 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.shmaddr = args->ptr; a.shmflg = args->arg2; a.raddr = (l_ulong *)args->arg3; - return (linux_shmat(p, &a)); + return (linux_shmat(td, &a)); } case LINUX_SHMDT: { struct linux_shmdt_args a; a.shmaddr = args->ptr; - return (linux_shmdt(p, &a)); + return (linux_shmdt(td, &a)); } case LINUX_SHMGET: { struct linux_shmget_args a; @@ -224,7 +224,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.key = args->arg1; a.size = args->arg2; a.shmflg = args->arg3; - return (linux_shmget(p, &a)); + return (linux_shmget(td, &a)); } case LINUX_SHMCTL: { struct linux_shmctl_args a; @@ -232,7 +232,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) a.shmid = args->arg1; a.cmd = args->arg2; a.buf = args->ptr; - return (linux_shmctl(p, &a)); + return (linux_shmctl(td, &a)); } default: break; @@ -242,7 +242,7 @@ linux_ipc(struct proc *p, struct linux_ipc_args *args) } int -linux_old_select(struct proc *p, struct linux_old_select_args *args) +linux_old_select(struct thread *td, struct linux_old_select_args *args) { struct l_old_select_argv linux_args; struct linux_select_args newsel; @@ -262,11 +262,11 @@ linux_old_select(struct proc *p, struct linux_old_select_args *args) newsel.writefds = linux_args.writefds; newsel.exceptfds = linux_args.exceptfds; newsel.timeout = linux_args.timeout; - return (linux_select(p, &newsel)); + return (linux_select(td, &newsel)); } int -linux_fork(struct proc *p, struct linux_fork_args *args) +linux_fork(struct thread *td, struct linux_fork_args *args) { int error; @@ -275,16 +275,16 @@ linux_fork(struct proc *p, struct linux_fork_args *args) printf(ARGS(fork, "")); #endif - if ((error = fork(p, (struct fork_args *)args)) != 0) + if ((error = fork(td, (struct fork_args *)args)) != 0) return (error); - if (p->p_retval[1] == 1) - p->p_retval[0] = 0; + if (td->td_retval[1] == 1) + td->td_retval[0] = 0; return (0); } int -linux_vfork(struct proc *p, struct linux_vfork_args *args) +linux_vfork(struct thread *td, struct linux_vfork_args *args) { int error; @@ -293,11 +293,11 @@ linux_vfork(struct proc *p, struct linux_vfork_args *args) printf(ARGS(vfork, "")); #endif - if ((error = vfork(p, (struct vfork_args *)args)) != 0) + if ((error = vfork(td, (struct vfork_args *)args)) != 0) return (error); /* Are we the child? */ - if (p->p_retval[1] == 1) - p->p_retval[0] = 0; + if (td->td_retval[1] == 1) + td->td_retval[0] = 0; return (0); } @@ -308,7 +308,7 @@ linux_vfork(struct proc *p, struct linux_vfork_args *args) #define CLONE_PID 0x1000 int -linux_clone(struct proc *p, struct linux_clone_args *args) +linux_clone(struct thread *td, struct linux_clone_args *args) { int error, ff = RFPROC | RFSTOPPED; struct proc *p2; @@ -341,14 +341,14 @@ linux_clone(struct proc *p, struct linux_clone_args *args) ff |= RFFDG; mtx_lock(&Giant); - error = fork1(p, ff, &p2); + error = fork1(td, ff, &p2); if (error == 0) { - p->p_retval[0] = p2->p_pid; - p->p_retval[1] = 0; + td->td_retval[0] = p2->p_pid; + td->td_retval[1] = 0; PROC_LOCK(p2); p2->p_sigparent = exit_signal; - p2->p_frame->tf_esp = (unsigned int)args->stack; + p2->p_thread.td_frame->tf_esp = (unsigned int)args->stack; #ifdef DEBUG if (ldebug(clone)) @@ -361,7 +361,7 @@ linux_clone(struct proc *p, struct linux_clone_args *args) */ mtx_lock_spin(&sched_lock); p2->p_stat = SRUN; - setrunqueue(p2); + setrunqueue(&p2->p_thread); mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p2); } @@ -384,8 +384,9 @@ struct l_mmap_argv { #define GUARD_SIZE (4 * PAGE_SIZE) int -linux_mmap(struct proc *p, struct linux_mmap_args *args) +linux_mmap(struct thread *td, struct linux_mmap_args *args) { + struct proc *p = td->td_proc; struct mmap_args /* { caddr_t addr; size_t len; @@ -501,11 +502,11 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args) bsd_args.flags, bsd_args.fd, (int)bsd_args.pos); #endif - return (mmap(p, &bsd_args)); + return (mmap(td, &bsd_args)); } int -linux_pipe(struct proc *p, struct linux_pipe_args *args) +linux_pipe(struct thread *td, struct linux_pipe_args *args) { int error; int reg_edx; @@ -515,26 +516,26 @@ linux_pipe(struct proc *p, struct linux_pipe_args *args) printf(ARGS(pipe, "*")); #endif - reg_edx = p->p_retval[1]; - error = pipe(p, 0); + reg_edx = td->td_retval[1]; + error = pipe(td, 0); if (error) { - p->p_retval[1] = reg_edx; + td->td_retval[1] = reg_edx; return (error); } - error = copyout(p->p_retval, args->pipefds, 2*sizeof(int)); + error = copyout(td->td_retval, args->pipefds, 2*sizeof(int)); if (error) { - p->p_retval[1] = reg_edx; + td->td_retval[1] = reg_edx; return (error); } - p->p_retval[1] = reg_edx; - p->p_retval[0] = 0; + td->td_retval[1] = reg_edx; + td->td_retval[0] = 0; return (0); } int -linux_ioperm(struct proc *p, struct linux_ioperm_args *args) +linux_ioperm(struct thread *td, struct linux_ioperm_args *args) { struct sysarch_args sa; struct i386_ioperm_args *iia; @@ -547,28 +548,28 @@ linux_ioperm(struct proc *p, struct linux_ioperm_args *args) iia->enable = args->enable; sa.op = I386_SET_IOPERM; sa.parms = (char *)iia; - return (sysarch(p, &sa)); + return (sysarch(td, &sa)); } int -linux_iopl(struct proc *p, struct linux_iopl_args *args) +linux_iopl(struct thread *td, struct linux_iopl_args *args) { int error; if (args->level < 0 || args->level > 3) return (EINVAL); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); if (securelevel > 0) return (EPERM); - p->p_frame->tf_eflags = (p->p_frame->tf_eflags & ~PSL_IOPL) | + td->td_frame->tf_eflags = (td->td_frame->tf_eflags & ~PSL_IOPL) | (args->level * (PSL_IOPL / 3)); return (0); } int -linux_modify_ldt(p, uap) - struct proc *p; +linux_modify_ldt(td, uap) + struct thread *td; struct linux_modify_ldt_args *uap; { int error; @@ -591,8 +592,8 @@ linux_modify_ldt(p, uap) ldt->num = uap->bytecount / sizeof(union descriptor); args.op = I386_GET_LDT; args.parms = (char*)ldt; - error = sysarch(p, &args); - p->p_retval[0] *= sizeof(union descriptor); + error = sysarch(td, &args); + td->td_retval[0] *= sizeof(union descriptor); break; case 0x01: /* write_ldt */ case 0x11: /* write_ldt */ @@ -621,7 +622,7 @@ linux_modify_ldt(p, uap) desc->sd.sd_gran = ld.limit_in_pages; args.op = I386_SET_LDT; args.parms = (char*)ldt; - error = sysarch(p, &args); + error = sysarch(td, &args); break; default: error = EINVAL; @@ -637,7 +638,7 @@ linux_modify_ldt(p, uap) } int -linux_sigaction(struct proc *p, struct linux_sigaction_args *args) +linux_sigaction(struct thread *td, struct linux_sigaction_args *args) { l_osigaction_t osa; l_sigaction_t act, oact; @@ -661,7 +662,7 @@ linux_sigaction(struct proc *p, struct linux_sigaction_args *args) act.lsa_mask.__bits[0] = osa.lsa_mask; } - error = linux_do_sigaction(p, args->sig, args->nsa ? &act : NULL, + error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL, args->osa ? &oact : NULL); if (args->osa != NULL && !error) { @@ -682,7 +683,7 @@ linux_sigaction(struct proc *p, struct linux_sigaction_args *args) * enables the signal to happen with a different register set. */ int -linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args) +linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args) { struct sigsuspend_args bsd; sigset_t *sigmask; @@ -699,12 +700,12 @@ linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args) mask.__bits[0] = args->mask; linux_to_bsd_sigset(&mask, sigmask); bsd.sigmask = sigmask; - return (sigsuspend(p, &bsd)); + return (sigsuspend(td, &bsd)); } int -linux_rt_sigsuspend(p, uap) - struct proc *p; +linux_rt_sigsuspend(td, uap) + struct thread *td; struct linux_rt_sigsuspend_args *uap; { l_sigset_t lmask; @@ -729,12 +730,13 @@ linux_rt_sigsuspend(p, uap) bmask = stackgap_alloc(&sg, sizeof(sigset_t)); linux_to_bsd_sigset(&lmask, bmask); bsd.sigmask = bmask; - return (sigsuspend(p, &bsd)); + return (sigsuspend(td, &bsd)); } int -linux_pause(struct proc *p, struct linux_pause_args *args) +linux_pause(struct thread *td, struct linux_pause_args *args) { + struct proc *p = td->td_proc; struct sigsuspend_args bsd; sigset_t *sigmask; caddr_t sg = stackgap_init(); @@ -749,13 +751,11 @@ linux_pause(struct proc *p, struct linux_pause_args *args) *sigmask = p->p_sigmask; PROC_UNLOCK(p); bsd.sigmask = sigmask; - return (sigsuspend(p, &bsd)); + return (sigsuspend(td, &bsd)); } int -linux_sigaltstack(p, uap) - struct proc *p; - struct linux_sigaltstack_args *uap; +linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap) { struct sigaltstack_args bsd; stack_t *ss, *oss; @@ -786,7 +786,7 @@ linux_sigaltstack(p, uap) bsd.ss = ss; bsd.oss = oss; - error = sigaltstack(p, &bsd); + error = sigaltstack(td, &bsd); if (!error && oss != NULL) { lss.ss_sp = oss->ss_sp; diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index 6105da1..12b52ff 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -15,6 +15,8 @@ struct proc; +struct thread; + #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 0 : sizeof(register_t) - sizeof(t)) @@ -643,161 +645,161 @@ struct linux_fcntl64_args { char cmd_l_[PADL_(l_uint)]; l_uint cmd; char cmd_r_[PADR_(l_uint)]; char arg_l_[PADL_(l_ulong)]; l_ulong arg; char arg_r_[PADR_(l_ulong)]; }; -int linux_fork __P((struct proc *, struct linux_fork_args *)); -int linux_open __P((struct proc *, struct linux_open_args *)); -int linux_waitpid __P((struct proc *, struct linux_waitpid_args *)); -int linux_creat __P((struct proc *, struct linux_creat_args *)); -int linux_link __P((struct proc *, struct linux_link_args *)); -int linux_unlink __P((struct proc *, struct linux_unlink_args *)); -int linux_execve __P((struct proc *, struct linux_execve_args *)); -int linux_chdir __P((struct proc *, struct linux_chdir_args *)); -int linux_time __P((struct proc *, struct linux_time_args *)); -int linux_mknod __P((struct proc *, struct linux_mknod_args *)); -int linux_chmod __P((struct proc *, struct linux_chmod_args *)); -int linux_lchown16 __P((struct proc *, struct linux_lchown16_args *)); -int linux_stat __P((struct proc *, struct linux_stat_args *)); -int linux_lseek __P((struct proc *, struct linux_lseek_args *)); -int linux_getpid __P((struct proc *, struct linux_getpid_args *)); -int linux_mount __P((struct proc *, struct linux_mount_args *)); -int linux_oldumount __P((struct proc *, struct linux_oldumount_args *)); -int linux_setuid16 __P((struct proc *, struct linux_setuid16_args *)); -int linux_getuid16 __P((struct proc *, struct linux_getuid16_args *)); -int linux_stime __P((struct proc *, struct linux_stime_args *)); -int linux_ptrace __P((struct proc *, struct linux_ptrace_args *)); -int linux_alarm __P((struct proc *, struct linux_alarm_args *)); -int linux_fstat __P((struct proc *, struct linux_fstat_args *)); -int linux_pause __P((struct proc *, struct linux_pause_args *)); -int linux_utime __P((struct proc *, struct linux_utime_args *)); -int linux_access __P((struct proc *, struct linux_access_args *)); -int linux_nice __P((struct proc *, struct linux_nice_args *)); -int linux_kill __P((struct proc *, struct linux_kill_args *)); -int linux_rename __P((struct proc *, struct linux_rename_args *)); -int linux_mkdir __P((struct proc *, struct linux_mkdir_args *)); -int linux_rmdir __P((struct proc *, struct linux_rmdir_args *)); -int linux_pipe __P((struct proc *, struct linux_pipe_args *)); -int linux_times __P((struct proc *, struct linux_times_args *)); -int linux_brk __P((struct proc *, struct linux_brk_args *)); -int linux_setgid16 __P((struct proc *, struct linux_setgid16_args *)); -int linux_getgid16 __P((struct proc *, struct linux_getgid16_args *)); -int linux_signal __P((struct proc *, struct linux_signal_args *)); -int linux_geteuid16 __P((struct proc *, struct linux_geteuid16_args *)); -int linux_getegid16 __P((struct proc *, struct linux_getegid16_args *)); -int linux_umount __P((struct proc *, struct linux_umount_args *)); -int linux_ioctl __P((struct proc *, struct linux_ioctl_args *)); -int linux_fcntl __P((struct proc *, struct linux_fcntl_args *)); -int linux_olduname __P((struct proc *, struct linux_olduname_args *)); -int linux_ustat __P((struct proc *, struct linux_ustat_args *)); -int linux_sigaction __P((struct proc *, struct linux_sigaction_args *)); -int linux_sgetmask __P((struct proc *, struct linux_sgetmask_args *)); -int linux_ssetmask __P((struct proc *, struct linux_ssetmask_args *)); -int linux_setreuid16 __P((struct proc *, struct linux_setreuid16_args *)); -int linux_setregid16 __P((struct proc *, struct linux_setregid16_args *)); -int linux_sigsuspend __P((struct proc *, struct linux_sigsuspend_args *)); -int linux_sigpending __P((struct proc *, struct linux_sigpending_args *)); -int linux_setrlimit __P((struct proc *, struct linux_setrlimit_args *)); -int linux_old_getrlimit __P((struct proc *, struct linux_old_getrlimit_args *)); -int linux_getgroups16 __P((struct proc *, struct linux_getgroups16_args *)); -int linux_setgroups16 __P((struct proc *, struct linux_setgroups16_args *)); -int linux_old_select __P((struct proc *, struct linux_old_select_args *)); -int linux_symlink __P((struct proc *, struct linux_symlink_args *)); -int linux_readlink __P((struct proc *, struct linux_readlink_args *)); -int linux_uselib __P((struct proc *, struct linux_uselib_args *)); -int linux_reboot __P((struct proc *, struct linux_reboot_args *)); -int linux_readdir __P((struct proc *, struct linux_readdir_args *)); -int linux_mmap __P((struct proc *, struct linux_mmap_args *)); -int linux_truncate __P((struct proc *, struct linux_truncate_args *)); -int linux_statfs __P((struct proc *, struct linux_statfs_args *)); -int linux_fstatfs __P((struct proc *, struct linux_fstatfs_args *)); -int linux_ioperm __P((struct proc *, struct linux_ioperm_args *)); -int linux_socketcall __P((struct proc *, struct linux_socketcall_args *)); -int linux_syslog __P((struct proc *, struct linux_syslog_args *)); -int linux_setitimer __P((struct proc *, struct linux_setitimer_args *)); -int linux_getitimer __P((struct proc *, struct linux_getitimer_args *)); -int linux_newstat __P((struct proc *, struct linux_newstat_args *)); -int linux_newlstat __P((struct proc *, struct linux_newlstat_args *)); -int linux_newfstat __P((struct proc *, struct linux_newfstat_args *)); -int linux_uname __P((struct proc *, struct linux_uname_args *)); -int linux_iopl __P((struct proc *, struct linux_iopl_args *)); -int linux_vhangup __P((struct proc *, struct linux_vhangup_args *)); -int linux_vm86old __P((struct proc *, struct linux_vm86old_args *)); -int linux_wait4 __P((struct proc *, struct linux_wait4_args *)); -int linux_swapoff __P((struct proc *, struct linux_swapoff_args *)); -int linux_sysinfo __P((struct proc *, struct linux_sysinfo_args *)); -int linux_ipc __P((struct proc *, struct linux_ipc_args *)); -int linux_sigreturn __P((struct proc *, struct linux_sigreturn_args *)); -int linux_clone __P((struct proc *, struct linux_clone_args *)); -int linux_newuname __P((struct proc *, struct linux_newuname_args *)); -int linux_modify_ldt __P((struct proc *, struct linux_modify_ldt_args *)); -int linux_adjtimex __P((struct proc *, struct linux_adjtimex_args *)); -int linux_sigprocmask __P((struct proc *, struct linux_sigprocmask_args *)); -int linux_create_module __P((struct proc *, struct linux_create_module_args *)); -int linux_init_module __P((struct proc *, struct linux_init_module_args *)); -int linux_delete_module __P((struct proc *, struct linux_delete_module_args *)); -int linux_get_kernel_syms __P((struct proc *, struct linux_get_kernel_syms_args *)); -int linux_quotactl __P((struct proc *, struct linux_quotactl_args *)); -int linux_getpgid __P((struct proc *, struct linux_getpgid_args *)); -int linux_bdflush __P((struct proc *, struct linux_bdflush_args *)); -int linux_sysfs __P((struct proc *, struct linux_sysfs_args *)); -int linux_personality __P((struct proc *, struct linux_personality_args *)); -int linux_setfsuid16 __P((struct proc *, struct linux_setfsuid16_args *)); -int linux_setfsgid16 __P((struct proc *, struct linux_setfsgid16_args *)); -int linux_llseek __P((struct proc *, struct linux_llseek_args *)); -int linux_getdents __P((struct proc *, struct linux_getdents_args *)); -int linux_select __P((struct proc *, struct linux_select_args *)); -int linux_msync __P((struct proc *, struct linux_msync_args *)); -int linux_getsid __P((struct proc *, struct linux_getsid_args *)); -int linux_fdatasync __P((struct proc *, struct linux_fdatasync_args *)); -int linux_sysctl __P((struct proc *, struct linux_sysctl_args *)); -int linux_sched_setscheduler __P((struct proc *, struct linux_sched_setscheduler_args *)); -int linux_sched_getscheduler __P((struct proc *, struct linux_sched_getscheduler_args *)); -int linux_sched_get_priority_max __P((struct proc *, struct linux_sched_get_priority_max_args *)); -int linux_sched_get_priority_min __P((struct proc *, struct linux_sched_get_priority_min_args *)); -int linux_mremap __P((struct proc *, struct linux_mremap_args *)); -int linux_setresuid16 __P((struct proc *, struct linux_setresuid16_args *)); -int linux_getresuid16 __P((struct proc *, struct linux_getresuid16_args *)); -int linux_vm86 __P((struct proc *, struct linux_vm86_args *)); -int linux_query_module __P((struct proc *, struct linux_query_module_args *)); -int linux_nfsservctl __P((struct proc *, struct linux_nfsservctl_args *)); -int linux_setresgid16 __P((struct proc *, struct linux_setresgid16_args *)); -int linux_getresgid16 __P((struct proc *, struct linux_getresgid16_args *)); -int linux_prctl __P((struct proc *, struct linux_prctl_args *)); -int linux_rt_sigreturn __P((struct proc *, struct linux_rt_sigreturn_args *)); -int linux_rt_sigaction __P((struct proc *, struct linux_rt_sigaction_args *)); -int linux_rt_sigprocmask __P((struct proc *, struct linux_rt_sigprocmask_args *)); -int linux_rt_sigpending __P((struct proc *, struct linux_rt_sigpending_args *)); -int linux_rt_sigtimedwait __P((struct proc *, struct linux_rt_sigtimedwait_args *)); -int linux_rt_sigqueueinfo __P((struct proc *, struct linux_rt_sigqueueinfo_args *)); -int linux_rt_sigsuspend __P((struct proc *, struct linux_rt_sigsuspend_args *)); -int linux_pread __P((struct proc *, struct linux_pread_args *)); -int linux_pwrite __P((struct proc *, struct linux_pwrite_args *)); -int linux_chown16 __P((struct proc *, struct linux_chown16_args *)); -int linux_getcwd __P((struct proc *, struct linux_getcwd_args *)); -int linux_capget __P((struct proc *, struct linux_capget_args *)); -int linux_capset __P((struct proc *, struct linux_capset_args *)); -int linux_sigaltstack __P((struct proc *, struct linux_sigaltstack_args *)); -int linux_sendfile __P((struct proc *, struct linux_sendfile_args *)); -int linux_vfork __P((struct proc *, struct linux_vfork_args *)); -int linux_getrlimit __P((struct proc *, struct linux_getrlimit_args *)); -int linux_mmap2 __P((struct proc *, struct linux_mmap2_args *)); -int linux_truncate64 __P((struct proc *, struct linux_truncate64_args *)); -int linux_ftruncate64 __P((struct proc *, struct linux_ftruncate64_args *)); -int linux_stat64 __P((struct proc *, struct linux_stat64_args *)); -int linux_lstat64 __P((struct proc *, struct linux_lstat64_args *)); -int linux_fstat64 __P((struct proc *, struct linux_fstat64_args *)); -int linux_lchown __P((struct proc *, struct linux_lchown_args *)); -int linux_getuid __P((struct proc *, struct linux_getuid_args *)); -int linux_getgid __P((struct proc *, struct linux_getgid_args *)); -int linux_getgroups __P((struct proc *, struct linux_getgroups_args *)); -int linux_setgroups __P((struct proc *, struct linux_setgroups_args *)); -int linux_fchown __P((struct proc *, struct linux_fchown_args *)); -int linux_chown __P((struct proc *, struct linux_chown_args *)); -int linux_setfsuid __P((struct proc *, struct linux_setfsuid_args *)); -int linux_setfsgid __P((struct proc *, struct linux_setfsgid_args *)); -int linux_pivot_root __P((struct proc *, struct linux_pivot_root_args *)); -int linux_mincore __P((struct proc *, struct linux_mincore_args *)); -int linux_madvise __P((struct proc *, struct linux_madvise_args *)); -int linux_getdents64 __P((struct proc *, struct linux_getdents64_args *)); -int linux_fcntl64 __P((struct proc *, struct linux_fcntl64_args *)); +int linux_fork __P((struct thread *, struct linux_fork_args *)); +int linux_open __P((struct thread *, struct linux_open_args *)); +int linux_waitpid __P((struct thread *, struct linux_waitpid_args *)); +int linux_creat __P((struct thread *, struct linux_creat_args *)); +int linux_link __P((struct thread *, struct linux_link_args *)); +int linux_unlink __P((struct thread *, struct linux_unlink_args *)); +int linux_execve __P((struct thread *, struct linux_execve_args *)); +int linux_chdir __P((struct thread *, struct linux_chdir_args *)); +int linux_time __P((struct thread *, struct linux_time_args *)); +int linux_mknod __P((struct thread *, struct linux_mknod_args *)); +int linux_chmod __P((struct thread *, struct linux_chmod_args *)); +int linux_lchown16 __P((struct thread *, struct linux_lchown16_args *)); +int linux_stat __P((struct thread *, struct linux_stat_args *)); +int linux_lseek __P((struct thread *, struct linux_lseek_args *)); +int linux_getpid __P((struct thread *, struct linux_getpid_args *)); +int linux_mount __P((struct thread *, struct linux_mount_args *)); +int linux_oldumount __P((struct thread *, struct linux_oldumount_args *)); +int linux_setuid16 __P((struct thread *, struct linux_setuid16_args *)); +int linux_getuid16 __P((struct thread *, struct linux_getuid16_args *)); +int linux_stime __P((struct thread *, struct linux_stime_args *)); +int linux_ptrace __P((struct thread *, struct linux_ptrace_args *)); +int linux_alarm __P((struct thread *, struct linux_alarm_args *)); +int linux_fstat __P((struct thread *, struct linux_fstat_args *)); +int linux_pause __P((struct thread *, struct linux_pause_args *)); +int linux_utime __P((struct thread *, struct linux_utime_args *)); +int linux_access __P((struct thread *, struct linux_access_args *)); +int linux_nice __P((struct thread *, struct linux_nice_args *)); +int linux_kill __P((struct thread *, struct linux_kill_args *)); +int linux_rename __P((struct thread *, struct linux_rename_args *)); +int linux_mkdir __P((struct thread *, struct linux_mkdir_args *)); +int linux_rmdir __P((struct thread *, struct linux_rmdir_args *)); +int linux_pipe __P((struct thread *, struct linux_pipe_args *)); +int linux_times __P((struct thread *, struct linux_times_args *)); +int linux_brk __P((struct thread *, struct linux_brk_args *)); +int linux_setgid16 __P((struct thread *, struct linux_setgid16_args *)); +int linux_getgid16 __P((struct thread *, struct linux_getgid16_args *)); +int linux_signal __P((struct thread *, struct linux_signal_args *)); +int linux_geteuid16 __P((struct thread *, struct linux_geteuid16_args *)); +int linux_getegid16 __P((struct thread *, struct linux_getegid16_args *)); +int linux_umount __P((struct thread *, struct linux_umount_args *)); +int linux_ioctl __P((struct thread *, struct linux_ioctl_args *)); +int linux_fcntl __P((struct thread *, struct linux_fcntl_args *)); +int linux_olduname __P((struct thread *, struct linux_olduname_args *)); +int linux_ustat __P((struct thread *, struct linux_ustat_args *)); +int linux_sigaction __P((struct thread *, struct linux_sigaction_args *)); +int linux_sgetmask __P((struct thread *, struct linux_sgetmask_args *)); +int linux_ssetmask __P((struct thread *, struct linux_ssetmask_args *)); +int linux_setreuid16 __P((struct thread *, struct linux_setreuid16_args *)); +int linux_setregid16 __P((struct thread *, struct linux_setregid16_args *)); +int linux_sigsuspend __P((struct thread *, struct linux_sigsuspend_args *)); +int linux_sigpending __P((struct thread *, struct linux_sigpending_args *)); +int linux_setrlimit __P((struct thread *, struct linux_setrlimit_args *)); +int linux_old_getrlimit __P((struct thread *, struct linux_old_getrlimit_args *)); +int linux_getgroups16 __P((struct thread *, struct linux_getgroups16_args *)); +int linux_setgroups16 __P((struct thread *, struct linux_setgroups16_args *)); +int linux_old_select __P((struct thread *, struct linux_old_select_args *)); +int linux_symlink __P((struct thread *, struct linux_symlink_args *)); +int linux_readlink __P((struct thread *, struct linux_readlink_args *)); +int linux_uselib __P((struct thread *, struct linux_uselib_args *)); +int linux_reboot __P((struct thread *, struct linux_reboot_args *)); +int linux_readdir __P((struct thread *, struct linux_readdir_args *)); +int linux_mmap __P((struct thread *, struct linux_mmap_args *)); +int linux_truncate __P((struct thread *, struct linux_truncate_args *)); +int linux_statfs __P((struct thread *, struct linux_statfs_args *)); +int linux_fstatfs __P((struct thread *, struct linux_fstatfs_args *)); +int linux_ioperm __P((struct thread *, struct linux_ioperm_args *)); +int linux_socketcall __P((struct thread *, struct linux_socketcall_args *)); +int linux_syslog __P((struct thread *, struct linux_syslog_args *)); +int linux_setitimer __P((struct thread *, struct linux_setitimer_args *)); +int linux_getitimer __P((struct thread *, struct linux_getitimer_args *)); +int linux_newstat __P((struct thread *, struct linux_newstat_args *)); +int linux_newlstat __P((struct thread *, struct linux_newlstat_args *)); +int linux_newfstat __P((struct thread *, struct linux_newfstat_args *)); +int linux_uname __P((struct thread *, struct linux_uname_args *)); +int linux_iopl __P((struct thread *, struct linux_iopl_args *)); +int linux_vhangup __P((struct thread *, struct linux_vhangup_args *)); +int linux_vm86old __P((struct thread *, struct linux_vm86old_args *)); +int linux_wait4 __P((struct thread *, struct linux_wait4_args *)); +int linux_swapoff __P((struct thread *, struct linux_swapoff_args *)); +int linux_sysinfo __P((struct thread *, struct linux_sysinfo_args *)); +int linux_ipc __P((struct thread *, struct linux_ipc_args *)); +int linux_sigreturn __P((struct thread *, struct linux_sigreturn_args *)); +int linux_clone __P((struct thread *, struct linux_clone_args *)); +int linux_newuname __P((struct thread *, struct linux_newuname_args *)); +int linux_modify_ldt __P((struct thread *, struct linux_modify_ldt_args *)); +int linux_adjtimex __P((struct thread *, struct linux_adjtimex_args *)); +int linux_sigprocmask __P((struct thread *, struct linux_sigprocmask_args *)); +int linux_create_module __P((struct thread *, struct linux_create_module_args *)); +int linux_init_module __P((struct thread *, struct linux_init_module_args *)); +int linux_delete_module __P((struct thread *, struct linux_delete_module_args *)); +int linux_get_kernel_syms __P((struct thread *, struct linux_get_kernel_syms_args *)); +int linux_quotactl __P((struct thread *, struct linux_quotactl_args *)); +int linux_getpgid __P((struct thread *, struct linux_getpgid_args *)); +int linux_bdflush __P((struct thread *, struct linux_bdflush_args *)); +int linux_sysfs __P((struct thread *, struct linux_sysfs_args *)); +int linux_personality __P((struct thread *, struct linux_personality_args *)); +int linux_setfsuid16 __P((struct thread *, struct linux_setfsuid16_args *)); +int linux_setfsgid16 __P((struct thread *, struct linux_setfsgid16_args *)); +int linux_llseek __P((struct thread *, struct linux_llseek_args *)); +int linux_getdents __P((struct thread *, struct linux_getdents_args *)); +int linux_select __P((struct thread *, struct linux_select_args *)); +int linux_msync __P((struct thread *, struct linux_msync_args *)); +int linux_getsid __P((struct thread *, struct linux_getsid_args *)); +int linux_fdatasync __P((struct thread *, struct linux_fdatasync_args *)); +int linux_sysctl __P((struct thread *, struct linux_sysctl_args *)); +int linux_sched_setscheduler __P((struct thread *, struct linux_sched_setscheduler_args *)); +int linux_sched_getscheduler __P((struct thread *, struct linux_sched_getscheduler_args *)); +int linux_sched_get_priority_max __P((struct thread *, struct linux_sched_get_priority_max_args *)); +int linux_sched_get_priority_min __P((struct thread *, struct linux_sched_get_priority_min_args *)); +int linux_mremap __P((struct thread *, struct linux_mremap_args *)); +int linux_setresuid16 __P((struct thread *, struct linux_setresuid16_args *)); +int linux_getresuid16 __P((struct thread *, struct linux_getresuid16_args *)); +int linux_vm86 __P((struct thread *, struct linux_vm86_args *)); +int linux_query_module __P((struct thread *, struct linux_query_module_args *)); +int linux_nfsservctl __P((struct thread *, struct linux_nfsservctl_args *)); +int linux_setresgid16 __P((struct thread *, struct linux_setresgid16_args *)); +int linux_getresgid16 __P((struct thread *, struct linux_getresgid16_args *)); +int linux_prctl __P((struct thread *, struct linux_prctl_args *)); +int linux_rt_sigreturn __P((struct thread *, struct linux_rt_sigreturn_args *)); +int linux_rt_sigaction __P((struct thread *, struct linux_rt_sigaction_args *)); +int linux_rt_sigprocmask __P((struct thread *, struct linux_rt_sigprocmask_args *)); +int linux_rt_sigpending __P((struct thread *, struct linux_rt_sigpending_args *)); +int linux_rt_sigtimedwait __P((struct thread *, struct linux_rt_sigtimedwait_args *)); +int linux_rt_sigqueueinfo __P((struct thread *, struct linux_rt_sigqueueinfo_args *)); +int linux_rt_sigsuspend __P((struct thread *, struct linux_rt_sigsuspend_args *)); +int linux_pread __P((struct thread *, struct linux_pread_args *)); +int linux_pwrite __P((struct thread *, struct linux_pwrite_args *)); +int linux_chown16 __P((struct thread *, struct linux_chown16_args *)); +int linux_getcwd __P((struct thread *, struct linux_getcwd_args *)); +int linux_capget __P((struct thread *, struct linux_capget_args *)); +int linux_capset __P((struct thread *, struct linux_capset_args *)); +int linux_sigaltstack __P((struct thread *, struct linux_sigaltstack_args *)); +int linux_sendfile __P((struct thread *, struct linux_sendfile_args *)); +int linux_vfork __P((struct thread *, struct linux_vfork_args *)); +int linux_getrlimit __P((struct thread *, struct linux_getrlimit_args *)); +int linux_mmap2 __P((struct thread *, struct linux_mmap2_args *)); +int linux_truncate64 __P((struct thread *, struct linux_truncate64_args *)); +int linux_ftruncate64 __P((struct thread *, struct linux_ftruncate64_args *)); +int linux_stat64 __P((struct thread *, struct linux_stat64_args *)); +int linux_lstat64 __P((struct thread *, struct linux_lstat64_args *)); +int linux_fstat64 __P((struct thread *, struct linux_fstat64_args *)); +int linux_lchown __P((struct thread *, struct linux_lchown_args *)); +int linux_getuid __P((struct thread *, struct linux_getuid_args *)); +int linux_getgid __P((struct thread *, struct linux_getgid_args *)); +int linux_getgroups __P((struct thread *, struct linux_getgroups_args *)); +int linux_setgroups __P((struct thread *, struct linux_setgroups_args *)); +int linux_fchown __P((struct thread *, struct linux_fchown_args *)); +int linux_chown __P((struct thread *, struct linux_chown_args *)); +int linux_setfsuid __P((struct thread *, struct linux_setfsuid_args *)); +int linux_setfsgid __P((struct thread *, struct linux_setfsgid_args *)); +int linux_pivot_root __P((struct thread *, struct linux_pivot_root_args *)); +int linux_mincore __P((struct thread *, struct linux_mincore_args *)); +int linux_madvise __P((struct thread *, struct linux_madvise_args *)); +int linux_getdents64 __P((struct thread *, struct linux_getdents64_args *)); +int linux_fcntl64 __P((struct thread *, struct linux_fcntl64_args *)); #ifdef COMPAT_43 diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index b90ea56..27e3649 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -219,13 +219,14 @@ extern unsigned long linux_sznonrtsigcode; static void linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { - register struct proc *p = curproc; + register struct thread *td = curthread; + register struct proc *p = td->td_proc; register struct trapframe *regs; struct l_rt_sigframe *fp, frame; int oonstack; PROC_LOCK_ASSERT(p, MA_OWNED); - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); #ifdef DEBUG @@ -335,7 +336,7 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) * instruction to halt it in its tracks. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -369,7 +370,8 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) static void linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { - register struct proc *p = curproc; + register struct thread *td = curthread; + register struct proc *p = td->td_proc; register struct trapframe *regs; struct l_sigframe *fp, frame; l_sigset_t lmask; @@ -381,7 +383,7 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) return; } - regs = p->p_frame; + regs = td->td_frame; oonstack = sigonstack(regs->tf_esp); #ifdef DEBUG @@ -468,7 +470,7 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) * instruction to halt it in its tracks. */ PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -497,16 +499,17 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) * a machine fault. */ int -linux_sigreturn(p, args) - struct proc *p; +linux_sigreturn(td, args) + struct thread *td; struct linux_sigreturn_args *args; { + struct proc *p = td->td_proc; struct l_sigframe frame; register struct trapframe *regs; l_sigset_t lmask; int eflags, i; - regs = p->p_frame; + regs = td->td_frame; #ifdef DEBUG if (ldebug(sigreturn)) @@ -592,10 +595,11 @@ linux_sigreturn(p, args) * a machine fault. */ int -linux_rt_sigreturn(p, args) - struct proc *p; +linux_rt_sigreturn(td, args) + struct thread *td; struct linux_rt_sigreturn_args *args; { + struct proc *p = td->td_proc; struct sigaltstack_args sasargs; struct l_ucontext uc; struct l_sigcontext *context; @@ -605,7 +609,7 @@ linux_rt_sigreturn(p, args) int eflags; caddr_t sg = stackgap_init(); - regs = p->p_frame; + regs = td->td_frame; #ifdef DEBUG if (ldebug(rt_sigreturn)) @@ -692,7 +696,7 @@ linux_rt_sigreturn(p, args) #endif sasargs.ss = ss; sasargs.oss = NULL; - (void) sigaltstack(p, &sasargs); + (void) sigaltstack(td, &sasargs); return (EJUSTRETURN); } @@ -740,7 +744,7 @@ exec_linux_imgact_try(imgp) if ((error = exec_shell_imgact(imgp)) == 0) { char *rpath = NULL; - linux_emul_find(imgp->proc, NULL, linux_emul_path, + linux_emul_find(&imgp->proc->p_thread, NULL, linux_emul_path, imgp->interpreter_name, &rpath, 0); if (rpath != imgp->interpreter_name) { int len = strlen(rpath) + 1; diff --git a/sys/i386/svr4/svr4_machdep.c b/sys/i386/svr4/svr4_machdep.c index 7dc2d47..f1522f6 100644 --- a/sys/i386/svr4/svr4_machdep.c +++ b/sys/i386/svr4/svr4_machdep.c @@ -77,26 +77,27 @@ static void svr4_getsiginfo __P((union svr4_siginfo *, int, u_long, caddr_t)); #if defined(__NetBSD__) void -svr4_setregs(p, epp, stack) - struct proc *p; +svr4_setregs(td, epp, stack) + struct thread *td; struct exec_package *epp; u_long stack; { - register struct pcb *pcb = &p->p_addr->u_pcb; + register struct pcb *pcb = td->td_pcb; pcb->pcb_savefpu.sv_env.en_cw = __SVR4_NPXCW__; - setregs(p, epp, stack, 0UL); + setregs(td, epp, stack, 0UL); } #endif /* __NetBSD__ */ void -svr4_getcontext(p, uc, mask, oonstack) - struct proc *p; +svr4_getcontext(td, uc, mask, oonstack) + struct thread *td; struct svr4_ucontext *uc; sigset_t *mask; int oonstack; { - struct trapframe *tf = p->p_frame; + struct proc *p = td->td_proc; + struct trapframe *tf = td->td_frame; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; #if defined(DONE_MORE_SIGALTSTACK_WORK) @@ -104,7 +105,7 @@ svr4_getcontext(p, uc, mask, oonstack) struct sigaltstack *sf; #endif - PROC_LOCK(p); + PROC_LOCK(td->td_proc); #if defined(DONE_MORE_SIGALTSTACK_WORK) psp = p->p_sigacts; sf = &p->p_sigstk; @@ -122,7 +123,7 @@ svr4_getcontext(p, uc, mask, oonstack) r[SVR4_X86_FS] = tf->tf_vm86_fs; r[SVR4_X86_ES] = tf->tf_vm86_es; r[SVR4_X86_DS] = tf->tf_vm86_ds; - r[SVR4_X86_EFL] = get_vflags(p); + r[SVR4_X86_EFL] = get_vflags(td); } else #endif { @@ -162,7 +163,7 @@ svr4_getcontext(p, uc, mask, oonstack) s->ss_size = 16384; s->ss_flags = 0; #endif - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); /* * Set the signal mask @@ -186,24 +187,25 @@ svr4_getcontext(p, uc, mask, oonstack) * a machine fault. */ int -svr4_setcontext(p, uc) - struct proc *p; +svr4_setcontext(td, uc) + struct thread *td; struct svr4_ucontext *uc; { #if defined(DONE_MORE_SIGALTSTACK_WORK) struct sigacts *psp; #endif + struct proc *p = td->td_proc; register struct trapframe *tf; svr4_greg_t *r = uc->uc_mcontext.greg; struct svr4_sigaltstack *s = &uc->uc_stack; struct sigaltstack *sf; sigset_t mask; - PROC_LOCK(p); + PROC_LOCK(td->td_proc); #if defined(DONE_MORE_SIGALTSTACK_WORK) - psp = p->p_sigacts; + psp = td->td_proc->p_sigacts; #endif - sf = &p->p_sigstk; + sf = &td->td_proc->p_sigstk; /* * XXX: @@ -219,7 +221,7 @@ svr4_setcontext(p, uc) DPRINTF(("svr4_setcontext(%d)\n", p->p_pid)); - tf = p->p_frame; + tf = td->td_frame; /* * Restore register context. @@ -231,7 +233,7 @@ svr4_setcontext(p, uc) tf->tf_vm86_fs = r[SVR4_X86_FS]; tf->tf_vm86_es = r[SVR4_X86_ES]; tf->tf_vm86_ds = r[SVR4_X86_DS]; - set_vflags(p, r[SVR4_X86_EFL]); + set_vflags(td, r[SVR4_X86_EFL]); } else #endif { @@ -293,7 +295,7 @@ svr4_setcontext(p, uc) SIG_CANTMASK(mask); p->p_sigmask = mask; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); return 0; /*EJUSTRETURN;*/ } @@ -409,7 +411,8 @@ svr4_sendsig(catcher, sig, mask, code) sigset_t *mask; u_long code; { - register struct proc *p = curproc; + register struct thread *td = curthread; + struct proc *p = td->td_proc; register struct trapframe *tf; struct svr4_sigframe *fp, frame; struct sigacts *psp; @@ -421,7 +424,7 @@ svr4_sendsig(catcher, sig, mask, code) PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; - tf = p->p_frame; + tf = td->td_frame; oonstack = sigonstack(tf->tf_esp); /* @@ -435,7 +438,7 @@ svr4_sendsig(catcher, sig, mask, code) } else { fp = (struct svr4_sigframe *)tf->tf_esp - 1; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); /* * Build the argument list for the signal handler. @@ -447,7 +450,7 @@ svr4_sendsig(catcher, sig, mask, code) * modify many kernel files to enable that] */ - svr4_getcontext(p, &frame.sf_uc, mask, oonstack); + svr4_getcontext(td, &frame.sf_uc, mask, oonstack); #if defined(DEBUG_SVR4) printf("obtained ucontext\n"); #endif @@ -469,8 +472,8 @@ svr4_sendsig(catcher, sig, mask, code) * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - PROC_LOCK(p); - sigexit(p, SIGILL); + PROC_LOCK(td->td_proc); + sigexit(td, SIGILL); /* NOTREACHED */ } #if defined(__NetBSD__) @@ -502,8 +505,8 @@ svr4_sendsig(catcher, sig, mask, code) int -svr4_sys_sysarch(p, v) - struct proc *p; +svr4_sys_sysarch(td, v) + struct thread *td; struct svr4_sys_sysarch_args *v; { struct svr4_sys_sysarch_args *uap = v; @@ -583,7 +586,7 @@ svr4_sys_sysarch(p, v) return error; } - return sys_sysarch(p, &ua, retval); + return sys_sysarch(td, &ua, retval); } #endif diff --git a/sys/i386/svr4/svr4_machdep.h b/sys/i386/svr4/svr4_machdep.h index fbbf05b..f6f58e3 100644 --- a/sys/i386/svr4/svr4_machdep.h +++ b/sys/i386/svr4/svr4_machdep.h @@ -71,12 +71,12 @@ typedef struct { long f_weitek[33]; /* weitek */ } svr4_fregset_t; -struct proc; +struct thread; struct svr4_ucontext; -void svr4_getcontext __P((struct proc *, struct svr4_ucontext *, +void svr4_getcontext __P((struct thread *, struct svr4_ucontext *, sigset_t *, int)); -int svr4_setcontext __P((struct proc *p, struct svr4_ucontext *)); +int svr4_setcontext __P((struct thread *p, struct svr4_ucontext *)); typedef struct { svr4_gregset_t greg; diff --git a/sys/i4b/driver/i4b_ctl.c b/sys/i4b/driver/i4b_ctl.c index b30f792..d74fa7e 100644 --- a/sys/i4b/driver/i4b_ctl.c +++ b/sys/i4b/driver/i4b_ctl.c @@ -141,12 +141,12 @@ static void *devfs_token; #ifndef __FreeBSD__ #define PDEVSTATIC /* */ void i4bctlattach __P((void)); -int i4bctlopen __P((dev_t dev, int flag, int fmt, struct proc *p)); -int i4bctlclose __P((dev_t dev, int flag, int fmt, struct proc *p)); +int i4bctlopen __P((dev_t dev, int flag, int fmt, struct thread *td)); +int i4bctlclose __P((dev_t dev, int flag, int fmt, struct thread *td)); #ifdef __bsdi__ -int i4bctlioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)); +int i4bctlioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)); #else -int i4bctlioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)); +int i4bctlioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)); #endif #endif /* !FreeBSD */ @@ -230,7 +230,7 @@ i4bctlattach() * i4bctlopen - device driver open routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bctlopen(dev_t dev, int flag, int fmt, struct proc *p) +i4bctlopen(dev_t dev, int flag, int fmt, struct thread *td) { if(minor(dev)) return (ENXIO); @@ -247,7 +247,7 @@ i4bctlopen(dev_t dev, int flag, int fmt, struct proc *p) * i4bctlclose - device driver close routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bctlclose(dev_t dev, int flag, int fmt, struct proc *p) +i4bctlclose(dev_t dev, int flag, int fmt, struct thread *td) { openflag = 0; return (0); @@ -258,11 +258,11 @@ i4bctlclose(dev_t dev, int flag, int fmt, struct proc *p) *---------------------------------------------------------------------------*/ PDEVSTATIC int #if defined (__FreeBSD_version) && __FreeBSD_version >= 300003 -i4bctlioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4bctlioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #elif defined(__bsdi__) -i4bctlioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4bctlioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #else -i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) #endif { #if DO_I4B_DEBUG @@ -360,7 +360,7 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) * i4bctlpoll - device driver poll routine *---------------------------------------------------------------------------*/ static int -i4bctlpoll (dev_t dev, int events, struct proc *p) +i4bctlpoll (dev_t dev, int events, struct thread *td) { return (ENODEV); } diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c index 1475428..29dce82 100644 --- a/sys/i4b/driver/i4b_rbch.c +++ b/sys/i4b/driver/i4b_rbch.c @@ -157,15 +157,15 @@ static void rbch_clrq(int unit); #define PDEVSTATIC /* - not static - */ #define IOCTL_CMD_T u_long void i4brbchattach __P((void)); -int i4brbchopen __P((dev_t dev, int flag, int fmt, struct proc *p)); -int i4brbchclose __P((dev_t dev, int flag, int fmt, struct proc *p)); +int i4brbchopen __P((dev_t dev, int flag, int fmt, struct thread *td)); +int i4brbchclose __P((dev_t dev, int flag, int fmt, struct thread *td)); int i4brbchread __P((dev_t dev, struct uio *uio, int ioflag)); int i4brbchwrite __P((dev_t dev, struct uio *uio, int ioflag)); -int i4brbchioctl __P((dev_t dev, IOCTL_CMD_T cmd, caddr_t arg, int flag, struct proc* pr)); +int i4brbchioctl __P((dev_t dev, IOCTL_CMD_T cmd, caddr_t arg, int flag, struct thread *td)); #ifdef OS_USES_POLL -int i4brbchpoll __P((dev_t dev, int events, struct proc *p)); +int i4brbchpoll __P((dev_t dev, int events, struct thread *td)); #else -PDEVSTATIC int i4brbchselect __P((dev_t dev, int rw, struct proc *p)); +PDEVSTATIC int i4brbchselect __P((dev_t dev, int rw, struct thread *td)); #endif #endif @@ -303,7 +303,7 @@ i4brbchattach() * open rbch device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p) +i4brbchopen(dev_t dev, int flag, int fmt, struct thread *td) { int unit = minor(dev); @@ -328,7 +328,7 @@ i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p) * close rbch device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchclose(dev_t dev, int flag, int fmt, struct proc *p) +i4brbchclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit = minor(dev); struct rbch_softc *sc = &rbch_softc[unit]; @@ -575,7 +575,7 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag) * rbch device ioctl handlibg *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p) +i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct thread *td) { int error = 0; int unit = minor(dev); @@ -674,7 +674,7 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p) * device driver poll *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchpoll(dev_t dev, int events, struct proc *p) +i4brbchpoll(dev_t dev, int events, struct thread *td) { int revents = 0; /* Events we found */ int s; @@ -720,7 +720,7 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) } if(revents == 0) - selrecord(p, &sc->selp); + selrecord(td, &sc->selp); splx(s); return(revents); @@ -732,7 +732,7 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) * device driver select *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchselect(dev_t dev, int rw, struct proc *p) +i4brbchselect(dev_t dev, int rw, struct thread *td) { int unit = minor(dev); struct rbch_softc *sc = &rbch_softc[unit]; diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c index 2b6115b..c9a195d 100644 --- a/sys/i4b/driver/i4b_tel.c +++ b/sys/i4b/driver/i4b_tel.c @@ -156,20 +156,20 @@ static u_char sinetab[]; PDEVSTATIC void i4btelattach __P((void)); #ifdef __bsdi__ -PDEVSTATIC int i4btelioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)); +PDEVSTATIC int i4btelioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)); #else -PDEVSTATIC int i4btelioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)); +PDEVSTATIC int i4btelioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)); #endif -int i4btelopen __P((dev_t dev, int flag, int fmt, struct proc *p)); -int i4btelclose __P((dev_t dev, int flag, int fmt, struct proc *p)); +int i4btelopen __P((dev_t dev, int flag, int fmt, struct thread *td)); +int i4btelclose __P((dev_t dev, int flag, int fmt, struct thread *td)); int i4btelread __P((dev_t dev, struct uio *uio, int ioflag)); int i4btelwrite __P((dev_t dev, struct uio * uio, int ioflag)); #ifdef OS_USES_POLL -int i4btelpoll __P((dev_t dev, int events, struct proc *p)); +int i4btelpoll __P((dev_t dev, int events, struct thread *td)); #else -int i4btelsel __P((dev_t dev, int rw, struct proc *p)); +int i4btelsel __P((dev_t dev, int rw, struct thread *td)); #endif #endif /* ! __FreeBSD__ */ @@ -234,7 +234,7 @@ SYSINIT(i4bteldev, SI_SUB_DRIVERS, #ifdef __bsdi__ -int i4btelsel(dev_t dev, int rw, struct proc *p); +int i4btelsel(dev_t dev, int rw, struct thread *td); int i4btelmatch(struct device *parent, struct cfdata *cf, void *aux); void dummy_i4btelattach(struct device*, struct device *, void *); @@ -314,7 +314,7 @@ i4btelattach() * open tel device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btelopen(dev_t dev, int flag, int fmt, struct proc *p) +i4btelopen(dev_t dev, int flag, int fmt, struct thread *td) { int unit = UNIT(dev); int func = FUNC(dev); @@ -343,7 +343,7 @@ i4btelopen(dev_t dev, int flag, int fmt, struct proc *p) * close tel device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btelclose(dev_t dev, int flag, int fmt, struct proc *p) +i4btelclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit = UNIT(dev); int func = FUNC(dev); @@ -387,11 +387,11 @@ i4btelclose(dev_t dev, int flag, int fmt, struct proc *p) *---------------------------------------------------------------------------*/ PDEVSTATIC int #if defined(__FreeBSD__) -i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #elif defined(__bsdi__) -i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #else -i4btelioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +i4btelioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) #endif { int unit = UNIT(dev); @@ -815,7 +815,7 @@ tel_tone(tel_sc_t *sc) * device driver poll *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btelpoll(dev_t dev, int events, struct proc *p) +i4btelpoll(dev_t dev, int events, struct thread *td) { int revents = 0; /* Events we found */ int s; @@ -863,7 +863,7 @@ i4btelpoll(dev_t dev, int events, struct proc *p) if(revents == 0) { NDBGL4(L4_TELDBG, "i4btel%d, selrecord", unit); - selrecord(p, &sc->selp); + selrecord(td, &sc->selp); } } else if(func == FUNCDIAL) @@ -884,7 +884,7 @@ i4btelpoll(dev_t dev, int events, struct proc *p) if(revents == 0) { NDBGL4(L4_TELDBG, "i4bteld%d, selrecord", unit); - selrecord(p, &sc->selp); + selrecord(td, &sc->selp); } } splx(s); @@ -897,7 +897,7 @@ i4btelpoll(dev_t dev, int events, struct proc *p) * device driver select *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btelsel(dev_t dev, int rw, struct proc *p) +i4btelsel(dev_t dev, int rw, struct thread *td) { int s; int unit = UNIT(dev); @@ -963,7 +963,7 @@ i4btelsel(dev_t dev, int rw, struct proc *p) } NDBGL4(L4_TELDBG, "i4bteld%d, selrecord", unit); - selrecord(p, &sc->selp); + selrecord(td, &sc->selp); splx(s); return 0; } diff --git a/sys/i4b/driver/i4b_trace.c b/sys/i4b/driver/i4b_trace.c index a9ad351..4a95094 100644 --- a/sys/i4b/driver/i4b_trace.c +++ b/sys/i4b/driver/i4b_trace.c @@ -101,14 +101,14 @@ static int outunit = -1; #define PDEVSTATIC /* - not static - */ void i4btrcattach __P((void)); -int i4btrcopen __P((dev_t dev, int flag, int fmt, struct proc *p)); -int i4btrcclose __P((dev_t dev, int flag, int fmt, struct proc *p)); +int i4btrcopen __P((dev_t dev, int flag, int fmt, struct thread *td)); +int i4btrcclose __P((dev_t dev, int flag, int fmt, struct thread *td)); int i4btrcread __P((dev_t dev, struct uio * uio, int ioflag)); #ifdef __bsdi__ -int i4btrcioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)); +int i4btrcioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)); #else -int i4btrcioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)); +int i4btrcioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)); #endif #endif @@ -333,7 +333,7 @@ get_trace_data_from_l1(i4b_trace_hdr_t *hdr, int len, char *buf) * open trace device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btrcopen(dev_t dev, int flag, int fmt, struct proc *p) +i4btrcopen(dev_t dev, int flag, int fmt, struct thread *td) { int x; int unit = minor(dev); @@ -360,7 +360,7 @@ i4btrcopen(dev_t dev, int flag, int fmt, struct proc *p) * close trace device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btrcclose(dev_t dev, int flag, int fmt, struct proc *p) +i4btrcclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit = minor(dev); int i, x; @@ -462,7 +462,7 @@ i4btrcread(dev_t dev, struct uio * uio, int ioflag) * poll device *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4btrcpoll(dev_t dev, int events, struct proc *p) +i4btrcpoll(dev_t dev, int events, struct thread *td) { return(ENODEV); } @@ -473,11 +473,11 @@ i4btrcpoll(dev_t dev, int events, struct proc *p) *---------------------------------------------------------------------------*/ PDEVSTATIC int #if defined (__FreeBSD_version) && __FreeBSD_version >= 300003 -i4btrcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4btrcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #elif defined(__bsdi__) -i4btrcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4btrcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #else -i4btrcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +i4btrcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) #endif { int error = 0; diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c index f26adf8..f5f3224 100644 --- a/sys/i4b/layer4/i4b_i4bdrv.c +++ b/sys/i4b/layer4/i4b_i4bdrv.c @@ -132,20 +132,20 @@ static void *devfs_token; #define PDEVSTATIC /* - not static - */ PDEVSTATIC void i4battach __P((void)); -PDEVSTATIC int i4bopen __P((dev_t dev, int flag, int fmt, struct proc *p)); -PDEVSTATIC int i4bclose __P((dev_t dev, int flag, int fmt, struct proc *p)); +PDEVSTATIC int i4bopen __P((dev_t dev, int flag, int fmt, struct thread *td)); +PDEVSTATIC int i4bclose __P((dev_t dev, int flag, int fmt, struct thread *td)); PDEVSTATIC int i4bread __P((dev_t dev, struct uio *uio, int ioflag)); #ifdef __bsdi__ -PDEVSTATIC int i4bioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)); +PDEVSTATIC int i4bioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)); #else -PDEVSTATIC int i4bioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)); +PDEVSTATIC int i4bioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)); #endif #ifdef OS_USES_POLL -PDEVSTATIC int i4bpoll __P((dev_t dev, int events, struct proc *p)); +PDEVSTATIC int i4bpoll __P((dev_t dev, int events, struct thread *td)); #else -PDEVSTATIC int i4bselect __P((dev_t dev, int rw, struct proc *p)); +PDEVSTATIC int i4bselect __P((dev_t dev, int rw, struct thread *td)); #endif #endif /* #ifndef __FreeBSD__ */ @@ -275,7 +275,7 @@ i4battach() * i4bopen - device driver open routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bopen(dev_t dev, int flag, int fmt, struct proc *p) +i4bopen(dev_t dev, int flag, int fmt, struct thread *td) { int x; @@ -297,7 +297,7 @@ i4bopen(dev_t dev, int flag, int fmt, struct proc *p) * i4bclose - device driver close routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bclose(dev_t dev, int flag, int fmt, struct proc *p) +i4bclose(dev_t dev, int flag, int fmt, struct thread *td) { int x = splimp(); openflag = 0; @@ -360,11 +360,11 @@ i4bread(dev_t dev, struct uio *uio, int ioflag) *---------------------------------------------------------------------------*/ PDEVSTATIC int #if defined (__FreeBSD_version) && __FreeBSD_version >= 300003 -i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #elif defined(__bsdi__) -i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #else -i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) #endif { call_desc_t *cd; @@ -920,7 +920,7 @@ diag_done: * i4bselect - device driver select routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bselect(dev_t dev, int rw, struct proc *p) +i4bselect(dev_t dev, int rw, struct thread *td) { int x; @@ -933,7 +933,7 @@ i4bselect(dev_t dev, int rw, struct proc *p) if(!IF_QEMPTY(&i4b_rdqueue)) return(1); x = splimp(); - selrecord(p, &select_rd_info); + selrecord(td, &select_rd_info); selflag = 1; splx(x); return(0); @@ -952,7 +952,7 @@ i4bselect(dev_t dev, int rw, struct proc *p) * i4bpoll - device driver poll routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4bpoll(dev_t dev, int events, struct proc *p) +i4bpoll(dev_t dev, int events, struct thread *td) { int x; @@ -965,7 +965,7 @@ i4bpoll(dev_t dev, int events, struct proc *p) return(1); x = splimp(); - selrecord(p, &select_rd_info); + selrecord(td, &select_rd_info); selflag = 1; splx(x); return(0); diff --git a/sys/ia64/ia64/exception.S b/sys/ia64/ia64/exception.S index bec2ae1..60c321a 100644 --- a/sys/ia64/ia64/exception.S +++ b/sys/ia64/ia64/exception.S @@ -31,7 +31,7 @@ #include <assym.s> /* - * ar.k7 = curproc + * ar.k7 = curthread * ar.k6 = ksp * ar.k5 = kbsp * ar.k4 = globalp diff --git a/sys/ia64/ia64/exception.s b/sys/ia64/ia64/exception.s index bec2ae1..60c321a 100644 --- a/sys/ia64/ia64/exception.s +++ b/sys/ia64/ia64/exception.s @@ -31,7 +31,7 @@ #include <assym.s> /* - * ar.k7 = curproc + * ar.k7 = curthread * ar.k6 = ksp * ar.k5 = kbsp * ar.k4 = globalp diff --git a/sys/ia64/ia64/genassym.c b/sys/ia64/ia64/genassym.c index 7da41b0..0984c87 100644 --- a/sys/ia64/ia64/genassym.c +++ b/sys/ia64/ia64/genassym.c @@ -65,11 +65,8 @@ #include <nfs/nfs.h> #include <nfs/nfsdiskless.h> -ASSYM(UPAGES, UPAGES); -ASSYM(PAGE_SIZE, PAGE_SIZE); - -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); -ASSYM(GD_FPCURPROC, offsetof(struct globaldata, gd_fpcurproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); +ASSYM(GD_FPCURTHREAD, offsetof(struct globaldata, gd_fpcurthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); @@ -79,13 +76,13 @@ ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse)); ASSYM(MTX_SAVECRIT, offsetof(struct mtx, mtx_savecrit)); ASSYM(MTX_UNOWNED, MTX_UNOWNED); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); -ASSYM(P_MD_FLAGS, offsetof(struct proc, p_md.md_flags)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); +ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack)); +ASSYM(TD_MD_FLAGS, offsetof(struct thread, td_md.md_flags)); ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); -ASSYM(SIZEOF_USER, sizeof(struct user)); - ASSYM(FRAME_SYSCALL, FRAME_SYSCALL); ASSYM(TF_CR_IPSR, offsetof(struct trapframe, tf_cr_ipsr)); @@ -101,35 +98,35 @@ ASSYM(FRAME_R6, FRAME_R6); ASSYM(FRAME_R7, FRAME_R7); ASSYM(FRAME_SP, FRAME_SP); -ASSYM(U_PCB_R4, offsetof(struct user, u_pcb.pcb_r4)); -ASSYM(U_PCB_R5, offsetof(struct user, u_pcb.pcb_r5)); -ASSYM(U_PCB_R6, offsetof(struct user, u_pcb.pcb_r6)); -ASSYM(U_PCB_R7, offsetof(struct user, u_pcb.pcb_r7)); +ASSYM(PCB_R4, offsetof(struct pcb, pcb_r4)); +ASSYM(PCB_R5, offsetof(struct pcb, pcb_r5)); +ASSYM(PCB_R6, offsetof(struct pcb, pcb_r6)); +ASSYM(PCB_R7, offsetof(struct pcb, pcb_r7)); -ASSYM(U_PCB_F2, offsetof(struct user, u_pcb.pcb_f2)); -ASSYM(U_PCB_F3, offsetof(struct user, u_pcb.pcb_f3)); -ASSYM(U_PCB_F4, offsetof(struct user, u_pcb.pcb_f4)); -ASSYM(U_PCB_F5, offsetof(struct user, u_pcb.pcb_f5)); +ASSYM(PCB_F2, offsetof(struct pcb, pcb_f2)); +ASSYM(PCB_F3, offsetof(struct pcb, pcb_f3)); +ASSYM(PCB_F4, offsetof(struct pcb, pcb_f4)); +ASSYM(PCB_F5, offsetof(struct pcb, pcb_f5)); -ASSYM(U_PCB_B0, offsetof(struct user, u_pcb.pcb_b0)); -ASSYM(U_PCB_B1, offsetof(struct user, u_pcb.pcb_b1)); -ASSYM(U_PCB_B2, offsetof(struct user, u_pcb.pcb_b2)); -ASSYM(U_PCB_B3, offsetof(struct user, u_pcb.pcb_b3)); -ASSYM(U_PCB_B4, offsetof(struct user, u_pcb.pcb_b4)); -ASSYM(U_PCB_B5, offsetof(struct user, u_pcb.pcb_b5)); +ASSYM(PCB_B0, offsetof(struct pcb, pcb_b0)); +ASSYM(PCB_B1, offsetof(struct pcb, pcb_b1)); +ASSYM(PCB_B2, offsetof(struct pcb, pcb_b2)); +ASSYM(PCB_B3, offsetof(struct pcb, pcb_b3)); +ASSYM(PCB_B4, offsetof(struct pcb, pcb_b4)); +ASSYM(PCB_B5, offsetof(struct pcb, pcb_b5)); -ASSYM(U_PCB_OLD_UNAT, offsetof(struct user, u_pcb.pcb_old_unat)); -ASSYM(U_PCB_SP, offsetof(struct user, u_pcb.pcb_sp)); -ASSYM(U_PCB_PFS, offsetof(struct user, u_pcb.pcb_pfs)); -ASSYM(U_PCB_BSPSTORE, offsetof(struct user, u_pcb.pcb_bspstore)); +ASSYM(PCB_OLD_UNAT, offsetof(struct pcb, pcb_old_unat)); +ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); +ASSYM(PCB_PFS, offsetof(struct pcb, pcb_pfs)); +ASSYM(PCB_BSPSTORE, offsetof(struct pcb, pcb_bspstore)); -ASSYM(U_PCB_UNAT, offsetof(struct user, u_pcb.pcb_unat)); -ASSYM(U_PCB_RNAT, offsetof(struct user, u_pcb.pcb_rnat)); -ASSYM(U_PCB_PR, offsetof(struct user, u_pcb.pcb_pr)); +ASSYM(PCB_UNAT, offsetof(struct pcb, pcb_unat)); +ASSYM(PCB_RNAT, offsetof(struct pcb, pcb_rnat)); +ASSYM(PCB_PR, offsetof(struct pcb, pcb_pr)); -ASSYM(U_PCB_ONFAULT, offsetof(struct user, u_pcb.pcb_onfault)); +ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -ASSYM(U_PCB_HIGHFP, offsetof(struct user, u_pcb.pcb_highfp)); +ASSYM(PCB_HIGHFP, offsetof(struct pcb, pcb_highfp)); ASSYM(UC_MCONTEXT_MC_AR_BSP, offsetof(ucontext_t, uc_mcontext.mc_ar_bsp)); ASSYM(UC_MCONTEXT_MC_AR_RNAT, offsetof(ucontext_t, uc_mcontext.mc_ar_rnat)); @@ -137,4 +134,8 @@ ASSYM(UC_MCONTEXT_MC_AR_RNAT, offsetof(ucontext_t, uc_mcontext.mc_ar_rnat)); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); +ASSYM(PAGE_SIZE, PAGE_SIZE); +ASSYM(KSTACK_PAGES, KSTACK_PAGES); + ASSYM(SIZEOF_TRAPFRAME, sizeof(struct trapframe)); +ASSYM(SIZEOF_PCB, sizeof(struct pcb)); diff --git a/sys/ia64/ia64/interrupt.c b/sys/ia64/ia64/interrupt.c index b4b51a8..8661fcd 100644 --- a/sys/ia64/ia64/interrupt.c +++ b/sys/ia64/ia64/interrupt.c @@ -81,10 +81,10 @@ static u_int schedclk2; void interrupt(u_int64_t vector, struct trapframe *framep) { - struct proc *p; + struct thread *td; - p = curproc; - atomic_add_int(&p->p_intr_nesting_level, 1); + td = curthread; + atomic_add_int(&td->td_intr_nesting_level, 1); switch (vector) { case 240: /* clock interrupt */ CTR0(KTR_INTR, "clock interrupt"); @@ -107,7 +107,7 @@ interrupt(u_int64_t vector, struct trapframe *framep) panic("unexpected interrupt: vec %ld\n", vector); /* NOTREACHED */ } - atomic_subtract_int(&p->p_intr_nesting_level, 1); + atomic_subtract_int(&td->td_intr_nesting_level, 1); } diff --git a/sys/ia64/ia64/locore.S b/sys/ia64/ia64/locore.S index 6aed337..55c0816 100644 --- a/sys/ia64/ia64/locore.S +++ b/sys/ia64/ia64/locore.S @@ -64,9 +64,9 @@ #endif .section .data.proc0,"aw" - .global proc0paddr + .global kstack .align PAGE_SIZE -proc0paddr: .space UPAGES * PAGE_SIZE +kstack: .space KSTACK_PAGES * PAGE_SIZE .text @@ -80,23 +80,19 @@ ENTRY(__start, 1) ;; mov cr.iva=r8 mov cr.pta=r9 - movl r10=proc0 ;; - add r10=P_ADDR,r10 - movl r11=proc0paddr + movl r11=kstack ;; - st8 [r10]=r11 srlz.i ;; srlz.d - mov r9=UPAGES*PAGE_SIZE-16 + mov r9=KSTACK_PAGES*PAGE_SIZE-SIZEOF_PCB-16 ;; movl gp=__gp // find kernel globals add sp=r9,r11 // proc0's stack - add r10=SIZEOF_USER,r11 // proc0's backing store mov ar.rsc=0 // turn off rse ;; - mov ar.bspstore=r10 // switch backing store + mov ar.bspstore=r11 // switch backing store ;; loadrs // invalidate regs ;; @@ -105,17 +101,19 @@ ENTRY(__start, 1) br.call.sptk.many rp=ia64_init /* - * switch to proc0 and then initialise the rest of the kernel. + * switch to thread0 and then initialise the rest of the kernel. */ alloc r16=ar.pfs,0,0,1,0 ;; - movl out0=proc0 + movl out0=thread0 ;; - add out0=P_ADDR,out0 + ld8 out0=[out0] + ;; + add out0=TD_PCB,out0 ;; ld8 out0=[out0] ;; - add r16=U_PCB_B0,out0 // return to mi_startup + add r16=PCB_B0,out0 // return to mi_startup movl r17=mi_startup ;; st8 [r16]=r17 diff --git a/sys/ia64/ia64/locore.s b/sys/ia64/ia64/locore.s index 6aed337..55c0816 100644 --- a/sys/ia64/ia64/locore.s +++ b/sys/ia64/ia64/locore.s @@ -64,9 +64,9 @@ #endif .section .data.proc0,"aw" - .global proc0paddr + .global kstack .align PAGE_SIZE -proc0paddr: .space UPAGES * PAGE_SIZE +kstack: .space KSTACK_PAGES * PAGE_SIZE .text @@ -80,23 +80,19 @@ ENTRY(__start, 1) ;; mov cr.iva=r8 mov cr.pta=r9 - movl r10=proc0 ;; - add r10=P_ADDR,r10 - movl r11=proc0paddr + movl r11=kstack ;; - st8 [r10]=r11 srlz.i ;; srlz.d - mov r9=UPAGES*PAGE_SIZE-16 + mov r9=KSTACK_PAGES*PAGE_SIZE-SIZEOF_PCB-16 ;; movl gp=__gp // find kernel globals add sp=r9,r11 // proc0's stack - add r10=SIZEOF_USER,r11 // proc0's backing store mov ar.rsc=0 // turn off rse ;; - mov ar.bspstore=r10 // switch backing store + mov ar.bspstore=r11 // switch backing store ;; loadrs // invalidate regs ;; @@ -105,17 +101,19 @@ ENTRY(__start, 1) br.call.sptk.many rp=ia64_init /* - * switch to proc0 and then initialise the rest of the kernel. + * switch to thread0 and then initialise the rest of the kernel. */ alloc r16=ar.pfs,0,0,1,0 ;; - movl out0=proc0 + movl out0=thread0 ;; - add out0=P_ADDR,out0 + ld8 out0=[out0] + ;; + add out0=TD_PCB,out0 ;; ld8 out0=[out0] ;; - add r16=U_PCB_B0,out0 // return to mi_startup + add r16=PCB_B0,out0 // return to mi_startup movl r17=mi_startup ;; st8 [r16]=r17 diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index eb6a997..e5af476 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -86,7 +86,9 @@ struct bootinfo bootinfo; struct mtx sched_lock; struct mtx Giant; -char proc0paddr[UPAGES * PAGE_SIZE]; +extern char kstack[]; +struct user *proc0uarea; +vm_offset_t proc0kstack; char machine[] = "ia64"; SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); @@ -546,11 +548,23 @@ ia64_init() } + proc_linkup(&proc0); + /* + * Init mapping for u page(s) for proc 0 + */ + proc0uarea = (struct user *)pmap_steal_memory(UAREA_PAGES * PAGE_SIZE); + proc0kstack = (vm_offset_t)kstack; + proc0.p_uarea = proc0uarea; + thread0 = &proc0.p_thread; + thread0->td_kstack = proc0kstack; + thread0->td_pcb = (struct pcb *) + (thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; /* * Setup the global data for the bootstrap cpu. */ { - size_t sz = round_page(UPAGES * PAGE_SIZE); + /* This is not a 'struct user' */ + size_t sz = round_page(KSTACK_PAGES * PAGE_SIZE); globalp = (struct globaldata *) pmap_steal_memory(sz); globaldata_init(globalp, 0, sz); ia64_set_k4((u_int64_t) globalp); @@ -568,18 +582,18 @@ ia64_init() * Set the kernel sp, reserving space for an (empty) trapframe, * and make proc0's trapframe pointer point to it for sanity. * Initialise proc0's backing store to start after u area. + * + * XXX what is all this +/- 16 stuff? */ - proc0.p_addr->u_pcb.pcb_sp = - (u_int64_t)proc0.p_addr + USPACE - sizeof(struct trapframe) - 16; - proc0.p_addr->u_pcb.pcb_bspstore = (u_int64_t) (proc0.p_addr + 1); - proc0.p_frame = - (struct trapframe *)(proc0.p_addr->u_pcb.pcb_sp + 16); + thread0->td_frame = (struct trapframe *)thread0->td_pcb - 1; + thread0->td_pcb->pcb_sp = (u_int64_t)thread0->td_frame - 16; + thread0->td_pcb->pcb_bspstore = (u_int64_t)proc0kstack; /* Setup curproc so that mutexes work */ - PCPU_SET(curproc, &proc0); + PCPU_SET(curthread, thread0); PCPU_SET(spinlocks, NULL); - LIST_INIT(&proc0.p_contested); + LIST_INIT(&thread0->td_contested); /* * Initialise mutexes. @@ -739,16 +753,19 @@ DELAY(int n) void sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { - struct proc *p = curproc; + struct proc *p; + struct thread *td; struct trapframe *frame; struct sigacts *psp; struct sigframe sf, *sfp; u_int64_t sbs = 0; int oonstack, rndfsize; + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; - frame = p->p_frame; + frame = td->td_frame; oonstack = sigonstack(frame->tf_r[FRAME_SP]); rndfsize = ((sizeof(sf) + 15) / 16) * 16; @@ -843,12 +860,12 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) #if 0 /* save the floating-point state, if necessary, then copy it. */ - ia64_fpstate_save(p, 1); - sf.sf_uc.uc_mcontext.mc_ownedfp = p->p_md.md_flags & MDP_FPUSED; - bcopy(&p->p_addr->u_pcb.pcb_fp, + ia64_fpstate_save(td, 1); + sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; + bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs, sizeof(struct fpreg)); - sf.sf_uc.uc_mcontext.mc_fp_control = p->p_addr->u_pcb.pcb_fp_control; + sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb.pcb_fp_control; #endif /* @@ -907,7 +924,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) */ #ifdef COMPAT_43 int -osigreturn(struct proc *p, +osigreturn(struct thread *td, struct osigreturn_args /* { struct osigcontext *sigcntxp; } */ *uap) @@ -927,18 +944,20 @@ osigreturn(struct proc *p, */ int -sigreturn(struct proc *p, +sigreturn(struct thread *td, struct sigreturn_args /* { ucontext_t *sigcntxp; } */ *uap) { ucontext_t uc, *ucp; struct pcb *pcb; - struct trapframe *frame = p->p_frame; + struct trapframe *frame = td->td_frame; struct __mcontext *mcp; + struct proc *p; ucp = uap->sigcntxp; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; + p = td->td_proc; #ifdef DEBUG if (sigdebug & SDB_FOLLOW) @@ -1000,12 +1019,11 @@ sigreturn(struct proc *p, PROC_UNLOCK(p); /* XXX ksc.sc_ownedfp ? */ - ia64_fpstate_drop(p); + ia64_fpstate_drop(td); #if 0 bcopy((struct fpreg *)uc.uc_mcontext.mc_fpregs, - &p->p_addr->u_pcb.pcb_fp, sizeof(struct fpreg)); - p->p_addr->u_pcb.pcb_fp_control = - uc.uc_mcontext.mc_fp_control; + &td->td_pcb->pcb_fp, sizeof(struct fpreg)); + td->td_pcb->pcb_fp_control = uc.uc_mcontext.mc_fp_control; #endif #ifdef DEBUG @@ -1039,11 +1057,11 @@ cpu_halt(void) * Clear registers on exec */ void -setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) +setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) { struct trapframe *frame; - frame = p->p_frame; + frame = td->td_frame; /* * Make sure that we restore the entire trapframe after an @@ -1069,25 +1087,25 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) * Setup the new backing store and make sure the new image * starts executing with an empty register stack frame. */ - frame->tf_ar_bspstore = p->p_md.md_bspstore; + frame->tf_ar_bspstore = td->td_md.md_bspstore; frame->tf_ndirty = 0; frame->tf_cr_ifs = (1L<<63); /* ifm=0, v=1 */ frame->tf_ar_rsc = 0xf; /* user mode rsc */ frame->tf_ar_fpsr = IA64_FPSR_DEFAULT; - p->p_md.md_flags &= ~MDP_FPUSED; - ia64_fpstate_drop(p); + td->td_md.md_flags &= ~MDP_FPUSED; + ia64_fpstate_drop(td); } int -ptrace_set_pc(struct proc *p, unsigned long addr) +ptrace_set_pc(struct thread *td, unsigned long addr) { /* TODO set pc in trapframe */ return 0; } int -ptrace_single_step(struct proc *p) +ptrace_single_step(struct thread *td) { /* TODO arrange for user process to single step */ return 0; @@ -1100,8 +1118,8 @@ ia64_pa_access(vm_offset_t pa) } int -fill_regs(p, regs) - struct proc *p; +fill_regs(td, regs) + struct thread *td; struct reg *regs; { /* TODO copy trapframe to regs */ @@ -1109,8 +1127,8 @@ fill_regs(p, regs) } int -set_regs(p, regs) - struct proc *p; +set_regs(td, regs) + struct thread *td; struct reg *regs; { /* TODO copy regs to trapframe */ @@ -1118,29 +1136,29 @@ set_regs(p, regs) } int -fill_fpregs(p, fpregs) - struct proc *p; +fill_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { /* TODO copy fpu state to fpregs */ - ia64_fpstate_save(p, 0); + ia64_fpstate_save(td, 0); #if 0 - bcopy(&p->p_addr->u_pcb.pcb_fp, fpregs, sizeof *fpregs); + bcopy(&td->td_pcb->pcb_fp, fpregs, sizeof *fpregs); #endif return (0); } int -set_fpregs(p, fpregs) - struct proc *p; +set_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { /* TODO copy fpregs fpu state */ - ia64_fpstate_drop(p); + ia64_fpstate_drop(td); #if 0 - bcopy(fpregs, &p->p_addr->u_pcb.pcb_fp, sizeof *fpregs); + bcopy(fpregs, &td->td_pcb->pcb_fp, sizeof *fpregs); #endif return (0); } @@ -1236,11 +1254,11 @@ SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock, CTLFLAG_RW, &wall_cmos_clock, 0, ""); void -ia64_fpstate_check(struct proc *p) +ia64_fpstate_check(struct thread *td) { - if ((p->p_frame->tf_cr_ipsr & IA64_PSR_DFH) == 0) - if (p != PCPU_GET(fpcurproc)) - panic("ia64_check_fpcurproc: bogus"); + if ((td->td_frame->tf_cr_ipsr & IA64_PSR_DFH) == 0) + if (td != PCPU_GET(fpcurthread)) + panic("ia64_check_fpcurthread: bogus"); } /* @@ -1251,17 +1269,17 @@ ia64_fpstate_check(struct proc *p) * by generating a disabled fp trap. */ void -ia64_fpstate_save(struct proc *p, int write) +ia64_fpstate_save(struct thread *td, int write) { - if (p == PCPU_GET(fpcurproc)) { + if (td == PCPU_GET(fpcurthread)) { /* * Save the state in the pcb. */ - savehighfp(p->p_addr->u_pcb.pcb_highfp); + savehighfp(td->td_pcb->pcb_highfp); if (write) { - p->p_frame->tf_cr_ipsr |= IA64_PSR_DFH; - PCPU_SET(fpcurproc, NULL); + td->td_frame->tf_cr_ipsr |= IA64_PSR_DFH; + PCPU_SET(fpcurthread, NULL); } } } @@ -1272,11 +1290,11 @@ ia64_fpstate_save(struct proc *p, int write) * (e.g. on sigreturn). */ void -ia64_fpstate_drop(struct proc *p) +ia64_fpstate_drop(struct thread *td) { - if (p == PCPU_GET(fpcurproc)) { - p->p_frame->tf_cr_ipsr |= IA64_PSR_DFH; - PCPU_SET(fpcurproc, NULL); + if (td == PCPU_GET(fpcurthread)) { + td->td_frame->tf_cr_ipsr |= IA64_PSR_DFH; + PCPU_SET(fpcurthread, NULL); } } @@ -1285,24 +1303,24 @@ ia64_fpstate_drop(struct proc *p) * from the pcb. */ void -ia64_fpstate_switch(struct proc *p) +ia64_fpstate_switch(struct thread *td) { - if (PCPU_GET(fpcurproc)) { + if (PCPU_GET(fpcurthread)) { /* * Dump the old fp state if its valid. */ - savehighfp(PCPU_GET(fpcurproc)->p_addr->u_pcb.pcb_highfp); - PCPU_GET(fpcurproc)->p_frame->tf_cr_ipsr |= IA64_PSR_DFH; + savehighfp(PCPU_GET(fpcurthread)->td_pcb->pcb_highfp); + PCPU_GET(fpcurthread)->td_frame->tf_cr_ipsr |= IA64_PSR_DFH; } /* * Remember the new FP owner and reload its state. */ - PCPU_SET(fpcurproc, p); - restorehighfp(p->p_addr->u_pcb.pcb_highfp); - p->p_frame->tf_cr_ipsr &= ~IA64_PSR_DFH; + PCPU_SET(fpcurthread, td); + restorehighfp(td->td_pcb->pcb_highfp); + td->td_frame->tf_cr_ipsr &= ~IA64_PSR_DFH; - p->p_md.md_flags |= MDP_FPUSED; + td->td_md.md_flags |= MDP_FPUSED; } /* diff --git a/sys/ia64/ia64/mem.c b/sys/ia64/ia64/mem.c index a6dd046..0142a48 100644 --- a/sys/ia64/ia64/mem.c +++ b/sys/ia64/ia64/mem.c @@ -99,12 +99,12 @@ static struct cdevsw mem_cdevsw = { struct mem_range_softc mem_range_softc; static int -mmclose(dev_t dev, int flags, int fmt, struct proc *p) +mmclose(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { #ifdef PERFMON case 32: - return perfmon_close(dev, flags, fmt, p); + return perfmon_close(dev, flags, fmt, td); #endif default: break; @@ -113,7 +113,7 @@ mmclose(dev_t dev, int flags, int fmt, struct proc *p) } static int -mmopen(dev_t dev, int flags, int fmt, struct proc *p) +mmopen(dev_t dev, int flags, int fmt, struct thread *td) { switch (minor(dev)) { @@ -124,7 +124,7 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p) break; case 32: #ifdef PERFMON - return perfmon_open(dev, flags, fmt, p); + return perfmon_open(dev, flags, fmt, td); #else return ENODEV; #endif @@ -236,12 +236,12 @@ memmmap(dev_t dev, vm_offset_t offset, int prot) } static int -mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct proc *p) +mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct thread *td) { switch(minor(dev)) { #ifdef PERFMON case 32: - return perfmon_ioctl(dev, cmd, cmdarg, flags, p); + return perfmon_ioctl(dev, cmd, cmdarg, flags, td); #endif default: return ENODEV; diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 5ddba29..3f70fb7 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -222,7 +222,7 @@ static int pmap_ridbits = 18; static vm_zone_t pvzone; static struct vm_zone pvzone_store; static struct vm_object pvzone_obj; -static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0; +static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; static int pmap_pagedaemon_waken = 0; static struct pv_entry *pvinit; @@ -320,7 +320,7 @@ pmap_bootstrap() * Set up proc0's PCB. */ #if 0 - proc0.p_addr->u_pcb.pcb_hw.apcb_asn = 0; + thread0->td_pcb->pcb_hw.apcb_asn = 0; #endif } @@ -505,7 +505,7 @@ pmap_track_modified(vm_offset_t va) } /* - * Create the UPAGES for a new process. + * Create the U area for a new process. * This routine directly affects the fork perf for a process. */ void @@ -518,7 +518,7 @@ pmap_new_proc(struct proc *p) * 7 address for it which makes it impossible to accidentally * lose when recording a trapframe. */ - up = contigmalloc(UPAGES * PAGE_SIZE, M_PMAP, + up = contigmalloc(UAREA_PAGES * PAGE_SIZE, M_PMAP, M_WAITOK, 0ul, 256*1024*1024 - 1, @@ -526,86 +526,96 @@ pmap_new_proc(struct proc *p) 256*1024*1024); p->p_md.md_uservirt = up; - p->p_addr = (struct user *) + p->p_uarea = (struct user *) IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t) up)); } /* - * Dispose the UPAGES for a process that has exited. + * Dispose the U area for a process that has exited. * This routine directly impacts the exit perf of a process. */ void pmap_dispose_proc(p) struct proc *p; { - contigfree(p->p_md.md_uservirt, UPAGES * PAGE_SIZE, M_PMAP); + contigfree(p->p_md.md_uservirt, UAREA_PAGES * PAGE_SIZE, M_PMAP); p->p_md.md_uservirt = 0; - p->p_addr = 0; + p->p_uarea = 0; } /* - * Allow the UPAGES for a process to be prejudicially paged out. + * Allow the U area for a process to be prejudicially paged out. */ void pmap_swapout_proc(p) struct proc *p; { -#if 0 - int i; - vm_object_t upobj; - vm_offset_t up; - vm_page_t m; +} + +/* + * Bring the U area for a specified process back in. + */ +void +pmap_swapin_proc(p) + struct proc *p; +{ +} + +/* + * Create the KSTACK for a new thread. + * This routine directly affects the fork perf for a process/thread. + */ +void +pmap_new_thread(struct thread *td) +{ + vm_offset_t *ks; /* - * Make sure we aren't fpcurproc. + * Use contigmalloc for user area so that we can use a region + * 7 address for it which makes it impossible to accidentally + * lose when recording a trapframe. */ - ia64_fpstate_save(p, 1); + ks = contigmalloc(KSTACK_PAGES * PAGE_SIZE, M_PMAP, + M_WAITOK, + 0ul, + 256*1024*1024 - 1, + PAGE_SIZE, + 256*1024*1024); - upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { - m = vm_page_lookup(upobj, i); - if (m == NULL) - panic("pmap_swapout_proc: upage already missing?"); - vm_page_dirty(m); - vm_page_unwire(m, 0); - pmap_kremove(up + i * PAGE_SIZE); - } -#endif + td->td_md.md_kstackvirt = ks; + td->td_kstack = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)ks)); } /* - * Bring the UPAGES for a specified process back in. + * Dispose the KSTACK for a thread that has exited. + * This routine directly impacts the exit perf of a process/thread. */ void -pmap_swapin_proc(p) - struct proc *p; +pmap_dispose_thread(td) + struct thread *td; { -#if 0 - int i, rv; - vm_object_t upobj; - vm_offset_t up; - vm_page_t m; + contigfree(td->td_md.md_kstackvirt, KSTACK_PAGES * PAGE_SIZE, M_PMAP); + td->td_md.md_kstackvirt = 0; + td->td_kstack = 0; +} - upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { - m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); - pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); - if (m->valid != VM_PAGE_BITS_ALL) { - rv = vm_pager_get_pages(upobj, &m, 1, 0); - if (rv != VM_PAGER_OK) - panic("pmap_swapin_proc: cannot get upages for proc: %d\n", p->p_pid); - m = vm_page_lookup(upobj, i); - m->valid = VM_PAGE_BITS_ALL; - } - vm_page_wire(m); - vm_page_wakeup(m); - vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); - } -#endif +/* + * Allow the KSTACK for a thread to be prejudicially paged out. + */ +void +pmap_swapout_thread(td) + struct thread *td; +{ } +/* + * Bring the KSTACK for a specified thread back in. + */ +void +pmap_swapin_thread(td) + struct thread *td; +{ +} /*************************************************** * Page table page management routines..... ***************************************************/ @@ -1149,7 +1159,7 @@ pmap_collect() { int i; vm_page_t m; - static int warningdone=0; + static int warningdone = 0; if (pmap_pagedaemon_waken == 0) return; @@ -2199,9 +2209,9 @@ pmap_mincore(pmap, addr) } void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { - pmap_install(vmspace_pmap(p->p_vmspace)); + pmap_install(vmspace_pmap(td->td_proc->p_vmspace)); } pmap_t @@ -2281,14 +2291,14 @@ pmap_pid_dump(int pid) int i,j; index = 0; pmap = vmspace_pmap(p->p_vmspace); - for(i=0;i<1024;i++) { + for(i = 0; i < 1024; i++) { pd_entry_t *pde; pt_entry_t *pte; unsigned base = i << PDRSHIFT; pde = &pmap->pm_pdir[i]; if (pde && pmap_pde_v(pde)) { - for(j=0;j<1024;j++) { + for(j = 0; j < 1024; j++) { unsigned va = base + (j << PAGE_SHIFT); if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) { if (index) { diff --git a/sys/ia64/ia64/procfs_machdep.c b/sys/ia64/ia64/procfs_machdep.c index e623e49..08582fb 100644 --- a/sys/ia64/ia64/procfs_machdep.c +++ b/sys/ia64/ia64/procfs_machdep.c @@ -85,7 +85,7 @@ int error; \ \ mtx_lock_spin(&sched_lock); \ - if ((p->p_sflag & PS_INMEM) == 0) \ + if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ error = EIO; \ else \ error = (action); \ @@ -94,21 +94,21 @@ } while(0) int -procfs_read_regs(p, regs) - struct proc *p; +procfs_read_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(fill_regs(p, regs)); + PROCFS_ACTION(fill_regs(td, regs)); } int -procfs_write_regs(p, regs) - struct proc *p; +procfs_write_regs(td, regs) + struct thread *td; struct reg *regs; { - PROCFS_ACTION(set_regs(p, regs)); + PROCFS_ACTION(set_regs(td, regs)); } /* @@ -117,26 +117,26 @@ procfs_write_regs(p, regs) */ int -procfs_read_fpregs(p, fpregs) - struct proc *p; +procfs_read_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(fill_fpregs(p, fpregs)); + PROCFS_ACTION(fill_fpregs(td, fpregs)); } int -procfs_write_fpregs(p, fpregs) - struct proc *p; +procfs_write_fpregs(td, fpregs) + struct thread *td; struct fpreg *fpregs; { - PROCFS_ACTION(set_fpregs(p, fpregs)); + PROCFS_ACTION(set_fpregs(td, fpregs)); } int -procfs_sstep(p) - struct proc *p; +procfs_sstep(td) + struct thread *td; { return (EINVAL); } @@ -145,16 +145,16 @@ procfs_sstep(p) * Placeholders */ int -procfs_read_dbregs(p, dbregs) - struct proc *p; +procfs_read_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { return (EIO); } int -procfs_write_dbregs(p, dbregs) - struct proc *p; +procfs_write_dbregs(td, dbregs) + struct thread *td; struct dbreg *dbregs; { return (EIO); diff --git a/sys/ia64/ia64/ssc.c b/sys/ia64/ia64/ssc.c index ecc593e..52eb48f 100644 --- a/sys/ia64/ia64/ssc.c +++ b/sys/ia64/ia64/ssc.c @@ -124,7 +124,7 @@ ssccncheckc(dev_t dev) } static int -sscopen(dev_t dev, int flag, int mode, struct proc *p) +sscopen(dev_t dev, int flag, int mode, struct thread *td) { struct tty *tp; int s; @@ -148,7 +148,7 @@ sscopen(dev_t dev, int flag, int mode, struct proc *p) ttsetwater(tp); setuptimeout = 1; - } else if ((tp->t_state & TS_XCLUDE) && suser(p)) { + } else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) { splx(s); return EBUSY; } @@ -167,7 +167,7 @@ sscopen(dev_t dev, int flag, int mode, struct proc *p) } static int -sscclose(dev_t dev, int flag, int mode, struct proc *p) +sscclose(dev_t dev, int flag, int mode, struct thread *td) { int unit = minor(dev); struct tty *tp = ssc_tp; @@ -182,7 +182,7 @@ sscclose(dev_t dev, int flag, int mode, struct proc *p) } static int -sscioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +sscioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int unit = minor(dev); struct tty *tp = ssc_tp; @@ -191,7 +191,7 @@ sscioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (unit != 0) return ENXIO; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return error; error = ttioctl(tp, cmd, data, flag); diff --git a/sys/ia64/ia64/sscdisk.c b/sys/ia64/ia64/sscdisk.c index 5b7bd09..8e473ad 100644 --- a/sys/ia64/ia64/sscdisk.c +++ b/sys/ia64/ia64/sscdisk.c @@ -121,14 +121,14 @@ struct ssc_s { static int sscunits; static int -sscopen(dev_t dev, int flag, int fmt, struct proc *p) +sscopen(dev_t dev, int flag, int fmt, struct thread *td) { struct ssc_s *sc; struct disklabel *dl; if (ssc_debug) printf("sscopen(%s %x %x %p)\n", - devtoname(dev), flag, fmt, p); + devtoname(dev), flag, fmt, td); sc = dev->si_drv1; @@ -144,12 +144,12 @@ sscopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -sscioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) +sscioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { if (ssc_debug) printf("sscioctl(%s %lx %p %x %p)\n", - devtoname(dev), cmd, addr, flags, p); + devtoname(dev), cmd, addr, flags, td); return (ENOIOCTL); } diff --git a/sys/ia64/ia64/support.S b/sys/ia64/ia64/support.S index 2e18b9c..d6c71d5 100644 --- a/sys/ia64/ia64/support.S +++ b/sys/ia64/ia64/support.S @@ -70,15 +70,15 @@ ENTRY(suword, 2) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -98,15 +98,15 @@ ENTRY(subyte, 2) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -126,15 +126,15 @@ ENTRY(fuword, 1) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -153,15 +153,15 @@ ENTRY(fubyte, 1) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -242,15 +242,15 @@ ENTRY(copyinstr, 4) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -277,15 +277,15 @@ ENTRY(copyoutstr, 4) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -392,15 +392,15 @@ ENTRY(copyin, 3) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -427,15 +427,15 @@ ENTRY(copyout, 3) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -453,11 +453,11 @@ END(copyout) ENTRY(copyerr, 0) - add r14=GD_CURPROC,r13 ;; // find curproc + add r14=GD_CURTHREAD,r13 ;; // find curthread ld8 r14=[r14] ;; - add r14=P_ADDR,r14 ;; // curproc->p_addr + add r14=TD_PCB,r14 ;; // curthread->td_addr ld8 r14=[r14] ;; - add r14=U_PCB_ONFAULT,r14 ;; // &curproc->p_addr->u_pcb.pcb_onfault + add r14=PCB_ONFAULT,r14 ;; // &curthread->td_pcb->pcb_onfault st8 [r14]=r0 // reset fault handler mov ret0=EFAULT // return EFAULT diff --git a/sys/ia64/ia64/support.s b/sys/ia64/ia64/support.s index 2e18b9c..d6c71d5 100644 --- a/sys/ia64/ia64/support.s +++ b/sys/ia64/ia64/support.s @@ -70,15 +70,15 @@ ENTRY(suword, 2) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -98,15 +98,15 @@ ENTRY(subyte, 2) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -126,15 +126,15 @@ ENTRY(fuword, 1) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -153,15 +153,15 @@ ENTRY(fubyte, 1) (p6) br.dpnt.few fusufault movl r14=fusufault // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add r15=U_PCB_ONFAULT,r15 + add r15=PCB_ONFAULT,r15 ;; st8 [r15]=r14 ;; @@ -242,15 +242,15 @@ ENTRY(copyinstr, 4) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -277,15 +277,15 @@ ENTRY(copyoutstr, 4) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -392,15 +392,15 @@ ENTRY(copyin, 3) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -427,15 +427,15 @@ ENTRY(copyout, 3) ;; (p6) br.cond.spnt.few copyerr // if it's not, error out. movl r14=copyerr // set up fault handler. - add r15=GD_CURPROC,r13 // find curproc + add r15=GD_CURTHREAD,r13 // find curthread ;; ld8 r15=[r15] ;; - add r15=P_ADDR,r15 // find pcb + add r15=TD_PCB,r15 // find pcb ;; ld8 r15=[r15] ;; - add loc2=U_PCB_ONFAULT,r15 + add loc2=PCB_ONFAULT,r15 ;; st8 [loc2]=r14 ;; @@ -453,11 +453,11 @@ END(copyout) ENTRY(copyerr, 0) - add r14=GD_CURPROC,r13 ;; // find curproc + add r14=GD_CURTHREAD,r13 ;; // find curthread ld8 r14=[r14] ;; - add r14=P_ADDR,r14 ;; // curproc->p_addr + add r14=TD_PCB,r14 ;; // curthread->td_addr ld8 r14=[r14] ;; - add r14=U_PCB_ONFAULT,r14 ;; // &curproc->p_addr->u_pcb.pcb_onfault + add r14=PCB_ONFAULT,r14 ;; // &curthread->td_pcb->pcb_onfault st8 [r14]=r0 // reset fault handler mov ret0=EFAULT // return EFAULT diff --git a/sys/ia64/ia64/swtch.s b/sys/ia64/ia64/swtch.s index 10f568e..e26cdb2 100644 --- a/sys/ia64/ia64/swtch.s +++ b/sys/ia64/ia64/swtch.s @@ -105,7 +105,7 @@ ENTRY(savectx, 1) ENTRY(restorectx, 1) - add r3=U_PCB_UNAT,in0 // point at NaT for r4..r7 + add r3=PCB_UNAT,in0 // point at NaT for r4..r7 mov ar.rsc=0 ;; // switch off the RSE ld8 r16=[r3] // load NaT for r4..r7 ;; @@ -158,9 +158,9 @@ ENTRY(restorectx, 1) ENTRY(cpu_switch, 0) - add r16=GD_CURPROC,r13 ;; + add r16=GD_CURTHREAD,r13 ;; ld8 r17=[r16] ;; - add r17=P_ADDR,r17 ;; + add r17=TD_PCB,r17 ;; ld8 r17=[r17] flushrs // push out caller's dirty regs @@ -209,18 +209,18 @@ ENTRY(cpu_switch, 0) mov ar.rsc=3 // turn RSE back on - br.call.sptk.few rp=chooseproc + br.call.sptk.few rp=choosethread - add r14=GD_CURPROC,r13 ;; + add r14=GD_CURTHREAD,r13 ;; ld8 r15=[r14] ;; #if 0 - cmp.ne p6,p0=r15,ret0 // chooseproc() == curproc ? + cmp.ne p6,p0=r15,ret0 // chooseproc() == curthread ? (p6) br.dptk.few 1f ;; - add r17=P_ADDR,r15 ;; // restore b0 + add r17=TD_PCB,r15 ;; // restore b0 ld8 r17=[r17] ;; - add r17=U_PCB_B0,r17 ;; + add r17=PCB_B0,r17 ;; ld8 r17=[r17] ;; mov b0=r17 @@ -228,7 +228,7 @@ ENTRY(cpu_switch, 0) #endif 1: - st8 [r14]=ret0 // set r13->gd_curproc + st8 [r14]=ret0 // set r13->gd_curthread mov ar.k7=ret0 mov r4=ret0 // save from call ;; @@ -237,12 +237,13 @@ ENTRY(cpu_switch, 0) mov out0=r4 br.call.sptk.few rp=pmap_activate // install RIDs etc. - add r15=P_ADDR,r4 ;; - ld8 r15=[r15] ;; - add r16=SIZEOF_USER,r15 ;; + add r15=TD_PCB,r4 + add r16=TD_KSTACK,r4 ;; + ld8 r15=[r15] + ld8 r16=[r16] ;; mov ar.k5=r16 - add r3=U_PCB_UNAT,r15 // point at NaT for r4..r7 + add r3=PCB_UNAT,r15 // point at NaT for r4..r7 mov ar.rsc=0 ;; // switch off the RSE ld8 r16=[r3] // load NaT for r4..r7 ;; diff --git a/sys/ia64/ia64/sys_machdep.c b/sys/ia64/ia64/sys_machdep.c index 84e7620..097dc02 100644 --- a/sys/ia64/ia64/sys_machdep.c +++ b/sys/ia64/ia64/sys_machdep.c @@ -64,8 +64,8 @@ struct sysarch_args { #endif int -sysarch(p, uap) - struct proc *p; +sysarch(td, uap) + struct thread *td; register struct sysarch_args *uap; { int error = 0; diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 9baf9e1..c21cdf4 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -69,7 +69,7 @@ #include <ddb/ddb.h> #endif -static int unaligned_fixup(struct trapframe *framep, struct proc *p); +static int unaligned_fixup(struct trapframe *framep, struct thread *td); #ifdef WITNESS extern char *syscallnames[]; @@ -160,10 +160,10 @@ printtrap(int vector, int imm, struct trapframe *framep, int isfatal, int user) printf(" cr.isr = 0x%lx\n", framep->tf_cr_isr); printf(" cr.ifa = 0x%lx\n", framep->tf_cr_ifa); printf(" cr.iim = 0x%x\n", imm); - printf(" curproc = %p\n", curproc); - if (curproc != NULL) - printf(" pid = %d, comm = %s\n", curproc->p_pid, - curproc->p_comm); + printf(" curthread = %p\n", curthread); + if (curthread != NULL) + printf(" pid = %d, comm = %s\n", + curthread->td_proc->p_pid, curthread->td_proc->p_comm); printf("\n"); } @@ -177,6 +177,7 @@ printtrap(int vector, int imm, struct trapframe *framep, int isfatal, int user) void trap(int vector, int imm, struct trapframe *framep) { + struct thread *td; struct proc *p; int i; u_int64_t ucode; @@ -184,13 +185,14 @@ trap(int vector, int imm, struct trapframe *framep) int user; cnt.v_trap++; - p = curproc; + td = curthread; + p = td->td_proc; ucode = 0; user = ((framep->tf_cr_ipsr & IA64_PSR_CPL) == IA64_PSR_CPL_USER); if (user) { - sticks = p->p_sticks; - p->p_frame = framep; + sticks = td->td_kse->ke_sticks; + td->td_frame = framep; } else { sticks = 0; /* XXX bogus -Wuninitialized warning */ } @@ -204,7 +206,7 @@ trap(int vector, int imm, struct trapframe *framep) */ if (user) { mtx_lock(&Giant); - if ((i = unaligned_fixup(framep, p)) == 0) { + if ((i = unaligned_fixup(framep, td)) == 0) { mtx_unlock(&Giant); goto out; } @@ -246,15 +248,15 @@ trap(int vector, int imm, struct trapframe *framep) case IA64_VEC_DISABLED_FP: /* - * on exit from the kernel, if proc == fpcurproc, + * on exit from the kernel, if thread == fpcurthread, * FP is enabled. */ - if (PCPU_GET(fpcurproc) == p) { - printf("trap: fp disabled for fpcurproc == %p", p); + if (PCPU_GET(fpcurthread) == td) { + printf("trap: fp disabled for fpcurthread == %p", td); goto dopanic; } - ia64_fpstate_switch(p); + ia64_fpstate_switch(td); goto out; break; @@ -276,12 +278,11 @@ trap(int vector, int imm, struct trapframe *framep) * when they are running. */ if (!user && - p != NULL && - p->p_addr->u_pcb.pcb_onfault == - (unsigned long)fswintrberr && - p->p_addr->u_pcb.pcb_accessaddr == va) { - framep->tf_cr_iip = p->p_addr->u_pcb.pcb_onfault; - p->p_addr->u_pcb.pcb_onfault = 0; + td != NULL && + td->td_pcb->pcb_onfault == (unsigned long)fswintrberr && + td->td_pcb->pcb_accessaddr == va) { + framep->tf_cr_iip = td->td_pcb->pcb_onfault; + td->td_pcb->pcb_onfault = 0; goto out; } mtx_lock(&Giant); @@ -301,8 +302,8 @@ trap(int vector, int imm, struct trapframe *framep) */ if (!user && ((va >= VM_MIN_KERNEL_ADDRESS) - || (p == NULL) - || (p->p_addr->u_pcb.pcb_onfault == 0))) { + || (td == NULL) + || (td->td_pcb->pcb_onfault == 0))) { if (va >= trunc_page(PS_STRINGS - szsigcode - SPARE_USRSPACE) @@ -405,7 +406,7 @@ trap(int vector, int imm, struct trapframe *framep) trapsignal(p, i, ucode); out: if (user) - userret(p, framep, sticks); + userret(td, framep, sticks); if (mtx_owned(&Giant)) mtx_unlock(&Giant); return; @@ -439,15 +440,18 @@ void syscall(int code, u_int64_t *args, struct trapframe *framep) { struct sysent *callp; + struct thread *td; struct proc *p; int error = 0; u_int64_t oldip, oldri; u_int sticks; cnt.v_syscall++; - p = curproc; - p->p_frame = framep; - sticks = p->p_sticks; + td = curthread; + p = td->td_proc; + + td->td_frame = framep; + sticks = td->td_kse->ke_sticks; mtx_lock(&Giant); /* @@ -463,7 +467,7 @@ syscall(int code, u_int64_t *args, struct trapframe *framep) } #ifdef DIAGNOSTIC - ia64_fpstate_check(p); + ia64_fpstate_check(td); #endif if (p->p_sysent->sv_prepsyscall) { @@ -496,19 +500,19 @@ syscall(int code, u_int64_t *args, struct trapframe *framep) ktrsyscall(p->p_tracep, code, (callp->sy_narg & SYF_ARGMASK), args); #endif if (error == 0) { - p->p_retval[0] = 0; - p->p_retval[1] = 0; + td->td_retval[0] = 0; + td->td_retval[1] = 0; STOPEVENT(p, S_SCE, (callp->sy_narg & SYF_ARGMASK)); - error = (*callp->sy_call)(p, args); + error = (*callp->sy_call)(td, args); } switch (error) { case 0: - framep->tf_r[FRAME_R8] = p->p_retval[0]; - framep->tf_r[FRAME_R9] = p->p_retval[1]; + framep->tf_r[FRAME_R8] = td->td_retval[0]; + framep->tf_r[FRAME_R9] = td->td_retval[1]; framep->tf_r[FRAME_R10] = 0; break; case ERESTART: @@ -530,10 +534,10 @@ syscall(int code, u_int64_t *args, struct trapframe *framep) break; } - userret(p, framep, sticks); + userret(td, framep, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p->p_tracep, code, error, p->p_retval[0]); + ktrsysret(p->p_tracep, code, error, td->td_retval[0]); #endif mtx_unlock(&Giant); @@ -545,7 +549,7 @@ syscall(int code, u_int64_t *args, struct trapframe *framep) STOPEVENT(p, S_SCX, code); #ifdef WITNESS - if (witness_list(p)) { + if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", syscallnames[code]); } @@ -558,21 +562,25 @@ extern int ia64_unaligned_print, ia64_unaligned_fix; extern int ia64_unaligned_sigbus; static int -unaligned_fixup(struct trapframe *framep, struct proc *p) +unaligned_fixup(struct trapframe *framep, struct thread *td) { vm_offset_t va = framep->tf_cr_ifa; int doprint, dofix, dosigbus; int signal, size = 0; unsigned long uac; + struct proc *p; /* * Figure out what actions to take. */ - if (p) - uac = p->p_md.md_flags & MDP_UAC_MASK; - else + if (td) { + uac = td->td_md.md_flags & MDP_UAC_MASK; + p = td->td_proc; + } else { uac = 0; + p = NULL; + } doprint = ia64_unaligned_print && !(uac & MDP_UAC_NOPRINT); dofix = ia64_unaligned_fix && !(uac & MDP_UAC_NOFIX); @@ -593,7 +601,7 @@ unaligned_fixup(struct trapframe *framep, struct proc *p) */ if (doprint) { uprintf("pid %d (%s): unaligned access: va=0x%lx pc=0x%lx\n", - p->p_pid, p->p_comm, va, p->p_frame->tf_cr_iip); + p->p_pid, p->p_comm, va, td->td_frame->tf_cr_iip); } /* diff --git a/sys/ia64/ia64/vm_machdep.c b/sys/ia64/ia64/vm_machdep.c index 3774212..492b8ec 100644 --- a/sys/ia64/ia64/vm_machdep.c +++ b/sys/ia64/ia64/vm_machdep.c @@ -124,25 +124,30 @@ struct ia64_fdesc { * ready to run and return to user mode. */ void -cpu_fork(p1, p2, flags) - register struct proc *p1, *p2; +cpu_fork(td1, p2, flags) + register struct thread *td1; + register struct proc *p2; int flags; { - struct user *up; + struct proc *p1; + struct thread *td2; struct trapframe *p2tf; u_int64_t bspstore, *p1bs, *p2bs, rnatloc, rnat; if ((flags & RFPROC) == 0) return; - p2->p_frame = p1->p_frame; - p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK); + p1 = td1->td_proc; + td2 = &p2->p_thread; + td2->td_pcb = (struct pcb *) + (td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td2->td_md.md_flags = td1->td_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK); /* * Copy floating point state from the FP chip to the PCB * if this process has state stored there. */ - ia64_fpstate_save(p1, 0); + ia64_fpstate_save(td1, 0); /* * Copy pcb and stack from proc p1 to p2. We do this as @@ -150,15 +155,15 @@ cpu_fork(p1, p2, flags) * stack. The stack and pcb need to agree. Make sure that the * new process has FEN disabled. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; + bcopy(td1->td_pcb, td2->td_pcb, sizeof(struct pcb)); /* * Set the floating point state. */ #if 0 - if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) { - p2->p_addr->u_pcb.pcb_fp_control = 0; - p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL + if ((td2->td_pcb->pcb_fp_control & IEEE_INHERIT) == 0) { + td2->td_pcb->pcb_fp_control = 0; + td2->td_pcb->pcb_fp.fpr_cr = (FPCR_DYN_NORMAL | FPCR_INVD | FPCR_DZED | FPCR_OVFD | FPCR_INED | FPCR_UNFD); @@ -170,9 +175,9 @@ cpu_fork(p1, p2, flags) * is started, to resume here, returning nonzero from setjmp. */ #ifdef DIAGNOSTIC - if (p1 != curproc) + if (td1 != curthread) panic("cpu_fork: curproc"); - ia64_fpstate_check(p1); + ia64_fpstate_check(td1); #endif /* @@ -182,25 +187,24 @@ cpu_fork(p1, p2, flags) * copy trapframe from parent so return to user mode * will be to right address, with correct registers. */ - p2->p_frame = (struct trapframe *) - ((char *)p2->p_addr + USPACE - sizeof(struct trapframe)); - bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe)); + td2->td_frame = (struct trapframe *)td2->td_pcb - 1; + bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); /* * Set up return-value registers as fork() libc stub expects. */ - p2tf = p2->p_frame; + p2tf = td2->td_frame; p2tf->tf_r[FRAME_R8] = 0; /* child's pid (linux) */ p2tf->tf_r[FRAME_R9] = 1; /* is child (FreeBSD) */ p2tf->tf_r[FRAME_R10] = 0; /* no error */ /* * Turn off RSE for a moment and work out our current - * ar.bspstore. This assumes that p1==curproc. Also + * ar.bspstore. This assumes that td1==curthread. Also * flush dirty regs to ensure that the user's stacked * regs are written out to backing store. * - * We could cope with p1!=curproc by digging values + * We could cope with td1!=curthread by digging values * out of its PCB but I don't see the point since * current usage never allows it. */ @@ -208,23 +212,23 @@ cpu_fork(p1, p2, flags) __asm __volatile("flushrs;;" ::: "memory"); __asm __volatile("mov %0=ar.bspstore" : "=r"(bspstore)); - p1bs = (u_int64_t *) (p1->p_addr + 1); - p2bs = (u_int64_t *) (p2->p_addr + 1); + p1bs = (u_int64_t *)td1->td_kstack; + p2bs = (u_int64_t *)td2->td_kstack; /* - * Copy enough of p1's backing store to include all + * Copy enough of td1's backing store to include all * the user's stacked regs. */ - bcopy(p1bs, p2bs, p1->p_frame->tf_ndirty); + bcopy(p1bs, p2bs, td1->td_frame->tf_ndirty); /* - * To calculate the ar.rnat for p2, we need to decide - * if p1's ar.bspstore has advanced past the place + * To calculate the ar.rnat for td2, we need to decide + * if td1's ar.bspstore has advanced past the place * where the last ar.rnat which covers the user's * saved registers would be placed. If so, we read - * that one from memory, otherwise we take p1's + * that one from memory, otherwise we take td1's * current ar.rnat. */ - rnatloc = (u_int64_t)p1bs + p1->p_frame->tf_ndirty; + rnatloc = (u_int64_t)p1bs + td1->td_frame->tf_ndirty; rnatloc |= 0x1f8; if (bspstore > rnatloc) rnat = *(u_int64_t *) rnatloc; @@ -242,21 +246,22 @@ cpu_fork(p1, p2, flags) * should work since the child will normally return * straight into exception_restore. */ - up = p2->p_addr; - up->u_pcb.pcb_bspstore = (u_int64_t)p2bs + p1->p_frame->tf_ndirty; - up->u_pcb.pcb_rnat = rnat; - up->u_pcb.pcb_pfs = 0; + td2->td_pcb->pcb_bspstore = (u_int64_t)p2bs + td1->td_frame->tf_ndirty; + td2->td_pcb->pcb_rnat = rnat; + td2->td_pcb->pcb_pfs = 0; /* * Arrange for continuation at fork_return(), which * will return to exception_restore(). Note that the * child process doesn't stay in the kernel for long! + * + * XXX what is this +/- 16 stuff here? */ - up->u_pcb.pcb_sp = (u_int64_t)p2tf - 16; - up->u_pcb.pcb_r4 = (u_int64_t)fork_return; - up->u_pcb.pcb_r5 = FDESC_FUNC(exception_restore); - up->u_pcb.pcb_r6 = (u_int64_t)p2; - up->u_pcb.pcb_b0 = FDESC_FUNC(fork_trampoline); + td2->td_pcb->pcb_sp = (u_int64_t)p2tf - 16; + td2->td_pcb->pcb_r4 = (u_int64_t)fork_return; + td2->td_pcb->pcb_r5 = FDESC_FUNC(exception_restore); + td2->td_pcb->pcb_r6 = (u_int64_t)td2; + td2->td_pcb->pcb_b0 = FDESC_FUNC(fork_trampoline); } /* @@ -266,13 +271,13 @@ cpu_fork(p1, p2, flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(p, func, arg) - struct proc *p; +cpu_set_fork_handler(td, func, arg) + struct thread *td; void (*func) __P((void *)); void *arg; { - p->p_addr->u_pcb.pcb_r4 = (u_int64_t) func; - p->p_addr->u_pcb.pcb_r6 = (u_int64_t) arg; + td->td_pcb->pcb_r4 = (u_int64_t) func; + td->td_pcb->pcb_r6 = (u_int64_t) arg; } /* @@ -281,11 +286,11 @@ cpu_set_fork_handler(p, func, arg) * When the proc is reaped, cpu_wait() will gc the VM state. */ void -cpu_exit(p) - register struct proc *p; +cpu_exit(td) + register struct thread *td; { - ia64_fpstate_drop(p); + ia64_fpstate_drop(td); } void @@ -307,14 +312,22 @@ cpu_throw(void) * Dump the machine specific header information at the start of a core dump. */ int -cpu_coredump(p, vp, cred) - struct proc *p; +cpu_coredump(td, vp, cred) + struct thread *td; struct vnode *vp; struct ucred *cred; { - - return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p)); + int error; + + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_proc->p_uarea, + ctob(UAREA_PAGES), (off_t)0, + UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); + if (error) + return error; + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_kstack, + ctob(KSTACK_PAGES), (off_t)0, + UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); + return error; } /* diff --git a/sys/ia64/include/cpu.h b/sys/ia64/include/cpu.h index 062bebc..d7dfde8 100644 --- a/sys/ia64/include/cpu.h +++ b/sys/ia64/include/cpu.h @@ -52,7 +52,7 @@ #include <machine/frame.h> -#define cpu_getstack(p) ((p)->p_frame->tf_r[FRAME_SP]) +#define cpu_getstack(td) ((td)->td_frame->tf_r[FRAME_SP]) /* * Arguments to hardclock and gatherstats encapsulate the previous @@ -99,7 +99,7 @@ struct clockframe { #ifdef _KERNEL struct pcb; -struct proc; +struct thread; struct reg; struct rpb; struct trapframe; @@ -109,7 +109,6 @@ extern volatile int mc_expected, mc_received; int badaddr __P((void *, size_t)); int badaddr_read __P((void *, size_t, void *)); -void child_return __P((struct proc *p)); u_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t)); void do_sir __P((void)); void dumpconf __P((void)); @@ -118,10 +117,10 @@ void frametoreg __P((struct trapframe *, struct reg *)); long fswintrberr __P((void)); /* MAGIC */ int ia64_pa_access __P((u_long)); void ia64_init __P((void)); -void ia64_fpstate_check __P((struct proc *p)); -void ia64_fpstate_save __P((struct proc *p, int write)); -void ia64_fpstate_drop __P((struct proc *p)); -void ia64_fpstate_switch __P((struct proc *p)); +void ia64_fpstate_check __P((struct thread *p)); +void ia64_fpstate_save __P((struct thread *p, int write)); +void ia64_fpstate_drop __P((struct thread *p)); +void ia64_fpstate_switch __P((struct thread *p)); void init_prom_interface __P((struct rpb*)); void interrupt __P((u_int64_t, struct trapframe *)); void machine_check @@ -133,7 +132,6 @@ void regtoframe __P((struct reg *, struct trapframe *)); int savectx __P((struct pcb *)); void restorectx __P((struct pcb *)); void set_iointr __P((void (*)(void *, unsigned long))); -void switch_exit __P((struct proc *)); /* MAGIC */ void fork_trampoline __P((void)); /* MAGIC */ void syscall __P((int, u_int64_t *, struct trapframe *)); void trap __P((int vector, int imm, struct trapframe *framep)); diff --git a/sys/ia64/include/globaldata.h b/sys/ia64/include/globaldata.h index 308086c..50f4990 100644 --- a/sys/ia64/include/globaldata.h +++ b/sys/ia64/include/globaldata.h @@ -44,15 +44,14 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ u_int64_t gd_pending_ipis; /* pending IPI events */ struct pmap *gd_current_pmap; /* which pmap is active */ u_int32_t gd_next_asn; /* next ASN to allocate */ diff --git a/sys/ia64/include/globals.h b/sys/ia64/include/globals.h index 20ca26e..b953cf1 100644 --- a/sys/ia64/include/globals.h +++ b/sys/ia64/include/globals.h @@ -40,9 +40,11 @@ register struct globaldata *globalp __asm__("r13"); #define PCPU_PTR(member) (&GLOBALP->gd_ ## member) #define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value)) -#define CURPROC PCPU_GET(curproc) -#define CURTHD PCPU_GET(curproc) /* temporary */ -#define curproc PCPU_GET(curproc) +#define curthread PCPU_GET(curthread) +#define CURPROC (curthread->td_proc) +#define curproc (curthread->td_proc) +#define curksegrp (curthread->td_ksegrp) +#define curkse (curthread->td_kse) #endif /* _KERNEL */ diff --git a/sys/ia64/include/md_var.h b/sys/ia64/include/md_var.h index 2154611..789b389 100644 --- a/sys/ia64/include/md_var.h +++ b/sys/ia64/include/md_var.h @@ -39,7 +39,7 @@ extern int szsigcode; extern int Maxmem; struct fpreg; -struct proc; +struct thread; struct reg; void busdma_swi __P((void)); @@ -47,9 +47,9 @@ void cpu_halt __P((void)); void cpu_reset __P((void)); int is_physical_memory __P((vm_offset_t addr)); void swi_vm __P((void *)); -int fill_regs __P((struct proc *, struct reg *)); -int set_regs __P((struct proc *, struct reg *)); -int fill_fpregs __P((struct proc *, struct fpreg *)); -int set_fpregs __P((struct proc *, struct fpreg *)); +int fill_regs __P((struct thread *, struct reg *)); +int set_regs __P((struct thread *, struct reg *)); +int fill_fpregs __P((struct thread *, struct fpreg *)); +int set_fpregs __P((struct thread *, struct fpreg *)); #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/ia64/include/mutex.h b/sys/ia64/include/mutex.h index 2e7916c..6581d70 100644 --- a/sys/ia64/include/mutex.h +++ b/sys/ia64/include/mutex.h @@ -55,7 +55,7 @@ add rLCK=MTX_LOCK,rLCK ;; \ rsm psr.i ; \ mov ar.ccv=MTX_UNOWNED ; \ - add rNEW=PC_CURPROC,rNEW ;; \ + add rNEW=PC_CURTHREAD,rNEW ;; \ ld8 rNEW=[rNEW] ;; \ 1: cmpxchg8.acq rOLD=[rLCK],rNEW,ar.ccv ;; \ cmp.eq p1,p0=MTX_UNOWNED,rOLD ;; \ diff --git a/sys/ia64/include/param.h b/sys/ia64/include/param.h index 8c8f91d..db87619 100644 --- a/sys/ia64/include/param.h +++ b/sys/ia64/include/param.h @@ -152,8 +152,10 @@ #define SSIZE 1 /* initial stack size/NBPG */ #define SINCR 1 /* increment of stack/NBPG */ -#define UPAGES 4 /* pages of u-area */ -#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */ +#define KSTACK_PAGES 4 /* pages of kernel stack */ +#define UAREA_PAGES 1 /* pages of u-area */ + +/* #define KSTACK_GUARD */ /* compile in kstack guard page */ /* * Constants related to network buffer management. diff --git a/sys/ia64/include/pcpu.h b/sys/ia64/include/pcpu.h index 308086c..50f4990 100644 --- a/sys/ia64/include/pcpu.h +++ b/sys/ia64/include/pcpu.h @@ -44,15 +44,14 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ u_int64_t gd_pending_ipis; /* pending IPI events */ struct pmap *gd_current_pmap; /* which pmap is active */ u_int32_t gd_next_asn; /* next ASN to allocate */ diff --git a/sys/ia64/include/proc.h b/sys/ia64/include/proc.h index 9d900f0..aeacc2a 100644 --- a/sys/ia64/include/proc.h +++ b/sys/ia64/include/proc.h @@ -35,9 +35,9 @@ * Machine-dependent part of the proc struct for the Alpha. */ -struct mdproc { +struct mdthread { u_long md_flags; - struct user *md_uservirt; /* virtual address of p_addr */ + void *md_kstackvirt; /* virtual address of td_kstack */ vm_offset_t md_bspstore; /* initial ar.bspstore */ }; @@ -47,3 +47,7 @@ struct mdproc { #define MDP_UAC_SIGBUS 0x0040 /* Deliver SIGBUS upon unaligned access */ #define MDP_UAC_MASK (MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS) + +struct mdproc { + struct user *md_uservirt; /* virtual address of p_addr */ +}; diff --git a/sys/ia64/include/reg.h b/sys/ia64/include/reg.h index 31a06af..5ac4bfa 100644 --- a/sys/ia64/include/reg.h +++ b/sys/ia64/include/reg.h @@ -54,11 +54,11 @@ struct dbreg { #ifdef _KERNEL -struct proc; +struct thread; void restorehighfp __P((struct ia64_fpreg *)); void savehighfp __P((struct ia64_fpreg *)); -void setregs __P((struct proc *, u_long, u_long, u_long)); +void setregs __P((struct thread *, u_long, u_long, u_long)); #endif #endif /* _MACHINE_REG_H_ */ diff --git a/sys/isa/fd.c b/sys/isa/fd.c index f896b33..845f520 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -1519,7 +1519,7 @@ out_fdc(struct fdc_data *fdc, int x) * auxiliary functions). */ int -Fdopen(dev_t dev, int flags, int mode, struct proc *p) +Fdopen(dev_t dev, int flags, int mode, struct thread *td) { fdu_t fdu = FDUNIT(minor(dev)); int type = FDTYPE(minor(dev)); @@ -1614,7 +1614,7 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p) } int -fdclose(dev_t dev, int flags, int mode, struct proc *p) +fdclose(dev_t dev, int flags, int mode, struct thread *td) { fdu_t fdu = FDUNIT(minor(dev)); struct fd_data *fd; @@ -2473,7 +2473,7 @@ fdmisccmd(dev_t dev, u_int cmd, void *data) } static int -fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { fdu_t fdu; fd_p fd; @@ -2545,7 +2545,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) case FD_STYPE: /* set drive type */ /* this is considered harmful; only allow for superuser */ - if (suser(p) != 0) + if (suser_td(td) != 0) return (EPERM); *fd->ft = *(struct fd_type *)addr; break; @@ -2569,7 +2569,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) #endif case FD_CLRERR: - if (suser(p) != 0) + if (suser_td(td) != 0) return (EPERM); fd->fdc->fdc_errs = 0; break; diff --git a/sys/isa/joy.c b/sys/isa/joy.c index beda4de..0f3f11d 100644 --- a/sys/isa/joy.c +++ b/sys/isa/joy.c @@ -159,7 +159,7 @@ DRIVER_MODULE(joy, isa, joy_isa_driver, joy_devclass, 0, 0); DRIVER_MODULE(joy, acpi, joy_isa_driver, joy_devclass, 0, 0); static int -joyopen(dev_t dev, int flags, int fmt, struct proc *p) +joyopen(dev_t dev, int flags, int fmt, struct thread *td) { int i = joypart (dev); struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); @@ -172,7 +172,7 @@ joyopen(dev_t dev, int flags, int fmt, struct proc *p) } static int -joyclose(dev_t dev, int flags, int fmt, struct proc *p) +joyclose(dev_t dev, int flags, int fmt, struct thread *td) { int i = joypart (dev); struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); @@ -240,7 +240,7 @@ joyread(dev_t dev, struct uio *uio, int flag) } static int -joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct joy_softc *joy = JOY_SOFTC(UNIT(dev)); int i = joypart (dev); diff --git a/sys/isa/psm.c b/sys/isa/psm.c index 1bb5b71..1fb37ea 100644 --- a/sys/isa/psm.c +++ b/sys/isa/psm.c @@ -1164,7 +1164,7 @@ psmdetach(device_t dev) } static int -psmopen(dev_t dev, int flag, int fmt, struct proc *p) +psmopen(dev_t dev, int flag, int fmt, struct thread *td) { int unit = PSM_UNIT(dev); struct psm_softc *sc; @@ -1248,7 +1248,7 @@ psmopen(dev_t dev, int flag, int fmt, struct proc *p) } static int -psmclose(dev_t dev, int flag, int fmt, struct proc *p) +psmclose(dev_t dev, int flag, int fmt, struct thread *td) { int unit = PSM_UNIT(dev); struct psm_softc *sc = PSM_SOFTC(unit); @@ -1516,7 +1516,7 @@ unblock_mouse_data(struct psm_softc *sc, int c) } static int -psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); mousemode_t mode; @@ -2237,7 +2237,7 @@ psmintr(void *arg) } static int -psmpoll(dev_t dev, int events, struct proc *p) +psmpoll(dev_t dev, int events, struct thread *td) { struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); int s; @@ -2249,7 +2249,7 @@ psmpoll(dev_t dev, int events, struct proc *p) if (sc->queue.count > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sc->rsel); + selrecord(td, &sc->rsel); } splx(s); diff --git a/sys/isa/sio.c b/sys/isa/sio.c index 3c68d7c..05d8f35 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -1378,11 +1378,11 @@ determined_type: ; } static int -sioopen(dev, flag, mode, p) +sioopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -1440,7 +1440,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser_td(td)) { error = EBUSY; goto out; } @@ -1560,11 +1560,11 @@ out: } static int -sioclose(dev, flag, mode, p) +sioclose(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct com_s *com; int mynor; @@ -2114,12 +2114,12 @@ cont: } static int -sioioctl(dev, cmd, data, flag, p) +sioioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct com_s *com; int error; @@ -2150,7 +2150,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser_td(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -2200,7 +2200,7 @@ sioioctl(dev, cmd, data, flag, p) if (lt->c_ospeed != 0) dt->c_ospeed = tp->t_ospeed; } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error != ENOIOCTL) return (error); s = spltty(); @@ -2241,7 +2241,7 @@ sioioctl(dev, cmd, data, flag, p) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser(p); + error = suser_td(td); if (error != 0) { splx(s); return (error); diff --git a/sys/isa/vga_isa.c b/sys/isa/vga_isa.c index 0cc754a..101dc55 100644 --- a/sys/isa/vga_isa.c +++ b/sys/isa/vga_isa.c @@ -166,15 +166,15 @@ isavga_attach(device_t dev) #ifdef FB_INSTALL_CDEV static int -isavga_open(dev_t dev, int flag, int mode, struct proc *p) +isavga_open(dev_t dev, int flag, int mode, struct thread *td) { - return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, p); + return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); } static int -isavga_close(dev_t dev, int flag, int mode, struct proc *p) +isavga_close(dev_t dev, int flag, int mode, struct thread *td) { - return vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, p); + return vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); } static int @@ -190,9 +190,9 @@ isavga_write(dev_t dev, struct uio *uio, int flag) } static int -isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) +isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { - return vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, p); + return vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, td); } static int diff --git a/sys/isofs/cd9660/cd9660_lookup.c b/sys/isofs/cd9660/cd9660_lookup.c index b2d5057..979c0bd 100644 --- a/sys/isofs/cd9660/cd9660_lookup.c +++ b/sys/isofs/cd9660/cd9660_lookup.c @@ -120,7 +120,7 @@ cd9660_lookup(ap) struct componentname *cnp = ap->a_cnp; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; bp = NULL; *vpp = NULL; @@ -351,16 +351,16 @@ found: * it's a relocated directory. */ if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp, dp->i_ino != ino, ep); brelse(bp); if (error) { - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (lockparent && (flags & ISLASTCN)) { - if ((error = vn_lock(pdp, LK_EXCLUSIVE, p)) != 0) { + if ((error = vn_lock(pdp, LK_EXCLUSIVE, td)) != 0) { cnp->cn_flags |= PDIRUNLOCK; vput(tdp); return (error); @@ -380,7 +380,7 @@ found: return (error); if (!lockparent || !(flags & ISLASTCN)) { cnp->cn_flags |= PDIRUNLOCK; - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); } *vpp = tdp; } diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c index 00f79e8..53ffeca 100644 --- a/sys/isofs/cd9660/cd9660_node.c +++ b/sys/isofs/cd9660/cd9660_node.c @@ -97,7 +97,7 @@ cd9660_ihashget(dev, inum) dev_t dev; ino_t inum; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct iso_node *ip; struct vnode *vp; @@ -108,7 +108,7 @@ loop: vp = ITOV(ip); mtx_lock(&vp->v_interlock); mtx_unlock(&cd9660_ihash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -124,7 +124,6 @@ void cd9660_ihashins(ip) struct iso_node *ip; { - struct proc *p = curproc; /* XXX */ struct iso_node **ipp, *iq; mtx_lock(&cd9660_ihash_mtx); @@ -136,7 +135,7 @@ cd9660_ihashins(ip) *ipp = ip; mtx_unlock(&cd9660_ihash_mtx); - lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p); + lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, curthread); } /* @@ -167,11 +166,11 @@ int cd9660_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; register struct iso_node *ip = VTOI(vp); int error = 0; @@ -179,13 +178,13 @@ cd9660_inactive(ap) vprint("cd9660_inactive: pushing active", vp); ip->i_flag = 0; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * If we are done with the inode, reclaim it * so that it can be reused immediately. */ if (ip->inode.iso_mode == 0) - vrecycle(vp, NULL, p); + vrecycle(vp, NULL, td); return error; } @@ -196,7 +195,7 @@ int cd9660_reclaim(ap) struct vop_reclaim_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 0b42933..73a5bce 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -65,10 +65,10 @@ MALLOC_DEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure"); MALLOC_DEFINE(M_ISOFSNODE, "ISOFS node", "ISOFS vnode private part"); static int cd9660_mount __P((struct mount *, - char *, caddr_t, struct nameidata *, struct proc *)); -static int cd9660_unmount __P((struct mount *, int, struct proc *)); + char *, caddr_t, struct nameidata *, struct thread *)); +static int cd9660_unmount __P((struct mount *, int, struct thread *)); static int cd9660_root __P((struct mount *, struct vnode **)); -static int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); +static int cd9660_statfs __P((struct mount *, struct statfs *, struct thread *)); static int cd9660_vget __P((struct mount *, ino_t, struct vnode **)); static int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **)); static int cd9660_vptofh __P((struct vnode *, struct fid *)); @@ -97,9 +97,9 @@ MODULE_VERSION(cd9660, 1); * Called by vfs_mountroot when iso is going to be mounted as root. */ -static int iso_get_ssector __P((dev_t dev, struct proc *p)); +static int iso_get_ssector __P((dev_t dev, struct thread *td)); static int iso_mountfs __P((struct vnode *devvp, struct mount *mp, - struct proc *p, struct iso_args *argp)); + struct thread *td, struct iso_args *argp)); /* * Try to find the start of the last data track on this CD-ROM. This @@ -107,9 +107,9 @@ static int iso_mountfs __P((struct vnode *devvp, struct mount *mp, * and return 0 if we fail, this is always a safe bet. */ static int -iso_get_ssector(dev, p) +iso_get_ssector(dev, td) dev_t dev; - struct proc *p; + struct thread *td; { struct ioc_toc_header h; struct ioc_read_toc_single_entry t; @@ -122,13 +122,13 @@ iso_get_ssector(dev, p) if (ioctlp == NULL) return 0; - if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p) != 0) + if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, td) != 0) return 0; for (i = h.ending_track; i >= 0; i--) { t.address_format = CD_LBA_FORMAT; t.track = i; - if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, p) != 0) + if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, td) != 0) return 0; if ((t.entry.control & 4) != 0) /* found a data track */ @@ -141,12 +141,12 @@ iso_get_ssector(dev, p) return ntohl(t.entry.addr.lba); } -static int iso_mountroot __P((struct mount *mp, struct proc *p)); +static int iso_mountroot __P((struct mount *mp, struct thread *td)); static int -iso_mountroot(mp, p) +iso_mountroot(mp, td) struct mount *mp; - struct proc *p; + struct thread *td; { struct iso_args args; int error; @@ -156,14 +156,14 @@ iso_mountroot(mp, p) return (error); } args.flags = ISOFSMNT_ROOT; - args.ssector = iso_get_ssector(rootdev, p); + args.ssector = iso_get_ssector(rootdev, td); if (bootverbose) printf("iso_mountroot(): using session at block %d\n", args.ssector); - if ((error = iso_mountfs(rootvp, mp, p, &args)) != 0) + if ((error = iso_mountfs(rootvp, mp, td, &args)) != 0) return (error); - (void)cd9660_statfs(mp, &mp->mnt_stat, p); + (void)cd9660_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -173,12 +173,12 @@ iso_mountroot(mp, p) * mount system call */ static int -cd9660_mount(mp, path, data, ndp, p) +cd9660_mount(mp, path, data, ndp, td) register struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *devvp; struct iso_args args; @@ -188,7 +188,7 @@ cd9660_mount(mp, path, data, ndp, p) struct iso_mnt *imp = 0; if ((mp->mnt_flag & MNT_ROOTFS) != 0) { - return (iso_mountroot(mp, p)); + return (iso_mountroot(mp, td)); } if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args)))) return (error); @@ -209,7 +209,7 @@ cd9660_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); if ((error = namei(ndp))) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -225,18 +225,18 @@ cd9660_mount(mp, path, data, ndp, p) * or has superuser abilities */ accessmode = VREAD; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td); if (error) - error = suser(p); + error = suser_td(td); if (error) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = iso_mountfs(devvp, mp, p, &args); + error = iso_mountfs(devvp, mp, td, &args); } else { if (devvp != imp->im_devvp) error = EINVAL; /* needs translation */ @@ -251,7 +251,7 @@ cd9660_mount(mp, path, data, ndp, p) (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) cd9660_statfs(mp, &mp->mnt_stat, p); + (void) cd9660_statfs(mp, &mp->mnt_stat, td); return 0; } @@ -259,10 +259,10 @@ cd9660_mount(mp, path, data, ndp, p) * Common code for mount and mountroot */ static int -iso_mountfs(devvp, mp, p, argp) +iso_mountfs(devvp, mp, td, argp) register struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; struct iso_args *argp; { register struct iso_mnt *isomp = (struct iso_mnt *)0; @@ -295,12 +295,12 @@ iso_mountfs(devvp, mp, p, argp) return error; if (vcount(devvp) > 1 && devvp != rootvp) return EBUSY; - if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))) + if ((error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0))) return (error); - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, FREAD, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, FREAD, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return error; @@ -510,7 +510,7 @@ out: if (supbp) brelse(supbp); if (needclose) - (void)VOP_CLOSE(devvp, FREAD, NOCRED, p); + (void)VOP_CLOSE(devvp, FREAD, NOCRED, td); if (isomp) { free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; @@ -522,10 +522,10 @@ out: * unmount system call */ static int -cd9660_unmount(mp, mntflags, p) +cd9660_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct iso_mnt *isomp; int error, flags = 0; @@ -543,7 +543,7 @@ cd9660_unmount(mp, mntflags, p) isomp = VFSTOISOFS(mp); isomp->im_devvp->v_rdev->si_mountpoint = NULL; - error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p); + error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, td); vrele(isomp->im_devvp); free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; @@ -576,10 +576,10 @@ cd9660_root(mp, vpp) * Get file system statistics. */ int -cd9660_statfs(mp, sbp, p) +cd9660_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { register struct iso_mnt *isomp; diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 702823e..a902b58 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -87,7 +87,7 @@ cd9660_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -128,7 +128,7 @@ cd9660_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -162,7 +162,7 @@ cd9660_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -197,7 +197,7 @@ cd9660_getattr(ap) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = ap->a_p; + auio.uio_td = ap->a_td; auio.uio_resid = MAXPATHLEN; rdlnk.a_uio = &auio; rdlnk.a_vp = ap->a_vp; @@ -226,7 +226,7 @@ cd9660_ioctl(ap) caddr_t a_data; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index 9aa8b3d..3ec8f5f 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -26,7 +26,7 @@ * $FreeBSD$ */ -#include "opt_upages.h" +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/exec.h> @@ -250,29 +250,33 @@ exec_aout_imgact(imgp) * expand_name(), unless the process was setuid/setgid. */ int -aout_coredump(p, vp, limit) - register struct proc *p; +aout_coredump(td, vp, limit) + register struct thread *td; register struct vnode *vp; off_t limit; { + struct proc *p = td->td_proc; register struct ucred *cred = p->p_ucred; register struct vmspace *vm = p->p_vmspace; int error; - if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= limit) + if (ctob((UAREA_PAGES + KSTACK_PAGES) + + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); - fill_kinfo_proc(p, &p->p_addr->u_kproc); - error = cpu_coredump(p, vp, cred); + fill_kinfo_proc(p, &p->p_uarea->u_kproc); + error = cpu_coredump(td, vp, cred); if (error == 0) - error = vn_rdwr_inchunks(UIO_WRITE, vp, vm->vm_daddr, - (int)ctob(vm->vm_dsize), (off_t)ctob(UPAGES), UIO_USERSPACE, - IO_UNIT, cred, (int *) NULL, p); + error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr, + (int)ctob(vm->vm_dsize), + (off_t)ctob(UAREA_PAGES + KSTACK_PAGES), UIO_USERSPACE, + IO_UNIT, cred, (int *) NULL, td); if (error == 0) error = vn_rdwr_inchunks(UIO_WRITE, vp, (caddr_t) trunc_page(USRSTACK - ctob(vm->vm_ssize)), round_page(ctob(vm->vm_ssize)), - (off_t)ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE, - IO_UNIT, cred, (int *) NULL, p); + (off_t)ctob(UAREA_PAGES + KSTACK_PAGES) + + ctob(vm->vm_dsize), UIO_USERSPACE, + IO_UNIT, cred, (int *) NULL, td); return (error); } diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 63999d1..66a3a34 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -342,6 +342,9 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) u_long base_addr = 0; int error, i, numsegs; + if (curthread->td_proc != p) + panic("elf_load_file - thread"); /* XXXKSE DIAGNOSTIC */ + tempdata = malloc(sizeof(*tempdata), M_TEMP, M_WAITOK); nd = &tempdata->nd; attr = &tempdata->attr; @@ -362,7 +365,8 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) goto fail; } - NDINIT(nd, LOOKUP, LOCKLEAF|FOLLOW, UIO_SYSSPACE, file, p); + /* XXXKSE */ + NDINIT(nd, LOOKUP, LOCKLEAF|FOLLOW, UIO_SYSSPACE, file, curthread); if ((error = namei(nd)) != 0) { nd->ni_vp = NULL; @@ -376,7 +380,7 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) */ error = exec_check_permissions(imgp); if (error) { - VOP_UNLOCK(nd->ni_vp, 0, p); + VOP_UNLOCK(nd->ni_vp, 0, curthread); /* XXXKSE */ goto fail; } @@ -387,7 +391,7 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) */ if (error == 0) nd->ni_vp->v_flag |= VTEXT; - VOP_UNLOCK(nd->ni_vp, 0, p); + VOP_UNLOCK(nd->ni_vp, 0, curthread); /* XXXKSE */ if (error) goto fail; @@ -736,7 +740,7 @@ static void cb_put_phdr __P((vm_map_entry_t, void *)); static void cb_size_segment __P((vm_map_entry_t, void *)); static void each_writable_segment __P((struct proc *, segment_callback, void *)); -static int elf_corehdr __P((struct proc *, struct vnode *, struct ucred *, +static int elf_corehdr __P((struct thread *, struct vnode *, struct ucred *, int, void *, size_t)); static void elf_puthdr __P((struct proc *, void *, size_t *, const prstatus_t *, const prfpregset_t *, const prpsinfo_t *, int)); @@ -746,11 +750,12 @@ static void elf_putnote __P((void *, size_t *, const char *, int, extern int osreldate; int -elf_coredump(p, vp, limit) - register struct proc *p; +elf_coredump(td, vp, limit) + struct thread *td; register struct vnode *vp; off_t limit; { + register struct proc *p = td->td_proc; register struct ucred *cred = p->p_ucred; int error = 0; struct sseg_closure seginfo; @@ -783,7 +788,7 @@ elf_coredump(p, vp, limit) if (hdr == NULL) { return EINVAL; } - error = elf_corehdr(p, vp, cred, seginfo.count, hdr, hdrsize); + error = elf_corehdr(td, vp, cred, seginfo.count, hdr, hdrsize); /* Write the contents of all of the writable segments. */ if (error == 0) { @@ -797,7 +802,7 @@ elf_coredump(p, vp, limit) error = vn_rdwr_inchunks(UIO_WRITE, vp, (caddr_t)php->p_vaddr, php->p_filesz, offset, UIO_USERSPACE, - IO_UNIT, cred, (int *)NULL, p); + IO_UNIT, cred, (int *)NULL, curthread); /* XXXKSE */ if (error != 0) break; offset += php->p_filesz; @@ -909,8 +914,8 @@ each_writable_segment(p, func, closure) * the page boundary. */ static int -elf_corehdr(p, vp, cred, numsegs, hdr, hdrsize) - struct proc *p; +elf_corehdr(td, vp, cred, numsegs, hdr, hdrsize) + struct thread *td; struct vnode *vp; struct ucred *cred; int numsegs; @@ -922,6 +927,7 @@ elf_corehdr(p, vp, cred, numsegs, hdr, hdrsize) prfpregset_t fpregset; prpsinfo_t psinfo; } *tempdata; + struct proc *p = td->td_proc; size_t off; prstatus_t *status; prfpregset_t *fpregset; @@ -940,9 +946,9 @@ elf_corehdr(p, vp, cred, numsegs, hdr, hdrsize) status->pr_osreldate = osreldate; status->pr_cursig = p->p_sig; status->pr_pid = p->p_pid; - fill_regs(p, &status->pr_reg); + fill_regs(td, &status->pr_reg); - fill_fpregs(p, fpregset); + fill_fpregs(td, fpregset); psinfo->pr_version = PRPSINFO_VERSION; psinfo->pr_psinfosz = sizeof(prpsinfo_t); @@ -960,7 +966,7 @@ elf_corehdr(p, vp, cred, numsegs, hdr, hdrsize) /* Write it to the core file. */ return vn_rdwr_inchunks(UIO_WRITE, vp, hdr, hdrsize, (off_t)0, - UIO_SYSSPACE, IO_UNIT, cred, NULL, p); + UIO_SYSSPACE, IO_UNIT, cred, NULL, td); /* XXXKSE */ } static void diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 3859c5b..62d1655 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -83,6 +83,7 @@ void mi_startup(void); /* Should be elsewhere */ static struct session session0; static struct pgrp pgrp0; struct proc proc0; +struct thread *thread0; static struct procsig procsig0; static struct filedesc0 filedesc0; static struct plimit limit0; @@ -90,7 +91,6 @@ static struct vmspace vmspace0; struct proc *initproc; int cmask = CMASK; -extern struct user *proc0paddr; extern int fallback_elf_brand; struct vnode *rootvp; @@ -273,10 +273,17 @@ proc0_init(void *dummy __unused) register struct proc *p; register struct filedesc0 *fdp; register unsigned i; + struct thread *td; GIANT_REQUIRED; - + /* + * This assumes the proc0 struct has already been linked + * using proc_linkup() in the machine specific initialisation + * e.g. i386_init() + */ p = &proc0; + td = thread0; + mtx_init(&p->p_mtx, "process lock", MTX_DEF); /* * Initialize magic number. @@ -321,11 +328,11 @@ proc0_init(void *dummy __unused) p->p_flag = P_SYSTEM; p->p_sflag = PS_INMEM; p->p_stat = SRUN; - p->p_nice = NZERO; - p->p_pri.pri_class = PRI_TIMESHARE; - p->p_pri.pri_level = PVM; - p->p_pri.pri_native = PUSER; - p->p_pri.pri_user = PUSER; + p->p_ksegrp.kg_nice = NZERO; + p->p_ksegrp.kg_pri.pri_class = PRI_TIMESHARE; + p->p_ksegrp.kg_pri.pri_level = PVM; + p->p_ksegrp.kg_pri.pri_native = PUSER; + p->p_ksegrp.kg_pri.pri_user = PUSER; p->p_peers = 0; p->p_leader = p; @@ -333,7 +340,7 @@ proc0_init(void *dummy __unused) bcopy("swapper", p->p_comm, sizeof ("swapper")); callout_init(&p->p_itcallout, 0); - callout_init(&p->p_slpcallout, 1); + callout_init(&td->td_slpcallout, 1); /* Create credentials. */ p->p_ucred = crget(); @@ -381,14 +388,13 @@ proc0_init(void *dummy __unused) vm_map_init(&vmspace0.vm_map, round_page(VM_MIN_ADDRESS), trunc_page(VM_MAXUSER_ADDRESS)); vmspace0.vm_map.pmap = vmspace_pmap(&vmspace0); - p->p_addr = proc0paddr; /* XXX */ /* * We continue to place resource usage info and signal * actions in the user struct so they're pageable. */ - p->p_stats = &p->p_addr->u_stats; - p->p_sigacts = &p->p_addr->u_sigacts; + p->p_stats = &p->p_uarea->u_stats; + p->p_sigacts = &p->p_uarea->u_sigacts; /* * Charge root for one process. @@ -467,13 +473,15 @@ start_init(void *dummy) int options, error; char *var, *path, *next, *s; char *ucp, **uap, *arg0, *arg1; + struct thread *td; struct proc *p; mtx_lock(&Giant); GIANT_REQUIRED; - p = curproc; + td = curthread; + p = td->td_proc; /* Get the vnode for '/'. Set p->p_fd->fd_cdir to reference it. */ if (VFS_ROOT(TAILQ_FIRST(&mountlist), &rootvnode)) @@ -482,7 +490,7 @@ start_init(void *dummy) VREF(p->p_fd->fd_cdir); p->p_fd->fd_rdir = rootvnode; VREF(p->p_fd->fd_rdir); - VOP_UNLOCK(rootvnode, 0, p); + VOP_UNLOCK(rootvnode, 0, td); /* * Need just enough stack to hold the faked-up "execve()" arguments. @@ -573,7 +581,7 @@ start_init(void *dummy) * Otherwise, return via fork_trampoline() all the way * to user mode as init! */ - if ((error = execve(p, &args)) == 0) { + if ((error = execve(td, &args)) == 0) { mtx_unlock(&Giant); return; } @@ -597,7 +605,7 @@ create_init(const void *udata __unused) { int error; - error = fork1(&proc0, RFFDG | RFPROC | RFSTOPPED, &initproc); + error = fork1(thread0, RFFDG | RFPROC | RFSTOPPED, &initproc); if (error) panic("cannot fork init: %d\n", error); PROC_LOCK(initproc); @@ -606,7 +614,7 @@ create_init(const void *udata __unused) mtx_lock_spin(&sched_lock); initproc->p_sflag |= PS_INMEM; mtx_unlock_spin(&sched_lock); - cpu_set_fork_handler(initproc, start_init, NULL); + cpu_set_fork_handler(&initproc->p_thread, start_init, NULL); } SYSINIT(init, SI_SUB_CREATE_INIT, SI_ORDER_FIRST, create_init, NULL) @@ -619,7 +627,7 @@ kick_init(const void *udata __unused) mtx_lock_spin(&sched_lock); initproc->p_stat = SRUN; - setrunqueue(initproc); + setrunqueue(&initproc->p_thread); /* XXXKSE */ mtx_unlock_spin(&sched_lock); } SYSINIT(kickinit, SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kick_init, NULL) diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 9a2ebab..8c319f7 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -110,20 +110,20 @@ SYSCTL_INT(_kern, OID_AUTO, acct_chkfreq, CTLFLAG_RW, * MPSAFE */ int -acct(a1, uap) - struct proc *a1; +acct(td, uap) + struct thread *td; struct acct_args /* { syscallarg(char *) path; } */ *uap; { - struct proc *p = curproc; /* XXX */ struct nameidata nd; int error, flags; mtx_lock(&Giant); - + if (td != curthread) + panic("acct"); /* XXXKSE DIAGNOSTIC */ /* Make sure that the caller is root. */ - error = suser(p); + error = suser(td->td_proc); if (error) goto done2; @@ -133,15 +133,15 @@ acct(a1, uap) */ if (SCARG(uap, path) != NULL) { NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), - p); + td); flags = FWRITE; error = vn_open(&nd, &flags, 0); if (error) goto done2; NDFREE(&nd, NDF_ONLY_PNBUF); - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); if (nd.ni_vp->v_type != VREG) { - vn_close(nd.ni_vp, FWRITE, p->p_ucred, p); + vn_close(nd.ni_vp, FWRITE, td->td_proc->p_ucred, td); error = EACCES; goto done2; } @@ -154,7 +154,7 @@ acct(a1, uap) if (acctp != NULLVP || savacctp != NULLVP) { callout_stop(&acctwatch_callout); error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE, - p->p_ucred, p); + td->td_proc->p_ucred, td); acctp = savacctp = NULLVP; } if (SCARG(uap, path) == NULL) @@ -180,9 +180,10 @@ done2: */ int -acct_process(p) - struct proc *p; +acct_process(td) + struct thread *td; { + struct proc *p = td->td_proc; struct acct acct; struct rusage *r; struct timeval ut, st, tmp; @@ -253,10 +254,10 @@ acct_process(p) /* * Write the accounting information to the file. */ - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); return (vn_rdwr(UIO_WRITE, vp, (caddr_t)&acct, sizeof (acct), - (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, p->p_ucred, - (int *)0, p)); + (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, td->td_proc->p_ucred, + (int *)0, td)); } /* @@ -317,7 +318,7 @@ acctwatch(a) savacctp = NULLVP; return; } - (void)VFS_STATFS(savacctp->v_mount, &sb, (struct proc *)0); + (void)VFS_STATFS(savacctp->v_mount, &sb, (struct thread *)0); if (sb.f_bavail > acctresume * sb.f_blocks / 100) { acctp = savacctp; savacctp = NULLVP; @@ -331,7 +332,7 @@ acctwatch(a) acctp = NULLVP; return; } - (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0); + (void)VFS_STATFS(acctp->v_mount, &sb, (struct thread *)0); if (sb.f_bavail <= acctsuspend * sb.f_blocks / 100) { savacctp = acctp; acctp = NULLVP; diff --git a/sys/kern/kern_acl.c b/sys/kern/kern_acl.c index 69dbe85..045d1a8 100644 --- a/sys/kern/kern_acl.c +++ b/sys/kern/kern_acl.c @@ -48,11 +48,11 @@ MALLOC_DEFINE(M_ACL, "acl", "access control list"); -static int vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_aclcheck(struct proc *p, struct vnode *vp, +static int vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); /* @@ -562,7 +562,7 @@ acl_posix1e_check(struct acl *acl) * Given a vnode, set its ACL. */ static int -vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; @@ -571,10 +571,10 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, type, &inkernacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return(error); } @@ -582,16 +582,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, get its ACL. */ static int -vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_GETACL(vp, type, &inkernelacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -601,14 +601,14 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, delete its ACL. */ static int -vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) +vacl_delete( struct thread *td, struct vnode *vp, acl_type_t type) { int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -616,7 +616,7 @@ vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) * Given a vnode, check whether an ACL is appropriate for it */ static int -vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; @@ -625,7 +625,7 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); + error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_proc->p_ucred, td); return (error); } @@ -641,17 +641,17 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, * MPSAFE */ int -__acl_get_file(struct proc *p, struct __acl_get_file_args *uap) +__acl_get_file( struct thread *td, struct __acl_get_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); /* what flags are required here -- possible not LOCKLEAF? */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_get_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_get_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -665,16 +665,16 @@ __acl_get_file(struct proc *p, struct __acl_get_file_args *uap) * MPSAFE */ int -__acl_set_file(struct proc *p, struct __acl_set_file_args *uap) +__acl_set_file( struct thread *td, struct __acl_set_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_set_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_set_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -688,15 +688,15 @@ __acl_set_file(struct proc *p, struct __acl_set_file_args *uap) * MPSAFE */ int -__acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) +__acl_get_fd( struct thread *td, struct __acl_get_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_get_acl(p, (struct vnode *)fp->f_data, + error = vacl_get_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -709,15 +709,15 @@ __acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) * MPSAFE */ int -__acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) +__acl_set_fd( struct thread *td, struct __acl_set_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_set_acl(p, (struct vnode *)fp->f_data, + error = vacl_set_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -730,16 +730,16 @@ __acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) * MPSAFE */ int -__acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) +__acl_delete_file( struct thread *td, struct __acl_delete_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_delete(p, nd.ni_vp, SCARG(uap, type)); + error = vacl_delete(td, nd.ni_vp, SCARG(uap, type)); NDFREE(&nd, 0); } mtx_unlock(&Giant); @@ -752,15 +752,15 @@ __acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) * MPSAFE */ int -__acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) +__acl_delete_fd( struct thread *td, struct __acl_delete_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_delete(p, (struct vnode *)fp->f_data, + error = vacl_delete(td, (struct vnode *)fp->f_data, SCARG(uap, type)); } mtx_unlock(&Giant); @@ -773,16 +773,16 @@ __acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) * MPSAFE */ int -__acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) +__acl_aclcheck_file( struct thread *td, struct __acl_aclcheck_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_aclcheck(p, nd.ni_vp, SCARG(uap, type), + error = vacl_aclcheck(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -796,15 +796,15 @@ __acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) * MPSAFE */ int -__acl_aclcheck_fd(struct proc *p, struct __acl_aclcheck_fd_args *uap) +__acl_aclcheck_fd( struct thread *td, struct __acl_aclcheck_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_aclcheck(p, (struct vnode *)fp->f_data, + error = vacl_aclcheck(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); diff --git a/sys/kern/kern_cap.c b/sys/kern/kern_cap.c index b8f0c42..45a2509 100644 --- a/sys/kern/kern_cap.c +++ b/sys/kern/kern_cap.c @@ -54,7 +54,7 @@ * Syscall to allow a process to get it's currently capability set */ int -__cap_get_proc(struct proc *p, struct __cap_get_proc_args *uap) +__cap_get_proc(struct thread *td, struct __cap_get_proc_args *uap) { return (ENOSYS); @@ -65,7 +65,7 @@ __cap_get_proc(struct proc *p, struct __cap_get_proc_args *uap) * permitted. */ int -__cap_set_proc(struct proc *p, struct __cap_set_proc_args *uap) +__cap_set_proc(struct thread *td, struct __cap_set_proc_args *uap) { return (ENOSYS); @@ -76,14 +76,14 @@ __cap_set_proc(struct proc *p, struct __cap_set_proc_args *uap) * files, if permitted. */ int -__cap_get_fd(struct proc *p, struct __cap_get_fd_args *uap) +__cap_get_fd(struct thread *td, struct __cap_get_fd_args *uap) { return (ENOSYS); } int -__cap_get_file(struct proc *p, struct __cap_get_file_args *uap) +__cap_get_file(struct thread *td, struct __cap_get_file_args *uap) { return (ENOSYS); @@ -94,14 +94,14 @@ __cap_get_file(struct proc *p, struct __cap_get_file_args *uap) * if permitted. */ int -__cap_set_fd(struct proc *p, struct __cap_set_fd_args *uap) +__cap_set_fd(struct thread *td, struct __cap_set_fd_args *uap) { return (ENOSYS); } int -__cap_set_file(struct proc *p, struct __cap_set_file_args *uap) +__cap_set_file(struct thread *td, struct __cap_set_file_args *uap) { return (ENOSYS); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index f48b212..9ac63ad 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -150,7 +150,7 @@ initclocks(dummy) /* * Each time the real-time timer fires, this function is called on all CPUs - * with each CPU passing in its curproc as the first argument. If possible + * with each CPU passing in its curthread as the first argument. If possible * a nice optimization in the future would be to allow the CPU receiving the * actual real-time timer interrupt to call this function on behalf of the * other CPUs rather than sending an IPI to all other CPUs so that they @@ -159,24 +159,33 @@ initclocks(dummy) * system need to call this function (or have it called on their behalf. */ void -hardclock_process(p, user) - struct proc *p; +hardclock_process(td, user) + struct thread *td; int user; { struct pstats *pstats; + struct proc *p = td->td_proc; /* * Run current process's virtual and profile time, as needed. */ mtx_assert(&sched_lock, MA_OWNED); - pstats = p->p_stats; - if (user && - timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) && - itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) - p->p_sflag |= PS_ALRMPEND | PS_ASTPENDING; - if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) && - itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) - p->p_sflag |= PS_PROFPEND | PS_ASTPENDING; + if (p->p_flag & P_KSES) { + /* XXXKSE What to do? */ + } else { + pstats = p->p_stats; + if (user && + timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) && + itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) { + p->p_sflag |= PS_ALRMPEND; + td->td_kse->ke_flags |= KEF_ASTPENDING; + } + if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) && + itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) { + p->p_sflag |= PS_PROFPEND; + td->td_kse->ke_flags |= KEF_ASTPENDING; + } + } } /* @@ -190,7 +199,7 @@ hardclock(frame) CTR0(KTR_INTR, "hardclock fired"); mtx_lock_spin(&sched_lock); - hardclock_process(curproc, CLKF_USERMODE(frame)); + hardclock_process(curthread, CLKF_USERMODE(frame)); mtx_unlock_spin(&sched_lock); /* @@ -337,14 +346,14 @@ stopprofclock(p) /* * Do process and kernel statistics. Most of the statistics are only * used by user-level statistics programs. The main exceptions are - * p->p_uticks, p->p_sticks, p->p_iticks, and p->p_estcpu. This function + * ke->ke_uticks, p->p_sticks, p->p_iticks, and p->p_estcpu. This function * should be called by all CPUs in the system for each statistics clock * interrupt. See the description of hardclock_process for more detail on * this function's relationship to statclock. */ void -statclock_process(p, pc, user) - struct proc *p; +statclock_process(ke, pc, user) + struct kse *ke; register_t pc; int user; { @@ -356,8 +365,10 @@ statclock_process(p, pc, user) long rss; struct rusage *ru; struct vmspace *vm; + struct proc *p = ke->ke_proc; + struct thread *td = ke->ke_thread; /* current thread */ - KASSERT(p == curproc, ("statclock_process: p != curproc")); + KASSERT(ke == curthread->td_kse, ("statclock_process: td != curthread")); mtx_assert(&sched_lock, MA_OWNED); if (user) { /* @@ -365,14 +376,14 @@ statclock_process(p, pc, user) * If this process is being profiled, record the tick. */ if (p->p_sflag & PS_PROFIL) - addupc_intr(p, pc, 1); + addupc_intr(ke, pc, 1); if (pscnt < psdiv) return; /* * Charge the time as appropriate. */ - p->p_uticks++; - if (p->p_nice > NZERO) + ke->ke_uticks++; + if (ke->ke_ksegrp->kg_nice > NZERO) cp_time[CP_NICE]++; else cp_time[CP_USER]++; @@ -404,19 +415,19 @@ statclock_process(p, pc, user) * so that we know how much of its real time was spent * in ``non-process'' (i.e., interrupt) work. */ - if ((p->p_ithd != NULL) || p->p_intr_nesting_level >= 2) { - p->p_iticks++; + if ((td->td_ithd != NULL) || td->td_intr_nesting_level >= 2) { + ke->ke_iticks++; cp_time[CP_INTR]++; } else { - p->p_sticks++; - if (p != PCPU_GET(idleproc)) + ke->ke_sticks++; + if (p != PCPU_GET(idlethread)->td_proc) cp_time[CP_SYS]++; else cp_time[CP_IDLE]++; } } - schedclock(p); + schedclock(ke->ke_thread); /* Update resource usage integrals and maximums. */ if ((pstats = p->p_stats) != NULL && @@ -435,7 +446,7 @@ statclock_process(p, pc, user) * Statistics clock. Grab profile sample, and if divider reaches 0, * do process and kernel statistics. Most of the statistics are only * used by user-level statistics programs. The main exceptions are - * p->p_uticks, p->p_sticks, p->p_iticks, and p->p_estcpu. + * ke->ke_uticks, p->p_sticks, p->p_iticks, and p->p_estcpu. */ void statclock(frame) @@ -446,7 +457,7 @@ statclock(frame) mtx_lock_spin(&sched_lock); if (--pscnt == 0) pscnt = psdiv; - statclock_process(curproc, CLKF_PC(frame), CLKF_USERMODE(frame)); + statclock_process(curthread->td_kse, CLKF_PC(frame), CLKF_USERMODE(frame)); mtx_unlock_spin(&sched_lock); } diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index 4e26f2e..7a8b376 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -46,9 +46,9 @@ /* * Common sanity checks for cv_wait* functions. */ -#define CV_ASSERT(cvp, mp, p) do { \ - KASSERT((p) != NULL, ("%s: curproc NULL", __FUNCTION__)); \ - KASSERT((p)->p_stat == SRUN, ("%s: not SRUN", __FUNCTION__)); \ +#define CV_ASSERT(cvp, mp, td) do { \ + KASSERT((td) != NULL, ("%s: curthread NULL", __FUNCTION__)); \ + KASSERT((td)->td_proc->p_stat == SRUN, ("%s: not SRUN", __FUNCTION__)); \ KASSERT((cvp) != NULL, ("%s: cvp NULL", __FUNCTION__)); \ KASSERT((mp) != NULL, ("%s: mp NULL", __FUNCTION__)); \ mtx_assert((mp), MA_OWNED | MA_NOTRECURSED); \ @@ -112,21 +112,23 @@ cv_destroy(struct cv *cvp) * Switch context. */ static __inline void -cv_switch(struct proc *p) +cv_switch(struct thread *td) { - p->p_stat = SSLEEP; - p->p_stats->p_ru.ru_nvcsw++; + td->td_proc->p_stat = SSLEEP; + td->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); - CTR3(KTR_PROC, "cv_switch: resume proc %p (pid %d, %s)", p, p->p_pid, - p->p_comm); + CTR3(KTR_PROC, "cv_switch: resume thread %p (pid %d, %s)", + td, + td->td_proc->p_pid, + td->td_proc->p_comm); } /* * Switch context, catching signals. */ static __inline int -cv_switch_catch(struct proc *p) +cv_switch_catch(struct thread *td) { int sig; @@ -136,69 +138,71 @@ cv_switch_catch(struct proc *p) * both) could occur while we were stopped. A SIGCONT would cause us to * be marked as SSLEEP without resuming us, thus we must be ready for * sleep when CURSIG is called. If the wakeup happens while we're - * stopped, p->p_wchan will be 0 upon return from CURSIG. + * stopped, td->td_wchan will be 0 upon return from CURSIG. */ - p->p_sflag |= PS_SINTR; + td->td_flags |= TDF_SINTR; mtx_unlock_spin(&sched_lock); - PROC_LOCK(p); - sig = CURSIG(p); + PROC_LOCK(td->td_proc); + sig = CURSIG(td->td_proc); /* XXXKSE */ mtx_lock_spin(&sched_lock); - PROC_UNLOCK_NOSWITCH(p); + PROC_UNLOCK_NOSWITCH(td->td_proc); if (sig != 0) { - if (p->p_wchan != NULL) - cv_waitq_remove(p); - p->p_stat = SRUN; - } else if (p->p_wchan != NULL) { - cv_switch(p); + if (td->td_wchan != NULL) + cv_waitq_remove(td); + td->td_proc->p_stat = SRUN; + } else if (td->td_wchan != NULL) { + cv_switch(td); } - p->p_sflag &= ~PS_SINTR; + td->td_flags &= ~TDF_SINTR; return sig; } /* - * Add a process to the wait queue of a condition variable. + * Add a thread to the wait queue of a condition variable. */ static __inline void -cv_waitq_add(struct cv *cvp, struct proc *p) +cv_waitq_add(struct cv *cvp, struct thread *td) { /* * Process may be sitting on a slpque if asleep() was called, remove it * before re-adding. */ - if (p->p_wchan != NULL) - unsleep(p); - - p->p_sflag |= PS_CVWAITQ; - p->p_wchan = cvp; - p->p_wmesg = cvp->cv_description; - p->p_slptime = 0; - p->p_pri.pri_native = p->p_pri.pri_level; - CTR3(KTR_PROC, "cv_waitq_add: proc %p (pid %d, %s)", p, p->p_pid, - p->p_comm); - TAILQ_INSERT_TAIL(&cvp->cv_waitq, p, p_slpq); + if (td->td_wchan != NULL) + unsleep(td); + + td->td_flags |= TDF_CVWAITQ; + td->td_wchan = cvp; + td->td_wmesg = cvp->cv_description; + td->td_kse->ke_slptime = 0; /* XXXKSE */ + td->td_ksegrp->kg_slptime = 0; /* XXXKSE */ + td->td_ksegrp->kg_pri.pri_native = td->td_ksegrp->kg_pri.pri_level; + CTR3(KTR_PROC, "cv_waitq_add: thread %p (pid %d, %s)", td, + td->td_proc->p_pid, + td->td_proc->p_comm); + TAILQ_INSERT_TAIL(&cvp->cv_waitq, td, td_slpq); } /* - * Wait on a condition variable. The current process is placed on the condition + * Wait on a condition variable. The current thread is placed on the condition * variable's wait queue and suspended. A cv_signal or cv_broadcast on the same - * condition variable will resume the process. The mutex is released before + * condition variable will resume the thread. The mutex is released before * sleeping and will be held on return. It is recommended that the mutex be * held when cv_signal or cv_broadcast are called. */ void cv_wait(struct cv *cvp, struct mtx *mp) { - struct proc *p; + struct thread *td; WITNESS_SAVE_DECL(mp); - p = CURPROC; + td = curthread; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 1, 0); + if (td->td_proc && KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 1, 0); #endif - CV_ASSERT(cvp, mp, p); + CV_ASSERT(cvp, mp, td); WITNESS_SLEEP(0, &mp->mtx_object); WITNESS_SAVE(&mp->mtx_object, mp); @@ -207,7 +211,7 @@ cv_wait(struct cv *cvp, struct mtx *mp) /* * After a panic, or during autoconfiguration, just give * interrupts a chance, then just return; don't run any other - * procs or panic below, in case this is the idle process and + * thread or panic below, in case this is the idle process and * already asleep. */ mtx_unlock_spin(&sched_lock); @@ -218,13 +222,13 @@ cv_wait(struct cv *cvp, struct mtx *mp) DROP_GIANT_NOSWITCH(); mtx_unlock_flags(mp, MTX_NOSWITCH); - cv_waitq_add(cvp, p); - cv_switch(p); + cv_waitq_add(cvp, td); + cv_switch(td); mtx_unlock_spin(&sched_lock); #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 0, 0); + if (KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 0, 0); #endif PICKUP_GIANT(); mtx_lock(mp); @@ -233,25 +237,25 @@ cv_wait(struct cv *cvp, struct mtx *mp) /* * Wait on a condition variable, allowing interruption by signals. Return 0 if - * the process was resumed with cv_signal or cv_broadcast, EINTR or ERESTART if + * the thread was resumed with cv_signal or cv_broadcast, EINTR or ERESTART if * a signal was caught. If ERESTART is returned the system call should be * restarted if possible. */ int cv_wait_sig(struct cv *cvp, struct mtx *mp) { - struct proc *p; + struct thread *td; int rval; int sig; WITNESS_SAVE_DECL(mp); - p = CURPROC; + td = curthread; rval = 0; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 1, 0); + if (td->td_proc && KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 1, 0); #endif - CV_ASSERT(cvp, mp, p); + CV_ASSERT(cvp, mp, td); WITNESS_SLEEP(0, &mp->mtx_object); WITNESS_SAVE(&mp->mtx_object, mp); @@ -271,27 +275,27 @@ cv_wait_sig(struct cv *cvp, struct mtx *mp) DROP_GIANT_NOSWITCH(); mtx_unlock_flags(mp, MTX_NOSWITCH); - cv_waitq_add(cvp, p); - sig = cv_switch_catch(p); + cv_waitq_add(cvp, td); + sig = cv_switch_catch(td); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); - PROC_LOCK(p); + PROC_LOCK(td->td_proc); if (sig == 0) - sig = CURSIG(p); + sig = CURSIG(td->td_proc); /* XXXKSE */ if (sig != 0) { - if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) + if (SIGISMEMBER(td->td_proc->p_sigacts->ps_sigintr, sig)) rval = EINTR; else rval = ERESTART; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); #ifdef KTRACE mtx_lock(&Giant); - if (KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 0, 0); + if (KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 0, 0); mtx_unlock(&Giant); #endif mtx_lock(mp); @@ -308,17 +312,16 @@ cv_wait_sig(struct cv *cvp, struct mtx *mp) int cv_timedwait(struct cv *cvp, struct mtx *mp, int timo) { - struct proc *p; + struct thread *td; int rval; WITNESS_SAVE_DECL(mp); - p = CURPROC; + td = curthread; rval = 0; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 1, 0); + ktrcsw(td->td_proc->p_tracep, 1, 0); #endif - CV_ASSERT(cvp, mp, p); + CV_ASSERT(cvp, mp, td); WITNESS_SLEEP(0, &mp->mtx_object); WITNESS_SAVE(&mp->mtx_object, mp); @@ -327,7 +330,7 @@ cv_timedwait(struct cv *cvp, struct mtx *mp, int timo) /* * After a panic, or during autoconfiguration, just give * interrupts a chance, then just return; don't run any other - * procs or panic below, in case this is the idle process and + * thread or panic below, in case this is the idle process and * already asleep. */ mtx_unlock_spin(&sched_lock); @@ -338,29 +341,29 @@ cv_timedwait(struct cv *cvp, struct mtx *mp, int timo) DROP_GIANT_NOSWITCH(); mtx_unlock_flags(mp, MTX_NOSWITCH); - cv_waitq_add(cvp, p); - callout_reset(&p->p_slpcallout, timo, cv_timedwait_end, p); - cv_switch(p); + cv_waitq_add(cvp, td); + callout_reset(&td->td_slpcallout, timo, cv_timedwait_end, td); + cv_switch(td); - if (p->p_sflag & PS_TIMEOUT) { - p->p_sflag &= ~PS_TIMEOUT; + if (td->td_flags & TDF_TIMEOUT) { + td->td_flags &= ~TDF_TIMEOUT; rval = EWOULDBLOCK; - } else if (p->p_sflag & PS_TIMOFAIL) - p->p_sflag &= ~PS_TIMOFAIL; - else if (callout_stop(&p->p_slpcallout) == 0) { + } else if (td->td_flags & TDF_TIMOFAIL) + td->td_flags &= ~TDF_TIMOFAIL; + else if (callout_stop(&td->td_slpcallout) == 0) { /* * Work around race with cv_timedwait_end similar to that * between msleep and endtsleep. */ - p->p_sflag |= PS_TIMEOUT; - p->p_stats->p_ru.ru_nivcsw++; + td->td_flags |= TDF_TIMEOUT; + td->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); } mtx_unlock_spin(&sched_lock); #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 0, 0); + if (KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 0, 0); #endif PICKUP_GIANT(); mtx_lock(mp); @@ -371,25 +374,25 @@ cv_timedwait(struct cv *cvp, struct mtx *mp, int timo) /* * Wait on a condition variable for at most timo/hz seconds, allowing - * interruption by signals. Returns 0 if the process was resumed by cv_signal + * interruption by signals. Returns 0 if the thread was resumed by cv_signal * or cv_broadcast, EWOULDBLOCK if the timeout expires, and EINTR or ERESTART if * a signal was caught. */ int cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo) { - struct proc *p; + struct thread *td; int rval; int sig; WITNESS_SAVE_DECL(mp); - p = CURPROC; + td = curthread; rval = 0; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 1, 0); + if (td->td_proc && KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 1, 0); #endif - CV_ASSERT(cvp, mp, p); + CV_ASSERT(cvp, mp, td); WITNESS_SLEEP(0, &mp->mtx_object); WITNESS_SAVE(&mp->mtx_object, mp); @@ -398,7 +401,7 @@ cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo) /* * After a panic, or during autoconfiguration, just give * interrupts a chance, then just return; don't run any other - * procs or panic below, in case this is the idle process and + * thread or panic below, in case this is the idle process and * already asleep. */ mtx_unlock_spin(&sched_lock); @@ -409,43 +412,43 @@ cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo) DROP_GIANT_NOSWITCH(); mtx_unlock_flags(mp, MTX_NOSWITCH); - cv_waitq_add(cvp, p); - callout_reset(&p->p_slpcallout, timo, cv_timedwait_end, p); - sig = cv_switch_catch(p); + cv_waitq_add(cvp, td); + callout_reset(&td->td_slpcallout, timo, cv_timedwait_end, td); + sig = cv_switch_catch(td); - if (p->p_sflag & PS_TIMEOUT) { - p->p_sflag &= ~PS_TIMEOUT; + if (td->td_flags & TDF_TIMEOUT) { + td->td_flags &= ~TDF_TIMEOUT; rval = EWOULDBLOCK; - } else if (p->p_sflag & PS_TIMOFAIL) - p->p_sflag &= ~PS_TIMOFAIL; - else if (callout_stop(&p->p_slpcallout) == 0) { + } else if (td->td_flags & TDF_TIMOFAIL) + td->td_flags &= ~TDF_TIMOFAIL; + else if (callout_stop(&td->td_slpcallout) == 0) { /* * Work around race with cv_timedwait_end similar to that * between msleep and endtsleep. */ - p->p_sflag |= PS_TIMEOUT; - p->p_stats->p_ru.ru_nivcsw++; + td->td_flags |= TDF_TIMEOUT; + td->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); } mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); - PROC_LOCK(p); + PROC_LOCK(td->td_proc); if (sig == 0) - sig = CURSIG(p); + sig = CURSIG(td->td_proc); if (sig != 0) { - if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) + if (SIGISMEMBER(td->td_proc->p_sigacts->ps_sigintr, sig)) rval = EINTR; else rval = ERESTART; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); #ifdef KTRACE mtx_lock(&Giant); - if (KTRPOINT(p, KTR_CSW)) - ktrcsw(p->p_tracep, 0, 0); + if (KTRPOINT(td->td_proc, KTR_CSW)) + ktrcsw(td->td_proc->p_tracep, 0, 0); mtx_unlock(&Giant); #endif mtx_lock(mp); @@ -461,38 +464,39 @@ cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo) static __inline void cv_wakeup(struct cv *cvp) { - struct proc *p; + struct thread *td; mtx_assert(&sched_lock, MA_OWNED); - p = TAILQ_FIRST(&cvp->cv_waitq); - KASSERT(p->p_wchan == cvp, ("%s: bogus wchan", __FUNCTION__)); - KASSERT(p->p_sflag & PS_CVWAITQ, ("%s: not on waitq", __FUNCTION__)); - TAILQ_REMOVE(&cvp->cv_waitq, p, p_slpq); - p->p_sflag &= ~PS_CVWAITQ; - p->p_wchan = 0; - if (p->p_stat == SSLEEP) { - /* OPTIMIZED EXPANSION OF setrunnable(p); */ - CTR3(KTR_PROC, "cv_signal: proc %p (pid %d, %s)", - p, p->p_pid, p->p_comm); - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; - p->p_stat = SRUN; - if (p->p_sflag & PS_INMEM) { - setrunqueue(p); - maybe_resched(p); + td = TAILQ_FIRST(&cvp->cv_waitq); + KASSERT(td->td_wchan == cvp, ("%s: bogus wchan", __FUNCTION__)); + KASSERT(td->td_flags & TDF_CVWAITQ, ("%s: not on waitq", __FUNCTION__)); + TAILQ_REMOVE(&cvp->cv_waitq, td, td_slpq); + td->td_flags &= ~TDF_CVWAITQ; + td->td_wchan = 0; + if (td->td_proc->p_stat == SSLEEP) { + /* OPTIMIZED EXPANSION OF setrunnable(td); */ + CTR3(KTR_PROC, "cv_signal: thread %p (pid %d, %s)", + td, td->td_proc->p_pid, td->td_proc->p_comm); + if (td->td_ksegrp->kg_slptime > 1) /* XXXKSE */ + updatepri(td); + td->td_kse->ke_slptime = 0; + td->td_ksegrp->kg_slptime = 0; + td->td_proc->p_stat = SRUN; + if (td->td_proc->p_sflag & PS_INMEM) { + setrunqueue(td); + maybe_resched(td->td_ksegrp); } else { - p->p_sflag |= PS_SWAPINREQ; - wakeup(&proc0); + td->td_proc->p_sflag |= PS_SWAPINREQ; + wakeup(&proc0); /* XXXKSE */ } /* END INLINE EXPANSION */ } } /* - * Signal a condition variable, wakes up one waiting process. Will also wakeup + * Signal a condition variable, wakes up one waiting thread. Will also wakeup * the swapper if the process is not in memory, so that it can bring the - * sleeping process in. Note that this may also result in additional processes + * sleeping process in. Note that this may also result in additional threads * being made runnable. Should be called with the same mutex as was passed to * cv_wait held. */ @@ -510,7 +514,7 @@ cv_signal(struct cv *cvp) } /* - * Broadcast a signal to a condition variable. Wakes up all waiting processes. + * Broadcast a signal to a condition variable. Wakes up all waiting threads. * Should be called with the same mutex as was passed to cv_wait held. */ void @@ -526,46 +530,46 @@ cv_broadcast(struct cv *cvp) } /* - * Remove a process from the wait queue of its condition variable. This may be + * Remove a thread from the wait queue of its condition variable. This may be * called externally. */ void -cv_waitq_remove(struct proc *p) +cv_waitq_remove(struct thread *td) { struct cv *cvp; mtx_lock_spin(&sched_lock); - if ((cvp = p->p_wchan) != NULL && p->p_sflag & PS_CVWAITQ) { - TAILQ_REMOVE(&cvp->cv_waitq, p, p_slpq); - p->p_sflag &= ~PS_CVWAITQ; - p->p_wchan = NULL; + if ((cvp = td->td_wchan) != NULL && td->td_flags & TDF_CVWAITQ) { + TAILQ_REMOVE(&cvp->cv_waitq, td, td_slpq); + td->td_flags &= ~TDF_CVWAITQ; + td->td_wchan = NULL; } mtx_unlock_spin(&sched_lock); } /* - * Timeout function for cv_timedwait. Put the process on the runqueue and set + * Timeout function for cv_timedwait. Put the thread on the runqueue and set * its timeout flag. */ static void cv_timedwait_end(void *arg) { - struct proc *p; + struct thread *td; - p = arg; - CTR3(KTR_PROC, "cv_timedwait_end: proc %p (pid %d, %s)", p, p->p_pid, - p->p_comm); + td = arg; + CTR3(KTR_PROC, "cv_timedwait_end: thread %p (pid %d, %s)", td, td->td_proc->p_pid, + td->td_proc->p_comm); mtx_lock_spin(&sched_lock); - if (p->p_sflag & PS_TIMEOUT) { - p->p_sflag &= ~PS_TIMEOUT; - setrunqueue(p); - } else if (p->p_wchan != NULL) { - if (p->p_stat == SSLEEP) - setrunnable(p); + if (td->td_flags & TDF_TIMEOUT) { + td->td_flags &= ~TDF_TIMEOUT; + setrunqueue(td); + } else if (td->td_wchan != NULL) { + if (td->td_proc->p_stat == SSLEEP) /* XXXKSE */ + setrunnable(td); else - cv_waitq_remove(p); - p->p_sflag |= PS_TIMEOUT; + cv_waitq_remove(td); + td->td_flags |= TDF_TIMEOUT; } else - p->p_sflag |= PS_TIMOFAIL; + td->td_flags |= TDF_TIMOFAIL; mtx_unlock_spin(&sched_lock); } diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 35cffc2..2f3bf92 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -35,8 +35,8 @@ #include <sys/param.h> #include <sys/kernel.h> -#include <sys/sysctl.h> #include <sys/systm.h> +#include <sys/sysctl.h> #include <sys/module.h> #include <sys/malloc.h> #include <sys/conf.h> diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index a09c8c2..da3bf4c 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -90,16 +90,16 @@ static struct cdevsw fildesc_cdevsw = { /* flags */ 0, }; -static int do_dup __P((struct filedesc *fdp, int old, int new, register_t *retval, struct proc *p)); +static int do_dup __P((struct filedesc *fdp, int old, int new, register_t *retval, struct thread *td)); static int badfo_readwrite __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); static int badfo_ioctl __P((struct file *fp, u_long com, caddr_t data, - struct proc *p)); + struct thread *td)); static int badfo_poll __P((struct file *fp, int events, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); static int badfo_kqfilter __P((struct file *fp, struct knote *kn)); -static int badfo_stat __P((struct file *fp, struct stat *sb, struct proc *p)); -static int badfo_close __P((struct file *fp, struct proc *p)); +static int badfo_stat __P((struct file *fp, struct stat *sb, struct thread *td)); +static int badfo_close __P((struct file *fp, struct thread *td)); /* * Descriptor management. @@ -121,13 +121,14 @@ struct getdtablesize_args { */ /* ARGSUSED */ int -getdtablesize(p, uap) - struct proc *p; +getdtablesize(td, uap) + struct thread *td; struct getdtablesize_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = + td->td_retval[0] = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfilesperproc); mtx_unlock(&Giant); return (0); @@ -150,11 +151,12 @@ struct dup2_args { */ /* ARGSUSED */ int -dup2(p, uap) - struct proc *p; +dup2(td, uap) + struct thread *td; struct dup2_args *uap; { - register struct filedesc *fdp = p->p_fd; + struct proc *p = td->td_proc; + register struct filedesc *fdp = td->td_proc->p_fd; register u_int old = uap->from, new = uap->to; int i, error; @@ -168,12 +170,12 @@ retry: goto done2; } if (old == new) { - p->p_retval[0] = new; + td->td_retval[0] = new; error = 0; goto done2; } if (new >= fdp->fd_nfiles) { - if ((error = fdalloc(p, new, &i))) + if ((error = fdalloc(td, new, &i))) goto done2; if (new != i) panic("dup2: fdalloc"); @@ -182,7 +184,7 @@ retry: */ goto retry; } - error = do_dup(fdp, (int)old, (int)new, p->p_retval, p); + error = do_dup(fdp, (int)old, (int)new, td->td_retval, td); done2: mtx_unlock(&Giant); return(error); @@ -201,8 +203,8 @@ struct dup_args { */ /* ARGSUSED */ int -dup(p, uap) - struct proc *p; +dup(td, uap) + struct thread *td; struct dup_args *uap; { register struct filedesc *fdp; @@ -211,14 +213,14 @@ dup(p, uap) mtx_lock(&Giant); old = uap->fd; - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL) { error = EBADF; goto done2; } - if ((error = fdalloc(p, 0, &new))) + if ((error = fdalloc(td, 0, &new))) goto done2; - error = do_dup(fdp, (int)old, new, p->p_retval, p); + error = do_dup(fdp, (int)old, new, td->td_retval, td); done2: mtx_unlock(&Giant); return (error); @@ -239,10 +241,11 @@ struct fcntl_args { */ /* ARGSUSED */ int -fcntl(p, uap) - struct proc *p; +fcntl(td, uap) + struct thread *td; register struct fcntl_args *uap; { + register struct proc *p = td->td_proc; register struct filedesc *fdp; register struct file *fp; register char *pop; @@ -269,13 +272,13 @@ fcntl(p, uap) error = EINVAL; break; } - if ((error = fdalloc(p, newmin, &i))) + if ((error = fdalloc(td, newmin, &i))) break; - error = do_dup(fdp, uap->fd, i, p->p_retval, p); + error = do_dup(fdp, uap->fd, i, td->td_retval, td); break; case F_GETFD: - p->p_retval[0] = *pop & 1; + td->td_retval[0] = *pop & 1; break; case F_SETFD: @@ -283,7 +286,7 @@ fcntl(p, uap) break; case F_GETFL: - p->p_retval[0] = OFLAGS(fp->f_flag); + td->td_retval[0] = OFLAGS(fp->f_flag); break; case F_SETFL: @@ -291,33 +294,33 @@ fcntl(p, uap) fp->f_flag &= ~FCNTLFLAGS; fp->f_flag |= FFLAGS(uap->arg & ~O_ACCMODE) & FCNTLFLAGS; tmp = fp->f_flag & FNONBLOCK; - error = fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, p); + error = fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, td); if (error) { - fdrop(fp, p); + fdrop(fp, td); break; } tmp = fp->f_flag & FASYNC; - error = fo_ioctl(fp, FIOASYNC, (caddr_t)&tmp, p); + error = fo_ioctl(fp, FIOASYNC, (caddr_t)&tmp, td); if (!error) { - fdrop(fp, p); + fdrop(fp, td); break; } fp->f_flag &= ~FNONBLOCK; tmp = 0; - (void)fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, p); - fdrop(fp, p); + (void)fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, td); + fdrop(fp, td); break; case F_GETOWN: fhold(fp); - error = fo_ioctl(fp, FIOGETOWN, (caddr_t)p->p_retval, p); - fdrop(fp, p); + error = fo_ioctl(fp, FIOGETOWN, (caddr_t)td->td_retval, td); + fdrop(fp, td); break; case F_SETOWN: fhold(fp); - error = fo_ioctl(fp, FIOSETOWN, (caddr_t)&uap->arg, p); - fdrop(fp, p); + error = fo_ioctl(fp, FIOSETOWN, (caddr_t)&uap->arg, td); + fdrop(fp, td); break; case F_SETLKW: @@ -339,14 +342,14 @@ fcntl(p, uap) error = copyin((caddr_t)(intptr_t)uap->arg, (caddr_t)&fl, sizeof(fl)); if (error) { - fdrop(fp, p); + fdrop(fp, td); break; } if (fl.l_whence == SEEK_CUR) { if (fp->f_offset < 0 || (fl.l_start > 0 && fp->f_offset > OFF_MAX - fl.l_start)) { - fdrop(fp, p); + fdrop(fp, td); error = EOVERFLOW; break; } @@ -380,8 +383,9 @@ fcntl(p, uap) error = EINVAL; break; } - fdrop(fp, p); + fdrop(fp, td); break; + case F_GETLK: if (fp->f_type != DTYPE_VNODE) { error = EBADF; @@ -396,12 +400,12 @@ fcntl(p, uap) error = copyin((caddr_t)(intptr_t)uap->arg, (caddr_t)&fl, sizeof(fl)); if (error) { - fdrop(fp, p); + fdrop(fp, td); break; } if (fl.l_type != F_RDLCK && fl.l_type != F_WRLCK && fl.l_type != F_UNLCK) { - fdrop(fp, p); + fdrop(fp, td); error = EINVAL; break; } @@ -410,7 +414,7 @@ fcntl(p, uap) fp->f_offset > OFF_MAX - fl.l_start) || (fl.l_start < 0 && fp->f_offset < OFF_MIN - fl.l_start)) { - fdrop(fp, p); + fdrop(fp, td); error = EOVERFLOW; break; } @@ -418,7 +422,7 @@ fcntl(p, uap) } error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK, &fl, F_POSIX); - fdrop(fp, p); + fdrop(fp, td); if (error == 0) { error = copyout((caddr_t)&fl, (caddr_t)(intptr_t)uap->arg, sizeof(fl)); @@ -437,11 +441,11 @@ done2: * Common code for dup, dup2, and fcntl(F_DUPFD). */ static int -do_dup(fdp, old, new, retval, p) +do_dup(fdp, old, new, retval, td) register struct filedesc *fdp; register int old, new; register_t *retval; - struct proc *p; + struct thread *td; { struct file *fp; struct file *delfp; @@ -454,7 +458,7 @@ do_dup(fdp, old, new, retval, p) delfp = fdp->fd_ofiles[new]; #if 0 if (delfp && (fdp->fd_ofileflags[new] & UF_MAPPED)) - (void) munmapfd(p, new); + (void) munmapfd(td, new); #endif /* @@ -474,7 +478,7 @@ do_dup(fdp, old, new, retval, p) * close() were performed on it). */ if (delfp) - (void) closef(delfp, p); + (void) closef(delfp, td); return (0); } @@ -549,7 +553,7 @@ fsetown(pgid, sigiop) * restrict FSETOWN to the current process or process * group for maximum safety. */ - if (proc->p_session != curproc->p_session) { + if (proc->p_session != curthread->td_proc->p_session) { PROC_UNLOCK(proc); return (EPERM); } @@ -569,7 +573,7 @@ fsetown(pgid, sigiop) * restrict FSETOWN to the current process or process * group for maximum safety. */ - if (pgrp->pg_session != curproc->p_session) + if (pgrp->pg_session != curthread->td_proc->p_session) return (EPERM); proc = NULL; @@ -584,8 +588,8 @@ fsetown(pgid, sigiop) sigio->sio_pgrp = pgrp; } sigio->sio_pgid = pgid; - crhold(curproc->p_ucred); - sigio->sio_ucred = curproc->p_ucred; + crhold(curthread->td_proc->p_ucred); + sigio->sio_ucred = curthread->td_proc->p_ucred; sigio->sio_myref = sigiop; s = splhigh(); *sigiop = sigio; @@ -616,8 +620,8 @@ struct close_args { */ /* ARGSUSED */ int -close(p, uap) - struct proc *p; +close(td, uap) + struct thread *td; struct close_args *uap; { register struct filedesc *fdp; @@ -626,7 +630,7 @@ close(p, uap) int error = 0; mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) { error = EBADF; @@ -634,7 +638,7 @@ close(p, uap) } #if 0 if (fdp->fd_ofileflags[fd] & UF_MAPPED) - (void) munmapfd(p, fd); + (void) munmapfd(td, fd); #endif fdp->fd_ofiles[fd] = NULL; fdp->fd_ofileflags[fd] = 0; @@ -648,8 +652,8 @@ close(p, uap) if (fd < fdp->fd_freefile) fdp->fd_freefile = fd; if (fd < fdp->fd_knlistsize) - knote_fdclose(p, fd); - error = closef(fp, p); + knote_fdclose(td, fd); + error = closef(fp, td); done2: mtx_unlock(&Giant); return(error); @@ -670,11 +674,11 @@ struct ofstat_args { */ /* ARGSUSED */ int -ofstat(p, uap) - struct proc *p; +ofstat(td, uap) + struct thread *td; register struct ofstat_args *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; register struct file *fp; struct stat ub; struct ostat oub; @@ -688,12 +692,12 @@ ofstat(p, uap) goto done2; } fhold(fp); - error = fo_stat(fp, &ub, p); + error = fo_stat(fp, &ub, td); if (error == 0) { cvtstat(&ub, &oub); error = copyout((caddr_t)&oub, (caddr_t)uap->sb, sizeof (oub)); } - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -714,8 +718,8 @@ struct fstat_args { */ /* ARGSUSED */ int -fstat(p, uap) - struct proc *p; +fstat(td, uap) + struct thread *td; register struct fstat_args *uap; { register struct filedesc *fdp; @@ -724,7 +728,7 @@ fstat(p, uap) int error; mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) { @@ -732,10 +736,10 @@ fstat(p, uap) goto done2; } fhold(fp); - error = fo_stat(fp, &ub, p); + error = fo_stat(fp, &ub, td); if (error == 0) error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub)); - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -755,8 +759,8 @@ struct nfstat_args { */ /* ARGSUSED */ int -nfstat(p, uap) - struct proc *p; +nfstat(td, uap) + struct thread *td; register struct nfstat_args *uap; { register struct filedesc *fdp; @@ -767,19 +771,19 @@ nfstat(p, uap) mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) { error = EBADF; goto done2; } fhold(fp); - error = fo_stat(fp, &ub, p); + error = fo_stat(fp, &ub, td); if (error == 0) { cvtnstat(&ub, &nub); error = copyout((caddr_t)&nub, (caddr_t)uap->sb, sizeof (nub)); } - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -799,8 +803,8 @@ struct fpathconf_args { */ /* ARGSUSED */ int -fpathconf(p, uap) - struct proc *p; +fpathconf(td, uap) + struct thread *td; register struct fpathconf_args *uap; { struct filedesc *fdp; @@ -809,7 +813,7 @@ fpathconf(p, uap) int error = 0; mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) { @@ -826,19 +830,19 @@ fpathconf(p, uap) error = EINVAL; goto done2; } - p->p_retval[0] = PIPE_BUF; + td->td_retval[0] = PIPE_BUF; error = 0; break; case DTYPE_FIFO: case DTYPE_VNODE: vp = (struct vnode *)fp->f_data; - error = VOP_PATHCONF(vp, uap->name, p->p_retval); + error = VOP_PATHCONF(vp, uap->name, td->td_retval); break; default: error = EOPNOTSUPP; break; } - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return(error); @@ -851,12 +855,13 @@ static int fdexpand; SYSCTL_INT(_debug, OID_AUTO, fdexpand, CTLFLAG_RD, &fdexpand, 0, ""); int -fdalloc(p, want, result) - struct proc *p; +fdalloc(td, want, result) + struct thread *td; int want; int *result; { - register struct filedesc *fdp = p->p_fd; + struct proc *p = td->td_proc; + register struct filedesc *fdp = td->td_proc->p_fd; register int i; int lim, last, nfiles; struct file **newofile; @@ -930,11 +935,12 @@ fdalloc(p, want, result) * are available to the process p. */ int -fdavail(p, n) - struct proc *p; +fdavail(td, n) + struct thread *td; register int n; { - register struct filedesc *fdp = p->p_fd; + struct proc *p = td->td_proc; + register struct filedesc *fdp = td->td_proc->p_fd; register struct file **fpp; register int i, lim, last; @@ -956,11 +962,12 @@ fdavail(p, n) * a file decriptor for the process that refers to it. */ int -falloc(p, resultfp, resultfd) - register struct proc *p; +falloc(td, resultfp, resultfd) + register struct thread *td; struct file **resultfp; int *resultfd; { + struct proc *p = td->td_proc; register struct file *fp, *fq; int error, i; @@ -982,7 +989,7 @@ falloc(p, resultfp, resultfd) * allocating the slot, else a race might have shrunk it if we had * allocated it before the malloc. */ - if ((error = fdalloc(p, 0, &i))) { + if ((error = fdalloc(td, 0, &i))) { nfiles--; FREE(fp, M_FILE); return (error); @@ -1023,11 +1030,11 @@ ffree(fp) * Build a new filedesc structure. */ struct filedesc * -fdinit(p) - struct proc *p; +fdinit(td) + struct thread *td; { register struct filedesc0 *newfdp; - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0), M_FILEDESC, M_WAITOK | M_ZERO); @@ -1067,10 +1074,10 @@ fdshare(p) * Copy a filedesc structure. */ struct filedesc * -fdcopy(p) - struct proc *p; +fdcopy(td) + struct thread *td; { - register struct filedesc *newfdp, *fdp = p->p_fd; + register struct filedesc *newfdp, *fdp = td->td_proc->p_fd; register struct file **fpp; register int i; @@ -1144,10 +1151,10 @@ fdcopy(p) * Release a filedesc structure. */ void -fdfree(p) - struct proc *p; +fdfree(td) + struct thread *td; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; struct file **fpp; register int i; @@ -1164,7 +1171,7 @@ fdfree(p) fpp = fdp->fd_ofiles; for (i = fdp->fd_lastfile; i-- >= 0; fpp++) { if (*fpp) - (void) closef(*fpp, p); + (void) closef(*fpp, td); } if (fdp->fd_nfiles > NDFILE) FREE(fdp->fd_ofiles, M_FILEDESC); @@ -1206,10 +1213,10 @@ is_unsafe(struct file *fp) * Make this setguid thing safe, if at all possible. */ void -setugidsafety(p) - struct proc *p; +setugidsafety(td) + struct thread *td; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; register int i; /* Certain daemons might not have file descriptors. */ @@ -1228,10 +1235,10 @@ setugidsafety(p) #if 0 if ((fdp->fd_ofileflags[i] & UF_MAPPED) != 0) - (void) munmapfd(p, i); + (void) munmapfd(td, i); #endif if (i < fdp->fd_knlistsize) - knote_fdclose(p, i); + knote_fdclose(td, i); /* * NULL-out descriptor prior to close to avoid * a race while close blocks. @@ -1241,7 +1248,7 @@ setugidsafety(p) fdp->fd_ofileflags[i] = 0; if (i < fdp->fd_freefile) fdp->fd_freefile = i; - (void) closef(fp, p); + (void) closef(fp, td); } } while (fdp->fd_lastfile > 0 && fdp->fd_ofiles[fdp->fd_lastfile] == NULL) @@ -1252,10 +1259,10 @@ setugidsafety(p) * Close any files on exec? */ void -fdcloseexec(p) - struct proc *p; +fdcloseexec(td) + struct thread *td; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; register int i; /* Certain daemons might not have file descriptors. */ @@ -1273,10 +1280,10 @@ fdcloseexec(p) #if 0 if (fdp->fd_ofileflags[i] & UF_MAPPED) - (void) munmapfd(p, i); + (void) munmapfd(td, i); #endif if (i < fdp->fd_knlistsize) - knote_fdclose(p, i); + knote_fdclose(td, i); /* * NULL-out descriptor prior to close to avoid * a race while close blocks. @@ -1286,7 +1293,7 @@ fdcloseexec(p) fdp->fd_ofileflags[i] = 0; if (i < fdp->fd_freefile) fdp->fd_freefile = i; - (void) closef(fp, p); + (void) closef(fp, td); } } while (fdp->fd_lastfile > 0 && fdp->fd_ofiles[fdp->fd_lastfile] == NULL) @@ -1300,10 +1307,11 @@ fdcloseexec(p) * that was being passed in a message. */ int -closef(fp, p) +closef(fp, td) register struct file *fp; - register struct proc *p; + register struct thread *td; { + struct proc *p = td->td_proc; struct vnode *vp; struct flock lf; @@ -1325,13 +1333,13 @@ closef(fp, p) vp = (struct vnode *)fp->f_data; (void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &lf, F_POSIX); } - return (fdrop(fp, p)); + return (fdrop(fp, td)); } int -fdrop(fp, p) +fdrop(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { struct flock lf; struct vnode *vp; @@ -1350,7 +1358,7 @@ fdrop(fp, p) (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK); } if (fp->f_ops != &badfileops) - error = fo_close(fp, p); + error = fo_close(fp, td); else error = 0; ffree(fp); @@ -1374,11 +1382,11 @@ struct flock_args { */ /* ARGSUSED */ int -flock(p, uap) - struct proc *p; +flock(td, uap) + struct thread *td; register struct flock_args *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; register struct file *fp; struct vnode *vp; struct flock lf; @@ -1433,21 +1441,21 @@ done2: */ /* ARGSUSED */ static int -fdopen(dev, mode, type, p) +fdopen(dev, mode, type, td) dev_t dev; int mode, type; - struct proc *p; + struct thread *td; { /* - * XXX Kludge: set curproc->p_dupfd to contain the value of the + * XXX Kludge: set curthread->td_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. */ - p->p_dupfd = dev2unit(dev); + td->td_dupfd = dev2unit(dev); return (ENODEV); } @@ -1455,8 +1463,8 @@ fdopen(dev, mode, type, p) * Duplicate the specified descriptor to a free descriptor. */ int -dupfdopen(p, fdp, indx, dfd, mode, error) - struct proc *p; +dupfdopen(td, fdp, indx, dfd, mode, error) + struct thread *td; struct filedesc *fdp; int indx, dfd; int mode; @@ -1498,7 +1506,7 @@ dupfdopen(p, fdp, indx, dfd, mode, error) fp = fdp->fd_ofiles[indx]; #if 0 if (fp && fdp->fd_ofileflags[indx] & UF_MAPPED) - (void) munmapfd(p, indx); + (void) munmapfd(td, indx); #endif fdp->fd_ofiles[indx] = wfp; fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd]; @@ -1510,7 +1518,7 @@ dupfdopen(p, fdp, indx, dfd, mode, error) * used to own. Release it. */ if (fp) - fdrop(fp, p); + fdrop(fp, td); return (0); case ENXIO: @@ -1520,7 +1528,7 @@ dupfdopen(p, fdp, indx, dfd, mode, error) fp = fdp->fd_ofiles[indx]; #if 0 if (fp && fdp->fd_ofileflags[indx] & UF_MAPPED) - (void) munmapfd(p, indx); + (void) munmapfd(td, indx); #endif fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd]; fdp->fd_ofiles[dfd] = NULL; @@ -1532,7 +1540,7 @@ dupfdopen(p, fdp, indx, dfd, mode, error) * used to own. Release it. */ if (fp) - fdrop(fp, p); + fdrop(fp, td); /* * Complete the clean up of the filedesc structure by * recomputing the various hints. @@ -1630,11 +1638,11 @@ struct fileops badfileops = { }; static int -badfo_readwrite(fp, uio, cred, flags, p) +badfo_readwrite(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { @@ -1642,22 +1650,22 @@ badfo_readwrite(fp, uio, cred, flags, p) } static int -badfo_ioctl(fp, com, data, p) +badfo_ioctl(fp, com, data, td) struct file *fp; u_long com; caddr_t data; - struct proc *p; + struct thread *td; { return (EBADF); } static int -badfo_poll(fp, events, cred, p) +badfo_poll(fp, events, cred, td) struct file *fp; int events; struct ucred *cred; - struct proc *p; + struct thread *td; { return (0); @@ -1673,19 +1681,19 @@ badfo_kqfilter(fp, kn) } static int -badfo_stat(fp, sb, p) +badfo_stat(fp, sb, td) struct file *fp; struct stat *sb; - struct proc *p; + struct thread *td; { return (EBADF); } static int -badfo_close(fp, p) +badfo_close(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { return (EBADF); diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 6f871b6..35391b0 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -52,18 +52,18 @@ static int kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, const struct timespec *timeout, - struct proc *p); + struct thread *td); static int kqueue_read(struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p); + struct ucred *cred, int flags, struct thread *td); static int kqueue_write(struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p); + struct ucred *cred, int flags, struct thread *td); static int kqueue_ioctl(struct file *fp, u_long com, caddr_t data, - struct proc *p); + struct thread *td); static int kqueue_poll(struct file *fp, int events, struct ucred *cred, - struct proc *p); + struct thread *td); static int kqueue_kqfilter(struct file *fp, struct knote *kn); -static int kqueue_stat(struct file *fp, struct stat *st, struct proc *p); -static int kqueue_close(struct file *fp, struct proc *p); +static int kqueue_stat(struct file *fp, struct stat *st, struct thread *td); +static int kqueue_close(struct file *fp, struct thread *td); static void kqueue_wakeup(struct kqueue *kq); static struct fileops kqueueops = { @@ -77,7 +77,7 @@ static struct fileops kqueueops = { }; static void knote_attach(struct knote *kn, struct filedesc *fdp); -static void knote_drop(struct knote *kn, struct proc *p); +static void knote_drop(struct knote *kn, struct thread *td); static void knote_enqueue(struct knote *kn); static void knote_dequeue(struct knote *kn); static void knote_init(void); @@ -335,7 +335,7 @@ filt_timer(struct knote *kn, long hint) * MPSAFE */ int -kqueue(struct proc *p, struct kqueue_args *uap) +kqueue(struct thread *td, struct kqueue_args *uap) { struct filedesc *fdp; struct kqueue *kq; @@ -343,8 +343,8 @@ kqueue(struct proc *p, struct kqueue_args *uap) int fd, error; mtx_lock(&Giant); - fdp = p->p_fd; - error = falloc(p, &fp, &fd); + fdp = td->td_proc->p_fd; + error = falloc(td, &fp, &fd); if (error) goto done2; fp->f_flag = FREAD | FWRITE; @@ -353,7 +353,7 @@ kqueue(struct proc *p, struct kqueue_args *uap) kq = malloc(sizeof(struct kqueue), M_TEMP, M_WAITOK | M_ZERO); TAILQ_INIT(&kq->kq_head); fp->f_data = (caddr_t)kq; - p->p_retval[0] = fd; + td->td_retval[0] = fd; if (fdp->fd_knlistsize < 0) fdp->fd_knlistsize = 0; /* this process has a kq */ kq->kq_fdp = fdp; @@ -376,7 +376,7 @@ struct kevent_args { * MPSAFE */ int -kevent(struct proc *p, struct kevent_args *uap) +kevent(struct thread *td, struct kevent_args *uap) { struct filedesc *fdp; struct kevent *kevp; @@ -386,7 +386,7 @@ kevent(struct proc *p, struct kevent_args *uap) int i, n, nerrors, error; mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if (((u_int)uap->fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL || (fp->f_type != DTYPE_KQUEUE)) { @@ -414,7 +414,7 @@ kevent(struct proc *p, struct kevent_args *uap) for (i = 0; i < n; i++) { kevp = &kq->kq_kev[i]; kevp->flags &= ~EV_SYSFLAGS; - error = kqueue_register(kq, kevp, p); + error = kqueue_register(kq, kevp, td); if (error) { if (uap->nevents != 0) { kevp->flags = EV_ERROR; @@ -434,21 +434,21 @@ kevent(struct proc *p, struct kevent_args *uap) uap->changelist += n; } if (nerrors) { - p->p_retval[0] = nerrors; + td->td_retval[0] = nerrors; error = 0; goto done; } - error = kqueue_scan(fp, uap->nevents, uap->eventlist, uap->timeout, p); + error = kqueue_scan(fp, uap->nevents, uap->eventlist, uap->timeout, td); done: if (fp != NULL) - fdrop(fp, p); + fdrop(fp, td); mtx_unlock(&Giant); return (error); } int -kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) +kqueue_register(struct kqueue *kq, struct kevent *kev, struct thread *td) { struct filedesc *fdp = kq->kq_fdp; struct filterops *fops; @@ -531,7 +531,7 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) knote_attach(kn, fdp); if ((error = fops->f_attach(kn)) != 0) { - knote_drop(kn, p); + knote_drop(kn, td); goto done; } } else { @@ -552,7 +552,7 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) } else if (kev->flags & EV_DELETE) { kn->kn_fop->f_detach(kn); - knote_drop(kn, p); + knote_drop(kn, td); goto done; } @@ -574,13 +574,13 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) done: if (fp != NULL) - fdrop(fp, p); + fdrop(fp, td); return (error); } static int kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, - const struct timespec *tsp, struct proc *p) + const struct timespec *tsp, struct thread *td) { struct kqueue *kq = (struct kqueue *)fp->f_data; struct kevent *kevp; @@ -673,7 +673,7 @@ start: kq->kq_count--; splx(s); kn->kn_fop->f_detach(kn); - knote_drop(kn, p); + knote_drop(kn, td); s = splhigh(); } else if (kn->kn_flags & EV_CLEAR) { kn->kn_data = 0; @@ -702,7 +702,7 @@ done: if (nkev != 0) error = copyout((caddr_t)&kq->kq_kev, (caddr_t)ulistp, sizeof(struct kevent) * nkev); - p->p_retval[0] = maxevents - count; + td->td_retval[0] = maxevents - count; return (error); } @@ -713,7 +713,7 @@ done: /*ARGSUSED*/ static int kqueue_read(struct file *fp, struct uio *uio, struct ucred *cred, - int flags, struct proc *p) + int flags, struct thread *td) { return (ENXIO); } @@ -721,21 +721,21 @@ kqueue_read(struct file *fp, struct uio *uio, struct ucred *cred, /*ARGSUSED*/ static int kqueue_write(struct file *fp, struct uio *uio, struct ucred *cred, - int flags, struct proc *p) + int flags, struct thread *td) { return (ENXIO); } /*ARGSUSED*/ static int -kqueue_ioctl(struct file *fp, u_long com, caddr_t data, struct proc *p) +kqueue_ioctl(struct file *fp, u_long com, caddr_t data, struct thread *td) { return (ENOTTY); } /*ARGSUSED*/ static int -kqueue_poll(struct file *fp, int events, struct ucred *cred, struct proc *p) +kqueue_poll(struct file *fp, int events, struct ucred *cred, struct thread *td) { struct kqueue *kq = (struct kqueue *)fp->f_data; int revents = 0; @@ -745,7 +745,7 @@ kqueue_poll(struct file *fp, int events, struct ucred *cred, struct proc *p) if (kq->kq_count) { revents |= events & (POLLIN | POLLRDNORM); } else { - selrecord(p, &kq->kq_sel); + selrecord(curthread, &kq->kq_sel); kq->kq_state |= KQ_SEL; } } @@ -755,7 +755,7 @@ kqueue_poll(struct file *fp, int events, struct ucred *cred, struct proc *p) /*ARGSUSED*/ static int -kqueue_stat(struct file *fp, struct stat *st, struct proc *p) +kqueue_stat(struct file *fp, struct stat *st, struct thread *td) { struct kqueue *kq = (struct kqueue *)fp->f_data; @@ -768,10 +768,10 @@ kqueue_stat(struct file *fp, struct stat *st, struct proc *p) /*ARGSUSED*/ static int -kqueue_close(struct file *fp, struct proc *p) +kqueue_close(struct file *fp, struct thread *td) { struct kqueue *kq = (struct kqueue *)fp->f_data; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct knote **knp, *kn, *kn0; int i; @@ -782,7 +782,7 @@ kqueue_close(struct file *fp, struct proc *p) kn0 = SLIST_NEXT(kn, kn_link); if (kq == kn->kn_kq) { kn->kn_fop->f_detach(kn); - fdrop(kn->kn_fp, p); + fdrop(kn->kn_fp, td); knote_free(kn); *knp = kn0; } else { @@ -847,13 +847,13 @@ knote(struct klist *list, long hint) * remove all knotes from a specified klist */ void -knote_remove(struct proc *p, struct klist *list) +knote_remove(struct thread *td, struct klist *list) { struct knote *kn; while ((kn = SLIST_FIRST(list)) != NULL) { kn->kn_fop->f_detach(kn); - knote_drop(kn, p); + knote_drop(kn, td); } } @@ -861,12 +861,12 @@ knote_remove(struct proc *p, struct klist *list) * remove all knotes referencing a specified fd */ void -knote_fdclose(struct proc *p, int fd) +knote_fdclose(struct thread *td, int fd) { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct klist *list = &fdp->fd_knlist[fd]; - knote_remove(p, list); + knote_remove(td, list); } static void @@ -910,9 +910,9 @@ done: * while calling fdrop and free. */ static void -knote_drop(struct knote *kn, struct proc *p) +knote_drop(struct knote *kn, struct thread *td) { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct klist *list; if (kn->kn_fop->f_isfd) @@ -924,7 +924,7 @@ knote_drop(struct knote *kn, struct proc *p) if (kn->kn_status & KN_QUEUED) knote_dequeue(kn); if (kn->kn_fop->f_isfd) - fdrop(kn->kn_fp, p); + fdrop(kn->kn_fp, td); knote_free(kn); } diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 90a4f4c..0091d09 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -102,10 +102,11 @@ struct execve_args { * MPSAFE */ int -execve(p, uap) - struct proc *p; +execve(td, uap) + struct thread *td; register struct execve_args *uap; { + struct proc *p = td->td_proc; struct nameidata nd, *ndp; struct ucred *newcred, *oldcred; register_t *stack_base; @@ -117,6 +118,10 @@ execve(p, uap) imgp = &image_params; +/* XXXKSE */ +/* !!!!!!!! we need abort all the other threads of this process before we */ +/* proceed beyond his point! */ + /* * Initialize part of the common data */ @@ -156,7 +161,7 @@ execve(p, uap) */ ndp = &nd; NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, - UIO_USERSPACE, uap->fname, p); + UIO_USERSPACE, uap->fname, td); interpret: @@ -175,12 +180,12 @@ interpret: */ error = exec_check_permissions(imgp); if (error) { - VOP_UNLOCK(imgp->vp, 0, p); + VOP_UNLOCK(imgp->vp, 0, td); goto exec_fail_dealloc; } error = exec_map_first_page(imgp); - VOP_UNLOCK(imgp->vp, 0, p); + VOP_UNLOCK(imgp->vp, 0, td); if (error) goto exec_fail_dealloc; @@ -223,7 +228,7 @@ interpret: vrele(ndp->ni_vp); /* set new name to that of the interpreter */ NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, - UIO_SYSSPACE, imgp->interpreter_name, p); + UIO_SYSSPACE, imgp->interpreter_name, td); goto interpret; } @@ -250,8 +255,8 @@ interpret: if (p->p_fd->fd_refcnt > 1) { struct filedesc *tmp; - tmp = fdcopy(p); - fdfree(p); + tmp = fdcopy(td); + fdfree(td); p->p_fd = tmp; } @@ -270,17 +275,17 @@ interpret: p->p_procsig->ps_refcnt--; p->p_procsig = newprocsig; p->p_procsig->ps_refcnt = 1; - if (p->p_sigacts == &p->p_addr->u_sigacts) + if (p->p_sigacts == &p->p_uarea->u_sigacts) panic("shared procsig but private sigacts?"); - p->p_addr->u_sigacts = *p->p_sigacts; - p->p_sigacts = &p->p_addr->u_sigacts; + p->p_uarea->u_sigacts = *p->p_sigacts; + p->p_sigacts = &p->p_uarea->u_sigacts; } /* Stop profiling */ stopprofclock(p); /* close files on exec */ - fdcloseexec(p); + fdcloseexec(td); /* reset caught signals */ execsigs(p); @@ -342,7 +347,7 @@ interpret: change_euid(newcred, attr.va_uid); if (attr.va_mode & VSGID) change_egid(newcred, attr.va_gid); - setugidsafety(p); + setugidsafety(td); } else { if (oldcred->cr_uid == oldcred->cr_ruid && oldcred->cr_gid == oldcred->cr_rgid) @@ -408,7 +413,7 @@ interpret: p->p_acflag &= ~AFORK; /* Set values passed into the program in registers. */ - setregs(p, imgp->entry_addr, (u_long)(uintptr_t)stack_base, + setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base, imgp->ps_strings); /* Free any previous argument cache */ @@ -454,7 +459,7 @@ exec_fail_dealloc: exec_fail: if (imgp->vmspace_destroyed) { /* sorry, no more process anymore. exit gracefully */ - exit1(p, W_EXITCODE(0, SIGABRT)); + exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ error = 0; } @@ -587,7 +592,7 @@ exec_new_vmspace(imgp) error = vm_map_find(&vmspace->vm_map, 0, 0, &bsaddr, 4*PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0); - imgp->proc->p_md.md_bspstore = bsaddr; + imgp->proc->p_thread.td_md.md_bspstore = bsaddr; } #endif @@ -798,7 +803,7 @@ exec_check_permissions(imgp) int error; /* Get file attributes */ - error = VOP_GETATTR(vp, attr, p->p_ucred, p); + error = VOP_GETATTR(vp, attr, p->p_ucred, curthread); /* XXXKSE */ if (error) return (error); @@ -825,7 +830,7 @@ exec_check_permissions(imgp) /* * Check for execute permission to file based on current credentials. */ - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, p->p_ucred, curthread); /* XXXKSE */ if (error) return (error); @@ -840,7 +845,7 @@ exec_check_permissions(imgp) * Call filesystem specific open routine (which does nothing in the * general case). */ - error = VOP_OPEN(vp, FREAD, p->p_ucred, p); + error = VOP_OPEN(vp, FREAD, p->p_ucred, curthread); /* XXXKSE */ if (error) return (error); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 812b20e..80da053 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -79,7 +79,7 @@ MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status"); static MALLOC_DEFINE(M_ATEXIT, "atexit", "atexit callback"); -static int wait1 __P((struct proc *, struct wait_args *, int)); +static int wait1 __P((struct thread *, struct wait_args *, int)); /* * callout list for things to do at exit time @@ -99,14 +99,15 @@ static struct exit_list_head exit_list = TAILQ_HEAD_INITIALIZER(exit_list); * MPSAFE */ void -sys_exit(p, uap) - struct proc *p; +sys_exit(td, uap) + struct thread *td; struct sys_exit_args /* { int rval; } */ *uap; { + mtx_lock(&Giant); - exit1(p, W_EXITCODE(uap->rval, 0)); + exit1(td, W_EXITCODE(uap->rval, 0)); /* NOTREACHED */ } @@ -116,10 +117,11 @@ sys_exit(p, uap) * status and rusage for wait(). Check for child processes and orphan them. */ void -exit1(p, rv) - register struct proc *p; +exit1(td, rv) + register struct thread *td; int rv; { + struct proc *p = td->td_proc; register struct proc *q, *nq; register struct vmspace *vm; struct exitlist *ep; @@ -132,6 +134,9 @@ exit1(p, rv) panic("Going nowhere without my init!"); } +/* XXXXKSE */ +/* MUST abort all other threads before proceeding past this point */ + aio_proc_rundown(p); /* are we a task leader? */ @@ -189,7 +194,7 @@ exit1(p, rv) * Close open files and release open-file table. * This may block! */ - fdfree(p); + fdfree(&p->p_thread); /* XXXKSE */ /* * Remove ourself from our leader's peer list and wake our leader. @@ -264,7 +269,7 @@ exit1(p, rv) } else PROC_UNLOCK(p); fixjobc(p, p->p_pgrp, 0); - (void)acct_process(p); + (void)acct_process(td); #ifdef KTRACE /* * release trace file @@ -385,7 +390,7 @@ exit1(p, rv) * The address space is released by "vmspace_free(p->p_vmspace)" * in vm_waitproc(); */ - cpu_exit(p); + cpu_exit(td); PROC_LOCK(p); mtx_lock_spin(&sched_lock); @@ -413,8 +418,8 @@ exit1(p, rv) * MPSAFE, the dirty work is handled by wait1(). */ int -owait(p, uap) - struct proc *p; +owait(td, uap) + struct thread *td; register struct owait_args /* { int dummy; } */ *uap; @@ -425,7 +430,7 @@ owait(p, uap) w.rusage = NULL; w.pid = WAIT_ANY; w.status = NULL; - return (wait1(p, &w, 1)); + return (wait1(td, &w, 1)); } #endif /* COMPAT_43 */ @@ -433,19 +438,20 @@ owait(p, uap) * MPSAFE, the dirty work is handled by wait1(). */ int -wait4(p, uap) - struct proc *p; +wait4(td, uap) + struct thread *td; struct wait_args *uap; { - return (wait1(p, uap, 0)); + + return (wait1(td, uap, 0)); } /* * MPSAFE */ static int -wait1(q, uap, compat) - register struct proc *q; +wait1(td, uap, compat) + register struct thread *td; register struct wait_args /* { int pid; int *status; @@ -455,10 +461,11 @@ wait1(q, uap, compat) int compat; { register int nfound; - register struct proc *p, *t; + register struct proc *q, *p, *t; int status, error; mtx_lock(&Giant); + q = td->td_proc; if (uap->pid == 0) uap->pid = -q->p_pgid; if (uap->options &~ (WUNTRACED|WNOHANG|WLINUXCLONE)) { @@ -491,20 +498,31 @@ loop: nfound++; mtx_lock_spin(&sched_lock); if (p->p_stat == SZOMB) { - /* charge childs scheduling cpu usage to parent */ - if (curproc->p_pid != 1) { - curproc->p_estcpu = - ESTCPULIM(curproc->p_estcpu + p->p_estcpu); + /* + * charge childs scheduling cpu usage to parent + * XXXKSE assume only one thread & kse & ksegrp + * keep estcpu in each ksegrp + * so charge it to the ksegrp that did the wait + * since process estcpu is sum of all ksegrps, + * this is strictly as expected. + * Assume that the child process aggregated all + * tke estcpu into the 'build-in' ksegrp. + * XXXKSE + */ + if (curthread->td_proc->p_pid != 1) { + curthread->td_ksegrp->kg_estcpu = + ESTCPULIM(curthread->td_ksegrp->kg_estcpu + + p->p_ksegrp.kg_estcpu); } mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); sx_sunlock(&proctree_lock); - q->p_retval[0] = p->p_pid; + td->td_retval[0] = p->p_pid; #ifdef COMPAT_43 if (compat) - q->p_retval[1] = p->p_xstat; + td->td_retval[1] = p->p_xstat; else #endif if (uap->status) { @@ -583,7 +601,7 @@ loop: FREE(p->p_args, M_PARGS); if (--p->p_procsig->ps_refcnt == 0) { - if (p->p_sigacts != &p->p_addr->u_sigacts) + if (p->p_sigacts != &p->p_uarea->u_sigacts) FREE(p->p_sigacts, M_SUBPROC); FREE(p->p_procsig, M_SUBPROC); p->p_procsig = NULL; @@ -607,10 +625,10 @@ loop: p->p_flag |= P_WAITED; PROC_UNLOCK(p); sx_sunlock(&proctree_lock); - q->p_retval[0] = p->p_pid; + td->td_retval[0] = p->p_pid; #ifdef COMPAT_43 if (compat) { - q->p_retval[1] = W_STOPCODE(p->p_xstat); + td->td_retval[1] = W_STOPCODE(p->p_xstat); error = 0; } else #endif @@ -631,7 +649,7 @@ loop: goto done2; } if (uap->options & WNOHANG) { - q->p_retval[0] = 0; + td->td_retval[0] = 0; error = 0; goto done2; } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index af154c3..f5ae42c 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -110,18 +110,18 @@ SYSINIT(fork_list, SI_SUB_INTRINSIC, SI_ORDER_ANY, init_fork_list, NULL); */ /* ARGSUSED */ int -fork(p, uap) - struct proc *p; +fork(td, uap) + struct thread *td; struct fork_args *uap; { int error; struct proc *p2; mtx_lock(&Giant); - error = fork1(p, RFFDG | RFPROC, &p2); + error = fork1(td, RFFDG | RFPROC, &p2); if (error == 0) { - p->p_retval[0] = p2->p_pid; - p->p_retval[1] = 0; + td->td_retval[0] = p2->p_pid; + td->td_retval[1] = 0; } mtx_unlock(&Giant); return error; @@ -132,18 +132,18 @@ fork(p, uap) */ /* ARGSUSED */ int -vfork(p, uap) - struct proc *p; +vfork(td, uap) + struct thread *td; struct vfork_args *uap; { int error; struct proc *p2; mtx_lock(&Giant); - error = fork1(p, RFFDG | RFPROC | RFPPWAIT | RFMEM, &p2); + error = fork1(td, RFFDG | RFPROC | RFPPWAIT | RFMEM, &p2); if (error == 0) { - p->p_retval[0] = p2->p_pid; - p->p_retval[1] = 0; + td->td_retval[0] = p2->p_pid; + td->td_retval[1] = 0; } mtx_unlock(&Giant); return error; @@ -153,8 +153,8 @@ vfork(p, uap) * MPSAFE */ int -rfork(p, uap) - struct proc *p; +rfork(td, uap) + struct thread *td; struct rfork_args *uap; { int error; @@ -162,10 +162,10 @@ rfork(p, uap) /* mask kernel only flags out of the user flags */ mtx_lock(&Giant); - error = fork1(p, uap->flags & ~RFKERNELONLY, &p2); + error = fork1(td, uap->flags & ~RFKERNELONLY, &p2); if (error == 0) { - p->p_retval[0] = p2 ? p2->p_pid : 0; - p->p_retval[1] = 0; + td->td_retval[0] = p2 ? p2->p_pid : 0; + td->td_retval[1] = 0; } mtx_unlock(&Giant); return error; @@ -209,9 +209,26 @@ sysctl_kern_randompid(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_kern_randompid, "I", "Random PID modulus"); +#if 0 +void +kse_init(struct kse *kse1, struct kse *kse2) +{ +} + +void +thread_init(struct thread *thread1, struct thread *thread2) +{ +} + +void +ksegrp_init(struct ksegrp *ksegrp1, struct ksegrp *ksegrp2) +{ +} +#endif + int -fork1(p1, flags, procp) - struct proc *p1; /* parent proc */ +fork1(td, flags, procp) + struct thread *td; /* parent proc */ int flags; struct proc **procp; /* child proc */ { @@ -223,6 +240,7 @@ fork1(p1, flags, procp) static int pidchecked = 0; struct forklist *ep; struct filedesc *fd; + struct proc *p1 = td->td_proc; GIANT_REQUIRED; @@ -235,16 +253,16 @@ fork1(p1, flags, procp) * certain parts of a process from itself. */ if ((flags & RFPROC) == 0) { - vm_forkproc(p1, 0, flags); + vm_forkproc(td, 0, flags); /* * Close all file descriptors. */ if (flags & RFCFDG) { struct filedesc *fdtmp; - fdtmp = fdinit(p1); + fdtmp = fdinit(td); /* XXXKSE */ PROC_LOCK(p1); - fdfree(p1); + fdfree(td); /* XXXKSE */ p1->p_fd = fdtmp; PROC_UNLOCK(p1); } @@ -255,9 +273,9 @@ fork1(p1, flags, procp) if (flags & RFFDG) { if (p1->p_fd->fd_refcnt > 1) { struct filedesc *newfd; - newfd = fdcopy(p1); + newfd = fdcopy(td); PROC_LOCK(p1); - fdfree(p1); + fdfree(td); p1->p_fd = newfd; PROC_UNLOCK(p1); } @@ -401,13 +419,42 @@ again: */ bzero(&p2->p_startzero, (unsigned) ((caddr_t)&p2->p_endzero - (caddr_t)&p2->p_startzero)); + bzero(&p2->p_kse.ke_startzero, + (unsigned) ((caddr_t)&p2->p_kse.ke_endzero + - (caddr_t)&p2->p_kse.ke_startzero)); + bzero(&p2->p_thread.td_startzero, + (unsigned) ((caddr_t)&p2->p_thread.td_endzero + - (caddr_t)&p2->p_thread.td_startzero)); + bzero(&p2->p_ksegrp.kg_startzero, + (unsigned) ((caddr_t)&p2->p_ksegrp.kg_endzero + - (caddr_t)&p2->p_ksegrp.kg_startzero)); PROC_LOCK(p1); bcopy(&p1->p_startcopy, &p2->p_startcopy, (unsigned) ((caddr_t)&p2->p_endcopy - (caddr_t)&p2->p_startcopy)); + + bcopy(&p1->p_kse.ke_startcopy, &p2->p_kse.ke_startcopy, + (unsigned) ((caddr_t)&p2->p_kse.ke_endcopy + - (caddr_t)&p2->p_kse.ke_startcopy)); + + bcopy(&p1->p_thread.td_startcopy, &p2->p_thread.td_startcopy, + (unsigned) ((caddr_t)&p2->p_thread.td_endcopy + - (caddr_t)&p2->p_thread.td_startcopy)); + + bcopy(&p1->p_ksegrp.kg_startcopy, &p2->p_ksegrp.kg_startcopy, + (unsigned) ((caddr_t)&p2->p_ksegrp.kg_endcopy + - (caddr_t)&p2->p_ksegrp.kg_startcopy)); PROC_UNLOCK(p1); + /* + * XXXKSE Theoretically only the running thread would get copied + * Others in the kernel would be 'aborted' in the child. + * i.e return E*something* + */ + proc_linkup(p2); + mtx_init(&p2->p_mtx, "process lock", MTX_DEF); PROC_LOCK(p2); + /* note.. XXXKSE no pcb or u-area yet */ /* * Duplicate sub-structures as needed. @@ -433,7 +480,7 @@ again: if (flags & RFSIGSHARE) { p2->p_procsig = p1->p_procsig; p2->p_procsig->ps_refcnt++; - if (p1->p_sigacts == &p1->p_addr->u_sigacts) { + if (p1->p_sigacts == &p1->p_uarea->u_sigacts) { struct sigacts *newsigacts; PROC_UNLOCK(p1); @@ -450,7 +497,7 @@ again: * the shared p_procsig->ps_sigacts. */ p2->p_sigacts = newsigacts; - *p2->p_sigacts = p1->p_addr->u_sigacts; + *p2->p_sigacts = p1->p_uarea->u_sigacts; } } else { PROC_UNLOCK(p1); @@ -476,9 +523,9 @@ again: VREF(p2->p_textvp); if (flags & RFCFDG) - fd = fdinit(p1); + fd = fdinit(td); else if (flags & RFFDG) - fd = fdcopy(p1); + fd = fdcopy(td); else fd = fdshare(p1); PROC_LOCK(p2); @@ -531,10 +578,10 @@ again: sx_xunlock(&proctree_lock); PROC_LOCK(p2); LIST_INIT(&p2->p_children); - LIST_INIT(&p2->p_contested); + LIST_INIT(&p2->p_thread.td_contested); /* XXXKSE only 1 thread? */ callout_init(&p2->p_itcallout, 0); - callout_init(&p2->p_slpcallout, 1); + callout_init(&p2->p_thread.td_slpcallout, 1); /* XXXKSE */ PROC_LOCK(p1); #ifdef KTRACE @@ -556,9 +603,10 @@ again: /* * set priority of child to be that of parent + * XXXKSE hey! copying the estcpu seems dodgy.. should split it.. */ mtx_lock_spin(&sched_lock); - p2->p_estcpu = p1->p_estcpu; + p2->p_ksegrp.kg_estcpu = p1->p_ksegrp.kg_estcpu; mtx_unlock_spin(&sched_lock); /* @@ -573,7 +621,7 @@ again: * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) */ - vm_forkproc(p1, p2, flags); + vm_forkproc(td, p2, flags); if (flags == (RFFDG | RFPROC)) { cnt.v_forks++; @@ -609,7 +657,7 @@ again: if ((flags & RFSTOPPED) == 0) { mtx_lock_spin(&sched_lock); p2->p_stat = SRUN; - setrunqueue(p2); + setrunqueue(&p2->p_thread); mtx_unlock_spin(&sched_lock); } @@ -708,14 +756,13 @@ fork_exit(callout, arg, frame) void *arg; struct trapframe *frame; { - struct proc *p; - - p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; /* * Setup the sched_lock state so that we can release it. */ - sched_lock.mtx_lock = (uintptr_t)p; + sched_lock.mtx_lock = (uintptr_t)td; sched_lock.mtx_recurse = 0; /* * XXX: We really shouldn't have to do this. @@ -760,15 +807,15 @@ fork_exit(callout, arg, frame) * first parameter and is called when returning to a new userland process. */ void -fork_return(p, frame) - struct proc *p; +fork_return(td, frame) + struct thread *td; struct trapframe *frame; { - userret(p, frame, 0); + userret(td, frame, 0); #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) { - ktrsysret(p->p_tracep, SYS_fork, 0, 0); + if (KTRPOINT(td->td_proc, KTR_SYSRET)) { + ktrsysret(td->td_proc->p_tracep, SYS_fork, 0, 0); } #endif mtx_assert(&Giant, MA_NOTOWNED); diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c index c1482bb..b37e27a 100644 --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -46,13 +46,13 @@ idle_setup(void *dummy) SLIST_FOREACH(gd, &cpuhead, gd_allcpu) { error = kthread_create(idle_proc, NULL, &p, RFSTOPPED | RFHIGHPID, "idle: cpu%d", gd->gd_cpuid); - gd->gd_idleproc = p; - if (gd->gd_curproc == NULL) - gd->gd_curproc = p; + gd->gd_idlethread = &p->p_thread; + if (gd->gd_curthread == NULL) + gd->gd_curthread = gd->gd_idlethread; #else error = kthread_create(idle_proc, NULL, &p, RFSTOPPED | RFHIGHPID, "idle"); - PCPU_SET(idleproc, p); + PCPU_SET(idlethread, &p->p_thread); #endif if (error) panic("idle_setup: kthread_create error %d\n", error); diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index f5ba010..15ae4ff 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -118,25 +118,27 @@ static void ithread_update(struct ithd *ithd) { struct intrhand *ih; + struct thread *td; struct proc *p; int entropy; mtx_assert(&ithd->it_lock, MA_OWNED); - p = ithd->it_proc; - if (p == NULL) + td = ithd->it_td; + if (td == NULL) return; + p = td->td_proc; strncpy(p->p_comm, ithd->it_name, sizeof(ithd->it_name)); ih = TAILQ_FIRST(&ithd->it_handlers); if (ih == NULL) { - p->p_pri.pri_level = PRI_MAX_ITHD; + td->td_ksegrp->kg_pri.pri_level = PRI_MAX_ITHD; ithd->it_flags &= ~IT_ENTROPY; return; } entropy = 0; - p->p_pri.pri_level = ih->ih_pri; - p->p_pri.pri_native = ih->ih_pri; + td->td_ksegrp->kg_pri.pri_level = ih->ih_pri; + td->td_ksegrp->kg_pri.pri_native = ih->ih_pri; TAILQ_FOREACH(ih, &ithd->it_handlers, ih_next) { if (strlen(p->p_comm) + strlen(ih->ih_name) + 1 < sizeof(p->p_comm)) { @@ -166,6 +168,7 @@ ithread_create(struct ithd **ithread, int vector, int flags, void (*disable)(int), void (*enable)(int), const char *fmt, ...) { struct ithd *ithd; + struct thread *td; struct proc *p; int error; va_list ap; @@ -194,11 +197,12 @@ ithread_create(struct ithd **ithread, int vector, int flags, free(ithd, M_ITHREAD); return (error); } - p->p_pri.pri_class = PRI_ITHD; - p->p_pri.pri_level = PRI_MAX_ITHD; + td = &p->p_thread; /* XXXKSE */ + td->td_ksegrp->kg_pri.pri_class = PRI_ITHD; + td->td_ksegrp->kg_pri.pri_level = PRI_MAX_ITHD; p->p_stat = SWAIT; - ithd->it_proc = p; - p->p_ithd = ithd; + ithd->it_td = td; + td->td_ithd = ithd; if (ithread != NULL) *ithread = ithd; mtx_unlock(&ithd->it_lock); @@ -211,9 +215,13 @@ int ithread_destroy(struct ithd *ithread) { + struct thread *td; + struct proc *p; if (ithread == NULL) return (EINVAL); + td = ithread->it_td; + p = td->td_proc; mtx_lock(&ithread->it_lock); if (!TAILQ_EMPTY(&ithread->it_handlers)) { mtx_unlock(&ithread->it_lock); @@ -221,9 +229,9 @@ ithread_destroy(struct ithd *ithread) } ithread->it_flags |= IT_DEAD; mtx_lock_spin(&sched_lock); - if (ithread->it_proc->p_stat == SWAIT) { - ithread->it_proc->p_stat = SRUN; - setrunqueue(ithread->it_proc); + if (p->p_stat == SWAIT) { + p->p_stat = SRUN; /* XXXKSE */ + setrunqueue(td); } mtx_unlock_spin(&sched_lock); mtx_unlock(&ithread->it_lock); @@ -319,7 +327,7 @@ ok: * handler as being dead and let the ithread do the actual removal. */ mtx_lock_spin(&sched_lock); - if (ithread->it_proc->p_stat != SWAIT) { + if (ithread->it_td->td_proc->p_stat != SWAIT) { handler->ih_flags |= IH_DEAD; /* @@ -343,6 +351,7 @@ int ithread_schedule(struct ithd *ithread, int do_switch) { struct int_entropy entropy; + struct thread *td; struct proc *p; /* @@ -357,12 +366,13 @@ ithread_schedule(struct ithd *ithread, int do_switch) */ if (harvest.interrupt && ithread->it_flags & IT_ENTROPY) { entropy.vector = ithread->it_vector; - entropy.proc = CURPROC; + entropy.proc = curthread->td_proc;; random_harvest(&entropy, sizeof(entropy), 2, 0, RANDOM_INTERRUPT); } - p = ithread->it_proc; + td = ithread->it_td; + p = td->td_proc; KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name)); CTR3(KTR_INTR, __func__ ": pid %d: (%s) need = %d", p->p_pid, p->p_comm, ithread->it_need); @@ -380,14 +390,14 @@ ithread_schedule(struct ithd *ithread, int do_switch) if (p->p_stat == SWAIT) { CTR1(KTR_INTR, __func__ ": setrunqueue %d", p->p_pid); p->p_stat = SRUN; - setrunqueue(p); - if (do_switch && curproc->p_stat == SRUN) { - if (curproc != PCPU_GET(idleproc)) - setrunqueue(curproc); - curproc->p_stats->p_ru.ru_nivcsw++; + setrunqueue(td); /* XXXKSE */ + if (do_switch && curthread->td_proc->p_stat == SRUN) { + if (curthread != PCPU_GET(idlethread)) + setrunqueue(curthread); + curthread->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); } else - curproc->p_sflag |= PS_NEEDRESCHED; + curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; } else { CTR3(KTR_INTR, __func__ ": pid %d: it_need %d, state %d", p->p_pid, ithread->it_need, p->p_stat); @@ -439,7 +449,7 @@ swi_sched(void *cookie, int flags) atomic_add_int(&cnt.v_intr, 1); /* one more global interrupt */ CTR3(KTR_INTR, "swi_sched pid %d(%s) need=%d", - it->it_proc->p_pid, it->it_proc->p_comm, it->it_need); + it->it_td->td_proc->p_pid, it->it_td->td_proc->p_comm, it->it_need); /* * Set ih_need for this handler so that if the ithread is already @@ -461,11 +471,13 @@ ithread_loop(void *arg) { struct ithd *ithd; /* our thread context */ struct intrhand *ih; /* and our interrupt handler chain */ + struct thread *td; struct proc *p; - p = curproc; + td = curthread; + p = td->td_proc; ithd = (struct ithd *)arg; /* point to myself */ - KASSERT(ithd->it_proc == p && p->p_ithd == ithd, + KASSERT(ithd->it_td == td && td->td_ithd == ithd, (__func__ ": ithread and proc linkage out of sync")); /* @@ -479,7 +491,7 @@ ithread_loop(void *arg) if (ithd->it_flags & IT_DEAD) { CTR2(KTR_INTR, __func__ ": pid %d: (%s) exiting", p->p_pid, p->p_comm); - p->p_ithd = NULL; + td->td_ithd = NULL; mtx_destroy(&ithd->it_lock); mtx_lock(&Giant); free(ithd, M_ITHREAD); @@ -559,9 +571,9 @@ start_softintr(void *dummy) swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, 0, &vm_ih)) panic("died while creating standard software ithreads"); - PROC_LOCK(clk_ithd->it_proc); - clk_ithd->it_proc->p_flag |= P_NOLOAD; - PROC_UNLOCK(clk_ithd->it_proc); + PROC_LOCK(clk_ithd->it_td->td_proc); + clk_ithd->it_td->td_proc->p_flag |= P_NOLOAD; + PROC_UNLOCK(clk_ithd->it_td->td_proc); } SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index abe5e0f..c1d9470 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -48,12 +48,13 @@ SYSCTL_INT(_jail, OID_AUTO, sysvipc_allowed, CTLFLAG_RW, * MPSAFE */ int -jail(p, uap) - struct proc *p; +jail(td, uap) + struct thread *td; struct jail_args /* { syscallarg(struct jail *) jail; } */ *uap; { + struct proc *p = td->td_proc; int error; struct prison *pr; struct jail j; @@ -79,7 +80,7 @@ jail(p, uap) pr->pr_ip = j.ip_number; ca.path = j.path; - error = chroot(p, &ca); + error = chroot(td, &ca); if (error) goto bail; diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 7e8e702..cb715da 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -81,7 +81,7 @@ kthread_create(void (*func)(void *), void *arg, if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */) panic("kthread_create called too soon"); - error = fork1(&proc0, RFMEM | RFFDG | RFPROC | RFSTOPPED | flags, &p2); + error = fork1(thread0, RFMEM | RFFDG | RFPROC | RFSTOPPED | flags, &p2); if (error) return error; @@ -102,14 +102,14 @@ kthread_create(void (*func)(void *), void *arg, va_end(ap); /* call the processes' main()... */ - cpu_set_fork_handler(p2, func, arg); + cpu_set_fork_handler(&p2->p_thread, func, arg); /* XXXKSE */ /* Delay putting it on the run queue until now. */ mtx_lock_spin(&sched_lock); p2->p_sflag |= PS_INMEM; if (!(flags & RFSTOPPED)) { p2->p_stat = SRUN; - setrunqueue(p2); + setrunqueue(&p2->p_thread); /* XXXKSE */ } mtx_unlock_spin(&sched_lock); @@ -125,7 +125,7 @@ kthread_exit(int ecode) proc_reparent(curproc, initproc); PROC_UNLOCK(curproc); sx_xunlock(&proctree_lock); - exit1(curproc, W_EXITCODE(ecode, 0)); + exit1(curthread, W_EXITCODE(ecode, 0)); } /* diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 9b97944..6297f9b 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -251,11 +251,12 @@ struct ktrace_args { #endif /* ARGSUSED */ int -ktrace(curp, uap) - struct proc *curp; +ktrace(td, uap) + struct thread *td; register struct ktrace_args *uap; { #ifdef KTRACE + struct proc *curp = td->td_proc; register struct vnode *vp = NULL; register struct proc *p; struct pgrp *pg; @@ -271,7 +272,7 @@ ktrace(curp, uap) /* * an operation which requires a file argument. */ - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, curp); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td); flags = FREAD | FWRITE | O_NOFOLLOW; error = vn_open(&nd, &flags, 0); if (error) { @@ -280,9 +281,9 @@ ktrace(curp, uap) } NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - VOP_UNLOCK(vp, 0, curp); + VOP_UNLOCK(vp, 0, td); if (vp->v_type != VREG) { - (void) vn_close(vp, FREAD|FWRITE, curp->p_ucred, curp); + (void) vn_close(vp, FREAD|FWRITE, curp->p_ucred, td); curp->p_traceflag &= ~KTRFAC_ACTIVE; return (EACCES); } @@ -298,7 +299,7 @@ ktrace(curp, uap) p->p_tracep = NULL; p->p_traceflag = 0; (void) vn_close(vp, FREAD|FWRITE, - p->p_ucred, p); + p->p_ucred, td); } else error = EPERM; } @@ -349,7 +350,7 @@ ktrace(curp, uap) error = EPERM; done: if (vp != NULL) - (void) vn_close(vp, FWRITE, curp->p_ucred, curp); + (void) vn_close(vp, FWRITE, curp->p_ucred, td); curp->p_traceflag &= ~KTRFAC_ACTIVE; return (error); #else @@ -362,10 +363,11 @@ done: */ /* ARGSUSED */ int -utrace(curp, uap) - struct proc *curp; +utrace(td, uap) + struct thread *td; register struct utrace_args *uap; { + #ifdef KTRACE struct ktr_header *kth; struct proc *p = curproc; /* XXX */ @@ -474,7 +476,8 @@ ktrwrite(vp, kth, uio) { struct uio auio; struct iovec aiov[2]; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; /* XXX */ struct mount *mp; int error; @@ -488,7 +491,7 @@ ktrwrite(vp, kth, uio) aiov[0].iov_len = sizeof(struct ktr_header); auio.uio_resid = sizeof(struct ktr_header); auio.uio_iovcnt = 1; - auio.uio_procp = curproc; + auio.uio_td = curthread; if (kth->ktr_len > 0) { auio.uio_iovcnt++; aiov[1].iov_base = kth->ktr_buffer; @@ -498,14 +501,14 @@ ktrwrite(vp, kth, uio) kth->ktr_len += uio->uio_resid; } vn_start_write(vp, &mp, V_WAIT); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - (void)VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + (void)VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, p->p_ucred); if (error == 0 && uio != NULL) { - (void)VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + (void)VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); error = VOP_WRITE(vp, uio, IO_UNIT | IO_APPEND, p->p_ucred); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); if (!error) return; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index bf6face..353d811 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -354,14 +354,14 @@ linker_find_file_by_name(const char* filename) goto out; sprintf(koname, "%s.ko", filename); - lockmgr(&lock, LK_SHARED, 0, curproc); + lockmgr(&lock, LK_SHARED, 0, curthread); TAILQ_FOREACH(lf, &linker_files, link) { if (!strcmp(lf->filename, koname)) break; if (!strcmp(lf->filename, filename)) break; } - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); out: if (koname) @@ -374,11 +374,11 @@ linker_find_file_by_id(int fileid) { linker_file_t lf = 0; - lockmgr(&lock, LK_SHARED, 0, curproc); + lockmgr(&lock, LK_SHARED, 0, curthread); TAILQ_FOREACH(lf, &linker_files, link) if (lf->id == fileid) break; - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); return lf; } @@ -392,7 +392,7 @@ linker_make_file(const char* pathname, linker_class_t lc) filename = linker_basename(pathname); KLD_DPF(FILE, ("linker_make_file: new file, filename=%s\n", filename)); - lockmgr(&lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&lock, LK_EXCLUSIVE, 0, curthread); lf = (linker_file_t) kobj_create((kobj_class_t) lc, M_LINKER, M_WAITOK); if (!lf) goto out; @@ -410,7 +410,7 @@ linker_make_file(const char* pathname, linker_class_t lc) TAILQ_INSERT_TAIL(&linker_files, lf, link); out: - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); return lf; } @@ -428,7 +428,7 @@ linker_file_unload(linker_file_t file) return EPERM; KLD_DPF(FILE, ("linker_file_unload: lf->refs=%d\n", file->refs)); - lockmgr(&lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&lock, LK_EXCLUSIVE, 0, curthread); if (file->refs == 1) { KLD_DPF(FILE, ("linker_file_unload: file is unloading, informing modules\n")); /* @@ -443,7 +443,7 @@ linker_file_unload(linker_file_t file) if ((error = module_unload(mod)) != 0) { KLD_DPF(FILE, ("linker_file_unload: module %x vetoes unload\n", mod)); - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); goto out; } @@ -453,7 +453,7 @@ linker_file_unload(linker_file_t file) file->refs--; if (file->refs > 0) { - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); goto out; } @@ -471,7 +471,7 @@ linker_file_unload(linker_file_t file) } TAILQ_REMOVE(&linker_files, file, link); - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); if (file->deps) { for (i = 0; i < file->ndeps; i++) @@ -683,21 +683,21 @@ linker_ddb_symbol_values(c_linker_sym_t sym, linker_symval_t *symval) * MPSAFE */ int -kldload(struct proc* p, struct kldload_args* uap) +kldload(struct thread* td, struct kldload_args* uap) { char *kldname, *modname; char *pathname = NULL; linker_file_t lf; int error = 0; - p->p_retval[0] = -1; + td->td_retval[0] = -1; if (securelevel > 0) /* redundant, but that's OK */ return EPERM; mtx_lock(&Giant); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) goto out; pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); @@ -720,7 +720,7 @@ kldload(struct proc* p, struct kldload_args* uap) goto out; lf->userrefs++; - p->p_retval[0] = lf->id; + td->td_retval[0] = lf->id; out: if (pathname) @@ -733,7 +733,7 @@ out: * MPSAFE */ int -kldunload(struct proc* p, struct kldunload_args* uap) +kldunload(struct thread* td, struct kldunload_args* uap) { linker_file_t lf; int error = 0; @@ -743,7 +743,7 @@ kldunload(struct proc* p, struct kldunload_args* uap) mtx_lock(&Giant); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) goto out; lf = linker_find_file_by_id(SCARG(uap, fileid)); @@ -770,7 +770,7 @@ out: * MPSAFE */ int -kldfind(struct proc* p, struct kldfind_args* uap) +kldfind(struct thread* td, struct kldfind_args* uap) { char* pathname; const char *filename; @@ -778,8 +778,7 @@ kldfind(struct proc* p, struct kldfind_args* uap) int error = 0; mtx_lock(&Giant); - - p->p_retval[0] = -1; + td->td_retval[0] = -1; pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); if ((error = copyinstr(SCARG(uap, file), pathname, MAXPATHLEN, NULL)) != 0) @@ -789,7 +788,7 @@ kldfind(struct proc* p, struct kldfind_args* uap) lf = linker_find_file_by_name(filename); if (lf) - p->p_retval[0] = lf->id; + td->td_retval[0] = lf->id; else error = ENOENT; @@ -804,7 +803,7 @@ out: * MPSAFE */ int -kldnext(struct proc* p, struct kldnext_args* uap) +kldnext(struct thread* td, struct kldnext_args* uap) { linker_file_t lf; int error = 0; @@ -813,18 +812,18 @@ kldnext(struct proc* p, struct kldnext_args* uap) if (SCARG(uap, fileid) == 0) { if (TAILQ_FIRST(&linker_files)) - p->p_retval[0] = TAILQ_FIRST(&linker_files)->id; + td->td_retval[0] = TAILQ_FIRST(&linker_files)->id; else - p->p_retval[0] = 0; + td->td_retval[0] = 0; goto out; } lf = linker_find_file_by_id(SCARG(uap, fileid)); if (lf) { if (TAILQ_NEXT(lf, link)) - p->p_retval[0] = TAILQ_NEXT(lf, link)->id; + td->td_retval[0] = TAILQ_NEXT(lf, link)->id; else - p->p_retval[0] = 0; + td->td_retval[0] = 0; } else { error = ENOENT; } @@ -837,7 +836,7 @@ out: * MPSAFE */ int -kldstat(struct proc* p, struct kldstat_args* uap) +kldstat(struct thread* td, struct kldstat_args* uap) { linker_file_t lf; int error = 0; @@ -879,7 +878,7 @@ kldstat(struct proc* p, struct kldstat_args* uap) if ((error = copyout(&lf->size, &stat->size, sizeof(size_t))) != 0) goto out; - p->p_retval[0] = 0; + td->td_retval[0] = 0; out: mtx_unlock(&Giant); @@ -890,7 +889,7 @@ out: * MPSAFE */ int -kldfirstmod(struct proc* p, struct kldfirstmod_args* uap) +kldfirstmod(struct thread* td, struct kldfirstmod_args* uap) { linker_file_t lf; int error = 0; @@ -899,9 +898,9 @@ kldfirstmod(struct proc* p, struct kldfirstmod_args* uap) lf = linker_find_file_by_id(SCARG(uap, fileid)); if (lf) { if (TAILQ_FIRST(&lf->modules)) - p->p_retval[0] = module_getid(TAILQ_FIRST(&lf->modules)); + td->td_retval[0] = module_getid(TAILQ_FIRST(&lf->modules)); else - p->p_retval[0] = 0; + td->td_retval[0] = 0; } else { error = ENOENT; } @@ -913,7 +912,7 @@ kldfirstmod(struct proc* p, struct kldfirstmod_args* uap) * MPSAFE */ int -kldsym(struct proc *p, struct kldsym_args *uap) +kldsym(struct thread *td, struct kldsym_args *uap) { char *symstr = NULL; c_linker_sym_t sym; @@ -1309,7 +1308,7 @@ linker_lookup_file(const char *path, int pathlen, const char *name, int namelen, struct vattr *vap) { struct nameidata nd; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ char *result, **cpp, *sep; int error, len, extlen, reclen, flags; enum vtype type; @@ -1332,16 +1331,16 @@ linker_lookup_file(const char *path, int pathlen, * Attempt to open the file, and return the path if we succeed * and it's a regular file. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, td); flags = FREAD; error = vn_open(&nd, &flags, 0); if (error == 0) { NDFREE(&nd, NDF_ONLY_PNBUF); type = nd.ni_vp->v_type; if (vap) - VOP_GETATTR(nd.ni_vp, vap, p->p_ucred, p); - VOP_UNLOCK(nd.ni_vp, 0, p); - vn_close(nd.ni_vp, FREAD, p->p_ucred, p); + VOP_GETATTR(nd.ni_vp, vap, td->td_proc->p_ucred, td); + VOP_UNLOCK(nd.ni_vp, 0, td); + vn_close(nd.ni_vp, FREAD, td->td_proc->p_ucred, td); if (type == VREG) return(result); } @@ -1363,8 +1362,8 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname, int modnamelen, struct mod_depend *verinfo) { - struct proc *p = curproc; - struct ucred *cred = p ? p->p_ucred : NULL; + struct thread *td = curthread; /* XXX */ + struct ucred *cred = td ? td->td_proc->p_ucred : NULL; struct nameidata nd; struct vattr vattr, mattr; u_char *hints = NULL; @@ -1380,17 +1379,17 @@ linker_hints_lookup(const char *path, int pathlen, pathbuf = malloc(reclen, M_LINKER, M_WAITOK); snprintf(pathbuf, reclen, "%.*s%s%s", pathlen, path, sep, linker_hintfile); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, td); flags = FREAD; error = vn_open(&nd, &flags, 0); if (error) goto bad; NDFREE(&nd, NDF_ONLY_PNBUF); - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); if (nd.ni_vp->v_type != VREG) goto bad; best = cp = NULL; - error = VOP_GETATTR(nd.ni_vp, &vattr, cred, p); + error = VOP_GETATTR(nd.ni_vp, &vattr, cred, td); if (error) goto bad; /* @@ -1404,10 +1403,10 @@ linker_hints_lookup(const char *path, int pathlen, if (hints == NULL) goto bad; error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)hints, vattr.va_size, 0, - UIO_SYSSPACE, IO_NODELOCKED, cred, &reclen, p); + UIO_SYSSPACE, IO_NODELOCKED, cred, &reclen, td); if (error) goto bad; - vn_close(nd.ni_vp, FREAD, cred, p); + vn_close(nd.ni_vp, FREAD, cred, td); nd.ni_vp = NULL; if (reclen != 0) { printf("can't read %d\n", reclen); @@ -1472,7 +1471,7 @@ bad: if (hints) free(hints, M_TEMP); if (nd.ni_vp != NULL) - vn_close(nd.ni_vp, FREAD, cred, p); + vn_close(nd.ni_vp, FREAD, cred, td); /* * If nothing found or hints is absent - fallback to the old way * by using "kldname[.ko]" as module name. diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 147508c..3f8373b 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -208,14 +208,14 @@ acquire(struct lock *lkp, int extflags, int wanted) { */ int #ifndef DEBUG_LOCKS -lockmgr(lkp, flags, interlkp, p) +lockmgr(lkp, flags, interlkp, td) #else -debuglockmgr(lkp, flags, interlkp, p, name, file, line) +debuglockmgr(lkp, flags, interlkp, td, name, file, line) #endif struct lock *lkp; u_int flags; struct mtx *interlkp; - struct proc *p; + struct thread *td; #ifdef DEBUG_LOCKS const char *name; /* Name of lock function */ const char *file; /* Name of file call is from */ @@ -228,13 +228,13 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) CTR5(KTR_LOCKMGR, "lockmgr(): lkp == %p (lk_wmesg == \"%s\"), flags == 0x%x, " - "interlkp == %p, p == %p", lkp, lkp->lk_wmesg, flags, interlkp, p); + "interlkp == %p, td == %p", lkp, lkp->lk_wmesg, flags, interlkp, td); error = 0; - if (p == NULL) + if (td == NULL) pid = LK_KERNPROC; else - pid = p->p_pid; + pid = td->td_proc->p_pid; mtx_lock(lkp->lk_interlock); if (flags & LK_INTERLOCK) { @@ -257,19 +257,19 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) * while there is an exclusive lock holder or while an * exclusive lock request or upgrade request is in progress. * - * However, if P_DEADLKTREAT is set, we override exclusive + * However, if TDF_DEADLKTREAT is set, we override exclusive * lock requests or upgrade requests ( but not the exclusive * lock itself ). */ if (lkp->lk_lockholder != pid) { lockflags = LK_HAVE_EXCL; - if (p) { - PROC_LOCK(p); - if (!(p->p_flag & P_DEADLKTREAT)) { + if (td) { + PROC_LOCK(td->td_proc); + if (!(td->td_flags & TDF_DEADLKTREAT)) { lockflags |= LK_WANT_EXCL | LK_WANT_UPGRADE; } - PROC_UNLOCK(p); + PROC_UNLOCK(td->td_proc); } error = acquire(lkp, extflags, lockflags); if (error) @@ -560,15 +560,15 @@ lockdestroy(lkp) * Determine the status of a lock. */ int -lockstatus(lkp, p) +lockstatus(lkp, td) struct lock *lkp; - struct proc *p; + struct thread *td; { int lock_type = 0; mtx_lock(lkp->lk_interlock); if (lkp->lk_exclusivecount != 0) { - if (p == NULL || lkp->lk_lockholder == p->p_pid) + if (td == NULL || lkp->lk_lockholder == td->td_proc->p_pid) lock_type = LK_EXCLUSIVE; else lock_type = LK_EXCLOTHER; diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c index c60705f..3bbb4d0 100644 --- a/sys/kern/kern_lockf.c +++ b/sys/kern/kern_lockf.c @@ -242,25 +242,29 @@ lf_setlock(lock) if ((lock->lf_flags & F_POSIX) && (block->lf_flags & F_POSIX)) { register struct proc *wproc; + struct thread *td; register struct lockf *waitblock; int i = 0; /* The block is waiting on something */ + /* XXXKSE this is not complete under threads */ wproc = (struct proc *)block->lf_id; mtx_lock_spin(&sched_lock); - while (wproc->p_wchan && - (wproc->p_wmesg == lockstr) && - (i++ < maxlockdepth)) { - waitblock = (struct lockf *)wproc->p_wchan; - /* Get the owner of the blocking lock */ - waitblock = waitblock->lf_next; - if ((waitblock->lf_flags & F_POSIX) == 0) - break; - wproc = (struct proc *)waitblock->lf_id; - if (wproc == (struct proc *)lock->lf_id) { - mtx_unlock_spin(&sched_lock); - free(lock, M_LOCKF); - return (EDEADLK); + FOREACH_THREAD_IN_PROC(wproc, td) { + while (td->td_wchan && + (td->td_wmesg == lockstr) && + (i++ < maxlockdepth)) { + waitblock = (struct lockf *)td->td_wchan; + /* Get the owner of the blocking lock */ + waitblock = waitblock->lf_next; + if ((waitblock->lf_flags & F_POSIX) == 0) + break; + wproc = (struct proc *)waitblock->lf_id; + if (wproc == (struct proc *)lock->lf_id) { + mtx_unlock_spin(&sched_lock); + free(lock, M_LOCKF); + return (EDEADLK); + } } } mtx_unlock_spin(&sched_lock); diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 5f9ca0c..0446b1f 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -144,7 +144,7 @@ malloc(size, type, flags) #if defined(INVARIANTS) if (flags == M_WAITOK) - KASSERT(curproc->p_intr_nesting_level == 0, + KASSERT(curthread->td_intr_nesting_level == 0, ("malloc(M_WAITOK) in interrupt context")); #endif indx = BUCKETINDX(size); diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 3fbdb72..f3651d2 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -222,18 +222,18 @@ module_setspecific(module_t mod, modspecific_t *datap) * MPSAFE */ int -modnext(struct proc* p, struct modnext_args* uap) +modnext(struct thread *td, struct modnext_args *uap) { module_t mod; int error = 0; mtx_lock(&Giant); - p->p_retval[0] = -1; + td->td_retval[0] = -1; if (SCARG(uap, modid) == 0) { mod = TAILQ_FIRST(&modules); if (mod) - p->p_retval[0] = mod->id; + td->td_retval[0] = mod->id; else error = ENOENT; goto done2; @@ -246,9 +246,9 @@ modnext(struct proc* p, struct modnext_args* uap) } if (TAILQ_NEXT(mod, link)) - p->p_retval[0] = TAILQ_NEXT(mod, link)->id; + td->td_retval[0] = TAILQ_NEXT(mod, link)->id; else - p->p_retval[0] = 0; + td->td_retval[0] = 0; done2: mtx_unlock(&Giant); return (error); @@ -258,12 +258,12 @@ done2: * MPSAFE */ int -modfnext(struct proc* p, struct modfnext_args* uap) +modfnext(struct thread *td, struct modfnext_args *uap) { module_t mod; int error; - p->p_retval[0] = -1; + td->td_retval[0] = -1; mtx_lock(&Giant); @@ -273,9 +273,9 @@ modfnext(struct proc* p, struct modfnext_args* uap) } else { error = 0; if (TAILQ_NEXT(mod, flink)) - p->p_retval[0] = TAILQ_NEXT(mod, flink)->id; + td->td_retval[0] = TAILQ_NEXT(mod, flink)->id; else - p->p_retval[0] = 0; + td->td_retval[0] = 0; } mtx_unlock(&Giant); return (error); @@ -292,7 +292,7 @@ struct module_stat_v1 { * MPSAFE */ int -modstat(struct proc* p, struct modstat_args* uap) +modstat(struct thread *td, struct modstat_args *uap) { module_t mod; int error = 0; @@ -340,7 +340,7 @@ modstat(struct proc* p, struct modstat_args* uap) goto out; } - p->p_retval[0] = 0; + td->td_retval[0] = 0; out: mtx_unlock(&Giant); @@ -351,7 +351,7 @@ out: * MPSAFE */ int -modfind(struct proc* p, struct modfind_args* uap) +modfind(struct thread *td, struct modfind_args *uap) { int error = 0; char name[MAXMODNAME]; @@ -365,7 +365,7 @@ modfind(struct proc* p, struct modfind_args* uap) if (mod == NULL) error = ENOENT; else - p->p_retval[0] = mod->id; + td->td_retval[0] = mod->id; mtx_unlock(&Giant); out: return error; diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 646d99a..bbcac94 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -86,9 +86,9 @@ #define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED) #define mtx_owner(m) (mtx_unowned((m)) ? NULL \ - : (struct proc *)((m)->mtx_lock & MTX_FLAGMASK)) + : (struct thread *)((m)->mtx_lock & MTX_FLAGMASK)) -#define SET_PRIO(p, pri) (p)->p_pri.pri_level = (pri) +#define SET_PRIO(td, pri) (td)->td_ksegrp->kg_pri.pri_level = (pri) /* * Lock classes for sleep and spin mutexes. @@ -105,113 +105,118 @@ struct lock_class lock_class_mtx_spin = { /* * Prototypes for non-exported routines. */ -static void propagate_priority(struct proc *); +static void propagate_priority(struct thread *); static void -propagate_priority(struct proc *p) +propagate_priority(struct thread *td) { - int pri = p->p_pri.pri_level; - struct mtx *m = p->p_blocked; + struct ksegrp *kg = td->td_ksegrp; + int pri = kg->kg_pri.pri_level; + struct mtx *m = td->td_blocked; mtx_assert(&sched_lock, MA_OWNED); for (;;) { - struct proc *p1; + struct thread *td1; - p = mtx_owner(m); + td = mtx_owner(m); - if (p == NULL) { + if (td == NULL) { /* * This really isn't quite right. Really - * ought to bump priority of process that + * ought to bump priority of thread that * next acquires the mutex. */ MPASS(m->mtx_lock == MTX_CONTESTED); return; } - MPASS(p->p_magic == P_MAGIC); - KASSERT(p->p_stat != SSLEEP, ("sleeping process owns a mutex")); - if (p->p_pri.pri_level <= pri) + MPASS(td->td_proc->p_magic == P_MAGIC); + KASSERT(td->td_proc->p_stat != SSLEEP, ("sleeping thread owns a mutex")); + if (kg->kg_pri.pri_level <= pri) /* lower is higher priority */ return; /* - * Bump this process' priority. + * Bump this thread's priority. */ - SET_PRIO(p, pri); + SET_PRIO(td, pri); /* * If lock holder is actually running, just bump priority. */ - if (p->p_oncpu != NOCPU) { - MPASS(p->p_stat == SRUN || p->p_stat == SZOMB || p->p_stat == SSTOP); + /* XXXKSE this test is not sufficient */ + if (td->td_kse && (td->td_kse->ke_oncpu != NOCPU)) { + MPASS(td->td_proc->p_stat == SRUN + || td->td_proc->p_stat == SZOMB + || td->td_proc->p_stat == SSTOP); return; } #ifndef SMP /* - * For UP, we check to see if p is curproc (this shouldn't + * For UP, we check to see if td is curthread (this shouldn't * ever happen however as it would mean we are in a deadlock.) */ - KASSERT(p != curproc, ("Deadlock detected")); + KASSERT(td != curthread, ("Deadlock detected")); #endif /* - * If on run queue move to new run queue, and - * quit. + * If on run queue move to new run queue, and quit. + * XXXKSE this gets a lot more complicated under threads + * but try anyhow. */ - if (p->p_stat == SRUN) { - MPASS(p->p_blocked == NULL); - remrunqueue(p); - setrunqueue(p); + if (td->td_proc->p_stat == SRUN) { + MPASS(td->td_blocked == NULL); + remrunqueue(td); + setrunqueue(td); return; } /* * If we aren't blocked on a mutex, we should be. */ - KASSERT(p->p_stat == SMTX, ( + KASSERT(td->td_proc->p_stat == SMTX, ( "process %d(%s):%d holds %s but isn't blocked on a mutex\n", - p->p_pid, p->p_comm, p->p_stat, + td->td_proc->p_pid, td->td_proc->p_comm, td->td_proc->p_stat, m->mtx_object.lo_name)); /* - * Pick up the mutex that p is blocked on. + * Pick up the mutex that td is blocked on. */ - m = p->p_blocked; + m = td->td_blocked; MPASS(m != NULL); /* - * Check if the proc needs to be moved up on + * Check if the thread needs to be moved up on * the blocked chain */ - if (p == TAILQ_FIRST(&m->mtx_blocked)) { + if (td == TAILQ_FIRST(&m->mtx_blocked)) { continue; } - p1 = TAILQ_PREV(p, procqueue, p_procq); - if (p1->p_pri.pri_level <= pri) { + td1 = TAILQ_PREV(td, threadqueue, td_blkq); + if (td1->td_ksegrp->kg_pri.pri_level <= pri) { continue; } /* - * Remove proc from blocked chain and determine where - * it should be moved up to. Since we know that p1 has - * a lower priority than p, we know that at least one - * process in the chain has a lower priority and that - * p1 will thus not be NULL after the loop. + * Remove thread from blocked chain and determine where + * it should be moved up to. Since we know that td1 has + * a lower priority than td, we know that at least one + * thread in the chain has a lower priority and that + * td1 will thus not be NULL after the loop. */ - TAILQ_REMOVE(&m->mtx_blocked, p, p_procq); - TAILQ_FOREACH(p1, &m->mtx_blocked, p_procq) { - MPASS(p1->p_magic == P_MAGIC); - if (p1->p_pri.pri_level > pri) + TAILQ_REMOVE(&m->mtx_blocked, td, td_blkq); + TAILQ_FOREACH(td1, &m->mtx_blocked, td_blkq) { + MPASS(td1->td_proc->p_magic == P_MAGIC); + if (td1->td_ksegrp->kg_pri.pri_level > pri) break; } - MPASS(p1 != NULL); - TAILQ_INSERT_BEFORE(p1, p, p_procq); + MPASS(td1 != NULL); + TAILQ_INSERT_BEFORE(td1, td, td_blkq); CTR4(KTR_LOCK, "propagate_priority: p %p moved before %p on [%p] %s", - p, p1, m, m->mtx_object.lo_name); + td, td1, m, m->mtx_object.lo_name); } } @@ -257,7 +262,7 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) { int rval; - MPASS(curproc != NULL); + MPASS(curthread != NULL); /* * _mtx_trylock does not accept MTX_NOSWITCH option. @@ -265,7 +270,7 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) KASSERT((opts & MTX_NOSWITCH) == 0, ("mtx_trylock() called with invalid option flag(s) %d", opts)); - rval = _obtain_lock(m, curproc); + rval = _obtain_lock(m, curthread); LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line); if (rval) { @@ -291,9 +296,10 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) void _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) { - struct proc *p = curproc; + struct thread *td = curthread; + struct ksegrp *kg = td->td_ksegrp; - if ((m->mtx_lock & MTX_FLAGMASK) == (uintptr_t)p) { + if ((m->mtx_lock & MTX_FLAGMASK) == (uintptr_t)td) { m->mtx_recurse++; atomic_set_ptr(&m->mtx_lock, MTX_RECURSED); if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -306,9 +312,9 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->mtx_object.lo_name, (void *)m->mtx_lock, file, line); - while (!_obtain_lock(m, p)) { + while (!_obtain_lock(m, td)) { uintptr_t v; - struct proc *p1; + struct thread *td1; mtx_lock_spin(&sched_lock); /* @@ -322,15 +328,15 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) /* * The mutex was marked contested on release. This means that - * there are processes blocked on it. + * there are threads blocked on it. */ if (v == MTX_CONTESTED) { - p1 = TAILQ_FIRST(&m->mtx_blocked); - MPASS(p1 != NULL); - m->mtx_lock = (uintptr_t)p | MTX_CONTESTED; + td1 = TAILQ_FIRST(&m->mtx_blocked); + MPASS(td1 != NULL); + m->mtx_lock = (uintptr_t)td | MTX_CONTESTED; - if (p1->p_pri.pri_level < p->p_pri.pri_level) - SET_PRIO(p, p1->p_pri.pri_level); + if (td1->td_ksegrp->kg_pri.pri_level < kg->kg_pri.pri_level) + SET_PRIO(td, td1->td_ksegrp->kg_pri.pri_level); mtx_unlock_spin(&sched_lock); return; } @@ -357,8 +363,8 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) * If we're borrowing an interrupted thread's VM context, we * must clean up before going to sleep. */ - if (p->p_ithd != NULL) { - struct ithd *it = p->p_ithd; + if (td->td_ithd != NULL) { + struct ithd *it = td->td_ithd; if (it->it_interrupted) { if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -374,39 +380,39 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) * Put us on the list of threads blocked on this mutex. */ if (TAILQ_EMPTY(&m->mtx_blocked)) { - p1 = (struct proc *)(m->mtx_lock & MTX_FLAGMASK); - LIST_INSERT_HEAD(&p1->p_contested, m, mtx_contested); - TAILQ_INSERT_TAIL(&m->mtx_blocked, p, p_procq); + td1 = (struct thread *)(m->mtx_lock & MTX_FLAGMASK); + LIST_INSERT_HEAD(&td1->td_contested, m, mtx_contested); + TAILQ_INSERT_TAIL(&m->mtx_blocked, td, td_blkq); } else { - TAILQ_FOREACH(p1, &m->mtx_blocked, p_procq) - if (p1->p_pri.pri_level > p->p_pri.pri_level) + TAILQ_FOREACH(td1, &m->mtx_blocked, td_blkq) + if (td1->td_ksegrp->kg_pri.pri_level > kg->kg_pri.pri_level) break; - if (p1) - TAILQ_INSERT_BEFORE(p1, p, p_procq); + if (td1) + TAILQ_INSERT_BEFORE(td1, td, td_blkq); else - TAILQ_INSERT_TAIL(&m->mtx_blocked, p, p_procq); + TAILQ_INSERT_TAIL(&m->mtx_blocked, td, td_blkq); } /* * Save who we're blocked on. */ - p->p_blocked = m; - p->p_mtxname = m->mtx_object.lo_name; - p->p_stat = SMTX; - propagate_priority(p); + td->td_blocked = m; + td->td_mtxname = m->mtx_object.lo_name; + td->td_proc->p_stat = SMTX; + propagate_priority(td); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR3(KTR_LOCK, - "_mtx_lock_sleep: p %p blocked on [%p] %s", p, m, + "_mtx_lock_sleep: p %p blocked on [%p] %s", td, m, m->mtx_object.lo_name); - p->p_stats->p_ru.ru_nvcsw++; + td->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR3(KTR_LOCK, "_mtx_lock_sleep: p %p free from blocked on [%p] %s", - p, m, m->mtx_object.lo_name); + td, m, m->mtx_object.lo_name); mtx_unlock_spin(&sched_lock); } @@ -430,7 +436,7 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file, CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); for (;;) { - if (_obtain_lock(m, curproc)) + if (_obtain_lock(m, curthread)) break; /* Give interrupts a chance while we spin. */ @@ -467,11 +473,13 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file, void _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) { - struct proc *p, *p1; + struct thread *td, *td1; struct mtx *m1; int pri; + struct ksegrp *kg; - p = curproc; + td = curthread; + kg = td->td_ksegrp; if (mtx_recursed(m)) { if (--(m->mtx_recurse) == 0) @@ -485,11 +493,11 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); - p1 = TAILQ_FIRST(&m->mtx_blocked); - MPASS(p->p_magic == P_MAGIC); - MPASS(p1->p_magic == P_MAGIC); + td1 = TAILQ_FIRST(&m->mtx_blocked); + MPASS(td->td_proc->p_magic == P_MAGIC); + MPASS(td1->td_proc->p_magic == P_MAGIC); - TAILQ_REMOVE(&m->mtx_blocked, p1, p_procq); + TAILQ_REMOVE(&m->mtx_blocked, td1, td_blkq); if (TAILQ_EMPTY(&m->mtx_blocked)) { LIST_REMOVE(m, mtx_contested); @@ -500,28 +508,28 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) atomic_store_rel_ptr(&m->mtx_lock, (void *)MTX_CONTESTED); pri = PRI_MAX; - LIST_FOREACH(m1, &p->p_contested, mtx_contested) { - int cp = TAILQ_FIRST(&m1->mtx_blocked)->p_pri.pri_level; + LIST_FOREACH(m1, &td->td_contested, mtx_contested) { + int cp = TAILQ_FIRST(&m1->mtx_blocked)->td_ksegrp->kg_pri.pri_level; if (cp < pri) pri = cp; } - if (pri > p->p_pri.pri_native) - pri = p->p_pri.pri_native; - SET_PRIO(p, pri); + if (pri > kg->kg_pri.pri_native) + pri = kg->kg_pri.pri_native; + SET_PRIO(td, pri); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p contested setrunqueue %p", - m, p1); + m, td1); - p1->p_blocked = NULL; - p1->p_stat = SRUN; - setrunqueue(p1); + td1->td_blocked = NULL; + td1->td_proc->p_stat = SRUN; + setrunqueue(td1); - if ((opts & MTX_NOSWITCH) == 0 && p1->p_pri.pri_level < pri) { + if ((opts & MTX_NOSWITCH) == 0 && td1->td_ksegrp->kg_pri.pri_level < pri) { #ifdef notyet - if (p->p_ithd != NULL) { - struct ithd *it = p->p_ithd; + if (td->td_ithd != NULL) { + struct ithd *it = td->td_ithd; if (it->it_interrupted) { if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -532,13 +540,13 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) } } #endif - setrunqueue(p); + setrunqueue(td); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p switching out lock=%p", m, (void *)m->mtx_lock); - p->p_stats->p_ru.ru_nivcsw++; + td->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p resuming lock=%p", diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 3d689db..4701d2f 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -276,7 +276,7 @@ struct ntp_adjtime_args { * MPSAFE */ int -ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) +ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) { struct timex ntv; /* temporary structure */ long freq; /* frequency ns/s) */ @@ -300,7 +300,7 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) mtx_lock(&Giant); modes = ntv.modes; if (modes) - error = suser(p); + error = suser_td(td); if (error) goto done2; s = splclock(); @@ -416,9 +416,9 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap) time_status & STA_PPSJITTER) || (time_status & STA_PPSFREQ && time_status & (STA_PPSWANDER | STA_PPSERROR))) { - p->p_retval[0] = TIME_ERROR; + td->td_retval[0] = TIME_ERROR; } else { - p->p_retval[0] = time_state; + td->td_retval[0] = time_state; } done2: mtx_unlock(&Giant); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 858b37a..5b0e960 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -115,6 +115,72 @@ procinit() } /* + * link up a process structure and it's inbuilt threads etc. + */ +void +proc_linkup(struct proc *p) +{ + struct thread *td; + + td = &p->p_thread; + + /**** lists headed in the proc structure ****/ + /* ALL KSEGRPs in this process */ + TAILQ_INIT( &p->p_ksegrps); /* all ksegrps in proc */ + TAILQ_INSERT_HEAD(&p->p_ksegrps, &p->p_ksegrp, kg_ksegrp); + + /* All threads in this process (an optimisation) */ + TAILQ_INIT( &p->p_threads); /* all threads in proc */ + TAILQ_INSERT_HEAD(&p->p_threads, &p->p_thread, td_plist); + + /**** Lists headed in the KSEGROUP structure ****/ + /* all thread in this ksegroup */ + TAILQ_INIT( &p->p_ksegrp.kg_threads); + TAILQ_INSERT_HEAD(&p->p_ksegrp.kg_threads, &p->p_thread, td_kglist); + + /* All runnable threads not assigned to a particular KSE */ + /* XXXKSE THIS MAY GO AWAY.. KSEs are never unassigned */ + TAILQ_INIT( &p->p_ksegrp.kg_runq); /* links with td_runq */ + + /* All threads presently not runnable (Thread starts this way) */ + TAILQ_INIT( &p->p_ksegrp.kg_slpq); /* links with td_runq */ + TAILQ_INSERT_HEAD(&p->p_ksegrp.kg_slpq, &p->p_thread, td_runq); + /*p->p_thread.td_flags &= ~TDF_ONRUNQ;*/ + + /* all KSEs in this ksegroup */ + TAILQ_INIT( &p->p_ksegrp.kg_kseq); /* all kses in ksegrp */ + TAILQ_INSERT_HEAD(&p->p_ksegrp.kg_kseq, &p->p_kse, ke_kglist); + + /* KSE starts out idle *//* XXXKSE */ + TAILQ_INIT( &p->p_ksegrp.kg_rq); /* all kses in ksegrp */ + TAILQ_INIT( &p->p_ksegrp.kg_iq); /* all kses in ksegrp */ +#if 0 + TAILQ_INSERT_HEAD(&p->p_ksegrp.kg_iq, &p->p_kse, ke_kgrlist); +#endif /* is running, not idle */ + /*p->p_kse.ke_flags &= &KEF_ONRUNQ;*/ + + /**** Lists headed in the KSE structure ****/ + /* runnable threads assigned to this kse */ + TAILQ_INIT( &p->p_kse.ke_runq); /* links with td_runq */ + + p->p_thread.td_proc = p; + p->p_kse.ke_proc = p; + p->p_ksegrp.kg_proc = p; + + p->p_thread.td_ksegrp = &p->p_ksegrp; + p->p_kse.ke_ksegrp = &p->p_ksegrp; + + p->p_thread.td_last_kse = &p->p_kse; + p->p_thread.td_kse = &p->p_kse; + + p->p_kse.ke_thread = &p->p_thread; + + p->p_ksegrp.kg_runnable = 1; + p->p_ksegrp.kg_kses = 1; + p->p_ksegrp.kg_runq_kses = 1; /* XXXKSE change name */ +} + +/* * Is p an inferior of the current process? */ int @@ -410,6 +476,7 @@ fill_kinfo_proc(p, kp) struct proc *p; struct kinfo_proc *kp; { + struct thread *td; struct tty *tp; struct session *sp; @@ -418,7 +485,7 @@ fill_kinfo_proc(p, kp) kp->ki_structsize = sizeof(*kp); kp->ki_paddr = p; PROC_LOCK(p); - kp->ki_addr = p->p_addr; + kp->ki_addr =/* p->p_addr; */0; /* XXXKSE */ kp->ki_args = p->p_args; kp->ki_tracep = p->p_tracep; kp->ki_textvp = p->p_textvp; @@ -446,7 +513,9 @@ fill_kinfo_proc(p, kp) kp->ki_size = vm->vm_map.size; kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/ if (p->p_sflag & PS_INMEM) - kp->ki_rssize += UPAGES; + kp->ki_rssize += UAREA_PAGES; + FOREACH_THREAD_IN_PROC(p, td) /* XXXKSE: thread swapout check */ + kp->ki_rssize += KSTACK_PAGES; kp->ki_swrss = vm->vm_swrss; kp->ki_tsize = vm->vm_tsize; kp->ki_dsize = vm->vm_dsize; @@ -460,28 +529,33 @@ fill_kinfo_proc(p, kp) kp->ki_childtime.tv_usec = p->p_stats->p_cru.ru_utime.tv_usec + p->p_stats->p_cru.ru_stime.tv_usec; } - if (p->p_wmesg != NULL) - strncpy(kp->ki_wmesg, p->p_wmesg, sizeof(kp->ki_wmesg) - 1); + if (p->p_thread.td_wmesg != NULL) + strncpy(kp->ki_wmesg, p->p_thread.td_wmesg, sizeof(kp->ki_wmesg) - 1); if (p->p_stat == SMTX) { kp->ki_kiflag |= KI_MTXBLOCK; - strncpy(kp->ki_mtxname, p->p_mtxname, + strncpy(kp->ki_mtxname, p->p_thread.td_mtxname, sizeof(kp->ki_mtxname) - 1); } kp->ki_stat = p->p_stat; kp->ki_sflag = p->p_sflag; - kp->ki_pctcpu = p->p_pctcpu; - kp->ki_estcpu = p->p_estcpu; - kp->ki_slptime = p->p_slptime; kp->ki_swtime = p->p_swtime; - kp->ki_wchan = p->p_wchan; kp->ki_traceflag = p->p_traceflag; - kp->ki_pri = p->p_pri; - kp->ki_nice = p->p_nice; - kp->ki_runtime = p->p_runtime; kp->ki_pid = p->p_pid; - kp->ki_rqindex = p->p_rqindex; - kp->ki_oncpu = p->p_oncpu; - kp->ki_lastcpu = p->p_lastcpu; + /* vvv XXXKSE */ + kp->ki_runtime = p->p_runtime; + kp->ki_pctcpu = p->p_kse.ke_pctcpu; + kp->ki_estcpu = p->p_ksegrp.kg_estcpu; + kp->ki_slptime = p->p_ksegrp.kg_slptime; + kp->ki_wchan = p->p_thread.td_wchan; + kp->ki_pri = p->p_ksegrp.kg_pri; + kp->ki_nice = p->p_ksegrp.kg_nice; + kp->ki_rqindex = p->p_kse.ke_rqindex; + kp->ki_oncpu = p->p_kse.ke_oncpu; + kp->ki_lastcpu = p->p_thread.td_lastcpu; + kp->ki_tdflags = p->p_thread.td_flags; + kp->ki_pcb = p->p_thread.td_pcb; + kp->ki_kstack = (void *)p->p_thread.td_kstack; + /* ^^^ XXXKSE */ mtx_unlock_spin(&sched_lock); sp = NULL; if (p->p_pgrp) { diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index baa73dd..0c2939c 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -81,16 +81,17 @@ struct getpid_args { */ /* ARGSUSED */ int -getpid(p, uap) - struct proc *p; +getpid(td, uap) + struct thread *td; struct getpid_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = p->p_pid; + td->td_retval[0] = p->p_pid; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) PROC_LOCK(p); - p->p_retval[1] = p->p_pptr->p_pid; + td->td_retval[1] = p->p_pptr->p_pid; PROC_UNLOCK(p); #endif mtx_unlock(&Giant); @@ -111,14 +112,15 @@ struct getppid_args { */ /* ARGSUSED */ int -getppid(p, uap) - struct proc *p; +getppid(td, uap) + struct thread *td; struct getppid_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); PROC_LOCK(p); - p->p_retval[0] = p->p_pptr->p_pid; + td->td_retval[0] = p->p_pptr->p_pid; PROC_UNLOCK(p); mtx_unlock(&Giant); return (0); @@ -138,13 +140,14 @@ struct getpgrp_args { * MPSAFE */ int -getpgrp(p, uap) - struct proc *p; +getpgrp(td, uap) + struct thread *td; struct getpgrp_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = p->p_pgrp->pg_id; + td->td_retval[0] = p->p_pgrp->pg_id; mtx_unlock(&Giant); return (0); } @@ -160,16 +163,17 @@ struct getpgid_args { * MPSAFE */ int -getpgid(p, uap) - struct proc *p; +getpgid(td, uap) + struct thread *td; struct getpgid_args *uap; { + struct proc *p = td->td_proc; struct proc *pt; int error = 0; mtx_lock(&Giant); if (uap->pid == 0) - p->p_retval[0] = p->p_pgrp->pg_id; + td->td_retval[0] = p->p_pgrp->pg_id; else { if ((pt = pfind(uap->pid)) == NULL) { error = ESRCH; @@ -179,7 +183,7 @@ getpgid(p, uap) PROC_UNLOCK(pt); goto done2; } - p->p_retval[0] = pt->p_pgrp->pg_id; + td->td_retval[0] = pt->p_pgrp->pg_id; PROC_UNLOCK(pt); } done2: @@ -200,16 +204,17 @@ struct getsid_args { * MPSAFE */ int -getsid(p, uap) - struct proc *p; +getsid(td, uap) + struct thread *td; struct getsid_args *uap; { + struct proc *p = td->td_proc; struct proc *pt; int error = 0; mtx_lock(&Giant); if (uap->pid == 0) { - p->p_retval[0] = p->p_session->s_sid; + td->td_retval[0] = p->p_session->s_sid; } else { if ((pt = pfind(uap->pid)) == NULL) { error = ESRCH; @@ -219,7 +224,7 @@ getsid(p, uap) PROC_UNLOCK(pt); goto done2; } - p->p_retval[0] = pt->p_session->s_sid; + td->td_retval[0] = pt->p_session->s_sid; PROC_UNLOCK(pt); } done2: @@ -242,15 +247,16 @@ struct getuid_args { */ /* ARGSUSED */ int -getuid(p, uap) - struct proc *p; +getuid(td, uap) + struct thread *td; struct getuid_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = p->p_ucred->cr_ruid; + td->td_retval[0] = p->p_ucred->cr_ruid; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) - p->p_retval[1] = p->p_ucred->cr_uid; + td->td_retval[1] = p->p_ucred->cr_uid; #endif mtx_unlock(&Giant); return (0); @@ -267,13 +273,12 @@ struct geteuid_args { /* ARGSUSED */ int -geteuid(p, uap) - struct proc *p; +geteuid(td, uap) + struct thread *td; struct geteuid_args *uap; { - mtx_lock(&Giant); - p->p_retval[0] = p->p_ucred->cr_uid; + td->td_retval[0] = td->td_proc->p_ucred->cr_uid; mtx_unlock(&Giant); return (0); } @@ -292,15 +297,16 @@ struct getgid_args { */ /* ARGSUSED */ int -getgid(p, uap) - struct proc *p; +getgid(td, uap) + struct thread *td; struct getgid_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = p->p_ucred->cr_rgid; + td->td_retval[0] = p->p_ucred->cr_rgid; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) - p->p_retval[1] = p->p_ucred->cr_groups[0]; + td->td_retval[1] = p->p_ucred->cr_groups[0]; #endif mtx_unlock(&Giant); return (0); @@ -322,13 +328,14 @@ struct getegid_args { */ /* ARGSUSED */ int -getegid(p, uap) - struct proc *p; +getegid(td, uap) + struct thread *td; struct getegid_args *uap; { + struct proc *p = td->td_proc; mtx_lock(&Giant); - p->p_retval[0] = p->p_ucred->cr_groups[0]; + td->td_retval[0] = p->p_ucred->cr_groups[0]; mtx_unlock(&Giant); return (0); } @@ -343,18 +350,19 @@ struct getgroups_args { * MPSAFE */ int -getgroups(p, uap) - struct proc *p; +getgroups(td, uap) + struct thread *td; register struct getgroups_args *uap; { struct ucred *cred; + struct proc *p = td->td_proc; u_int ngrp; int error = 0; mtx_lock(&Giant); cred = p->p_ucred; if ((ngrp = uap->gidsetsize) == 0) { - p->p_retval[0] = cred->cr_ngroups; + td->td_retval[0] = cred->cr_ngroups; error = 0; goto done2; } @@ -367,7 +375,7 @@ getgroups(p, uap) (caddr_t)uap->gidset, ngrp * sizeof(gid_t)))) { goto done2; } - p->p_retval[0] = ngrp; + td->td_retval[0] = ngrp; done2: mtx_unlock(&Giant); return (error); @@ -384,18 +392,19 @@ struct setsid_args { */ /* ARGSUSED */ int -setsid(p, uap) - register struct proc *p; +setsid(td, uap) + register struct thread *td; struct setsid_args *uap; { int error; + struct proc *p = td->td_proc; mtx_lock(&Giant); if (p->p_pgid == p->p_pid || pgfind(p->p_pid)) { error = EPERM; } else { (void)enterpgrp(p, p->p_pid, 1); - p->p_retval[0] = p->p_pid; + td->td_retval[0] = p->p_pid; error = 0; } mtx_unlock(&Giant); @@ -426,10 +435,11 @@ struct setpgid_args { */ /* ARGSUSED */ int -setpgid(curp, uap) - struct proc *curp; +setpgid(td, uap) + struct thread *td; register struct setpgid_args *uap; { + struct proc *curp = td->td_proc; register struct proc *targp; /* target process */ register struct pgrp *pgrp; /* target pgrp */ int error; @@ -510,10 +520,11 @@ struct setuid_args { */ /* ARGSUSED */ int -setuid(p, uap) - struct proc *p; +setuid(td, uap) + struct thread *td; struct setuid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; uid_t uid; int error = 0; @@ -607,10 +618,11 @@ struct seteuid_args { */ /* ARGSUSED */ int -seteuid(p, uap) - struct proc *p; +seteuid(td, uap) + struct thread *td; struct seteuid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; uid_t euid; int error = 0; @@ -650,10 +662,11 @@ struct setgid_args { */ /* ARGSUSED */ int -setgid(p, uap) - struct proc *p; +setgid(td, uap) + struct thread *td; struct setgid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; gid_t gid; int error = 0; @@ -741,10 +754,11 @@ struct setegid_args { */ /* ARGSUSED */ int -setegid(p, uap) - struct proc *p; +setegid(td, uap) + struct thread *td; struct setegid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; gid_t egid; int error = 0; @@ -781,10 +795,11 @@ struct setgroups_args { */ /* ARGSUSED */ int -setgroups(p, uap) - struct proc *p; +setgroups(td, uap) + struct thread *td; struct setgroups_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; u_int ngrp; int error; @@ -839,10 +854,11 @@ struct setreuid_args { */ /* ARGSUSED */ int -setreuid(p, uap) - register struct proc *p; +setreuid(td, uap) + register struct thread *td; struct setreuid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; uid_t ruid, euid; int error = 0; @@ -892,10 +908,11 @@ struct setregid_args { */ /* ARGSUSED */ int -setregid(p, uap) - register struct proc *p; +setregid(td, uap) + register struct thread *td; struct setregid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; gid_t rgid, egid; int error = 0; @@ -952,10 +969,11 @@ struct setresuid_args { */ /* ARGSUSED */ int -setresuid(p, uap) - register struct proc *p; +setresuid(td, uap) + register struct thread *td; struct setresuid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; uid_t ruid, euid, suid; int error; @@ -1017,10 +1035,11 @@ struct setresgid_args { */ /* ARGSUSED */ int -setresgid(p, uap) - register struct proc *p; +setresgid(td, uap) + register struct thread *td; struct setresgid_args *uap; { + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; gid_t rgid, egid, sgid; int error; @@ -1076,11 +1095,12 @@ struct getresuid_args { */ /* ARGSUSED */ int -getresuid(p, uap) - register struct proc *p; +getresuid(td, uap) + register struct thread *td; struct getresuid_args *uap; { struct ucred *cred; + struct proc *p = td->td_proc; int error1 = 0, error2 = 0, error3 = 0; mtx_lock(&Giant); @@ -1111,11 +1131,12 @@ struct getresgid_args { */ /* ARGSUSED */ int -getresgid(p, uap) - register struct proc *p; +getresgid(td, uap) + register struct thread *td; struct getresgid_args *uap; { struct ucred *cred; + struct proc *p = td->td_proc; int error1 = 0, error2 = 0, error3 = 0; mtx_lock(&Giant); @@ -1142,10 +1163,12 @@ struct issetugid_args { #endif /* ARGSUSED */ int -issetugid(p, uap) - register struct proc *p; +issetugid(td, uap) + register struct thread *td; struct issetugid_args *uap; { + struct proc *p = td->td_proc; + /* * Note: OpenBSD sets a P_SUGIDEXEC flag set at execve() time, * we use P_SUGID because we consider changing the owners as @@ -1154,7 +1177,7 @@ issetugid(p, uap) * a user without an exec - programs cannot know *everything* * that libc *might* have put in their data segment. */ - p->p_retval[0] = (p->p_flag & P_SUGID) ? 1 : 0; + td->td_retval[0] = (p->p_flag & P_SUGID) ? 1 : 0; return (0); } @@ -1162,8 +1185,8 @@ issetugid(p, uap) * MPSAFE */ int -__setugid(p, uap) - struct proc *p; +__setugid(td, uap) + struct thread *td; struct __setugid_args *uap; { #ifdef REGRESSION @@ -1172,10 +1195,10 @@ __setugid(p, uap) mtx_lock(&Giant); switch (uap->flag) { case 0: - p->p_flag &= ~P_SUGID; + td->td_proc->p_flag &= ~P_SUGID; break; case 1: - p->p_flag |= P_SUGID; + td->td_proc->p_flag |= P_SUGID; break; default: error = EINVAL; @@ -1231,6 +1254,30 @@ suser(p) return suser_xxx(0, p, 0); } +/* + * version for when the thread pointer is available and not the proc. + * (saves having to include proc.h into every file that needs to do the change.) + */ +int +suser_td(td) + + struct thread *td; +{ + return suser_xxx(0, td->td_proc, 0); +} + +/* + * wrapper to use if you have the thread on hand but not the proc. + */ +int +suser_xxx_td(cred, td, flag) + struct ucred *cred; + struct thread *td; + int flag; +{ + return(suser_xxx(cred, td->td_proc, flag)); +} + int suser_xxx(cred, proc, flag) struct ucred *cred; @@ -1566,11 +1613,12 @@ struct getlogin_args { */ /* ARGSUSED */ int -getlogin(p, uap) - struct proc *p; +getlogin(td, uap) + struct thread *td; struct getlogin_args *uap; { int error; + struct proc *p = td->td_proc; mtx_lock(&Giant); if (uap->namelen > MAXLOGNAME) @@ -1594,10 +1642,11 @@ struct setlogin_args { */ /* ARGSUSED */ int -setlogin(p, uap) - struct proc *p; +setlogin(td, uap) + struct thread *td; struct setlogin_args *uap; { + struct proc *p = td->td_proc; int error; char logintmp[MAXLOGNAME]; diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 3b65ace..093e4c2 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -84,10 +84,11 @@ struct getpriority_args { * MPSAFE */ int -getpriority(curp, uap) - struct proc *curp; +getpriority(td, uap) + struct thread *td; register struct getpriority_args *uap; { + struct proc *curp = td->td_proc; register struct proc *p; register int low = PRIO_MAX + 1; int error = 0; @@ -97,13 +98,13 @@ getpriority(curp, uap) switch (uap->which) { case PRIO_PROCESS: if (uap->who == 0) - low = curp->p_nice; + low = td->td_ksegrp->kg_nice; else { p = pfind(uap->who); if (p == NULL) break; if (p_cansee(curp, p) == 0) - low = p->p_nice; + low = p->p_ksegrp.kg_nice /* XXXKSE */ ; PROC_UNLOCK(p); } break; @@ -116,8 +117,8 @@ getpriority(curp, uap) else if ((pg = pgfind(uap->who)) == NULL) break; LIST_FOREACH(p, &pg->pg_members, p_pglist) { - if (!p_cansee(curp, p) && p->p_nice < low) - low = p->p_nice; + if (!p_cansee(curp, p) && p->p_ksegrp.kg_nice /* XXXKSE */ < low) + low = p->p_ksegrp.kg_nice /* XXXKSE */ ; } break; } @@ -129,8 +130,8 @@ getpriority(curp, uap) LIST_FOREACH(p, &allproc, p_list) if (!p_cansee(curp, p) && p->p_ucred->cr_uid == uap->who && - p->p_nice < low) - low = p->p_nice; + p->p_ksegrp.kg_nice /* XXXKSE */ < low) + low = p->p_ksegrp.kg_nice /* XXXKSE */ ; sx_sunlock(&allproc_lock); break; @@ -140,7 +141,7 @@ getpriority(curp, uap) } if (low == PRIO_MAX + 1 && error == 0) error = ESRCH; - curp->p_retval[0] = low; + td->td_retval[0] = low; mtx_unlock(&Giant); return (error); } @@ -157,10 +158,11 @@ struct setpriority_args { */ /* ARGSUSED */ int -setpriority(curp, uap) - struct proc *curp; +setpriority(td, uap) + struct thread *td; register struct setpriority_args *uap; { + struct proc *curp = td->td_proc; register struct proc *p; int found = 0, error = 0; @@ -201,12 +203,13 @@ setpriority(curp, uap) if (uap->who == 0) uap->who = curp->p_ucred->cr_uid; sx_slock(&allproc_lock); - LIST_FOREACH(p, &allproc, p_list) + FOREACH_PROC_IN_SYSTEM(p) { if (p->p_ucred->cr_uid == uap->who && !p_cansee(curp, p)) { error = donice(curp, p, uap->prio); found++; } + } sx_sunlock(&allproc_lock); break; @@ -233,10 +236,10 @@ donice(curp, chgp, n) n = PRIO_MAX; if (n < PRIO_MIN) n = PRIO_MIN; - if (n < chgp->p_nice && suser(curp)) + if (n < chgp->p_ksegrp.kg_nice /* XXXKSE */ && suser(curp)) return (EACCES); - chgp->p_nice = n; - (void)resetpriority(chgp); + chgp->p_ksegrp.kg_nice /* XXXKSE */ = n; + (void)resetpriority(&chgp->p_ksegrp); /* XXXKSE */ return (0); } @@ -258,10 +261,11 @@ struct rtprio_args { */ /* ARGSUSED */ int -rtprio(curp, uap) - struct proc *curp; +rtprio(td, uap) + struct thread *td; register struct rtprio_args *uap; { + struct proc *curp = td->td_proc; register struct proc *p; struct rtprio rtp; int error; @@ -285,7 +289,7 @@ rtprio(curp, uap) if ((error = p_cansee(curp, p))) break; mtx_lock_spin(&sched_lock); - pri_to_rtp(&p->p_pri, &rtp); + pri_to_rtp(&p->p_ksegrp.kg_pri /* XXXKSE */ , &rtp); mtx_unlock_spin(&sched_lock); error = copyout(&rtp, uap->rtp, sizeof(struct rtprio)); break; @@ -317,7 +321,7 @@ rtprio(curp, uap) } } mtx_lock_spin(&sched_lock); - error = rtp_to_pri(&rtp, &p->p_pri); + error = rtp_to_pri(&rtp, &p->p_ksegrp.kg_pri); mtx_unlock_spin(&sched_lock); break; default: @@ -387,8 +391,8 @@ struct osetrlimit_args { */ /* ARGSUSED */ int -osetrlimit(p, uap) - struct proc *p; +osetrlimit(td, uap) + struct thread *td; register struct osetrlimit_args *uap; { struct orlimit olim; @@ -401,7 +405,7 @@ osetrlimit(p, uap) lim.rlim_cur = olim.rlim_cur; lim.rlim_max = olim.rlim_max; mtx_lock(&Giant); - error = dosetrlimit(p, uap->which, &lim); + error = dosetrlimit(td, uap->which, &lim); mtx_unlock(&Giant); return (error); } @@ -417,10 +421,11 @@ struct ogetrlimit_args { */ /* ARGSUSED */ int -ogetrlimit(p, uap) - struct proc *p; +ogetrlimit(td, uap) + struct thread *td; register struct ogetrlimit_args *uap; { + struct proc *p = td->td_proc; struct orlimit olim; int error; @@ -450,8 +455,8 @@ struct __setrlimit_args { */ /* ARGSUSED */ int -setrlimit(p, uap) - struct proc *p; +setrlimit(td, uap) + struct thread *td; register struct __setrlimit_args *uap; { struct rlimit alim; @@ -461,17 +466,18 @@ setrlimit(p, uap) copyin((caddr_t)uap->rlp, (caddr_t)&alim, sizeof (struct rlimit)))) return (error); mtx_lock(&Giant); - error = dosetrlimit(p, uap->which, &alim); + error = dosetrlimit(td, uap->which, &alim); mtx_unlock(&Giant); return (error); } int -dosetrlimit(p, which, limp) - struct proc *p; +dosetrlimit(td, which, limp) + struct thread *td; u_int which; struct rlimit *limp; { + struct proc *p = td->td_proc; register struct rlimit *alimp; int error; @@ -582,11 +588,12 @@ struct __getrlimit_args { */ /* ARGSUSED */ int -getrlimit(p, uap) - struct proc *p; +getrlimit(td, uap) + struct thread *td; register struct __getrlimit_args *uap; { int error; + struct proc *p = td->td_proc; if (uap->which >= RLIM_NLIMITS) return (EINVAL); @@ -610,85 +617,102 @@ calcru(p, up, sp, ip) { /* {user, system, interrupt, total} {ticks, usec}; previous tu: */ u_int64_t ut, uu, st, su, it, iu, tt, tu, ptu; + u_int64_t uut = 0, sut = 0, iut = 0; int s; struct timeval tv; + struct kse *ke; + struct ksegrp *kg; mtx_assert(&sched_lock, MA_OWNED); /* XXX: why spl-protect ? worst case is an off-by-one report */ - s = splstatclock(); - ut = p->p_uticks; - st = p->p_sticks; - it = p->p_iticks; - splx(s); - tt = ut + st + it; - if (tt == 0) { - st = 1; - tt = 1; - } - - tu = p->p_runtime; - if (p == curproc) { + FOREACH_KSEGRP_IN_PROC(p, kg) { + /* we could accumulate per ksegrp and per process here*/ + FOREACH_KSE_IN_GROUP(kg, ke) { + s = splstatclock(); + ut = ke->ke_uticks; + st = ke->ke_sticks; + it = ke->ke_iticks; + splx(s); + + tt = ut + st + it; + if (tt == 0) { + st = 1; + tt = 1; + } + + tu = p->p_runtime; + if (ke == curthread->td_kse) { /* * Adjust for the current time slice. This is actually fairly * important since the error here is on the order of a time * quantum, which is much greater than the sampling error. + * XXXKSE use a different test due to threads on other + * processors also being 'current'. */ - microuptime(&tv); - if (timevalcmp(&tv, PCPU_PTR(switchtime), <)) - printf("microuptime() went backwards (%ld.%06ld -> %ld.%06ld)\n", - PCPU_GET(switchtime.tv_sec), PCPU_GET(switchtime.tv_usec), - tv.tv_sec, tv.tv_usec); - else - tu += (tv.tv_usec - PCPU_GET(switchtime.tv_usec)) + - (tv.tv_sec - PCPU_GET(switchtime.tv_sec)) * - (int64_t)1000000; - } - ptu = p->p_uu + p->p_su + p->p_iu; - if (tu < ptu || (int64_t)tu < 0) { - /* XXX no %qd in kernel. Truncate. */ - printf("calcru: negative time of %ld usec for pid %d (%s)\n", - (long)tu, p->p_pid, p->p_comm); - tu = ptu; - } + microuptime(&tv); + if (timevalcmp(&tv, PCPU_PTR(switchtime), <)) + printf("microuptime() went backwards (%ld.%06ld -> %ld.%06ld)\n", + PCPU_GET(switchtime.tv_sec), + PCPU_GET(switchtime.tv_usec), + tv.tv_sec, tv.tv_usec); + else + tu += (tv.tv_usec + - PCPU_GET(switchtime.tv_usec)) + + (tv.tv_sec + - PCPU_GET(switchtime.tv_sec)) + * (int64_t)1000000; + } + ptu = ke->ke_uu + ke->ke_su + ke->ke_iu; + if (tu < ptu || (int64_t)tu < 0) { + /* XXX no %qd in kernel. Truncate. */ + printf("calcru: negative time of %ld usec for pid %d (%s)\n", + (long)tu, p->p_pid, p->p_comm); + tu = ptu; + } - /* Subdivide tu. */ - uu = (tu * ut) / tt; - su = (tu * st) / tt; - iu = tu - uu - su; - - /* Enforce monotonicity. */ - if (uu < p->p_uu || su < p->p_su || iu < p->p_iu) { - if (uu < p->p_uu) - uu = p->p_uu; - else if (uu + p->p_su + p->p_iu > tu) - uu = tu - p->p_su - p->p_iu; - if (st == 0) - su = p->p_su; - else { - su = ((tu - uu) * st) / (st + it); - if (su < p->p_su) - su = p->p_su; - else if (uu + su + p->p_iu > tu) - su = tu - uu - p->p_iu; - } - KASSERT(uu + su + p->p_iu <= tu, - ("calcru: monotonisation botch 1")); - iu = tu - uu - su; - KASSERT(iu >= p->p_iu, - ("calcru: monotonisation botch 2")); - } - p->p_uu = uu; - p->p_su = su; - p->p_iu = iu; - - up->tv_sec = uu / 1000000; - up->tv_usec = uu % 1000000; - sp->tv_sec = su / 1000000; - sp->tv_usec = su % 1000000; + /* Subdivide tu. */ + uu = (tu * ut) / tt; + su = (tu * st) / tt; + iu = tu - uu - su; + + /* Enforce monotonicity. */ + if (uu < ke->ke_uu || su < ke->ke_su || iu < ke->ke_iu) { + if (uu < ke->ke_uu) + uu = ke->ke_uu; + else if (uu + ke->ke_su + ke->ke_iu > tu) + uu = tu - ke->ke_su - ke->ke_iu; + if (st == 0) + su = ke->ke_su; + else { + su = ((tu - uu) * st) / (st + it); + if (su < ke->ke_su) + su = ke->ke_su; + else if (uu + su + ke->ke_iu > tu) + su = tu - uu - ke->ke_iu; + } + KASSERT(uu + su + ke->ke_iu <= tu, + ("calcru: monotonisation botch 1")); + iu = tu - uu - su; + KASSERT(iu >= ke->ke_iu, + ("calcru: monotonisation botch 2")); + } + ke->ke_uu = uu; + ke->ke_su = su; + ke->ke_iu = iu; + uut += uu; + sut += su; + iut += iu; + + } /* end kse loop */ + } /* end kseg loop */ + up->tv_sec = uut / 1000000; + up->tv_usec = uut % 1000000; + sp->tv_sec = sut / 1000000; + sp->tv_usec = sut % 1000000; if (ip != NULL) { - ip->tv_sec = iu / 1000000; - ip->tv_usec = iu % 1000000; + ip->tv_sec = iut / 1000000; + ip->tv_usec = iut % 1000000; } } @@ -703,10 +727,11 @@ struct getrusage_args { */ /* ARGSUSED */ int -getrusage(p, uap) - register struct proc *p; +getrusage(td, uap) + register struct thread *td; register struct getrusage_args *uap; { + struct proc *p = td->td_proc; register struct rusage *rup; int error = 0; diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 4dd9c62..61efa8d 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -138,12 +138,12 @@ SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) */ /* ARGSUSED */ int -reboot(struct proc *p, struct reboot_args *uap) +reboot(struct thread *td, struct reboot_args *uap) { int error; mtx_lock(&Giant); - if ((error = suser(p)) == 0) + if ((error = suser_td(td)) == 0) boot(uap->opt); mtx_unlock(&Giant); return (error); @@ -237,7 +237,7 @@ boot(int howto) waittime = 0; printf("\nsyncing disks... "); - sync(&proc0, NULL); + sync(thread0, NULL); /* * With soft updates, some buffers that are @@ -262,13 +262,13 @@ boot(int howto) if (nbusy < pbusy) iter = 0; pbusy = nbusy; - sync(&proc0, NULL); - if (curproc != NULL) { + sync(thread0, NULL); + if (curthread != NULL) { DROP_GIANT_NOSWITCH(); for (subiter = 0; subiter < 50 * iter; subiter++) { mtx_lock_spin(&sched_lock); - setrunqueue(curproc); - curproc->p_stats->p_ru.ru_nvcsw++; + setrunqueue(curthread); + curthread->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); /* Allow interrupt threads to run */ mtx_unlock_spin(&sched_lock); DELAY(1000); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 607c78c..233bdbe 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -74,7 +74,7 @@ #define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ -static int coredump __P((struct proc *)); +static int coredump __P((struct thread *)); static int do_sigaction __P((struct proc *p, int sig, struct sigaction *act, struct sigaction *oact, int old)); static int do_sigprocmask __P((struct proc *p, int how, sigset_t *set, @@ -351,10 +351,11 @@ struct sigaction_args { */ /* ARGSUSED */ int -sigaction(p, uap) - struct proc *p; +sigaction(td, uap) + struct thread *td; register struct sigaction_args *uap; { + struct proc *p = td->td_proc; struct sigaction act, oact; register struct sigaction *actp, *oactp; int error; @@ -390,10 +391,11 @@ struct osigaction_args { */ /* ARGSUSED */ int -osigaction(p, uap) - struct proc *p; +osigaction(td, uap) + struct thread *td; register struct osigaction_args *uap; { + struct proc *p = td->td_proc; struct osigaction sa; struct sigaction nsa, osa; register struct sigaction *nsap, *osap; @@ -534,7 +536,7 @@ do_sigprocmask(p, how, set, oset, old) } /* - * sigprocmask() - MP SAFE + * sigprocmask() - MP SAFE (XXXKSE not under KSE it isn't) */ #ifndef _SYS_SYSPROTO_H_ @@ -545,10 +547,11 @@ struct sigprocmask_args { }; #endif int -sigprocmask(p, uap) - register struct proc *p; +sigprocmask(td, uap) + register struct thread *td; struct sigprocmask_args *uap; { + struct proc *p = td->td_proc; sigset_t set, oset; sigset_t *setp, *osetp; int error; @@ -578,16 +581,17 @@ struct osigprocmask_args { }; #endif int -osigprocmask(p, uap) - register struct proc *p; +osigprocmask(td, uap) + register struct thread *td; struct osigprocmask_args *uap; { + struct proc *p = td->td_proc; sigset_t set, oset; int error; OSIG2SIG(uap->mask, set); error = do_sigprocmask(p, uap->how, &set, &oset, 1); - SIG2OSIG(oset, p->p_retval[0]); + SIG2OSIG(oset, td->td_retval[0]); return (error); } #endif /* COMPAT_43 */ @@ -602,10 +606,11 @@ struct sigpending_args { */ /* ARGSUSED */ int -sigpending(p, uap) - struct proc *p; +sigpending(td, uap) + struct thread *td; struct sigpending_args *uap; { + struct proc *p = td->td_proc; sigset_t siglist; int error; @@ -629,13 +634,15 @@ struct osigpending_args { */ /* ARGSUSED */ int -osigpending(p, uap) - struct proc *p; +osigpending(td, uap) + struct thread *td; struct osigpending_args *uap; { + struct proc *p = td->td_proc; + mtx_lock(&Giant); PROC_LOCK(p); - SIG2OSIG(p->p_siglist, p->p_retval[0]); + SIG2OSIG(p->p_siglist, td->td_retval[0]); PROC_UNLOCK(p); mtx_unlock(&Giant); return (0); @@ -658,10 +665,11 @@ struct osigvec_args { */ /* ARGSUSED */ int -osigvec(p, uap) - struct proc *p; +osigvec(td, uap) + struct thread *td; register struct osigvec_args *uap; { + struct proc *p = td->td_proc; struct sigvec vec; struct sigaction nsa, osa; register struct sigaction *nsap, *osap; @@ -709,17 +717,18 @@ struct osigblock_args { * MPSAFE */ int -osigblock(p, uap) - register struct proc *p; +osigblock(td, uap) + register struct thread *td; struct osigblock_args *uap; { + struct proc *p = td->td_proc; sigset_t set; OSIG2SIG(uap->mask, set); SIG_CANTMASK(set); mtx_lock(&Giant); PROC_LOCK(p); - SIG2OSIG(p->p_sigmask, p->p_retval[0]); + SIG2OSIG(p->p_sigmask, td->td_retval[0]); SIGSETOR(p->p_sigmask, set); PROC_UNLOCK(p); mtx_unlock(&Giant); @@ -735,17 +744,18 @@ struct osigsetmask_args { * MPSAFE */ int -osigsetmask(p, uap) - struct proc *p; +osigsetmask(td, uap) + struct thread *td; struct osigsetmask_args *uap; { + struct proc *p = td->td_proc; sigset_t set; OSIG2SIG(uap->mask, set); SIG_CANTMASK(set); mtx_lock(&Giant); PROC_LOCK(p); - SIG2OSIG(p->p_sigmask, p->p_retval[0]); + SIG2OSIG(p->p_sigmask, td->td_retval[0]); SIGSETLO(p->p_sigmask, set); PROC_UNLOCK(p); mtx_unlock(&Giant); @@ -757,6 +767,9 @@ osigsetmask(p, uap) * Suspend process until signal, providing mask to be set * in the meantime. Note nonstandard calling convention: * libc stub passes mask, not pointer, to save a copyin. + ***** XXXKSE this doesn't make sense under KSE. + ***** Do we suspend the thread or all threads in the process? + ***** How do we suspend threads running NOW on another processor? */ #ifndef _SYS_SYSPROTO_H_ struct sigsuspend_args { @@ -768,10 +781,11 @@ struct sigsuspend_args { */ /* ARGSUSED */ int -sigsuspend(p, uap) - register struct proc *p; +sigsuspend(td, uap) + struct thread *td; struct sigsuspend_args *uap; { + struct proc *p = td->td_proc; sigset_t mask; register struct sigacts *ps; int error; @@ -814,10 +828,11 @@ struct osigsuspend_args { */ /* ARGSUSED */ int -osigsuspend(p, uap) - register struct proc *p; +osigsuspend(td, uap) + struct thread *td; struct osigsuspend_args *uap; { + struct proc *p = td->td_proc; sigset_t mask; register struct sigacts *ps; @@ -850,10 +865,11 @@ struct osigstack_args { */ /* ARGSUSED */ int -osigstack(p, uap) - struct proc *p; +osigstack(td, uap) + struct thread *td; register struct osigstack_args *uap; { + struct proc *p = td->td_proc; struct sigstack ss; int error = 0; @@ -862,7 +878,7 @@ osigstack(p, uap) if (uap->oss != NULL) { PROC_LOCK(p); ss.ss_sp = p->p_sigstk.ss_sp; - ss.ss_onstack = sigonstack(cpu_getstack(p)); + ss.ss_onstack = sigonstack(cpu_getstack(td)); PROC_UNLOCK(p); error = copyout(&ss, uap->oss, sizeof(struct sigstack)); if (error) @@ -896,17 +912,18 @@ struct sigaltstack_args { */ /* ARGSUSED */ int -sigaltstack(p, uap) - struct proc *p; +sigaltstack(td, uap) + struct thread *td; register struct sigaltstack_args *uap; { + struct proc *p = td->td_proc; stack_t ss; int oonstack; int error = 0; mtx_lock(&Giant); - oonstack = sigonstack(cpu_getstack(p)); + oonstack = sigonstack(cpu_getstack(td)); if (uap->oss != NULL) { PROC_LOCK(p); @@ -1027,10 +1044,11 @@ struct kill_args { */ /* ARGSUSED */ int -kill(cp, uap) - register struct proc *cp; +kill(td, uap) + register struct thread *td; register struct kill_args *uap; { + register struct proc *cp = td->td_proc; register struct proc *p; int error = 0; @@ -1080,8 +1098,8 @@ struct okillpg_args { */ /* ARGSUSED */ int -okillpg(p, uap) - struct proc *p; +okillpg(td, uap) + struct thread *td; register struct okillpg_args *uap; { int error; @@ -1089,7 +1107,7 @@ okillpg(p, uap) if ((u_int)uap->signum > _SIG_MAXSIG) return (EINVAL); mtx_lock(&Giant); - error = killpg1(p, uap->signum, uap->pgid, 0); + error = killpg1(td->td_proc, uap->signum, uap->pgid, 0); mtx_unlock(&Giant); return (error); } @@ -1198,6 +1216,8 @@ psignal(p, sig) { register int prop; register sig_t action; + struct thread *td; + struct ksegrp *kg; if (sig > _SIG_MAXSIG || sig <= 0) { printf("psignal: signal %d\n", sig); @@ -1214,9 +1234,9 @@ psignal(p, sig) * if signal event is tracked by procfs, give *that* * a chance, as well. */ - if ((p->p_flag & P_TRACED) || (p->p_stops & S_SIG)) + if ((p->p_flag & P_TRACED) || (p->p_stops & S_SIG)) { action = SIG_DFL; - else { + } else { /* * If the signal is being ignored, * then we forget about it immediately. @@ -1234,10 +1254,27 @@ psignal(p, sig) action = SIG_DFL; } + /* + * bring the priority of a process up if we want it to get + * killed in this lifetime. + * XXXKSE think if a better way to do this. + * + * What we need to do is see if there is a thread that will + * be able to accept the signal. e.g. + * FOREACH_THREAD_IN_PROC() { + * if runnable, we're done + * else pick one at random. + * } + */ + /* XXXKSE + * For now there is one thread per proc. + * Effectively select one sucker thread.. + */ + td = &p->p_thread; mtx_lock_spin(&sched_lock); - if (p->p_nice > NZERO && action == SIG_DFL && (prop & SA_KILL) && - (p->p_flag & P_TRACED) == 0) - p->p_nice = NZERO; + if ((p->p_ksegrp.kg_nice > NZERO) && (action == SIG_DFL) && + (prop & SA_KILL) && ((p->p_flag & P_TRACED) == 0)) + p->p_ksegrp.kg_nice = NZERO; /* XXXKSE */ mtx_unlock_spin(&sched_lock); if (prop & SA_CONT) @@ -1266,6 +1303,7 @@ psignal(p, sig) mtx_unlock_spin(&sched_lock); return; } + switch (p->p_stat) { case SSLEEP: @@ -1275,7 +1313,7 @@ psignal(p, sig) * be noticed when the process returns through * trap() or syscall(). */ - if ((p->p_sflag & PS_SINTR) == 0) { + if ((td->td_flags & TDF_SINTR) == 0) { mtx_unlock_spin(&sched_lock); goto out; } @@ -1357,11 +1395,28 @@ psignal(p, sig) if (action == SIG_CATCH) goto runfast; mtx_lock_spin(&sched_lock); - if (p->p_wchan == NULL) - goto run; - p->p_stat = SSLEEP; - mtx_unlock_spin(&sched_lock); - goto out; + /* + * XXXKSE + * do this for each thread. + */ + if (p->p_flag & P_KSES) { + mtx_assert(&sched_lock, + MA_OWNED | MA_NOTRECURSED); + FOREACH_THREAD_IN_PROC(p, td) { + if (td->td_wchan == NULL) { + setrunnable(td); /* XXXKSE */ + } else { + /* mark it as sleeping */ + } + } + mtx_unlock_spin(&sched_lock); + goto out; + } else { + if (p->p_thread.td_wchan == NULL) + goto run; + p->p_stat = SSLEEP; + mtx_unlock_spin(&sched_lock); + } } if (prop & SA_STOP) { @@ -1378,13 +1433,25 @@ psignal(p, sig) * wakeup so that when it is continued, it will be made * runnable and can look at the signal. But don't make * the process runnable, leave it stopped. + * XXXKSE should we wake ALL blocked threads? */ mtx_lock_spin(&sched_lock); - if (p->p_wchan && p->p_sflag & PS_SINTR) { - if (p->p_sflag & PS_CVWAITQ) - cv_waitq_remove(p); - else - unsleep(p); + if (p->p_flag & P_KSES) { + FOREACH_THREAD_IN_PROC(p, td) { + if (td->td_wchan && (td->td_flags & TDF_SINTR)){ + if (td->td_flags & TDF_CVWAITQ) + cv_waitq_remove(td); + else + unsleep(td); /* XXXKSE */ + } + } + } else { + if (td->td_wchan && td->td_flags & TDF_SINTR) { + if (td->td_flags & TDF_CVWAITQ) + cv_waitq_remove(td); + else + unsleep(td); /* XXXKSE */ + } } mtx_unlock_spin(&sched_lock); goto out; @@ -1396,9 +1463,21 @@ psignal(p, sig) * It will either never be noticed, or noticed very soon. */ if (p->p_stat == SRUN) { - signotify(p); #ifdef SMP - forward_signal(p); + struct kse *ke; + struct thread *td = curthread; + signotify(&p->p_kse); /* XXXKSE */ +/* we should only deliver to one thread.. but which one? */ + FOREACH_KSEGRP_IN_PROC(p, kg) { + FOREACH_KSE_IN_GROUP(kg, ke) { + if (ke->ke_thread == td) { + continue; + } + forward_signal(ke->ke_thread); + } + } +#else + signotify(&p->p_kse); /* XXXKSE */ #endif } mtx_unlock_spin(&sched_lock); @@ -1409,14 +1488,19 @@ psignal(p, sig) runfast: /* * Raise priority to at least PUSER. + * XXXKSE Should we make them all run fast? + * Maybe just one would be enough? */ mtx_lock_spin(&sched_lock); - if (p->p_pri.pri_level > PUSER) - p->p_pri.pri_level = PUSER; + FOREACH_KSEGRP_IN_PROC(p, kg) { + if (kg->kg_pri.pri_level > PUSER) { + kg->kg_pri.pri_level = PUSER; + } + } run: /* If we jump here, sched_lock has to be owned. */ mtx_assert(&sched_lock, MA_OWNED | MA_NOTRECURSED); - setrunnable(p); + setrunnable(td); /* XXXKSE */ mtx_unlock_spin(&sched_lock); out: /* If we jump here, sched_lock should not be owned. */ @@ -1623,7 +1707,8 @@ void postsig(sig) register int sig; { - register struct proc *p = curproc; + struct thread *td = curthread; + register struct proc *p = td->td_proc; struct sigacts *ps; sig_t action; sigset_t returnmask; @@ -1647,7 +1732,7 @@ postsig(sig) * Default action, where the default is to kill * the process. (Other cases were ignored above.) */ - sigexit(p, sig); + sigexit(td, sig); /* NOTREACHED */ } else { /* @@ -1722,10 +1807,11 @@ killproc(p, why) * does not return. */ void -sigexit(p, sig) - register struct proc *p; +sigexit(td, sig) + struct thread *td; int sig; { + struct proc *p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); p->p_acflag |= AXSIG; @@ -1740,7 +1826,7 @@ sigexit(p, sig) PROC_UNLOCK(p); if (!mtx_owned(&Giant)) mtx_lock(&Giant); - if (coredump(p) == 0) + if (coredump(td) == 0) sig |= WCOREFLAG; if (kern_logsigexit) log(LOG_INFO, @@ -1754,7 +1840,7 @@ sigexit(p, sig) if (!mtx_owned(&Giant)) mtx_lock(&Giant); } - exit1(p, W_EXITCODE(0, sig)); + exit1(td, W_EXITCODE(0, sig)); /* NOTREACHED */ } @@ -1849,9 +1935,9 @@ const char *name; uid_t uid; pid_t pid; { */ static int -coredump(p) - register struct proc *p; +coredump(struct thread *td) { + struct proc *p = td->td_proc; register struct vnode *vp; register struct ucred *cred = p->p_ucred; struct flock lf; @@ -1889,7 +1975,7 @@ restart: name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid); if (name == NULL) return (EINVAL); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); /* XXXKSE */ flags = O_CREAT | FWRITE | O_NOFOLLOW; error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR); free(name, M_TEMP); @@ -1898,7 +1984,7 @@ restart: NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); lf.l_whence = SEEK_SET; lf.l_start = 0; lf.l_len = 0; @@ -1910,7 +1996,7 @@ restart: if (vn_start_write(vp, &mp, V_NOWAIT) != 0) { lf.l_type = F_UNLCK; VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); - if ((error = vn_close(vp, FWRITE, cred, p)) != 0) + if ((error = vn_close(vp, FWRITE, cred, td)) != 0) return (error); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); @@ -1919,20 +2005,20 @@ restart: /* Don't dump to non-regular files or files with links. */ if (vp->v_type != VREG || - VOP_GETATTR(vp, &vattr, cred, p) || vattr.va_nlink != 1) { + VOP_GETATTR(vp, &vattr, cred, td) || vattr.va_nlink != 1) { error = EFAULT; goto out1; } VATTR_NULL(&vattr); vattr.va_size = 0; - VOP_LEASE(vp, p, cred, LEASE_WRITE); - VOP_SETATTR(vp, &vattr, cred, p); + VOP_LEASE(vp, td, cred, LEASE_WRITE); + VOP_SETATTR(vp, &vattr, cred, td); PROC_LOCK(p); p->p_acflag |= ACORE; PROC_UNLOCK(p); error = p->p_sysent->sv_coredump ? - p->p_sysent->sv_coredump(p, vp, limit) : + p->p_sysent->sv_coredump(td, vp, limit) : ENOSYS; out1: @@ -1940,7 +2026,7 @@ out1: VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); vn_finished_write(mp); out2: - error1 = vn_close(vp, FWRITE, cred, p); + error1 = vn_close(vp, FWRITE, cred, td); if (error == 0) error = error1; return (error); @@ -1960,10 +2046,12 @@ struct nosys_args { */ /* ARGSUSED */ int -nosys(p, args) - struct proc *p; +nosys(td, args) + struct thread *td; struct nosys_args *args; { + struct proc *p = td->td_proc; + mtx_lock(&Giant); PROC_LOCK(p); psignal(p, SIGSYS); diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 48364ad..31cde4f 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -66,6 +66,7 @@ uiomove(cp, n, uio) register int n; register struct uio *uio; { + struct thread *td = curthread; register struct iovec *iov; u_int cnt; int error = 0; @@ -73,12 +74,12 @@ uiomove(cp, n, uio) KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE, ("uiomove: mode")); - KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_procp == curproc, + KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, ("uiomove proc")); - if (curproc) { - save = curproc->p_flag & P_DEADLKTREAT; - curproc->p_flag |= P_DEADLKTREAT; + if (td) { + save = td->td_flags & TDF_DEADLKTREAT; + td->td_flags |= TDF_DEADLKTREAT; } while (n > 0 && uio->uio_resid) { @@ -122,8 +123,10 @@ uiomove(cp, n, uio) cp += cnt; n -= cnt; } - if (curproc) - curproc->p_flag = (curproc->p_flag & ~P_DEADLKTREAT) | save; + if (td != curthread) printf("uiomove: IT CHANGED!"); + td = curthread; /* Might things have changed in copyin/copyout? */ + if (td) + td->td_flags = (td->td_flags & ~TDF_DEADLKTREAT) | save; return (error); } @@ -140,7 +143,7 @@ uiomoveco(cp, n, uio, obj) KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE, ("uiomoveco: mode")); - KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_procp == curproc, + KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, ("uiomoveco proc")); while (n > 0 && uio->uio_resid) { @@ -376,14 +379,14 @@ phashinit(elements, type, nentries) static void uio_yield() { - struct proc *p; + struct thread *td; - p = curproc; + td = curthread; mtx_lock_spin(&sched_lock); DROP_GIANT_NOSWITCH(); - p->p_pri.pri_level = p->p_pri.pri_user; - setrunqueue(p); - p->p_stats->p_ru.ru_nivcsw++; + td->td_ksegrp->kg_pri.pri_level = td->td_ksegrp->kg_pri.pri_user; + setrunqueue(td); + td->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index a1eaf98..f61c47c 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -45,10 +45,10 @@ SYSINIT(runq, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, runq_init, &runq) * Wrappers which implement old interface; act on global run queue. */ -struct proc * -chooseproc(void) +struct thread * +choosethread(void) { - return runq_choose(&runq); + return (runq_choose(&runq)->ke_thread); } int @@ -58,15 +58,15 @@ procrunnable(void) } void -remrunqueue(struct proc *p) +remrunqueue(struct thread *td) { - runq_remove(&runq, p); + runq_remove(&runq, td->td_kse); } void -setrunqueue(struct proc *p) +setrunqueue(struct thread *td) { - runq_add(&runq, p); + runq_add(&runq, td->td_kse); } /* @@ -132,15 +132,15 @@ runq_setbit(struct runq *rq, int pri) * Return true if the specified process is already in the run queue. */ static __inline int -runq_find(struct runq *rq, struct proc *p) +runq_find(struct runq *rq, struct kse *ke) { - struct proc *p2; + struct kse *ke2; int i; mtx_assert(&sched_lock, MA_OWNED); for (i = 0; i < RQB_LEN; i++) - TAILQ_FOREACH(p2, &rq->rq_queues[i], p_procq) - if (p2 == p) + TAILQ_FOREACH(ke2, &rq->rq_queues[i], ke_procq) + if (ke2 == ke) return 1; return 0; } @@ -151,23 +151,30 @@ runq_find(struct runq *rq, struct proc *p) * corresponding status bit. */ void -runq_add(struct runq *rq, struct proc *p) +runq_add(struct runq *rq, struct kse *ke) { struct rqhead *rqh; int pri; + struct ksegrp *kg = ke->ke_ksegrp; +#ifdef INVARIANTS + struct proc *p = ke->ke_proc; +#endif + if (ke->ke_flags & KEF_ONRUNQ) + return; mtx_assert(&sched_lock, MA_OWNED); KASSERT(p->p_stat == SRUN, ("runq_add: proc %p (%s) not SRUN", p, p->p_comm)); - KASSERT(runq_find(rq, p) == 0, - ("runq_add: proc %p (%s) already in run queue", p, p->p_comm)); - pri = p->p_pri.pri_level / RQ_PPQ; - p->p_rqindex = pri; + KASSERT(runq_find(rq, ke) == 0, + ("runq_add: proc %p (%s) already in run queue", ke, p->p_comm)); + pri = kg->kg_pri.pri_level / RQ_PPQ; + ke->ke_rqindex = pri; runq_setbit(rq, pri); rqh = &rq->rq_queues[pri]; CTR4(KTR_RUNQ, "runq_add: p=%p pri=%d %d rqh=%p", - p, p->p_pri.pri_level, pri, rqh); - TAILQ_INSERT_TAIL(rqh, p, p_procq); + p, kg->kg_pri.pri_level, pri, rqh); + TAILQ_INSERT_TAIL(rqh, ke, ke_procq); + ke->ke_flags |= KEF_ONRUNQ; } /* @@ -198,32 +205,33 @@ runq_check(struct runq *rq) * If there are no runnable processes, the per-cpu idle process is * returned. Will not return NULL under any circumstances. */ -struct proc * +struct kse * runq_choose(struct runq *rq) { struct rqhead *rqh; - struct proc *p; + struct kse *ke; int pri; mtx_assert(&sched_lock, MA_OWNED); if ((pri = runq_findbit(rq)) != -1) { rqh = &rq->rq_queues[pri]; - p = TAILQ_FIRST(rqh); - KASSERT(p != NULL, ("runq_choose: no proc on busy queue")); - KASSERT(p->p_stat == SRUN, - ("runq_choose: process %d(%s) in state %d", p->p_pid, - p->p_comm, p->p_stat)); - CTR3(KTR_RUNQ, "runq_choose: pri=%d p=%p rqh=%p", pri, p, rqh); - TAILQ_REMOVE(rqh, p, p_procq); + ke = TAILQ_FIRST(rqh); + KASSERT(ke != NULL, ("runq_choose: no proc on busy queue")); + KASSERT(ke->ke_proc->p_stat == SRUN, + ("runq_choose: process %d(%s) in state %d", ke->ke_proc->p_pid, + ke->ke_proc->p_comm, ke->ke_proc->p_stat)); + CTR3(KTR_RUNQ, "runq_choose: pri=%d kse=%p rqh=%p", pri, ke, rqh); + TAILQ_REMOVE(rqh, ke, ke_procq); if (TAILQ_EMPTY(rqh)) { CTR0(KTR_RUNQ, "runq_choose: empty"); runq_clrbit(rq, pri); } - return (p); + ke->ke_flags &= ~KEF_ONRUNQ; + return (ke); } CTR1(KTR_RUNQ, "runq_choose: idleproc pri=%d", pri); - return (PCPU_GET(idleproc)); + return (PCPU_GET(idlethread)->td_kse); } /* @@ -244,20 +252,26 @@ runq_init(struct runq *rq) * corresponding status bit if the queue becomes empty. */ void -runq_remove(struct runq *rq, struct proc *p) +runq_remove(struct runq *rq, struct kse *ke) { +#ifdef KTR + struct ksegrp *kg = ke->ke_ksegrp; +#endif struct rqhead *rqh; int pri; + if (!(ke->ke_flags & KEF_ONRUNQ)) + return; mtx_assert(&sched_lock, MA_OWNED); - pri = p->p_rqindex; + pri = ke->ke_rqindex; rqh = &rq->rq_queues[pri]; CTR4(KTR_RUNQ, "runq_remove: p=%p pri=%d %d rqh=%p", - p, p->p_pri.pri_level, pri, rqh); - KASSERT(p != NULL, ("runq_remove: no proc on busy queue")); - TAILQ_REMOVE(rqh, p, p_procq); + ke, kg->kg_pri.pri_level, pri, rqh); + KASSERT(ke != NULL, ("runq_remove: no proc on busy queue")); + TAILQ_REMOVE(rqh, ke, ke_procq); if (TAILQ_EMPTY(rqh)) { CTR0(KTR_RUNQ, "runq_remove: empty"); runq_clrbit(rq, pri); } + ke->ke_flags &= ~KEF_ONRUNQ; } diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index e1d1ce6..df18c1e 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -95,7 +95,7 @@ _sx_slock(struct sx *sx, const char *file, int line) { mtx_lock(&sx->sx_lock); - KASSERT(sx->sx_xholder != curproc, + KASSERT(sx->sx_xholder != curthread, ("%s (%s): slock while xlock is held @ %s:%d\n", __FUNCTION__, sx->sx_object.lo_name, file, line)); @@ -148,7 +148,7 @@ _sx_xlock(struct sx *sx, const char *file, int line) * xlock while in here, we consider it API abuse and put it under * INVARIANTS. */ - KASSERT(sx->sx_xholder != curproc, + KASSERT(sx->sx_xholder != curthread, ("%s (%s): xlock already held @ %s:%d", __FUNCTION__, sx->sx_object.lo_name, file, line)); @@ -163,7 +163,7 @@ _sx_xlock(struct sx *sx, const char *file, int line) /* Acquire an exclusive lock. */ sx->sx_cnt--; - sx->sx_xholder = curproc; + sx->sx_xholder = curthread; LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); @@ -178,7 +178,7 @@ _sx_try_xlock(struct sx *sx, const char *file, int line) mtx_lock(&sx->sx_lock); if (sx->sx_cnt == 0) { sx->sx_cnt--; - sx->sx_xholder = curproc; + sx->sx_xholder = curthread; LOCK_LOG_TRY("XLOCK", &sx->sx_object, 0, 1, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); @@ -256,7 +256,7 @@ _sx_try_upgrade(struct sx *sx, const char *file, int line) if (sx->sx_cnt == 1) { sx->sx_cnt = -1; - sx->sx_xholder = curproc; + sx->sx_xholder = curthread; LOCK_LOG_TRY("XUPGRADE", &sx->sx_object, 0, 1, file, line); WITNESS_UPGRADE(&sx->sx_object, LOP_EXCLUSIVE | LOP_TRYLOCK, diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 24da6e9..5278d17 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -107,13 +107,13 @@ SYSCTL_PROC(_kern, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW, * schedulers into account. */ void -maybe_resched(p) - struct proc *p; +maybe_resched(kg) + struct ksegrp *kg; { mtx_assert(&sched_lock, MA_OWNED); - if (p->p_pri.pri_level < curproc->p_pri.pri_level) - curproc->p_sflag |= PS_NEEDRESCHED; + if (kg->kg_pri.pri_level < curthread->td_ksegrp->kg_pri.pri_level) + curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; } int @@ -245,59 +245,88 @@ schedcpu(arg) { register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); register struct proc *p; + register struct kse *ke; + register struct ksegrp *kg; register int realstathz; + int awake; realstathz = stathz ? stathz : hz; sx_slock(&allproc_lock); - LIST_FOREACH(p, &allproc, p_list) { - /* - * Increment time in/out of memory and sleep time - * (if sleeping). We ignore overflow; with 16-bit int's - * (remember them?) overflow takes 45 days. - */ + FOREACH_PROC_IN_SYSTEM(p) { mtx_lock_spin(&sched_lock); p->p_swtime++; - if (p->p_stat == SSLEEP || p->p_stat == SSTOP) - p->p_slptime++; - p->p_pctcpu = (p->p_pctcpu * ccpu) >> FSHIFT; - /* - * If the process has slept the entire second, - * stop recalculating its priority until it wakes up. - */ - if (p->p_slptime > 1) { - mtx_unlock_spin(&sched_lock); - continue; - } + FOREACH_KSEGRP_IN_PROC(p, kg) { + awake = 0; + FOREACH_KSE_IN_GROUP(kg, ke) { + /* + * Increment time in/out of memory and sleep + * time (if sleeping). We ignore overflow; + * with 16-bit int's (remember them?) + * overflow takes 45 days. + */ + /* XXXKSE */ + /* if ((ke->ke_flags & KEF_ONRUNQ) == 0) */ + if (p->p_stat == SSLEEP || p->p_stat == SSTOP) { + ke->ke_slptime++; + } else { + ke->ke_slptime = 0; + awake = 1; + } + + /* + * pctcpu is only for ps? + * Do it per kse.. and add them up at the end? + * XXXKSE + */ + ke->ke_pctcpu = (ke->ke_pctcpu * ccpu) >> FSHIFT; + /* + * If the kse has been idle the entire second, + * stop recalculating its priority until + * it wakes up. + */ + if (ke->ke_slptime > 1) { + continue; + } - /* - * p_pctcpu is only for ps. - */ #if (FSHIFT >= CCPU_SHIFT) - p->p_pctcpu += (realstathz == 100)? - ((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT): - 100 * (((fixpt_t) p->p_cpticks) - << (FSHIFT - CCPU_SHIFT)) / realstathz; + ke->ke_pctcpu += (realstathz == 100) ? + ((fixpt_t) ke->ke_cpticks) << + (FSHIFT - CCPU_SHIFT) : + 100 * (((fixpt_t) ke->ke_cpticks) << + (FSHIFT - CCPU_SHIFT)) / realstathz; #else - p->p_pctcpu += ((FSCALE - ccpu) * - (p->p_cpticks * FSCALE / realstathz)) >> FSHIFT; + ke->ke_pctcpu += ((FSCALE - ccpu) * + (ke->ke_cpticks * FSCALE / realstathz)) >> + FSHIFT; #endif - p->p_cpticks = 0; - p->p_estcpu = decay_cpu(loadfac, p->p_estcpu); - resetpriority(p); - if (p->p_pri.pri_level >= PUSER) { - if (p->p_oncpu == NOCPU && /* idle */ - p->p_stat == SRUN && - (p->p_sflag & PS_INMEM) && - (p->p_pri.pri_level / RQ_PPQ) != - (p->p_pri.pri_user / RQ_PPQ)) { - remrunqueue(p); - p->p_pri.pri_level = p->p_pri.pri_user; - setrunqueue(p); - } else - p->p_pri.pri_level = p->p_pri.pri_user; - } + ke->ke_cpticks = 0; + } /* end of kse loop */ + if (awake == 0) { + kg->kg_slptime++; + } else { + kg->kg_slptime = 0; + } + kg->kg_estcpu = decay_cpu(loadfac, kg->kg_estcpu); + resetpriority(kg); + if (kg->kg_pri.pri_level >= PUSER && + (p->p_sflag & PS_INMEM)) { + int changedqueue = + ((kg->kg_pri.pri_level / RQ_PPQ) != + (kg->kg_pri.pri_user / RQ_PPQ)); + + kg->kg_pri.pri_level = kg->kg_pri.pri_user; + FOREACH_KSE_IN_GROUP(kg, ke) { + if ((ke->ke_oncpu == NOCPU) && /* idle */ + (p->p_stat == SRUN) && /* XXXKSE */ + changedqueue) { + remrunqueue(ke->ke_thread); + setrunqueue(ke->ke_thread); + } + } + } + } /* end of ksegrp loop */ mtx_unlock_spin(&sched_lock); - } + } /* end of process loop */ sx_sunlock(&allproc_lock); vmmeter(); wakeup((caddr_t)&lbolt); @@ -310,21 +339,26 @@ schedcpu(arg) * least six times the loadfactor will decay p_estcpu to zero. */ void -updatepri(p) - register struct proc *p; +updatepri(td) + register struct thread *td; { - register unsigned int newcpu = p->p_estcpu; + register struct ksegrp *kg; + register unsigned int newcpu; register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]); - if (p->p_slptime > 5 * loadfac) - p->p_estcpu = 0; + if (td == NULL) + return; + kg = td->td_ksegrp; + newcpu = kg->kg_estcpu; + if (kg->kg_slptime > 5 * loadfac) + kg->kg_estcpu = 0; else { - p->p_slptime--; /* the first time was done in schedcpu */ - while (newcpu && --p->p_slptime) + kg->kg_slptime--; /* the first time was done in schedcpu */ + while (newcpu && --kg->kg_slptime) newcpu = decay_cpu(loadfac, newcpu); - p->p_estcpu = newcpu; + kg->kg_estcpu = newcpu; } - resetpriority(p); + resetpriority(td->td_ksegrp); } /* @@ -333,7 +367,7 @@ updatepri(p) * of 2. Shift right by 8, i.e. drop the bottom 256 worth. */ #define TABLESIZE 128 -static TAILQ_HEAD(slpquehead, proc) slpque[TABLESIZE]; +static TAILQ_HEAD(slpquehead, thread) slpque[TABLESIZE]; #define LOOKUP(x) (((intptr_t)(x) >> 8) & (TABLESIZE - 1)) void @@ -370,6 +404,7 @@ msleep(ident, mtx, priority, wmesg, timo) const char *wmesg; { struct proc *p = curproc; + struct thread *td = curthread; int sig, catch = priority & PCATCH; int rval = 0; WITNESS_SAVE_DECL(mtx); @@ -406,17 +441,18 @@ msleep(ident, mtx, priority, wmesg, timo) } KASSERT(p != NULL, ("msleep1")); - KASSERT(ident != NULL && p->p_stat == SRUN, ("msleep")); - - p->p_wchan = ident; - p->p_wmesg = wmesg; - p->p_slptime = 0; - p->p_pri.pri_level = priority & PRIMASK; - CTR5(KTR_PROC, "msleep: proc %p (pid %d, %s) on %s (%p)", p, p->p_pid, - p->p_comm, wmesg, ident); - TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); + KASSERT(ident != NULL && td->td_proc->p_stat == SRUN, ("msleep")); + + td->td_wchan = ident; + td->td_wmesg = wmesg; + td->td_kse->ke_slptime = 0; /* XXXKSE */ + td->td_ksegrp->kg_slptime = 0; + td->td_ksegrp->kg_pri.pri_level = priority & PRIMASK; + CTR5(KTR_PROC, "msleep: thread %p (pid %d, %s) on %s (%p)", + td, p->p_pid, p->p_comm, wmesg, ident); + TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], td, td_slpq); if (timo) - callout_reset(&p->p_slpcallout, timo, endtsleep, p); + callout_reset(&td->td_slpcallout, timo, endtsleep, td); /* * We put ourselves on the sleep queue and start our timeout * before calling CURSIG, as we could stop there, and a wakeup @@ -424,40 +460,40 @@ msleep(ident, mtx, priority, wmesg, timo) * A SIGCONT would cause us to be marked as SSLEEP * without resuming us, thus we must be ready for sleep * when CURSIG is called. If the wakeup happens while we're - * stopped, p->p_wchan will be 0 upon return from CURSIG. + * stopped, td->td_wchan will be 0 upon return from CURSIG. */ if (catch) { CTR3(KTR_PROC, "msleep caught: proc %p (pid %d, %s)", p, p->p_pid, p->p_comm); - p->p_sflag |= PS_SINTR; + td->td_flags |= TDF_SINTR; mtx_unlock_spin(&sched_lock); PROC_LOCK(p); sig = CURSIG(p); mtx_lock_spin(&sched_lock); PROC_UNLOCK_NOSWITCH(p); if (sig != 0) { - if (p->p_wchan != NULL) - unsleep(p); - } else if (p->p_wchan == NULL) + if (td->td_wchan != NULL) + unsleep(td); + } else if (td->td_wchan == NULL) catch = 0; } else sig = 0; - if (p->p_wchan != NULL) { - p->p_stat = SSLEEP; + if (td->td_wchan != NULL) { + td->td_proc->p_stat = SSLEEP; p->p_stats->p_ru.ru_nvcsw++; mi_switch(); } - CTR3(KTR_PROC, "msleep resume: proc %p (pid %d, %s)", p, p->p_pid, + CTR3(KTR_PROC, "msleep resume: proc %p (pid %d, %s)", td, p->p_pid, p->p_comm); - KASSERT(p->p_stat == SRUN, ("running but not SRUN")); - p->p_sflag &= ~PS_SINTR; - if (p->p_sflag & PS_TIMEOUT) { - p->p_sflag &= ~PS_TIMEOUT; + KASSERT(td->td_proc->p_stat == SRUN, ("running but not SRUN")); + td->td_flags &= ~TDF_SINTR; + if (td->td_flags & TDF_TIMEOUT) { + td->td_flags &= ~TDF_TIMEOUT; if (sig == 0) rval = EWOULDBLOCK; - } else if (p->p_sflag & PS_TIMOFAIL) - p->p_sflag &= ~PS_TIMOFAIL; - else if (timo && callout_stop(&p->p_slpcallout) == 0) { + } else if (td->td_flags & TDF_TIMOFAIL) + td->td_flags &= ~TDF_TIMOFAIL; + else if (timo && callout_stop(&td->td_slpcallout) == 0) { /* * This isn't supposed to be pretty. If we are here, then * the endtsleep() callout is currently executing on another @@ -467,7 +503,7 @@ msleep(ident, mtx, priority, wmesg, timo) * has a chance to run and the callout may end up waking up * the wrong msleep(). Yuck. */ - p->p_sflag |= PS_TIMEOUT; + td->td_flags |= TDF_TIMEOUT; p->p_stats->p_ru.ru_nivcsw++; mi_switch(); } @@ -510,28 +546,28 @@ static void endtsleep(arg) void *arg; { - register struct proc *p; + register struct thread *td = arg; - p = (struct proc *)arg; - CTR3(KTR_PROC, "endtsleep: proc %p (pid %d, %s)", p, p->p_pid, - p->p_comm); + CTR3(KTR_PROC, "endtsleep: thread %p (pid %d, %s)", td, td->td_proc->p_pid, + td->td_proc->p_comm); mtx_lock_spin(&sched_lock); /* * This is the other half of the synchronization with msleep() * described above. If the PS_TIMEOUT flag is set, we lost the * race and just need to put the process back on the runqueue. */ - if ((p->p_sflag & PS_TIMEOUT) != 0) { - p->p_sflag &= ~PS_TIMEOUT; - setrunqueue(p); - } else if (p->p_wchan != NULL) { - if (p->p_stat == SSLEEP) - setrunnable(p); + if ((td->td_flags & TDF_TIMEOUT) != 0) { + td->td_flags &= ~TDF_TIMEOUT; + setrunqueue(td); + } else if (td->td_wchan != NULL) { + if (td->td_proc->p_stat == SSLEEP) /* XXXKSE */ + setrunnable(td); else - unsleep(p); - p->p_sflag |= PS_TIMEOUT; - } else - p->p_sflag |= PS_TIMOFAIL; + unsleep(td); + td->td_flags |= TDF_TIMEOUT; + } else { + td->td_flags |= TDF_TIMOFAIL; + } mtx_unlock_spin(&sched_lock); } @@ -539,14 +575,13 @@ endtsleep(arg) * Remove a process from its wait queue */ void -unsleep(p) - register struct proc *p; +unsleep(struct thread *td) { mtx_lock_spin(&sched_lock); - if (p->p_wchan != NULL) { - TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_slpq); - p->p_wchan = NULL; + if (td->td_wchan != NULL) { + TAILQ_REMOVE(&slpque[LOOKUP(td->td_wchan)], td, td_slpq); + td->td_wchan = NULL; } mtx_unlock_spin(&sched_lock); } @@ -559,26 +594,29 @@ wakeup(ident) register void *ident; { register struct slpquehead *qp; - register struct proc *p; + register struct thread *td; + struct proc *p; mtx_lock_spin(&sched_lock); qp = &slpque[LOOKUP(ident)]; restart: - TAILQ_FOREACH(p, qp, p_slpq) { - if (p->p_wchan == ident) { - TAILQ_REMOVE(qp, p, p_slpq); - p->p_wchan = NULL; - if (p->p_stat == SSLEEP) { + TAILQ_FOREACH(td, qp, td_slpq) { + p = td->td_proc; + if (td->td_wchan == ident) { + TAILQ_REMOVE(qp, td, td_slpq); + td->td_wchan = NULL; + if (td->td_proc->p_stat == SSLEEP) { /* OPTIMIZED EXPANSION OF setrunnable(p); */ - CTR3(KTR_PROC, "wakeup: proc %p (pid %d, %s)", - p, p->p_pid, p->p_comm); - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; - p->p_stat = SRUN; + CTR3(KTR_PROC, "wakeup: thread %p (pid %d, %s)", + td, p->p_pid, p->p_comm); + if (td->td_ksegrp->kg_slptime > 1) + updatepri(td); + td->td_ksegrp->kg_slptime = 0; + td->td_kse->ke_slptime = 0; + td->td_proc->p_stat = SRUN; if (p->p_sflag & PS_INMEM) { - setrunqueue(p); - maybe_resched(p); + setrunqueue(td); + maybe_resched(td->td_ksegrp); } else { p->p_sflag |= PS_SWAPINREQ; wakeup((caddr_t)&proc0); @@ -601,26 +639,29 @@ wakeup_one(ident) register void *ident; { register struct slpquehead *qp; + register struct thread *td; register struct proc *p; mtx_lock_spin(&sched_lock); qp = &slpque[LOOKUP(ident)]; - TAILQ_FOREACH(p, qp, p_slpq) { - if (p->p_wchan == ident) { - TAILQ_REMOVE(qp, p, p_slpq); - p->p_wchan = NULL; - if (p->p_stat == SSLEEP) { + TAILQ_FOREACH(td, qp, td_slpq) { + p = td->td_proc; + if (td->td_wchan == ident) { + TAILQ_REMOVE(qp, td, td_slpq); + td->td_wchan = NULL; + if (td->td_proc->p_stat == SSLEEP) { /* OPTIMIZED EXPANSION OF setrunnable(p); */ CTR3(KTR_PROC, "wakeup1: proc %p (pid %d, %s)", p, p->p_pid, p->p_comm); - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; - p->p_stat = SRUN; + if (td->td_ksegrp->kg_slptime > 1) + updatepri(td); + td->td_ksegrp->kg_slptime = 0; + td->td_kse->ke_slptime = 0; + td->td_proc->p_stat = SRUN; if (p->p_sflag & PS_INMEM) { - setrunqueue(p); - maybe_resched(p); + setrunqueue(td); + maybe_resched(td->td_ksegrp); break; } else { p->p_sflag |= PS_SWAPINREQ; @@ -640,7 +681,8 @@ void mi_switch() { struct timeval new_switchtime; - register struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + register struct proc *p = td->td_proc; /* XXX */ #if 0 register struct rlimit *rlim; #endif @@ -717,14 +759,14 @@ mi_switch() p->p_comm); sched_crit = sched_lock.mtx_savecrit; sched_nest = sched_lock.mtx_recurse; - p->p_lastcpu = p->p_oncpu; - p->p_oncpu = NOCPU; - p->p_sflag &= ~PS_NEEDRESCHED; + td->td_lastcpu = td->td_kse->ke_oncpu; + td->td_kse->ke_oncpu = NOCPU; + td->td_kse->ke_flags &= ~KEF_NEEDRESCHED; cpu_switch(); - p->p_oncpu = PCPU_GET(cpuid); + td->td_kse->ke_oncpu = PCPU_GET(cpuid); sched_lock.mtx_savecrit = sched_crit; sched_lock.mtx_recurse = sched_nest; - sched_lock.mtx_lock = (uintptr_t)p; + sched_lock.mtx_lock = (uintptr_t)td; CTR3(KTR_PROC, "mi_switch: new proc %p (pid %d, %s)", p, p->p_pid, p->p_comm); if (PCPU_GET(switchtime.tv_sec) == 0) @@ -738,39 +780,42 @@ mi_switch() * and awakening the swapper if it isn't in memory. */ void -setrunnable(p) - register struct proc *p; +setrunnable(struct thread *td) { - + struct proc *p = td->td_proc; mtx_lock_spin(&sched_lock); switch (p->p_stat) { + case SZOMB: /* not a thread flag XXXKSE */ + panic("setrunnabl(1)"); + } + switch (td->td_proc->p_stat) { case 0: case SRUN: - case SZOMB: case SWAIT: default: - panic("setrunnable"); + panic("setrunnable(2)"); case SSTOP: case SSLEEP: /* e.g. when sending signals */ - if (p->p_sflag & PS_CVWAITQ) - cv_waitq_remove(p); + if (td->td_flags & TDF_CVWAITQ) + cv_waitq_remove(td); else - unsleep(p); + unsleep(td); break; case SIDL: break; } - p->p_stat = SRUN; - if (p->p_slptime > 1) - updatepri(p); - p->p_slptime = 0; + td->td_proc->p_stat = SRUN; + if (td->td_ksegrp->kg_slptime > 1) + updatepri(td); + td->td_ksegrp->kg_slptime = 0; + td->td_kse->ke_slptime = 0; if ((p->p_sflag & PS_INMEM) == 0) { p->p_sflag |= PS_SWAPINREQ; wakeup((caddr_t)&proc0); } else { - setrunqueue(p); - maybe_resched(p); + setrunqueue(td); + maybe_resched(td->td_ksegrp); } mtx_unlock_spin(&sched_lock); } @@ -781,20 +826,20 @@ setrunnable(p) * than that of the current process. */ void -resetpriority(p) - register struct proc *p; +resetpriority(kg) + register struct ksegrp *kg; { register unsigned int newpriority; mtx_lock_spin(&sched_lock); - if (p->p_pri.pri_class == PRI_TIMESHARE) { - newpriority = PUSER + p->p_estcpu / INVERSE_ESTCPU_WEIGHT + - NICE_WEIGHT * (p->p_nice - PRIO_MIN); + if (kg->kg_pri.pri_class == PRI_TIMESHARE) { + newpriority = PUSER + kg->kg_estcpu / INVERSE_ESTCPU_WEIGHT + + NICE_WEIGHT * (kg->kg_nice - PRIO_MIN); newpriority = min(max(newpriority, PRI_MIN_TIMESHARE), PRI_MAX_TIMESHARE); - p->p_pri.pri_user = newpriority; + kg->kg_pri.pri_user = newpriority; } - maybe_resched(p); + maybe_resched(kg); mtx_unlock_spin(&sched_lock); } @@ -827,16 +872,22 @@ sched_setup(dummy) * run much recently, and to round-robin among other processes. */ void -schedclock(p) - struct proc *p; +schedclock(td) + struct thread *td; { - - p->p_cpticks++; - p->p_estcpu = ESTCPULIM(p->p_estcpu + 1); - if ((p->p_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) { - resetpriority(p); - if (p->p_pri.pri_level >= PUSER) - p->p_pri.pri_level = p->p_pri.pri_user; + struct kse *ke = td->td_kse; + struct ksegrp *kg = td->td_ksegrp; + + if (td) { + ke->ke_cpticks++; + kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + 1); + if ((kg->kg_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) { + resetpriority(td->td_ksegrp); + if (kg->kg_pri.pri_level >= PUSER) + kg->kg_pri.pri_level = kg->kg_pri.pri_user; + } + } else { + panic("schedclock"); } } @@ -844,18 +895,20 @@ schedclock(p) * General purpose yield system call */ int -yield(struct proc *p, struct yield_args *uap) +yield(struct thread *td, struct yield_args *uap) { - p->p_retval[0] = 0; + + struct ksegrp *kg = td->td_ksegrp; + td->td_retval[0] = 0; mtx_lock_spin(&sched_lock); mtx_assert(&Giant, MA_NOTOWNED); #if 0 DROP_GIANT_NOSWITCH(); #endif - p->p_pri.pri_level = PRI_MAX_TIMESHARE; - setrunqueue(p); - p->p_stats->p_ru.ru_nvcsw++; + kg->kg_pri.pri_level = PRI_MAX_TIMESHARE; + setrunqueue(td); + kg->kg_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); #if 0 diff --git a/sys/kern/kern_syscalls.c b/sys/kern/kern_syscalls.c index 633406a..4dd623e 100644 --- a/sys/kern/kern_syscalls.c +++ b/sys/kern/kern_syscalls.c @@ -39,15 +39,15 @@ * Place holder for system call slots reserved for loadable modules. */ int -lkmnosys(struct proc *p, struct nosys_args *args) +lkmnosys(struct thread *td, struct nosys_args *args) { - return(nosys(p, args)); + return(nosys(td, args)); } int -lkmressys(struct proc *p, struct nosys_args *args) +lkmressys(struct thread *td, struct nosys_args *args) { - return(nosys(p, args)); + return(nosys(td, args)); } int diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ce5ba3d..34fcb68 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -836,7 +836,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l) } int -kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, +kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval) { int error = 0; @@ -844,7 +844,7 @@ kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, bzero(&req, sizeof req); - req.p = p; + req.p = td->td_proc; if (oldlenp) { req.oldlen = *oldlenp; @@ -896,7 +896,7 @@ kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, } int -kernel_sysctlbyname(struct proc *p, char *name, void *old, size_t *oldlenp, +kernel_sysctlbyname(struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval) { int oid[CTL_MAXNAME]; @@ -907,12 +907,12 @@ kernel_sysctlbyname(struct proc *p, char *name, void *old, size_t *oldlenp, oid[1] = 3; /* name2oid */ oidlen = sizeof(oid); - error = kernel_sysctl(p, oid, 2, oid, &oidlen, + error = kernel_sysctl(td, oid, 2, oid, &oidlen, (void *)name, strlen(name), &plen); if (error) return (error); - error = kernel_sysctl(p, oid, plen / sizeof(int), old, oldlenp, + error = kernel_sysctl(td, oid, plen / sizeof(int), old, oldlenp, new, newlen, retval); return (error); } @@ -1066,7 +1066,7 @@ struct sysctl_args { * MPSAFE */ int -__sysctl(struct proc *p, struct sysctl_args *uap) +__sysctl(struct thread *td, struct sysctl_args *uap) { int error, name[CTL_MAXNAME]; size_t j; @@ -1080,7 +1080,7 @@ __sysctl(struct proc *p, struct sysctl_args *uap) mtx_lock(&Giant); - error = userland_sysctl(p, name, uap->namelen, + error = userland_sysctl(td, name, uap->namelen, uap->old, uap->oldlenp, 0, uap->new, uap->newlen, &j); if (error && error != ENOMEM) @@ -1100,7 +1100,7 @@ done2: * must be in kernel space. */ int -userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, +userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval) { int error = 0; @@ -1108,7 +1108,7 @@ userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, bzero(&req, sizeof req); - req.p = p; + req.p = td->td_proc; if (oldlenp) { if (inkernel) { @@ -1245,7 +1245,7 @@ struct getkerninfo_args { * MPSAFE */ int -ogetkerninfo(struct proc *p, struct getkerninfo_args *uap) +ogetkerninfo(struct thread *td, struct getkerninfo_args *uap) { int error, name[6]; size_t size; @@ -1262,14 +1262,14 @@ ogetkerninfo(struct proc *p, struct getkerninfo_args *uap) name[3] = (uap->op & 0xff0000) >> 16; name[4] = uap->op & 0xff; name[5] = uap->arg; - error = userland_sysctl(p, name, 6, uap->where, uap->size, + error = userland_sysctl(td, name, 6, uap->where, uap->size, 0, 0, 0, &size); break; case KINFO_VNODE: name[0] = CTL_KERN; name[1] = KERN_VNODE; - error = userland_sysctl(p, name, 2, uap->where, uap->size, + error = userland_sysctl(td, name, 2, uap->where, uap->size, 0, 0, 0, &size); break; @@ -1278,35 +1278,35 @@ ogetkerninfo(struct proc *p, struct getkerninfo_args *uap) name[1] = KERN_PROC; name[2] = uap->op & 0xff; name[3] = uap->arg; - error = userland_sysctl(p, name, 4, uap->where, uap->size, + error = userland_sysctl(td, name, 4, uap->where, uap->size, 0, 0, 0, &size); break; case KINFO_FILE: name[0] = CTL_KERN; name[1] = KERN_FILE; - error = userland_sysctl(p, name, 2, uap->where, uap->size, + error = userland_sysctl(td, name, 2, uap->where, uap->size, 0, 0, 0, &size); break; case KINFO_METER: name[0] = CTL_VM; name[1] = VM_METER; - error = userland_sysctl(p, name, 2, uap->where, uap->size, + error = userland_sysctl(td, name, 2, uap->where, uap->size, 0, 0, 0, &size); break; case KINFO_LOADAVG: name[0] = CTL_VM; name[1] = VM_LOADAVG; - error = userland_sysctl(p, name, 2, uap->where, uap->size, + error = userland_sysctl(td, name, 2, uap->where, uap->size, 0, 0, 0, &size); break; case KINFO_CLOCKRATE: name[0] = CTL_KERN; name[1] = KERN_CLOCKRATE; - error = userland_sysctl(p, name, 2, uap->where, uap->size, + error = userland_sysctl(td, name, 2, uap->where, uap->size, 0, 0, 0, &size); break; @@ -1380,7 +1380,7 @@ ogetkerninfo(struct proc *p, struct getkerninfo_args *uap) break; } if (error == 0) { - p->p_retval[0] = needed ? needed : size; + td->td_retval[0] = needed ? needed : size; if (uap->size) { error = copyout((caddr_t)&size, (caddr_t)uap->size, sizeof(size)); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 545479d..17e3a46 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -64,7 +64,7 @@ struct timezone tz; * timers when they expire. */ -static int nanosleep1 __P((struct proc *p, struct timespec *rqt, +static int nanosleep1 __P((struct thread *td, struct timespec *rqt, struct timespec *rmt)); static int settime __P((struct timeval *)); static void timevalfix __P((struct timeval *)); @@ -151,8 +151,8 @@ struct clock_gettime_args { */ /* ARGSUSED */ int -clock_gettime(p, uap) - struct proc *p; +clock_gettime(td, uap) + struct thread *td; struct clock_gettime_args *uap; { struct timespec ats; @@ -177,8 +177,8 @@ struct clock_settime_args { */ /* ARGSUSED */ int -clock_settime(p, uap) - struct proc *p; +clock_settime(td, uap) + struct thread *td; struct clock_settime_args *uap; { struct timeval atv; @@ -186,7 +186,7 @@ clock_settime(p, uap) int error; mtx_lock(&Giant); - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) goto done2; if (SCARG(uap, clock_id) != CLOCK_REALTIME) { error = EINVAL; @@ -214,8 +214,8 @@ struct clock_getres_args { #endif int -clock_getres(p, uap) - struct proc *p; +clock_getres(td, uap) + struct thread *td; struct clock_getres_args *uap; { struct timespec ts; @@ -235,8 +235,8 @@ clock_getres(p, uap) static int nanowait; static int -nanosleep1(p, rqt, rmt) - struct proc *p; +nanosleep1(td, rqt, rmt) + struct thread *td; struct timespec *rqt, *rmt; { struct timespec ts, ts2, ts3; @@ -285,8 +285,8 @@ struct nanosleep_args { */ /* ARGSUSED */ int -nanosleep(p, uap) - struct proc *p; +nanosleep(td, uap) + struct thread *td; struct nanosleep_args *uap; { struct timespec rmt, rqt; @@ -304,7 +304,7 @@ nanosleep(p, uap) goto done2; } } - error = nanosleep1(p, &rqt, &rmt); + error = nanosleep1(td, &rqt, &rmt); if (error && SCARG(uap, rmtp)) { int error2; @@ -328,8 +328,8 @@ struct gettimeofday_args { */ /* ARGSUSED */ int -gettimeofday(p, uap) - struct proc *p; +gettimeofday(td, uap) + struct thread *td; register struct gettimeofday_args *uap; { struct timeval atv; @@ -363,8 +363,8 @@ struct settimeofday_args { */ /* ARGSUSED */ int -settimeofday(p, uap) - struct proc *p; +settimeofday(td, uap) + struct thread *td; struct settimeofday_args *uap; { struct timeval atv; @@ -373,7 +373,7 @@ settimeofday(p, uap) mtx_lock(&Giant); - if ((error = suser(p))) + if ((error = suser_td(td))) goto done2; /* Verify all parameters before changing time. */ if (uap->tv) { @@ -414,8 +414,8 @@ struct adjtime_args { */ /* ARGSUSED */ int -adjtime(p, uap) - struct proc *p; +adjtime(td, uap) + struct thread *td; register struct adjtime_args *uap; { struct timeval atv; @@ -424,7 +424,7 @@ adjtime(p, uap) mtx_lock(&Giant); - if ((error = suser(p))) + if ((error = suser_td(td))) goto done2; error = copyin((caddr_t)uap->delta, (caddr_t)&atv, sizeof(struct timeval)); @@ -502,10 +502,11 @@ struct getitimer_args { */ /* ARGSUSED */ int -getitimer(p, uap) - struct proc *p; +getitimer(td, uap) + struct thread *td; register struct getitimer_args *uap; { + struct proc *p = td->td_proc; struct timeval ctv; struct itimerval aitv; int s; @@ -553,10 +554,11 @@ struct setitimer_args { */ /* ARGSUSED */ int -setitimer(p, uap) - struct proc *p; +setitimer(td, uap) + struct thread *td; register struct setitimer_args *uap; { + struct proc *p = td->td_proc; struct itimerval aitv; struct timeval ctv; register struct itimerval *itvp; @@ -572,7 +574,7 @@ setitimer(p, uap) mtx_lock(&Giant); if ((uap->itv = uap->oitv) && - (error = getitimer(p, (struct getitimer_args *)uap))) { + (error = getitimer(td, (struct getitimer_args *)uap))) { goto done2; } if (itvp == 0) { diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 84d88ce..f3f19ee 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -60,8 +60,8 @@ struct gethostname_args { */ /* ARGSUSED */ int -ogethostname(p, uap) - struct proc *p; +ogethostname(td, uap) + struct thread *td; struct gethostname_args *uap; { int name[2]; @@ -71,7 +71,7 @@ ogethostname(p, uap) name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; mtx_lock(&Giant); - error = userland_sysctl(p, name, 2, uap->hostname, &len, 1, 0, 0, 0); + error = userland_sysctl(td, name, 2, uap->hostname, &len, 1, 0, 0, 0); mtx_unlock(&Giant); return(error); } @@ -87,8 +87,8 @@ struct sethostname_args { */ /* ARGSUSED */ int -osethostname(p, uap) - struct proc *p; +osethostname(td, uap) + struct thread *td; register struct sethostname_args *uap; { int name[2]; @@ -97,8 +97,8 @@ osethostname(p, uap) name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; mtx_lock(&Giant); - if ((error = suser_xxx(0, p, PRISON_ROOT)) == 0) { - error = userland_sysctl(p, name, 2, 0, 0, 0, + if ((error = suser_xxx(0, td->td_proc, PRISON_ROOT)) == 0) { + error = userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, uap->len, 0); } mtx_unlock(&Giant); @@ -115,12 +115,12 @@ struct ogethostid_args { */ /* ARGSUSED */ int -ogethostid(p, uap) - struct proc *p; +ogethostid(td, uap) + struct thread *td; struct ogethostid_args *uap; { - *(long *)(p->p_retval) = hostid; + *(long *)(td->td_retval) = hostid; return (0); } #endif /* COMPAT_43 || COMPAT_SUNOS */ @@ -136,14 +136,14 @@ struct osethostid_args { */ /* ARGSUSED */ int -osethostid(p, uap) - struct proc *p; +osethostid(td, uap) + struct thread *td; struct osethostid_args *uap; { int error; mtx_lock(&Giant); - if ((error = suser(p)) == 0) + if ((error = suser_td(td))) hostid = uap->hostid; mtx_unlock(&Giant); return (error); @@ -153,8 +153,8 @@ osethostid(p, uap) * MPSAFE */ int -oquota(p, uap) - struct proc *p; +oquota(td, uap) + struct thread *td; struct oquota_args *uap; { return (ENOSYS); @@ -180,8 +180,8 @@ struct uname_args { */ /* ARGSUSED */ int -uname(p, uap) - struct proc *p; +uname(td, uap) + struct thread *td; struct uname_args *uap; { int name[2], error; @@ -192,7 +192,7 @@ uname(p, uap) name[1] = KERN_OSTYPE; len = sizeof (uap->name->sysname); mtx_lock(&Giant); - error = userland_sysctl(p, name, 2, uap->name->sysname, &len, + error = userland_sysctl(td, name, 2, uap->name->sysname, &len, 1, 0, 0, 0); if (error) goto done2; @@ -200,7 +200,7 @@ uname(p, uap) name[1] = KERN_HOSTNAME; len = sizeof uap->name->nodename; - error = userland_sysctl(p, name, 2, uap->name->nodename, &len, + error = userland_sysctl(td, name, 2, uap->name->nodename, &len, 1, 0, 0, 0); if (error) goto done2; @@ -208,7 +208,7 @@ uname(p, uap) name[1] = KERN_OSRELEASE; len = sizeof uap->name->release; - error = userland_sysctl(p, name, 2, uap->name->release, &len, + error = userland_sysctl(td, name, 2, uap->name->release, &len, 1, 0, 0, 0); if (error) goto done2; @@ -217,7 +217,7 @@ uname(p, uap) /* name = KERN_VERSION; len = sizeof uap->name->version; - error = userland_sysctl(p, name, 2, uap->name->version, &len, + error = userland_sysctl(td, name, 2, uap->name->version, &len, 1, 0, 0, 0); if (error) goto done2; @@ -241,7 +241,7 @@ uname(p, uap) name[0] = CTL_HW; name[1] = HW_MACHINE; len = sizeof uap->name->machine; - error = userland_sysctl(p, name, 2, uap->name->machine, &len, + error = userland_sysctl(td, name, 2, uap->name->machine, &len, 1, 0, 0, 0); if (error) goto done2; @@ -263,8 +263,8 @@ struct getdomainname_args { */ /* ARGSUSED */ int -getdomainname(p, uap) - struct proc *p; +getdomainname(td, uap) + struct thread *td; struct getdomainname_args *uap; { int domainnamelen; @@ -291,14 +291,14 @@ struct setdomainname_args { */ /* ARGSUSED */ int -setdomainname(p, uap) - struct proc *p; +setdomainname(td, uap) + struct thread *td; struct setdomainname_args *uap; { int error, domainnamelen; mtx_lock(&Giant); - if ((error = suser(p))) + if ((error = suser_td(td))) goto done2; if ((u_int)uap->len > sizeof (domainname) - 1) { error = EINVAL; diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c index d118b93..6ad2a07 100644 --- a/sys/kern/ksched.c +++ b/sys/kern/ksched.c @@ -62,9 +62,9 @@ int ksched_attach(struct ksched **p) return 0; } -int ksched_detach(struct ksched *p) +int ksched_detach(struct ksched *ks) { - p31b_free(p); + p31b_free(ks); return 0; } @@ -94,13 +94,13 @@ int ksched_detach(struct ksched *p) #define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN) static __inline int -getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) +getscheduler(register_t *ret, struct ksched *ksched, struct thread *td) { struct rtprio rtp; int e = 0; mtx_lock_spin(&sched_lock); - pri_to_rtp(&p->p_pri, &rtp); + pri_to_rtp(&td->td_ksegrp->kg_pri, &rtp); mtx_unlock_spin(&sched_lock); switch (rtp.type) { @@ -121,31 +121,31 @@ getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) } int ksched_setparam(register_t *ret, struct ksched *ksched, - struct proc *p, const struct sched_param *param) + struct thread *td, const struct sched_param *param) { register_t policy; int e; - e = getscheduler(&policy, ksched, p); + e = getscheduler(&policy, ksched, td); if (e == 0) { if (policy == SCHED_OTHER) e = EINVAL; else - e = ksched_setscheduler(ret, ksched, p, policy, param); + e = ksched_setscheduler(ret, ksched, td, policy, param); } return e; } int ksched_getparam(register_t *ret, struct ksched *ksched, - struct proc *p, struct sched_param *param) + struct thread *td, struct sched_param *param) { struct rtprio rtp; mtx_lock_spin(&sched_lock); - pri_to_rtp(&p->p_pri, &rtp); + pri_to_rtp(&td->td_ksegrp->kg_pri, &rtp); mtx_unlock_spin(&sched_lock); if (RTP_PRIO_IS_REALTIME(rtp.type)) param->sched_priority = rtpprio_to_p4prio(rtp.prio); @@ -161,7 +161,7 @@ int ksched_getparam(register_t *ret, struct ksched *ksched, * */ int ksched_setscheduler(register_t *ret, struct ksched *ksched, - struct proc *p, int policy, const struct sched_param *param) + struct thread *td, int policy, const struct sched_param *param) { int e = 0; struct rtprio rtp; @@ -179,8 +179,8 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; mtx_lock_spin(&sched_lock); - rtp_to_pri(&rtp, &p->p_pri); - p->p_sflag |= PS_NEEDRESCHED; + rtp_to_pri(&rtp, &td->td_ksegrp->kg_pri); + td->td_last_kse->ke_flags |= KEF_NEEDRESCHED; /* XXXKSE */ mtx_unlock_spin(&sched_lock); } else @@ -194,7 +194,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, rtp.type = RTP_PRIO_NORMAL; rtp.prio = p4prio_to_rtpprio(param->sched_priority); mtx_lock_spin(&sched_lock); - rtp_to_pri(&rtp, &p->p_pri); + rtp_to_pri(&rtp, &td->td_ksegrp->kg_pri); /* XXX Simply revert to whatever we had for last * normal scheduler priorities. @@ -202,7 +202,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, * on the scheduling code: You must leave the * scheduling info alone. */ - p->p_sflag |= PS_NEEDRESCHED; + td->td_last_kse->ke_flags |= KEF_NEEDRESCHED; /* XXXKSE */ mtx_unlock_spin(&sched_lock); } break; @@ -211,9 +211,9 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, return e; } -int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) +int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct thread *td) { - return getscheduler(ret, ksched, p); + return getscheduler(ret, ksched, td); } /* ksched_yield: Yield the CPU. @@ -221,7 +221,7 @@ int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) int ksched_yield(register_t *ret, struct ksched *ksched) { mtx_lock_spin(&sched_lock); - curproc->p_sflag |= PS_NEEDRESCHED; + curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; mtx_unlock_spin(&sched_lock); return 0; } @@ -271,7 +271,7 @@ int ksched_get_priority_min(register_t *ret, struct ksched *ksched, int policy) } int ksched_rr_get_interval(register_t *ret, struct ksched *ksched, - struct proc *p, struct timespec *timespec) + struct thread *td, struct timespec *timespec) { *timespec = ksched->rr_interval; diff --git a/sys/kern/link_aout.c b/sys/kern/link_aout.c index 1218e22..e410b20 100644 --- a/sys/kern/link_aout.c +++ b/sys/kern/link_aout.c @@ -193,14 +193,15 @@ static int link_aout_load_file(linker_class_t lc, const char* filename, linker_file_t* result) { struct nameidata nd; - struct proc* p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; int error = 0; int resid, flags; struct exec header; aout_file_t af; linker_file_t lf = 0; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); flags = FREAD; error = vn_open(&nd, &flags, 0); if (error) @@ -211,7 +212,7 @@ link_aout_load_file(linker_class_t lc, const char* filename, linker_file_t* resu * Read the a.out header from the file. */ error = vn_rdwr(UIO_READ, nd.ni_vp, (void*) &header, sizeof header, 0, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; @@ -236,7 +237,7 @@ link_aout_load_file(linker_class_t lc, const char* filename, linker_file_t* resu */ error = vn_rdwr(UIO_READ, nd.ni_vp, (void*) af->address, header.a_text + header.a_data, 0, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; bzero(af->address + header.a_text + header.a_data, header.a_bss); @@ -267,8 +268,8 @@ link_aout_load_file(linker_class_t lc, const char* filename, linker_file_t* resu out: if (error && lf) linker_file_unload(lf); - VOP_UNLOCK(nd.ni_vp, 0, p); - vn_close(nd.ni_vp, FREAD, p->p_ucred, p); + VOP_UNLOCK(nd.ni_vp, 0, td); + vn_close(nd.ni_vp, FREAD, p->p_ucred, td); return error; } diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 0abf96c..db29c37 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -513,7 +513,8 @@ static int link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* result) { struct nameidata nd; - struct proc* p = curproc; /* XXX */ + struct thread* td = curthread; /* XXX */ + struct proc* p = td->td_proc; /* XXX */ Elf_Ehdr *hdr; caddr_t firstpage; int nbytes, i; @@ -546,7 +547,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu shdr = NULL; lf = NULL; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); flags = FREAD; error = vn_open(&nd, &flags, 0); if (error) @@ -563,7 +564,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } hdr = (Elf_Ehdr *)firstpage; error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); nbytes = PAGE_SIZE - resid; if (error) goto out; @@ -702,7 +703,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu caddr_t segbase = mapbase + segs[i]->p_vaddr - base_vaddr; error = vn_rdwr(UIO_READ, nd.ni_vp, segbase, segs[i]->p_filesz, segs[i]->p_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) { goto out; } @@ -756,7 +757,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; symtabindex = -1; @@ -781,12 +782,12 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } error = vn_rdwr(UIO_READ, nd.ni_vp, ef->symbase, symcnt, shdr[symtabindex].sh_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; error = vn_rdwr(UIO_READ, nd.ni_vp, ef->strbase, strcnt, shdr[symstrindex].sh_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; @@ -817,8 +818,8 @@ out: free(shdr, M_LINKER); if (firstpage) free(firstpage, M_LINKER); - VOP_UNLOCK(nd.ni_vp, 0, p); - vn_close(nd.ni_vp, FREAD, p->p_ucred, p); + VOP_UNLOCK(nd.ni_vp, 0, td); + vn_close(nd.ni_vp, FREAD, p->p_ucred, td); return error; } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 0abf96c..db29c37 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -513,7 +513,8 @@ static int link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* result) { struct nameidata nd; - struct proc* p = curproc; /* XXX */ + struct thread* td = curthread; /* XXX */ + struct proc* p = td->td_proc; /* XXX */ Elf_Ehdr *hdr; caddr_t firstpage; int nbytes, i; @@ -546,7 +547,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu shdr = NULL; lf = NULL; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); flags = FREAD; error = vn_open(&nd, &flags, 0); if (error) @@ -563,7 +564,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } hdr = (Elf_Ehdr *)firstpage; error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); nbytes = PAGE_SIZE - resid; if (error) goto out; @@ -702,7 +703,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu caddr_t segbase = mapbase + segs[i]->p_vaddr - base_vaddr; error = vn_rdwr(UIO_READ, nd.ni_vp, segbase, segs[i]->p_filesz, segs[i]->p_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) { goto out; } @@ -756,7 +757,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; symtabindex = -1; @@ -781,12 +782,12 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu } error = vn_rdwr(UIO_READ, nd.ni_vp, ef->symbase, symcnt, shdr[symtabindex].sh_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; error = vn_rdwr(UIO_READ, nd.ni_vp, ef->strbase, strcnt, shdr[symstrindex].sh_offset, - UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, td); if (error) goto out; @@ -817,8 +818,8 @@ out: free(shdr, M_LINKER); if (firstpage) free(firstpage, M_LINKER); - VOP_UNLOCK(nd.ni_vp, 0, p); - vn_close(nd.ni_vp, FREAD, p->p_ucred, p); + VOP_UNLOCK(nd.ni_vp, 0, td); + vn_close(nd.ni_vp, FREAD, p->p_ucred, td); return error; } diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index e505379..5134275 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -114,6 +114,7 @@ s/\$//g printf "#include <sys/signal.h>\n\n" > sysarg printf "#include <sys/acl.h>\n\n" > sysarg printf "struct proc;\n\n" > sysarg + printf "struct thread;\n\n" > sysarg printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg printf "#if BYTE_ORDER == LITTLE_ENDIAN\n"> sysarg @@ -320,7 +321,7 @@ s/\$//g } if ($2 != "NOPROTO" && (!nosys || funcname != "nosys") && \ (!lkmnosys || funcname != "lkmnosys")) { - printf("%s\t%s __P((struct proc *, struct %s *))", + printf("%s\t%s __P((struct thread *, struct %s *))", rettype, funcname, argalias) > sysdcl printf(";\n") > sysdcl } @@ -370,7 +371,7 @@ s/\$//g else if($2 != "CPT_NOA") printf("struct %s {\n\tregister_t dummy;\n};\n", argalias) > sysarg - printf("%s\to%s __P((struct proc *, struct %s *));\n", + printf("%s\to%s __P((struct thread *, struct %s *));\n", rettype, funcname, argalias) > syscompatdcl printf("\t{ compat(%s%s,%s) },", mpsafe, argssize, funcname) > sysent diff --git a/sys/kern/p1003_1b.c b/sys/kern/p1003_1b.c index 4e43b22..0409d63 100644 --- a/sys/kern/p1003_1b.c +++ b/sys/kern/p1003_1b.c @@ -56,10 +56,10 @@ MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B"); * start to use this when they shouldn't. That will be removed if annoying. */ int -syscall_not_present(struct proc *p, const char *s, struct nosys_args *uap) +syscall_not_present(struct thread *td, const char *s, struct nosys_args *uap) { log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n", - p->p_comm, p->p_pid, s); + td->td_proc->p_comm, td->td_proc->p_pid, s); /* a " return nosys(p, uap); " here causes a core dump. */ @@ -105,9 +105,10 @@ static int sched_attach(void) /* * MPSAFE */ -int sched_setparam(struct proc *p, +int sched_setparam(struct thread *td, struct sched_setparam_args *uap) { + struct thread *targettd; struct proc *targetp; int e; struct sched_param sched_param; @@ -118,7 +119,8 @@ int sched_setparam(struct proc *p, mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -126,12 +128,13 @@ int sched_setparam(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansched(p, targetp); + e = p_cansched(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_setparam(&p->p_retval[0], ksched, targetp, + e = ksched_setparam(&td->td_retval[0], ksched, targettd, (const struct sched_param *)&sched_param); } done2: @@ -142,16 +145,18 @@ done2: /* * MPSAFE */ -int sched_getparam(struct proc *p, +int sched_getparam(struct thread *td, struct sched_getparam_args *uap) { int e; struct sched_param sched_param; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -159,28 +164,31 @@ int sched_getparam(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e) goto done2; - e = ksched_getparam(&p->p_retval[0], ksched, targetp, &sched_param); + e = ksched_getparam(&td->td_retval[0], ksched, targettd, &sched_param); if (e == 0) e = copyout(&sched_param, uap->param, sizeof(sched_param)); done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_setscheduler(struct proc *p, +int sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap) { int e; struct sched_param sched_param; + struct thread *targettd; struct proc *targetp; e = copyin(uap->param, &sched_param, sizeof(sched_param)); @@ -189,7 +197,8 @@ int sched_setscheduler(struct proc *p, mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -197,31 +206,34 @@ int sched_setscheduler(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansched(p, targetp); + e = p_cansched(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_setscheduler(&p->p_retval[0], ksched, - targetp, uap->policy, - (const struct sched_param *)&sched_param); + e = ksched_setscheduler(&td->td_retval[0], ksched, targettd, + uap->policy, (const struct sched_param *)&sched_param); } done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_getscheduler(struct proc *p, +int sched_getscheduler(struct thread *td, struct sched_getscheduler_args *uap) { int e; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -229,67 +241,75 @@ int sched_getscheduler(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) - e = ksched_getscheduler(&p->p_retval[0], ksched, targetp); + e = ksched_getscheduler(&td->td_retval[0], ksched, targettd); done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_yield(struct proc *p, +int sched_yield(struct thread *td, struct sched_yield_args *uap) { int error; mtx_lock(&Giant); - error = ksched_yield(&p->p_retval[0], ksched); + error = ksched_yield(&td->td_retval[0], ksched); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_get_priority_max(struct proc *p, +int sched_get_priority_max(struct thread *td, struct sched_get_priority_max_args *uap) { int error; mtx_lock(&Giant); - error = ksched_get_priority_max(&p->p_retval[0], ksched, uap->policy); + error = ksched_get_priority_max(&td->td_retval[0], ksched, uap->policy); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_get_priority_min(struct proc *p, +int sched_get_priority_min(struct thread *td, struct sched_get_priority_min_args *uap) { int error; + mtx_lock(&Giant); - error = ksched_get_priority_min(&p->p_retval[0], ksched, uap->policy); + error = ksched_get_priority_min(&td->td_retval[0], ksched, uap->policy); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_rr_get_interval(struct proc *p, +int sched_rr_get_interval(struct thread *td, struct sched_rr_get_interval_args *uap) { int e; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targettd = td; + targetp = td->td_proc; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -297,12 +317,13 @@ int sched_rr_get_interval(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_rr_get_interval(&p->p_retval[0], ksched, targetp, + e = ksched_rr_get_interval(&td->td_retval[0], ksched, targettd, uap->interval); } done2: diff --git a/sys/kern/subr_acl_posix1e.c b/sys/kern/subr_acl_posix1e.c index 69dbe85..045d1a8 100644 --- a/sys/kern/subr_acl_posix1e.c +++ b/sys/kern/subr_acl_posix1e.c @@ -48,11 +48,11 @@ MALLOC_DEFINE(M_ACL, "acl", "access control list"); -static int vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_aclcheck(struct proc *p, struct vnode *vp, +static int vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); /* @@ -562,7 +562,7 @@ acl_posix1e_check(struct acl *acl) * Given a vnode, set its ACL. */ static int -vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; @@ -571,10 +571,10 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, type, &inkernacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return(error); } @@ -582,16 +582,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, get its ACL. */ static int -vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_GETACL(vp, type, &inkernelacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -601,14 +601,14 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, delete its ACL. */ static int -vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) +vacl_delete( struct thread *td, struct vnode *vp, acl_type_t type) { int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -616,7 +616,7 @@ vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) * Given a vnode, check whether an ACL is appropriate for it */ static int -vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; @@ -625,7 +625,7 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); + error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_proc->p_ucred, td); return (error); } @@ -641,17 +641,17 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, * MPSAFE */ int -__acl_get_file(struct proc *p, struct __acl_get_file_args *uap) +__acl_get_file( struct thread *td, struct __acl_get_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); /* what flags are required here -- possible not LOCKLEAF? */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_get_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_get_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -665,16 +665,16 @@ __acl_get_file(struct proc *p, struct __acl_get_file_args *uap) * MPSAFE */ int -__acl_set_file(struct proc *p, struct __acl_set_file_args *uap) +__acl_set_file( struct thread *td, struct __acl_set_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_set_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_set_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -688,15 +688,15 @@ __acl_set_file(struct proc *p, struct __acl_set_file_args *uap) * MPSAFE */ int -__acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) +__acl_get_fd( struct thread *td, struct __acl_get_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_get_acl(p, (struct vnode *)fp->f_data, + error = vacl_get_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -709,15 +709,15 @@ __acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) * MPSAFE */ int -__acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) +__acl_set_fd( struct thread *td, struct __acl_set_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_set_acl(p, (struct vnode *)fp->f_data, + error = vacl_set_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -730,16 +730,16 @@ __acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) * MPSAFE */ int -__acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) +__acl_delete_file( struct thread *td, struct __acl_delete_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_delete(p, nd.ni_vp, SCARG(uap, type)); + error = vacl_delete(td, nd.ni_vp, SCARG(uap, type)); NDFREE(&nd, 0); } mtx_unlock(&Giant); @@ -752,15 +752,15 @@ __acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) * MPSAFE */ int -__acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) +__acl_delete_fd( struct thread *td, struct __acl_delete_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_delete(p, (struct vnode *)fp->f_data, + error = vacl_delete(td, (struct vnode *)fp->f_data, SCARG(uap, type)); } mtx_unlock(&Giant); @@ -773,16 +773,16 @@ __acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) * MPSAFE */ int -__acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) +__acl_aclcheck_file( struct thread *td, struct __acl_aclcheck_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_aclcheck(p, nd.ni_vp, SCARG(uap, type), + error = vacl_aclcheck(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -796,15 +796,15 @@ __acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) * MPSAFE */ int -__acl_aclcheck_fd(struct proc *p, struct __acl_aclcheck_fd_args *uap) +__acl_aclcheck_fd( struct thread *td, struct __acl_aclcheck_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_aclcheck(p, (struct vnode *)fp->f_data, + error = vacl_aclcheck(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index da961ba..4efc5b2 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -225,7 +225,7 @@ SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD, 0, NULL, */ static int -diskopen(dev_t dev, int oflags, int devtype, struct proc *p) +diskopen(dev_t dev, int oflags, int devtype, struct thread *td) { dev_t pdev; struct disk *dp; @@ -249,7 +249,7 @@ diskopen(dev_t dev, int oflags, int devtype, struct proc *p) if (!dsisopen(dp->d_slice)) { if (!pdev->si_iosize_max) pdev->si_iosize_max = dev->si_iosize_max; - error = dp->d_devsw->d_open(pdev, oflags, devtype, p); + error = dp->d_devsw->d_open(pdev, oflags, devtype, td); } /* Inherit properties from the whole/raw dev_t */ @@ -261,7 +261,7 @@ diskopen(dev_t dev, int oflags, int devtype, struct proc *p) error = dsopen(dev, devtype, dp->d_dsflags, &dp->d_slice, &dp->d_label); if (!dsisopen(dp->d_slice)) - dp->d_devsw->d_close(pdev, oflags, devtype, p); + dp->d_devsw->d_close(pdev, oflags, devtype, td); out: dp->d_flags &= ~DISKFLAG_LOCK; if (dp->d_flags & DISKFLAG_WANTED) { @@ -273,7 +273,7 @@ out: } static int -diskclose(dev_t dev, int fflag, int devtype, struct proc *p) +diskclose(dev_t dev, int fflag, int devtype, struct thread *td) { struct disk *dp; int error; @@ -286,7 +286,7 @@ diskclose(dev_t dev, int fflag, int devtype, struct proc *p) return (ENXIO); dsclose(dev, devtype, dp->d_slice); if (!dsisopen(dp->d_slice)) - error = dp->d_devsw->d_close(dp->d_dev, fflag, devtype, p); + error = dp->d_devsw->d_close(dp->d_dev, fflag, devtype, td); return (error); } @@ -325,7 +325,7 @@ diskstrategy(struct bio *bp) } static int -diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) +diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { struct disk *dp; int error; @@ -337,7 +337,7 @@ diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) return (ENXIO); error = dsioctl(dev, cmd, data, fflag, &dp->d_slice); if (error == ENOIOCTL) - error = dp->d_devsw->d_ioctl(dev, cmd, data, fflag, p); + error = dp->d_devsw->d_ioctl(dev, cmd, data, fflag, td); return (error); } diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 0e20032..76adaa9 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -816,9 +816,9 @@ dssize(dev, sspp) if (ssp == NULL || slice >= ssp->dss_nslices || !(ssp->dss_slices[slice].ds_openmask & (1 << part))) { if (devsw(dev)->d_open(dev, FREAD, S_IFCHR, - (struct proc *)NULL) != 0) + (struct thread *)NULL) != 0) return (-1); - devsw(dev)->d_close(dev, FREAD, S_IFCHR, (struct proc *)NULL); + devsw(dev)->d_close(dev, FREAD, S_IFCHR, (struct thread *)NULL); ssp = *sspp; } lp = ssp->dss_slices[slice].ds_label; diff --git a/sys/kern/subr_eventhandler.c b/sys/kern/subr_eventhandler.c index 7d9fcca..f02fb33 100644 --- a/sys/kern/subr_eventhandler.c +++ b/sys/kern/subr_eventhandler.c @@ -112,7 +112,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, eg->ee.ee_priority = priority; /* sort it into the list */ - lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, CURPROC); + lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, curthread); for (ep = TAILQ_FIRST(&list->el_entries); ep != NULL; ep = TAILQ_NEXT(ep, ee_link)) { @@ -123,7 +123,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, } if (ep == NULL) TAILQ_INSERT_TAIL(&list->el_entries, &eg->ee, ee_link); - lockmgr(&list->el_lock, LK_RELEASE, NULL, CURPROC); + lockmgr(&list->el_lock, LK_RELEASE, NULL, curthread); mtx_unlock(&eventhandler_mutex); return(&eg->ee); } @@ -134,7 +134,7 @@ eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) struct eventhandler_entry *ep = tag; /* XXX insert diagnostic check here? */ - lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, CURPROC); + lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, curthread); if (ep != NULL) { /* remove just this entry */ TAILQ_REMOVE(&list->el_entries, ep, ee_link); @@ -147,7 +147,7 @@ eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) free(ep, M_EVENTHANDLER); } } - lockmgr(&list->el_lock, LK_RELEASE, NULL, CURPROC); + lockmgr(&list->el_lock, LK_RELEASE, NULL, curthread); } struct eventhandler_list * diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index afcf63f..7fa5618 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -98,13 +98,13 @@ SYSCTL_INT(_kern, OID_AUTO, log_wakeups_per_second, CTLFLAG_RW, /*ARGSUSED*/ static int -logopen(dev_t dev, int flags, int mode, struct proc *p) +logopen(dev_t dev, int flags, int mode, struct thread *td) { if (log_open) return (EBUSY); log_open = 1; callout_init(&logsoftc.sc_callout, 0); - fsetown(p->p_pid, &logsoftc.sc_sigio); /* signal process only */ + fsetown(td->td_proc->p_pid, &logsoftc.sc_sigio); /* signal process only */ callout_reset(&logsoftc.sc_callout, hz / log_wakeups_per_second, logtimeout, NULL); return (0); @@ -112,7 +112,7 @@ logopen(dev_t dev, int flags, int mode, struct proc *p) /*ARGSUSED*/ static int -logclose(dev_t dev, int flag, int mode, struct proc *p) +logclose(dev_t dev, int flag, int mode, struct thread *td) { log_open = 0; @@ -167,7 +167,7 @@ logread(dev_t dev, struct uio *uio, int flag) /*ARGSUSED*/ static int -logpoll(dev_t dev, int events, struct proc *p) +logpoll(dev_t dev, int events, struct thread *td) { int s; int revents = 0; @@ -178,7 +178,7 @@ logpoll(dev_t dev, int events, struct proc *p) if (msgbufp->msg_bufr != msgbufp->msg_bufx) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &logsoftc.sc_selp); + selrecord(curthread, &logsoftc.sc_selp); } splx(s); return (revents); @@ -209,7 +209,7 @@ logtimeout(void *arg) /*ARGSUSED*/ static int -logioctl(dev_t dev, u_long com, caddr_t data, int flag, struct proc *p) +logioctl(dev_t dev, u_long com, caddr_t data, int flag, struct thread *td) { long l; int s; diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c index 08def9c..65095e0 100644 --- a/sys/kern/subr_mbuf.c +++ b/sys/kern/subr_mbuf.c @@ -862,7 +862,7 @@ mb_reclaim(void) * XXX: to avoid this. */ #ifdef WITNESS - KASSERT(witness_list(curproc) == 0, + KASSERT(witness_list(curthread) == 0, ("mb_reclaim() called with locks held")); #endif diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 3ce2d7d..8708704 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -109,12 +109,13 @@ tablefull(const char *tab) int uprintf(const char *fmt, ...) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; va_list ap; struct putchar_arg pca; int retval = 0; - if (p && p != PCPU_GET(idleproc) && p->p_flag & P_CONTROLT && + if (td && td != PCPU_GET(idlethread) && p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { va_start(ap, fmt); pca.tty = p->p_session->s_ttyp; diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index e177065..ae1d5c3 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -356,8 +356,8 @@ struct profil_args { */ /* ARGSUSED */ int -profil(p, uap) - struct proc *p; +profil(td, uap) + struct thread *td; register struct profil_args *uap; { register struct uprof *upp; @@ -371,10 +371,10 @@ profil(p, uap) goto done2; } if (uap->scale == 0) { - stopprofclock(p); + stopprofclock(td->td_proc); goto done2; } - upp = &p->p_stats->p_prof; + upp = &td->td_proc->p_stats->p_prof; /* Block profile interrupts while changing state. */ s = splstatclock(); @@ -382,7 +382,7 @@ profil(p, uap) upp->pr_scale = uap->scale; upp->pr_base = uap->samples; upp->pr_size = uap->size; - startprofclock(p); + startprofclock(td->td_proc); splx(s); done2: @@ -413,8 +413,8 @@ done2: * inaccurate. */ void -addupc_intr(p, pc, ticks) - register struct proc *p; +addupc_intr(ke, pc, ticks) + register struct kse *ke; register uintptr_t pc; u_int ticks; { @@ -425,7 +425,7 @@ addupc_intr(p, pc, ticks) if (ticks == 0) return; - prof = &p->p_stats->p_prof; + prof = &ke->ke_proc->p_stats->p_prof; if (pc < prof->pr_off || (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) return; /* out of range; ignore */ @@ -435,7 +435,7 @@ addupc_intr(p, pc, ticks) mtx_lock_spin(&sched_lock); prof->pr_addr = pc; prof->pr_ticks = ticks; - p->p_sflag |= PS_OWEUPC | PS_ASTPENDING; + ke->ke_flags |= KEF_OWEUPC | KEF_ASTPENDING ; mtx_unlock_spin(&sched_lock); } } @@ -445,11 +445,12 @@ addupc_intr(p, pc, ticks) * update fails, we simply turn off profiling. */ void -addupc_task(p, pc, ticks) - register struct proc *p; +addupc_task(ke, pc, ticks) + register struct kse *ke; register uintptr_t pc; u_int ticks; { + struct proc *p = ke->ke_proc; register struct uprof *prof; register caddr_t addr; register u_int i; diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index c107442..03c6612 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -100,7 +100,7 @@ mp_start(void *dummy) SYSINIT(cpu_mp, SI_SUB_CPU, SI_ORDER_SECOND, mp_start, NULL) void -forward_signal(struct proc *p) +forward_signal(struct thread *td) { int id; @@ -110,9 +110,9 @@ forward_signal(struct proc *p) * executes ast(). */ mtx_assert(&sched_lock, MA_OWNED); - KASSERT(p->p_stat == SRUN, ("forward_signal: process is not SRUN")); + KASSERT(td->td_proc->p_stat == SRUN, ("forward_signal: process is not SRUN")); - CTR1(KTR_SMP, "forward_signal(%p)", p); + CTR1(KTR_SMP, "forward_signal(%p)", td->td_proc); if (!smp_started || cold || panicstr) return; @@ -120,10 +120,10 @@ forward_signal(struct proc *p) return; /* No need to IPI ourself. */ - if (p == curproc) + if (td == curthread) return; - id = p->p_oncpu; + id = td->td_kse->ke_oncpu; if (id == NOCPU) return; ipi_selected(1 << id, IPI_AST); @@ -133,7 +133,7 @@ void forward_roundrobin(void) { struct globaldata *gd; - struct proc *p; + struct thread *td; u_int id, map; mtx_assert(&sched_lock, MA_OWNED); @@ -146,11 +146,11 @@ forward_roundrobin(void) return; map = 0; SLIST_FOREACH(gd, &cpuhead, gd_allcpu) { - p = gd->gd_curproc; + td = gd->gd_curthread; id = gd->gd_cpuid; if (id != PCPU_GET(cpuid) && (id & stopped_cpus) == 0 && - p != gd->gd_idleproc) { - p->p_sflag |= PS_NEEDRESCHED; + td != gd->gd_idlethread) { + td->td_kse->ke_flags |= KEF_NEEDRESCHED; map |= id; } } diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 727fe69..ad96be7 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -62,11 +62,14 @@ * MPSAFE */ void -userret(p, frame, oticks) - struct proc *p; +userret(td, frame, oticks) + struct thread *td; struct trapframe *frame; u_int oticks; { + struct proc *p = td->td_proc; + struct kse *ke = td->td_kse; + struct ksegrp *kg = td->td_ksegrp; int sig; mtx_lock(&Giant); @@ -77,8 +80,8 @@ userret(p, frame, oticks) mtx_unlock(&Giant); mtx_lock_spin(&sched_lock); - p->p_pri.pri_level = p->p_pri.pri_user; - if (p->p_sflag & PS_NEEDRESCHED) { + kg->kg_pri.pri_level = kg->kg_pri.pri_user; + if (ke->ke_flags & KEF_NEEDRESCHED) { /* * Since we are curproc, a clock interrupt could * change our priority without changing run queues @@ -88,7 +91,7 @@ userret(p, frame, oticks) * indicated by our priority. */ DROP_GIANT_NOSWITCH(); - setrunqueue(p); + setrunqueue(td); p->p_stats->p_ru.ru_nivcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); @@ -105,9 +108,10 @@ userret(p, frame, oticks) /* * Charge system time if profiling. */ - if (p->p_sflag & PS_PROFIL) - addupc_task(p, TRAPF_PC(frame), - ((u_int)p->p_sticks - oticks) * psratio); + if (p->p_sflag & PS_PROFIL) { + addupc_task(ke, TRAPF_PC(frame), + (u_int)(ke->ke_sticks - oticks) * psratio); + } } /* @@ -119,42 +123,47 @@ void ast(framep) struct trapframe *framep; { - struct proc *p = CURPROC; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct kse *ke = td->td_kse; u_int prticks, sticks; critical_t s; int sflag; + int flags; #if defined(DEV_NPX) && !defined(SMP) int ucode; #endif KASSERT(TRAPF_USERMODE(framep), ("ast in kernel mode")); #ifdef WITNESS - if (witness_list(p)) + if (witness_list(td)) panic("Returning to user mode with mutex(s) held"); #endif mtx_assert(&Giant, MA_NOTOWNED); s = critical_enter(); - while ((p->p_sflag & (PS_ASTPENDING | PS_NEEDRESCHED)) != 0) { + while ((ke->ke_flags & (KEF_ASTPENDING | KEF_NEEDRESCHED)) != 0) { critical_exit(s); - p->p_frame = framep; + td->td_frame = framep; /* * This updates the p_sflag's for the checks below in one * "atomic" operation with turning off the astpending flag. * If another AST is triggered while we are handling the * AST's saved in sflag, the astpending flag will be set and * we will loop again. + * XXXKSE Can't do it atomically in KSE */ mtx_lock_spin(&sched_lock); - sticks = p->p_sticks; + sticks = ke->ke_sticks; sflag = p->p_sflag; - p->p_sflag &= ~(PS_OWEUPC | PS_ALRMPEND | PS_PROFPEND | - PS_ASTPENDING); + flags = ke->ke_flags; + p->p_sflag &= ~(PS_PROFPEND | PS_ALRMPEND); + ke->ke_flags &= ~(KEF_OWEUPC | KEF_ASTPENDING); cnt.v_soft++; - if (sflag & PS_OWEUPC) { + if (flags & KEF_OWEUPC) { prticks = p->p_stats->p_prof.pr_ticks; p->p_stats->p_prof.pr_ticks = 0; mtx_unlock_spin(&sched_lock); - addupc_task(p, p->p_stats->p_prof.pr_addr, prticks); + addupc_task(ke, p->p_stats->p_prof.pr_addr, prticks); } else mtx_unlock_spin(&sched_lock); if (sflag & PS_ALRMPEND) { @@ -178,7 +187,7 @@ ast(framep) PROC_UNLOCK(p); } - userret(p, framep, sticks); + userret(td, framep, sticks); s = critical_enter(); } mtx_assert(&Giant, MA_NOTOWNED); diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 646d99a..bbcac94 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -86,9 +86,9 @@ #define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED) #define mtx_owner(m) (mtx_unowned((m)) ? NULL \ - : (struct proc *)((m)->mtx_lock & MTX_FLAGMASK)) + : (struct thread *)((m)->mtx_lock & MTX_FLAGMASK)) -#define SET_PRIO(p, pri) (p)->p_pri.pri_level = (pri) +#define SET_PRIO(td, pri) (td)->td_ksegrp->kg_pri.pri_level = (pri) /* * Lock classes for sleep and spin mutexes. @@ -105,113 +105,118 @@ struct lock_class lock_class_mtx_spin = { /* * Prototypes for non-exported routines. */ -static void propagate_priority(struct proc *); +static void propagate_priority(struct thread *); static void -propagate_priority(struct proc *p) +propagate_priority(struct thread *td) { - int pri = p->p_pri.pri_level; - struct mtx *m = p->p_blocked; + struct ksegrp *kg = td->td_ksegrp; + int pri = kg->kg_pri.pri_level; + struct mtx *m = td->td_blocked; mtx_assert(&sched_lock, MA_OWNED); for (;;) { - struct proc *p1; + struct thread *td1; - p = mtx_owner(m); + td = mtx_owner(m); - if (p == NULL) { + if (td == NULL) { /* * This really isn't quite right. Really - * ought to bump priority of process that + * ought to bump priority of thread that * next acquires the mutex. */ MPASS(m->mtx_lock == MTX_CONTESTED); return; } - MPASS(p->p_magic == P_MAGIC); - KASSERT(p->p_stat != SSLEEP, ("sleeping process owns a mutex")); - if (p->p_pri.pri_level <= pri) + MPASS(td->td_proc->p_magic == P_MAGIC); + KASSERT(td->td_proc->p_stat != SSLEEP, ("sleeping thread owns a mutex")); + if (kg->kg_pri.pri_level <= pri) /* lower is higher priority */ return; /* - * Bump this process' priority. + * Bump this thread's priority. */ - SET_PRIO(p, pri); + SET_PRIO(td, pri); /* * If lock holder is actually running, just bump priority. */ - if (p->p_oncpu != NOCPU) { - MPASS(p->p_stat == SRUN || p->p_stat == SZOMB || p->p_stat == SSTOP); + /* XXXKSE this test is not sufficient */ + if (td->td_kse && (td->td_kse->ke_oncpu != NOCPU)) { + MPASS(td->td_proc->p_stat == SRUN + || td->td_proc->p_stat == SZOMB + || td->td_proc->p_stat == SSTOP); return; } #ifndef SMP /* - * For UP, we check to see if p is curproc (this shouldn't + * For UP, we check to see if td is curthread (this shouldn't * ever happen however as it would mean we are in a deadlock.) */ - KASSERT(p != curproc, ("Deadlock detected")); + KASSERT(td != curthread, ("Deadlock detected")); #endif /* - * If on run queue move to new run queue, and - * quit. + * If on run queue move to new run queue, and quit. + * XXXKSE this gets a lot more complicated under threads + * but try anyhow. */ - if (p->p_stat == SRUN) { - MPASS(p->p_blocked == NULL); - remrunqueue(p); - setrunqueue(p); + if (td->td_proc->p_stat == SRUN) { + MPASS(td->td_blocked == NULL); + remrunqueue(td); + setrunqueue(td); return; } /* * If we aren't blocked on a mutex, we should be. */ - KASSERT(p->p_stat == SMTX, ( + KASSERT(td->td_proc->p_stat == SMTX, ( "process %d(%s):%d holds %s but isn't blocked on a mutex\n", - p->p_pid, p->p_comm, p->p_stat, + td->td_proc->p_pid, td->td_proc->p_comm, td->td_proc->p_stat, m->mtx_object.lo_name)); /* - * Pick up the mutex that p is blocked on. + * Pick up the mutex that td is blocked on. */ - m = p->p_blocked; + m = td->td_blocked; MPASS(m != NULL); /* - * Check if the proc needs to be moved up on + * Check if the thread needs to be moved up on * the blocked chain */ - if (p == TAILQ_FIRST(&m->mtx_blocked)) { + if (td == TAILQ_FIRST(&m->mtx_blocked)) { continue; } - p1 = TAILQ_PREV(p, procqueue, p_procq); - if (p1->p_pri.pri_level <= pri) { + td1 = TAILQ_PREV(td, threadqueue, td_blkq); + if (td1->td_ksegrp->kg_pri.pri_level <= pri) { continue; } /* - * Remove proc from blocked chain and determine where - * it should be moved up to. Since we know that p1 has - * a lower priority than p, we know that at least one - * process in the chain has a lower priority and that - * p1 will thus not be NULL after the loop. + * Remove thread from blocked chain and determine where + * it should be moved up to. Since we know that td1 has + * a lower priority than td, we know that at least one + * thread in the chain has a lower priority and that + * td1 will thus not be NULL after the loop. */ - TAILQ_REMOVE(&m->mtx_blocked, p, p_procq); - TAILQ_FOREACH(p1, &m->mtx_blocked, p_procq) { - MPASS(p1->p_magic == P_MAGIC); - if (p1->p_pri.pri_level > pri) + TAILQ_REMOVE(&m->mtx_blocked, td, td_blkq); + TAILQ_FOREACH(td1, &m->mtx_blocked, td_blkq) { + MPASS(td1->td_proc->p_magic == P_MAGIC); + if (td1->td_ksegrp->kg_pri.pri_level > pri) break; } - MPASS(p1 != NULL); - TAILQ_INSERT_BEFORE(p1, p, p_procq); + MPASS(td1 != NULL); + TAILQ_INSERT_BEFORE(td1, td, td_blkq); CTR4(KTR_LOCK, "propagate_priority: p %p moved before %p on [%p] %s", - p, p1, m, m->mtx_object.lo_name); + td, td1, m, m->mtx_object.lo_name); } } @@ -257,7 +262,7 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) { int rval; - MPASS(curproc != NULL); + MPASS(curthread != NULL); /* * _mtx_trylock does not accept MTX_NOSWITCH option. @@ -265,7 +270,7 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) KASSERT((opts & MTX_NOSWITCH) == 0, ("mtx_trylock() called with invalid option flag(s) %d", opts)); - rval = _obtain_lock(m, curproc); + rval = _obtain_lock(m, curthread); LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line); if (rval) { @@ -291,9 +296,10 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) void _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) { - struct proc *p = curproc; + struct thread *td = curthread; + struct ksegrp *kg = td->td_ksegrp; - if ((m->mtx_lock & MTX_FLAGMASK) == (uintptr_t)p) { + if ((m->mtx_lock & MTX_FLAGMASK) == (uintptr_t)td) { m->mtx_recurse++; atomic_set_ptr(&m->mtx_lock, MTX_RECURSED); if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -306,9 +312,9 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->mtx_object.lo_name, (void *)m->mtx_lock, file, line); - while (!_obtain_lock(m, p)) { + while (!_obtain_lock(m, td)) { uintptr_t v; - struct proc *p1; + struct thread *td1; mtx_lock_spin(&sched_lock); /* @@ -322,15 +328,15 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) /* * The mutex was marked contested on release. This means that - * there are processes blocked on it. + * there are threads blocked on it. */ if (v == MTX_CONTESTED) { - p1 = TAILQ_FIRST(&m->mtx_blocked); - MPASS(p1 != NULL); - m->mtx_lock = (uintptr_t)p | MTX_CONTESTED; + td1 = TAILQ_FIRST(&m->mtx_blocked); + MPASS(td1 != NULL); + m->mtx_lock = (uintptr_t)td | MTX_CONTESTED; - if (p1->p_pri.pri_level < p->p_pri.pri_level) - SET_PRIO(p, p1->p_pri.pri_level); + if (td1->td_ksegrp->kg_pri.pri_level < kg->kg_pri.pri_level) + SET_PRIO(td, td1->td_ksegrp->kg_pri.pri_level); mtx_unlock_spin(&sched_lock); return; } @@ -357,8 +363,8 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) * If we're borrowing an interrupted thread's VM context, we * must clean up before going to sleep. */ - if (p->p_ithd != NULL) { - struct ithd *it = p->p_ithd; + if (td->td_ithd != NULL) { + struct ithd *it = td->td_ithd; if (it->it_interrupted) { if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -374,39 +380,39 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) * Put us on the list of threads blocked on this mutex. */ if (TAILQ_EMPTY(&m->mtx_blocked)) { - p1 = (struct proc *)(m->mtx_lock & MTX_FLAGMASK); - LIST_INSERT_HEAD(&p1->p_contested, m, mtx_contested); - TAILQ_INSERT_TAIL(&m->mtx_blocked, p, p_procq); + td1 = (struct thread *)(m->mtx_lock & MTX_FLAGMASK); + LIST_INSERT_HEAD(&td1->td_contested, m, mtx_contested); + TAILQ_INSERT_TAIL(&m->mtx_blocked, td, td_blkq); } else { - TAILQ_FOREACH(p1, &m->mtx_blocked, p_procq) - if (p1->p_pri.pri_level > p->p_pri.pri_level) + TAILQ_FOREACH(td1, &m->mtx_blocked, td_blkq) + if (td1->td_ksegrp->kg_pri.pri_level > kg->kg_pri.pri_level) break; - if (p1) - TAILQ_INSERT_BEFORE(p1, p, p_procq); + if (td1) + TAILQ_INSERT_BEFORE(td1, td, td_blkq); else - TAILQ_INSERT_TAIL(&m->mtx_blocked, p, p_procq); + TAILQ_INSERT_TAIL(&m->mtx_blocked, td, td_blkq); } /* * Save who we're blocked on. */ - p->p_blocked = m; - p->p_mtxname = m->mtx_object.lo_name; - p->p_stat = SMTX; - propagate_priority(p); + td->td_blocked = m; + td->td_mtxname = m->mtx_object.lo_name; + td->td_proc->p_stat = SMTX; + propagate_priority(td); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR3(KTR_LOCK, - "_mtx_lock_sleep: p %p blocked on [%p] %s", p, m, + "_mtx_lock_sleep: p %p blocked on [%p] %s", td, m, m->mtx_object.lo_name); - p->p_stats->p_ru.ru_nvcsw++; + td->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR3(KTR_LOCK, "_mtx_lock_sleep: p %p free from blocked on [%p] %s", - p, m, m->mtx_object.lo_name); + td, m, m->mtx_object.lo_name); mtx_unlock_spin(&sched_lock); } @@ -430,7 +436,7 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file, CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); for (;;) { - if (_obtain_lock(m, curproc)) + if (_obtain_lock(m, curthread)) break; /* Give interrupts a chance while we spin. */ @@ -467,11 +473,13 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file, void _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) { - struct proc *p, *p1; + struct thread *td, *td1; struct mtx *m1; int pri; + struct ksegrp *kg; - p = curproc; + td = curthread; + kg = td->td_ksegrp; if (mtx_recursed(m)) { if (--(m->mtx_recurse) == 0) @@ -485,11 +493,11 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m); - p1 = TAILQ_FIRST(&m->mtx_blocked); - MPASS(p->p_magic == P_MAGIC); - MPASS(p1->p_magic == P_MAGIC); + td1 = TAILQ_FIRST(&m->mtx_blocked); + MPASS(td->td_proc->p_magic == P_MAGIC); + MPASS(td1->td_proc->p_magic == P_MAGIC); - TAILQ_REMOVE(&m->mtx_blocked, p1, p_procq); + TAILQ_REMOVE(&m->mtx_blocked, td1, td_blkq); if (TAILQ_EMPTY(&m->mtx_blocked)) { LIST_REMOVE(m, mtx_contested); @@ -500,28 +508,28 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) atomic_store_rel_ptr(&m->mtx_lock, (void *)MTX_CONTESTED); pri = PRI_MAX; - LIST_FOREACH(m1, &p->p_contested, mtx_contested) { - int cp = TAILQ_FIRST(&m1->mtx_blocked)->p_pri.pri_level; + LIST_FOREACH(m1, &td->td_contested, mtx_contested) { + int cp = TAILQ_FIRST(&m1->mtx_blocked)->td_ksegrp->kg_pri.pri_level; if (cp < pri) pri = cp; } - if (pri > p->p_pri.pri_native) - pri = p->p_pri.pri_native; - SET_PRIO(p, pri); + if (pri > kg->kg_pri.pri_native) + pri = kg->kg_pri.pri_native; + SET_PRIO(td, pri); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p contested setrunqueue %p", - m, p1); + m, td1); - p1->p_blocked = NULL; - p1->p_stat = SRUN; - setrunqueue(p1); + td1->td_blocked = NULL; + td1->td_proc->p_stat = SRUN; + setrunqueue(td1); - if ((opts & MTX_NOSWITCH) == 0 && p1->p_pri.pri_level < pri) { + if ((opts & MTX_NOSWITCH) == 0 && td1->td_ksegrp->kg_pri.pri_level < pri) { #ifdef notyet - if (p->p_ithd != NULL) { - struct ithd *it = p->p_ithd; + if (td->td_ithd != NULL) { + struct ithd *it = td->td_ithd; if (it->it_interrupted) { if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -532,13 +540,13 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) } } #endif - setrunqueue(p); + setrunqueue(td); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p switching out lock=%p", m, (void *)m->mtx_lock); - p->p_stats->p_ru.ru_nivcsw++; + td->td_proc->p_stats->p_ru.ru_nivcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p resuming lock=%p", diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index ecbafd0..51ccd49 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -464,6 +464,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) struct lock_class *class; struct witness *w, *w1; struct proc *p; + struct thread *td; int i, j; #ifdef DDB int go_into_ddb = 0; @@ -474,7 +475,8 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) return; w = lock->lo_witness; class = lock->lo_class; - p = curproc; + td = curthread; + p = td->td_proc; /* * We have to hold a spinlock to keep lock_list valid across the check @@ -493,7 +495,7 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line) panic("blockable sleep lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); } - lock_list = &p->p_sleeplocks; + lock_list = &td->td_sleeplocks; } mtx_unlock_spin(&w_mtx); @@ -732,7 +734,7 @@ witness_upgrade(struct lock_object *lock, int flags, const char *file, int line) if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) panic("upgrade of non-sleep lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); - instance = find_instance(curproc->p_sleeplocks, lock); + instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("upgrade of unlocked lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); @@ -763,7 +765,7 @@ witness_downgrade(struct lock_object *lock, int flags, const char *file, if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) panic("downgrade of non-sleep lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); - instance = find_instance(curproc->p_sleeplocks, lock); + instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("downgrade of unlocked lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); @@ -784,16 +786,18 @@ witness_unlock(struct lock_object *lock, int flags, const char *file, int line) struct lock_instance *instance; struct lock_class *class; struct proc *p; + struct thread *td; critical_t s; int i, j; if (witness_cold || witness_dead || lock->lo_witness == NULL || panicstr != NULL) return; - p = curproc; + td = curthread; + p = td->td_proc; class = lock->lo_class; if (class->lc_flags & LC_SLEEPLOCK) - lock_list = &p->p_sleeplocks; + lock_list = &td->td_sleeplocks; else lock_list = PCPU_PTR(spinlocks); for (; *lock_list != NULL; lock_list = &(*lock_list)->ll_next) @@ -883,6 +887,7 @@ witness_sleep(int check_only, struct lock_object *lock, const char *file, struct lock_list_entry **lock_list, *lle; struct lock_instance *lock1; struct proc *p; + struct thread *td; critical_t savecrit; int i, n; @@ -894,8 +899,9 @@ witness_sleep(int check_only, struct lock_object *lock, const char *file, * Preemption bad because we need PCPU_PTR(spinlocks) to not change. */ savecrit = critical_enter(); - p = curproc; - lock_list = &p->p_sleeplocks; + td = curthread; + p = td->td_proc; + lock_list = &td->td_sleeplocks; again: for (lle = *lock_list; lle != NULL; lle = lle->ll_next) for (i = lle->ll_count - 1; i >= 0; i--) { @@ -920,7 +926,7 @@ again: lock1->li_lock->lo_name, lock1->li_file, lock1->li_line); } - if (lock_list == &p->p_sleeplocks) { + if (lock_list == &td->td_sleeplocks) { lock_list = PCPU_PTR(spinlocks); goto again; } @@ -1323,35 +1329,35 @@ witness_list_locks(struct lock_list_entry **lock_list) } /* - * Calling this on p != curproc is bad unless we are in ddb. + * Calling this on td != curthread is bad unless we are in ddb. */ int -witness_list(struct proc *p) +witness_list(struct thread *td) { critical_t savecrit; int nheld; KASSERT(!witness_cold, ("%s: witness_cold", __func__)); #ifdef DDB - KASSERT(p == curproc || db_active, - ("%s: p != curproc and we aren't in the debugger", __func__)); + KASSERT(td == curthread || db_active, + ("%s: td != curthread and we aren't in the debugger", __func__)); if (!db_active && witness_dead) return (0); #else - KASSERT(p == curproc, ("%s: p != curproc", __func__)); + KASSERT(td == curthread, ("%s: p != curthread", __func__)); if (witness_dead) return (0); #endif - nheld = witness_list_locks(&p->p_sleeplocks); + nheld = witness_list_locks(&td->td_sleeplocks); /* - * We only handle spinlocks if p == curproc. This is somewhat broken + * We only handle spinlocks if td == curthread. This is somewhat broken * if p is currently executing on some other CPU and holds spin locks * as we won't display those locks. If we had a MI way of getting * the per-cpu data for a given cpu then we could use p->p_oncpu to * get the list of spinlocks for this process and "fix" this. */ - if (p == curproc) { + if (td == curthread) { /* * Preemption bad because we need PCPU_PTR(spinlocks) to not * change. @@ -1374,7 +1380,7 @@ witness_save(struct lock_object *lock, const char **filep, int *linep) if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) panic("%s: lock (%s) %s is not a sleep lock", __func__, lock->lo_class->lc_name, lock->lo_name); - instance = find_instance(curproc->p_sleeplocks, lock); + instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("%s: lock (%s) %s not locked", __func__, lock->lo_class->lc_name, lock->lo_name); @@ -1393,7 +1399,7 @@ witness_restore(struct lock_object *lock, const char *file, int line) if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) panic("%s: lock (%s) %s is not a sleep lock", __func__, lock->lo_class->lc_name, lock->lo_name); - instance = find_instance(curproc->p_sleeplocks, lock); + instance = find_instance(curthread->td_sleeplocks, lock); if (instance == NULL) panic("%s: lock (%s) %s not locked", __func__, lock->lo_class->lc_name, lock->lo_name); @@ -1412,7 +1418,7 @@ witness_assert(struct lock_object *lock, int flags, const char *file, int line) if (lock->lo_witness == NULL || witness_dead || panicstr != NULL) return; if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) != 0) - instance = find_instance(curproc->p_sleeplocks, lock); + instance = find_instance(curthread->td_sleeplocks, lock); else if ((lock->lo_class->lc_flags & LC_SPINLOCK) != 0) instance = find_instance(PCPU_GET(spinlocks), lock); else @@ -1464,15 +1470,16 @@ witness_assert(struct lock_object *lock, int flags, const char *file, int line) DB_SHOW_COMMAND(locks, db_witness_list) { - struct proc *p; + struct thread *td; pid_t pid; + struct proc *p; if (have_addr) { pid = (addr % 16) + ((addr >> 4) % 16) * 10 + ((addr >> 8) % 16) * 100 + ((addr >> 12) % 16) * 1000 + ((addr >> 16) % 16) * 10000; /* sx_slock(&allproc_lock); */ - LIST_FOREACH(p, &allproc, p_list) { + FOREACH_PROC_IN_SYSTEM(p) { if (p->p_pid == pid) break; } @@ -1481,9 +1488,11 @@ DB_SHOW_COMMAND(locks, db_witness_list) db_printf("pid %d not found\n", pid); return; } - } else - p = curproc; - witness_list(p); + td = &p->p_thread; /* XXXKSE */ + } else { + td = curthread; + } + witness_list(td); } DB_SHOW_COMMAND(witness, db_witness_display) diff --git a/sys/kern/subr_xxx.c b/sys/kern/subr_xxx.c index f3fd2ed..094b67c 100644 --- a/sys/kern/subr_xxx.c +++ b/sys/kern/subr_xxx.c @@ -80,22 +80,22 @@ nullop() */ int -noopen(dev, flags, fmt, p) +noopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { return (ENODEV); } int -noclose(dev, flags, fmt, p) +noclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { return (ENODEV); @@ -122,12 +122,12 @@ nowrite(dev, uio, ioflag) } int -noioctl(dev, cmd, data, flags, p) +noioctl(dev, cmd, data, flags, td) dev_t dev; u_long cmd; caddr_t data; int flags; - struct proc *p; + struct thread *td; { return (ENODEV); @@ -172,22 +172,22 @@ nodump(dev) * minor number. */ int -nullopen(dev, flags, fmt, p) +nullopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { return (0); } int -nullclose(dev, flags, fmt, p) +nullclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { return (0); diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 945530a..a897979 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -74,13 +74,13 @@ static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer"); static MALLOC_DEFINE(M_SELECT, "select", "select() buffer"); MALLOC_DEFINE(M_IOV, "iov", "large iov's"); -static int pollscan __P((struct proc *, struct pollfd *, u_int)); -static int pollholddrop __P((struct proc *, struct pollfd *, u_int, int)); -static int selscan __P((struct proc *, fd_mask **, fd_mask **, int)); -static int selholddrop __P((struct proc *, fd_mask *, fd_mask *, int, int)); -static int dofileread __P((struct proc *, struct file *, int, void *, +static int pollscan __P((struct thread *, struct pollfd *, u_int)); +static int pollholddrop __P((struct thread *, struct pollfd *, u_int, int)); +static int selscan __P((struct thread *, fd_mask **, fd_mask **, int)); +static int selholddrop __P((struct thread *, fd_mask *, fd_mask *, int, int)); +static int dofileread __P((struct thread *, struct file *, int, void *, size_t, off_t, int)); -static int dofilewrite __P((struct proc *, struct file *, int, +static int dofilewrite __P((struct thread *, struct file *, int, const void *, size_t, off_t, int)); struct file* @@ -113,18 +113,18 @@ struct read_args { * MPSAFE */ int -read(p, uap) - struct proc *p; +read(td, uap) + struct thread *td; register struct read_args *uap; { register struct file *fp; int error; mtx_lock(&Giant); - if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) != NULL) { - error = dofileread(p, fp, uap->fd, uap->buf, + if ((fp = holdfp(td->td_proc->p_fd, uap->fd, FREAD)) != NULL) { + error = dofileread(td, fp, uap->fd, uap->buf, uap->nbyte, (off_t)-1, 0); - fdrop(fp, p); + fdrop(fp, td); } else { error = EBADF; } @@ -148,23 +148,23 @@ struct pread_args { * MPSAFE */ int -pread(p, uap) - struct proc *p; +pread(td, uap) + struct thread *td; register struct pread_args *uap; { register struct file *fp; int error; mtx_lock(&Giant); - if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) == NULL) { + if ((fp = holdfp(td->td_proc->p_fd, uap->fd, FREAD)) == NULL) { error = EBADF; } else if (fp->f_type != DTYPE_VNODE) { error = ESPIPE; - fdrop(fp, p); + fdrop(fp, td); } else { - error = dofileread(p, fp, uap->fd, uap->buf, uap->nbyte, + error = dofileread(td, fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); - fdrop(fp, p); + fdrop(fp, td); } mtx_unlock(&Giant); return(error); @@ -174,8 +174,8 @@ pread(p, uap) * Code common for read and pread */ int -dofileread(p, fp, fd, buf, nbyte, offset, flags) - struct proc *p; +dofileread(td, fp, fd, buf, nbyte, offset, flags) + struct thread *td; struct file *fp; int fd, flags; void *buf; @@ -201,12 +201,12 @@ dofileread(p, fp, fd, buf, nbyte, offset, flags) auio.uio_resid = nbyte; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; #ifdef KTRACE /* * if tracing, save a copy of iovec */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { ktriov = aiov; ktruio = auio; didktr = 1; @@ -214,7 +214,7 @@ dofileread(p, fp, fd, buf, nbyte, offset, flags) #endif cnt = nbyte; - if ((error = fo_read(fp, &auio, fp->f_cred, flags, p))) { + if ((error = fo_read(fp, &auio, fp->f_cred, flags, td))) { if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; @@ -224,10 +224,10 @@ dofileread(p, fp, fd, buf, nbyte, offset, flags) if (didktr && error == 0) { ktruio.uio_iov = &ktriov; ktruio.uio_resid = cnt; - ktrgenio(p->p_tracep, fd, UIO_READ, &ktruio, error); + ktrgenio(td->td_proc->p_tracep, fd, UIO_READ, &ktruio, error); } #endif - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; return (error); } @@ -245,8 +245,8 @@ struct readv_args { * MPSAFE */ int -readv(p, uap) - struct proc *p; +readv(td, uap) + struct thread *td; register struct readv_args *uap; { register struct file *fp; @@ -262,7 +262,7 @@ readv(p, uap) struct uio ktruio; #endif mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((fp = holdfp(fdp, uap->fd, FREAD)) == NULL) { error = EBADF; @@ -285,7 +285,7 @@ readv(p, uap) auio.uio_iovcnt = uap->iovcnt; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = -1; if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) goto done; @@ -302,14 +302,14 @@ readv(p, uap) /* * if tracing, save a copy of iovec */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); ktruio = auio; } #endif cnt = auio.uio_resid; - if ((error = fo_read(fp, &auio, fp->f_cred, 0, p))) { + if ((error = fo_read(fp, &auio, fp->f_cred, 0, td))) { if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; @@ -320,15 +320,15 @@ readv(p, uap) if (error == 0) { ktruio.uio_iov = ktriov; ktruio.uio_resid = cnt; - ktrgenio(p->p_tracep, uap->fd, UIO_READ, &ktruio, + ktrgenio(td->td_proc->p_tracep, uap->fd, UIO_READ, &ktruio, error); } FREE(ktriov, M_TEMP); } #endif - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: - fdrop(fp, p); + fdrop(fp, td); if (needfree) FREE(needfree, M_IOV); done2: @@ -350,18 +350,18 @@ struct write_args { * MPSAFE */ int -write(p, uap) - struct proc *p; +write(td, uap) + struct thread *td; register struct write_args *uap; { register struct file *fp; int error; mtx_lock(&Giant); - if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) != NULL) { - error = dofilewrite(p, fp, uap->fd, uap->buf, uap->nbyte, + if ((fp = holdfp(td->td_proc->p_fd, uap->fd, FWRITE)) != NULL) { + error = dofilewrite(td, fp, uap->fd, uap->buf, uap->nbyte, (off_t)-1, 0); - fdrop(fp, p); + fdrop(fp, td); } else { error = EBADF; } @@ -385,31 +385,31 @@ struct pwrite_args { * MPSAFE */ int -pwrite(p, uap) - struct proc *p; +pwrite(td, uap) + struct thread *td; register struct pwrite_args *uap; { register struct file *fp; int error; mtx_lock(&Giant); - if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) == NULL) { + if ((fp = holdfp(td->td_proc->p_fd, uap->fd, FWRITE)) == NULL) { error = EBADF; } else if (fp->f_type != DTYPE_VNODE) { error = ESPIPE; - fdrop(fp, p); + fdrop(fp, td); } else { - error = dofilewrite(p, fp, uap->fd, uap->buf, uap->nbyte, + error = dofilewrite(td, fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); - fdrop(fp, p); + fdrop(fp, td); } mtx_unlock(&Giant); return(error); } static int -dofilewrite(p, fp, fd, buf, nbyte, offset, flags) - struct proc *p; +dofilewrite(td, fp, fd, buf, nbyte, offset, flags) + struct thread *td; struct file *fp; int fd, flags; const void *buf; @@ -435,12 +435,12 @@ dofilewrite(p, fp, fd, buf, nbyte, offset, flags) auio.uio_resid = nbyte; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; #ifdef KTRACE /* * if tracing, save a copy of iovec and uio */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { ktriov = aiov; ktruio = auio; didktr = 1; @@ -449,14 +449,14 @@ dofilewrite(p, fp, fd, buf, nbyte, offset, flags) cnt = nbyte; if (fp->f_type == DTYPE_VNODE) bwillwrite(); - if ((error = fo_write(fp, &auio, fp->f_cred, flags, p))) { + if ((error = fo_write(fp, &auio, fp->f_cred, flags, td))) { if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; if (error == EPIPE) { - PROC_LOCK(p); - psignal(p, SIGPIPE); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGPIPE); + PROC_UNLOCK(td->td_proc); } } cnt -= auio.uio_resid; @@ -464,10 +464,10 @@ dofilewrite(p, fp, fd, buf, nbyte, offset, flags) if (didktr && error == 0) { ktruio.uio_iov = &ktriov; ktruio.uio_resid = cnt; - ktrgenio(p->p_tracep, fd, UIO_WRITE, &ktruio, error); + ktrgenio(td->td_proc->p_tracep, fd, UIO_WRITE, &ktruio, error); } #endif - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; return (error); } @@ -485,8 +485,8 @@ struct writev_args { * MPSAFE */ int -writev(p, uap) - struct proc *p; +writev(td, uap) + struct thread *td; register struct writev_args *uap; { register struct file *fp; @@ -503,7 +503,7 @@ writev(p, uap) #endif mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((fp = holdfp(fdp, uap->fd, FWRITE)) == NULL) { error = EBADF; goto done2; @@ -526,7 +526,7 @@ writev(p, uap) auio.uio_iovcnt = uap->iovcnt; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = -1; if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) goto done; @@ -543,7 +543,7 @@ writev(p, uap) /* * if tracing, save a copy of iovec and uio */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); ktruio = auio; @@ -552,14 +552,14 @@ writev(p, uap) cnt = auio.uio_resid; if (fp->f_type == DTYPE_VNODE) bwillwrite(); - if ((error = fo_write(fp, &auio, fp->f_cred, 0, p))) { + if ((error = fo_write(fp, &auio, fp->f_cred, 0, td))) { if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; if (error == EPIPE) { - PROC_LOCK(p); - psignal(p, SIGPIPE); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGPIPE); + PROC_UNLOCK(td->td_proc); } } cnt -= auio.uio_resid; @@ -568,15 +568,15 @@ writev(p, uap) if (error == 0) { ktruio.uio_iov = ktriov; ktruio.uio_resid = cnt; - ktrgenio(p->p_tracep, uap->fd, UIO_WRITE, &ktruio, + ktrgenio(td->td_proc->p_tracep, uap->fd, UIO_WRITE, &ktruio, error); } FREE(ktriov, M_TEMP); } #endif - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: - fdrop(fp, p); + fdrop(fp, td); if (needfree) FREE(needfree, M_IOV); done2: @@ -599,8 +599,8 @@ struct ioctl_args { */ /* ARGSUSED */ int -ioctl(p, uap) - struct proc *p; +ioctl(td, uap) + struct thread *td; register struct ioctl_args *uap; { register struct file *fp; @@ -617,7 +617,7 @@ ioctl(p, uap) } ubuf; mtx_lock(&Giant); - fdp = p->p_fd; + fdp = td->td_proc->p_fd; if ((u_int)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) { error = EBADF; @@ -663,7 +663,7 @@ ioctl(p, uap) if (error) { if (memp) free(memp, M_IOCTLOPS); - fdrop(fp, p); + fdrop(fp, td); goto done2; } } else { @@ -686,7 +686,7 @@ ioctl(p, uap) fp->f_flag |= FNONBLOCK; else fp->f_flag &= ~FNONBLOCK; - error = fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, p); + error = fo_ioctl(fp, FIONBIO, (caddr_t)&tmp, td); break; case FIOASYNC: @@ -694,11 +694,11 @@ ioctl(p, uap) fp->f_flag |= FASYNC; else fp->f_flag &= ~FASYNC; - error = fo_ioctl(fp, FIOASYNC, (caddr_t)&tmp, p); + error = fo_ioctl(fp, FIOASYNC, (caddr_t)&tmp, td); break; default: - error = fo_ioctl(fp, com, data, p); + error = fo_ioctl(fp, com, data, td); /* * Copy any data to user, size was * already set and checked above. @@ -709,7 +709,7 @@ ioctl(p, uap) } if (memp) free(memp, M_IOCTLOPS); - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -733,8 +733,8 @@ struct select_args { * MPSAFE */ int -select(p, uap) - register struct proc *p; +select(td, uap) + register struct thread *td; register struct select_args *uap; { /* @@ -755,8 +755,8 @@ select(p, uap) mtx_lock(&Giant); - if (uap->nd > p->p_fd->fd_nfiles) - uap->nd = p->p_fd->fd_nfiles; /* forgiving; slightly wrong */ + if (uap->nd > td->td_proc->p_fd->fd_nfiles) + uap->nd = td->td_proc->p_fd->fd_nfiles; /* forgiving; slightly wrong */ /* * Allocate just enough bits for the non-null fd_sets. Use the @@ -828,16 +828,16 @@ select(p, uap) atv.tv_sec = 0; atv.tv_usec = 0; } - selholddrop(p, hibits, hobits, uap->nd, 1); + selholddrop(td, hibits, hobits, uap->nd, 1); timo = 0; - PROC_LOCK(p); + PROC_LOCK(td->td_proc); retry: ncoll = nselcoll; - p->p_flag |= P_SELECT; - PROC_UNLOCK(p); - error = selscan(p, ibits, obits, uap->nd); - PROC_LOCK(p); - if (error || p->p_retval[0]) + td->td_flags |= TDF_SELECT; + PROC_UNLOCK(td->td_proc); + error = selscan(td, ibits, obits, uap->nd); + PROC_LOCK(td->td_proc); + if (error || td->td_retval[0]) goto done; if (atv.tv_sec || atv.tv_usec) { getmicrouptime(&rtv); @@ -845,15 +845,15 @@ retry: /* * An event of our interest may occur during locking a process. * In order to avoid missing the event that occured during locking - * the process, test P_SELECT and rescan file descriptors if + * the process, test TDF_SELECT and rescan file descriptors if * necessary. */ - if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { + if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { ncoll = nselcoll; - p->p_flag |= P_SELECT; - PROC_UNLOCK(p); - error = selscan(p, ibits, obits, uap->nd); - PROC_LOCK(p); + td->td_flags |= TDF_SELECT; + PROC_UNLOCK(td->td_proc); + error = selscan(td, ibits, obits, uap->nd); + PROC_LOCK(td->td_proc); } goto done; } @@ -862,20 +862,20 @@ retry: timo = ttv.tv_sec > 24 * 60 * 60 ? 24 * 60 * 60 * hz : tvtohz(&ttv); } - p->p_flag &= ~P_SELECT; + td->td_flags &= ~TDF_SELECT; if (timo > 0) - error = cv_timedwait_sig(&selwait, &p->p_mtx, timo); + error = cv_timedwait_sig(&selwait, &td->td_proc->p_mtx, timo); else - error = cv_wait_sig(&selwait, &p->p_mtx); + error = cv_wait_sig(&selwait, &td->td_proc->p_mtx); if (error == 0) goto retry; done: - p->p_flag &= ~P_SELECT; - PROC_UNLOCK(p); - selholddrop(p, hibits, hobits, uap->nd, 0); + td->td_flags &= ~TDF_SELECT; + PROC_UNLOCK(td->td_proc); + selholddrop(td, hibits, hobits, uap->nd, 0); done_noproclock: /* select is not restarted after signals... */ if (error == ERESTART) @@ -903,12 +903,12 @@ done_noproclock: } static int -selholddrop(p, ibits, obits, nfd, hold) - struct proc *p; +selholddrop(td, ibits, obits, nfd, hold) + struct thread *td; fd_mask *ibits, *obits; int nfd, hold; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; int i, fd; fd_mask bits; struct file *fp; @@ -930,19 +930,19 @@ selholddrop(p, ibits, obits, nfd, hold) obits[(fd)/NFDBITS] |= ((fd_mask)1 << ((fd) % NFDBITS)); } else - fdrop(fp, p); + fdrop(fp, td); } } return (0); } static int -selscan(p, ibits, obits, nfd) - struct proc *p; +selscan(td, ibits, obits, nfd) + struct thread *td; fd_mask **ibits, **obits; int nfd; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; int msk, i, fd; fd_mask bits; struct file *fp; @@ -962,7 +962,7 @@ selscan(p, ibits, obits, nfd) fp = fdp->fd_ofiles[fd]; if (fp == NULL) return (EBADF); - if (fo_poll(fp, flag[msk], fp->f_cred, p)) { + if (fo_poll(fp, flag[msk], fp->f_cred, td)) { obits[msk][(fd)/NFDBITS] |= ((fd_mask)1 << ((fd) % NFDBITS)); n++; @@ -970,7 +970,7 @@ selscan(p, ibits, obits, nfd) } } } - p->p_retval[0] = n; + td->td_retval[0] = n; return (0); } @@ -988,8 +988,8 @@ struct poll_args { * MPSAFE */ int -poll(p, uap) - struct proc *p; +poll(td, uap) + struct thread *td; struct poll_args *uap; { caddr_t bits; @@ -1011,7 +1011,8 @@ poll(p, uap) * least enough for the current limits. We want to be reasonably * safe, but not overly restrictive. */ - if (nfds > p->p_rlimit[RLIMIT_NOFILE].rlim_cur && nfds > FD_SETSIZE) { + if ((nfds > td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur) && + (nfds > FD_SETSIZE)) { error = EINVAL; goto done2; } @@ -1043,16 +1044,16 @@ poll(p, uap) atv.tv_sec = 0; atv.tv_usec = 0; } - pollholddrop(p, heldbits, nfds, 1); + pollholddrop(td, heldbits, nfds, 1); timo = 0; - PROC_LOCK(p); + PROC_LOCK(td->td_proc); retry: ncoll = nselcoll; - p->p_flag |= P_SELECT; - PROC_UNLOCK(p); - error = pollscan(p, (struct pollfd *)bits, nfds); - PROC_LOCK(p); - if (error || p->p_retval[0]) + td->td_flags |= TDF_SELECT; + PROC_UNLOCK(td->td_proc); + error = pollscan(td, (struct pollfd *)bits, nfds); + PROC_LOCK(td->td_proc); + if (error || td->td_retval[0]) goto done; if (atv.tv_sec || atv.tv_usec) { getmicrouptime(&rtv); @@ -1060,15 +1061,15 @@ retry: /* * An event of our interest may occur during locking a process. * In order to avoid missing the event that occured during locking - * the process, test P_SELECT and rescan file descriptors if + * the process, test TDF_SELECT and rescan file descriptors if * necessary. */ - if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { + if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { ncoll = nselcoll; - p->p_flag |= P_SELECT; - PROC_UNLOCK(p); - error = pollscan(p, (struct pollfd *)bits, nfds); - PROC_LOCK(p); + td->td_flags |= TDF_SELECT; + PROC_UNLOCK(td->td_proc); + error = pollscan(td, (struct pollfd *)bits, nfds); + PROC_LOCK(td->td_proc); } goto done; } @@ -1077,18 +1078,18 @@ retry: timo = ttv.tv_sec > 24 * 60 * 60 ? 24 * 60 * 60 * hz : tvtohz(&ttv); } - p->p_flag &= ~P_SELECT; + td->td_flags &= ~TDF_SELECT; if (timo > 0) - error = cv_timedwait_sig(&selwait, &p->p_mtx, timo); + error = cv_timedwait_sig(&selwait, &td->td_proc->p_mtx, timo); else - error = cv_wait_sig(&selwait, &p->p_mtx); + error = cv_wait_sig(&selwait, &td->td_proc->p_mtx); if (error == 0) goto retry; done: - p->p_flag &= ~P_SELECT; - PROC_UNLOCK(p); - pollholddrop(p, heldbits, nfds, 0); + td->td_flags &= ~TDF_SELECT; + PROC_UNLOCK(td->td_proc); + pollholddrop(td, heldbits, nfds, 0); done_noproclock: /* poll is not restarted after signals... */ if (error == ERESTART) @@ -1111,13 +1112,13 @@ done2: } static int -pollholddrop(p, fds, nfd, hold) - struct proc *p; +pollholddrop(td, fds, nfd, hold) + struct thread *td; struct pollfd *fds; u_int nfd; int hold; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int i; struct file *fp; @@ -1131,19 +1132,19 @@ pollholddrop(p, fds, nfd, hold) } else fds->revents = 0; } else if(fp != NULL && fds->revents) - fdrop(fp, p); + fdrop(fp, td); } } return (0); } static int -pollscan(p, fds, nfd) - struct proc *p; +pollscan(td, fds, nfd) + struct thread *td; struct pollfd *fds; u_int nfd; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int i; struct file *fp; int n = 0; @@ -1165,13 +1166,13 @@ pollscan(p, fds, nfd) * POLLERR if appropriate. */ fds->revents = fo_poll(fp, fds->events, - fp->f_cred, p); + fp->f_cred, td); if (fds->revents != 0) n++; } } } - p->p_retval[0] = n; + td->td_retval[0] = n; return (0); } @@ -1190,41 +1191,57 @@ struct openbsd_poll_args { * MPSAFE */ int -openbsd_poll(p, uap) - register struct proc *p; +openbsd_poll(td, uap) + register struct thread *td; register struct openbsd_poll_args *uap; { - return (poll(p, (struct poll_args *)uap)); + return (poll(td, (struct poll_args *)uap)); } /*ARGSUSED*/ int -seltrue(dev, events, p) +seltrue(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); } +static int +find_thread_in_proc(struct proc *p, struct thread *td) +{ + struct thread *td2; + FOREACH_THREAD_IN_PROC(p, td2) { + if (td2 == td) { + return (1); + } + } + return (0); +} + /* * Record a select request. */ void selrecord(selector, sip) - struct proc *selector; + struct thread *selector; struct selinfo *sip; { struct proc *p; pid_t mypid; - mypid = selector->p_pid; - if (sip->si_pid == mypid) + mypid = selector->td_proc->p_pid; + if ((sip->si_pid == mypid) && + (sip->si_thread == selector)) { /* XXXKSE should be an ID? */ return; - if (sip->si_pid && (p = pfind(sip->si_pid))) { + } + if (sip->si_pid && + (p = pfind(sip->si_pid)) && + (find_thread_in_proc(p, sip->si_thread))) { mtx_lock_spin(&sched_lock); - if (p->p_wchan == (caddr_t)&selwait) { + if (sip->si_thread->td_wchan == (caddr_t)&selwait) { mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); sip->si_flags |= SI_COLL; @@ -1234,6 +1251,7 @@ selrecord(selector, sip) PROC_UNLOCK(p); } sip->si_pid = mypid; + sip->si_thread = selector; } /* @@ -1243,6 +1261,7 @@ void selwakeup(sip) register struct selinfo *sip; { + struct thread *td; register struct proc *p; if (sip->si_pid == 0) @@ -1254,17 +1273,22 @@ selwakeup(sip) } p = pfind(sip->si_pid); sip->si_pid = 0; + td = sip->si_thread; if (p != NULL) { + if (!find_thread_in_proc(p, td)) { + PROC_UNLOCK(p); /* lock is in pfind() */; + return; + } mtx_lock_spin(&sched_lock); - if (p->p_wchan == (caddr_t)&selwait) { - if (p->p_stat == SSLEEP) - setrunnable(p); + if (td->td_wchan == (caddr_t)&selwait) { + if (td->td_proc->p_stat == SSLEEP) + setrunnable(td); else - cv_waitq_remove(p); + cv_waitq_remove(td); } else - p->p_flag &= ~P_SELECT; + td->td_flags &= ~TDF_SELECT; mtx_unlock_spin(&sched_lock); - PROC_UNLOCK(p); + PROC_UNLOCK(p); /* Lock is in pfind() */ } } diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index dcc57d8..b543ddf 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -90,15 +90,15 @@ * interfaces to the outside world */ static int pipe_read __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); static int pipe_write __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); -static int pipe_close __P((struct file *fp, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); +static int pipe_close __P((struct file *fp, struct thread *td)); static int pipe_poll __P((struct file *fp, int events, struct ucred *cred, - struct proc *p)); + struct thread *td)); static int pipe_kqfilter __P((struct file *fp, struct knote *kn)); -static int pipe_stat __P((struct file *fp, struct stat *sb, struct proc *p)); -static int pipe_ioctl __P((struct file *fp, u_long cmd, caddr_t data, struct proc *p)); +static int pipe_stat __P((struct file *fp, struct stat *sb, struct thread *td)); +static int pipe_ioctl __P((struct file *fp, u_long cmd, caddr_t data, struct thread *td)); static struct fileops pipeops = { pipe_read, pipe_write, pipe_ioctl, pipe_poll, pipe_kqfilter, @@ -166,13 +166,13 @@ static vm_zone_t pipe_zone; /* ARGSUSED */ int -pipe(p, uap) - struct proc *p; +pipe(td, uap) + struct thread *td; struct pipe_args /* { int dummy; } */ *uap; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *rf, *wf; struct pipe *rpipe, *wpipe; int fd, error; @@ -190,14 +190,14 @@ pipe(p, uap) rpipe->pipe_state |= PIPE_DIRECTOK; wpipe->pipe_state |= PIPE_DIRECTOK; - error = falloc(p, &rf, &fd); + error = falloc(td, &rf, &fd); if (error) { pipeclose(rpipe); pipeclose(wpipe); return (error); } fhold(rf); - p->p_retval[0] = fd; + td->td_retval[0] = fd; /* * Warning: once we've gotten past allocation of the fd for the @@ -209,13 +209,13 @@ pipe(p, uap) rf->f_type = DTYPE_PIPE; rf->f_data = (caddr_t)rpipe; rf->f_ops = &pipeops; - error = falloc(p, &wf, &fd); + error = falloc(td, &wf, &fd); if (error) { - if (fdp->fd_ofiles[p->p_retval[0]] == rf) { - fdp->fd_ofiles[p->p_retval[0]] = NULL; - fdrop(rf, p); + if (fdp->fd_ofiles[td->td_retval[0]] == rf) { + fdp->fd_ofiles[td->td_retval[0]] = NULL; + fdrop(rf, td); } - fdrop(rf, p); + fdrop(rf, td); /* rpipe has been closed by fdrop(). */ pipeclose(wpipe); return (error); @@ -224,11 +224,11 @@ pipe(p, uap) wf->f_type = DTYPE_PIPE; wf->f_data = (caddr_t)wpipe; wf->f_ops = &pipeops; - p->p_retval[1] = fd; + td->td_retval[1] = fd; rpipe->pipe_peer = wpipe; wpipe->pipe_peer = rpipe; - fdrop(rf, p); + fdrop(rf, td); return (0); } @@ -390,11 +390,11 @@ pipeselwakeup(cpipe) /* ARGSUSED */ static int -pipe_read(fp, uio, cred, flags, p) +pipe_read(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { struct pipe *rpipe = (struct pipe *) fp->f_data; @@ -755,11 +755,11 @@ error1: #endif static int -pipe_write(fp, uio, cred, flags, p) +pipe_write(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { int error = 0; @@ -1029,11 +1029,11 @@ pipe_write(fp, uio, cred, flags, p) * we implement a very minimal set of ioctls for compatibility with sockets. */ int -pipe_ioctl(fp, cmd, data, p) +pipe_ioctl(fp, cmd, data, td) struct file *fp; u_long cmd; caddr_t data; - struct proc *p; + struct thread *td; { struct pipe *mpipe = (struct pipe *)fp->f_data; @@ -1078,11 +1078,11 @@ pipe_ioctl(fp, cmd, data, p) } int -pipe_poll(fp, events, cred, p) +pipe_poll(fp, events, cred, td) struct file *fp; int events; struct ucred *cred; - struct proc *p; + struct thread *td; { struct pipe *rpipe = (struct pipe *)fp->f_data; struct pipe *wpipe; @@ -1108,12 +1108,12 @@ pipe_poll(fp, events, cred, p) if (revents == 0) { if (events & (POLLIN | POLLRDNORM)) { - selrecord(p, &rpipe->pipe_sel); + selrecord(curthread, &rpipe->pipe_sel); rpipe->pipe_state |= PIPE_SEL; } if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p, &wpipe->pipe_sel); + selrecord(curthread, &wpipe->pipe_sel); wpipe->pipe_state |= PIPE_SEL; } } @@ -1122,10 +1122,10 @@ pipe_poll(fp, events, cred, p) } static int -pipe_stat(fp, ub, p) +pipe_stat(fp, ub, td) struct file *fp; struct stat *ub; - struct proc *p; + struct thread *td; { struct pipe *pipe = (struct pipe *)fp->f_data; @@ -1148,9 +1148,9 @@ pipe_stat(fp, ub, p) /* ARGSUSED */ static int -pipe_close(fp, p) +pipe_close(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { struct pipe *cpipe = (struct pipe *)fp->f_data; diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index a81a768..96b38a0 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -202,10 +202,11 @@ struct ptrace_args { #endif int -ptrace(curp, uap) - struct proc *curp; +ptrace(td, uap) + struct thread *td; struct ptrace_args *uap; { + struct proc *curp = td->td_proc; struct proc *p; struct iovec iov; struct uio uio; @@ -314,14 +315,14 @@ ptrace(curp, uap) /* * Single step fixup ala procfs */ - FIX_SSTEP(p); + FIX_SSTEP(&p->p_thread); /* XXXKSE */ #endif /* * Actually do the requests */ - curp->p_retval[0] = 0; + td->td_retval[0] = 0; switch (uap->req) { case PT_TRACE_ME: @@ -356,15 +357,15 @@ ptrace(curp, uap) PHOLD(p); if (uap->req == PT_STEP) { - if ((error = ptrace_single_step (p))) { + if ((error = ptrace_single_step (td))) { PRELE(p); return error; } } if (uap->addr != (caddr_t)1) { - fill_kinfo_proc (p, &p->p_addr->u_kproc); - if ((error = ptrace_set_pc (p, + fill_kinfo_proc (p, &p->p_uarea->u_kproc); + if ((error = ptrace_set_pc (td, (u_long)(uintfptr_t)uap->addr))) { PRELE(p); return error; @@ -403,7 +404,7 @@ ptrace(curp, uap) mtx_lock_spin(&sched_lock); if (p->p_stat == SSTOP) { p->p_xstat = uap->data; - setrunnable(p); + setrunnable(&p->p_thread); /* XXXKSE */ mtx_unlock_spin(&sched_lock); } else { mtx_unlock_spin(&sched_lock); @@ -421,7 +422,7 @@ ptrace(curp, uap) case PT_READ_I: case PT_READ_D: /* write = 0 set above */ - iov.iov_base = write ? (caddr_t)&uap->data : (caddr_t)curp->p_retval; + iov.iov_base = write ? (caddr_t)&uap->data : (caddr_t)td->td_retval; iov.iov_len = sizeof(int); uio.uio_iov = &iov; uio.uio_iovcnt = 1; @@ -429,7 +430,7 @@ ptrace(curp, uap) uio.uio_resid = sizeof(int); uio.uio_segflg = UIO_SYSSPACE; /* ie: the uap */ uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; error = procfs_domem(curp, p, NULL, &uio); if (uio.uio_resid != 0) { /* @@ -460,7 +461,7 @@ ptrace(curp, uap) /* write = 0 above */ #endif /* PT_SETREGS */ #if defined(PT_SETREGS) || defined(PT_GETREGS) - if (!procfs_validregs(p)) /* no P_SYSTEM procs please */ + if (!procfs_validregs(td)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; @@ -471,7 +472,7 @@ ptrace(curp, uap) uio.uio_resid = sizeof(struct reg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = td; return (procfs_doregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETREGS) || defined(PT_GETREGS) */ @@ -486,7 +487,7 @@ ptrace(curp, uap) /* write = 0 above */ #endif /* PT_SETFPREGS */ #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) - if (!procfs_validfpregs(p)) /* no P_SYSTEM procs please */ + if (!procfs_validfpregs(td)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; @@ -497,7 +498,7 @@ ptrace(curp, uap) uio.uio_resid = sizeof(struct fpreg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = td; return (procfs_dofpregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETFPREGS) || defined(PT_GETFPREGS) */ @@ -512,7 +513,7 @@ ptrace(curp, uap) /* write = 0 above */ #endif /* PT_SETDBREGS */ #if defined(PT_SETDBREGS) || defined(PT_GETDBREGS) - if (!procfs_validdbregs(p)) /* no P_SYSTEM procs please */ + if (!procfs_validdbregs(td)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; @@ -523,7 +524,7 @@ ptrace(curp, uap) uio.uio_resid = sizeof(struct dbreg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = td; return (procfs_dodbregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETDBREGS) || defined(PT_GETDBREGS) */ diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index dc72a8a..8822fcb 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -57,11 +57,11 @@ struct fileops socketops = { /* ARGSUSED */ int -soo_read(fp, uio, cred, flags, p) +soo_read(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { struct socket *so = (struct socket *)fp->f_data; @@ -70,24 +70,24 @@ soo_read(fp, uio, cred, flags, p) /* ARGSUSED */ int -soo_write(fp, uio, cred, flags, p) +soo_write(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { struct socket *so = (struct socket *)fp->f_data; return so->so_proto->pr_usrreqs->pru_sosend(so, 0, uio, 0, 0, 0, - uio->uio_procp); + uio->uio_td); } int -soo_ioctl(fp, cmd, data, p) +soo_ioctl(fp, cmd, data, td) struct file *fp; u_long cmd; register caddr_t data; - struct proc *p; + struct thread *td; { register struct socket *so = (struct socket *)fp->f_data; @@ -140,28 +140,28 @@ soo_ioctl(fp, cmd, data, p) * different entry since a socket's unnecessary */ if (IOCGROUP(cmd) == 'i') - return (ifioctl(so, cmd, data, p)); + return (ifioctl(so, cmd, data, td)); if (IOCGROUP(cmd) == 'r') return (rtioctl(cmd, data)); - return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, p)); + return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, td)); } int -soo_poll(fp, events, cred, p) +soo_poll(fp, events, cred, td) struct file *fp; int events; struct ucred *cred; - struct proc *p; + struct thread *td; { struct socket *so = (struct socket *)fp->f_data; - return so->so_proto->pr_usrreqs->pru_sopoll(so, events, cred, p); + return so->so_proto->pr_usrreqs->pru_sopoll(so, events, cred, td); } int -soo_stat(fp, ub, p) +soo_stat(fp, ub, td) struct file *fp; struct stat *ub; - struct proc *p; + struct thread *td; { struct socket *so = (struct socket *)fp->f_data; @@ -184,9 +184,9 @@ soo_stat(fp, ub, p) /* ARGSUSED */ int -soo_close(fp, p) +soo_close(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { int error = 0; diff --git a/sys/kern/sysv_ipc.c b/sys/kern/sysv_ipc.c index f28d660..70e2f4b 100644 --- a/sys/kern/sysv_ipc.c +++ b/sys/kern/sysv_ipc.c @@ -83,11 +83,12 @@ shmexit(p) */ int -ipcperm(p, perm, mode) - struct proc *p; +ipcperm(td, perm, mode) + struct thread *td; struct ipc_perm *perm; int mode; { + struct proc *p = td->td_proc; struct ucred *cred = p->p_ucred; /* Check for user match. */ diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index d6badbe..76bb22c 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -269,8 +269,8 @@ MODULE_VERSION(sysvmsg, 1); * MPSAFE */ int -msgsys(p, uap) - struct proc *p; +msgsys(td, uap) + struct thread *td; /* XXX actually varargs. */ struct msgsys_args /* { u_int which; @@ -284,8 +284,7 @@ msgsys(p, uap) int error; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -293,7 +292,7 @@ msgsys(p, uap) error = EINVAL; goto done2; } - error = (*msgcalls[uap->which])(p, &uap->a2); + error = (*msgcalls[uap->which])(td, &uap->a2); done2: mtx_unlock(&Giant); return (error); @@ -335,8 +334,8 @@ struct msgctl_args { * MPSAFE */ int -msgctl(p, uap) - struct proc *p; +msgctl(td, uap) + struct thread *td; register struct msgctl_args *uap; { int msqid = uap->msqid; @@ -350,8 +349,7 @@ msgctl(p, uap) printf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr); #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -392,7 +390,7 @@ msgctl(p, uap) case IPC_RMID: { struct msg *msghdr; - if ((error = ipcperm(p, &msqptr->msg_perm, IPC_M))) + if ((error = ipcperm(td, &msqptr->msg_perm, IPC_M))) goto done2; /* Free the message headers */ msghdr = msqptr->msg_first; @@ -420,12 +418,12 @@ msgctl(p, uap) break; case IPC_SET: - if ((error = ipcperm(p, &msqptr->msg_perm, IPC_M))) + if ((error = ipcperm(td, &msqptr->msg_perm, IPC_M))) goto done2; if ((error = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0) goto done2; if (msqbuf.msg_qbytes > msqptr->msg_qbytes) { - error = suser(p); + error = suser_td(td); if (error) goto done2; } @@ -452,7 +450,7 @@ msgctl(p, uap) break; case IPC_STAT: - if ((error = ipcperm(p, &msqptr->msg_perm, IPC_R))) { + if ((error = ipcperm(td, &msqptr->msg_perm, IPC_R))) { #ifdef MSG_DEBUG_OK printf("requester doesn't have read access\n"); #endif @@ -471,7 +469,7 @@ msgctl(p, uap) } if (error == 0) - p->p_retval[0] = rval; + td->td_retval[0] = rval; done2: mtx_unlock(&Giant); return(error); @@ -488,14 +486,14 @@ struct msgget_args { * MPSAFE */ int -msgget(p, uap) - struct proc *p; +msgget(td, uap) + struct thread *td; register struct msgget_args *uap; { int msqid, error = 0; int key = uap->key; int msgflg = uap->msgflg; - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; register struct msqid_ds *msqptr = NULL; #ifdef MSG_DEBUG_OK @@ -503,8 +501,7 @@ msgget(p, uap) #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -527,7 +524,7 @@ msgget(p, uap) error = EEXIST; goto done2; } - if ((error = ipcperm(p, &msqptr->msg_perm, msgflg & 0700 ))) { + if ((error = ipcperm(td, &msqptr->msg_perm, msgflg & 0700 ))) { #ifdef MSG_DEBUG_OK printf("requester doesn't have 0%o access\n", msgflg & 0700); @@ -592,7 +589,7 @@ msgget(p, uap) found: /* Construct the unique msqid */ - p->p_retval[0] = IXSEQ_TO_IPCID(msqid, msqptr->msg_perm); + td->td_retval[0] = IXSEQ_TO_IPCID(msqid, msqptr->msg_perm); done2: mtx_unlock(&Giant); return (error); @@ -611,8 +608,8 @@ struct msgsnd_args { * MPSAFE */ int -msgsnd(p, uap) - struct proc *p; +msgsnd(td, uap) + struct thread *td; register struct msgsnd_args *uap; { int msqid = uap->msqid; @@ -629,8 +626,7 @@ msgsnd(p, uap) msgflg); #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -662,7 +658,7 @@ msgsnd(p, uap) goto done2; } - if ((error = ipcperm(p, &msqptr->msg_perm, IPC_W))) { + if ((error = ipcperm(td, &msqptr->msg_perm, IPC_W))) { #ifdef MSG_DEBUG_OK printf("requester doesn't have write access\n"); #endif @@ -929,11 +925,11 @@ msgsnd(p, uap) msqptr->msg_cbytes += msghdr->msg_ts; msqptr->msg_qnum++; - msqptr->msg_lspid = p->p_pid; + msqptr->msg_lspid = td->td_proc->p_pid; msqptr->msg_stime = time_second; wakeup((caddr_t)msqptr); - p->p_retval[0] = 0; + td->td_retval[0] = 0; done2: mtx_unlock(&Giant); return (error); @@ -953,8 +949,8 @@ struct msgrcv_args { * MPSAFE */ int -msgrcv(p, uap) - struct proc *p; +msgrcv(td, uap) + struct thread *td; register struct msgrcv_args *uap; { int msqid = uap->msqid; @@ -974,8 +970,7 @@ msgrcv(p, uap) #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -1007,7 +1002,7 @@ msgrcv(p, uap) goto done2; } - if ((error = ipcperm(p, &msqptr->msg_perm, IPC_R))) { + if ((error = ipcperm(td, &msqptr->msg_perm, IPC_R))) { #ifdef MSG_DEBUG_OK printf("requester doesn't have read access\n"); #endif @@ -1159,7 +1154,7 @@ msgrcv(p, uap) msqptr->msg_cbytes -= msghdr->msg_ts; msqptr->msg_qnum--; - msqptr->msg_lrpid = p->p_pid; + msqptr->msg_lrpid = td->td_proc->p_pid; msqptr->msg_rtime = time_second; /* @@ -1228,7 +1223,7 @@ msgrcv(p, uap) msg_freehdr(msghdr); wakeup((caddr_t)msqptr); - p->p_retval[0] = msgsz; + td->td_retval[0] = msgsz; done2: mtx_unlock(&Giant); return (error); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index 0b9a0b6..b8bf079 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -34,15 +34,15 @@ static int sysctl_sema __P((SYSCTL_HANDLER_ARGS)); #ifndef _SYS_SYSPROTO_H_ struct __semctl_args; -int __semctl __P((struct proc *p, struct __semctl_args *uap)); +int __semctl __P((struct thread *td, struct __semctl_args *uap)); struct semget_args; -int semget __P((struct proc *p, struct semget_args *uap)); +int semget __P((struct thread *td, struct semget_args *uap)); struct semop_args; -int semop __P((struct proc *p, struct semop_args *uap)); +int semop __P((struct thread *td, struct semop_args *uap)); #endif -static struct sem_undo *semu_alloc __P((struct proc *p)); -static int semundo_adjust __P((struct proc *p, struct sem_undo **supptr, +static struct sem_undo *semu_alloc __P((struct thread *td)); +static int semundo_adjust __P((struct thread *td, struct sem_undo **supptr, int semid, int semnum, int adjval)); static void semundo_clear __P((int semid, int semnum)); @@ -250,8 +250,8 @@ MODULE_VERSION(sysvsem, 1); * MPSAFE */ int -semsys(p, uap) - struct proc *p; +semsys(td, uap) + struct thread *td; /* XXX actually varargs. */ struct semsys_args /* { u_int which; @@ -264,17 +264,15 @@ semsys(p, uap) int error; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } - if (uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) { error = EINVAL; goto done2; } - error = (*semcalls[uap->which])(p, &uap->a2); + error = (*semcalls[uap->which])(td, &uap->a2); done2: mtx_unlock(&Giant); return (error); @@ -286,8 +284,8 @@ done2: */ static struct sem_undo * -semu_alloc(p) - struct proc *p; +semu_alloc(td) + struct thread *td; { register int i; register struct sem_undo *suptr; @@ -312,7 +310,7 @@ semu_alloc(p) suptr->un_next = semu_list; semu_list = suptr; suptr->un_cnt = 0; - suptr->un_proc = p; + suptr->un_proc = td->td_proc; return(suptr); } } @@ -356,12 +354,13 @@ semu_alloc(p) */ static int -semundo_adjust(p, supptr, semid, semnum, adjval) - register struct proc *p; +semundo_adjust(td, supptr, semid, semnum, adjval) + register struct thread *td; struct sem_undo **supptr; int semid, semnum; int adjval; { + struct proc *p = td->td_proc; register struct sem_undo *suptr; register struct undo *sunptr; int i; @@ -381,7 +380,7 @@ semundo_adjust(p, supptr, semid, semnum, adjval) if (suptr == NULL) { if (adjval == 0) return(0); - suptr = semu_alloc(p); + suptr = semu_alloc(td); if (suptr == NULL) return(ENOSPC); *supptr = suptr; @@ -466,8 +465,8 @@ struct __semctl_args { * MPSAFE */ int -__semctl(p, uap) - struct proc *p; +__semctl(td, uap) + struct thread *td; register struct __semctl_args *uap; { int semid = uap->semid; @@ -475,7 +474,7 @@ __semctl(p, uap) int cmd = uap->cmd; union semun *arg = uap->arg; union semun real_arg; - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; int i, rval, error; struct semid_ds sbuf; register struct semid_ds *semaptr; @@ -484,8 +483,7 @@ __semctl(p, uap) printf("call to semctl(%d, %d, %d, 0x%x)\n", semid, semnum, cmd, arg); #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -508,7 +506,7 @@ __semctl(p, uap) switch (cmd) { case IPC_RMID: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_M))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_M))) goto done2; semaptr->sem_perm.cuid = cred->cr_uid; semaptr->sem_perm.uid = cred->cr_uid; @@ -526,7 +524,7 @@ __semctl(p, uap) break; case IPC_SET: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_M))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_M))) goto done2; if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) goto done2; @@ -542,7 +540,7 @@ __semctl(p, uap) break; case IPC_STAT: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) goto done2; @@ -551,7 +549,7 @@ __semctl(p, uap) break; case GETNCNT: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if (semnum < 0 || semnum >= semaptr->sem_nsems) { error = EINVAL; @@ -561,7 +559,7 @@ __semctl(p, uap) break; case GETPID: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if (semnum < 0 || semnum >= semaptr->sem_nsems) { error = EINVAL; @@ -571,7 +569,7 @@ __semctl(p, uap) break; case GETVAL: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if (semnum < 0 || semnum >= semaptr->sem_nsems) { error = EINVAL; @@ -581,7 +579,7 @@ __semctl(p, uap) break; case GETALL: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) goto done2; @@ -594,7 +592,7 @@ __semctl(p, uap) break; case GETZCNT: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_R))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) goto done2; if (semnum < 0 || semnum >= semaptr->sem_nsems) { error = EINVAL; @@ -604,7 +602,7 @@ __semctl(p, uap) break; case SETVAL: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_W))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_W))) goto done2; if (semnum < 0 || semnum >= semaptr->sem_nsems) { error = EINVAL; @@ -618,7 +616,7 @@ __semctl(p, uap) break; case SETALL: - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_W))) + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_W))) goto done2; if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0) goto done2; @@ -639,7 +637,7 @@ __semctl(p, uap) } if (error == 0) - p->p_retval[0] = rval; + td->td_retval[0] = rval; done2: mtx_unlock(&Giant); return(error); @@ -657,22 +655,21 @@ struct semget_args { * MPSAFE */ int -semget(p, uap) - struct proc *p; +semget(td, uap) + struct thread *td; register struct semget_args *uap; { int semid, error = 0; int key = uap->key; int nsems = uap->nsems; int semflg = uap->semflg; - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; #ifdef SEM_DEBUG printf("semget(0x%x, %d, 0%o)\n", key, nsems, semflg); #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -687,7 +684,7 @@ semget(p, uap) #ifdef SEM_DEBUG printf("found public key\n"); #endif - if ((error = ipcperm(p, &sema[semid].sem_perm, + if ((error = ipcperm(td, &sema[semid].sem_perm, semflg & 0700))) { goto done2; } @@ -771,7 +768,7 @@ semget(p, uap) } found: - p->p_retval[0] = IXSEQ_TO_IPCID(semid, sema[semid].sem_perm); + td->td_retval[0] = IXSEQ_TO_IPCID(semid, sema[semid].sem_perm); done2: mtx_unlock(&Giant); return (error); @@ -789,8 +786,8 @@ struct semop_args { * MPSAFE */ int -semop(p, uap) - struct proc *p; +semop(td, uap) + struct thread *td; register struct semop_args *uap; { int semid = uap->semid; @@ -808,8 +805,7 @@ semop(p, uap) #endif mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } @@ -831,7 +827,7 @@ semop(p, uap) goto done2; } - if ((error = ipcperm(p, &semaptr->sem_perm, IPC_W))) { + if ((error = ipcperm(td, &semaptr->sem_perm, IPC_W))) { #ifdef SEM_DEBUG printf("error = %d from ipcperm\n", error); #endif @@ -1000,7 +996,7 @@ done: adjval = sops[i].sem_op; if (adjval == 0) continue; - error = semundo_adjust(p, &suptr, semid, + error = semundo_adjust(td, &suptr, semid, sops[i].sem_num, -adjval); if (error == 0) continue; @@ -1020,7 +1016,7 @@ done: adjval = sops[j].sem_op; if (adjval == 0) continue; - if (semundo_adjust(p, &suptr, semid, + if (semundo_adjust(td, &suptr, semid, sops[j].sem_num, adjval) != 0) panic("semop - can't undo undos"); } @@ -1040,7 +1036,7 @@ done: for (i = 0; i < nsops; i++) { sopptr = &sops[i]; semptr = &semaptr->sem_base[sopptr->sem_num]; - semptr->sempid = p->p_pid; + semptr->sempid = td->td_proc->p_pid; } /* Do a wakeup if any semaphore was up'd. */ @@ -1056,7 +1052,7 @@ done: #ifdef SEM_DEBUG printf("semop: done\n"); #endif - p->p_retval[0] = 0; + td->td_retval[0] = 0; done2: mtx_unlock(&Giant); return (error); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index ce9574c..649308d 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -62,11 +62,11 @@ static MALLOC_DEFINE(M_SHM, "shm", "SVID compatible shared memory segments"); struct oshmctl_args; -static int oshmctl __P((struct proc *p, struct oshmctl_args *uap)); +static int oshmctl __P((struct thread *td, struct oshmctl_args *uap)); -static int shmget_allocate_segment __P((struct proc *p, +static int shmget_allocate_segment __P((struct thread *td, struct shmget_args *uap, int mode)); -static int shmget_existing __P((struct proc *p, struct shmget_args *uap, +static int shmget_existing __P((struct thread *td, struct shmget_args *uap, int mode, int segnum)); /* XXX casting to (sy_call_t *) is bogus, as usual. */ @@ -97,7 +97,7 @@ struct shmmap_state { static void shm_deallocate_segment __P((struct shmid_ds *)); static int shm_find_segment_by_key __P((key_t)); static struct shmid_ds *shm_find_segment_by_shmid __P((int)); -static int shm_delete_mapping __P((struct proc *, struct shmmap_state *)); +static int shm_delete_mapping __P((struct proc *p, struct shmmap_state *)); static void shmrealloc __P((void)); static void shminit __P((void)); static int sysvshm_modload __P((struct module *, int, void *)); @@ -237,21 +237,20 @@ struct shmdt_args { * MPSAFE */ int -shmdt(p, uap) - struct proc *p; +shmdt(td, uap) + struct thread *td; struct shmdt_args *uap; { + struct proc *p = td->td_proc; struct shmmap_state *shmmap_s; int i; int error = 0; mtx_lock(&Giant); - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { error = ENOSYS; goto done2; } - shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; if (shmmap_s == NULL) { error = EINVAL; @@ -285,10 +284,11 @@ struct shmat_args { * MPSAFE */ int -shmat(p, uap) - struct proc *p; +shmat(td, uap) + struct thread *td; struct shmat_args *uap; { + struct proc *p = td->td_proc; int i, flags; struct shmid_ds *shmseg; struct shmmap_state *shmmap_s = NULL; @@ -300,12 +300,10 @@ shmat(p, uap) int error = 0; mtx_lock(&Giant); - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { error = ENOSYS; goto done2; } - shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; if (shmmap_s == NULL) { size = shminfo.shmseg * sizeof(struct shmmap_state); @@ -319,7 +317,7 @@ shmat(p, uap) error = EINVAL; goto done2; } - error = ipcperm(p, &shmseg->shm_perm, + error = ipcperm(td, &shmseg->shm_perm, (uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W); if (error) goto done2; @@ -376,7 +374,7 @@ shmat(p, uap) shmseg->shm_lpid = p->p_pid; shmseg->shm_atime = time_second; shmseg->shm_nattch++; - p->p_retval[0] = attach_va; + td->td_retval[0] = attach_va; done2: mtx_unlock(&Giant); return (error); @@ -404,8 +402,8 @@ struct oshmctl_args { * MPSAFE */ static int -oshmctl(p, uap) - struct proc *p; +oshmctl(td, uap) + struct thread *td; struct oshmctl_args *uap; { #ifdef COMPAT_43 @@ -414,12 +412,10 @@ oshmctl(p, uap) struct oshmid_ds outbuf; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } - shmseg = shm_find_segment_by_shmid(uap->shmid); if (shmseg == NULL) { error = EINVAL; @@ -427,7 +423,7 @@ oshmctl(p, uap) } switch (uap->cmd) { case IPC_STAT: - error = ipcperm(p, &shmseg->shm_perm, IPC_R); + error = ipcperm(td, &shmseg->shm_perm, IPC_R); if (error) goto done2; outbuf.shm_perm = shmseg->shm_perm; @@ -445,7 +441,7 @@ oshmctl(p, uap) break; default: /* XXX casting to (sy_call_t *) is bogus, as usual. */ - error = ((sy_call_t *)shmctl)(p, uap); + error = ((sy_call_t *)shmctl)(td, uap); break; } done2: @@ -468,8 +464,8 @@ struct shmctl_args { * MPSAFE */ int -shmctl(p, uap) - struct proc *p; +shmctl(td, uap) + struct thread *td; struct shmctl_args *uap; { int error = 0; @@ -477,12 +473,10 @@ shmctl(p, uap) struct shmid_ds *shmseg; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } - shmseg = shm_find_segment_by_shmid(uap->shmid); if (shmseg == NULL) { error = EINVAL; @@ -490,7 +484,7 @@ shmctl(p, uap) } switch (uap->cmd) { case IPC_STAT: - error = ipcperm(p, &shmseg->shm_perm, IPC_R); + error = ipcperm(td, &shmseg->shm_perm, IPC_R); if (error) goto done2; error = copyout((caddr_t)shmseg, uap->buf, sizeof(inbuf)); @@ -498,7 +492,7 @@ shmctl(p, uap) goto done2; break; case IPC_SET: - error = ipcperm(p, &shmseg->shm_perm, IPC_M); + error = ipcperm(td, &shmseg->shm_perm, IPC_M); if (error) goto done2; error = copyin(uap->buf, (caddr_t)&inbuf, sizeof(inbuf)); @@ -512,7 +506,7 @@ shmctl(p, uap) shmseg->shm_ctime = time_second; break; case IPC_RMID: - error = ipcperm(p, &shmseg->shm_perm, IPC_M); + error = ipcperm(td, &shmseg->shm_perm, IPC_M); if (error) goto done2; shmseg->shm_perm.key = IPC_PRIVATE; @@ -544,8 +538,8 @@ struct shmget_args { #endif static int -shmget_existing(p, uap, mode, segnum) - struct proc *p; +shmget_existing(td, uap, mode, segnum) + struct thread *td; struct shmget_args *uap; int mode; int segnum; @@ -568,23 +562,23 @@ shmget_existing(p, uap, mode, segnum) } if ((uap->shmflg & (IPC_CREAT | IPC_EXCL)) == (IPC_CREAT | IPC_EXCL)) return EEXIST; - error = ipcperm(p, &shmseg->shm_perm, mode); + error = ipcperm(td, &shmseg->shm_perm, mode); if (error) return error; if (uap->size && uap->size > shmseg->shm_segsz) return EINVAL; - p->p_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm); + td->td_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm); return 0; } static int -shmget_allocate_segment(p, uap, mode) - struct proc *p; +shmget_allocate_segment(td, uap, mode) + struct thread *td; struct shmget_args *uap; int mode; { int i, segnum, shmid, size; - struct ucred *cred = p->p_ucred; + struct ucred *cred = td->td_proc->p_ucred; struct shmid_ds *shmseg; struct shm_handle *shm_handle; @@ -641,7 +635,7 @@ shmget_allocate_segment(p, uap, mode) shmseg->shm_perm.mode = (shmseg->shm_perm.mode & SHMSEG_WANTED) | (mode & ACCESSPERMS) | SHMSEG_ALLOCATED; shmseg->shm_segsz = uap->size; - shmseg->shm_cpid = p->p_pid; + shmseg->shm_cpid = td->td_proc->p_pid; shmseg->shm_lpid = shmseg->shm_nattch = 0; shmseg->shm_atime = shmseg->shm_dtime = 0; shmseg->shm_ctime = time_second; @@ -655,7 +649,7 @@ shmget_allocate_segment(p, uap, mode) shmseg->shm_perm.mode &= ~SHMSEG_WANTED; wakeup((caddr_t)shmseg); } - p->p_retval[0] = shmid; + td->td_retval[0] = shmid; return 0; } @@ -663,26 +657,24 @@ shmget_allocate_segment(p, uap, mode) * MPSAFE */ int -shmget(p, uap) - struct proc *p; +shmget(td, uap) + struct thread *td; struct shmget_args *uap; { int segnum, mode; int error; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } - mode = uap->shmflg & ACCESSPERMS; if (uap->key != IPC_PRIVATE) { again: segnum = shm_find_segment_by_key(uap->key); if (segnum >= 0) { - error = shmget_existing(p, uap, mode, segnum); + error = shmget_existing(td, uap, mode, segnum); if (error == EAGAIN) goto again; goto done2; @@ -692,7 +684,7 @@ shmget(p, uap) goto done2; } } - error = shmget_allocate_segment(p, uap, mode); + error = shmget_allocate_segment(td, uap, mode); done2: mtx_unlock(&Giant); return (error); @@ -702,8 +694,8 @@ done2: * MPSAFE */ int -shmsys(p, uap) - struct proc *p; +shmsys(td, uap) + struct thread *td; /* XXX actually varargs. */ struct shmsys_args /* { u_int which; @@ -715,17 +707,15 @@ shmsys(p, uap) int error; mtx_lock(&Giant); - - if (!jail_sysvipc_allowed && jailed(p->p_ucred)) { + if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { error = ENOSYS; goto done2; } - if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) { error = EINVAL; goto done2; } - error = (*shmcalls[uap->which])(p, &uap->a2); + error = (*shmcalls[uap->which])(td, &uap->a2); done2: mtx_unlock(&Giant); return (error); diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 1095864..a4d42fc 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1065,10 +1065,10 @@ ttioctl(tp, cmd, data, flag) } int -ttypoll(dev, events, p) +ttypoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { int s; int revents = 0; @@ -1084,7 +1084,7 @@ ttypoll(dev, events, p) if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE)) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &tp->t_rsel); + selrecord(td, &tp->t_rsel); } if (events & (POLLOUT | POLLWRNORM)) { if ((tp->t_outq.c_cc <= tp->t_olowat && @@ -1092,7 +1092,7 @@ ttypoll(dev, events, p) || ISSET(tp->t_state, TS_ZOMBIE)) revents |= events & (POLLOUT | POLLWRNORM); else - selrecord(p, &tp->t_wsel); + selrecord(td, &tp->t_wsel); } splx(s); return (revents); @@ -2337,8 +2337,8 @@ ttyinfo(tp) if (proc_compare(pick, p)) pick = p; - stmp = pick->p_stat == SRUN ? "running" : - pick->p_wmesg ? pick->p_wmesg : "iowait"; + stmp = pick->p_stat == SRUN ? "running" : /* XXXKSE */ + pick->p_thread.td_wmesg ? pick->p_thread.td_wmesg : "iowait"; calcru(pick, &utime, &stime, NULL); ltmp = pick->p_stat == SIDL || pick->p_stat == SWAIT || pick->p_stat == SZOMB ? 0 : @@ -2386,6 +2386,8 @@ proc_compare(p1, p2) register struct proc *p1, *p2; { + int esta, estb; + struct ksegrp *kg; mtx_assert(&sched_lock, MA_OWNED); if (p1 == NULL) return (1); @@ -2402,9 +2404,16 @@ proc_compare(p1, p2) /* * tie - favor one with highest recent cpu utilization */ - if (p2->p_estcpu > p1->p_estcpu) + esta = estb = 0; + FOREACH_KSEGRP_IN_PROC(p1,kg) { + esta += kg->kg_estcpu; + } + FOREACH_KSEGRP_IN_PROC(p2,kg) { + estb += kg->kg_estcpu; + } + if (estb > esta) return (1); - if (p1->p_estcpu > p2->p_estcpu) + if (esta > estb) return (0); return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } @@ -2420,6 +2429,7 @@ proc_compare(p1, p2) return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } +#if 0 /* XXXKSE */ /* * pick the one with the smallest sleep time */ @@ -2434,6 +2444,7 @@ proc_compare(p1, p2) return (1); if (p2->p_sflag & PS_SINTR && (p1->p_sflag & PS_SINTR) == 0) return (0); +#endif return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } diff --git a/sys/kern/tty_conf.c b/sys/kern/tty_conf.c index ba3d785..0609dc9 100644 --- a/sys/kern/tty_conf.c +++ b/sys/kern/tty_conf.c @@ -198,12 +198,12 @@ l_nostart(tp) * discipline specific ioctl command. */ int -l_nullioctl(tp, cmd, data, flags, p) +l_nullioctl(tp, cmd, data, flags, td) struct tty *tp; u_long cmd; char *data; int flags; - struct proc *p; + struct thread *td; { return (ENOIOCTL); diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 478c7e9..70c7fee 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -219,9 +219,9 @@ sysctl_kern_consmute(SYSCTL_HANDLER_ARGS) */ cninit_finish(); if(cn_is_open) - /* XXX curproc is not what we want really */ + /* XXX curthread is not what we want really */ error = cnopen(cn_dev_t, openflag, - openmode, curproc); + openmode, curthread); /* if it failed, back it out */ if ( error != 0) cnuninit(); } else if (!ocn_mute && cn_mute) { @@ -231,7 +231,7 @@ sysctl_kern_consmute(SYSCTL_HANDLER_ARGS) */ if(cn_is_open) error = cnclose(cn_dev_t, openflag, - openmode, curproc); + openmode, curthread); if ( error == 0) cnuninit(); } if (error != 0) { @@ -248,10 +248,10 @@ SYSCTL_PROC(_kern, OID_AUTO, consmute, CTLTYPE_INT|CTLFLAG_RW, 0, sizeof cn_mute, sysctl_kern_consmute, "I", ""); static int -cnopen(dev, flag, mode, p) +cnopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { dev_t cndev, physdev; int retval = 0; @@ -266,7 +266,7 @@ cnopen(dev, flag, mode, p) * bypass this and go straight to the device. */ if(!cn_mute) - retval = (*cn_phys_open)(physdev, flag, mode, p); + retval = (*cn_phys_open)(physdev, flag, mode, td); if (retval == 0) { /* * check if we openned it via /dev/console or @@ -285,10 +285,10 @@ cnopen(dev, flag, mode, p) } static int -cnclose(dev, flag, mode, p) +cnclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { dev_t cndev; struct tty *cn_tp; @@ -323,7 +323,7 @@ cnclose(dev, flag, mode, p) dev = cndev; } if(cn_phys_close) - return ((*cn_phys_close)(dev, flag, mode, p)); + return ((*cn_phys_close)(dev, flag, mode, td)); return (0); } @@ -360,12 +360,12 @@ cnwrite(dev, uio, flag) } static int -cnioctl(dev, cmd, data, flag, p) +cnioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { int error; @@ -376,28 +376,28 @@ cnioctl(dev, cmd, data, flag, p) * output from the "virtual" console. */ if (cmd == TIOCCONS && constty) { - error = suser(p); + error = suser_td(td); if (error) return (error); constty = NULL; return (0); } dev = cn_tab->cn_dev; - return ((*devsw(dev)->d_ioctl)(dev, cmd, data, flag, p)); + return ((*devsw(dev)->d_ioctl)(dev, cmd, data, flag, td)); } static int -cnpoll(dev, events, p) +cnpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { if ((cn_tab == NULL) || cn_mute) return (1); dev = cn_tab->cn_dev; - return ((*devsw(dev)->d_poll)(dev, events, p)); + return ((*devsw(dev)->d_poll)(dev, events, td)); } static int diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 8672077..68e93a9 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -164,11 +164,12 @@ ptyinit(dev_t devc) /*ARGSUSED*/ static int -ptsopen(dev, flag, devtype, p) +ptsopen(dev, flag, devtype, td) dev_t dev; int flag, devtype; - struct proc *p; + struct thread *td; { + struct proc *p = td->td_proc; register struct tty *tp; int error; struct pt_ioctl *pti; @@ -206,10 +207,10 @@ ptsopen(dev, flag, devtype, p) } static int -ptsclose(dev, flag, mode, p) +ptsclose(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { register struct tty *tp; int err; @@ -227,7 +228,8 @@ ptsread(dev, uio, flag) struct uio *uio; int flag; { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; register struct tty *tp = dev->si_tty; register struct pt_ioctl *pti = dev->si_drv1; int error = 0; @@ -326,11 +328,12 @@ ptcwakeup(tp, flag) } static int -ptcopen(dev, flag, devtype, p) +ptcopen(dev, flag, devtype, td) dev_t dev; int flag, devtype; - struct proc *p; + struct thread *td; { + struct proc *p = td->td_proc; register struct tty *tp; struct pt_ioctl *pti; @@ -355,11 +358,11 @@ ptcopen(dev, flag, devtype, p) } static int -ptcclose(dev, flags, fmt, p) +ptcclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { register struct tty *tp; @@ -471,10 +474,10 @@ ptsstop(tp, flush) } static int -ptcpoll(dev, events, p) +ptcpoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { register struct tty *tp = dev->si_tty; struct pt_ioctl *pti = dev->si_drv1; @@ -482,7 +485,7 @@ ptcpoll(dev, events, p) int s; if ((tp->t_state & TS_CONNECTED) == 0) - return (seltrue(dev, events, p) | POLLHUP); + return (seltrue(dev, events, td) | POLLHUP); /* * Need to block timeouts (ttrstart). @@ -510,10 +513,10 @@ ptcpoll(dev, events, p) if (revents == 0) { if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &pti->pt_selr); + selrecord(curthread, &pti->pt_selr); if (events & (POLLOUT | POLLWRNORM)) - selrecord(p, &pti->pt_selw); + selrecord(curthread, &pti->pt_selw); } splx(s); @@ -632,12 +635,12 @@ block: /*ARGSUSED*/ static int -ptyioctl(dev, cmd, data, flag, p) +ptyioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { register struct tty *tp = dev->si_tty; register struct pt_ioctl *pti = dev->si_drv1; @@ -741,7 +744,7 @@ ptyioctl(dev, cmd, data, flag, p) } return(0); } - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td); if (error == ENOIOCTL) error = ttioctl(tp, cmd, data, flag); if (error == ENOIOCTL) { diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index b175719..1c6635c 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -71,23 +71,23 @@ static struct cdevsw ctty_cdevsw = { /* flags */ D_TTY, }; -#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL) +#define cttyvp(td) ((td)->td_proc->p_flag & P_CONTROLT ? (td)->td_proc->p_session->s_ttyvp : NULL) /*ARGSUSED*/ static int -cttyopen(dev, flag, mode, p) +cttyopen(dev, flag, mode, td) dev_t dev; int flag, mode; - struct proc *p; + struct thread *td; { - struct vnode *ttyvp = cttyvp(p); + struct vnode *ttyvp = cttyvp(td); int error; if (ttyvp == NULL) return (ENXIO); - vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(ttyvp, flag, NOCRED, p); - VOP_UNLOCK(ttyvp, 0, p); + vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(ttyvp, flag, NOCRED, td); + VOP_UNLOCK(ttyvp, 0, td); return (error); } @@ -98,15 +98,15 @@ cttyread(dev, uio, flag) struct uio *uio; int flag; { - struct proc *p = uio->uio_procp; - register struct vnode *ttyvp = cttyvp(p); + struct thread *td = uio->uio_td; + register struct vnode *ttyvp = cttyvp(td); int error; if (ttyvp == NULL) return (EIO); - vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_READ(ttyvp, uio, flag, NOCRED); - VOP_UNLOCK(ttyvp, 0, p); + VOP_UNLOCK(ttyvp, 0, td); return (error); } @@ -117,8 +117,8 @@ cttywrite(dev, uio, flag) struct uio *uio; int flag; { - struct proc *p = uio->uio_procp; - struct vnode *ttyvp = cttyvp(uio->uio_procp); + struct thread *td = uio->uio_td; + struct vnode *ttyvp = cttyvp(uio->uio_td); struct mount *mp; int error; @@ -128,51 +128,51 @@ cttywrite(dev, uio, flag) if (ttyvp->v_type != VCHR && (error = vn_start_write(ttyvp, &mp, V_WAIT | PCATCH)) != 0) return (error); - vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_WRITE(ttyvp, uio, flag, NOCRED); - VOP_UNLOCK(ttyvp, 0, p); + VOP_UNLOCK(ttyvp, 0, td); vn_finished_write(mp); return (error); } /*ARGSUSED*/ static int -cttyioctl(dev, cmd, addr, flag, p) +cttyioctl(dev, cmd, addr, flag, td) dev_t dev; u_long cmd; caddr_t addr; int flag; - struct proc *p; + struct thread *td; { - struct vnode *ttyvp = cttyvp(p); + struct vnode *ttyvp = cttyvp(td); if (ttyvp == NULL) return (EIO); if (cmd == TIOCSCTTY) /* don't allow controlling tty to be set */ return EINVAL; /* to controlling tty -- infinite recursion */ if (cmd == TIOCNOTTY) { - if (!SESS_LEADER(p)) { - p->p_flag &= ~P_CONTROLT; + if (!SESS_LEADER(td->td_proc)) { + td->td_proc->p_flag &= ~P_CONTROLT; return (0); } else return (EINVAL); } - return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, p)); + return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, td)); } /*ARGSUSED*/ static int -cttypoll(dev, events, p) +cttypoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { - struct vnode *ttyvp = cttyvp(p); + struct vnode *ttyvp = cttyvp(td); if (ttyvp == NULL) /* try operation to get EOF/failure */ - return (seltrue(dev, events, p)); - return (VOP_POLL(ttyvp, events, p->p_ucred, p)); + return (seltrue(dev, events, td)); + return (VOP_POLL(ttyvp, events, td->td_proc->p_ucred, td)); } static void ctty_clone __P((void *arg, char *name, int namelen, dev_t *dev)); @@ -188,7 +188,7 @@ ctty_clone(void *arg, char *name, int namelen, dev_t *dev) return; if (strcmp(name, "tty")) return; - vp = cttyvp(curproc); + vp = cttyvp(curthread); if (vp == NULL) { if (ctty) *dev = ctty; diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index e352e36..b7042ff 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -221,10 +221,10 @@ sonewconn(head, connstatus) } struct socket * -sonewconn3(head, connstatus, p) +sonewconn3(head, connstatus, td) register struct socket *head; int connstatus; - struct proc *p; + struct thread *td; { register struct socket *so; @@ -240,7 +240,7 @@ sonewconn3(head, connstatus, p) so->so_state = head->so_state | SS_NOFDREF; so->so_proto = head->so_proto; so->so_timeo = head->so_timeo; - so->so_cred = p ? p->p_ucred : head->so_cred; + so->so_cred = td ? td->td_proc->p_ucred : head->so_cred; crhold(so->so_cred); if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) || (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) { @@ -391,11 +391,11 @@ soreserve(so, sndcc, rcvcc) register struct socket *so; u_long sndcc, rcvcc; { - struct proc *p = curproc; + struct thread *td = curthread; - if (sbreserve(&so->so_snd, sndcc, so, p) == 0) + if (sbreserve(&so->so_snd, sndcc, so, td) == 0) goto bad; - if (sbreserve(&so->so_rcv, rcvcc, so, p) == 0) + if (sbreserve(&so->so_rcv, rcvcc, so, td) == 0) goto bad2; if (so->so_rcv.sb_lowat == 0) so->so_rcv.sb_lowat = 1; @@ -416,21 +416,21 @@ bad: * if buffering efficiency is near the normal case. */ int -sbreserve(sb, cc, so, p) +sbreserve(sb, cc, so, td) struct sockbuf *sb; u_long cc; struct socket *so; - struct proc *p; + struct thread *td; { /* - * p will only be NULL when we're in an interrupt + * td will only be NULL when we're in an interrupt * (e.g. in tcp_input()) */ if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES)) return (0); if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, - p ? p->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { + td ? td->td_proc->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { return (0); } sb->sb_mbmax = min(cc * sb_efficiency, sb_max); @@ -876,7 +876,7 @@ pru_accept_notsupp(struct socket *so, struct sockaddr **nam) } int -pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct proc *p) +pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct thread *td) { return EOPNOTSUPP; } @@ -889,13 +889,13 @@ pru_connect2_notsupp(struct socket *so1, struct socket *so2) int pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p) + struct ifnet *ifp, struct thread *td) { return EOPNOTSUPP; } int -pru_listen_notsupp(struct socket *so, struct proc *p) +pru_listen_notsupp(struct socket *so, struct thread *td) { return EOPNOTSUPP; } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 9a2cb93..f4edaaf 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -125,12 +125,12 @@ soalloc(waitok) } int -socreate(dom, aso, type, proto, p) +socreate(dom, aso, type, proto, td) int dom; struct socket **aso; register int type; int proto; - struct proc *p; + struct thread *td; { register struct protosw *prp; register struct socket *so; @@ -144,7 +144,7 @@ socreate(dom, aso, type, proto, p) if (prp == 0 || prp->pr_usrreqs->pru_attach == 0) return (EPROTONOSUPPORT); - if (jailed(p->p_ucred) && jail_socket_unixiproute_only && + if (jailed(td->td_proc->p_ucred) && jail_socket_unixiproute_only && prp->pr_domain->dom_family != PF_LOCAL && prp->pr_domain->dom_family != PF_INET && prp->pr_domain->dom_family != PF_ROUTE) { @@ -153,17 +153,17 @@ socreate(dom, aso, type, proto, p) if (prp->pr_type != type) return (EPROTOTYPE); - so = soalloc(p != 0); + so = soalloc(td != 0); if (so == 0) return (ENOBUFS); TAILQ_INIT(&so->so_incomp); TAILQ_INIT(&so->so_comp); so->so_type = type; - so->so_cred = p->p_ucred; + so->so_cred = td->td_proc->p_ucred; crhold(so->so_cred); so->so_proto = prp; - error = (*prp->pr_usrreqs->pru_attach)(so, proto, p); + error = (*prp->pr_usrreqs->pru_attach)(so, proto, td); if (error) { so->so_state |= SS_NOFDREF; sofree(so); @@ -174,15 +174,15 @@ socreate(dom, aso, type, proto, p) } int -sobind(so, nam, p) +sobind(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { int s = splnet(); int error; - error = (*so->so_proto->pr_usrreqs->pru_bind)(so, nam, p); + error = (*so->so_proto->pr_usrreqs->pru_bind)(so, nam, td); splx(s); return (error); } @@ -215,15 +215,15 @@ sodealloc(so) } int -solisten(so, backlog, p) +solisten(so, backlog, td) register struct socket *so; int backlog; - struct proc *p; + struct thread *td; { int s, error; s = splnet(); - error = (*so->so_proto->pr_usrreqs->pru_listen)(so, p); + error = (*so->so_proto->pr_usrreqs->pru_listen)(so, td); if (error) { splx(s); return (error); @@ -369,10 +369,10 @@ soaccept(so, nam) } int -soconnect(so, nam, p) +soconnect(so, nam, td) register struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { int s; int error; @@ -391,7 +391,7 @@ soconnect(so, nam, p) (error = sodisconnect(so)))) error = EISCONN; else - error = (*so->so_proto->pr_usrreqs->pru_connect)(so, nam, p); + error = (*so->so_proto->pr_usrreqs->pru_connect)(so, nam, td); splx(s); return (error); } @@ -449,14 +449,14 @@ bad: * Data and control buffers are freed on return. */ int -sosend(so, addr, uio, top, control, flags, p) +sosend(so, addr, uio, top, control, flags, td) register struct socket *so; struct sockaddr *addr; struct uio *uio; struct mbuf *top; struct mbuf *control; int flags; - struct proc *p; + struct thread *td; { struct mbuf **mp; register struct mbuf *m; @@ -486,8 +486,8 @@ sosend(so, addr, uio, top, control, flags, p) dontroute = (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 && (so->so_proto->pr_flags & PR_ATOMIC); - if (p) - p->p_stats->p_ru.ru_msgsnd++; + if (td) + td->td_proc->p_stats->p_ru.ru_msgsnd++; if (control) clen = control->m_len; #define snderr(errno) { error = errno; splx(s); goto release; } @@ -624,7 +624,7 @@ nopages: PRUS_EOF : /* If there is more to send set PRUS_MORETOCOME */ (resid > 0 && space > 0) ? PRUS_MORETOCOME : 0, - top, addr, control, p); + top, addr, control, td); splx(s); if (dontroute) so->so_options &= ~SO_DONTROUTE; @@ -774,8 +774,8 @@ restart: goto restart; } dontblock: - if (uio->uio_procp) - uio->uio_procp->p_stats->p_ru.ru_msgrcv++; + if (uio->uio_td) + uio->uio_td->td_proc->p_stats->p_ru.ru_msgrcv++; nextrecord = m->m_nextpkt; if (pr->pr_flags & PR_ADDR) { KASSERT(m->m_type == MT_SONAME, ("receive 1a")); @@ -1103,7 +1103,7 @@ sooptcopyin(sopt, buf, len, minlen) if (valsize > len) sopt->sopt_valsize = valsize = len; - if (sopt->sopt_p != 0) + if (sopt->sopt_td != 0) return (copyin(sopt->sopt_val, buf, valsize)); bcopy(sopt->sopt_val, buf, valsize); @@ -1189,7 +1189,7 @@ sosetopt(so, sopt) case SO_RCVBUF: if (sbreserve(sopt->sopt_name == SO_SNDBUF ? &so->so_snd : &so->so_rcv, (u_long)optval, - so, curproc) == 0) { + so, curthread) == 0) { error = ENOBUFS; goto bad; } @@ -1279,7 +1279,7 @@ sooptcopyout(sopt, buf, len) valsize = min(len, sopt->sopt_valsize); sopt->sopt_valsize = valsize; if (sopt->sopt_val != 0) { - if (sopt->sopt_p != 0) + if (sopt->sopt_td != 0) error = copyout(buf, sopt->sopt_val, valsize); else bcopy(buf, sopt->sopt_val, valsize); @@ -1394,11 +1394,11 @@ soopt_getm(struct sockopt *sopt, struct mbuf **mp) struct mbuf *m, *m_prev; int sopt_size = sopt->sopt_valsize; - MGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_DATA); if (m == 0) return ENOBUFS; if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT); + MCLGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_free(m); return ENOBUFS; @@ -1412,13 +1412,13 @@ soopt_getm(struct sockopt *sopt, struct mbuf **mp) m_prev = m; while (sopt_size) { - MGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_DATA); if (m == 0) { m_freem(*mp); return ENOBUFS; } if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT); + MCLGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(*mp); return ENOBUFS; @@ -1443,7 +1443,7 @@ soopt_mcopyin(struct sockopt *sopt, struct mbuf *m) if (sopt->sopt_val == NULL) return 0; while (m != NULL && sopt->sopt_valsize >= m->m_len) { - if (sopt->sopt_p != NULL) { + if (sopt->sopt_td != NULL) { int error; error = copyin(sopt->sopt_val, mtod(m, char *), @@ -1473,7 +1473,7 @@ soopt_mcopyout(struct sockopt *sopt, struct mbuf *m) if (sopt->sopt_val == NULL) return 0; while (m != NULL && sopt->sopt_valsize >= m->m_len) { - if (sopt->sopt_p != NULL) { + if (sopt->sopt_td != NULL) { int error; error = copyout(mtod(m, char *), sopt->sopt_val, @@ -1508,7 +1508,7 @@ sohasoutofband(so) } int -sopoll(struct socket *so, int events, struct ucred *cred, struct proc *p) +sopoll(struct socket *so, int events, struct ucred *cred, struct thread *td) { int revents = 0; int s = splnet(); @@ -1527,12 +1527,12 @@ sopoll(struct socket *so, int events, struct ucred *cred, struct proc *p) if (revents == 0) { if (events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { - selrecord(p, &so->so_rcv.sb_sel); + selrecord(curthread, &so->so_rcv.sb_sel); so->so_rcv.sb_flags |= SB_SEL; } if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p, &so->so_snd.sb_sel); + selrecord(curthread, &so->so_snd.sb_sel); so->so_snd.sb_flags |= SB_SEL; } } diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index e352e36..b7042ff 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -221,10 +221,10 @@ sonewconn(head, connstatus) } struct socket * -sonewconn3(head, connstatus, p) +sonewconn3(head, connstatus, td) register struct socket *head; int connstatus; - struct proc *p; + struct thread *td; { register struct socket *so; @@ -240,7 +240,7 @@ sonewconn3(head, connstatus, p) so->so_state = head->so_state | SS_NOFDREF; so->so_proto = head->so_proto; so->so_timeo = head->so_timeo; - so->so_cred = p ? p->p_ucred : head->so_cred; + so->so_cred = td ? td->td_proc->p_ucred : head->so_cred; crhold(so->so_cred); if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) || (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) { @@ -391,11 +391,11 @@ soreserve(so, sndcc, rcvcc) register struct socket *so; u_long sndcc, rcvcc; { - struct proc *p = curproc; + struct thread *td = curthread; - if (sbreserve(&so->so_snd, sndcc, so, p) == 0) + if (sbreserve(&so->so_snd, sndcc, so, td) == 0) goto bad; - if (sbreserve(&so->so_rcv, rcvcc, so, p) == 0) + if (sbreserve(&so->so_rcv, rcvcc, so, td) == 0) goto bad2; if (so->so_rcv.sb_lowat == 0) so->so_rcv.sb_lowat = 1; @@ -416,21 +416,21 @@ bad: * if buffering efficiency is near the normal case. */ int -sbreserve(sb, cc, so, p) +sbreserve(sb, cc, so, td) struct sockbuf *sb; u_long cc; struct socket *so; - struct proc *p; + struct thread *td; { /* - * p will only be NULL when we're in an interrupt + * td will only be NULL when we're in an interrupt * (e.g. in tcp_input()) */ if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES)) return (0); if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, - p ? p->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { + td ? td->td_proc->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { return (0); } sb->sb_mbmax = min(cc * sb_efficiency, sb_max); @@ -876,7 +876,7 @@ pru_accept_notsupp(struct socket *so, struct sockaddr **nam) } int -pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct proc *p) +pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct thread *td) { return EOPNOTSUPP; } @@ -889,13 +889,13 @@ pru_connect2_notsupp(struct socket *so1, struct socket *so2) int pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p) + struct ifnet *ifp, struct thread *td) { return EOPNOTSUPP; } int -pru_listen_notsupp(struct socket *so, struct proc *p) +pru_listen_notsupp(struct socket *so, struct thread *td) { return EOPNOTSUPP; } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index ecf4406..e09951f 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -77,14 +77,14 @@ SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) static struct sf_buf *sf_buf_alloc(void); static void sf_buf_free(caddr_t addr, void *args); -static int sendit __P((struct proc *p, int s, struct msghdr *mp, int flags)); -static int recvit __P((struct proc *p, int s, struct msghdr *mp, +static int sendit __P((struct thread *td, int s, struct msghdr *mp, int flags)); +static int recvit __P((struct thread *td, int s, struct msghdr *mp, caddr_t namelenp)); -static int accept1 __P((struct proc *p, struct accept_args *uap, int compat)); -static int getsockname1 __P((struct proc *p, struct getsockname_args *uap, +static int accept1 __P((struct thread *td, struct accept_args *uap, int compat)); +static int getsockname1 __P((struct thread *td, struct getsockname_args *uap, int compat)); -static int getpeername1 __P((struct proc *p, struct getpeername_args *uap, +static int getpeername1 __P((struct thread *td, struct getpeername_args *uap, int compat)); /* @@ -113,8 +113,8 @@ extern struct fileops socketops; * MPSAFE */ int -socket(p, uap) - struct proc *p; +socket(td, uap) + struct thread *td; register struct socket_args /* { int domain; int type; @@ -127,26 +127,25 @@ socket(p, uap) int fd, error; mtx_lock(&Giant); - - fdp = p->p_fd; - error = falloc(p, &fp, &fd); + fdp = td->td_proc->p_fd; + error = falloc(td, &fp, &fd); if (error) goto done2; fhold(fp); - error = socreate(uap->domain, &so, uap->type, uap->protocol, p); + error = socreate(uap->domain, &so, uap->type, uap->protocol, td); if (error) { if (fdp->fd_ofiles[fd] == fp) { fdp->fd_ofiles[fd] = NULL; - fdrop(fp, p); + fdrop(fp, td); } } else { fp->f_data = (caddr_t)so; fp->f_flag = FREAD|FWRITE; fp->f_ops = &socketops; fp->f_type = DTYPE_SOCKET; - p->p_retval[0] = fd; + td->td_retval[0] = fd; } - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -157,8 +156,8 @@ done2: */ /* ARGSUSED */ int -bind(p, uap) - struct proc *p; +bind(td, uap) + struct thread *td; register struct bind_args /* { int s; caddr_t name; @@ -170,18 +169,17 @@ bind(p, uap) int error; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error) goto done2; error = getsockaddr(&sa, uap->name, uap->namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } - error = sobind((struct socket *)fp->f_data, sa, p); + error = sobind((struct socket *)fp->f_data, sa, td); FREE(sa, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -192,8 +190,8 @@ done2: */ /* ARGSUSED */ int -listen(p, uap) - struct proc *p; +listen(td, uap) + struct thread *td; register struct listen_args /* { int s; int backlog; @@ -203,10 +201,10 @@ listen(p, uap) int error; mtx_lock(&Giant); - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error == 0) { - error = solisten((struct socket *)fp->f_data, uap->backlog, p); - fdrop(fp, p); + error = solisten((struct socket *)fp->f_data, uap->backlog, td); + fdrop(fp, td); } mtx_unlock(&Giant); return(error); @@ -217,8 +215,8 @@ listen(p, uap) * MPSAFE */ static int -accept1(p, uap, compat) - struct proc *p; +accept1(td, uap, compat) + struct thread *td; register struct accept_args /* { int s; caddr_t name; @@ -236,8 +234,7 @@ accept1(p, uap, compat) short fflag; /* type must match fp->f_flag */ mtx_lock(&Giant); - fdp = p->p_fd; - + fdp = td->td_proc->p_fd; if (uap->name) { error = copyin((caddr_t)uap->anamelen, (caddr_t)&namelen, sizeof (namelen)); @@ -290,7 +287,7 @@ accept1(p, uap, compat) head->so_qlen--; fflag = lfp->f_flag; - error = falloc(p, &nfp, &fd); + error = falloc(td, &nfp, &fd); if (error) { /* * Probably ran out of file descriptors. Put the @@ -305,7 +302,7 @@ accept1(p, uap, compat) goto done; } fhold(nfp); - p->p_retval[0] = fd; + td->td_retval[0] = fd; /* connection has been removed from the listen queue */ KNOTE(&head->so_rcv.sb_sel.si_note, 0); @@ -367,7 +364,7 @@ noconnection: if (error) { if (fdp->fd_ofiles[fd] == nfp) { fdp->fd_ofiles[fd] = NULL; - fdrop(nfp, p); + fdrop(nfp, td); } } splx(s); @@ -377,8 +374,8 @@ noconnection: */ done: if (nfp != NULL) - fdrop(nfp, p); - fdrop(lfp, p); + fdrop(nfp, td); + fdrop(lfp, td); done2: mtx_unlock(&Giant); return (error); @@ -388,11 +385,12 @@ done2: * MPSAFE (accept1() is MPSAFE) */ int -accept(p, uap) - struct proc *p; +accept(td, uap) + struct thread *td; struct accept_args *uap; { - return (accept1(p, uap, 0)); + + return (accept1(td, uap, 0)); } #ifdef COMPAT_OLDSOCK @@ -400,11 +398,12 @@ accept(p, uap) * MPSAFE (accept1() is MPSAFE) */ int -oaccept(p, uap) - struct proc *p; +oaccept(td, uap) + struct thread *td; struct accept_args *uap; { - return (accept1(p, uap, 1)); + + return (accept1(td, uap, 1)); } #endif /* COMPAT_OLDSOCK */ @@ -413,8 +412,8 @@ oaccept(p, uap) */ /* ARGSUSED */ int -connect(p, uap) - struct proc *p; +connect(td, uap) + struct thread *td; register struct connect_args /* { int s; caddr_t name; @@ -427,8 +426,7 @@ connect(p, uap) int error, s; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error) goto done2; so = (struct socket *)fp->f_data; @@ -439,7 +437,7 @@ connect(p, uap) error = getsockaddr(&sa, uap->name, uap->namelen); if (error) goto done; - error = soconnect(so, sa, p); + error = soconnect(so, sa, td); if (error) goto bad; if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { @@ -465,7 +463,7 @@ bad: if (error == ERESTART) error = EINTR; done: - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -475,8 +473,8 @@ done2: * MPSAFE */ int -socketpair(p, uap) - struct proc *p; +socketpair(td, uap) + struct thread *td; register struct socketpair_args /* { int domain; int type; @@ -484,26 +482,25 @@ socketpair(p, uap) int *rsv; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; struct file *fp1, *fp2; struct socket *so1, *so2; int fd, error, sv[2]; mtx_lock(&Giant); - - error = socreate(uap->domain, &so1, uap->type, uap->protocol, p); + error = socreate(uap->domain, &so1, uap->type, uap->protocol, td); if (error) goto done2; - error = socreate(uap->domain, &so2, uap->type, uap->protocol, p); + error = socreate(uap->domain, &so2, uap->type, uap->protocol, td); if (error) goto free1; - error = falloc(p, &fp1, &fd); + error = falloc(td, &fp1, &fd); if (error) goto free2; fhold(fp1); sv[0] = fd; fp1->f_data = (caddr_t)so1; - error = falloc(p, &fp2, &fd); + error = falloc(td, &fp2, &fd); if (error) goto free3; fhold(fp2); @@ -524,21 +521,21 @@ socketpair(p, uap) fp1->f_ops = fp2->f_ops = &socketops; fp1->f_type = fp2->f_type = DTYPE_SOCKET; error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int)); - fdrop(fp1, p); - fdrop(fp2, p); + fdrop(fp1, td); + fdrop(fp2, td); goto done2; free4: if (fdp->fd_ofiles[sv[1]] == fp2) { fdp->fd_ofiles[sv[1]] = NULL; - fdrop(fp2, p); + fdrop(fp2, td); } - fdrop(fp2, p); + fdrop(fp2, td); free3: if (fdp->fd_ofiles[sv[0]] == fp1) { fdp->fd_ofiles[sv[0]] = NULL; - fdrop(fp1, p); + fdrop(fp1, td); } - fdrop(fp1, p); + fdrop(fp1, td); free2: (void)soclose(so2); free1: @@ -549,8 +546,8 @@ done2: } static int -sendit(p, s, mp, flags) - register struct proc *p; +sendit(td, s, mp, flags) + register struct thread *td; int s; register struct msghdr *mp; int flags; @@ -568,27 +565,27 @@ sendit(p, s, mp, flags) struct uio ktruio; #endif - error = holdsock(p->p_fd, s, &fp); + error = holdsock(td->td_proc->p_fd, s, &fp); if (error) return (error); auio.uio_iov = mp->msg_iov; auio.uio_iovcnt = mp->msg_iovlen; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = UIO_WRITE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { if ((auio.uio_resid += iov->iov_len) < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } } if (mp->msg_name) { error = getsockaddr(&to, mp->msg_name, mp->msg_namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } } else { @@ -627,7 +624,7 @@ sendit(p, s, mp, flags) control = 0; } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -638,31 +635,31 @@ sendit(p, s, mp, flags) len = auio.uio_resid; so = (struct socket *)fp->f_data; error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control, - flags, p); + flags, td); if (error) { if (auio.uio_resid != len && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; if (error == EPIPE) { - PROC_LOCK(p); - psignal(p, SIGPIPE); - PROC_UNLOCK(p); + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGPIPE); + PROC_UNLOCK(td->td_proc); } } if (error == 0) - p->p_retval[0] = len - auio.uio_resid; + td->td_retval[0] = len - auio.uio_resid; #ifdef KTRACE if (ktriov != NULL) { if (error == 0) { ktruio.uio_iov = ktriov; - ktruio.uio_resid = p->p_retval[0]; - ktrgenio(p->p_tracep, s, UIO_WRITE, &ktruio, error); + ktruio.uio_resid = td->td_retval[0]; + ktrgenio(td->td_proc->p_tracep, s, UIO_WRITE, &ktruio, error); } FREE(ktriov, M_TEMP); } #endif bad: - fdrop(fp, p); + fdrop(fp, td); if (to) FREE(to, M_SONAME); return (error); @@ -672,8 +669,8 @@ bad: * MPSAFE */ int -sendto(p, uap) - struct proc *p; +sendto(td, uap) + struct thread *td; register struct sendto_args /* { int s; caddr_t buf; @@ -698,7 +695,7 @@ sendto(p, uap) aiov.iov_base = uap->buf; aiov.iov_len = uap->len; mtx_lock(&Giant); - error = sendit(p, uap->s, &msg, uap->flags); + error = sendit(td, uap->s, &msg, uap->flags); mtx_unlock(&Giant); return (error); } @@ -708,8 +705,8 @@ sendto(p, uap) * MPSAFE */ int -osend(p, uap) - struct proc *p; +osend(td, uap) + struct thread *td; register struct osend_args /* { int s; caddr_t buf; @@ -730,7 +727,7 @@ osend(p, uap) msg.msg_control = 0; msg.msg_flags = 0; mtx_lock(&Giant); - error = sendit(p, uap->s, &msg, uap->flags); + error = sendit(td, uap->s, &msg, uap->flags); mtx_unlock(&Giant); return (error); } @@ -739,8 +736,8 @@ osend(p, uap) * MPSAFE */ int -osendmsg(p, uap) - struct proc *p; +osendmsg(td, uap) + struct thread *td; register struct osendmsg_args /* { int s; caddr_t msg; @@ -772,7 +769,7 @@ osendmsg(p, uap) goto done; msg.msg_flags = MSG_COMPAT; msg.msg_iov = iov; - error = sendit(p, uap->s, &msg, uap->flags); + error = sendit(td, uap->s, &msg, uap->flags); done: if (iov != aiov) FREE(iov, M_IOV); @@ -786,8 +783,8 @@ done2: * MPSAFE */ int -sendmsg(p, uap) - struct proc *p; +sendmsg(td, uap) + struct thread *td; register struct sendmsg_args /* { int s; caddr_t msg; @@ -799,7 +796,6 @@ sendmsg(p, uap) int error; mtx_lock(&Giant); - error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg)); if (error) goto done2; @@ -822,7 +818,7 @@ sendmsg(p, uap) #ifdef COMPAT_OLDSOCK msg.msg_flags = 0; #endif - error = sendit(p, uap->s, &msg, uap->flags); + error = sendit(td, uap->s, &msg, uap->flags); done: if (iov != aiov) FREE(iov, M_IOV); @@ -832,8 +828,8 @@ done2: } static int -recvit(p, s, mp, namelenp) - register struct proc *p; +recvit(td, s, mp, namelenp) + register struct thread *td; int s; register struct msghdr *mp; caddr_t namelenp; @@ -852,25 +848,25 @@ recvit(p, s, mp, namelenp) struct uio ktruio; #endif - error = holdsock(p->p_fd, s, &fp); + error = holdsock(td->td_proc->p_fd, s, &fp); if (error) return (error); auio.uio_iov = mp->msg_iov; auio.uio_iovcnt = mp->msg_iovlen; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; /* XXX */ auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { if ((auio.uio_resid += iov->iov_len) < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td->td_proc, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -893,14 +889,14 @@ recvit(p, s, mp, namelenp) if (error == 0) { ktruio.uio_iov = ktriov; ktruio.uio_resid = len - auio.uio_resid; - ktrgenio(p->p_tracep, s, UIO_READ, &ktruio, error); + ktrgenio(td->td_proc->p_tracep, s, UIO_READ, &ktruio, error); } FREE(ktriov, M_TEMP); } #endif if (error) goto out; - p->p_retval[0] = len - auio.uio_resid; + td->td_retval[0] = len - auio.uio_resid; if (mp->msg_name) { len = mp->msg_namelen; if (len <= 0 || fromsa == 0) @@ -979,7 +975,7 @@ recvit(p, s, mp, namelenp) mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control; } out: - fdrop(fp, p); + fdrop(fp, td); if (fromsa) FREE(fromsa, M_SONAME); if (control) @@ -991,8 +987,8 @@ out: * MPSAFE */ int -recvfrom(p, uap) - struct proc *p; +recvfrom(td, uap) + struct thread *td; register struct recvfrom_args /* { int s; caddr_t buf; @@ -1007,7 +1003,6 @@ recvfrom(p, uap) int error; mtx_lock(&Giant); - if (uap->fromlenaddr) { error = copyin((caddr_t)uap->fromlenaddr, (caddr_t)&msg.msg_namelen, sizeof (msg.msg_namelen)); @@ -1023,7 +1018,7 @@ recvfrom(p, uap) aiov.iov_len = uap->len; msg.msg_control = 0; msg.msg_flags = uap->flags; - error = recvit(p, uap->s, &msg, (caddr_t)uap->fromlenaddr); + error = recvit(td, uap->s, &msg, (caddr_t)uap->fromlenaddr); done2: mtx_unlock(&Giant); return(error); @@ -1034,13 +1029,13 @@ done2: * MPSAFE */ int -orecvfrom(p, uap) - struct proc *p; +orecvfrom(td, uap) + struct thread *td; struct recvfrom_args *uap; { uap->flags |= MSG_COMPAT; - return (recvfrom(p, uap)); + return (recvfrom(td, uap)); } #endif @@ -1050,8 +1045,8 @@ orecvfrom(p, uap) * MPSAFE */ int -orecv(p, uap) - struct proc *p; +orecv(td, uap) + struct thread *td; register struct orecv_args /* { int s; caddr_t buf; @@ -1072,7 +1067,7 @@ orecv(p, uap) aiov.iov_len = uap->len; msg.msg_control = 0; msg.msg_flags = uap->flags; - error = recvit(p, uap->s, &msg, (caddr_t)0); + error = recvit(td, uap->s, &msg, (caddr_t)0); mtx_unlock(&Giant); return (error); } @@ -1085,8 +1080,8 @@ orecv(p, uap) * MPSAFE */ int -orecvmsg(p, uap) - struct proc *p; +orecvmsg(td, uap) + struct thread *td; register struct orecvmsg_args /* { int s; struct omsghdr *msg; @@ -1120,7 +1115,7 @@ orecvmsg(p, uap) if (error) goto done; msg.msg_iov = iov; - error = recvit(p, uap->s, &msg, (caddr_t)&uap->msg->msg_namelen); + error = recvit(td, uap->s, &msg, (caddr_t)&uap->msg->msg_namelen); if (msg.msg_controllen && error == 0) error = copyout((caddr_t)&msg.msg_controllen, @@ -1138,8 +1133,8 @@ done2: * MPSAFE */ int -recvmsg(p, uap) - struct proc *p; +recvmsg(td, uap) + struct thread *td; register struct recvmsg_args /* { int s; struct msghdr *msg; @@ -1151,7 +1146,6 @@ recvmsg(p, uap) register int error; mtx_lock(&Giant); - error = copyin((caddr_t)uap->msg, (caddr_t)&msg, sizeof (msg)); if (error) goto done2; @@ -1177,7 +1171,7 @@ recvmsg(p, uap) (unsigned)(msg.msg_iovlen * sizeof (struct iovec))); if (error) goto done; - error = recvit(p, uap->s, &msg, (caddr_t)0); + error = recvit(td, uap->s, &msg, (caddr_t)0); if (!error) { msg.msg_iov = uiov; error = copyout((caddr_t)&msg, (caddr_t)uap->msg, sizeof(msg)); @@ -1195,8 +1189,8 @@ done2: */ /* ARGSUSED */ int -shutdown(p, uap) - struct proc *p; +shutdown(td, uap) + struct thread *td; register struct shutdown_args /* { int s; int how; @@ -1206,11 +1200,10 @@ shutdown(p, uap) int error; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error == 0) { error = soshutdown((struct socket *)fp->f_data, uap->how); - fdrop(fp, p); + fdrop(fp, td); } mtx_unlock(&Giant); return(error); @@ -1221,8 +1214,8 @@ shutdown(p, uap) */ /* ARGSUSED */ int -setsockopt(p, uap) - struct proc *p; +setsockopt(td, uap) + struct thread *td; register struct setsockopt_args /* { int s; int level; @@ -1241,16 +1234,16 @@ setsockopt(p, uap) return (EINVAL); mtx_lock(&Giant); - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error == 0) { sopt.sopt_dir = SOPT_SET; sopt.sopt_level = uap->level; sopt.sopt_name = uap->name; sopt.sopt_val = uap->val; sopt.sopt_valsize = uap->valsize; - sopt.sopt_p = p; + sopt.sopt_td = td; error = sosetopt((struct socket *)fp->f_data, &sopt); - fdrop(fp, p); + fdrop(fp, td); } mtx_unlock(&Giant); return(error); @@ -1261,8 +1254,8 @@ setsockopt(p, uap) */ /* ARGSUSED */ int -getsockopt(p, uap) - struct proc *p; +getsockopt(td, uap) + struct thread *td; register struct getsockopt_args /* { int s; int level; @@ -1276,19 +1269,18 @@ getsockopt(p, uap) struct sockopt sopt; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->s, &fp); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error) goto done2; if (uap->val) { error = copyin((caddr_t)uap->avalsize, (caddr_t)&valsize, sizeof (valsize)); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } if (valsize < 0) { - fdrop(fp, p); + fdrop(fp, td); error = EINVAL; goto done2; } @@ -1301,7 +1293,7 @@ getsockopt(p, uap) sopt.sopt_name = uap->name; sopt.sopt_val = uap->val; sopt.sopt_valsize = (size_t)valsize; /* checked non-negative above */ - sopt.sopt_p = p; + sopt.sopt_td = td; error = sogetopt((struct socket *)fp->f_data, &sopt); if (error == 0) { @@ -1309,7 +1301,7 @@ getsockopt(p, uap) error = copyout((caddr_t)&valsize, (caddr_t)uap->avalsize, sizeof (valsize)); } - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -1322,8 +1314,8 @@ done2: */ /* ARGSUSED */ static int -getsockname1(p, uap, compat) - struct proc *p; +getsockname1(td, uap, compat) + struct thread *td; register struct getsockname_args /* { int fdes; caddr_t asa; @@ -1337,13 +1329,12 @@ getsockname1(p, uap, compat) int len, error; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->fdes, &fp); + error = holdsock(td->td_proc->p_fd, uap->fdes, &fp); if (error) goto done2; error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } so = (struct socket *)fp->f_data; @@ -1369,7 +1360,7 @@ gotnothing: bad: if (sa) FREE(sa, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -1379,11 +1370,12 @@ done2: * MPSAFE */ int -getsockname(p, uap) - struct proc *p; +getsockname(td, uap) + struct thread *td; struct getsockname_args *uap; { - return (getsockname1(p, uap, 0)); + + return (getsockname1(td, uap, 0)); } #ifdef COMPAT_OLDSOCK @@ -1391,11 +1383,12 @@ getsockname(p, uap) * MPSAFE */ int -ogetsockname(p, uap) - struct proc *p; +ogetsockname(td, uap) + struct thread *td; struct getsockname_args *uap; { - return (getsockname1(p, uap, 1)); + + return (getsockname1(td, uap, 1)); } #endif /* COMPAT_OLDSOCK */ @@ -1406,8 +1399,8 @@ ogetsockname(p, uap) */ /* ARGSUSED */ static int -getpeername1(p, uap, compat) - struct proc *p; +getpeername1(td, uap, compat) + struct thread *td; register struct getpeername_args /* { int fdes; caddr_t asa; @@ -1421,19 +1414,18 @@ getpeername1(p, uap, compat) int len, error; mtx_lock(&Giant); - - error = holdsock(p->p_fd, uap->fdes, &fp); + error = holdsock(td->td_proc->p_fd, uap->fdes, &fp); if (error) goto done2; so = (struct socket *)fp->f_data; if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) { - fdrop(fp, p); + fdrop(fp, td); error = ENOTCONN; goto done2; } error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } sa = 0; @@ -1458,7 +1450,7 @@ gotnothing: bad: if (sa) FREE(sa, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -1468,11 +1460,12 @@ done2: * MPSAFE */ int -getpeername(p, uap) - struct proc *p; +getpeername(td, uap) + struct thread *td; struct getpeername_args *uap; { - return (getpeername1(p, uap, 0)); + + return (getpeername1(td, uap, 0)); } #ifdef COMPAT_OLDSOCK @@ -1480,12 +1473,13 @@ getpeername(p, uap) * MPSAFE */ int -ogetpeername(p, uap) - struct proc *p; +ogetpeername(td, uap) + struct thread *td; struct ogetpeername_args *uap; { + /* XXX uap should have type `getpeername_args *' to begin with. */ - return (getpeername1(p, (struct getpeername_args *)uap, 1)); + return (getpeername1(td, (struct getpeername_args *)uap, 1)); } #endif /* COMPAT_OLDSOCK */ @@ -1682,10 +1676,10 @@ sf_buf_free(caddr_t addr, void *args) * */ int -sendfile(struct proc *p, struct sendfile_args *uap) +sendfile(struct thread *td, struct sendfile_args *uap) { struct file *fp; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct vnode *vp; struct vm_object *obj; struct socket *so; @@ -1698,7 +1692,6 @@ sendfile(struct proc *p, struct sendfile_args *uap) int error = 0, s; mtx_lock(&Giant); - vp = NULL; /* * Do argument checking. Must be a regular file in, stream @@ -1719,8 +1712,8 @@ sendfile(struct proc *p, struct sendfile_args *uap) error = EINVAL; goto done; } - fdrop(fp, p); - error = holdsock(p->p_fd, uap->s, &fp); + fdrop(fp, td); + error = holdsock(td->td_proc->p_fd, uap->s, &fp); if (error) goto done; so = (struct socket *)fp->f_data; @@ -1752,10 +1745,10 @@ sendfile(struct proc *p, struct sendfile_args *uap) nuap.fd = uap->s; nuap.iovp = hdtr.headers; nuap.iovcnt = hdtr.hdr_cnt; - error = writev(p, &nuap); + error = writev(td, &nuap); if (error) goto done; - sbytes += p->p_retval[0]; + sbytes += td->td_retval[0]; } } @@ -1856,11 +1849,11 @@ retry_lookup: auio.uio_offset = trunc_page(off); auio.uio_segflg = UIO_NOCOPY; auio.uio_rw = UIO_READ; - auio.uio_procp = p; - vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, p); + auio.uio_td = td; + vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, td); error = VOP_READ(vp, &auio, IO_VMIO | ((MAXBSIZE / bsize) << 16), - p->p_ucred); - VOP_UNLOCK(vp, 0, p); + td->td_proc->p_ucred); + VOP_UNLOCK(vp, 0, td); vm_page_flag_clear(pg, PG_ZERO); vm_page_io_finish(pg); if (error) { @@ -1972,7 +1965,7 @@ retry_space: } goto retry_space; } - error = (*so->so_proto->pr_usrreqs->pru_send)(so, 0, m, 0, 0, p); + error = (*so->so_proto->pr_usrreqs->pru_send)(so, 0, m, 0, 0, td); splx(s); if (error) { sbunlock(&so->so_snd); @@ -1988,19 +1981,19 @@ retry_space: nuap.fd = uap->s; nuap.iovp = hdtr.trailers; nuap.iovcnt = hdtr.trl_cnt; - error = writev(p, &nuap); + error = writev(td, &nuap); if (error) goto done; - sbytes += p->p_retval[0]; + sbytes += td->td_retval[0]; } done: /* - * If there was no error we have to clear p->p_retval[0] + * If there was no error we have to clear td->td_retval[0] * because it may have been set by writev. */ if (error == 0) { - p->p_retval[0] = 0; + td->td_retval[0] = 0; } if (uap->sbytes != NULL) { copyout(&sbytes, uap->sbytes, sizeof(off_t)); @@ -2008,8 +2001,7 @@ done: if (vp) vrele(vp); if (fp) - fdrop(fp, p); + fdrop(fp, td); mtx_unlock(&Giant); return (error); } - diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 043bc6b..52c60cf 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -80,9 +80,9 @@ static ino_t unp_ino; /* prototype for fake inode numbers */ static int unp_attach __P((struct socket *)); static void unp_detach __P((struct unpcb *)); -static int unp_bind __P((struct unpcb *,struct sockaddr *, struct proc *)); +static int unp_bind __P((struct unpcb *,struct sockaddr *, struct thread *)); static int unp_connect __P((struct socket *,struct sockaddr *, - struct proc *)); + struct thread *)); static void unp_disconnect __P((struct unpcb *)); static void unp_shutdown __P((struct unpcb *)); static void unp_drop __P((struct unpcb *, int)); @@ -90,7 +90,7 @@ static void unp_gc __P((void)); static void unp_scan __P((struct mbuf *, void (*)(struct file *))); static void unp_mark __P((struct file *)); static void unp_discard __P((struct file *)); -static int unp_internalize __P((struct mbuf *, struct proc *)); +static int unp_internalize __P((struct mbuf *, struct thread *)); static int unp_listen __P((struct unpcb *, struct proc *)); static int @@ -127,7 +127,7 @@ uipc_accept(struct socket *so, struct sockaddr **nam) } static int -uipc_attach(struct socket *so, int proto, struct proc *p) +uipc_attach(struct socket *so, int proto, struct thread *td) { struct unpcb *unp = sotounpcb(so); @@ -137,24 +137,24 @@ uipc_attach(struct socket *so, int proto, struct proc *p) } static int -uipc_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct unpcb *unp = sotounpcb(so); if (unp == 0) return EINVAL; - return unp_bind(unp, nam, p); + return unp_bind(unp, nam, td); } static int -uipc_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +uipc_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct unpcb *unp = sotounpcb(so); if (unp == 0) return EINVAL; - return unp_connect(so, nam, curproc); + return unp_connect(so, nam, curthread); } static int @@ -194,13 +194,13 @@ uipc_disconnect(struct socket *so) } static int -uipc_listen(struct socket *so, struct proc *p) +uipc_listen(struct socket *so, struct thread *td) { struct unpcb *unp = sotounpcb(so); if (unp == 0 || unp->unp_vnode == 0) return EINVAL; - return unp_listen(unp, p); + return unp_listen(unp, td->td_proc); } static int @@ -258,7 +258,7 @@ uipc_rcvd(struct socket *so, int flags) static int uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { int error = 0; struct unpcb *unp = sotounpcb(so); @@ -274,7 +274,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, goto release; } - if (control && (error = unp_internalize(control, p))) + if (control && (error = unp_internalize(control, td))) goto release; switch (so->so_type) { @@ -287,7 +287,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, error = EISCONN; break; } - error = unp_connect(so, nam, p); + error = unp_connect(so, nam, td); if (error) break; } else { @@ -320,7 +320,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, */ if ((so->so_state & SS_ISCONNECTED) == 0) { if (nam) { - error = unp_connect(so, nam, p); + error = unp_connect(so, nam, td); if (error) break; /* XXX */ } else { @@ -534,7 +534,7 @@ unp_attach(so) unp_count++; LIST_INIT(&unp->unp_refs); unp->unp_socket = so; - unp->unp_rvnode = curproc->p_fd->fd_rdir; + unp->unp_rvnode = curthread->td_proc->p_fd->fd_rdir; LIST_INSERT_HEAD(so->so_type == SOCK_DGRAM ? &unp_dhead : &unp_shead, unp, unp_link); so->so_pcb = (caddr_t)unp; @@ -576,10 +576,10 @@ unp_detach(unp) } static int -unp_bind(unp, nam, p) +unp_bind(unp, nam, td) struct unpcb *unp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct sockaddr_un *soun = (struct sockaddr_un *)nam; struct vnode *vp; @@ -599,7 +599,7 @@ unp_bind(unp, nam, p) buf[namelen] = 0; /* null-terminate the string */ restart: NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT, UIO_SYSSPACE, - buf, p); + buf, td); /* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ error = namei(&nd); if (error) { @@ -627,8 +627,8 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VSOCK; - vattr.va_mode = (ACCESSPERMS & ~p->p_fd->fd_cmask); - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = (ACCESSPERMS & ~td->td_proc->p_fd->fd_cmask); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -640,17 +640,17 @@ restart: vp->v_socket = unp->unp_socket; unp->unp_vnode = vp; unp->unp_addr = (struct sockaddr_un *)dup_sockaddr(nam, 1); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); free(buf, M_TEMP); return (0); } static int -unp_connect(so, nam, p) +unp_connect(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { register struct sockaddr_un *soun = (struct sockaddr_un *)nam; register struct vnode *vp; @@ -666,7 +666,7 @@ unp_connect(so, nam, p) strncpy(buf, soun->sun_path, len); buf[len] = 0; - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, buf, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, buf, td); error = namei(&nd); if (error) return (error); @@ -676,7 +676,7 @@ unp_connect(so, nam, p) error = ENOTSOCK; goto bad; } - error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p); + error = VOP_ACCESS(vp, VWRITE, td->td_proc->p_ucred, td); if (error) goto bad; so2 = vp->v_socket; @@ -690,7 +690,7 @@ unp_connect(so, nam, p) } if (so->so_proto->pr_flags & PR_CONNREQUIRED) { if ((so2->so_options & SO_ACCEPTCONN) == 0 || - (so3 = sonewconn3(so2, 0, p)) == 0) { + (so3 = sonewconn3(so2, 0, td)) == 0) { error = ECONNREFUSED; goto bad; } @@ -710,9 +710,9 @@ unp_connect(so, nam, p) * (which is now). */ memset(&unp3->unp_peercred, '\0', sizeof(unp3->unp_peercred)); - unp3->unp_peercred.cr_uid = p->p_ucred->cr_uid; - unp3->unp_peercred.cr_ngroups = p->p_ucred->cr_ngroups; - memcpy(unp3->unp_peercred.cr_groups, p->p_ucred->cr_groups, + unp3->unp_peercred.cr_uid = td->td_proc->p_ucred->cr_uid; + unp3->unp_peercred.cr_ngroups = td->td_proc->p_ucred->cr_ngroups; + memcpy(unp3->unp_peercred.cr_groups, td->td_proc->p_ucred->cr_groups, sizeof(unp3->unp_peercred.cr_groups)); unp3->unp_flags |= UNP_HAVEPC; /* @@ -956,7 +956,7 @@ int unp_externalize(rights) struct mbuf *rights; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register int i; register struct cmsghdr *cm = mtod(rights, struct cmsghdr *); register int *fdp; @@ -969,7 +969,7 @@ unp_externalize(rights) /* * if the new FD's will not fit, then we free them all */ - if (!fdavail(p, newfds)) { + if (!fdavail(td, newfds)) { rp = (struct file **)CMSG_DATA(cm); for (i = 0; i < newfds; i++) { fp = *rp; @@ -997,10 +997,10 @@ unp_externalize(rights) fdp = (int *)(cm + 1); rp = (struct file **)CMSG_DATA(cm); for (i = 0; i < newfds; i++) { - if (fdalloc(p, 0, &f)) + if (fdalloc(td, 0, &f)) panic("unp_externalize"); fp = *rp++; - p->p_fd->fd_ofiles[f] = fp; + td->td_proc->p_fd->fd_ofiles[f] = fp; fp->f_msgcount--; unp_rights--; *fdp++ = f; @@ -1009,10 +1009,10 @@ unp_externalize(rights) fdp = (int *)(cm + 1) + newfds - 1; rp = (struct file **)CMSG_DATA(cm) + newfds - 1; for (i = 0; i < newfds; i++) { - if (fdalloc(p, 0, &f)) + if (fdalloc(td, 0, &f)) panic("unp_externalize"); fp = *rp--; - p->p_fd->fd_ofiles[f] = fp; + td->td_proc->p_fd->fd_ofiles[f] = fp; fp->f_msgcount--; unp_rights--; *fdp-- = f; @@ -1043,10 +1043,11 @@ unp_init(void) #endif static int -unp_internalize(control, p) +unp_internalize(control, td) struct mbuf *control; - struct proc *p; + struct thread *td; { + struct proc *p = td->td_proc; struct filedesc *fdescp = p->p_fd; register struct cmsghdr *cm = mtod(control, struct cmsghdr *); register struct file **rp; @@ -1308,7 +1309,7 @@ unp_gc() sorflush((struct socket *)(tfp->f_data)); } for (i = nunref, fpp = extra_ref; --i >= 0; ++fpp) - closef(*fpp, (struct proc *) NULL); + closef(*fpp, (struct thread *) NULL); free((caddr_t)extra_ref, M_FILE); unp_gcing = 0; } @@ -1386,5 +1387,5 @@ unp_discard(fp) fp->f_msgcount--; unp_rights--; - (void) closef(fp, (struct proc *)NULL); + (void) closef(fp, (struct thread *)NULL); } diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index 69dbe85..045d1a8 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -48,11 +48,11 @@ MALLOC_DEFINE(M_ACL, "acl", "access control list"); -static int vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +static int vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); -static int vacl_aclcheck(struct proc *p, struct vnode *vp, +static int vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp); /* @@ -562,7 +562,7 @@ acl_posix1e_check(struct acl *acl) * Given a vnode, set its ACL. */ static int -vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_set_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; @@ -571,10 +571,10 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, type, &inkernacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return(error); } @@ -582,16 +582,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, get its ACL. */ static int -vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_get_acl( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_GETACL(vp, type, &inkernelacl, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -601,14 +601,14 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, * Given a vnode, delete its ACL. */ static int -vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) +vacl_delete( struct thread *td, struct vnode *vp, acl_type_t type) { int error; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -616,7 +616,7 @@ vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) * Given a vnode, check whether an ACL is appropriate for it */ static int -vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, +vacl_aclcheck( struct thread *td, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; @@ -625,7 +625,7 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); + error = VOP_ACLCHECK(vp, type, &inkernelacl, td->td_proc->p_ucred, td); return (error); } @@ -641,17 +641,17 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, * MPSAFE */ int -__acl_get_file(struct proc *p, struct __acl_get_file_args *uap) +__acl_get_file( struct thread *td, struct __acl_get_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); /* what flags are required here -- possible not LOCKLEAF? */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_get_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_get_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -665,16 +665,16 @@ __acl_get_file(struct proc *p, struct __acl_get_file_args *uap) * MPSAFE */ int -__acl_set_file(struct proc *p, struct __acl_set_file_args *uap) +__acl_set_file( struct thread *td, struct __acl_set_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_set_acl(p, nd.ni_vp, SCARG(uap, type), + error = vacl_set_acl(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -688,15 +688,15 @@ __acl_set_file(struct proc *p, struct __acl_set_file_args *uap) * MPSAFE */ int -__acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) +__acl_get_fd( struct thread *td, struct __acl_get_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_get_acl(p, (struct vnode *)fp->f_data, + error = vacl_get_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -709,15 +709,15 @@ __acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap) * MPSAFE */ int -__acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) +__acl_set_fd( struct thread *td, struct __acl_set_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_set_acl(p, (struct vnode *)fp->f_data, + error = vacl_set_acl(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); @@ -730,16 +730,16 @@ __acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap) * MPSAFE */ int -__acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) +__acl_delete_file( struct thread *td, struct __acl_delete_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_delete(p, nd.ni_vp, SCARG(uap, type)); + error = vacl_delete(td, nd.ni_vp, SCARG(uap, type)); NDFREE(&nd, 0); } mtx_unlock(&Giant); @@ -752,15 +752,15 @@ __acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap) * MPSAFE */ int -__acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) +__acl_delete_fd( struct thread *td, struct __acl_delete_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_delete(p, (struct vnode *)fp->f_data, + error = vacl_delete(td, (struct vnode *)fp->f_data, SCARG(uap, type)); } mtx_unlock(&Giant); @@ -773,16 +773,16 @@ __acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap) * MPSAFE */ int -__acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) +__acl_aclcheck_file( struct thread *td, struct __acl_aclcheck_file_args *uap) { struct nameidata nd; int error; mtx_lock(&Giant); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); error = namei(&nd); if (error == 0) { - error = vacl_aclcheck(p, nd.ni_vp, SCARG(uap, type), + error = vacl_aclcheck(td, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp)); NDFREE(&nd, 0); } @@ -796,15 +796,15 @@ __acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap) * MPSAFE */ int -__acl_aclcheck_fd(struct proc *p, struct __acl_aclcheck_fd_args *uap) +__acl_aclcheck_fd( struct thread *td, struct __acl_aclcheck_fd_args *uap) { struct file *fp; int error; mtx_lock(&Giant); - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error == 0) { - error = vacl_aclcheck(p, (struct vnode *)fp->f_data, + error = vacl_aclcheck(td, (struct vnode *)fp->f_data, SCARG(uap, type), SCARG(uap, aclp)); } mtx_unlock(&Giant); diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index a695e5d..89a0c65 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -153,10 +153,10 @@ SYSCTL_INT(_vfs_aio, OID_AUTO, aiod_timeout, #define AIOP_FREE 0x1 /* proc on free queue */ #define AIOP_SCHED 0x2 /* proc explicitly scheduled */ -struct aioproclist { - int aioprocflags; /* AIO proc flags */ - TAILQ_ENTRY(aioproclist) list; /* List of processes */ - struct proc *aioproc; /* The AIO thread */ +struct aiothreadlist { + int aiothreadflags; /* AIO proc flags */ + TAILQ_ENTRY(aiothreadlist) list; /* List of processes */ + struct thread *aiothread; /* The AIO thread */ TAILQ_HEAD (,aiocblist) jobtorun; /* suggested job to run */ }; @@ -201,7 +201,7 @@ struct kaioinfo { #define KAIO_RUNDOWN 0x1 /* process is being run down */ #define KAIO_WAKEUP 0x2 /* wakeup process when there is a significant event */ -static TAILQ_HEAD(,aioproclist) aio_freeproc, aio_activeproc; +static TAILQ_HEAD(,aiothreadlist) aio_freeproc, aio_activeproc; static TAILQ_HEAD(,aiocblist) aio_jobs; /* Async job list */ static TAILQ_HEAD(,aiocblist) aio_bufjobs; /* Phys I/O job list */ @@ -210,7 +210,7 @@ static void aio_onceonly(void *); static int aio_free_entry(struct aiocblist *aiocbe); static void aio_process(struct aiocblist *aiocbe); static int aio_newproc(void); -static int aio_aqueue(struct proc *p, struct aiocb *job, int type); +static int aio_aqueue(struct thread *td, struct aiocb *job, int type); static void aio_physwakeup(struct buf *bp); static int aio_fphysio(struct proc *p, struct aiocblist *aiocbe); static int aio_qphysio(struct proc *p, struct aiocblist *iocb); @@ -233,7 +233,7 @@ aio_onceonly(void *na) TAILQ_INIT(&aio_jobs); TAILQ_INIT(&aio_bufjobs); kaio_zone = zinit("AIO", sizeof (struct kaioinfo), 0, 0, 1); - aiop_zone = zinit("AIOP", sizeof (struct aioproclist), 0, 0, 1); + aiop_zone = zinit("AIOP", sizeof (struct aiothreadlist), 0, 0, 1); aiocb_zone = zinit("AIOCB", sizeof (struct aiocblist), 0, 0, 1); aiol_zone = zinit("AIOL", AIO_LISTIO_MAX * sizeof (int), 0, 0, 1); aiolio_zone = zinit("AIOLIO", AIO_LISTIO_MAX * sizeof (struct @@ -284,7 +284,7 @@ static int aio_free_entry(struct aiocblist *aiocbe) { struct kaioinfo *ki; - struct aioproclist *aiop; + struct aiothreadlist *aiop; struct aio_liojob *lj; struct proc *p; int error; @@ -335,7 +335,13 @@ aio_free_entry(struct aiocblist *aiocbe) } /* aiocbe is going away, we need to destroy any knotes */ - knote_remove(p, &aiocbe->klist); + knote_remove(&p->p_thread, &aiocbe->klist); /* XXXKSE */ + /* XXXKSE Note the thread here is used to eventually find the + * owning process again, but it is also used to do a fo_close + * and that requires the thread. (but does it require the + * OWNING thread? (or maby the running thread?) + * There is a semantic problem here... + */ if ((ki->kaio_flags & KAIO_WAKEUP) || ((ki->kaio_flags & KAIO_RUNDOWN) && ((ki->kaio_buffer_count == 0) && (ki->kaio_queue_count == 0)))) { @@ -352,7 +358,7 @@ aio_free_entry(struct aiocblist *aiocbe) TAILQ_REMOVE(&ki->kaio_bufdone, aiocbe, plist); splx(s); } else if (aiocbe->jobstate == JOBST_JOBQPROC) { - aiop = aiocbe->jobaioproc; + aiop = aiocbe->jobaiothread; TAILQ_REMOVE(&aiop->jobtorun, aiocbe, list); } else if (aiocbe->jobstate == JOBST_JOBQGLOBAL) { TAILQ_REMOVE(&aio_jobs, aiocbe, list); @@ -521,7 +527,7 @@ restart4: * Select a job to run (called by an AIO daemon). */ static struct aiocblist * -aio_selectjob(struct aioproclist *aiop) +aio_selectjob(struct aiothreadlist *aiop) { int s; struct aiocblist *aiocbe; @@ -561,7 +567,9 @@ static void aio_process(struct aiocblist *aiocbe) { struct filedesc *fdp; - struct proc *userp, *mycp; + struct thread *td; + struct proc *userp; + struct proc *mycp; struct aiocb *cb; struct file *fp; struct uio auio; @@ -574,10 +582,10 @@ aio_process(struct aiocblist *aiocbe) int inblock_st, inblock_end; userp = aiocbe->userproc; + td = curthread; + mycp = td->td_proc; cb = &aiocbe->uaiocb; - mycp = curproc; - fdp = mycp->p_fd; fd = cb->aio_fildes; fp = fdp->fd_ofiles[fd]; @@ -588,7 +596,7 @@ aio_process(struct aiocblist *aiocbe) return; } - aiov.iov_base = (void *)cb->aio_buf; + aiov.iov_base = cb->aio_buf; aiov.iov_len = cb->aio_nbytes; auio.uio_iov = &aiov; @@ -597,7 +605,7 @@ aio_process(struct aiocblist *aiocbe) auio.uio_resid = cb->aio_nbytes; cnt = cb->aio_nbytes; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = mycp; + auio.uio_td = td; inblock_st = mycp->p_stats->p_ru.ru_inblock; oublock_st = mycp->p_stats->p_ru.ru_oublock; @@ -608,12 +616,12 @@ aio_process(struct aiocblist *aiocbe) fhold(fp); if (cb->aio_lio_opcode == LIO_READ) { auio.uio_rw = UIO_READ; - error = fo_read(fp, &auio, fp->f_cred, FOF_OFFSET, mycp); + error = fo_read(fp, &auio, fp->f_cred, FOF_OFFSET, td); } else { auio.uio_rw = UIO_WRITE; - error = fo_write(fp, &auio, fp->f_cred, FOF_OFFSET, mycp); + error = fo_write(fp, &auio, fp->f_cred, FOF_OFFSET, td); } - fdrop(fp, mycp); + fdrop(fp, td); inblock_end = mycp->p_stats->p_ru.ru_inblock; oublock_end = mycp->p_stats->p_ru.ru_oublock; @@ -646,16 +654,17 @@ aio_daemon(void *uproc) struct aio_liojob *lj; struct aiocb *cb; struct aiocblist *aiocbe; - struct aioproclist *aiop; + struct aiothreadlist *aiop; struct kaioinfo *ki; struct proc *curcp, *mycp, *userp; struct vmspace *myvm, *tmpvm; + struct thread *td = curthread; mtx_lock(&Giant); /* * Local copies of curproc (cp) and vmspace (myvm) */ - mycp = curproc; + mycp = td->td_proc; myvm = mycp->p_vmspace; if (mycp->p_textvp) { @@ -668,8 +677,8 @@ aio_daemon(void *uproc) * per daemon. */ aiop = zalloc(aiop_zone); - aiop->aioproc = mycp; - aiop->aioprocflags |= AIOP_FREE; + aiop->aiothread = td; + aiop->aiothreadflags |= AIOP_FREE; TAILQ_INIT(&aiop->jobtorun); s = splnet(); @@ -688,7 +697,7 @@ aio_daemon(void *uproc) * filedescriptors, except as temporarily inherited from the client. * Credentials are also cloned, and made equivalent to "root". */ - fdfree(mycp); + fdfree(td); mycp->p_fd = NULL; mycp->p_ucred = crcopy(mycp->p_ucred); mycp->p_ucred->cr_uid = 0; @@ -705,7 +714,7 @@ aio_daemon(void *uproc) /* * Wakeup parent process. (Parent sleeps to keep from blasting away - * creating to many daemons.) + * and creating too many daemons.) */ wakeup(mycp); @@ -719,14 +728,14 @@ aio_daemon(void *uproc) /* * Take daemon off of free queue */ - if (aiop->aioprocflags & AIOP_FREE) { + if (aiop->aiothreadflags & AIOP_FREE) { s = splnet(); TAILQ_REMOVE(&aio_freeproc, aiop, list); TAILQ_INSERT_TAIL(&aio_activeproc, aiop, list); - aiop->aioprocflags &= ~AIOP_FREE; + aiop->aiothreadflags &= ~AIOP_FREE; splx(s); } - aiop->aioprocflags &= ~AIOP_SCHED; + aiop->aiothreadflags &= ~AIOP_SCHED; /* * Check for jobs. @@ -755,7 +764,7 @@ aio_daemon(void *uproc) mycp->p_vmspace->vm_refcnt++; /* Activate the new mapping. */ - pmap_activate(mycp); + pmap_activate(&mycp->p_thread); /* * If the old address space wasn't the daemons @@ -775,7 +784,7 @@ aio_daemon(void *uproc) * because they were originally freed. */ if (mycp->p_fd) - fdfree(mycp); + fdfree(td); mycp->p_fd = fdshare(userp); curcp = userp; } @@ -787,7 +796,7 @@ aio_daemon(void *uproc) ki->kaio_active_count++; /* Do the I/O function. */ - aiocbe->jobaioproc = aiop; + aiocbe->jobaiothread = aiop; aio_process(aiocbe); /* Decrement the active job count. */ @@ -866,7 +875,7 @@ aio_daemon(void *uproc) mycp->p_vmspace = myvm; /* Activate the daemon's address space. */ - pmap_activate(mycp); + pmap_activate(&mycp->p_thread); #ifdef DIAGNOSTIC if (tmpvm == myvm) { printf("AIOD: vmspace problem -- %d\n", @@ -881,7 +890,7 @@ aio_daemon(void *uproc) * descriptors. */ if (mycp->p_fd) - fdfree(mycp); + fdfree(td); mycp->p_fd = NULL; curcp = mycp; } @@ -895,19 +904,19 @@ aio_daemon(void *uproc) if (TAILQ_EMPTY(&aio_freeproc)) wakeup(&aio_freeproc); TAILQ_INSERT_HEAD(&aio_freeproc, aiop, list); - aiop->aioprocflags |= AIOP_FREE; + aiop->aiothreadflags |= AIOP_FREE; splx(s); /* * If daemon is inactive for a long time, allow it to exit, * thereby freeing resources. */ - if (((aiop->aioprocflags & AIOP_SCHED) == 0) && tsleep(mycp, + if (((aiop->aiothreadflags & AIOP_SCHED) == 0) && tsleep(mycp, PRIBIO, "aiordy", aiod_lifetime)) { s = splnet(); if ((TAILQ_FIRST(&aio_jobs) == NULL) && (TAILQ_FIRST(&aiop->jobtorun) == NULL)) { - if ((aiop->aioprocflags & AIOP_FREE) && + if ((aiop->aiothreadflags & AIOP_FREE) && (num_aio_procs > target_aio_procs)) { TAILQ_REMOVE(&aio_freeproc, aiop, list); splx(s); @@ -1033,7 +1042,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe) bp->b_flags = B_PHYS; bp->b_iodone = aio_physwakeup; bp->b_saveaddr = bp->b_data; - bp->b_data = (void *)cb->aio_buf; + bp->b_data = cb->aio_buf; bp->b_blkno = btodb(cb->aio_offset); if (cb->aio_lio_opcode == LIO_WRITE) { @@ -1163,7 +1172,7 @@ aio_swake(struct socket *so, struct sockbuf *sb) struct proc *p; struct kaioinfo *ki = NULL; int opcode, wakecount = 0; - struct aioproclist *aiop; + struct aiothreadlist *aiop; if (sb == &so->so_snd) { opcode = LIO_WRITE; @@ -1192,8 +1201,8 @@ aio_swake(struct socket *so, struct sockbuf *sb) if ((aiop = TAILQ_FIRST(&aio_freeproc)) != 0) { TAILQ_REMOVE(&aio_freeproc, aiop, list); TAILQ_INSERT_TAIL(&aio_activeproc, aiop, list); - aiop->aioprocflags &= ~AIOP_FREE; - wakeup(aiop->aioproc); + aiop->aiothreadflags &= ~AIOP_FREE; + wakeup(aiop->aiothread); } } #endif /* VFS_AIO */ @@ -1205,8 +1214,9 @@ aio_swake(struct socket *so, struct sockbuf *sb) * technique is done in this code. */ static int -_aio_aqueue(struct proc *p, struct aiocb *job, struct aio_liojob *lj, int type) +_aio_aqueue(struct thread *td, struct aiocb *job, struct aio_liojob *lj, int type) { + struct proc *p = td->td_proc; struct filedesc *fdp; struct file *fp; unsigned int fd; @@ -1215,7 +1225,7 @@ _aio_aqueue(struct proc *p, struct aiocb *job, struct aio_liojob *lj, int type) int error; int opcode; struct aiocblist *aiocbe; - struct aioproclist *aiop; + struct aiothreadlist *aiop; struct kaioinfo *ki; struct kevent kev; struct kqueue *kq; @@ -1347,7 +1357,7 @@ _aio_aqueue(struct proc *p, struct aiocb *job, struct aio_liojob *lj, int type) kev.ident = (uintptr_t)aiocbe; kev.filter = EVFILT_AIO; kev.flags = EV_ADD | EV_ENABLE | EV_FLAG1; - error = kqueue_register(kq, &kev, p); + error = kqueue_register(kq, &kev, td); aqueue_fail: if (error) { zfree(aiocb_zone, aiocbe); @@ -1431,22 +1441,22 @@ retryproc: if ((aiop = TAILQ_FIRST(&aio_freeproc)) != NULL) { TAILQ_REMOVE(&aio_freeproc, aiop, list); TAILQ_INSERT_TAIL(&aio_activeproc, aiop, list); - aiop->aioprocflags &= ~AIOP_FREE; - wakeup(aiop->aioproc); + aiop->aiothreadflags &= ~AIOP_FREE; + wakeup(aiop->aiothread); } else if (((num_aio_resv_start + num_aio_procs) < max_aio_procs) && ((ki->kaio_active_count + num_aio_resv_start) < ki->kaio_maxactive_count)) { num_aio_resv_start++; if ((error = aio_newproc()) == 0) { num_aio_resv_start--; - p->p_retval[0] = 0; + td->td_retval[0] = 0; goto retryproc; } num_aio_resv_start--; } splx(s); done: - fdrop(fp, p); + fdrop(fp, td); return error; } @@ -1454,8 +1464,9 @@ done: * This routine queues an AIO request, checking for quotas. */ static int -aio_aqueue(struct proc *p, struct aiocb *job, int type) +aio_aqueue(struct thread *td, struct aiocb *job, int type) { + struct proc *p = td->td_proc; struct kaioinfo *ki; if (p->p_aioinfo == NULL) @@ -1468,7 +1479,7 @@ aio_aqueue(struct proc *p, struct aiocb *job, int type) if (ki->kaio_queue_count >= ki->kaio_qallowed_count) return EAGAIN; - return _aio_aqueue(p, job, NULL, type); + return _aio_aqueue(td, job, NULL, type); } #endif /* VFS_AIO */ @@ -1477,11 +1488,12 @@ aio_aqueue(struct proc *p, struct aiocb *job, int type) * released. */ int -aio_return(struct proc *p, struct aio_return_args *uap) +aio_return(struct thread *td, struct aio_return_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; int s; int jobref; struct aiocblist *cb, *ncb; @@ -1505,10 +1517,10 @@ aio_return(struct proc *p, struct aio_return_args *uap) jobref) { splx(s); if (ujob == cb->uuaiocb) { - p->p_retval[0] = + td->td_retval[0] = cb->uaiocb._aiocb_private.status; } else - p->p_retval[0] = EFAULT; + td->td_retval[0] = EFAULT; if (cb->uaiocb.aio_lio_opcode == LIO_WRITE) { curproc->p_stats->p_ru.ru_oublock += cb->outputcharge; @@ -1531,10 +1543,10 @@ aio_return(struct proc *p, struct aio_return_args *uap) == jobref) { splx(s); if (ujob == cb->uuaiocb) { - p->p_retval[0] = + td->td_retval[0] = cb->uaiocb._aiocb_private.status; } else - p->p_retval[0] = EFAULT; + td->td_retval[0] = EFAULT; aio_free_entry(cb); return 0; } @@ -1549,11 +1561,12 @@ aio_return(struct proc *p, struct aio_return_args *uap) * Allow a process to wakeup when any of the I/O requests are completed. */ int -aio_suspend(struct proc *p, struct aio_suspend_args *uap) +aio_suspend(struct thread *td, struct aio_suspend_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; struct timeval atv; struct timespec ts; struct aiocb *const *cbptr, *cbp; @@ -1666,11 +1679,12 @@ aio_suspend(struct proc *p, struct aio_suspend_args *uap) * progress. */ int -aio_cancel(struct proc *p, struct aio_cancel_args *uap) +aio_cancel(struct thread *td, struct aio_cancel_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; struct kaioinfo *ki; struct aiocblist *cbe, *cbn; struct file *fp; @@ -1694,7 +1708,7 @@ aio_cancel(struct proc *p, struct aio_cancel_args *uap) vp = (struct vnode *)fp->f_data; if (vn_isdisk(vp,&error)) { - p->p_retval[0] = AIO_NOTCANCELED; + td->td_retval[0] = AIO_NOTCANCELED; return 0; } } else if (fp->f_type == DTYPE_SOCKET) { @@ -1733,7 +1747,7 @@ aio_cancel(struct proc *p, struct aio_cancel_args *uap) splx(s); if ((cancelled) && (uap->aiocbp)) { - p->p_retval[0] = AIO_CANCELED; + td->td_retval[0] = AIO_CANCELED; return 0; } @@ -1777,16 +1791,16 @@ aio_cancel(struct proc *p, struct aio_cancel_args *uap) if (notcancelled) { - p->p_retval[0] = AIO_NOTCANCELED; + td->td_retval[0] = AIO_NOTCANCELED; return 0; } if (cancelled) { - p->p_retval[0] = AIO_CANCELED; + td->td_retval[0] = AIO_CANCELED; return 0; } - p->p_retval[0] = AIO_ALLDONE; + td->td_retval[0] = AIO_ALLDONE; return 0; #endif /* VFS_AIO */ @@ -1798,11 +1812,12 @@ aio_cancel(struct proc *p, struct aio_cancel_args *uap) * subroutine. */ int -aio_error(struct proc *p, struct aio_error_args *uap) +aio_error(struct thread *td, struct aio_error_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; int s; struct aiocblist *cb; struct kaioinfo *ki; @@ -1820,7 +1835,7 @@ aio_error(struct proc *p, struct aio_error_args *uap) plist)) { if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) == jobref) { - p->p_retval[0] = cb->uaiocb._aiocb_private.error; + td->td_retval[0] = cb->uaiocb._aiocb_private.error; return 0; } } @@ -1831,7 +1846,7 @@ aio_error(struct proc *p, struct aio_error_args *uap) plist)) { if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) == jobref) { - p->p_retval[0] = EINPROGRESS; + td->td_retval[0] = EINPROGRESS; splx(s); return 0; } @@ -1841,7 +1856,7 @@ aio_error(struct proc *p, struct aio_error_args *uap) plist)) { if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) == jobref) { - p->p_retval[0] = EINPROGRESS; + td->td_retval[0] = EINPROGRESS; splx(s); return 0; } @@ -1853,7 +1868,7 @@ aio_error(struct proc *p, struct aio_error_args *uap) plist)) { if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) == jobref) { - p->p_retval[0] = cb->uaiocb._aiocb_private.error; + td->td_retval[0] = cb->uaiocb._aiocb_private.error; splx(s); return 0; } @@ -1863,7 +1878,7 @@ aio_error(struct proc *p, struct aio_error_args *uap) plist)) { if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) == jobref) { - p->p_retval[0] = EINPROGRESS; + td->td_retval[0] = EINPROGRESS; splx(s); return 0; } @@ -1883,31 +1898,32 @@ aio_error(struct proc *p, struct aio_error_args *uap) } int -aio_read(struct proc *p, struct aio_read_args *uap) +aio_read(struct thread *td, struct aio_read_args *uap) { #ifndef VFS_AIO return ENOSYS; #else - return aio_aqueue(p, uap->aiocbp, LIO_READ); + return aio_aqueue(td, uap->aiocbp, LIO_READ); #endif /* VFS_AIO */ } int -aio_write(struct proc *p, struct aio_write_args *uap) +aio_write(struct thread *td, struct aio_write_args *uap) { #ifndef VFS_AIO return ENOSYS; #else - return aio_aqueue(p, uap->aiocbp, LIO_WRITE); + return aio_aqueue(td, uap->aiocbp, LIO_WRITE); #endif /* VFS_AIO */ } int -lio_listio(struct proc *p, struct lio_listio_args *uap) +lio_listio(struct thread *td, struct lio_listio_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; int nent, nentqueued; struct aiocb *iocb, * const *cbptr; struct aiocblist *cb; @@ -1975,7 +1991,7 @@ lio_listio(struct proc *p, struct lio_listio_args *uap) for (i = 0; i < uap->nent; i++) { iocb = (struct aiocb *)(intptr_t)fuword((caddr_t)&cbptr[i]); if (((intptr_t)iocb != -1) && ((intptr_t)iocb != NULL)) { - error = _aio_aqueue(p, iocb, lj, 0); + error = _aio_aqueue(td, iocb, lj, 0); if (error == 0) nentqueued++; else @@ -2173,11 +2189,12 @@ aio_physwakeup(struct buf *bp) #endif /* VFS_AIO */ int -aio_waitcomplete(struct proc *p, struct aio_waitcomplete_args *uap) +aio_waitcomplete(struct thread *td, struct aio_waitcomplete_args *uap) { #ifndef VFS_AIO return ENOSYS; #else + struct proc *p = td->td_proc; struct timeval atv; struct timespec ts; struct aiocb **cbptr; @@ -2212,7 +2229,7 @@ aio_waitcomplete(struct proc *p, struct aio_waitcomplete_args *uap) for (;;) { if ((cb = TAILQ_FIRST(&ki->kaio_jobdone)) != 0) { suword(uap->aiocbp, (int)cb->uuaiocb); - p->p_retval[0] = cb->uaiocb._aiocb_private.status; + td->td_retval[0] = cb->uaiocb._aiocb_private.status; if (cb->uaiocb.aio_lio_opcode == LIO_WRITE) { curproc->p_stats->p_ru.ru_oublock += cb->outputcharge; @@ -2230,7 +2247,7 @@ aio_waitcomplete(struct proc *p, struct aio_waitcomplete_args *uap) if ((cb = TAILQ_FIRST(&ki->kaio_bufdone)) != 0 ) { splx(s); suword(uap->aiocbp, (int)cb->uuaiocb); - p->p_retval[0] = cb->uaiocb._aiocb_private.status; + td->td_retval[0] = cb->uaiocb._aiocb_private.status; aio_free_entry(cb); return cb->uaiocb._aiocb_private.error; } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index e66a93e..39e09b3 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -594,8 +594,8 @@ breadn(struct vnode * vp, daddr_t blkno, int size, /* if not found in cache, do some I/O */ if ((bp->b_flags & B_CACHE) == 0) { - if (curproc != PCPU_GET(idleproc)) - curproc->p_stats->p_ru.ru_inblock++; + if (curthread != PCPU_GET(idlethread)) + curthread->td_proc->p_stats->p_ru.ru_inblock++; bp->b_iocmd = BIO_READ; bp->b_flags &= ~B_INVAL; bp->b_ioflags &= ~BIO_ERROR; @@ -615,8 +615,8 @@ breadn(struct vnode * vp, daddr_t blkno, int size, rabp = getblk(vp, *rablkno, *rabsize, 0, 0); if ((rabp->b_flags & B_CACHE) == 0) { - if (curproc != PCPU_GET(idleproc)) - curproc->p_stats->p_ru.ru_inblock++; + if (curthread != PCPU_GET(idlethread)) + curthread->td_proc->p_stats->p_ru.ru_inblock++; rabp->b_flags |= B_ASYNC; rabp->b_flags &= ~B_INVAL; rabp->b_ioflags &= ~BIO_ERROR; @@ -753,8 +753,8 @@ bwrite(struct buf * bp) bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; - if (curproc != PCPU_GET(idleproc)) - curproc->p_stats->p_ru.ru_oublock++; + if (curthread != PCPU_GET(idlethread)) + curthread->td_proc->p_stats->p_ru.ru_oublock++; splx(s); if (oldflags & B_ASYNC) BUF_KERNPROC(bp); @@ -2183,7 +2183,7 @@ loop: * XXX remove if 0 sections (clean this up after its proven) */ if (numfreebuffers == 0) { - if (curproc == PCPU_GET(idleproc)) + if (curthread == PCPU_GET(idlethread)) return NULL; needsbuffer |= VFS_BIO_NEED_ANY; } diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index af3035a..9483b9b 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -575,7 +575,7 @@ vfs_cache_lookup(ap) struct componentname *cnp = ap->a_cnp; struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; u_long vpid; /* capability number of vnode */ *vpp = NULL; @@ -589,7 +589,7 @@ vfs_cache_lookup(ap) (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) return (EROFS); - error = VOP_ACCESS(dvp, VEXEC, cred, p); + error = VOP_ACCESS(dvp, VEXEC, cred, td); if (error) return (error); @@ -609,17 +609,17 @@ vfs_cache_lookup(ap) VREF(vp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; - error = vget(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (!error && lockparent && (flags & ISLASTCN)) { - if ((error = vn_lock(dvp, LK_EXCLUSIVE, p)) == 0) + if ((error = vn_lock(dvp, LK_EXCLUSIVE, td)) == 0) cnp->cn_flags &= ~PDIRUNLOCK; } } else { - error = vget(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (!lockparent || error || !(flags & ISLASTCN)) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } @@ -632,12 +632,12 @@ vfs_cache_lookup(ap) return (0); vput(vp); if (lockparent && dvp != vp && (flags & ISLASTCN)) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } if (cnp->cn_flags & PDIRUNLOCK) { - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error) return (error); cnp->cn_flags &= ~PDIRUNLOCK; @@ -663,8 +663,8 @@ static u_long numcwdfail3; STATNODE(CTLFLAG_RD, numcwdfail3, &numcwdfail3); static u_long numcwdfail4; STATNODE(CTLFLAG_RD, numcwdfail4, &numcwdfail4); static u_long numcwdfound; STATNODE(CTLFLAG_RD, numcwdfound, &numcwdfound); int -__getcwd(p, uap) - struct proc *p; +__getcwd(td, uap) + struct thread *td; struct __getcwd_args *uap; { char *bp, *buf; @@ -683,7 +683,7 @@ __getcwd(p, uap) buf = bp = malloc(uap->buflen, M_TEMP, M_WAITOK); bp += uap->buflen - 1; *bp = '\0'; - fdp = p->p_fd; + fdp = td->td_proc->p_fd; slash_prefixed = 0; for (vp = fdp->fd_cdir; vp != fdp->fd_rdir && vp != rootvnode;) { if (vp->v_flag & VROOT) { diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index e651ef0..98c3f13 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -227,7 +227,7 @@ vfs_mountroot_try(char *mountfrom) */ strncpy(mp->mnt_stat.f_mntonname, "/", MNAMELEN); - error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); + error = VFS_MOUNT(mp, NULL, NULL, NULL, curthread); done: if (vfsname != NULL) @@ -236,7 +236,7 @@ done: free(path, M_MOUNT); if (error != 0) { if (mp != NULL) { - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, curthread); free(mp, M_MOUNT); } printf("Root mount failed: %d\n", error); @@ -249,7 +249,7 @@ done: /* sanity check system clock against root filesystem timestamp */ inittodr(mp->mnt_time); - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, curthread); } return(error); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 1a1f55b..c5d1f02 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -243,16 +243,16 @@ vop_stdlock(ap) struct vop_lock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; #ifndef DEBUG_LOCKS - return (lockmgr(&vp->v_lock, ap->a_flags, &vp->v_interlock, ap->a_p)); + return (lockmgr(&vp->v_lock, ap->a_flags, &vp->v_interlock, ap->a_td)); #else return (debuglockmgr(&vp->v_lock, ap->a_flags, &vp->v_interlock, - ap->a_p, "vop_stdlock", vp->filename, vp->line)); + ap->a_td, "vop_stdlock", vp->filename, vp->line)); #endif } @@ -261,35 +261,35 @@ vop_stdunlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; return (lockmgr(&vp->v_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, - ap->a_p)); + ap->a_td)); } int vop_stdislocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { - return (lockstatus(&ap->a_vp->v_lock, ap->a_p)); + return (lockstatus(&ap->a_vp->v_lock, ap->a_td)); } int vop_stdinactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); return (0); } @@ -302,7 +302,7 @@ vop_nopoll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { /* @@ -327,11 +327,11 @@ vop_stdpoll(ap) struct vnode *a_vp; int a_events; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { if (ap->a_events & ~POLLSTANDARD) - return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events)); + return (vn_pollrecord(ap->a_vp, ap->a_td, ap->a_events)); return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); } @@ -346,7 +346,7 @@ vop_sharedlock(ap) struct vop_lock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { /* @@ -393,9 +393,9 @@ vop_sharedlock(ap) if (flags & LK_INTERLOCK) vnflags |= LK_INTERLOCK; #ifndef DEBUG_LOCKS - return (lockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_p)); + return (lockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_td)); #else - return (debuglockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_p, + return (debuglockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_td, "vop_sharedlock", vp->filename, vp->line)); #endif } @@ -411,7 +411,7 @@ vop_nolock(ap) struct vop_lock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { #ifdef notyet @@ -450,7 +450,7 @@ vop_nolock(ap) } if (flags & LK_INTERLOCK) vnflags |= LK_INTERLOCK; - return(lockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_p)); + return(lockmgr(&vp->v_lock, vnflags, &vp->v_interlock, ap->a_td)); #else /* for now */ /* * Since we are not using the lock manager, we must clear @@ -470,7 +470,7 @@ vop_nounlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -490,7 +490,7 @@ int vop_noislocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -517,12 +517,12 @@ vop_stdcreatevobject(ap) struct vop_createvobject_args /* { struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { struct vnode *vp = ap->a_vp; struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vattr vat; vm_object_t object; int error = 0; @@ -535,7 +535,7 @@ vop_stdcreatevobject(ap) retry: if ((object = vp->v_object) == NULL) { if (vp->v_type == VREG || vp->v_type == VDIR) { - if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vat, cred, td)) != 0) goto retn; object = vnode_pager_alloc(vp, vat.va_size, 0, 0); } else if (devsw(vp->v_rdev) != NULL) { @@ -556,9 +556,9 @@ retry: vp->v_usecount--; } else { if (object->flags & OBJ_DEAD) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); tsleep(object, PVM, "vodead", 0); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); goto retry; } } @@ -677,21 +677,21 @@ vop_stdputpages(ap) * used to fill the vfs fucntion table to get reasonable default return values. */ int -vfs_stdmount (mp, path, data, ndp, p) +vfs_stdmount (mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { return (0); } int -vfs_stdunmount (mp, mntflags, p) +vfs_stdunmount (mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { return (0); } @@ -705,10 +705,10 @@ vfs_stdroot (mp, vpp) } int -vfs_stdstatfs (mp, sbp, p) +vfs_stdstatfs (mp, sbp, td) struct mount *mp; struct statfs *sbp; - struct proc *p; + struct thread *td; { return (EOPNOTSUPP); } @@ -722,31 +722,31 @@ vfs_stdvptofh (vp, fhp) } int -vfs_stdstart (mp, flags, p) +vfs_stdstart (mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { return (0); } int -vfs_stdquotactl (mp, cmds, uid, arg, p) +vfs_stdquotactl (mp, cmds, uid, arg, td) struct mount *mp; int cmds; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { return (EOPNOTSUPP); } int -vfs_stdsync (mp, waitfor, cred, p) +vfs_stdsync (mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { return (0); } @@ -784,13 +784,13 @@ vfs_stduninit (vfsp) } int -vfs_stdextattrctl(mp, cmd, filename_vp, attrnamespace, attrname, p) +vfs_stdextattrctl(mp, cmd, filename_vp, attrnamespace, attrname, td) struct mount *mp; int cmd; struct vnode *filename_vp; int attrnamespace; const char *attrname; - struct proc *p; + struct thread *td; { return(EOPNOTSUPP); } diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index bb39292..4e05b8d 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -75,18 +75,18 @@ #include <vm/vm_zone.h> #include <vm/vm_page.h> -static int change_dir __P((struct nameidata *ndp, struct proc *p)); +static int change_dir __P((struct nameidata *ndp, struct thread *td)); static void checkdirs __P((struct vnode *olddp, struct vnode *newdp)); static int chroot_refuse_vdir_fds __P((struct filedesc *fdp)); static int getutimes __P((const struct timeval *, struct timespec *)); -static int setfown __P((struct proc *, struct vnode *, uid_t, gid_t)); -static int setfmode __P((struct proc *, struct vnode *, int)); -static int setfflags __P((struct proc *, struct vnode *, int)); -static int setutimes __P((struct proc *, struct vnode *, +static int setfown __P((struct thread *td, struct vnode *, uid_t, gid_t)); +static int setfmode __P((struct thread *td, struct vnode *, int)); +static int setfflags __P((struct thread *td, struct vnode *, int)); +static int setutimes __P((struct thread *td, struct vnode *, const struct timespec *, int)); static int usermount = 0; /* if 1, non-root can mount fs. */ -int (*union_dircheckp) __P((struct proc *, struct vnode **, struct file *)); +int (*union_dircheckp) __P((struct thread *td, struct vnode **, struct file *)); SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -107,8 +107,8 @@ struct mount_args { #endif /* ARGSUSED */ int -mount(p, uap) - struct proc *p; +mount(td, uap) + struct thread *td; struct mount_args /* { syscallarg(char *) type; syscallarg(char *) path; @@ -133,7 +133,7 @@ mount(p, uap) error = copyinstr(SCARG(uap, path), fspath, MNAMELEN, NULL); if (error) goto finish; - error = vfs_mount(p, fstype, fspath, SCARG(uap, flags), + error = vfs_mount(td, fstype, fspath, SCARG(uap, flags), SCARG(uap, data)); finish: free(fstype, M_TEMP); @@ -150,8 +150,8 @@ finish: * into userspace. */ int -vfs_mount(p, fstype, fspath, fsflags, fsdata) - struct proc *p; +vfs_mount(td, fstype, fspath, fsflags, fsdata) + struct thread *td; const char *fstype; char *fspath; int fsflags; @@ -163,6 +163,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) int error, flag = 0, flag2 = 0; struct vattr va; struct nameidata nd; + struct proc *p = td->td_proc; /* * Be ultra-paranoid about making sure the type and fspath @@ -173,13 +174,13 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) (strlen(fspath) >= MNAMELEN - 1)) return (ENAMETOOLONG); - if (usermount == 0 && (error = suser(p))) + if (usermount == 0 && (error = suser_td(td))) return (error); /* * Do not allow NFS export by non-root users. */ if (fsflags & MNT_EXPORTED) { - error = suser(p); + error = suser_td(td); if (error) return (error); } @@ -191,7 +192,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) /* * Get vnode to be covered */ - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspath, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspath, td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -218,11 +219,11 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) * permitted to update it. */ if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid && - (error = suser(p))) { + (error = suser_td(td))) { vput(vp); return (error); } - if (vfs_busy(mp, LK_NOWAIT, 0, p)) { + if (vfs_busy(mp, LK_NOWAIT, 0, td)) { vput(vp); return (EBUSY); } @@ -230,7 +231,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) if ((vp->v_flag & VMOUNT) != 0 || vp->v_mountedhere != NULL) { mtx_unlock(&vp->v_interlock); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); vput(vp); return (EBUSY); } @@ -238,20 +239,20 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) mtx_unlock(&vp->v_interlock); mp->mnt_flag |= fsflags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_SNAPSHOT); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); goto update; } /* * If the user is not root, ensure that they own the directory * onto which we are attempting to mount. */ - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) || + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, td)) || (va.va_uid != p->p_ucred->cr_uid && - (error = suser(p)))) { + (error = suser_td(td)))) { vput(vp); return (error); } - if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) { + if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, td, 0, 0)) != 0) { vput(vp); return (error); } @@ -266,7 +267,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) linker_file_t lf; /* Only load modules for root (very important!) */ - if ((error = suser(p)) != 0) { + if ((error = suser_td(td)) != 0) { vput(vp); return error; } @@ -304,7 +305,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) */ mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); - (void)vfs_busy(mp, LK_NOWAIT, 0, p); + (void)vfs_busy(mp, LK_NOWAIT, 0, td); mp->mnt_op = vfsp->vfc_vfsops; mp->mnt_vfc = vfsp; vfsp->vfc_refcount++; @@ -317,7 +318,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) strncpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN); mp->mnt_stat.f_mntonname[MNAMELEN - 1] = '\0'; mp->mnt_iosize_max = DFLTPHYS; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); update: /* * Set the mount level flags. @@ -339,7 +340,7 @@ update: * XXX The final recipients of VFS_MOUNT just overwrite the ndp they * get. No freeing of cn_pnbuf. */ - error = VFS_MOUNT(mp, fspath, fsdata, &nd, p); + error = VFS_MOUNT(mp, fspath, fsdata, &nd, td); if (mp->mnt_flag & MNT_UPDATE) { if (mp->mnt_kern_flag & MNTK_WANTRDWR) mp->mnt_flag &= ~MNT_RDONLY; @@ -358,14 +359,14 @@ update: vrele(mp->mnt_syncer); mp->mnt_syncer = NULL; } - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); mtx_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; mtx_unlock(&vp->v_interlock); vrele(vp); return (error); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* * Put the new filesystem on the mount list after root. */ @@ -384,18 +385,18 @@ update: panic("mount: lost mount"); checkdirs(vp, newdp); vput(newdp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((mp->mnt_flag & MNT_RDONLY) == 0) error = vfs_allocate_syncvnode(mp); - vfs_unbusy(mp, p); - if ((error = VFS_START(mp, 0, p)) != 0) + vfs_unbusy(mp, td); + if ((error = VFS_START(mp, 0, td)) != 0) vrele(vp); } else { mtx_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; mtx_unlock(&vp->v_interlock); mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); free((caddr_t)mp, M_MOUNT); vput(vp); } @@ -454,8 +455,8 @@ struct unmount_args { #endif /* ARGSUSED */ int -unmount(p, uap) - struct proc *p; +unmount(td, uap) + struct thread *td; register struct unmount_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -467,7 +468,7 @@ unmount(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -478,8 +479,8 @@ unmount(p, uap) * Only root, or the user that did the original mount is * permitted to unmount this filesystem. */ - if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) && - (error = suser(p))) { + if ((mp->mnt_stat.f_owner != td->td_proc->p_ucred->cr_uid) && + (error = suser_td(td))) { vput(vp); return (error); } @@ -500,17 +501,17 @@ unmount(p, uap) return (EINVAL); } vput(vp); - return (dounmount(mp, SCARG(uap, flags), p)); + return (dounmount(mp, SCARG(uap, flags), td)); } /* * Do the actual file system unmount. */ int -dounmount(mp, flags, p) +dounmount(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { struct vnode *coveredvp, *fsrootvp; int error; @@ -518,7 +519,7 @@ dounmount(mp, flags, p) mtx_lock(&mountlist_mtx); mp->mnt_kern_flag |= MNTK_UNMOUNT; - lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_mtx, p); + lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_mtx, td); vn_start_write(NULL, &mp, V_WAIT); if (mp->mnt_flag & MNT_EXPUBLIC) @@ -541,9 +542,9 @@ dounmount(mp, flags, p) vput(fsrootvp); } if (((mp->mnt_flag & MNT_RDONLY) || - (error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0) || + (error = VFS_SYNC(mp, MNT_WAIT, td->td_proc->p_ucred, td)) == 0) || (flags & MNT_FORCE)) { - error = VFS_UNMOUNT(mp, flags, p); + error = VFS_UNMOUNT(mp, flags, td); } vn_finished_write(mp); if (error) { @@ -563,7 +564,7 @@ dounmount(mp, flags, p) mp->mnt_kern_flag &= ~MNTK_UNMOUNT; mp->mnt_flag |= async_flag; lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, - &mountlist_mtx, p); + &mountlist_mtx, td); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup((caddr_t)mp); return (error); @@ -575,7 +576,7 @@ dounmount(mp, flags, p) mp->mnt_vfc->vfc_refcount--; if (!LIST_EMPTY(&mp->mnt_vnodelist)) panic("unmount: dangling vnode"); - lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_mtx, p); + lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_mtx, td); lockdestroy(&mp->mnt_lock); if (coveredvp != NULL) vrele(coveredvp); @@ -601,8 +602,8 @@ SYSCTL_INT(_debug, OID_AUTO, syncprt, CTLFLAG_RW, &syncprt, 0, ""); /* ARGSUSED */ int -sync(p, uap) - struct proc *p; +sync(td, uap) + struct thread *td; struct sync_args *uap; { struct mount *mp, *nmp; @@ -610,7 +611,7 @@ sync(p, uap) mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -620,13 +621,13 @@ sync(p, uap) mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); VFS_SYNC(mp, MNT_NOWAIT, - ((p != NULL) ? p->p_ucred : NOCRED), p); + ((td != NULL) ? td->td_proc->p_ucred : NOCRED), td); mp->mnt_flag |= asyncflag; vn_finished_write(mp); } mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); #if 0 @@ -661,8 +662,8 @@ struct quotactl_args { #endif /* ARGSUSED */ int -quotactl(p, uap) - struct proc *p; +quotactl(td, uap) + struct thread *td; register struct quotactl_args /* { syscallarg(char *) path; syscallarg(int) cmd; @@ -674,9 +675,9 @@ quotactl(p, uap) int error; struct nameidata nd; - if (jailed(p->p_ucred) && !prison_quotas) + if (jailed(td->td_proc->p_ucred) && !prison_quotas) return (EPERM); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -685,7 +686,7 @@ quotactl(p, uap) if (error) return (error); error = VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid), - SCARG(uap, arg), p); + SCARG(uap, arg), td); vn_finished_write(mp); return (error); } @@ -701,8 +702,8 @@ struct statfs_args { #endif /* ARGSUSED */ int -statfs(p, uap) - struct proc *p; +statfs(td, uap) + struct thread *td; register struct statfs_args /* { syscallarg(char *) path; syscallarg(struct statfs *) buf; @@ -714,18 +715,18 @@ statfs(p, uap) struct nameidata nd; struct statfs sb; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); mp = nd.ni_vp->v_mount; sp = &mp->mnt_stat; NDFREE(&nd, NDF_ONLY_PNBUF); vrele(nd.ni_vp); - error = VFS_STATFS(mp, sp, p); + error = VFS_STATFS(mp, sp, td); if (error) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -744,8 +745,8 @@ struct fstatfs_args { #endif /* ARGSUSED */ int -fstatfs(p, uap) - struct proc *p; +fstatfs(td, uap) + struct thread *td; register struct fstatfs_args /* { syscallarg(int) fd; syscallarg(struct statfs *) buf; @@ -757,15 +758,15 @@ fstatfs(p, uap) int error; struct statfs sb; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; - error = VFS_STATFS(mp, sp, p); + error = VFS_STATFS(mp, sp, td); if (error) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -784,8 +785,8 @@ struct getfsstat_args { }; #endif int -getfsstat(p, uap) - struct proc *p; +getfsstat(td, uap) + struct thread *td; register struct getfsstat_args /* { syscallarg(struct statfs *) buf; syscallarg(long) bufsize; @@ -802,7 +803,7 @@ getfsstat(p, uap) count = 0; mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -815,16 +816,16 @@ getfsstat(p, uap) */ if (((SCARG(uap, flags) & (MNT_LAZY|MNT_NOWAIT)) == 0 || (SCARG(uap, flags) & MNT_WAIT)) && - (error = VFS_STATFS(mp, sp, p))) { + (error = VFS_STATFS(mp, sp, td))) { mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); continue; } sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; error = copyout((caddr_t)sp, sfsp, sizeof(*sp)); if (error) { - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (error); } sfsp += sizeof(*sp); @@ -832,13 +833,13 @@ getfsstat(p, uap) count++; mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); if (sfsp && count > maxcount) - p->p_retval[0] = maxcount; + td->td_retval[0] = maxcount; else - p->p_retval[0] = count; + td->td_retval[0] = count; return (0); } @@ -852,13 +853,13 @@ struct fchdir_args { #endif /* ARGSUSED */ int -fchdir(p, uap) - struct proc *p; +fchdir(td, uap) + struct thread *td; struct fchdir_args /* { syscallarg(int) fd; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; struct vnode *vp, *tdp; struct mount *mp; struct file *fp; @@ -868,16 +869,16 @@ fchdir(p, uap) return (error); vp = (struct vnode *)fp->f_data; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); while (!error && (mp = vp->v_mountedhere) != NULL) { - if (vfs_busy(mp, 0, 0, p)) + if (vfs_busy(mp, 0, 0, td)) continue; error = VFS_ROOT(mp, &tdp); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); if (error) break; vput(vp); @@ -887,7 +888,7 @@ fchdir(p, uap) vput(vp); return (error); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(fdp->fd_cdir); fdp->fd_cdir = vp; return (0); @@ -903,19 +904,19 @@ struct chdir_args { #endif /* ARGSUSED */ int -chdir(p, uap) - struct proc *p; +chdir(td, uap) + struct thread *td; struct chdir_args /* { syscallarg(char *) path; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = change_dir(&nd, p)) != 0) + SCARG(uap, path), td); + if ((error = change_dir(&nd, td)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(fdp->fd_cdir); @@ -971,17 +972,17 @@ struct chroot_args { #endif /* ARGSUSED */ int -chroot(p, uap) - struct proc *p; +chroot(td, uap) + struct thread *td; struct chroot_args /* { syscallarg(char *) path; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int error; struct nameidata nd; - error = suser_xxx(0, p, PRISON_ROOT); + error = suser_xxx(0, td->td_proc, PRISON_ROOT); if (error) return (error); if (chroot_allow_open_directories == 0 || @@ -990,8 +991,8 @@ chroot(p, uap) if (error) return (error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = change_dir(&nd, p)) != 0) + SCARG(uap, path), td); + if ((error = change_dir(&nd, td)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(fdp->fd_rdir); @@ -1007,9 +1008,9 @@ chroot(p, uap) * Common routine for chroot and chdir. */ static int -change_dir(ndp, p) +change_dir(ndp, td) register struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *vp; int error; @@ -1021,11 +1022,11 @@ change_dir(ndp, p) if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); if (error) vput(vp); else - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -1041,14 +1042,15 @@ struct open_args { }; #endif int -open(p, uap) - struct proc *p; +open(td, uap) + struct thread *td; register struct open_args /* { syscallarg(char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap; { + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; @@ -1064,13 +1066,13 @@ open(p, uap) if ((oflags & O_ACCMODE) == O_ACCMODE) return (EINVAL); flags = FFLAGS(oflags); - error = falloc(p, &nfp, &indx); + error = falloc(td, &nfp, &indx); if (error) return (error); fp = nfp; cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); - p->p_dupfd = -indx - 1; /* XXX check for fdopen */ + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); + td->td_dupfd = -indx - 1; /* XXX check for fdopen */ /* * Bump the ref count to prevent another process from closing * the descriptor while we are blocked in vn_open() @@ -1081,7 +1083,7 @@ open(p, uap) /* * release our own reference */ - fdrop(fp, p); + fdrop(fp, td); /* * handle special fdopen() case. bleh. dupfdopen() is @@ -1089,10 +1091,10 @@ open(p, uap) * if it succeeds. */ if ((error == ENODEV || error == ENXIO) && - p->p_dupfd >= 0 && /* XXX from fdopen */ + td->td_dupfd >= 0 && /* XXX from fdopen */ (error = - dupfdopen(p, fdp, indx, p->p_dupfd, flags, error)) == 0) { - p->p_retval[0] = indx; + dupfdopen(td, fdp, indx, td->td_dupfd, flags, error)) == 0) { + td->td_retval[0] = indx; return (0); } /* @@ -1101,14 +1103,14 @@ open(p, uap) */ if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } if (error == ERESTART) error = EINTR; return (error); } - p->p_dupfd = 0; + td->td_dupfd = 0; NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; @@ -1123,10 +1125,10 @@ open(p, uap) if (fp->f_count == 1) { KASSERT(fdp->fd_ofiles[indx] != fp, ("Open file descriptor lost all refs")); - VOP_UNLOCK(vp, 0, p); - vn_close(vp, flags & FMASK, fp->f_cred, p); - fdrop(fp, p); - p->p_retval[0] = indx; + VOP_UNLOCK(vp, 0, td); + vn_close(vp, flags & FMASK, fp->f_cred, td); + fdrop(fp, td); + td->td_retval[0] = indx; return 0; } @@ -1134,7 +1136,7 @@ open(p, uap) fp->f_flag = flags & FMASK; fp->f_ops = &vnops; fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (flags & (O_EXLOCK | O_SHLOCK)) { lf.l_whence = SEEK_SET; lf.l_start = 0; @@ -1153,12 +1155,12 @@ open(p, uap) if (flags & O_TRUNC) { if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto bad; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); VATTR_NULL(&vat); vat.va_size = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETATTR(vp, &vat, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETATTR(vp, &vat, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); if (error) goto bad; @@ -1170,15 +1172,15 @@ open(p, uap) * Release our private reference, leaving the one associated with * the descriptor table intact. */ - fdrop(fp, p); - p->p_retval[0] = indx; + fdrop(fp, td); + td->td_retval[0] = indx; return (0); bad: if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -1193,8 +1195,8 @@ struct ocreat_args { }; #endif int -ocreat(p, uap) - struct proc *p; +ocreat(td, uap) + struct thread *td; register struct ocreat_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1209,7 +1211,7 @@ ocreat(p, uap) SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, mode) = SCARG(uap, mode); SCARG(&nuap, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return (open(p, &nuap)); + return (open(td, &nuap)); } #endif /* COMPAT_43 */ @@ -1225,8 +1227,8 @@ struct mknod_args { #endif /* ARGSUSED */ int -mknod(p, uap) - struct proc *p; +mknod(td, uap) + struct thread *td; register struct mknod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1243,17 +1245,17 @@ mknod(p, uap) switch (SCARG(uap, mode) & S_IFMT) { case S_IFCHR: case S_IFBLK: - error = suser(p); + error = suser_td(td); break; default: - error = suser_xxx(0, p, PRISON_ROOT); + error = suser_xxx(0, td->td_proc, PRISON_ROOT); break; } if (error) return (error); restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -1262,7 +1264,7 @@ restart: error = EEXIST; } else { VATTR_NULL(&vattr); - vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; + vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ td->td_proc->p_fd->fd_cmask; vattr.va_rdev = SCARG(uap, dev); whiteout = 0; @@ -1292,7 +1294,7 @@ restart: goto restart; } if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); if (whiteout) error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, CREATE); else { @@ -1321,8 +1323,8 @@ struct mkfifo_args { #endif /* ARGSUSED */ int -mkfifo(p, uap) - struct proc *p; +mkfifo(td, uap) + struct thread *td; register struct mkfifo_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1335,7 +1337,7 @@ mkfifo(p, uap) restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); if (nd.ni_vp != NULL) { @@ -1353,8 +1355,8 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VFIFO; - vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); if (error == 0) vput(nd.ni_vp); @@ -1375,8 +1377,8 @@ struct link_args { #endif /* ARGSUSED */ int -link(p, uap) - struct proc *p; +link(td, uap) + struct thread *td; register struct link_args /* { syscallarg(char *) path; syscallarg(char *) link; @@ -1388,7 +1390,7 @@ link(p, uap) int error; bwillwrite(); - NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1401,14 +1403,14 @@ link(p, uap) vrele(vp); return (error); } - NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); + NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td); if ((error = namei(&nd)) == 0) { if (nd.ni_vp != NULL) { vrele(nd.ni_vp); error = EEXIST; } else { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1432,8 +1434,8 @@ struct symlink_args { #endif /* ARGSUSED */ int -symlink(p, uap) - struct proc *p; +symlink(td, uap) + struct thread *td; register struct symlink_args /* { syscallarg(char *) path; syscallarg(char *) link; @@ -1450,7 +1452,7 @@ symlink(p, uap) goto out; restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); + NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td); if ((error = namei(&nd)) != 0) goto out; if (nd.ni_vp) { @@ -1468,8 +1470,8 @@ restart: goto restart; } VATTR_NULL(&vattr); - vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path); NDFREE(&nd, NDF_ONLY_PNBUF); if (error == 0) @@ -1488,8 +1490,8 @@ out: */ /* ARGSUSED */ int -undelete(p, uap) - struct proc *p; +undelete(td, uap) + struct thread *td; register struct undelete_args /* { syscallarg(char *) path; } */ *uap; @@ -1501,7 +1503,7 @@ undelete(p, uap) restart: bwillwrite(); NDINIT(&nd, DELETE, LOCKPARENT|DOWHITEOUT, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); error = namei(&nd); if (error) return (error); @@ -1520,7 +1522,7 @@ restart: return (error); goto restart; } - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -1540,8 +1542,8 @@ struct unlink_args { #endif /* ARGSUSED */ int -unlink(p, uap) - struct proc *p; +unlink(td, uap) + struct thread *td; struct unlink_args /* { syscallarg(char *) path; } */ *uap; @@ -1553,7 +1555,7 @@ unlink(p, uap) restart: bwillwrite(); - NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -1576,10 +1578,10 @@ restart: return (error); goto restart; } - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1603,8 +1605,8 @@ struct lseek_args { }; #endif int -lseek(p, uap) - struct proc *p; +lseek(td, uap) + struct thread *td; register struct lseek_args /* { syscallarg(int) fd; syscallarg(int) pad; @@ -1612,8 +1614,8 @@ lseek(p, uap) syscallarg(int) whence; } */ *uap; { - struct ucred *cred = p->p_ucred; - register struct filedesc *fdp = p->p_fd; + struct ucred *cred = td->td_proc->p_ucred; + register struct filedesc *fdp = td->td_proc->p_fd; register struct file *fp; struct vattr vattr; struct vnode *vp; @@ -1637,7 +1639,7 @@ lseek(p, uap) offset += fp->f_offset; break; case L_XTND: - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); if (noneg && @@ -1654,7 +1656,7 @@ lseek(p, uap) if (noneg && offset < 0) return (EINVAL); fp->f_offset = offset; - *(off_t *)(p->p_retval) = fp->f_offset; + *(off_t *)(td->td_retval) = fp->f_offset; return (0); } @@ -1670,8 +1672,8 @@ struct olseek_args { }; #endif int -olseek(p, uap) - struct proc *p; +olseek(td, uap) + struct thread *td; register struct olseek_args /* { syscallarg(int) fd; syscallarg(long) offset; @@ -1689,7 +1691,7 @@ olseek(p, uap) SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, offset) = SCARG(uap, offset); SCARG(&nuap, whence) = SCARG(uap, whence); - error = lseek(p, &nuap); + error = lseek(td, &nuap); return (error); } #endif /* COMPAT_43 */ @@ -1704,8 +1706,8 @@ struct access_args { }; #endif int -access(p, uap) - struct proc *p; +access(td, uap) + struct thread *td; register struct access_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -1716,7 +1718,7 @@ access(p, uap) int error, flags; struct nameidata nd; - cred = p->p_ucred; + cred = td->td_proc->p_ucred; /* * Create and modify a temporary credential instead of one that * is potentially shared. This could also mess up socket @@ -1729,9 +1731,9 @@ access(p, uap) tmpcred = crdup(cred); tmpcred->cr_uid = cred->cr_ruid; tmpcred->cr_groups[0] = cred->cr_rgid; - p->p_ucred = tmpcred; + td->td_proc->p_ucred = tmpcred; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) goto out1; vp = nd.ni_vp; @@ -1746,12 +1748,12 @@ access(p, uap) if (SCARG(uap, flags) & X_OK) flags |= VEXEC; if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0) - error = VOP_ACCESS(vp, flags, tmpcred, p); + error = VOP_ACCESS(vp, flags, tmpcred, td); } NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); out1: - p->p_ucred = cred; + td->td_proc->p_ucred = cred; crfree(tmpcred); return (error); } @@ -1768,8 +1770,8 @@ struct ostat_args { #endif /* ARGSUSED */ int -ostat(p, uap) - struct proc *p; +ostat(td, uap) + struct thread *td; register struct ostat_args /* { syscallarg(char *) path; syscallarg(struct ostat *) ub; @@ -1781,11 +1783,11 @@ ostat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -1805,8 +1807,8 @@ struct olstat_args { #endif /* ARGSUSED */ int -olstat(p, uap) - struct proc *p; +olstat(td, uap) + struct thread *td; register struct olstat_args /* { syscallarg(char *) path; syscallarg(struct ostat *) ub; @@ -1819,11 +1821,11 @@ olstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); if (error) @@ -1874,8 +1876,8 @@ struct stat_args { #endif /* ARGSUSED */ int -stat(p, uap) - struct proc *p; +stat(td, uap) + struct thread *td; register struct stat_args /* { syscallarg(char *) path; syscallarg(struct stat *) ub; @@ -1886,10 +1888,10 @@ stat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_vp); if (error) @@ -1909,8 +1911,8 @@ struct lstat_args { #endif /* ARGSUSED */ int -lstat(p, uap) - struct proc *p; +lstat(td, uap) + struct thread *td; register struct lstat_args /* { syscallarg(char *) path; syscallarg(struct stat *) ub; @@ -1922,11 +1924,11 @@ lstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); if (error) @@ -1974,8 +1976,8 @@ struct nstat_args { #endif /* ARGSUSED */ int -nstat(p, uap) - struct proc *p; +nstat(td, uap) + struct thread *td; register struct nstat_args /* { syscallarg(char *) path; syscallarg(struct nstat *) ub; @@ -1987,11 +1989,11 @@ nstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -2011,8 +2013,8 @@ struct lstat_args { #endif /* ARGSUSED */ int -nlstat(p, uap) - struct proc *p; +nlstat(td, uap) + struct thread *td; register struct nlstat_args /* { syscallarg(char *) path; syscallarg(struct nstat *) ub; @@ -2025,12 +2027,12 @@ nlstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); vput(vp); if (error) return (error); @@ -2050,8 +2052,8 @@ struct pathconf_args { #endif /* ARGSUSED */ int -pathconf(p, uap) - struct proc *p; +pathconf(td, uap) + struct thread *td; register struct pathconf_args /* { syscallarg(char *) path; syscallarg(int) name; @@ -2061,11 +2063,11 @@ pathconf(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), p->p_retval); + error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), td->td_retval); vput(nd.ni_vp); return (error); } @@ -2082,8 +2084,8 @@ struct readlink_args { #endif /* ARGSUSED */ int -readlink(p, uap) - struct proc *p; +readlink(td, uap) + struct thread *td; register struct readlink_args /* { syscallarg(char *) path; syscallarg(char *) buf; @@ -2097,7 +2099,7 @@ readlink(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -2112,12 +2114,12 @@ readlink(p, uap) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - error = VOP_READLINK(vp, &auio, p->p_ucred); + error = VOP_READLINK(vp, &auio, td->td_proc->p_ucred); } vput(vp); - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } @@ -2125,8 +2127,8 @@ readlink(p, uap) * Common implementation code for chflags() and fchflags(). */ static int -setfflags(p, vp, flags) - struct proc *p; +setfflags(td, vp, flags) + struct thread *td; struct vnode *vp; int flags; { @@ -2141,17 +2143,17 @@ setfflags(p, vp, flags) * chown can't fail when done as root. */ if ((vp->v_type == VCHR || vp->v_type == VBLK) && - ((error = suser_xxx(p->p_ucred, p, PRISON_ROOT)) != 0)) + ((error = suser_xxx(td->td_proc->p_ucred, td->td_proc, PRISON_ROOT)) != 0)) return (error); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_flags = flags; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2167,8 +2169,8 @@ struct chflags_args { #endif /* ARGSUSED */ int -chflags(p, uap) - struct proc *p; +chflags(td, uap) + struct thread *td; register struct chflags_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -2177,11 +2179,11 @@ chflags(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfflags(p, nd.ni_vp, SCARG(uap, flags)); + error = setfflags(td, nd.ni_vp, SCARG(uap, flags)); vrele(nd.ni_vp); return error; } @@ -2197,8 +2199,8 @@ struct fchflags_args { #endif /* ARGSUSED */ int -fchflags(p, uap) - struct proc *p; +fchflags(td, uap) + struct thread *td; register struct fchflags_args /* { syscallarg(int) fd; syscallarg(int) flags; @@ -2207,17 +2209,17 @@ fchflags(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfflags(p, (struct vnode *) fp->f_data, SCARG(uap, flags)); + return setfflags(td, (struct vnode *) fp->f_data, SCARG(uap, flags)); } /* * Common implementation code for chmod(), lchmod() and fchmod(). */ static int -setfmode(p, vp, mode) - struct proc *p; +setfmode(td, vp, mode) + struct thread *td; struct vnode *vp; int mode; { @@ -2227,12 +2229,12 @@ setfmode(p, vp, mode) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_mode = mode & ALLPERMS; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2248,8 +2250,8 @@ struct chmod_args { #endif /* ARGSUSED */ int -chmod(p, uap) - struct proc *p; +chmod(td, uap) + struct thread *td; register struct chmod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -2258,11 +2260,11 @@ chmod(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); + error = setfmode(td, nd.ni_vp, SCARG(uap, mode)); vrele(nd.ni_vp); return error; } @@ -2278,8 +2280,8 @@ struct lchmod_args { #endif /* ARGSUSED */ int -lchmod(p, uap) - struct proc *p; +lchmod(td, uap) + struct thread *td; register struct lchmod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -2288,11 +2290,11 @@ lchmod(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); + error = setfmode(td, nd.ni_vp, SCARG(uap, mode)); vrele(nd.ni_vp); return error; } @@ -2308,8 +2310,8 @@ struct fchmod_args { #endif /* ARGSUSED */ int -fchmod(p, uap) - struct proc *p; +fchmod(td, uap) + struct thread *td; register struct fchmod_args /* { syscallarg(int) fd; syscallarg(int) mode; @@ -2318,17 +2320,17 @@ fchmod(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfmode(p, (struct vnode *)fp->f_data, SCARG(uap, mode)); + return setfmode(td, (struct vnode *)fp->f_data, SCARG(uap, mode)); } /* * Common implementation for chown(), lchown(), and fchown() */ static int -setfown(p, vp, uid, gid) - struct proc *p; +setfown(td, vp, uid, gid) + struct thread *td; struct vnode *vp; uid_t uid; gid_t gid; @@ -2339,13 +2341,13 @@ setfown(p, vp, uid, gid) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_uid = uid; vattr.va_gid = gid; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2362,8 +2364,8 @@ struct chown_args { #endif /* ARGSUSED */ int -chown(p, uap) - struct proc *p; +chown(td, uap) + struct thread *td; register struct chown_args /* { syscallarg(char *) path; syscallarg(int) uid; @@ -2373,11 +2375,11 @@ chown(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); + error = setfown(td, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); vrele(nd.ni_vp); return (error); } @@ -2394,8 +2396,8 @@ struct lchown_args { #endif /* ARGSUSED */ int -lchown(p, uap) - struct proc *p; +lchown(td, uap) + struct thread *td; register struct lchown_args /* { syscallarg(char *) path; syscallarg(int) uid; @@ -2405,11 +2407,11 @@ lchown(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); + error = setfown(td, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); vrele(nd.ni_vp); return (error); } @@ -2426,8 +2428,8 @@ struct fchown_args { #endif /* ARGSUSED */ int -fchown(p, uap) - struct proc *p; +fchown(td, uap) + struct thread *td; register struct fchown_args /* { syscallarg(int) fd; syscallarg(int) uid; @@ -2437,9 +2439,9 @@ fchown(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfown(p, (struct vnode *)fp->f_data, + return setfown(td, (struct vnode *)fp->f_data, SCARG(uap, uid), SCARG(uap, gid)); } @@ -2471,8 +2473,8 @@ getutimes(usrtvp, tsp) * Common implementation code for utimes(), lutimes(), and futimes(). */ static int -setutimes(p, vp, ts, nullflag) - struct proc *p; +setutimes(td, vp, ts, nullflag) + struct thread *td; struct vnode *vp; const struct timespec *ts; int nullflag; @@ -2483,15 +2485,15 @@ setutimes(p, vp, ts, nullflag) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_atime = ts[0]; vattr.va_mtime = ts[1]; if (nullflag) vattr.va_vaflags |= VA_UTIMES_NULL; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2507,8 +2509,8 @@ struct utimes_args { #endif /* ARGSUSED */ int -utimes(p, uap) - struct proc *p; +utimes(td, uap) + struct thread *td; register struct utimes_args /* { syscallarg(char *) path; syscallarg(struct timeval *) tptr; @@ -2522,11 +2524,11 @@ utimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL); + error = setutimes(td, nd.ni_vp, ts, usrtvp == NULL); vrele(nd.ni_vp); return (error); } @@ -2542,8 +2544,8 @@ struct lutimes_args { #endif /* ARGSUSED */ int -lutimes(p, uap) - struct proc *p; +lutimes(td, uap) + struct thread *td; register struct lutimes_args /* { syscallarg(char *) path; syscallarg(struct timeval *) tptr; @@ -2557,11 +2559,11 @@ lutimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL); + error = setutimes(td, nd.ni_vp, ts, usrtvp == NULL); vrele(nd.ni_vp); return (error); } @@ -2577,8 +2579,8 @@ struct futimes_args { #endif /* ARGSUSED */ int -futimes(p, uap) - struct proc *p; +futimes(td, uap) + struct thread *td; register struct futimes_args /* { syscallarg(int ) fd; syscallarg(struct timeval *) tptr; @@ -2592,9 +2594,9 @@ futimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setutimes(p, (struct vnode *)fp->f_data, ts, usrtvp == NULL); + return setutimes(td, (struct vnode *)fp->f_data, ts, usrtvp == NULL); } /* @@ -2609,8 +2611,8 @@ struct truncate_args { #endif /* ARGSUSED */ int -truncate(p, uap) - struct proc *p; +truncate(td, uap) + struct thread *td; register struct truncate_args /* { syscallarg(char *) path; syscallarg(int) pad; @@ -2625,7 +2627,7 @@ truncate(p, uap) if (uap->length < 0) return(EINVAL); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -2634,15 +2636,15 @@ truncate(p, uap) return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type == VDIR) error = EISDIR; else if ((error = vn_writechk(vp)) == 0 && - (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) { + (error = VOP_ACCESS(vp, VWRITE, td->td_proc->p_ucred, td)) == 0) { VATTR_NULL(&vattr); vattr.va_size = SCARG(uap, length); - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); } vput(vp); vn_finished_write(mp); @@ -2661,8 +2663,8 @@ struct ftruncate_args { #endif /* ARGSUSED */ int -ftruncate(p, uap) - struct proc *p; +ftruncate(td, uap) + struct thread *td; register struct ftruncate_args /* { syscallarg(int) fd; syscallarg(int) pad; @@ -2677,23 +2679,23 @@ ftruncate(p, uap) if (uap->length < 0) return(EINVAL); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FWRITE) == 0) return (EINVAL); vp = (struct vnode *)fp->f_data; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type == VDIR) error = EISDIR; else if ((error = vn_writechk(vp)) == 0) { VATTR_NULL(&vattr); vattr.va_size = SCARG(uap, length); - error = VOP_SETATTR(vp, &vattr, fp->f_cred, p); + error = VOP_SETATTR(vp, &vattr, fp->f_cred, td); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2710,8 +2712,8 @@ struct otruncate_args { #endif /* ARGSUSED */ int -otruncate(p, uap) - struct proc *p; +otruncate(td, uap) + struct thread *td; register struct otruncate_args /* { syscallarg(char *) path; syscallarg(long) length; @@ -2725,7 +2727,7 @@ otruncate(p, uap) SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, length) = SCARG(uap, length); - return (truncate(p, &nuap)); + return (truncate(td, &nuap)); } /* @@ -2739,8 +2741,8 @@ struct oftruncate_args { #endif /* ARGSUSED */ int -oftruncate(p, uap) - struct proc *p; +oftruncate(td, uap) + struct thread *td; register struct oftruncate_args /* { syscallarg(int) fd; syscallarg(long) length; @@ -2754,7 +2756,7 @@ oftruncate(p, uap) SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, length) = SCARG(uap, length); - return (ftruncate(p, &nuap)); + return (ftruncate(td, &nuap)); } #endif /* COMPAT_43 || COMPAT_SUNOS */ @@ -2768,8 +2770,8 @@ struct fsync_args { #endif /* ARGSUSED */ int -fsync(p, uap) - struct proc *p; +fsync(td, uap) + struct thread *td; struct fsync_args /* { syscallarg(int) fd; } */ *uap; @@ -2782,22 +2784,22 @@ fsync(p, uap) GIANT_REQUIRED; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, 0); } - error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p); + error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); #ifdef SOFTUPDATES if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP)) error = softdep_fsync(vp); #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2814,8 +2816,8 @@ struct rename_args { #endif /* ARGSUSED */ int -rename(p, uap) - struct proc *p; +rename(td, uap) + struct thread *td; register struct rename_args /* { syscallarg(char *) from; syscallarg(char *) to; @@ -2828,7 +2830,7 @@ rename(p, uap) bwillwrite(); NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE, - SCARG(uap, from), p); + SCARG(uap, from), td); if ((error = namei(&fromnd)) != 0) return (error); fvp = fromnd.ni_vp; @@ -2839,7 +2841,7 @@ rename(p, uap) goto out1; } NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | NOOBJ, - UIO_USERSPACE, SCARG(uap, to), p); + UIO_USERSPACE, SCARG(uap, to), td); if (fromnd.ni_vp->v_type == VDIR) tond.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&tond)) != 0) { @@ -2876,12 +2878,12 @@ rename(p, uap) error = -1; out: if (!error) { - VOP_LEASE(tdvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tdvp, td, td->td_proc->p_ucred, LEASE_WRITE); if (fromnd.ni_dvp != tdvp) { - VOP_LEASE(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(fromnd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); } if (tvp) { - VOP_LEASE(tvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tvp, td, td->td_proc->p_ucred, LEASE_WRITE); } error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); @@ -2924,13 +2926,24 @@ struct mkdir_args { #endif /* ARGSUSED */ int -mkdir(p, uap) - struct proc *p; +mkdir(td, uap) + struct thread *td; register struct mkdir_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap; { + + return vn_mkdir(uap->path, uap->mode, UIO_USERSPACE, td); +} + +int +vn_mkdir(path, mode, segflg, td) + char *path; + int mode; + enum uio_seg segflg; + struct thread *td; +{ struct mount *mp; struct vnode *vp; struct vattr vattr; @@ -2939,7 +2952,7 @@ mkdir(p, uap) restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, segflg, path, td); nd.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&nd)) != 0) return (error); @@ -2959,8 +2972,8 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VDIR; - vattr.va_mode = (SCARG(uap, mode) & ACCESSPERMS) &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -2982,8 +2995,8 @@ struct rmdir_args { #endif /* ARGSUSED */ int -rmdir(p, uap) - struct proc *p; +rmdir(td, uap) + struct thread *td; struct rmdir_args /* { syscallarg(char *) path; } */ *uap; @@ -2996,7 +3009,7 @@ rmdir(p, uap) restart: bwillwrite(); NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -3029,8 +3042,8 @@ restart: return (error); goto restart; } - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); vn_finished_write(mp); out: @@ -3058,8 +3071,8 @@ struct ogetdirentries_args { }; #endif int -ogetdirentries(p, uap) - struct proc *p; +ogetdirentries(td, uap) + struct thread *td; register struct ogetdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3079,7 +3092,7 @@ ogetdirentries(p, uap) /* XXX arbitrary sanity limit on `count'. */ if (SCARG(uap, count) > 64 * 1024) return (EINVAL); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) return (EBADF); @@ -3093,9 +3106,9 @@ unionread: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); loff = auio.uio_offset = fp->f_offset; # if (BYTE_ORDER != LITTLE_ENDIAN) if (vp->v_mount->mnt_maxsymlinklen <= 0) { @@ -3148,12 +3161,12 @@ unionread: } FREE(dirbuf, M_TEMP); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error) return (error); if (SCARG(uap, count) == auio.uio_resid) { if (union_dircheckp) { - error = union_dircheckp(p, &vp, fp); + error = union_dircheckp(td, &vp, fp); if (error == -1) goto unionread; if (error) @@ -3172,7 +3185,7 @@ unionread: } error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep), sizeof(long)); - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } #endif /* COMPAT_43 */ @@ -3189,8 +3202,8 @@ struct getdirentries_args { }; #endif int -getdirentries(p, uap) - struct proc *p; +getdirentries(td, uap) + struct thread *td; register struct getdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3205,7 +3218,7 @@ getdirentries(p, uap) long loff; int error, eofflag; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) return (EBADF); @@ -3219,19 +3232,19 @@ unionread: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - /* vn_lock(vp, LK_SHARED | LK_RETRY, p); */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + /* vn_lock(vp, LK_SHARED | LK_RETRY, td); */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); loff = auio.uio_offset = fp->f_offset; error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL); fp->f_offset = auio.uio_offset; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error) return (error); if (SCARG(uap, count) == auio.uio_resid) { if (union_dircheckp) { - error = union_dircheckp(p, &vp, fp); + error = union_dircheckp(td, &vp, fp); if (error == -1) goto unionread; if (error) @@ -3252,7 +3265,7 @@ unionread: error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep), sizeof(long)); } - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -3263,8 +3276,8 @@ struct getdents_args { }; #endif int -getdents(p, uap) - struct proc *p; +getdents(td, uap) + struct thread *td; register struct getdents_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3276,7 +3289,7 @@ getdents(p, uap) ap.buf = uap->buf; ap.count = uap->count; ap.basep = NULL; - return getdirentries(p, &ap); + return getdirentries(td, &ap); } /* @@ -3290,16 +3303,16 @@ struct umask_args { }; #endif int -umask(p, uap) - struct proc *p; +umask(td, uap) + struct thread *td; struct umask_args /* { syscallarg(int) newmask; } */ *uap; { register struct filedesc *fdp; - fdp = p->p_fd; - p->p_retval[0] = fdp->fd_cmask; + fdp = td->td_proc->p_fd; + td->td_retval[0] = fdp->fd_cmask; fdp->fd_cmask = SCARG(uap, newmask) & ALLPERMS; return (0); } @@ -3315,8 +3328,8 @@ struct revoke_args { #endif /* ARGSUSED */ int -revoke(p, uap) - struct proc *p; +revoke(td, uap) + struct thread *td; register struct revoke_args /* { syscallarg(char *) path; } */ *uap; @@ -3327,7 +3340,7 @@ revoke(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -3336,10 +3349,10 @@ revoke(p, uap) error = EINVAL; goto out; } - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) goto out; - if (p->p_ucred->cr_uid != vattr.va_uid && - (error = suser_xxx(0, p, PRISON_ROOT))) + if (td->td_proc->p_ucred->cr_uid != vattr.va_uid && + (error = suser_xxx(0, td->td_proc, PRISON_ROOT))) goto out; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto out; @@ -3380,8 +3393,8 @@ struct getfh_args { }; #endif int -getfh(p, uap) - struct proc *p; +getfh(td, uap) + struct thread *td; register struct getfh_args *uap; { struct nameidata nd; @@ -3392,10 +3405,10 @@ getfh(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td); error = namei(&nd); if (error) return (error); @@ -3425,13 +3438,14 @@ struct fhopen_args { }; #endif int -fhopen(p, uap) - struct proc *p; +fhopen(td, uap) + struct thread *td; struct fhopen_args /* { syscallarg(const struct fhandle *) u_fhp; syscallarg(int) flags; } */ *uap; { + struct proc *p = td->td_proc; struct mount *mp; struct vnode *vp; struct fhandle fhp; @@ -3447,7 +3461,7 @@ fhopen(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); @@ -3498,33 +3512,33 @@ fhopen(p, uap) if (fmode & FREAD) mode |= VREAD; if (mode) { - error = VOP_ACCESS(vp, mode, p->p_ucred, p); + error = VOP_ACCESS(vp, mode, p->p_ucred, td); if (error) goto bad; } if (fmode & O_TRUNC) { - VOP_UNLOCK(vp, 0, p); /* XXX */ + VOP_UNLOCK(vp, 0, td); /* XXX */ if ((error = vn_start_write(NULL, &mp, V_WAIT | PCATCH)) != 0) { vrele(vp); return (error); } - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* XXX */ + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* XXX */ VATTR_NULL(vap); vap->va_size = 0; - error = VOP_SETATTR(vp, vap, p->p_ucred, p); + error = VOP_SETATTR(vp, vap, p->p_ucred, td); vn_finished_write(mp); if (error) goto bad; } - error = VOP_OPEN(vp, fmode, p->p_ucred, p); + error = VOP_OPEN(vp, fmode, p->p_ucred, td); if (error) goto bad; /* * Make sure that a VM object is created for VMIO support. */ if (vn_canvmio(vp) == TRUE) { - if ((error = vfs_object_create(vp, p, p->p_ucred)) != 0) + if ((error = vfs_object_create(vp, td, p->p_ucred)) != 0) goto bad; } if (fmode & FWRITE) @@ -3534,7 +3548,7 @@ fhopen(p, uap) * end of vn_open code */ - if ((error = falloc(p, &nfp, &indx)) != 0) + if ((error = falloc(td, &nfp, &indx)) != 0) goto bad; fp = nfp; @@ -3558,7 +3572,7 @@ fhopen(p, uap) type = F_FLOCK; if ((fmode & FNONBLOCK) == 0) type |= F_WAIT; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) != 0) { /* * The lock request failed. Normally close the @@ -3567,23 +3581,23 @@ fhopen(p, uap) */ if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } /* * release our private reference */ - fdrop(fp, p); + fdrop(fp, td); return(error); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); fp->f_flag |= FHASLOCK; } if ((vp->v_type == VREG) && (VOP_GETVOBJECT(vp, NULL) != 0)) - vfs_object_create(vp, p, p->p_ucred); + vfs_object_create(vp, td, p->p_ucred); - VOP_UNLOCK(vp, 0, p); - fdrop(fp, p); - p->p_retval[0] = indx; + VOP_UNLOCK(vp, 0, td); + fdrop(fp, td); + td->td_retval[0] = indx; return (0); bad: @@ -3601,8 +3615,8 @@ struct fhstat_args { }; #endif int -fhstat(p, uap) - struct proc *p; +fhstat(td, uap) + struct thread *td; register struct fhstat_args /* { syscallarg(struct fhandle *) u_fhp; syscallarg(struct stat *) sb; @@ -3617,7 +3631,7 @@ fhstat(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); @@ -3629,7 +3643,7 @@ fhstat(p, uap) return (ESTALE); if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) return (error); - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); vput(vp); if (error) return (error); @@ -3647,8 +3661,8 @@ struct fhstatfs_args { }; #endif int -fhstatfs(p, uap) - struct proc *p; +fhstatfs(td, uap) + struct thread *td; struct fhstatfs_args /* { syscallarg(struct fhandle) *u_fhp; syscallarg(struct statfs) *buf; @@ -3664,7 +3678,7 @@ fhstatfs(p, uap) /* * Must be super user */ - if ((error = suser(p))) + if ((error = suser_td(td))) return (error); if ((error = copyin(SCARG(uap, u_fhp), &fh, sizeof(fhandle_t))) != 0) @@ -3677,10 +3691,10 @@ fhstatfs(p, uap) mp = vp->v_mount; sp = &mp->mnt_stat; vput(vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) + if ((error = VFS_STATFS(mp, sp, td)) != 0) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -3700,8 +3714,8 @@ fhstatfs(p, uap) * Currently this is used only by UFS Extended Attributes. */ int -extattrctl(p, uap) - struct proc *p; +extattrctl(td, uap) + struct thread *td; struct extattrctl_args *uap; { struct vnode *filename_vp; @@ -3728,7 +3742,7 @@ extattrctl(p, uap) filename_vp = NULL; if (SCARG(uap, filename) != NULL) { NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, filename), p); + SCARG(uap, filename), td); if ((error = namei(&nd)) != 0) return (error); filename_vp = nd.ni_vp; @@ -3736,7 +3750,7 @@ extattrctl(p, uap) } /* SCARG(uap, path) always defined. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); @@ -3749,10 +3763,10 @@ extattrctl(p, uap) if (SCARG(uap, attrname) != NULL) { error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, - SCARG(uap, attrnamespace), attrname, p); + SCARG(uap, attrnamespace), attrname, td); } else { error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, - SCARG(uap, attrnamespace), NULL, p); + SCARG(uap, attrnamespace), NULL, td); } vn_finished_write(mp); @@ -3779,7 +3793,7 @@ extattrctl(p, uap) */ static int extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct iovec *iovp, unsigned iovcnt, struct proc *p) + struct iovec *iovp, unsigned iovcnt, struct thread *td) { struct mount *mp; struct uio auio; @@ -3789,8 +3803,8 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); iovlen = iovcnt * sizeof(struct iovec); if (iovcnt > UIO_SMALLIOV) { @@ -3806,7 +3820,7 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, auio.uio_iovcnt = iovcnt; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; if ((error = copyin((caddr_t)iovp, (caddr_t)iov, iovlen))) goto done; @@ -3821,20 +3835,20 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, } cnt = auio.uio_resid; error = VOP_SETEXTATTR(vp, attrnamespace, attrname, &auio, - p->p_ucred, p); + td->td_proc->p_ucred, td); cnt -= auio.uio_resid; - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: if (needfree) FREE(needfree, M_IOV); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } int -extattr_set_file(p, uap) - struct proc *p; +extattr_set_file(td, uap) + struct thread *td; struct extattr_set_file_args *uap; { struct nameidata nd; @@ -3846,21 +3860,21 @@ extattr_set_file(p, uap) if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_set_vp(nd.ni_vp, SCARG(uap, attrnamespace), attrname, - SCARG(uap, iovp), SCARG(uap, iovcnt), p); + SCARG(uap, iovp), SCARG(uap, iovcnt), td); vrele(nd.ni_vp); return (error); } int -extattr_set_fd(p, uap) - struct proc *p; +extattr_set_fd(td, uap) + struct thread *td; struct extattr_set_fd_args *uap; { struct file *fp; @@ -3872,12 +3886,12 @@ extattr_set_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_set_vp((struct vnode *)fp->f_data, SCARG(uap, attrnamespace), attrname, SCARG(uap, iovp), - SCARG(uap, iovcnt), p); + SCARG(uap, iovcnt), td); return (error); } @@ -3895,15 +3909,15 @@ extattr_set_fd(p, uap) */ static int extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct iovec *iovp, unsigned iovcnt, struct proc *p) + struct iovec *iovp, unsigned iovcnt, struct thread *td) { struct uio auio; struct iovec *iov, *needfree = NULL, aiov[UIO_SMALLIOV]; u_int iovlen, cnt; int error, i; - VOP_LEASE(vp, p, p->p_ucred, LEASE_READ); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_READ); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); iovlen = iovcnt * sizeof (struct iovec); if (iovcnt > UIO_SMALLIOV) { @@ -3919,7 +3933,7 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, auio.uio_iovcnt = iovcnt; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; if ((error = copyin((caddr_t)iovp, (caddr_t)iov, iovlen))) goto done; @@ -3934,19 +3948,19 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, } cnt = auio.uio_resid; error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, - p->p_ucred, p); + td->td_proc->p_ucred, td); cnt -= auio.uio_resid; - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: if (needfree) FREE(needfree, M_IOV); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } int -extattr_get_file(p, uap) - struct proc *p; +extattr_get_file(td, uap) + struct thread *td; struct extattr_get_file_args *uap; { struct nameidata nd; @@ -3958,21 +3972,21 @@ extattr_get_file(p, uap) if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_get_vp(nd.ni_vp, SCARG(uap, attrnamespace), attrname, - SCARG(uap, iovp), SCARG(uap, iovcnt), p); + SCARG(uap, iovp), SCARG(uap, iovcnt), td); vrele(nd.ni_vp); return (error); } int -extattr_get_fd(p, uap) - struct proc *p; +extattr_get_fd(td, uap) + struct thread *td; struct extattr_get_fd_args *uap; { struct file *fp; @@ -3984,12 +3998,12 @@ extattr_get_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_get_vp((struct vnode *)fp->f_data, SCARG(uap, attrnamespace), attrname, SCARG(uap, iovp), - SCARG(uap, iovcnt), p); + SCARG(uap, iovcnt), td); return (error); } @@ -4006,27 +4020,27 @@ extattr_get_fd(p, uap) */ static int extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct proc *p) + struct thread *td) { struct mount *mp; int error; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_SETEXTATTR(vp, attrnamespace, attrname, NULL, - p->p_ucred, p); + td->td_proc->p_ucred, td); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } int -extattr_delete_file(p, uap) - struct proc *p; +extattr_delete_file(td, uap) + struct thread *td; struct extattr_delete_file_args *uap; { struct nameidata nd; @@ -4038,21 +4052,21 @@ extattr_delete_file(p, uap) if (error) return(error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return(error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_delete_vp(nd.ni_vp, SCARG(uap, attrnamespace), - attrname, p); + attrname, td); vrele(nd.ni_vp); return(error); } int -extattr_delete_fd(p, uap) - struct proc *p; +extattr_delete_fd(td, uap) + struct thread *td; struct extattr_delete_fd_args *uap; { struct file *fp; @@ -4064,11 +4078,11 @@ extattr_delete_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_delete_vp((struct vnode *)fp->f_data, - SCARG(uap, attrnamespace), attrname, p); + SCARG(uap, attrnamespace), attrname, td); return (error); } diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 4875533..470abba 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -100,15 +100,16 @@ namei(ndp) struct uio auio; int error, linklen; struct componentname *cnp = &ndp->ni_cnd; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; + struct proc *p = td->td_proc; - ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_proc->p_ucred; - KASSERT(cnp->cn_cred && cnp->cn_proc, ("namei: bad cred/proc")); + ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_proc->p_ucred; + KASSERT(cnp->cn_cred && p, ("namei: bad cred/proc")); KASSERT((cnp->cn_nameiop & (~OPMASK)) == 0, ("namei: nameiop contaminated with flags")); KASSERT((cnp->cn_flags & OPMASK) == 0, ("namei: flags contaminated with nameiops")); - fdp = cnp->cn_proc->p_fd; + fdp = p->p_fd; /* * Get a buffer for the name to be translated, and copy the @@ -136,8 +137,8 @@ namei(ndp) } ndp->ni_loopcnt = 0; #ifdef KTRACE - if (KTRPOINT(cnp->cn_proc, KTR_NAMEI)) - ktrnamei(cnp->cn_proc->p_tracep, cnp->cn_pnbuf); + if (KTRPOINT(p, KTR_NAMEI)) + ktrnamei(p->p_tracep, cnp->cn_pnbuf); #endif /* @@ -182,14 +183,13 @@ namei(ndp) (cnp->cn_nameiop != DELETE) && ((cnp->cn_flags & (NOOBJ|LOCKLEAF)) == LOCKLEAF)) - vfs_object_create(ndp->ni_vp, - ndp->ni_cnd.cn_proc, + vfs_object_create(ndp->ni_vp, td, ndp->ni_cnd.cn_cred); return (0); } if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { error = ELOOP; break; @@ -205,7 +205,7 @@ namei(ndp) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -296,7 +296,7 @@ lookup(ndp) int error = 0; int dpunlocked = 0; /* dp has already been unlocked */ struct componentname *cnp = &ndp->ni_cnd; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; /* * Setup: break out flag bits into variables. @@ -312,7 +312,7 @@ lookup(ndp) cnp->cn_flags &= ~ISSYMLINK; dp = ndp->ni_startdir; ndp->ni_startdir = NULLVP; - vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, td); dirloop: /* @@ -392,7 +392,7 @@ dirloop: } ndp->ni_vp = dp; if (!(cnp->cn_flags & (LOCKPARENT | LOCKLEAF))) - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, td); /* XXX This should probably move to the top of function. */ if (cnp->cn_flags & SAVESTART) panic("lookup: SAVESTART"); @@ -432,7 +432,7 @@ dirloop: dp = dp->v_mount->mnt_vnodecovered; vput(tdp); VREF(dp); - vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, td); } } @@ -459,7 +459,7 @@ unionlookup: else vput(tdp); VREF(dp); - vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, td); goto unionlookup; } @@ -514,11 +514,11 @@ unionlookup: */ while (dp->v_type == VDIR && (mp = dp->v_mountedhere) && (cnp->cn_flags & NOCROSSMOUNT) == 0) { - if (vfs_busy(mp, 0, 0, p)) + if (vfs_busy(mp, 0, 0, td)) continue; - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, td); error = VFS_ROOT(mp, &tdp); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); if (error) { dpunlocked = 1; goto bad2; @@ -587,13 +587,13 @@ nextname: vrele(ndp->ni_dvp); if ((cnp->cn_flags & LOCKLEAF) == 0) - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, td); return (0); bad2: if ((cnp->cn_flags & (LOCKPARENT | PDIRUNLOCK)) == LOCKPARENT && *ndp->ni_next == '\0') - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); vrele(ndp->ni_dvp); bad: if (dpunlocked) @@ -613,7 +613,7 @@ relookup(dvp, vpp, cnp) struct vnode *dvp, **vpp; struct componentname *cnp; { - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct vnode *dp = 0; /* the directory we are searching */ int docache; /* == 0 do not cache last component */ int wantparent; /* 1 => wantparent or lockparent flag */ @@ -635,7 +635,7 @@ relookup(dvp, vpp, cnp) rdonly = cnp->cn_flags & RDONLY; cnp->cn_flags &= ~ISSYMLINK; dp = dvp; - vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, td); /* dirloop: */ /* @@ -669,7 +669,7 @@ relookup(dvp, vpp, cnp) goto bad; } if (!(cnp->cn_flags & LOCKLEAF)) - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, td); *vpp = dp; /* XXX This should probably move to the top of function. */ if (cnp->cn_flags & SAVESTART) @@ -730,15 +730,15 @@ relookup(dvp, vpp, cnp) if (vn_canvmio(dp) == TRUE && ((cnp->cn_flags & (NOOBJ|LOCKLEAF)) == LOCKLEAF)) - vfs_object_create(dp, cnp->cn_proc, cnp->cn_cred); + vfs_object_create(dp, td, cnp->cn_cred); if ((cnp->cn_flags & LOCKLEAF) == 0) - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, td); return (0); bad2: if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); vrele(dvp); bad: vput(dp); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index e651ef0..98c3f13 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -227,7 +227,7 @@ vfs_mountroot_try(char *mountfrom) */ strncpy(mp->mnt_stat.f_mntonname, "/", MNAMELEN); - error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); + error = VFS_MOUNT(mp, NULL, NULL, NULL, curthread); done: if (vfsname != NULL) @@ -236,7 +236,7 @@ done: free(path, M_MOUNT); if (error != 0) { if (mp != NULL) { - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, curthread); free(mp, M_MOUNT); } printf("Root mount failed: %d\n", error); @@ -249,7 +249,7 @@ done: /* sanity check system clock against root filesystem timestamp */ inittodr(mp->mnt_time); - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, curthread); } return(error); } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b38bc16..8c67662 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -74,7 +74,7 @@ static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); static void addalias __P((struct vnode *vp, dev_t nvp_rdev)); static void insmntque __P((struct vnode *vp, struct mount *mp)); -static void vclean __P((struct vnode *vp, int flags, struct proc *p)); +static void vclean __P((struct vnode *vp, int flags, struct thread *td)); /* * Number of vnodes in existence. Increased whenever getnewvnode() @@ -269,11 +269,11 @@ SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, vntblinit, NULL) * unmounting. Interlock is not released on failure. */ int -vfs_busy(mp, flags, interlkp, p) +vfs_busy(mp, flags, interlkp, td) struct mount *mp; int flags; struct mtx *interlkp; - struct proc *p; + struct thread *td; { int lkflags; @@ -293,7 +293,7 @@ vfs_busy(mp, flags, interlkp, p) lkflags = LK_SHARED | LK_NOPAUSE; if (interlkp) lkflags |= LK_INTERLOCK; - if (lockmgr(&mp->mnt_lock, lkflags, interlkp, p)) + if (lockmgr(&mp->mnt_lock, lkflags, interlkp, td)) panic("vfs_busy: unexpected lock failure"); return (0); } @@ -302,12 +302,12 @@ vfs_busy(mp, flags, interlkp, p) * Free a busy filesystem. */ void -vfs_unbusy(mp, p) +vfs_unbusy(mp, td) struct mount *mp; - struct proc *p; + struct thread *td; { - lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, p); + lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); } /* @@ -322,7 +322,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) char *devname; struct mount **mpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vfsconf *vfsp; struct mount *mp; @@ -335,7 +335,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) return (ENODEV); mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); - (void)vfs_busy(mp, LK_NOWAIT, 0, p); + (void)vfs_busy(mp, LK_NOWAIT, 0, td); LIST_INIT(&mp->mnt_vnodelist); mp->mnt_vfc = vfsp; mp->mnt_op = vfsp->vfc_vfsops; @@ -524,7 +524,7 @@ getnewvnode(tag, mp, vops, vpp) struct vnode **vpp; { int s, count; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp = NULL; struct mount *vnmp; vm_object_t object; @@ -582,7 +582,7 @@ getnewvnode(tag, mp, vops, vpp) cache_purge(vp); vp->v_lease = NULL; if (vp->v_type != VBAD) { - vgonel(vp, p); + vgonel(vp, td); } else { mtx_unlock(&vp->v_interlock); } @@ -634,7 +634,7 @@ getnewvnode(tag, mp, vops, vpp) splx(s); - vfs_object_create(vp, p, p->p_ucred); + vfs_object_create(vp, td, td->td_proc->p_ucred); vnodeallocs++; if (vnodeallocs % vnoderecycleperiod == 0 && @@ -699,11 +699,11 @@ vwakeup(bp) * Called with the underlying object locked. */ int -vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) +vinvalbuf(vp, flags, cred, td, slpflag, slptimeo) register struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; int slpflag, slptimeo; { register struct buf *bp; @@ -726,7 +726,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) } if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) { splx(s); - if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)) != 0) + if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, td)) != 0) return (error); s = splbio(); if (vp->v_numoutput > 0 || @@ -815,10 +815,10 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) * sync activity. */ int -vtruncbuf(vp, cred, p, length, blksize) +vtruncbuf(vp, cred, td, length, blksize) register struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; off_t length; int blksize; { @@ -1020,15 +1020,15 @@ sched_sync(void) struct mount *mp; long starttime; int s; - struct proc *p = updateproc; + struct thread *td = &updateproc->p_thread; /* XXXKSE */ mtx_lock(&Giant); - EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, p, + EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, td->td_proc, SHUTDOWN_PRI_LAST); for (;;) { - kthread_suspend_check(p); + kthread_suspend_check(td->td_proc); starttime = time_second; @@ -1046,9 +1046,9 @@ sched_sync(void) while ((vp = LIST_FIRST(slp)) != NULL) { if (VOP_ISLOCKED(vp, NULL) == 0 && vn_start_write(vp, &mp, V_NOWAIT) == 0) { - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - (void) VOP_FSYNC(vp, p->p_ucred, MNT_LAZY, p); - VOP_UNLOCK(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + (void) VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_LAZY, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); } s = splbio(); @@ -1111,14 +1111,15 @@ sched_sync(void) * Request the syncer daemon to speed up its work. * We never push it to speed up more than half of its * normal turn time, otherwise it could take over the cpu. + * XXXKSE only one update? */ int speedup_syncer() { mtx_lock_spin(&sched_lock); - if (updateproc->p_wchan == &lbolt) - setrunnable(updateproc); + if (updateproc->p_thread.td_wchan == &lbolt) /* XXXKSE */ + setrunnable(&updateproc->p_thread); mtx_unlock_spin(&sched_lock); if (rushjob < syncdelay / 2) { rushjob += 1; @@ -1398,9 +1399,9 @@ addaliasu(nvp, nvp_rdev) ovp->v_vnlock = &ovp->v_lock; ops = ovp->v_op; ovp->v_op = nvp->v_op; - if (VOP_ISLOCKED(nvp, curproc)) { - VOP_UNLOCK(nvp, 0, curproc); - vn_lock(ovp, LK_EXCLUSIVE | LK_RETRY, curproc); + if (VOP_ISLOCKED(nvp, curthread)) { + VOP_UNLOCK(nvp, 0, curthread); + vn_lock(ovp, LK_EXCLUSIVE | LK_RETRY, curthread); } nvp->v_op = ops; insmntque(ovp, nvp->v_mount); @@ -1433,10 +1434,10 @@ addalias(nvp, dev) * been changed to a new file system type). */ int -vget(vp, flags, p) +vget(vp, flags, td) register struct vnode *vp; int flags; - struct proc *p; + struct thread *td; { int error; @@ -1449,7 +1450,7 @@ vget(vp, flags, p) if ((flags & LK_INTERLOCK) == 0) mtx_lock(&vp->v_interlock); if (vp->v_flag & VXLOCK) { - if (vp->v_vxproc == curproc) { + if (vp->v_vxproc == curthread) { printf("VXLOCK interlock avoided\n"); } else { vp->v_flag |= VXWANT; @@ -1464,7 +1465,7 @@ vget(vp, flags, p) if (VSHOULDBUSY(vp)) vbusy(vp); if (flags & LK_TYPE_MASK) { - if ((error = vn_lock(vp, flags | LK_INTERLOCK, p)) != 0) { + if ((error = vn_lock(vp, flags | LK_INTERLOCK, td)) != 0) { /* * must expand vrele here because we do not want * to call VOP_INACTIVE if the reference count @@ -1504,7 +1505,7 @@ void vrele(vp) struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ KASSERT(vp != NULL, ("vrele: null vp")); @@ -1532,8 +1533,8 @@ vrele(vp) * call VOP_INACTIVE with the node locked. So, in the case of * vrele, we explicitly lock the vnode before calling VOP_INACTIVE. */ - if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) == 0) { - VOP_INACTIVE(vp, p); + if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, td) == 0) { + VOP_INACTIVE(vp, td); } } else { @@ -1554,7 +1555,7 @@ void vput(vp) struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ GIANT_REQUIRED; @@ -1567,7 +1568,7 @@ vput(vp) if (vp->v_usecount > 1) { vp->v_usecount--; - VOP_UNLOCK(vp, LK_INTERLOCK, p); + VOP_UNLOCK(vp, LK_INTERLOCK, td); return; } @@ -1583,7 +1584,7 @@ vput(vp) * vrele, we explicitly lock the vnode before calling VOP_INACTIVE. */ mtx_unlock(&vp->v_interlock); - VOP_INACTIVE(vp, p); + VOP_INACTIVE(vp, td); } else { #ifdef DIAGNOSTIC @@ -1659,7 +1660,7 @@ vflush(mp, rootrefs, flags) int rootrefs; int flags; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp, *nvp, *rootvp = NULL; int busy = 0, error; @@ -1711,7 +1712,7 @@ loop: * vnode data structures and we are done. */ if (vp->v_usecount == 0) { - vgonel(vp, p); + vgonel(vp, td); mtx_lock(&mntvnode_mtx); continue; } @@ -1723,9 +1724,9 @@ loop: */ if (flags & FORCECLOSE) { if (vp->v_type != VCHR) { - vgonel(vp, p); + vgonel(vp, td); } else { - vclean(vp, 0, p); + vclean(vp, 0, td); vp->v_op = spec_vnodeop_p; insmntque(vp, (struct mount *) 0); } @@ -1750,7 +1751,7 @@ loop: KASSERT(busy > 0, ("vflush: not busy")); KASSERT(rootvp->v_usecount >= rootrefs, ("vflush: rootrefs")); if (busy == 1 && rootvp->v_usecount == rootrefs) { - vgonel(rootvp, p); + vgonel(rootvp, td); busy = 0; } else mtx_unlock(&rootvp->v_interlock); @@ -1766,10 +1767,10 @@ loop: * Disassociate the underlying file system from a vnode. */ static void -vclean(vp, flags, p) +vclean(vp, flags, td) struct vnode *vp; int flags; - struct proc *p; + struct thread *td; { int active; @@ -1788,7 +1789,7 @@ vclean(vp, flags, p) if (vp->v_flag & VXLOCK) panic("vclean: deadlock"); vp->v_flag |= VXLOCK; - vp->v_vxproc = curproc; + vp->v_vxproc = curthread; /* * Even if the count is zero, the VOP_INACTIVE routine may still * have the object locked while it cleans it out. The VOP_LOCK @@ -1796,7 +1797,7 @@ vclean(vp, flags, p) * For active vnodes, it ensures that no other activity can * occur while the underlying object is being cleaned out. */ - VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK, p); + VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK, td); /* * Clean out any buffers associated with the vnode. @@ -1805,8 +1806,8 @@ vclean(vp, flags, p) if (flags & DOCLOSE) { if (TAILQ_FIRST(&vp->v_dirtyblkhd) != NULL) (void) vn_write_suspend_wait(vp, NULL, V_WAIT); - if (vinvalbuf(vp, V_SAVE, NOCRED, p, 0, 0) != 0) - vinvalbuf(vp, 0, NOCRED, p, 0, 0); + if (vinvalbuf(vp, V_SAVE, NOCRED, td, 0, 0) != 0) + vinvalbuf(vp, 0, NOCRED, td, 0, 0); } VOP_DESTROYVOBJECT(vp); @@ -1818,19 +1819,19 @@ vclean(vp, flags, p) */ if (active) { if (flags & DOCLOSE) - VOP_CLOSE(vp, FNONBLOCK, NOCRED, p); - VOP_INACTIVE(vp, p); + VOP_CLOSE(vp, FNONBLOCK, NOCRED, td); + VOP_INACTIVE(vp, td); } else { /* * Any other processes trying to obtain this lock must first * wait for VXLOCK to clear, then call the new lock operation. */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } /* * Reclaim the vnode. */ - if (VOP_RECLAIM(vp, p)) + if (VOP_RECLAIM(vp, td)) panic("vclean: cannot reclaim"); if (active) { @@ -1916,10 +1917,10 @@ vop_revoke(ap) * Release the passed interlock if the vnode will be recycled. */ int -vrecycle(vp, inter_lkp, p) +vrecycle(vp, inter_lkp, td) struct vnode *vp; struct mtx *inter_lkp; - struct proc *p; + struct thread *td; { mtx_lock(&vp->v_interlock); @@ -1927,7 +1928,7 @@ vrecycle(vp, inter_lkp, p) if (inter_lkp) { mtx_unlock(inter_lkp); } - vgonel(vp, p); + vgonel(vp, td); return (1); } mtx_unlock(&vp->v_interlock); @@ -1942,19 +1943,19 @@ void vgone(vp) register struct vnode *vp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ mtx_lock(&vp->v_interlock); - vgonel(vp, p); + vgonel(vp, td); } /* * vgone, with the vp interlock held. */ void -vgonel(vp, p) +vgonel(vp, td) struct vnode *vp; - struct proc *p; + struct thread *td; { int s; @@ -1972,7 +1973,7 @@ vgonel(vp, p) /* * Clean out the filesystem specific data. */ - vclean(vp, DOCLOSE, p); + vclean(vp, DOCLOSE, td); mtx_lock(&vp->v_interlock); /* @@ -2132,14 +2133,14 @@ vprint(label, vp) */ DB_SHOW_COMMAND(lockedvnodes, lockedvnodes) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct mount *mp, *nmp; struct vnode *vp; printf("Locked vnodes\n"); mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -2151,7 +2152,7 @@ DB_SHOW_COMMAND(lockedvnodes, lockedvnodes) mtx_unlock(&mntvnode_mtx); mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); } @@ -2187,7 +2188,7 @@ vfs_sysctl(SYSCTL_HANDLER_ARGS) if (vfsp == NULL) return (EOPNOTSUPP); return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1, - oldp, oldlenp, newp, newlen, p)); + oldp, oldlenp, newp, newlen, td)); } #endif switch (name[1]) { @@ -2245,7 +2246,7 @@ sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS) static int sysctl_vnode(SYSCTL_HANDLER_ARGS) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct mount *mp, *nmp; struct vnode *nvp, *vp; int error; @@ -2260,7 +2261,7 @@ sysctl_vnode(SYSCTL_HANDLER_ARGS) mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -2286,7 +2287,7 @@ again: mtx_unlock(&mntvnode_mtx); mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); @@ -2323,19 +2324,19 @@ void vfs_unmountall() { struct mount *mp; - struct proc *p; + struct thread *td; int error; - if (curproc != NULL) - p = curproc; + if (curthread != NULL) + td = curthread; else - p = initproc; /* XXX XXX should this be proc0? */ + td = &initproc->p_thread; /* XXX XXX should this be proc0? */ /* * Since this only runs when rebooting, it is not interlocked. */ while(!TAILQ_EMPTY(&mountlist)) { mp = TAILQ_LAST(&mountlist, mntlist); - error = dounmount(mp, MNT_FORCE, p); + error = dounmount(mp, MNT_FORCE, td); if (error) { TAILQ_REMOVE(&mountlist, mp, mnt_list); printf("unmount of %s failed (", @@ -2394,7 +2395,7 @@ loop: if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) { if (!vget(vp, - LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) { + LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curthread)) { if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, flags == MNT_WAIT ? @@ -2422,13 +2423,13 @@ loop: * vp must be locked when vfs_object_create is called. */ int -vfs_object_create(vp, p, cred) +vfs_object_create(vp, td, cred) struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; { GIANT_REQUIRED; - return (VOP_CREATEVOBJECT(vp, cred, p)); + return (VOP_CREATEVOBJECT(vp, cred, td)); } /* @@ -2483,9 +2484,9 @@ vbusy(vp) * to avoid race conditions.) */ int -vn_pollrecord(vp, p, events) +vn_pollrecord(vp, td, events) struct vnode *vp; - struct proc *p; + struct thread *td; short events; { mtx_lock(&vp->v_pollinfo.vpi_lock); @@ -2504,7 +2505,7 @@ vn_pollrecord(vp, p, events) return events; } vp->v_pollinfo.vpi_events |= events; - selrecord(p, &vp->v_pollinfo.vpi_selinfo); + selrecord(td, &vp->v_pollinfo.vpi_selinfo); mtx_unlock(&vp->v_pollinfo.vpi_lock); return 0; } @@ -2640,12 +2641,12 @@ sync_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *syncvp = ap->a_vp; struct mount *mp = syncvp->v_mount; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int asyncflag; /* @@ -2664,22 +2665,22 @@ sync_fsync(ap) * not already on the sync list. */ mtx_lock(&mountlist_mtx); - if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_mtx, p) != 0) { + if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_mtx, td) != 0) { mtx_unlock(&mountlist_mtx); return (0); } if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) { - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (0); } asyncflag = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); - VFS_SYNC(mp, MNT_LAZY, ap->a_cred, p); + VFS_SYNC(mp, MNT_LAZY, ap->a_cred, td); if (asyncflag) mp->mnt_flag |= MNT_ASYNC; vn_finished_write(mp); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (0); } @@ -2690,7 +2691,7 @@ static int sync_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -2805,7 +2806,7 @@ NDFREE(ndp, flags) if (!(flags & NDF_NO_DVP_UNLOCK) && (ndp->ni_cnd.cn_flags & LOCKPARENT) && ndp->ni_dvp != ndp->ni_vp) - VOP_UNLOCK(ndp->ni_dvp, 0, ndp->ni_cnd.cn_proc); + VOP_UNLOCK(ndp->ni_dvp, 0, ndp->ni_cnd.cn_thread); if (!(flags & NDF_NO_DVP_RELE) && (ndp->ni_cnd.cn_flags & (LOCKPARENT|WANTPARENT))) { vrele(ndp->ni_dvp); @@ -2813,7 +2814,7 @@ NDFREE(ndp, flags) } if (!(flags & NDF_NO_VP_UNLOCK) && (ndp->ni_cnd.cn_flags & LOCKLEAF) && ndp->ni_vp) - VOP_UNLOCK(ndp->ni_vp, 0, ndp->ni_cnd.cn_proc); + VOP_UNLOCK(ndp->ni_vp, 0, ndp->ni_cnd.cn_thread); if (!(flags & NDF_NO_VP_RELE) && ndp->ni_vp) { vrele(ndp->ni_vp); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index bb39292..4e05b8d 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -75,18 +75,18 @@ #include <vm/vm_zone.h> #include <vm/vm_page.h> -static int change_dir __P((struct nameidata *ndp, struct proc *p)); +static int change_dir __P((struct nameidata *ndp, struct thread *td)); static void checkdirs __P((struct vnode *olddp, struct vnode *newdp)); static int chroot_refuse_vdir_fds __P((struct filedesc *fdp)); static int getutimes __P((const struct timeval *, struct timespec *)); -static int setfown __P((struct proc *, struct vnode *, uid_t, gid_t)); -static int setfmode __P((struct proc *, struct vnode *, int)); -static int setfflags __P((struct proc *, struct vnode *, int)); -static int setutimes __P((struct proc *, struct vnode *, +static int setfown __P((struct thread *td, struct vnode *, uid_t, gid_t)); +static int setfmode __P((struct thread *td, struct vnode *, int)); +static int setfflags __P((struct thread *td, struct vnode *, int)); +static int setutimes __P((struct thread *td, struct vnode *, const struct timespec *, int)); static int usermount = 0; /* if 1, non-root can mount fs. */ -int (*union_dircheckp) __P((struct proc *, struct vnode **, struct file *)); +int (*union_dircheckp) __P((struct thread *td, struct vnode **, struct file *)); SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -107,8 +107,8 @@ struct mount_args { #endif /* ARGSUSED */ int -mount(p, uap) - struct proc *p; +mount(td, uap) + struct thread *td; struct mount_args /* { syscallarg(char *) type; syscallarg(char *) path; @@ -133,7 +133,7 @@ mount(p, uap) error = copyinstr(SCARG(uap, path), fspath, MNAMELEN, NULL); if (error) goto finish; - error = vfs_mount(p, fstype, fspath, SCARG(uap, flags), + error = vfs_mount(td, fstype, fspath, SCARG(uap, flags), SCARG(uap, data)); finish: free(fstype, M_TEMP); @@ -150,8 +150,8 @@ finish: * into userspace. */ int -vfs_mount(p, fstype, fspath, fsflags, fsdata) - struct proc *p; +vfs_mount(td, fstype, fspath, fsflags, fsdata) + struct thread *td; const char *fstype; char *fspath; int fsflags; @@ -163,6 +163,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) int error, flag = 0, flag2 = 0; struct vattr va; struct nameidata nd; + struct proc *p = td->td_proc; /* * Be ultra-paranoid about making sure the type and fspath @@ -173,13 +174,13 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) (strlen(fspath) >= MNAMELEN - 1)) return (ENAMETOOLONG); - if (usermount == 0 && (error = suser(p))) + if (usermount == 0 && (error = suser_td(td))) return (error); /* * Do not allow NFS export by non-root users. */ if (fsflags & MNT_EXPORTED) { - error = suser(p); + error = suser_td(td); if (error) return (error); } @@ -191,7 +192,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) /* * Get vnode to be covered */ - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspath, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspath, td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -218,11 +219,11 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) * permitted to update it. */ if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid && - (error = suser(p))) { + (error = suser_td(td))) { vput(vp); return (error); } - if (vfs_busy(mp, LK_NOWAIT, 0, p)) { + if (vfs_busy(mp, LK_NOWAIT, 0, td)) { vput(vp); return (EBUSY); } @@ -230,7 +231,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) if ((vp->v_flag & VMOUNT) != 0 || vp->v_mountedhere != NULL) { mtx_unlock(&vp->v_interlock); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); vput(vp); return (EBUSY); } @@ -238,20 +239,20 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) mtx_unlock(&vp->v_interlock); mp->mnt_flag |= fsflags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_SNAPSHOT); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); goto update; } /* * If the user is not root, ensure that they own the directory * onto which we are attempting to mount. */ - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) || + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, td)) || (va.va_uid != p->p_ucred->cr_uid && - (error = suser(p)))) { + (error = suser_td(td)))) { vput(vp); return (error); } - if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) { + if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, td, 0, 0)) != 0) { vput(vp); return (error); } @@ -266,7 +267,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) linker_file_t lf; /* Only load modules for root (very important!) */ - if ((error = suser(p)) != 0) { + if ((error = suser_td(td)) != 0) { vput(vp); return error; } @@ -304,7 +305,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) */ mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); - (void)vfs_busy(mp, LK_NOWAIT, 0, p); + (void)vfs_busy(mp, LK_NOWAIT, 0, td); mp->mnt_op = vfsp->vfc_vfsops; mp->mnt_vfc = vfsp; vfsp->vfc_refcount++; @@ -317,7 +318,7 @@ vfs_mount(p, fstype, fspath, fsflags, fsdata) strncpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN); mp->mnt_stat.f_mntonname[MNAMELEN - 1] = '\0'; mp->mnt_iosize_max = DFLTPHYS; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); update: /* * Set the mount level flags. @@ -339,7 +340,7 @@ update: * XXX The final recipients of VFS_MOUNT just overwrite the ndp they * get. No freeing of cn_pnbuf. */ - error = VFS_MOUNT(mp, fspath, fsdata, &nd, p); + error = VFS_MOUNT(mp, fspath, fsdata, &nd, td); if (mp->mnt_flag & MNT_UPDATE) { if (mp->mnt_kern_flag & MNTK_WANTRDWR) mp->mnt_flag &= ~MNT_RDONLY; @@ -358,14 +359,14 @@ update: vrele(mp->mnt_syncer); mp->mnt_syncer = NULL; } - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); mtx_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; mtx_unlock(&vp->v_interlock); vrele(vp); return (error); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* * Put the new filesystem on the mount list after root. */ @@ -384,18 +385,18 @@ update: panic("mount: lost mount"); checkdirs(vp, newdp); vput(newdp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((mp->mnt_flag & MNT_RDONLY) == 0) error = vfs_allocate_syncvnode(mp); - vfs_unbusy(mp, p); - if ((error = VFS_START(mp, 0, p)) != 0) + vfs_unbusy(mp, td); + if ((error = VFS_START(mp, 0, td)) != 0) vrele(vp); } else { mtx_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; mtx_unlock(&vp->v_interlock); mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); free((caddr_t)mp, M_MOUNT); vput(vp); } @@ -454,8 +455,8 @@ struct unmount_args { #endif /* ARGSUSED */ int -unmount(p, uap) - struct proc *p; +unmount(td, uap) + struct thread *td; register struct unmount_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -467,7 +468,7 @@ unmount(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -478,8 +479,8 @@ unmount(p, uap) * Only root, or the user that did the original mount is * permitted to unmount this filesystem. */ - if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) && - (error = suser(p))) { + if ((mp->mnt_stat.f_owner != td->td_proc->p_ucred->cr_uid) && + (error = suser_td(td))) { vput(vp); return (error); } @@ -500,17 +501,17 @@ unmount(p, uap) return (EINVAL); } vput(vp); - return (dounmount(mp, SCARG(uap, flags), p)); + return (dounmount(mp, SCARG(uap, flags), td)); } /* * Do the actual file system unmount. */ int -dounmount(mp, flags, p) +dounmount(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { struct vnode *coveredvp, *fsrootvp; int error; @@ -518,7 +519,7 @@ dounmount(mp, flags, p) mtx_lock(&mountlist_mtx); mp->mnt_kern_flag |= MNTK_UNMOUNT; - lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_mtx, p); + lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_mtx, td); vn_start_write(NULL, &mp, V_WAIT); if (mp->mnt_flag & MNT_EXPUBLIC) @@ -541,9 +542,9 @@ dounmount(mp, flags, p) vput(fsrootvp); } if (((mp->mnt_flag & MNT_RDONLY) || - (error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0) || + (error = VFS_SYNC(mp, MNT_WAIT, td->td_proc->p_ucred, td)) == 0) || (flags & MNT_FORCE)) { - error = VFS_UNMOUNT(mp, flags, p); + error = VFS_UNMOUNT(mp, flags, td); } vn_finished_write(mp); if (error) { @@ -563,7 +564,7 @@ dounmount(mp, flags, p) mp->mnt_kern_flag &= ~MNTK_UNMOUNT; mp->mnt_flag |= async_flag; lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, - &mountlist_mtx, p); + &mountlist_mtx, td); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup((caddr_t)mp); return (error); @@ -575,7 +576,7 @@ dounmount(mp, flags, p) mp->mnt_vfc->vfc_refcount--; if (!LIST_EMPTY(&mp->mnt_vnodelist)) panic("unmount: dangling vnode"); - lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_mtx, p); + lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_mtx, td); lockdestroy(&mp->mnt_lock); if (coveredvp != NULL) vrele(coveredvp); @@ -601,8 +602,8 @@ SYSCTL_INT(_debug, OID_AUTO, syncprt, CTLFLAG_RW, &syncprt, 0, ""); /* ARGSUSED */ int -sync(p, uap) - struct proc *p; +sync(td, uap) + struct thread *td; struct sync_args *uap; { struct mount *mp, *nmp; @@ -610,7 +611,7 @@ sync(p, uap) mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -620,13 +621,13 @@ sync(p, uap) mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); VFS_SYNC(mp, MNT_NOWAIT, - ((p != NULL) ? p->p_ucred : NOCRED), p); + ((td != NULL) ? td->td_proc->p_ucred : NOCRED), td); mp->mnt_flag |= asyncflag; vn_finished_write(mp); } mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); #if 0 @@ -661,8 +662,8 @@ struct quotactl_args { #endif /* ARGSUSED */ int -quotactl(p, uap) - struct proc *p; +quotactl(td, uap) + struct thread *td; register struct quotactl_args /* { syscallarg(char *) path; syscallarg(int) cmd; @@ -674,9 +675,9 @@ quotactl(p, uap) int error; struct nameidata nd; - if (jailed(p->p_ucred) && !prison_quotas) + if (jailed(td->td_proc->p_ucred) && !prison_quotas) return (EPERM); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -685,7 +686,7 @@ quotactl(p, uap) if (error) return (error); error = VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid), - SCARG(uap, arg), p); + SCARG(uap, arg), td); vn_finished_write(mp); return (error); } @@ -701,8 +702,8 @@ struct statfs_args { #endif /* ARGSUSED */ int -statfs(p, uap) - struct proc *p; +statfs(td, uap) + struct thread *td; register struct statfs_args /* { syscallarg(char *) path; syscallarg(struct statfs *) buf; @@ -714,18 +715,18 @@ statfs(p, uap) struct nameidata nd; struct statfs sb; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); mp = nd.ni_vp->v_mount; sp = &mp->mnt_stat; NDFREE(&nd, NDF_ONLY_PNBUF); vrele(nd.ni_vp); - error = VFS_STATFS(mp, sp, p); + error = VFS_STATFS(mp, sp, td); if (error) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -744,8 +745,8 @@ struct fstatfs_args { #endif /* ARGSUSED */ int -fstatfs(p, uap) - struct proc *p; +fstatfs(td, uap) + struct thread *td; register struct fstatfs_args /* { syscallarg(int) fd; syscallarg(struct statfs *) buf; @@ -757,15 +758,15 @@ fstatfs(p, uap) int error; struct statfs sb; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; - error = VFS_STATFS(mp, sp, p); + error = VFS_STATFS(mp, sp, td); if (error) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -784,8 +785,8 @@ struct getfsstat_args { }; #endif int -getfsstat(p, uap) - struct proc *p; +getfsstat(td, uap) + struct thread *td; register struct getfsstat_args /* { syscallarg(struct statfs *) buf; syscallarg(long) bufsize; @@ -802,7 +803,7 @@ getfsstat(p, uap) count = 0; mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -815,16 +816,16 @@ getfsstat(p, uap) */ if (((SCARG(uap, flags) & (MNT_LAZY|MNT_NOWAIT)) == 0 || (SCARG(uap, flags) & MNT_WAIT)) && - (error = VFS_STATFS(mp, sp, p))) { + (error = VFS_STATFS(mp, sp, td))) { mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); continue; } sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; error = copyout((caddr_t)sp, sfsp, sizeof(*sp)); if (error) { - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (error); } sfsp += sizeof(*sp); @@ -832,13 +833,13 @@ getfsstat(p, uap) count++; mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); if (sfsp && count > maxcount) - p->p_retval[0] = maxcount; + td->td_retval[0] = maxcount; else - p->p_retval[0] = count; + td->td_retval[0] = count; return (0); } @@ -852,13 +853,13 @@ struct fchdir_args { #endif /* ARGSUSED */ int -fchdir(p, uap) - struct proc *p; +fchdir(td, uap) + struct thread *td; struct fchdir_args /* { syscallarg(int) fd; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; struct vnode *vp, *tdp; struct mount *mp; struct file *fp; @@ -868,16 +869,16 @@ fchdir(p, uap) return (error); vp = (struct vnode *)fp->f_data; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); while (!error && (mp = vp->v_mountedhere) != NULL) { - if (vfs_busy(mp, 0, 0, p)) + if (vfs_busy(mp, 0, 0, td)) continue; error = VFS_ROOT(mp, &tdp); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); if (error) break; vput(vp); @@ -887,7 +888,7 @@ fchdir(p, uap) vput(vp); return (error); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(fdp->fd_cdir); fdp->fd_cdir = vp; return (0); @@ -903,19 +904,19 @@ struct chdir_args { #endif /* ARGSUSED */ int -chdir(p, uap) - struct proc *p; +chdir(td, uap) + struct thread *td; struct chdir_args /* { syscallarg(char *) path; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = change_dir(&nd, p)) != 0) + SCARG(uap, path), td); + if ((error = change_dir(&nd, td)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(fdp->fd_cdir); @@ -971,17 +972,17 @@ struct chroot_args { #endif /* ARGSUSED */ int -chroot(p, uap) - struct proc *p; +chroot(td, uap) + struct thread *td; struct chroot_args /* { syscallarg(char *) path; } */ *uap; { - register struct filedesc *fdp = p->p_fd; + register struct filedesc *fdp = td->td_proc->p_fd; int error; struct nameidata nd; - error = suser_xxx(0, p, PRISON_ROOT); + error = suser_xxx(0, td->td_proc, PRISON_ROOT); if (error) return (error); if (chroot_allow_open_directories == 0 || @@ -990,8 +991,8 @@ chroot(p, uap) if (error) return (error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = change_dir(&nd, p)) != 0) + SCARG(uap, path), td); + if ((error = change_dir(&nd, td)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(fdp->fd_rdir); @@ -1007,9 +1008,9 @@ chroot(p, uap) * Common routine for chroot and chdir. */ static int -change_dir(ndp, p) +change_dir(ndp, td) register struct nameidata *ndp; - struct proc *p; + struct thread *td; { struct vnode *vp; int error; @@ -1021,11 +1022,11 @@ change_dir(ndp, p) if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td); if (error) vput(vp); else - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -1041,14 +1042,15 @@ struct open_args { }; #endif int -open(p, uap) - struct proc *p; +open(td, uap) + struct thread *td; register struct open_args /* { syscallarg(char *) path; syscallarg(int) flags; syscallarg(int) mode; } */ *uap; { + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; @@ -1064,13 +1066,13 @@ open(p, uap) if ((oflags & O_ACCMODE) == O_ACCMODE) return (EINVAL); flags = FFLAGS(oflags); - error = falloc(p, &nfp, &indx); + error = falloc(td, &nfp, &indx); if (error) return (error); fp = nfp; cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); - p->p_dupfd = -indx - 1; /* XXX check for fdopen */ + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); + td->td_dupfd = -indx - 1; /* XXX check for fdopen */ /* * Bump the ref count to prevent another process from closing * the descriptor while we are blocked in vn_open() @@ -1081,7 +1083,7 @@ open(p, uap) /* * release our own reference */ - fdrop(fp, p); + fdrop(fp, td); /* * handle special fdopen() case. bleh. dupfdopen() is @@ -1089,10 +1091,10 @@ open(p, uap) * if it succeeds. */ if ((error == ENODEV || error == ENXIO) && - p->p_dupfd >= 0 && /* XXX from fdopen */ + td->td_dupfd >= 0 && /* XXX from fdopen */ (error = - dupfdopen(p, fdp, indx, p->p_dupfd, flags, error)) == 0) { - p->p_retval[0] = indx; + dupfdopen(td, fdp, indx, td->td_dupfd, flags, error)) == 0) { + td->td_retval[0] = indx; return (0); } /* @@ -1101,14 +1103,14 @@ open(p, uap) */ if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } if (error == ERESTART) error = EINTR; return (error); } - p->p_dupfd = 0; + td->td_dupfd = 0; NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; @@ -1123,10 +1125,10 @@ open(p, uap) if (fp->f_count == 1) { KASSERT(fdp->fd_ofiles[indx] != fp, ("Open file descriptor lost all refs")); - VOP_UNLOCK(vp, 0, p); - vn_close(vp, flags & FMASK, fp->f_cred, p); - fdrop(fp, p); - p->p_retval[0] = indx; + VOP_UNLOCK(vp, 0, td); + vn_close(vp, flags & FMASK, fp->f_cred, td); + fdrop(fp, td); + td->td_retval[0] = indx; return 0; } @@ -1134,7 +1136,7 @@ open(p, uap) fp->f_flag = flags & FMASK; fp->f_ops = &vnops; fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (flags & (O_EXLOCK | O_SHLOCK)) { lf.l_whence = SEEK_SET; lf.l_start = 0; @@ -1153,12 +1155,12 @@ open(p, uap) if (flags & O_TRUNC) { if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto bad; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); VATTR_NULL(&vat); vat.va_size = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETATTR(vp, &vat, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETATTR(vp, &vat, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); if (error) goto bad; @@ -1170,15 +1172,15 @@ open(p, uap) * Release our private reference, leaving the one associated with * the descriptor table intact. */ - fdrop(fp, p); - p->p_retval[0] = indx; + fdrop(fp, td); + td->td_retval[0] = indx; return (0); bad: if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -1193,8 +1195,8 @@ struct ocreat_args { }; #endif int -ocreat(p, uap) - struct proc *p; +ocreat(td, uap) + struct thread *td; register struct ocreat_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1209,7 +1211,7 @@ ocreat(p, uap) SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, mode) = SCARG(uap, mode); SCARG(&nuap, flags) = O_WRONLY | O_CREAT | O_TRUNC; - return (open(p, &nuap)); + return (open(td, &nuap)); } #endif /* COMPAT_43 */ @@ -1225,8 +1227,8 @@ struct mknod_args { #endif /* ARGSUSED */ int -mknod(p, uap) - struct proc *p; +mknod(td, uap) + struct thread *td; register struct mknod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1243,17 +1245,17 @@ mknod(p, uap) switch (SCARG(uap, mode) & S_IFMT) { case S_IFCHR: case S_IFBLK: - error = suser(p); + error = suser_td(td); break; default: - error = suser_xxx(0, p, PRISON_ROOT); + error = suser_xxx(0, td->td_proc, PRISON_ROOT); break; } if (error) return (error); restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -1262,7 +1264,7 @@ restart: error = EEXIST; } else { VATTR_NULL(&vattr); - vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; + vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ td->td_proc->p_fd->fd_cmask; vattr.va_rdev = SCARG(uap, dev); whiteout = 0; @@ -1292,7 +1294,7 @@ restart: goto restart; } if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); if (whiteout) error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, CREATE); else { @@ -1321,8 +1323,8 @@ struct mkfifo_args { #endif /* ARGSUSED */ int -mkfifo(p, uap) - struct proc *p; +mkfifo(td, uap) + struct thread *td; register struct mkfifo_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -1335,7 +1337,7 @@ mkfifo(p, uap) restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); if (nd.ni_vp != NULL) { @@ -1353,8 +1355,8 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VFIFO; - vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); if (error == 0) vput(nd.ni_vp); @@ -1375,8 +1377,8 @@ struct link_args { #endif /* ARGSUSED */ int -link(p, uap) - struct proc *p; +link(td, uap) + struct thread *td; register struct link_args /* { syscallarg(char *) path; syscallarg(char *) link; @@ -1388,7 +1390,7 @@ link(p, uap) int error; bwillwrite(); - NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1401,14 +1403,14 @@ link(p, uap) vrele(vp); return (error); } - NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); + NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td); if ((error = namei(&nd)) == 0) { if (nd.ni_vp != NULL) { vrele(nd.ni_vp); error = EEXIST; } else { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1432,8 +1434,8 @@ struct symlink_args { #endif /* ARGSUSED */ int -symlink(p, uap) - struct proc *p; +symlink(td, uap) + struct thread *td; register struct symlink_args /* { syscallarg(char *) path; syscallarg(char *) link; @@ -1450,7 +1452,7 @@ symlink(p, uap) goto out; restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); + NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td); if ((error = namei(&nd)) != 0) goto out; if (nd.ni_vp) { @@ -1468,8 +1470,8 @@ restart: goto restart; } VATTR_NULL(&vattr); - vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path); NDFREE(&nd, NDF_ONLY_PNBUF); if (error == 0) @@ -1488,8 +1490,8 @@ out: */ /* ARGSUSED */ int -undelete(p, uap) - struct proc *p; +undelete(td, uap) + struct thread *td; register struct undelete_args /* { syscallarg(char *) path; } */ *uap; @@ -1501,7 +1503,7 @@ undelete(p, uap) restart: bwillwrite(); NDINIT(&nd, DELETE, LOCKPARENT|DOWHITEOUT, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); error = namei(&nd); if (error) return (error); @@ -1520,7 +1522,7 @@ restart: return (error); goto restart; } - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -1540,8 +1542,8 @@ struct unlink_args { #endif /* ARGSUSED */ int -unlink(p, uap) - struct proc *p; +unlink(td, uap) + struct thread *td; struct unlink_args /* { syscallarg(char *) path; } */ *uap; @@ -1553,7 +1555,7 @@ unlink(p, uap) restart: bwillwrite(); - NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -1576,10 +1578,10 @@ restart: return (error); goto restart; } - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1603,8 +1605,8 @@ struct lseek_args { }; #endif int -lseek(p, uap) - struct proc *p; +lseek(td, uap) + struct thread *td; register struct lseek_args /* { syscallarg(int) fd; syscallarg(int) pad; @@ -1612,8 +1614,8 @@ lseek(p, uap) syscallarg(int) whence; } */ *uap; { - struct ucred *cred = p->p_ucred; - register struct filedesc *fdp = p->p_fd; + struct ucred *cred = td->td_proc->p_ucred; + register struct filedesc *fdp = td->td_proc->p_fd; register struct file *fp; struct vattr vattr; struct vnode *vp; @@ -1637,7 +1639,7 @@ lseek(p, uap) offset += fp->f_offset; break; case L_XTND: - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); if (noneg && @@ -1654,7 +1656,7 @@ lseek(p, uap) if (noneg && offset < 0) return (EINVAL); fp->f_offset = offset; - *(off_t *)(p->p_retval) = fp->f_offset; + *(off_t *)(td->td_retval) = fp->f_offset; return (0); } @@ -1670,8 +1672,8 @@ struct olseek_args { }; #endif int -olseek(p, uap) - struct proc *p; +olseek(td, uap) + struct thread *td; register struct olseek_args /* { syscallarg(int) fd; syscallarg(long) offset; @@ -1689,7 +1691,7 @@ olseek(p, uap) SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, offset) = SCARG(uap, offset); SCARG(&nuap, whence) = SCARG(uap, whence); - error = lseek(p, &nuap); + error = lseek(td, &nuap); return (error); } #endif /* COMPAT_43 */ @@ -1704,8 +1706,8 @@ struct access_args { }; #endif int -access(p, uap) - struct proc *p; +access(td, uap) + struct thread *td; register struct access_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -1716,7 +1718,7 @@ access(p, uap) int error, flags; struct nameidata nd; - cred = p->p_ucred; + cred = td->td_proc->p_ucred; /* * Create and modify a temporary credential instead of one that * is potentially shared. This could also mess up socket @@ -1729,9 +1731,9 @@ access(p, uap) tmpcred = crdup(cred); tmpcred->cr_uid = cred->cr_ruid; tmpcred->cr_groups[0] = cred->cr_rgid; - p->p_ucred = tmpcred; + td->td_proc->p_ucred = tmpcred; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) goto out1; vp = nd.ni_vp; @@ -1746,12 +1748,12 @@ access(p, uap) if (SCARG(uap, flags) & X_OK) flags |= VEXEC; if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0) - error = VOP_ACCESS(vp, flags, tmpcred, p); + error = VOP_ACCESS(vp, flags, tmpcred, td); } NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); out1: - p->p_ucred = cred; + td->td_proc->p_ucred = cred; crfree(tmpcred); return (error); } @@ -1768,8 +1770,8 @@ struct ostat_args { #endif /* ARGSUSED */ int -ostat(p, uap) - struct proc *p; +ostat(td, uap) + struct thread *td; register struct ostat_args /* { syscallarg(char *) path; syscallarg(struct ostat *) ub; @@ -1781,11 +1783,11 @@ ostat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -1805,8 +1807,8 @@ struct olstat_args { #endif /* ARGSUSED */ int -olstat(p, uap) - struct proc *p; +olstat(td, uap) + struct thread *td; register struct olstat_args /* { syscallarg(char *) path; syscallarg(struct ostat *) ub; @@ -1819,11 +1821,11 @@ olstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); if (error) @@ -1874,8 +1876,8 @@ struct stat_args { #endif /* ARGSUSED */ int -stat(p, uap) - struct proc *p; +stat(td, uap) + struct thread *td; register struct stat_args /* { syscallarg(char *) path; syscallarg(struct stat *) ub; @@ -1886,10 +1888,10 @@ stat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_vp); if (error) @@ -1909,8 +1911,8 @@ struct lstat_args { #endif /* ARGSUSED */ int -lstat(p, uap) - struct proc *p; +lstat(td, uap) + struct thread *td; register struct lstat_args /* { syscallarg(char *) path; syscallarg(struct stat *) ub; @@ -1922,11 +1924,11 @@ lstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); if (error) @@ -1974,8 +1976,8 @@ struct nstat_args { #endif /* ARGSUSED */ int -nstat(p, uap) - struct proc *p; +nstat(td, uap) + struct thread *td; register struct nstat_args /* { syscallarg(char *) path; syscallarg(struct nstat *) ub; @@ -1987,11 +1989,11 @@ nstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(nd.ni_vp, &sb, p); + error = vn_stat(nd.ni_vp, &sb, td); vput(nd.ni_vp); if (error) return (error); @@ -2011,8 +2013,8 @@ struct lstat_args { #endif /* ARGSUSED */ int -nlstat(p, uap) - struct proc *p; +nlstat(td, uap) + struct thread *td; register struct nlstat_args /* { syscallarg(char *) path; syscallarg(struct nstat *) ub; @@ -2025,12 +2027,12 @@ nlstat(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); vput(vp); if (error) return (error); @@ -2050,8 +2052,8 @@ struct pathconf_args { #endif /* ARGSUSED */ int -pathconf(p, uap) - struct proc *p; +pathconf(td, uap) + struct thread *td; register struct pathconf_args /* { syscallarg(char *) path; syscallarg(int) name; @@ -2061,11 +2063,11 @@ pathconf(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), p->p_retval); + error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), td->td_retval); vput(nd.ni_vp); return (error); } @@ -2082,8 +2084,8 @@ struct readlink_args { #endif /* ARGSUSED */ int -readlink(p, uap) - struct proc *p; +readlink(td, uap) + struct thread *td; register struct readlink_args /* { syscallarg(char *) path; syscallarg(char *) buf; @@ -2097,7 +2099,7 @@ readlink(p, uap) struct nameidata nd; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -2112,12 +2114,12 @@ readlink(p, uap) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - error = VOP_READLINK(vp, &auio, p->p_ucred); + error = VOP_READLINK(vp, &auio, td->td_proc->p_ucred); } vput(vp); - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } @@ -2125,8 +2127,8 @@ readlink(p, uap) * Common implementation code for chflags() and fchflags(). */ static int -setfflags(p, vp, flags) - struct proc *p; +setfflags(td, vp, flags) + struct thread *td; struct vnode *vp; int flags; { @@ -2141,17 +2143,17 @@ setfflags(p, vp, flags) * chown can't fail when done as root. */ if ((vp->v_type == VCHR || vp->v_type == VBLK) && - ((error = suser_xxx(p->p_ucred, p, PRISON_ROOT)) != 0)) + ((error = suser_xxx(td->td_proc->p_ucred, td->td_proc, PRISON_ROOT)) != 0)) return (error); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_flags = flags; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2167,8 +2169,8 @@ struct chflags_args { #endif /* ARGSUSED */ int -chflags(p, uap) - struct proc *p; +chflags(td, uap) + struct thread *td; register struct chflags_args /* { syscallarg(char *) path; syscallarg(int) flags; @@ -2177,11 +2179,11 @@ chflags(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfflags(p, nd.ni_vp, SCARG(uap, flags)); + error = setfflags(td, nd.ni_vp, SCARG(uap, flags)); vrele(nd.ni_vp); return error; } @@ -2197,8 +2199,8 @@ struct fchflags_args { #endif /* ARGSUSED */ int -fchflags(p, uap) - struct proc *p; +fchflags(td, uap) + struct thread *td; register struct fchflags_args /* { syscallarg(int) fd; syscallarg(int) flags; @@ -2207,17 +2209,17 @@ fchflags(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfflags(p, (struct vnode *) fp->f_data, SCARG(uap, flags)); + return setfflags(td, (struct vnode *) fp->f_data, SCARG(uap, flags)); } /* * Common implementation code for chmod(), lchmod() and fchmod(). */ static int -setfmode(p, vp, mode) - struct proc *p; +setfmode(td, vp, mode) + struct thread *td; struct vnode *vp; int mode; { @@ -2227,12 +2229,12 @@ setfmode(p, vp, mode) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_mode = mode & ALLPERMS; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2248,8 +2250,8 @@ struct chmod_args { #endif /* ARGSUSED */ int -chmod(p, uap) - struct proc *p; +chmod(td, uap) + struct thread *td; register struct chmod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -2258,11 +2260,11 @@ chmod(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); + error = setfmode(td, nd.ni_vp, SCARG(uap, mode)); vrele(nd.ni_vp); return error; } @@ -2278,8 +2280,8 @@ struct lchmod_args { #endif /* ARGSUSED */ int -lchmod(p, uap) - struct proc *p; +lchmod(td, uap) + struct thread *td; register struct lchmod_args /* { syscallarg(char *) path; syscallarg(int) mode; @@ -2288,11 +2290,11 @@ lchmod(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfmode(p, nd.ni_vp, SCARG(uap, mode)); + error = setfmode(td, nd.ni_vp, SCARG(uap, mode)); vrele(nd.ni_vp); return error; } @@ -2308,8 +2310,8 @@ struct fchmod_args { #endif /* ARGSUSED */ int -fchmod(p, uap) - struct proc *p; +fchmod(td, uap) + struct thread *td; register struct fchmod_args /* { syscallarg(int) fd; syscallarg(int) mode; @@ -2318,17 +2320,17 @@ fchmod(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfmode(p, (struct vnode *)fp->f_data, SCARG(uap, mode)); + return setfmode(td, (struct vnode *)fp->f_data, SCARG(uap, mode)); } /* * Common implementation for chown(), lchown(), and fchown() */ static int -setfown(p, vp, uid, gid) - struct proc *p; +setfown(td, vp, uid, gid) + struct thread *td; struct vnode *vp; uid_t uid; gid_t gid; @@ -2339,13 +2341,13 @@ setfown(p, vp, uid, gid) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_uid = uid; vattr.va_gid = gid; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2362,8 +2364,8 @@ struct chown_args { #endif /* ARGSUSED */ int -chown(p, uap) - struct proc *p; +chown(td, uap) + struct thread *td; register struct chown_args /* { syscallarg(char *) path; syscallarg(int) uid; @@ -2373,11 +2375,11 @@ chown(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); + error = setfown(td, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); vrele(nd.ni_vp); return (error); } @@ -2394,8 +2396,8 @@ struct lchown_args { #endif /* ARGSUSED */ int -lchown(p, uap) - struct proc *p; +lchown(td, uap) + struct thread *td; register struct lchown_args /* { syscallarg(char *) path; syscallarg(int) uid; @@ -2405,11 +2407,11 @@ lchown(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); + error = setfown(td, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid)); vrele(nd.ni_vp); return (error); } @@ -2426,8 +2428,8 @@ struct fchown_args { #endif /* ARGSUSED */ int -fchown(p, uap) - struct proc *p; +fchown(td, uap) + struct thread *td; register struct fchown_args /* { syscallarg(int) fd; syscallarg(int) uid; @@ -2437,9 +2439,9 @@ fchown(p, uap) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setfown(p, (struct vnode *)fp->f_data, + return setfown(td, (struct vnode *)fp->f_data, SCARG(uap, uid), SCARG(uap, gid)); } @@ -2471,8 +2473,8 @@ getutimes(usrtvp, tsp) * Common implementation code for utimes(), lutimes(), and futimes(). */ static int -setutimes(p, vp, ts, nullflag) - struct proc *p; +setutimes(td, vp, ts, nullflag) + struct thread *td; struct vnode *vp; const struct timespec *ts; int nullflag; @@ -2483,15 +2485,15 @@ setutimes(p, vp, ts, nullflag) if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VATTR_NULL(&vattr); vattr.va_atime = ts[0]; vattr.va_mtime = ts[1]; if (nullflag) vattr.va_vaflags |= VA_UTIMES_NULL; - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); - VOP_UNLOCK(vp, 0, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return error; } @@ -2507,8 +2509,8 @@ struct utimes_args { #endif /* ARGSUSED */ int -utimes(p, uap) - struct proc *p; +utimes(td, uap) + struct thread *td; register struct utimes_args /* { syscallarg(char *) path; syscallarg(struct timeval *) tptr; @@ -2522,11 +2524,11 @@ utimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL); + error = setutimes(td, nd.ni_vp, ts, usrtvp == NULL); vrele(nd.ni_vp); return (error); } @@ -2542,8 +2544,8 @@ struct lutimes_args { #endif /* ARGSUSED */ int -lutimes(p, uap) - struct proc *p; +lutimes(td, uap) + struct thread *td; register struct lutimes_args /* { syscallarg(char *) path; syscallarg(struct timeval *) tptr; @@ -2557,11 +2559,11 @@ lutimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL); + error = setutimes(td, nd.ni_vp, ts, usrtvp == NULL); vrele(nd.ni_vp); return (error); } @@ -2577,8 +2579,8 @@ struct futimes_args { #endif /* ARGSUSED */ int -futimes(p, uap) - struct proc *p; +futimes(td, uap) + struct thread *td; register struct futimes_args /* { syscallarg(int ) fd; syscallarg(struct timeval *) tptr; @@ -2592,9 +2594,9 @@ futimes(p, uap) usrtvp = SCARG(uap, tptr); if ((error = getutimes(usrtvp, ts)) != 0) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - return setutimes(p, (struct vnode *)fp->f_data, ts, usrtvp == NULL); + return setutimes(td, (struct vnode *)fp->f_data, ts, usrtvp == NULL); } /* @@ -2609,8 +2611,8 @@ struct truncate_args { #endif /* ARGSUSED */ int -truncate(p, uap) - struct proc *p; +truncate(td, uap) + struct thread *td; register struct truncate_args /* { syscallarg(char *) path; syscallarg(int) pad; @@ -2625,7 +2627,7 @@ truncate(p, uap) if (uap->length < 0) return(EINVAL); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -2634,15 +2636,15 @@ truncate(p, uap) return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type == VDIR) error = EISDIR; else if ((error = vn_writechk(vp)) == 0 && - (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) { + (error = VOP_ACCESS(vp, VWRITE, td->td_proc->p_ucred, td)) == 0) { VATTR_NULL(&vattr); vattr.va_size = SCARG(uap, length); - error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); + error = VOP_SETATTR(vp, &vattr, td->td_proc->p_ucred, td); } vput(vp); vn_finished_write(mp); @@ -2661,8 +2663,8 @@ struct ftruncate_args { #endif /* ARGSUSED */ int -ftruncate(p, uap) - struct proc *p; +ftruncate(td, uap) + struct thread *td; register struct ftruncate_args /* { syscallarg(int) fd; syscallarg(int) pad; @@ -2677,23 +2679,23 @@ ftruncate(p, uap) if (uap->length < 0) return(EINVAL); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FWRITE) == 0) return (EINVAL); vp = (struct vnode *)fp->f_data; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type == VDIR) error = EISDIR; else if ((error = vn_writechk(vp)) == 0) { VATTR_NULL(&vattr); vattr.va_size = SCARG(uap, length); - error = VOP_SETATTR(vp, &vattr, fp->f_cred, p); + error = VOP_SETATTR(vp, &vattr, fp->f_cred, td); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2710,8 +2712,8 @@ struct otruncate_args { #endif /* ARGSUSED */ int -otruncate(p, uap) - struct proc *p; +otruncate(td, uap) + struct thread *td; register struct otruncate_args /* { syscallarg(char *) path; syscallarg(long) length; @@ -2725,7 +2727,7 @@ otruncate(p, uap) SCARG(&nuap, path) = SCARG(uap, path); SCARG(&nuap, length) = SCARG(uap, length); - return (truncate(p, &nuap)); + return (truncate(td, &nuap)); } /* @@ -2739,8 +2741,8 @@ struct oftruncate_args { #endif /* ARGSUSED */ int -oftruncate(p, uap) - struct proc *p; +oftruncate(td, uap) + struct thread *td; register struct oftruncate_args /* { syscallarg(int) fd; syscallarg(long) length; @@ -2754,7 +2756,7 @@ oftruncate(p, uap) SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, length) = SCARG(uap, length); - return (ftruncate(p, &nuap)); + return (ftruncate(td, &nuap)); } #endif /* COMPAT_43 || COMPAT_SUNOS */ @@ -2768,8 +2770,8 @@ struct fsync_args { #endif /* ARGSUSED */ int -fsync(p, uap) - struct proc *p; +fsync(td, uap) + struct thread *td; struct fsync_args /* { syscallarg(int) fd; } */ *uap; @@ -2782,22 +2784,22 @@ fsync(p, uap) GIANT_REQUIRED; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, 0); } - error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p); + error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); #ifdef SOFTUPDATES if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP)) error = softdep_fsync(vp); #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -2814,8 +2816,8 @@ struct rename_args { #endif /* ARGSUSED */ int -rename(p, uap) - struct proc *p; +rename(td, uap) + struct thread *td; register struct rename_args /* { syscallarg(char *) from; syscallarg(char *) to; @@ -2828,7 +2830,7 @@ rename(p, uap) bwillwrite(); NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE, - SCARG(uap, from), p); + SCARG(uap, from), td); if ((error = namei(&fromnd)) != 0) return (error); fvp = fromnd.ni_vp; @@ -2839,7 +2841,7 @@ rename(p, uap) goto out1; } NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | NOOBJ, - UIO_USERSPACE, SCARG(uap, to), p); + UIO_USERSPACE, SCARG(uap, to), td); if (fromnd.ni_vp->v_type == VDIR) tond.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&tond)) != 0) { @@ -2876,12 +2878,12 @@ rename(p, uap) error = -1; out: if (!error) { - VOP_LEASE(tdvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tdvp, td, td->td_proc->p_ucred, LEASE_WRITE); if (fromnd.ni_dvp != tdvp) { - VOP_LEASE(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(fromnd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); } if (tvp) { - VOP_LEASE(tvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tvp, td, td->td_proc->p_ucred, LEASE_WRITE); } error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); @@ -2924,13 +2926,24 @@ struct mkdir_args { #endif /* ARGSUSED */ int -mkdir(p, uap) - struct proc *p; +mkdir(td, uap) + struct thread *td; register struct mkdir_args /* { syscallarg(char *) path; syscallarg(int) mode; } */ *uap; { + + return vn_mkdir(uap->path, uap->mode, UIO_USERSPACE, td); +} + +int +vn_mkdir(path, mode, segflg, td) + char *path; + int mode; + enum uio_seg segflg; + struct thread *td; +{ struct mount *mp; struct vnode *vp; struct vattr vattr; @@ -2939,7 +2952,7 @@ mkdir(p, uap) restart: bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, segflg, path, td); nd.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&nd)) != 0) return (error); @@ -2959,8 +2972,8 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VDIR; - vattr.va_mode = (SCARG(uap, mode) & ACCESSPERMS) &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask; + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -2982,8 +2995,8 @@ struct rmdir_args { #endif /* ARGSUSED */ int -rmdir(p, uap) - struct proc *p; +rmdir(td, uap) + struct thread *td; struct rmdir_args /* { syscallarg(char *) path; } */ *uap; @@ -2996,7 +3009,7 @@ rmdir(p, uap) restart: bwillwrite(); NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -3029,8 +3042,8 @@ restart: return (error); goto restart; } - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, td->td_proc->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); vn_finished_write(mp); out: @@ -3058,8 +3071,8 @@ struct ogetdirentries_args { }; #endif int -ogetdirentries(p, uap) - struct proc *p; +ogetdirentries(td, uap) + struct thread *td; register struct ogetdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3079,7 +3092,7 @@ ogetdirentries(p, uap) /* XXX arbitrary sanity limit on `count'. */ if (SCARG(uap, count) > 64 * 1024) return (EINVAL); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) return (EBADF); @@ -3093,9 +3106,9 @@ unionread: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); loff = auio.uio_offset = fp->f_offset; # if (BYTE_ORDER != LITTLE_ENDIAN) if (vp->v_mount->mnt_maxsymlinklen <= 0) { @@ -3148,12 +3161,12 @@ unionread: } FREE(dirbuf, M_TEMP); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error) return (error); if (SCARG(uap, count) == auio.uio_resid) { if (union_dircheckp) { - error = union_dircheckp(p, &vp, fp); + error = union_dircheckp(td, &vp, fp); if (error == -1) goto unionread; if (error) @@ -3172,7 +3185,7 @@ unionread: } error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep), sizeof(long)); - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } #endif /* COMPAT_43 */ @@ -3189,8 +3202,8 @@ struct getdirentries_args { }; #endif int -getdirentries(p, uap) - struct proc *p; +getdirentries(td, uap) + struct thread *td; register struct getdirentries_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3205,7 +3218,7 @@ getdirentries(p, uap) long loff; int error, eofflag; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) return (EBADF); @@ -3219,19 +3232,19 @@ unionread: auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_resid = SCARG(uap, count); - /* vn_lock(vp, LK_SHARED | LK_RETRY, p); */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + /* vn_lock(vp, LK_SHARED | LK_RETRY, td); */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); loff = auio.uio_offset = fp->f_offset; error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL); fp->f_offset = auio.uio_offset; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error) return (error); if (SCARG(uap, count) == auio.uio_resid) { if (union_dircheckp) { - error = union_dircheckp(p, &vp, fp); + error = union_dircheckp(td, &vp, fp); if (error == -1) goto unionread; if (error) @@ -3252,7 +3265,7 @@ unionread: error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep), sizeof(long)); } - p->p_retval[0] = SCARG(uap, count) - auio.uio_resid; + td->td_retval[0] = SCARG(uap, count) - auio.uio_resid; return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -3263,8 +3276,8 @@ struct getdents_args { }; #endif int -getdents(p, uap) - struct proc *p; +getdents(td, uap) + struct thread *td; register struct getdents_args /* { syscallarg(int) fd; syscallarg(char *) buf; @@ -3276,7 +3289,7 @@ getdents(p, uap) ap.buf = uap->buf; ap.count = uap->count; ap.basep = NULL; - return getdirentries(p, &ap); + return getdirentries(td, &ap); } /* @@ -3290,16 +3303,16 @@ struct umask_args { }; #endif int -umask(p, uap) - struct proc *p; +umask(td, uap) + struct thread *td; struct umask_args /* { syscallarg(int) newmask; } */ *uap; { register struct filedesc *fdp; - fdp = p->p_fd; - p->p_retval[0] = fdp->fd_cmask; + fdp = td->td_proc->p_fd; + td->td_retval[0] = fdp->fd_cmask; fdp->fd_cmask = SCARG(uap, newmask) & ALLPERMS; return (0); } @@ -3315,8 +3328,8 @@ struct revoke_args { #endif /* ARGSUSED */ int -revoke(p, uap) - struct proc *p; +revoke(td, uap) + struct thread *td; register struct revoke_args /* { syscallarg(char *) path; } */ *uap; @@ -3327,7 +3340,7 @@ revoke(p, uap) int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -3336,10 +3349,10 @@ revoke(p, uap) error = EINVAL; goto out; } - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) goto out; - if (p->p_ucred->cr_uid != vattr.va_uid && - (error = suser_xxx(0, p, PRISON_ROOT))) + if (td->td_proc->p_ucred->cr_uid != vattr.va_uid && + (error = suser_xxx(0, td->td_proc, PRISON_ROOT))) goto out; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto out; @@ -3380,8 +3393,8 @@ struct getfh_args { }; #endif int -getfh(p, uap) - struct proc *p; +getfh(td, uap) + struct thread *td; register struct getfh_args *uap; { struct nameidata nd; @@ -3392,10 +3405,10 @@ getfh(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td); error = namei(&nd); if (error) return (error); @@ -3425,13 +3438,14 @@ struct fhopen_args { }; #endif int -fhopen(p, uap) - struct proc *p; +fhopen(td, uap) + struct thread *td; struct fhopen_args /* { syscallarg(const struct fhandle *) u_fhp; syscallarg(int) flags; } */ *uap; { + struct proc *p = td->td_proc; struct mount *mp; struct vnode *vp; struct fhandle fhp; @@ -3447,7 +3461,7 @@ fhopen(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); @@ -3498,33 +3512,33 @@ fhopen(p, uap) if (fmode & FREAD) mode |= VREAD; if (mode) { - error = VOP_ACCESS(vp, mode, p->p_ucred, p); + error = VOP_ACCESS(vp, mode, p->p_ucred, td); if (error) goto bad; } if (fmode & O_TRUNC) { - VOP_UNLOCK(vp, 0, p); /* XXX */ + VOP_UNLOCK(vp, 0, td); /* XXX */ if ((error = vn_start_write(NULL, &mp, V_WAIT | PCATCH)) != 0) { vrele(vp); return (error); } - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* XXX */ + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* XXX */ VATTR_NULL(vap); vap->va_size = 0; - error = VOP_SETATTR(vp, vap, p->p_ucred, p); + error = VOP_SETATTR(vp, vap, p->p_ucred, td); vn_finished_write(mp); if (error) goto bad; } - error = VOP_OPEN(vp, fmode, p->p_ucred, p); + error = VOP_OPEN(vp, fmode, p->p_ucred, td); if (error) goto bad; /* * Make sure that a VM object is created for VMIO support. */ if (vn_canvmio(vp) == TRUE) { - if ((error = vfs_object_create(vp, p, p->p_ucred)) != 0) + if ((error = vfs_object_create(vp, td, p->p_ucred)) != 0) goto bad; } if (fmode & FWRITE) @@ -3534,7 +3548,7 @@ fhopen(p, uap) * end of vn_open code */ - if ((error = falloc(p, &nfp, &indx)) != 0) + if ((error = falloc(td, &nfp, &indx)) != 0) goto bad; fp = nfp; @@ -3558,7 +3572,7 @@ fhopen(p, uap) type = F_FLOCK; if ((fmode & FNONBLOCK) == 0) type |= F_WAIT; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if ((error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) != 0) { /* * The lock request failed. Normally close the @@ -3567,23 +3581,23 @@ fhopen(p, uap) */ if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } /* * release our private reference */ - fdrop(fp, p); + fdrop(fp, td); return(error); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); fp->f_flag |= FHASLOCK; } if ((vp->v_type == VREG) && (VOP_GETVOBJECT(vp, NULL) != 0)) - vfs_object_create(vp, p, p->p_ucred); + vfs_object_create(vp, td, p->p_ucred); - VOP_UNLOCK(vp, 0, p); - fdrop(fp, p); - p->p_retval[0] = indx; + VOP_UNLOCK(vp, 0, td); + fdrop(fp, td); + td->td_retval[0] = indx; return (0); bad: @@ -3601,8 +3615,8 @@ struct fhstat_args { }; #endif int -fhstat(p, uap) - struct proc *p; +fhstat(td, uap) + struct thread *td; register struct fhstat_args /* { syscallarg(struct fhandle *) u_fhp; syscallarg(struct stat *) sb; @@ -3617,7 +3631,7 @@ fhstat(p, uap) /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) return (error); @@ -3629,7 +3643,7 @@ fhstat(p, uap) return (ESTALE); if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) return (error); - error = vn_stat(vp, &sb, p); + error = vn_stat(vp, &sb, td); vput(vp); if (error) return (error); @@ -3647,8 +3661,8 @@ struct fhstatfs_args { }; #endif int -fhstatfs(p, uap) - struct proc *p; +fhstatfs(td, uap) + struct thread *td; struct fhstatfs_args /* { syscallarg(struct fhandle) *u_fhp; syscallarg(struct statfs) *buf; @@ -3664,7 +3678,7 @@ fhstatfs(p, uap) /* * Must be super user */ - if ((error = suser(p))) + if ((error = suser_td(td))) return (error); if ((error = copyin(SCARG(uap, u_fhp), &fh, sizeof(fhandle_t))) != 0) @@ -3677,10 +3691,10 @@ fhstatfs(p, uap) mp = vp->v_mount; sp = &mp->mnt_stat; vput(vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) + if ((error = VFS_STATFS(mp, sp, td)) != 0) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - if (suser_xxx(p->p_ucred, 0, 0)) { + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -3700,8 +3714,8 @@ fhstatfs(p, uap) * Currently this is used only by UFS Extended Attributes. */ int -extattrctl(p, uap) - struct proc *p; +extattrctl(td, uap) + struct thread *td; struct extattrctl_args *uap; { struct vnode *filename_vp; @@ -3728,7 +3742,7 @@ extattrctl(p, uap) filename_vp = NULL; if (SCARG(uap, filename) != NULL) { NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, filename), p); + SCARG(uap, filename), td); if ((error = namei(&nd)) != 0) return (error); filename_vp = nd.ni_vp; @@ -3736,7 +3750,7 @@ extattrctl(p, uap) } /* SCARG(uap, path) always defined. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); @@ -3749,10 +3763,10 @@ extattrctl(p, uap) if (SCARG(uap, attrname) != NULL) { error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, - SCARG(uap, attrnamespace), attrname, p); + SCARG(uap, attrnamespace), attrname, td); } else { error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, - SCARG(uap, attrnamespace), NULL, p); + SCARG(uap, attrnamespace), NULL, td); } vn_finished_write(mp); @@ -3779,7 +3793,7 @@ extattrctl(p, uap) */ static int extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct iovec *iovp, unsigned iovcnt, struct proc *p) + struct iovec *iovp, unsigned iovcnt, struct thread *td) { struct mount *mp; struct uio auio; @@ -3789,8 +3803,8 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); iovlen = iovcnt * sizeof(struct iovec); if (iovcnt > UIO_SMALLIOV) { @@ -3806,7 +3820,7 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, auio.uio_iovcnt = iovcnt; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; if ((error = copyin((caddr_t)iovp, (caddr_t)iov, iovlen))) goto done; @@ -3821,20 +3835,20 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname, } cnt = auio.uio_resid; error = VOP_SETEXTATTR(vp, attrnamespace, attrname, &auio, - p->p_ucred, p); + td->td_proc->p_ucred, td); cnt -= auio.uio_resid; - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: if (needfree) FREE(needfree, M_IOV); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } int -extattr_set_file(p, uap) - struct proc *p; +extattr_set_file(td, uap) + struct thread *td; struct extattr_set_file_args *uap; { struct nameidata nd; @@ -3846,21 +3860,21 @@ extattr_set_file(p, uap) if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_set_vp(nd.ni_vp, SCARG(uap, attrnamespace), attrname, - SCARG(uap, iovp), SCARG(uap, iovcnt), p); + SCARG(uap, iovp), SCARG(uap, iovcnt), td); vrele(nd.ni_vp); return (error); } int -extattr_set_fd(p, uap) - struct proc *p; +extattr_set_fd(td, uap) + struct thread *td; struct extattr_set_fd_args *uap; { struct file *fp; @@ -3872,12 +3886,12 @@ extattr_set_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_set_vp((struct vnode *)fp->f_data, SCARG(uap, attrnamespace), attrname, SCARG(uap, iovp), - SCARG(uap, iovcnt), p); + SCARG(uap, iovcnt), td); return (error); } @@ -3895,15 +3909,15 @@ extattr_set_fd(p, uap) */ static int extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct iovec *iovp, unsigned iovcnt, struct proc *p) + struct iovec *iovp, unsigned iovcnt, struct thread *td) { struct uio auio; struct iovec *iov, *needfree = NULL, aiov[UIO_SMALLIOV]; u_int iovlen, cnt; int error, i; - VOP_LEASE(vp, p, p->p_ucred, LEASE_READ); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_READ); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); iovlen = iovcnt * sizeof (struct iovec); if (iovcnt > UIO_SMALLIOV) { @@ -3919,7 +3933,7 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, auio.uio_iovcnt = iovcnt; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; if ((error = copyin((caddr_t)iovp, (caddr_t)iov, iovlen))) goto done; @@ -3934,19 +3948,19 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname, } cnt = auio.uio_resid; error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, - p->p_ucred, p); + td->td_proc->p_ucred, td); cnt -= auio.uio_resid; - p->p_retval[0] = cnt; + td->td_retval[0] = cnt; done: if (needfree) FREE(needfree, M_IOV); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } int -extattr_get_file(p, uap) - struct proc *p; +extattr_get_file(td, uap) + struct thread *td; struct extattr_get_file_args *uap; { struct nameidata nd; @@ -3958,21 +3972,21 @@ extattr_get_file(p, uap) if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_get_vp(nd.ni_vp, SCARG(uap, attrnamespace), attrname, - SCARG(uap, iovp), SCARG(uap, iovcnt), p); + SCARG(uap, iovp), SCARG(uap, iovcnt), td); vrele(nd.ni_vp); return (error); } int -extattr_get_fd(p, uap) - struct proc *p; +extattr_get_fd(td, uap) + struct thread *td; struct extattr_get_fd_args *uap; { struct file *fp; @@ -3984,12 +3998,12 @@ extattr_get_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_get_vp((struct vnode *)fp->f_data, SCARG(uap, attrnamespace), attrname, SCARG(uap, iovp), - SCARG(uap, iovcnt), p); + SCARG(uap, iovcnt), td); return (error); } @@ -4006,27 +4020,27 @@ extattr_get_fd(p, uap) */ static int extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname, - struct proc *p) + struct thread *td) { struct mount *mp; int error; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_SETEXTATTR(vp, attrnamespace, attrname, NULL, - p->p_ucred, p); + td->td_proc->p_ucred, td); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } int -extattr_delete_file(p, uap) - struct proc *p; +extattr_delete_file(td, uap) + struct thread *td; struct extattr_delete_file_args *uap; { struct nameidata nd; @@ -4038,21 +4052,21 @@ extattr_delete_file(p, uap) if (error) return(error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return(error); NDFREE(&nd, NDF_ONLY_PNBUF); error = extattr_delete_vp(nd.ni_vp, SCARG(uap, attrnamespace), - attrname, p); + attrname, td); vrele(nd.ni_vp); return(error); } int -extattr_delete_fd(p, uap) - struct proc *p; +extattr_delete_fd(td, uap) + struct thread *td; struct extattr_delete_fd_args *uap; { struct file *fp; @@ -4064,11 +4078,11 @@ extattr_delete_fd(p, uap) if (error) return (error); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); error = extattr_delete_vp((struct vnode *)fp->f_data, - SCARG(uap, attrnamespace), attrname, p); + SCARG(uap, attrnamespace), attrname, td); return (error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 9a6f87a..b3160b1 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -57,17 +57,17 @@ #include <machine/limits.h> -static int vn_closefile __P((struct file *fp, struct proc *p)); +static int vn_closefile __P((struct file *fp, struct thread *td)); static int vn_ioctl __P((struct file *fp, u_long com, caddr_t data, - struct proc *p)); + struct thread *td)); static int vn_read __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); static int vn_poll __P((struct file *fp, int events, struct ucred *cred, - struct proc *p)); + struct thread *td)); static int vn_kqfilter __P((struct file *fp, struct knote *kn)); -static int vn_statfile __P((struct file *fp, struct stat *sb, struct proc *p)); +static int vn_statfile __P((struct file *fp, struct stat *sb, struct thread *td)); static int vn_write __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); struct fileops vnops = { vn_read, vn_write, vn_ioctl, vn_poll, vn_kqfilter, @@ -88,8 +88,8 @@ vn_open(ndp, flagp, cmode) { struct vnode *vp; struct mount *mp; - struct proc *p = ndp->ni_cnd.cn_proc; - struct ucred *cred = p->p_ucred; + struct thread *td = ndp->ni_cnd.cn_thread; + struct ucred *cred = td->td_proc->p_ucred; struct vattr vat; struct vattr *vap = &vat; int mode, fmode, error; @@ -118,7 +118,7 @@ restart: return (error); goto restart; } - VOP_LEASE(ndp->ni_dvp, p, cred, LEASE_WRITE); + VOP_LEASE(ndp->ni_dvp, td, cred, LEASE_WRITE); error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, vap); vput(ndp->ni_dvp); @@ -175,18 +175,18 @@ restart: if (fmode & FREAD) mode |= VREAD; if (mode) { - error = VOP_ACCESS(vp, mode, cred, p); + error = VOP_ACCESS(vp, mode, cred, td); if (error) goto bad; } } - if ((error = VOP_OPEN(vp, fmode, cred, p)) != 0) + if ((error = VOP_OPEN(vp, fmode, cred, td)) != 0) goto bad; /* * Make sure that a VM object is created for VMIO support. */ if (vn_canvmio(vp) == TRUE) { - if ((error = vfs_object_create(vp, p, cred)) != 0) + if ((error = vfs_object_create(vp, td, cred)) != 0) goto bad; } @@ -224,17 +224,17 @@ vn_writechk(vp) * Vnode close call */ int -vn_close(vp, flags, cred, p) +vn_close(vp, flags, cred, td) register struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; { int error; if (flags & FWRITE) vp->v_writecount--; - error = VOP_CLOSE(vp, flags, cred, p); + error = VOP_CLOSE(vp, flags, cred, td); /* * XXX - In certain instances VOP_CLOSE has to do the vrele * itself. If the vrele has been done, it will return EAGAIN @@ -283,7 +283,7 @@ sequential_heuristic(struct uio *uio, struct file *fp) * Package up an I/O request on a vnode into a uio and do it. */ int -vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) +vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, td) enum uio_rw rw; struct vnode *vp; caddr_t base; @@ -293,7 +293,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) int ioflg; struct ucred *cred; int *aresid; - struct proc *p; + struct thread *td; { struct uio auio; struct iovec aiov; @@ -306,7 +306,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) vp->v_type != VCHR && (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); } auio.uio_iov = &aiov; auio.uio_iovcnt = 1; @@ -316,7 +316,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) auio.uio_offset = offset; auio.uio_segflg = segflg; auio.uio_rw = rw; - auio.uio_procp = p; + auio.uio_td = td; if (rw == UIO_READ) { error = VOP_READ(vp, &auio, ioflg, cred); } else { @@ -329,7 +329,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) error = EIO; if ((ioflg & IO_NODELOCKED) == 0) { vn_finished_write(mp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } return (error); } @@ -341,7 +341,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) * check bwillwrite() before calling vn_rdwr() */ int -vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) +vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, td) enum uio_rw rw; struct vnode *vp; caddr_t base; @@ -351,7 +351,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) int ioflg; struct ucred *cred; int *aresid; - struct proc *p; + struct thread *td; { int error = 0; @@ -361,7 +361,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) if (rw != UIO_READ && vp->v_type == VREG) bwillwrite(); error = vn_rdwr(rw, vp, base, chunk, offset, segflg, - ioflg, cred, aresid, p); + ioflg, cred, aresid, td); len -= chunk; /* aresid calc already includes length */ if (error) break; @@ -377,26 +377,26 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) * File table vnode read routine. */ static int -vn_read(fp, uio, cred, flags, p) +vn_read(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { struct vnode *vp; int error, ioflag; - KASSERT(uio->uio_procp == p, ("uio_procp %p is not p %p", - uio->uio_procp, p)); + KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", + uio->uio_td, td)); vp = (struct vnode *)fp->f_data; ioflag = 0; if (fp->f_flag & FNONBLOCK) ioflag |= IO_NDELAY; if (fp->f_flag & O_DIRECT) ioflag |= IO_DIRECT; - VOP_LEASE(vp, p, cred, LEASE_READ); - vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, p); + VOP_LEASE(vp, td, cred, LEASE_READ); + vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, td); if ((flags & FOF_OFFSET) == 0) uio->uio_offset = fp->f_offset; @@ -406,7 +406,7 @@ vn_read(fp, uio, cred, flags, p) if ((flags & FOF_OFFSET) == 0) fp->f_offset = uio->uio_offset; fp->f_nextoff = uio->uio_offset; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -414,19 +414,19 @@ vn_read(fp, uio, cred, flags, p) * File table vnode write routine. */ static int -vn_write(fp, uio, cred, flags, p) +vn_write(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { struct vnode *vp; struct mount *mp; int error, ioflag; - KASSERT(uio->uio_procp == p, ("uio_procp %p is not p %p", - uio->uio_procp, p)); + KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", + uio->uio_td, td)); vp = (struct vnode *)fp->f_data; if (vp->v_type == VREG) bwillwrite(); @@ -445,8 +445,8 @@ vn_write(fp, uio, cred, flags, p) if (vp->v_type != VCHR && (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - VOP_LEASE(vp, p, cred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, cred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if ((flags & FOF_OFFSET) == 0) uio->uio_offset = fp->f_offset; ioflag |= sequential_heuristic(uio, fp); @@ -454,7 +454,7 @@ vn_write(fp, uio, cred, flags, p) if ((flags & FOF_OFFSET) == 0) fp->f_offset = uio->uio_offset; fp->f_nextoff = uio->uio_offset; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); return (error); } @@ -463,21 +463,21 @@ vn_write(fp, uio, cred, flags, p) * File table vnode stat routine. */ static int -vn_statfile(fp, sb, p) +vn_statfile(fp, sb, td) struct file *fp; struct stat *sb; - struct proc *p; + struct thread *td; { struct vnode *vp = (struct vnode *)fp->f_data; - return vn_stat(vp, sb, p); + return vn_stat(vp, sb, td); } int -vn_stat(vp, sb, p) +vn_stat(vp, sb, td) struct vnode *vp; register struct stat *sb; - struct proc *p; + struct thread *td; { struct vattr vattr; register struct vattr *vap; @@ -485,7 +485,7 @@ vn_stat(vp, sb, p) u_short mode; vap = &vattr; - error = VOP_GETATTR(vp, vap, p->p_ucred, p); + error = VOP_GETATTR(vp, vap, td->td_proc->p_ucred, td); if (error) return (error); @@ -568,7 +568,7 @@ vn_stat(vp, sb, p) } sb->st_flags = vap->va_flags; - if (suser_xxx(p->p_ucred, 0, 0)) + if (suser_xxx(td->td_proc->p_ucred, 0, 0)) sb->st_gen = 0; else sb->st_gen = vap->va_gen; @@ -586,11 +586,11 @@ vn_stat(vp, sb, p) * File table vnode ioctl routine. */ static int -vn_ioctl(fp, com, data, p) +vn_ioctl(fp, com, data, td) struct file *fp; u_long com; caddr_t data; - struct proc *p; + struct thread *td; { register struct vnode *vp = ((struct vnode *)fp->f_data); struct vattr vattr; @@ -601,7 +601,7 @@ vn_ioctl(fp, com, data, p) case VREG: case VDIR: if (com == FIONREAD) { - error = VOP_GETATTR(vp, &vattr, p->p_ucred, p); + error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td); if (error) return (error); *(int *)data = vattr.va_size - fp->f_offset; @@ -624,18 +624,18 @@ vn_ioctl(fp, com, data, p) *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK; return (0); } - error = VOP_IOCTL(vp, com, data, fp->f_flag, p->p_ucred, p); + error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_proc->p_ucred, td); if (error == 0 && com == TIOCSCTTY) { /* Do nothing if reassigning same control tty */ - if (p->p_session->s_ttyvp == vp) + if (td->td_proc->p_session->s_ttyvp == vp) return (0); /* Get rid of reference to old control tty */ - if (p->p_session->s_ttyvp) - vrele(p->p_session->s_ttyvp); + if (td->td_proc->p_session->s_ttyvp) + vrele(td->td_proc->p_session->s_ttyvp); - p->p_session->s_ttyvp = vp; + td->td_proc->p_session->s_ttyvp = vp; VREF(vp); } return (error); @@ -646,14 +646,14 @@ vn_ioctl(fp, com, data, p) * File table vnode poll routine. */ static int -vn_poll(fp, events, cred, p) +vn_poll(fp, events, cred, td) struct file *fp; int events; struct ucred *cred; - struct proc *p; + struct thread *td; { - return (VOP_POLL(((struct vnode *)fp->f_data), events, cred, p)); + return (VOP_POLL(((struct vnode *)fp->f_data), events, cred, td)); } /* @@ -662,13 +662,13 @@ vn_poll(fp, events, cred, p) */ int #ifndef DEBUG_LOCKS -vn_lock(vp, flags, p) +vn_lock(vp, flags, td) #else -debug_vn_lock(vp, flags, p, filename, line) +debug_vn_lock(vp, flags, td, filename, line) #endif struct vnode *vp; int flags; - struct proc *p; + struct thread *td; #ifdef DEBUG_LOCKS const char *filename; int line; @@ -679,7 +679,7 @@ debug_vn_lock(vp, flags, p, filename, line) do { if ((flags & LK_INTERLOCK) == 0) mtx_lock(&vp->v_interlock); - if ((vp->v_flag & VXLOCK) && vp->v_vxproc != curproc) { + if ((vp->v_flag & VXLOCK) && vp->v_vxproc != curthread) { vp->v_flag |= VXWANT; msleep(vp, &vp->v_interlock, PINOD | PDROP, "vn_lock", 0); @@ -692,7 +692,7 @@ debug_vn_lock(vp, flags, p, filename, line) vp->line = line; #endif error = VOP_LOCK(vp, - flags | LK_NOPAUSE | LK_INTERLOCK, p); + flags | LK_NOPAUSE | LK_INTERLOCK, td); if (error == 0) return (error); } @@ -705,14 +705,14 @@ debug_vn_lock(vp, flags, p, filename, line) * File table vnode close routine. */ static int -vn_closefile(fp, p) +vn_closefile(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { fp->f_ops = &badfileops; return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, - fp->f_cred, p)); + fp->f_cred, td)); } /* @@ -825,14 +825,14 @@ void vfs_write_suspend(mp) struct mount *mp; { - struct proc *p = curproc; + struct thread *td = curthread; if (mp->mnt_kern_flag & MNTK_SUSPEND) return; mp->mnt_kern_flag |= MNTK_SUSPEND; if (mp->mnt_writeopcount > 0) (void) tsleep(&mp->mnt_writeopcount, PUSER - 1, "suspwt", 0); - VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p); + VFS_SYNC(mp, MNT_WAIT, td->td_proc->p_ucred, td); mp->mnt_kern_flag |= MNTK_SUSPENDED; } @@ -865,7 +865,7 @@ vn_kqfilter(struct file *fp, struct knote *kn) */ int vn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, int *buflen, char *buf, struct proc *p) + const char *attrname, int *buflen, char *buf, struct thread *td) { struct uio auio; struct iovec iov; @@ -878,18 +878,18 @@ vn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace, auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; auio.uio_resid = *buflen; if ((ioflg & IO_NODELOCKED) == 0) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* authorize attribute retrieval as kernel */ - error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, NULL, p); + error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, NULL, td); if ((ioflg & IO_NODELOCKED) == 0) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error == 0) { *buflen = *buflen - auio.uio_resid; @@ -903,7 +903,7 @@ vn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace, */ int vn_extattr_set(struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, int buflen, char *buf, struct proc *p) + const char *attrname, int buflen, char *buf, struct thread *td) { struct uio auio; struct iovec iov; @@ -917,22 +917,22 @@ vn_extattr_set(struct vnode *vp, int ioflg, int attrnamespace, auio.uio_iovcnt = 1; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; auio.uio_resid = buflen; if ((ioflg & IO_NODELOCKED) == 0) { if ((error = vn_start_write(vp, &mp, V_WAIT)) != 0) return (error); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); } /* authorize attribute setting as kernel */ - error = VOP_SETEXTATTR(vp, attrnamespace, attrname, &auio, NULL, p); + error = VOP_SETEXTATTR(vp, attrnamespace, attrname, &auio, NULL, td); if ((ioflg & IO_NODELOCKED) == 0) { vn_finished_write(mp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } return (error); @@ -940,7 +940,7 @@ vn_extattr_set(struct vnode *vp, int ioflg, int attrnamespace, int vn_extattr_rm(struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, struct proc *p) + const char *attrname, struct thread *td) { struct mount *mp; int error; @@ -948,15 +948,15 @@ vn_extattr_rm(struct vnode *vp, int ioflg, int attrnamespace, if ((ioflg & IO_NODELOCKED) == 0) { if ((error = vn_start_write(vp, &mp, V_WAIT)) != 0) return (error); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); } /* authorize attribute removal as kernel */ - error = VOP_SETEXTATTR(vp, attrnamespace, attrname, NULL, NULL, p); + error = VOP_SETEXTATTR(vp, attrnamespace, attrname, NULL, NULL, td); if ((ioflg & IO_NODELOCKED) == 0) { vn_finished_write(mp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } return (error); diff --git a/sys/kern/vnode_if.pl b/sys/kern/vnode_if.pl index 53236e5..32eabfe 100644 --- a/sys/kern/vnode_if.pl +++ b/sys/kern/vnode_if.pl @@ -322,8 +322,8 @@ line: while (<SRC>) { printf CFILE "\t%s,\n", &find_arg_with_type('struct vnode **'); # cred (if any) printf CFILE "\t%s,\n", &find_arg_with_type('struct ucred *'); - # proc (if any) - printf CFILE "\t%s,\n", &find_arg_with_type('struct proc *'); + # thread (if any) + printf CFILE "\t%s,\n", &find_arg_with_type('struct thread *'); # componentname printf CFILE "\t%s,\n", &find_arg_with_type('struct componentname *'); # transport layer information diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index e275617..43ff6b5 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -59,7 +59,7 @@ # vop_islocked { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -126,7 +126,7 @@ vop_open { IN struct vnode *vp; IN int mode; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -136,7 +136,7 @@ vop_close { IN struct vnode *vp; IN int fflag; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -146,7 +146,7 @@ vop_access { IN struct vnode *vp; IN int mode; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -156,7 +156,7 @@ vop_getattr { IN struct vnode *vp; OUT struct vattr *vap; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -166,7 +166,7 @@ vop_setattr { IN struct vnode *vp; IN struct vattr *vap; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -194,7 +194,7 @@ vop_write { # vop_lease { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; IN struct ucred *cred; IN int flag; }; @@ -208,7 +208,7 @@ vop_ioctl { IN caddr_t data; IN int fflag; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -218,7 +218,7 @@ vop_poll { IN struct vnode *vp; IN int events; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -244,7 +244,7 @@ vop_fsync { IN struct vnode *vp; IN struct ucred *cred; IN int waitfor; - IN struct proc *p; + IN struct thread *td; }; # @@ -341,7 +341,7 @@ vop_readlink { # vop_inactive { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -349,7 +349,7 @@ vop_inactive { # vop_reclaim { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -358,7 +358,7 @@ vop_reclaim { vop_lock { IN struct vnode *vp; IN int flags; - IN struct proc *p; + IN struct thread *td; }; # @@ -367,7 +367,7 @@ vop_lock { vop_unlock { IN struct vnode *vp; IN int flags; - IN struct proc *p; + IN struct thread *td; }; # @@ -479,7 +479,7 @@ vop_getacl { IN acl_type_t type; OUT struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -490,7 +490,7 @@ vop_setacl { IN acl_type_t type; IN struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -501,7 +501,7 @@ vop_aclcheck { IN acl_type_t type; IN struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -513,7 +513,7 @@ vop_getextattr { IN const char *name; INOUT struct uio *uio; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -525,7 +525,7 @@ vop_setextattr { IN const char *name; INOUT struct uio *uio; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -534,7 +534,7 @@ vop_setextattr { vop_createvobject { IN struct vnode *vp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # diff --git a/sys/modules/Makefile b/sys/modules/Makefile index e16cc7f..c6d0f4b 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -49,13 +49,11 @@ SUBDIR= 3dfx \ mii \ mlx \ msdosfs \ - ncp \ nfs \ nge \ nmdm \ ntfs \ nullfs \ - nwfs \ pcn \ portalfs \ procfs \ @@ -99,6 +97,9 @@ SUBDIR= 3dfx \ wx \ xl +#removed while KSE settles in: +# ncp \ +# nwfs \ # XXX some of these can move to the general case when de-i386'ed .if ${MACHINE_ARCH} == "i386" SUBDIR+=aac \ @@ -120,13 +121,14 @@ SUBDIR+=aac \ pecoff \ ray \ s3 \ - smbfs \ splash \ sr \ streams \ vesa \ wi .endif +#removed while KSE settles in: +# smbfs \ .if ${MACHINE} == "pc98" SUBDIR+=snc diff --git a/sys/modules/netgraph/Makefile b/sys/modules/netgraph/Makefile index 7f65322..466a4d4 100644 --- a/sys/modules/netgraph/Makefile +++ b/sys/modules/netgraph/Makefile @@ -6,6 +6,7 @@ SUBDIR= async \ bridge \ cisco \ echo \ + eiface \ ether \ frame_relay \ hole \ diff --git a/sys/net/bpf.c b/sys/net/bpf.c index cd12323..874fcb6 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -313,11 +313,11 @@ bpf_detachd(d) */ /* ARGSUSED */ static int -bpfopen(dev, flags, fmt, p) +bpfopen(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { struct bpf_d *d; @@ -353,11 +353,11 @@ bpfopen(dev, flags, fmt, p) */ /* ARGSUSED */ static int -bpfclose(dev, flags, fmt, p) +bpfclose(dev, flags, fmt, td) dev_t dev; int flags; int fmt; - struct proc *p; + struct thread *td; { struct bpf_d *d = dev->si_drv1; @@ -585,12 +585,12 @@ reset_d(d) */ /* ARGSUSED */ static int -bpfioctl(dev, cmd, addr, flags, p) +bpfioctl(dev, cmd, addr, flags, td) dev_t dev; u_long cmd; caddr_t addr; int flags; - struct proc *p; + struct thread *td; { struct bpf_d *d = dev->si_drv1; int error = 0; @@ -966,10 +966,10 @@ bpf_setif(d, ifr) * Otherwise, return false but make a note that a selwakeup() must be done. */ int -bpfpoll(dev, events, p) +bpfpoll(dev, events, td) register dev_t dev; int events; - struct proc *p; + struct thread *td; { struct bpf_d *d; int revents; @@ -990,7 +990,7 @@ bpfpoll(dev, events, p) if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0)) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &d->bd_sel); + selrecord(curthread, &d->bd_sel); } BPFD_UNLOCK(d); return (revents); diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h index 9172c7f..7f61d70 100644 --- a/sys/net/bpfdesc.h +++ b/sys/net/bpfdesc.h @@ -84,7 +84,7 @@ struct bpf_d { #if BSD < 199103 u_char bd_selcoll; /* true if selects collide */ int bd_timedout; - struct proc * bd_selproc; /* process that last selected us */ + struct thread * bd_selthread; /* process that last selected us */ #else u_char bd_pad; /* explicit alignment */ struct selinfo bd_sel; /* bsd select info */ diff --git a/sys/net/if.c b/sys/net/if.c index 7ff94c7..c08d494 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -952,11 +952,11 @@ if_withname(sa) * Interface ioctls. */ int -ifioctl(so, cmd, data, p) +ifioctl(so, cmd, data, td) struct socket *so; u_long cmd; caddr_t data; - struct proc *p; + struct thread *td; { register struct ifnet *ifp; register struct ifreq *ifr; @@ -975,7 +975,7 @@ ifioctl(so, cmd, data, p) switch (cmd) { case SIOCIFCREATE: case SIOCIFDESTROY: - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); return ((cmd == SIOCIFCREATE) ? if_clone_create(ifr->ifr_name, sizeof(ifr->ifr_name)) : @@ -1007,7 +1007,7 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFFLAGS: - error = suser(p); + error = suser_td(td); if (error) return (error); ifr->ifr_prevflags = ifp->if_flags; @@ -1032,7 +1032,7 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFMETRIC: - error = suser(p); + error = suser_td(td); if (error) return (error); ifp->if_metric = ifr->ifr_metric; @@ -1040,7 +1040,7 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFPHYS: - error = suser(p); + error = suser_td(td); if (error) return error; if (!ifp->if_ioctl) @@ -1054,7 +1054,7 @@ ifioctl(so, cmd, data, p) { u_long oldmtu = ifp->if_mtu; - error = suser(p); + error = suser_td(td); if (error) return (error); if (ifp->if_ioctl == NULL) @@ -1079,7 +1079,7 @@ ifioctl(so, cmd, data, p) case SIOCADDMULTI: case SIOCDELMULTI: - error = suser(p); + error = suser_td(td); if (error) return (error); @@ -1109,7 +1109,7 @@ ifioctl(so, cmd, data, p) case SIOCSLIFPHYADDR: case SIOCSIFMEDIA: case SIOCSIFGENERIC: - error = suser(p); + error = suser_td(td); if (error) return (error); if (ifp->if_ioctl == 0) @@ -1133,7 +1133,7 @@ ifioctl(so, cmd, data, p) return ((*ifp->if_ioctl)(ifp, cmd, data)); case SIOCSIFLLADDR: - error = suser(p); + error = suser_td(td); if (error) return (error); return if_setlladdr(ifp, @@ -1146,7 +1146,7 @@ ifioctl(so, cmd, data, p) #ifndef COMPAT_43 error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, - ifp, p)); + ifp, td)); #else { int ocmd = cmd; @@ -1187,7 +1187,7 @@ ifioctl(so, cmd, data, p) error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, - ifp, p)); + ifp, td)); switch (ocmd) { case OSIOCGIFADDR: diff --git a/sys/net/if.h b/sys/net/if.h index 088c7ef..70428bf 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -297,7 +297,7 @@ __END_DECLS #endif #ifdef _KERNEL -struct proc; +struct thread; /* XXX - this should go away soon. */ #include <net/if_var.h> diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 86c541b..95b9684 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -338,13 +338,14 @@ pppdealloc(sc) * Ioctl routine for generic ppp devices. */ int -pppioctl(sc, cmd, data, flag, p) +pppioctl(sc, cmd, data, flag, td) struct ppp_softc *sc; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { + struct proc *p = td->td_proc; int s, flags, mru, npx; u_int nb; int error = 0; diff --git a/sys/net/if_pppvar.h b/sys/net/if_pppvar.h index 77456f7..cc71846 100644 --- a/sys/net/if_pppvar.h +++ b/sys/net/if_pppvar.h @@ -103,7 +103,7 @@ extern struct ppp_softc ppp_softc[]; struct ppp_softc *pppalloc __P((pid_t pid)); void pppdealloc __P((struct ppp_softc *sc)); int pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data, - int flag, struct proc *p)); + int flag, struct thread *td)); int pppoutput __P((struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct rtentry *rtp)); void ppp_restart __P((struct ppp_softc *sc)); diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index b681a0b..35d67e2 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -72,6 +72,7 @@ #include <sys/systm.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/dkstat.h> #include <sys/socket.h> #include <sys/sockio.h> @@ -178,10 +179,10 @@ static void sldestroy __P((struct sl_softc *sc)); static struct mbuf *sl_btom __P((struct sl_softc *, int)); static timeout_t sl_keepalive; static timeout_t sl_outfill; -static int slclose __P((struct tty *,int)); -static int slinput __P((int, struct tty *)); +static l_close_t slclose; +static l_rint_t slinput; +static l_ioctl_t sltioctl; static int slioctl __P((struct ifnet *, u_long, caddr_t)); -static int sltioctl __P((struct tty *, u_long, caddr_t, int, struct proc *)); static int slopen __P((dev_t, struct tty *)); static int sloutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *)); @@ -336,11 +337,10 @@ slopen(dev, tp) dev_t dev; register struct tty *tp; { - struct proc *p = curproc; /* XXX */ register struct sl_softc *sc; int s, error; - error = suser(p); + error = suser_td(curthread); if (error) return (error); @@ -437,12 +437,12 @@ slclose(tp,flag) */ /* ARGSUSED */ static int -sltioctl(tp, cmd, data, flag, p) +sltioctl(tp, cmd, data, flag, td) struct tty *tp; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct sl_softc *sc = (struct sl_softc *)tp->t_sc, *nc; int s, unit, wasup; diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 6e60b5b..f41fbd3 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -389,17 +389,17 @@ tapcreate(dev) * to open tunnel. must be superuser */ static int -tapopen(dev, flag, mode, p) +tapopen(dev, flag, mode, td) dev_t dev; int flag; int mode; - struct proc *p; + struct thread *td; { struct tap_softc *tp = NULL; int unit, error; struct resource *r = NULL; - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); unit = dev2unit(dev) & TAPMAXUNIT; @@ -428,7 +428,7 @@ tapopen(dev, flag, mode, p) bcopy(tp->arpcom.ac_enaddr, tp->ether_addr, sizeof(tp->ether_addr)); tp->tap_unit = r; - tp->tap_pid = p->p_pid; + tp->tap_pid = td->td_proc->p_pid; tp->tap_flags |= TAP_OPEN; TAPDEBUG("%s%d is open. minor = %#x\n", @@ -444,11 +444,11 @@ tapopen(dev, flag, mode, p) * close the device - mark i/f down & delete routing info */ static int -tapclose(dev, foo, bar, p) +tapclose(dev, foo, bar, td) dev_t dev; int foo; int bar; - struct proc *p; + struct thread *td; { int s, error; struct tap_softc *tp = dev->si_drv1; @@ -643,12 +643,12 @@ tapifstart(ifp) * the cdevsw interface is now pretty minimal */ static int -tapioctl(dev, cmd, data, flag, p) +tapioctl(dev, cmd, data, flag, td) dev_t dev; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct tap_softc *tp = dev->si_drv1; struct ifnet *ifp = &tp->tap_if; @@ -911,10 +911,10 @@ tapwrite(dev, uio, flag) * anyway, it either accepts the packet or drops it */ static int -tappoll(dev, events, p) +tappoll(dev, events, td) dev_t dev; int events; - struct proc *p; + struct thread *td; { struct tap_softc *tp = dev->si_drv1; struct ifnet *ifp = &tp->tap_if; @@ -935,7 +935,7 @@ tappoll(dev, events, p) TAPDEBUG("%s%d waiting for data, minor = %#x\n", ifp->if_name, ifp->if_unit, minor(dev)); - selrecord(p, &tp->tap_rsel); + selrecord(curthread, &tp->tap_rsel); } } diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 1e6f19b..92bf7f6 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -259,7 +259,7 @@ tuncreate(dev_t dev) } static int -tunopen(dev_t dev, int flag, int mode, struct proc *p) +tunopen(dev_t dev, int flag, int mode, struct thread *td) { struct resource *r; struct ifnet *ifp; @@ -284,7 +284,7 @@ tunopen(dev_t dev, int flag, int mode, struct proc *p) } KASSERT(!(tp->tun_flags & TUN_OPEN), ("Resource & flags out-of-sync")); tp->r_unit = r; - tp->tun_pid = p->p_pid; + tp->tun_pid = td->td_proc->p_pid; ifp = &tp->tun_if; tp->tun_flags |= TUN_OPEN; TUNDEBUG("%s%d: open\n", ifp->if_name, ifp->if_unit); @@ -297,7 +297,7 @@ tunopen(dev_t dev, int flag, int mode, struct proc *p) * routing info */ static int -tunclose(dev_t dev, int foo, int bar, struct proc *p) +tunclose(dev_t dev, int foo, int bar, struct thread *td) { struct tun_softc *tp; struct ifnet *ifp; @@ -520,7 +520,7 @@ tunoutput( * the cdevsw interface is now pretty minimal. */ static int -tunioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +tunioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { int s; int error; @@ -532,7 +532,8 @@ tunioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) tunp = (struct tuninfo *)data; if (tunp->mtu < IF_MINMTU) return (EINVAL); - if (tp->tun_if.if_mtu != tunp->mtu && (error = suser(p)) != 0) + if (tp->tun_if.if_mtu != tunp->mtu + && (error = suser_td(td)) != 0) return (error); tp->tun_if.if_mtu = tunp->mtu; tp->tun_if.if_type = tunp->type; @@ -584,7 +585,7 @@ tunioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } break; case TUNSIFPID: - tp->tun_pid = curproc->p_pid; + tp->tun_pid = curthread->td_proc->p_pid; break; case FIONBIO: break; @@ -790,7 +791,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag) * anyway, it either accepts the packet or drops it. */ static int -tunpoll(dev_t dev, int events, struct proc *p) +tunpoll(dev_t dev, int events, struct thread *td) { int s; struct tun_softc *tp = dev->si_drv1; @@ -808,7 +809,7 @@ tunpoll(dev_t dev, int events, struct proc *p) } else { TUNDEBUG("%s%d: tunpoll waiting\n", ifp->if_name, ifp->if_unit); - selrecord(p, &tp->tun_rsel); + selrecord(curthread, &tp->tun_rsel); } } if (events & (POLLOUT | POLLWRNORM)) diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 5a4d92f..597eb64 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -67,7 +67,7 @@ * Forward structure declarations for function prototypes [sic]. */ struct mbuf; -struct proc; +struct thread; struct rtentry; struct socket; struct ether_header; @@ -410,7 +410,7 @@ int if_setlladdr __P((struct ifnet *, const u_char *, int)); void if_unroute __P((struct ifnet *, int flag, int fam)); void if_up __P((struct ifnet *)); /*void ifinit __P((void));*/ /* declared in systm.h for main() */ -int ifioctl __P((struct socket *, u_long, caddr_t, struct proc *)); +int ifioctl __P((struct socket *, u_long, caddr_t, struct thread *)); int ifpromisc __P((struct ifnet *, int)); struct ifnet *ifunit __P((const char *)); struct ifnet *if_withname __P((struct sockaddr *)); diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 3a95fdb..635e7ad 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -98,8 +98,8 @@ static int pppopen __P((dev_t dev, struct tty *tp)); static int pppclose __P((struct tty *tp, int flag)); static int pppread __P((struct tty *tp, struct uio *uio, int flag)); static int pppwrite __P((struct tty *tp, struct uio *uio, int flag)); -static int ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, int flag, - struct proc *)); +static int ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, + int flag, struct thread *td)); static int pppinput __P((int c, struct tty *tp)); static int pppstart __P((struct tty *tp)); @@ -171,11 +171,11 @@ pppopen(dev, tp) dev_t dev; register struct tty *tp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register struct ppp_softc *sc; int error, s; - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) return (error); s = spltty(); @@ -188,7 +188,7 @@ pppopen(dev, tp) } } - if ((sc = pppalloc(p->p_pid)) == NULL) { + if ((sc = pppalloc(td->td_proc->p_pid)) == NULL) { splx(s); return ENXIO; } @@ -428,12 +428,12 @@ pppwrite(tp, uio, flag) */ /* ARGSUSED */ static int -ppptioctl(tp, cmd, data, flag, p) +ppptioctl(tp, cmd, data, flag, td) struct tty *tp; u_long cmd; caddr_t data; int flag; - struct proc *p; + struct thread *td; { struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc; int error, s; @@ -444,7 +444,7 @@ ppptioctl(tp, cmd, data, flag, p) error = 0; switch (cmd) { case PPPIOCSASYNCMAP: - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) break; sc->sc_asyncmap[0] = *(u_int *)data; break; @@ -454,7 +454,7 @@ ppptioctl(tp, cmd, data, flag, p) break; case PPPIOCSRASYNCMAP: - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) break; sc->sc_rasyncmap = *(u_int *)data; break; @@ -464,7 +464,7 @@ ppptioctl(tp, cmd, data, flag, p) break; case PPPIOCSXASYNCMAP: - if ((error = suser(p)) != 0) + if ((error = suser_td(td)) != 0) break; s = spltty(); bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap)); @@ -479,7 +479,7 @@ ppptioctl(tp, cmd, data, flag, p) break; default: - error = pppioctl(sc, cmd, data, flag, p); + error = pppioctl(sc, cmd, data, flag, td); if (error == 0 && cmd == PPPIOCSMRU) pppgetm(sc); } diff --git a/sys/net/raw_cb.h b/sys/net/raw_cb.h index 6c079a9..59905085 100644 --- a/sys/net/raw_cb.h +++ b/sys/net/raw_cb.h @@ -62,13 +62,21 @@ struct rawcb { #ifdef _KERNEL extern LIST_HEAD(rawcb_list_head, rawcb) rawcb_list; +/* protosw entries */ +pr_ctlinput_t raw_ctlinput; +pr_init_t raw_init; + +/* usrreq entries */ int raw_attach __P((struct socket *, int)); -void raw_ctlinput __P((int, struct sockaddr *, void *)); void raw_detach __P((struct rawcb *)); void raw_disconnect __P((struct rawcb *)); -void raw_init __P((void)); + +#if 0 /* what the ??? */ +pr_input_t raw_input; +#else void raw_input __P((struct mbuf *, struct sockproto *, struct sockaddr *, struct sockaddr *)); +#endif extern struct pr_usrreqs raw_usrreqs; #endif diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 102ae69..555bd3f 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -150,26 +150,26 @@ raw_uabort(struct socket *so) /* pru_accept is EOPNOTSUPP */ static int -raw_uattach(struct socket *so, int proto, struct proc *p) +raw_uattach(struct socket *so, int proto, struct thread *td) { struct rawcb *rp = sotorawcb(so); int error; if (rp == 0) return EINVAL; - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; return raw_attach(so, proto); } static int -raw_ubind(struct socket *so, struct sockaddr *nam, struct proc *p) +raw_ubind(struct socket *so, struct sockaddr *nam, struct thread *td) { return EINVAL; } static int -raw_uconnect(struct socket *so, struct sockaddr *nam, struct proc *p) +raw_uconnect(struct socket *so, struct sockaddr *nam, struct thread *td) { return EINVAL; } @@ -225,7 +225,7 @@ raw_upeeraddr(struct socket *so, struct sockaddr **nam) static int raw_usend(struct socket *so, int flags, struct mbuf *m, - struct sockaddr *nam, struct mbuf *control, struct proc *p) + struct sockaddr *nam, struct mbuf *control, struct thread *td) { int error; struct rawcb *rp = sotorawcb(so); diff --git a/sys/net/route.h b/sys/net/route.h index bfe72d8..16c59e4 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -271,7 +271,6 @@ extern struct route_cb route_cb; extern struct radix_node_head *rt_tables[AF_MAX+1]; struct ifmultiaddr; -struct proc; void route_init __P((void)); void rt_ifmsg __P((struct ifnet *)); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index ede7ad6..e7f3a2c 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -102,7 +102,7 @@ rts_abort(struct socket *so) /* pru_accept is EOPNOTSUPP */ static int -rts_attach(struct socket *so, int proto, struct proc *p) +rts_attach(struct socket *so, int proto, struct thread *td) { struct rawcb *rp; int s, error; @@ -154,21 +154,21 @@ rts_attach(struct socket *so, int proto, struct proc *p) } static int -rts_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +rts_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_bind(so, nam, p); /* xxx just EINVAL */ + error = raw_usrreqs.pru_bind(so, nam, td); /* xxx just EINVAL */ splx(s); return error; } static int -rts_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +rts_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_connect(so, nam, p); /* XXX just EINVAL */ + error = raw_usrreqs.pru_connect(so, nam, td); /* XXX just EINVAL */ splx(s); return error; } @@ -232,11 +232,11 @@ rts_peeraddr(struct socket *so, struct sockaddr **nam) static int rts_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_send(so, flags, m, nam, control, p); + error = raw_usrreqs.pru_send(so, flags, m, nam, control, td); splx(s); return error; } diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c index 3107225..5144115 100644 --- a/sys/netatalk/at_control.c +++ b/sys/netatalk/at_control.c @@ -43,7 +43,7 @@ static int aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw); int at_control(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p ) + struct ifnet *ifp, struct thread *td ) { struct ifreq *ifr = (struct ifreq *)data; struct sockaddr_at *sat; @@ -99,7 +99,7 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * If we are not superuser, then we don't get to do these ops. */ - if ( suser(p) ) { + if ( suser_td(td) ) { return( EPERM ); } diff --git a/sys/netatalk/at_extern.h b/sys/netatalk/at_extern.h index 8191d4f..583bbec 100644 --- a/sys/netatalk/at_extern.h +++ b/sys/netatalk/at_extern.h @@ -1,3 +1,6 @@ +/* + * $FreeBSD$ + */ struct mbuf; struct sockaddr_at; @@ -16,7 +19,7 @@ extern void aarptfree __P((struct aarptab *)); #endif struct ifnet; -struct proc; +struct thread; struct socket; extern void aarp_clean __P((void)); @@ -24,7 +27,7 @@ extern int at_control __P(( struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, - struct proc *p )); + struct thread *td )); extern u_short at_cksum __P(( struct mbuf *m, int skip)); extern void ddp_init __P((void )); extern struct at_ifaddr *at_ifawithnet __P((struct sockaddr_at *)); diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c index 7390d8d..2dbf0f9 100644 --- a/sys/netatalk/ddp_pcb.c +++ b/sys/netatalk/ddp_pcb.c @@ -23,9 +23,9 @@ static void at_pcbdisconnect( struct ddpcb *ddp ); static void at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr); static int at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, - struct proc *p); + struct thread *td); static int at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, - struct proc *p); + struct thread *td); static void at_pcbdetach(struct socket *so, struct ddpcb *ddp); static int at_pcballoc(struct socket *so); @@ -36,7 +36,7 @@ static u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at )); static int -ddp_attach(struct socket *so, int proto, struct proc *p) +ddp_attach(struct socket *so, int proto, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -74,7 +74,7 @@ ddp_detach(struct socket *so) } static int -ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -85,13 +85,13 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) return( EINVAL); } s = splnet(); - error = at_pcbsetaddr(ddp, nam, p); + error = at_pcbsetaddr(ddp, nam, td); splx(s); return (error); } static int -ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -107,7 +107,7 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) } s = splnet(); - error = at_pcbconnect( ddp, nam, p ); + error = at_pcbconnect( ddp, nam, td ); splx(s); if ( error == 0 ) soisconnected( so ); @@ -152,7 +152,7 @@ ddp_shutdown(struct socket *so) static int ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -173,7 +173,7 @@ ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, } s = splnet(); - error = at_pcbconnect(ddp, addr, p); + error = at_pcbconnect(ddp, addr, td); splx( s ); if ( error ) { return(error); @@ -218,7 +218,7 @@ at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr) } static int -at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) +at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) { struct sockaddr_at lsat, *sat; struct at_ifaddr *aa; @@ -253,7 +253,7 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) return( EINVAL ); } if ( sat->sat_port < ATPORT_RESERVED && - suser(p) ) { + suser_td(td) ) { return( EACCES ); } } @@ -312,7 +312,7 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) } static int -at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) +at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) { struct sockaddr_at *sat = (struct sockaddr_at *)addr; struct route *ro; @@ -401,7 +401,7 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) ddp->ddp_fsat = *sat; if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return(at_pcbsetaddr(ddp, (struct sockaddr *)0, p)); + return(at_pcbsetaddr(ddp, (struct sockaddr *)0, td)); } return( 0 ); } diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index 7390d8d..2dbf0f9 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -23,9 +23,9 @@ static void at_pcbdisconnect( struct ddpcb *ddp ); static void at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr); static int at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, - struct proc *p); + struct thread *td); static int at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, - struct proc *p); + struct thread *td); static void at_pcbdetach(struct socket *so, struct ddpcb *ddp); static int at_pcballoc(struct socket *so); @@ -36,7 +36,7 @@ static u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at )); static int -ddp_attach(struct socket *so, int proto, struct proc *p) +ddp_attach(struct socket *so, int proto, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -74,7 +74,7 @@ ddp_detach(struct socket *so) } static int -ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -85,13 +85,13 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) return( EINVAL); } s = splnet(); - error = at_pcbsetaddr(ddp, nam, p); + error = at_pcbsetaddr(ddp, nam, td); splx(s); return (error); } static int -ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -107,7 +107,7 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) } s = splnet(); - error = at_pcbconnect( ddp, nam, p ); + error = at_pcbconnect( ddp, nam, td ); splx(s); if ( error == 0 ) soisconnected( so ); @@ -152,7 +152,7 @@ ddp_shutdown(struct socket *so) static int ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct ddpcb *ddp; int error = 0; @@ -173,7 +173,7 @@ ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, } s = splnet(); - error = at_pcbconnect(ddp, addr, p); + error = at_pcbconnect(ddp, addr, td); splx( s ); if ( error ) { return(error); @@ -218,7 +218,7 @@ at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr) } static int -at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) +at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) { struct sockaddr_at lsat, *sat; struct at_ifaddr *aa; @@ -253,7 +253,7 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) return( EINVAL ); } if ( sat->sat_port < ATPORT_RESERVED && - suser(p) ) { + suser_td(td) ) { return( EACCES ); } } @@ -312,7 +312,7 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) } static int -at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) +at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) { struct sockaddr_at *sat = (struct sockaddr_at *)addr; struct route *ro; @@ -401,7 +401,7 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) ddp->ddp_fsat = *sat; if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return(at_pcbsetaddr(ddp, (struct sockaddr *)0, p)); + return(at_pcbsetaddr(ddp, (struct sockaddr *)0, td)); } return( 0 ); } diff --git a/sys/netatm/atm_aal5.c b/sys/netatm/atm_aal5.c index ba79a5b..f0beaca 100644 --- a/sys/netatm/atm_aal5.c +++ b/sys/netatm/atm_aal5.c @@ -68,21 +68,21 @@ u_long atm_aal5_recvspace = 64 * 1024; /* XXX */ /* * Local functions */ -static int atm_aal5_attach __P((struct socket *, int, struct proc *)); +static int atm_aal5_attach __P((struct socket *, int, struct thread *td)); static int atm_aal5_detach __P((struct socket *)); static int atm_aal5_bind __P((struct socket *, struct sockaddr *, - struct proc *)); -static int atm_aal5_listen __P((struct socket *, struct proc *)); + struct thread *td)); +static int atm_aal5_listen __P((struct socket *, struct thread *td)); static int atm_aal5_connect __P((struct socket *, struct sockaddr *, - struct proc *)); + struct thread *td)); static int atm_aal5_accept __P((struct socket *, struct sockaddr **)); static int atm_aal5_disconnect __P((struct socket *)); static int atm_aal5_shutdown __P((struct socket *)); static int atm_aal5_send __P((struct socket *, int, KBuffer *, - struct sockaddr *, KBuffer *, struct proc *)); + struct sockaddr *, KBuffer *, struct thread *td)); static int atm_aal5_abort __P((struct socket *)); static int atm_aal5_control __P((struct socket *, u_long, caddr_t, - struct ifnet *, struct proc *)); + struct ifnet *, struct thread *td)); static int atm_aal5_sense __P((struct socket *, struct stat *)); static int atm_aal5_sockaddr __P((struct socket *, struct sockaddr **)); static int atm_aal5_peeraddr __P((struct socket *, struct sockaddr **)); @@ -244,10 +244,10 @@ static Atm_attributes atm_aal5_defattr = { * */ static int -atm_aal5_attach(so, proto, p) +atm_aal5_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { Atm_pcb *atp; @@ -314,10 +314,10 @@ atm_aal5_detach(so) * */ static int -atm_aal5_bind(so, addr, p) +atm_aal5_bind(so, addr, td) struct socket *so; struct sockaddr *addr; - struct proc *p; + struct thread *td; { ATM_INTRO("bind"); @@ -340,9 +340,9 @@ atm_aal5_bind(so, addr, p) * */ static int -atm_aal5_listen(so, p) +atm_aal5_listen(so, td) struct socket *so; - struct proc *p; + struct thread *td; { ATM_INTRO("listen"); @@ -366,10 +366,10 @@ atm_aal5_listen(so, p) * */ static int -atm_aal5_connect(so, addr, p) +atm_aal5_connect(so, addr, td) struct socket *so; struct sockaddr *addr; - struct proc *p; + struct thread *td; { Atm_pcb *atp; @@ -385,7 +385,7 @@ atm_aal5_connect(so, addr, p) size = atp->atp_attr.aal.v.aal5.forward_max_SDU_size; if (size != T_ATM_ABSENT) - if (!sbreserve(&so->so_snd, size, so, p)) { + if (!sbreserve(&so->so_snd, size, so, td)) { err = ENOBUFS; ATM_OUTRO(); } @@ -493,13 +493,13 @@ atm_aal5_shutdown(so) * */ static int -atm_aal5_send(so, flags, m, addr, control, p) +atm_aal5_send(so, flags, m, addr, control, td) struct socket *so; int flags; KBuffer *m; struct sockaddr *addr; KBuffer *control; - struct proc *p; + struct thread *td; { Atm_pcb *atp; @@ -585,12 +585,12 @@ atm_aal5_abort(so) * */ static int -atm_aal5_control(so, cmd, data, ifp, p) +atm_aal5_control(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; struct ifnet *ifp; - struct proc *p; + struct thread *td; { ATM_INTRO("control"); diff --git a/sys/netatm/atm_proto.c b/sys/netatm/atm_proto.c index c28f919..6de7a83 100644 --- a/sys/netatm/atm_proto.c +++ b/sys/netatm/atm_proto.c @@ -158,10 +158,10 @@ atm_proto_notsupp1(so) * */ int -atm_proto_notsupp2(so, addr, p) +atm_proto_notsupp2(so, addr, td) struct socket *so; struct sockaddr *addr; - struct proc *p; + struct thread *td; { return (EOPNOTSUPP); } @@ -203,13 +203,13 @@ atm_proto_notsupp3(so, addr) * */ int -atm_proto_notsupp4(so, i, m, addr, m2, p) +atm_proto_notsupp4(so, i, m, addr, m2, td) struct socket *so; int i; KBuffer *m; struct sockaddr *addr; KBuffer *m2; - struct proc *p; + struct thread *td; { return (EOPNOTSUPP); } diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c index 6965d9c..361665b 100644 --- a/sys/netatm/atm_usrreq.c +++ b/sys/netatm/atm_usrreq.c @@ -62,9 +62,9 @@ __RCSID("@(#) $FreeBSD$"); /* * Local functions */ -static int atm_dgram_attach __P((struct socket *, int, struct proc *)); +static int atm_dgram_attach __P((struct socket *, int, struct thread *)); static int atm_dgram_control __P((struct socket *, u_long, caddr_t, - struct ifnet *, struct proc *)); + struct ifnet *, struct thread *)); static int atm_dgram_info __P((caddr_t)); @@ -143,10 +143,10 @@ struct pr_usrreqs atm_dgram_usrreqs = { * */ static int -atm_dgram_attach(so, proto, p) +atm_dgram_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { ATM_INTRO(); @@ -173,12 +173,12 @@ atm_dgram_attach(so, proto, p) * */ static int -atm_dgram_control(so, cmd, data, ifp, p) +atm_dgram_control(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; struct ifnet *ifp; - struct proc *p; + struct thread *td; { ATM_INTRO(); @@ -192,7 +192,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct atmcfgreq *acp = (struct atmcfgreq *)data; struct atm_pif *pip; - if (p && (suser(p) != 0)) + if (td && (suser_td(td) != 0)) ATM_RETERR(EPERM); switch (acp->acr_opcode) { @@ -225,7 +225,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct atmaddreq *aap = (struct atmaddreq *)data; Atm_endpoint *epp; - if (p && (suser(p) != 0)) + if (td && (suser_td(td) != 0)) ATM_RETERR(EPERM); switch (aap->aar_opcode) { @@ -275,7 +275,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct sigmgr *smp; Atm_endpoint *epp; - if (p && (suser(p) != 0)) + if (td && (suser_td(td) != 0)) ATM_RETERR(EPERM); switch (adp->adr_opcode) { @@ -328,7 +328,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct sigmgr *smp; struct ifnet *ifp2; - if (p && (suser(p) != 0)) + if (td && (suser_td(td) != 0)) ATM_RETERR(EPERM); switch (asp->asr_opcode) { diff --git a/sys/netatm/atm_var.h b/sys/netatm/atm_var.h index 66edeb5..4c76bab 100644 --- a/sys/netatm/atm_var.h +++ b/sys/netatm/atm_var.h @@ -150,10 +150,10 @@ struct atm_nif * #if (defined(__FreeBSD__) && (BSD >= 199506)) int atm_proto_notsupp1 __P((struct socket *)); int atm_proto_notsupp2 __P((struct socket *, struct sockaddr *, - struct proc *)); + struct thread *)); int atm_proto_notsupp3 __P((struct socket *, struct sockaddr **)); int atm_proto_notsupp4 __P((struct socket *, int, KBuffer *, - struct sockaddr *, KBuffer *, struct proc *)); + struct sockaddr *, KBuffer *, struct thread *)); #endif /* atm_signal.c */ diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index 18faa65..69e1b35 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -609,6 +609,9 @@ ng_ether_rcvdata(hook_p hook, item_p item) if (hook == priv->upper) return ng_ether_rcv_upper(node, m, meta); panic("%s: weird hook", __FUNCTION__); +#ifdef RESTARTABLE_PANICS /* so we don;t get an error msg in LINT */ + return NULL; +#endif } /* diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c index c29aa7d..b47fe2c 100644 --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -548,7 +548,7 @@ ng_ksocket_constructor(node_p node) static int ng_ksocket_newhook(node_p node, hook_p hook, const char *name0) { - struct proc *p = curproc ? curproc : &proc0; /* XXX broken */ + struct thread *td = curthread ? curthread : thread0; /* XXX broken */ const priv_p priv = NG_NODE_PRIVATE(node); char *s1, *s2, name[NG_HOOKLEN+1]; int family, type, protocol, error; @@ -586,7 +586,7 @@ ng_ksocket_newhook(node_p node, hook_p hook, const char *name0) return (EINVAL); /* Create the socket */ - error = socreate(family, &priv->so, type, protocol, p); + error = socreate(family, &priv->so, type, protocol, td); if (error != 0) return (error); @@ -656,7 +656,7 @@ ng_ksocket_connect(hook_p hook) static int ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) { - struct proc *p = curproc ? curproc : &proc0; /* XXX broken */ + struct thread *td = curthread ? curthread : thread0; /* XXX broken */ const priv_p priv = NG_NODE_PRIVATE(node); struct socket *const so = priv->so; struct ng_mesg *resp = NULL; @@ -681,7 +681,7 @@ ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) ERROUT(ENXIO); /* Bind */ - error = sobind(so, sa, p); + error = sobind(so, sa, td); break; } case NGM_KSOCKET_LISTEN: @@ -693,7 +693,7 @@ ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) ERROUT(ENXIO); /* Listen */ - error = solisten(so, *((int32_t *)msg->data), p); + error = solisten(so, *((int32_t *)msg->data), td); break; } @@ -744,7 +744,7 @@ ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) /* Do connect */ if ((so->so_state & SS_ISCONNECTING) != 0) ERROUT(EALREADY); - if ((error = soconnect(so, sa, p)) != 0) { + if ((error = soconnect(so, sa, td)) != 0) { so->so_state &= ~SS_ISCONNECTING; ERROUT(error); } @@ -821,7 +821,7 @@ ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) sopt.sopt_dir = SOPT_GET; sopt.sopt_level = ksopt->level; sopt.sopt_name = ksopt->name; - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; sopt.sopt_valsize = NG_KSOCKET_MAX_OPTLEN; ksopt = (struct ng_ksocket_sockopt *)resp->data; sopt.sopt_val = ksopt->value; @@ -855,7 +855,7 @@ ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook) sopt.sopt_name = ksopt->name; sopt.sopt_val = ksopt->value; sopt.sopt_valsize = valsize; - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); break; } @@ -881,7 +881,7 @@ done: static int ng_ksocket_rcvdata(hook_p hook, item_p item) { - struct proc *p = curproc ? curproc : &proc0; /* XXX broken */ + struct thread *td = curthread ? curthread : thread0; /* XXX broken */ const node_p node = NG_HOOK_NODE(hook); const priv_p priv = NG_NODE_PRIVATE(node); struct socket *const so = priv->so; @@ -890,7 +890,7 @@ ng_ksocket_rcvdata(hook_p hook, item_p item) NGI_GET_M(item, m); NG_FREE_ITEM(item); - error = (*so->so_proto->pr_usrreqs->pru_sosend)(so, 0, 0, m, 0, 0, p); + error = (*so->so_proto->pr_usrreqs->pru_sosend)(so, 0, 0, m, 0, 0, td); return (error); } @@ -1053,7 +1053,7 @@ ng_ksocket_incoming2(node_p node, hook_p hook, void *arg1, int waitflag) } /* Read and forward available mbuf's */ - auio.uio_procp = NULL; + auio.uio_td = NULL; auio.uio_resid = 1000000000; flags = MSG_DONTWAIT; do { diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index e0bd485..a1d6ce8 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -388,6 +388,9 @@ ng_mppc_rcvdata(hook_p hook, item_p item) /* Oops */ panic("%s: unknown hook", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return (EINVAL); +#endif } /* diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c index 5daf600..fa29c6b 100644 --- a/sys/netgraph/ng_parse.c +++ b/sys/netgraph/ng_parse.c @@ -378,6 +378,9 @@ ng_int8_unparse(const struct ng_parse_type *type, break; default: panic("%s: unknown type", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return(0); +#endif } NG_PARSE_APPEND(fmt, fval); *off += sizeof(int8_t); @@ -472,6 +475,9 @@ ng_int16_unparse(const struct ng_parse_type *type, break; default: panic("%s: unknown type", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return(0); +#endif } NG_PARSE_APPEND(fmt, fval); *off += sizeof(int16_t); @@ -566,6 +572,9 @@ ng_int32_unparse(const struct ng_parse_type *type, break; default: panic("%s: unknown type", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return(0); +#endif } NG_PARSE_APPEND(fmt, fval); *off += sizeof(int32_t); @@ -659,6 +668,9 @@ ng_int64_unparse(const struct ng_parse_type *type, break; default: panic("%s: unknown type", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return(0); +#endif } NG_PARSE_APPEND(fmt, fval); *off += sizeof(int64_t); diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 09b8ab7..a7e7e20 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -117,7 +117,7 @@ static int ng_attach_data(struct socket *so); static int ng_attach_cntl(struct socket *so); static int ng_attach_common(struct socket *so, int type); static void ng_detach_common(struct ngpcb *pcbp, int type); -/*static int ng_internalize(struct mbuf *m, struct proc *p); */ +/*static int ng_internalize(struct mbuf *m, struct thread *p); */ static int ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp); static int ng_bind(struct sockaddr *nam, struct ngpcb *pcbp); @@ -162,11 +162,11 @@ LIST_HEAD(, ngpcb) ngsocklist; ***************************************************************/ static int -ngc_attach(struct socket *so, int proto, struct proc *p) +ngc_attach(struct socket *so, int proto, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); - if (suser(p)) + if (suser_td(td)) return (EPERM); if (pcbp != NULL) return (EISCONN); @@ -186,7 +186,7 @@ ngc_detach(struct socket *so) static int ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr; @@ -200,7 +200,7 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, goto release; } #ifdef NOTYET - if (control && (error = ng_internalize(control, p))) { + if (control && (error = ng_internalize(control, td))) { if (pcbp->sockdata == NULL) { error = ENOTCONN; goto release; @@ -287,7 +287,7 @@ release: } static int -ngc_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +ngc_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); @@ -297,7 +297,7 @@ ngc_bind(struct socket *so, struct sockaddr *nam, struct proc *p) } static int -ngc_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +ngc_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { printf(" program tried to connect control socket to remote node\n "); /* @@ -312,7 +312,7 @@ printf(" program tried to connect control socket to remote node\n "); ***************************************************************/ static int -ngd_attach(struct socket *so, int proto, struct proc *p) +ngd_attach(struct socket *so, int proto, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); @@ -334,7 +334,7 @@ ngd_detach(struct socket *so) static int ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr; @@ -402,7 +402,7 @@ release: } static int -ngd_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +ngd_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct ngpcb *const pcbp = sotongpcb(so); @@ -567,9 +567,9 @@ ng_detach_common(struct ngpcb *pcbp, int which) * which after all is the purpose of this whole system. */ static int -ng_internalize(struct mbuf *control, struct proc *p) +ng_internalize(struct mbuf *control, struct thread *td) { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct cmsghdr *cm = mtod(control, struct cmsghdr *); struct file *fp; struct vnode *vn; diff --git a/sys/netgraph/ng_tee.c b/sys/netgraph/ng_tee.c index e95c41f..7b47617 100644 --- a/sys/netgraph/ng_tee.c +++ b/sys/netgraph/ng_tee.c @@ -309,8 +309,12 @@ ngt_rcvdata(hook_p hook, item_p item) } else if (hinfo == &sc->left2right) { dup = NULL; dest = &sc->left; - } else + } else { panic("%s: no hook!", __FUNCTION__); +#ifdef RESTARTABLE_PANICS + return(EINVAL); +#endif + } /* Update stats on incoming hook */ hinfo->stats.inOctets += m->m_pkthdr.len; diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c index 690892f..cb3c770 100644 --- a/sys/netgraph/ng_tty.c +++ b/sys/netgraph/ng_tty.c @@ -120,7 +120,7 @@ static int ngt_close(struct tty *tp, int flag); static int ngt_read(struct tty *tp, struct uio *uio, int flag); static int ngt_write(struct tty *tp, struct uio *uio, int flag); static int ngt_tioctl(struct tty *tp, - u_long cmd, caddr_t data, int flag, struct proc *); + u_long cmd, caddr_t data, int flag, struct thread *); static int ngt_input(int c, struct tty *tp); static int ngt_start(struct tty *tp); @@ -184,13 +184,13 @@ static int ngt_ldisc; static int ngt_open(dev_t dev, struct tty *tp) { - struct proc *const p = curproc; /* XXX */ + struct thread *const td = curthread; /* XXX */ char name[sizeof(NG_TTY_NODE_TYPE) + 8]; sc_p sc; int s, error; /* Super-user only */ - if ((error = suser(p))) + if ((error = suser_td(td))) return (error); s = splnet(); (void) spltty(); /* XXX is this necessary? */ @@ -304,7 +304,7 @@ ngt_write(struct tty *tp, struct uio *uio, int flag) * We implement the NGIOCGINFO ioctl() defined in ng_message.h. */ static int -ngt_tioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) +ngt_tioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) { const sc_p sc = (sc_p) tp->t_sc; int s, error = 0; diff --git a/sys/netinet/in.c b/sys/netinet/in.c index c0b45c3..d56d28e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -57,7 +57,7 @@ static MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address"); static int in_mask2len __P((struct in_addr *)); static void in_len2mask __P((struct in_addr *, int)); static int in_lifaddr_ioctl __P((struct socket *, u_long, caddr_t, - struct ifnet *, struct proc *)); + struct ifnet *, struct thread *)); static void in_socktrim __P((struct sockaddr_in *)); static int in_ifinit __P((struct ifnet *, @@ -183,12 +183,12 @@ static int in_interfaces; /* number of external internet interfaces */ */ /* ARGSUSED */ int -in_control(so, cmd, data, ifp, p) +in_control(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; register struct ifnet *ifp; - struct proc *p; + struct thread *td; { register struct ifreq *ifr = (struct ifreq *)data; register struct in_ifaddr *ia = 0, *iap; @@ -202,13 +202,13 @@ in_control(so, cmd, data, ifp, p) switch (cmd) { case SIOCALIFADDR: case SIOCDLIFADDR: - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; /*fall through*/ case SIOCGLIFADDR: if (!ifp) return EINVAL; - return in_lifaddr_ioctl(so, cmd, data, ifp, p); + return in_lifaddr_ioctl(so, cmd, data, ifp, td); } /* @@ -257,7 +257,7 @@ in_control(so, cmd, data, ifp, p) case SIOCSIFADDR: case SIOCSIFNETMASK: case SIOCSIFDSTADDR: - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; if (ifp == 0) @@ -293,7 +293,7 @@ in_control(so, cmd, data, ifp, p) break; case SIOCSIFBRDADDR: - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; /* FALLTHROUGH */ @@ -454,12 +454,12 @@ in_control(so, cmd, data, ifp, p) * other values may be returned from in_ioctl() */ static int -in_lifaddr_ioctl(so, cmd, data, ifp, p) +in_lifaddr_ioctl(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; struct ifnet *ifp; - struct proc *p; + struct thread *td; { struct if_laddrreq *iflr = (struct if_laddrreq *)data; struct ifaddr *ifa; @@ -521,7 +521,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp, p) ifra.ifra_mask.sin_len = sizeof(struct sockaddr_in); in_len2mask(&ifra.ifra_mask.sin_addr, iflr->prefixlen); - return in_control(so, SIOCAIFADDR, (caddr_t)&ifra, ifp, p); + return in_control(so, SIOCAIFADDR, (caddr_t)&ifra, ifp, td); } case SIOCGLIFADDR: case SIOCDLIFADDR: @@ -607,7 +607,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp, p) ia->ia_sockmask.sin_len); return in_control(so, SIOCDIFADDR, (caddr_t)&ifra, - ifp, p); + ifp, td); } } } diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 46c10e0..8e41fa2 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -299,7 +299,7 @@ gif_encapcheck4(m, off, proto, arg) dst = (struct sockaddr_in *)sc->gif_pdst; /* LINTED const cast */ - m_copydata((struct mbuf *)m, 0, sizeof(ip), (caddr_t)&ip); + m_copydata(m, 0, sizeof(ip), (caddr_t)&ip); /* check for address match */ addrmatch = 0; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index c967851..0b54024 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -136,10 +136,10 @@ SYSCTL_PROC(_net_inet_ip_portrange, OID_AUTO, hilast, CTLTYPE_INT|CTLFLAG_RW, * Allocate a PCB and associate it with the socket. */ int -in_pcballoc(so, pcbinfo, p) +in_pcballoc(so, pcbinfo, td) struct socket *so; struct inpcbinfo *pcbinfo; - struct proc *p; + struct thread *td; { register struct inpcb *inp; #ifdef IPSEC @@ -175,11 +175,12 @@ in_pcballoc(so, pcbinfo, p) } int -in_pcbbind(inp, nam, p) +in_pcbbind(inp, nam, td) register struct inpcb *inp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { + struct proc *p = td->td_proc; register struct socket *so = inp->inp_socket; unsigned short *lastport; struct sockaddr_in *sin; @@ -494,10 +495,10 @@ in_pcbladdr(inp, nam, plocal_sin) * then pick one. */ int -in_pcbconnect(inp, nam, p) +in_pcbconnect(inp, nam, td) register struct inpcb *inp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct sockaddr_in *ifaddr; struct sockaddr_in *sin = (struct sockaddr_in *)nam; @@ -511,7 +512,7 @@ in_pcbconnect(inp, nam, p) sa.sin_addr.s_addr = htonl(cred->cr_prison->pr_ip); sa.sin_len=sizeof (sa); sa.sin_family = AF_INET; - error = in_pcbbind(inp, (struct sockaddr *)&sa, p); + error = in_pcbbind(inp, (struct sockaddr *)&sa, td); if (error) return (error); } @@ -528,7 +529,7 @@ in_pcbconnect(inp, nam, p) } if (inp->inp_laddr.s_addr == INADDR_ANY) { if (inp->inp_lport == 0) { - error = in_pcbbind(inp, (struct sockaddr *)0, p); + error = in_pcbbind(inp, (struct sockaddr *)0, td); if (error) return (error); } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 2b01db4..8423462 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -278,9 +278,9 @@ extern int ipport_hilastauto; void in_pcbpurgeif0 __P((struct inpcb *, struct ifnet *)); void in_losing __P((struct inpcb *)); void in_rtchange __P((struct inpcb *, int)); -int in_pcballoc __P((struct socket *, struct inpcbinfo *, struct proc *)); -int in_pcbbind __P((struct inpcb *, struct sockaddr *, struct proc *)); -int in_pcbconnect __P((struct inpcb *, struct sockaddr *, struct proc *)); +int in_pcballoc __P((struct socket *, struct inpcbinfo *, struct thread *)); +int in_pcbbind __P((struct inpcb *, struct sockaddr *, struct thread *)); +int in_pcbconnect __P((struct inpcb *, struct sockaddr *, struct thread *)); void in_pcbdetach __P((struct inpcb *)); void in_pcbdisconnect __P((struct inpcb *)); int in_pcbinshash __P((struct inpcb *)); diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index e603cee..7cef6ea 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -211,7 +211,7 @@ struct route; struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *)); void in_delmulti __P((struct in_multi *)); int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *, - struct proc *)); + struct thread *)); void in_rtqdrain __P((void)); void ip_input __P((struct mbuf *)); int in_ifadown __P((struct ifaddr *ifa, int)); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index a571271..d63df09 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -335,7 +335,7 @@ cantsend: } static int -div_attach(struct socket *so, int proto, struct proc *p) +div_attach(struct socket *so, int proto, struct thread *td) { struct inpcb *inp; int error, s; @@ -343,14 +343,14 @@ div_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("div_attach"); - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; error = soreserve(so, div_sendspace, div_recvspace); if (error) return error; s = splnet(); - error = in_pcballoc(so, &divcbinfo, p); + error = in_pcballoc(so, &divcbinfo, td); splx(s); if (error) return error; @@ -392,7 +392,7 @@ div_disconnect(struct socket *so) } static int -div_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +div_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp; int s; @@ -411,7 +411,7 @@ div_bind(struct socket *so, struct sockaddr *nam, struct proc *p) error = EAFNOSUPPORT; } else { ((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY; - error = in_pcbbind(inp, nam, p); + error = in_pcbbind(inp, nam, td); } splx(s); return error; @@ -426,7 +426,7 @@ div_shutdown(struct socket *so) static int div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { /* Packet must have a header (but that's about it) */ if (m->m_len < sizeof (struct ip) && diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 2201e06..86b321e 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1147,7 +1147,7 @@ ip_ctloutput(so, sopt) error = EMSGSIZE; break; } - MGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); + MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); if (m == 0) { error = ENOBUFS; break; @@ -1263,8 +1263,8 @@ ip_ctloutput(so, sopt) break; if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */ break; - priv = (sopt->sopt_p != NULL && - suser(sopt->sopt_p) != 0) ? 0 : 1; + priv = (sopt->sopt_td != NULL && + suser_td(sopt->sopt_td) != 0) ? 0 : 1; req = mtod(m, caddr_t); len = m->m_len; optname = sopt->sopt_name; diff --git a/sys/netinet/ipprotosw.h b/sys/netinet/ipprotosw.h index 97c1c85..bdc4c73 100644 --- a/sys/netinet/ipprotosw.h +++ b/sys/netinet/ipprotosw.h @@ -73,7 +73,6 @@ /* Forward declare these structures referenced from prototypes below. */ struct mbuf; -struct proc; struct sockaddr; struct socket; struct sockopt; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 7a1c9a1..178b483 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -461,7 +461,7 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, &rip_recvspace, 0, "Maximum incoming raw IP datagram size"); static int -rip_attach(struct socket *so, int proto, struct proc *p) +rip_attach(struct socket *so, int proto, struct thread *td) { struct inpcb *inp; int error, s; @@ -469,14 +469,14 @@ rip_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("rip_attach"); - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; error = soreserve(so, rip_sendspace, rip_recvspace); if (error) return error; s = splnet(); - error = in_pcballoc(so, &ripcbinfo, p); + error = in_pcballoc(so, &ripcbinfo, td); splx(s); if (error) return error; @@ -520,7 +520,7 @@ rip_disconnect(struct socket *so) } static int -rip_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = sotoinpcb(so); struct sockaddr_in *addr = (struct sockaddr_in *)nam; @@ -538,7 +538,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct proc *p) } static int -rip_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = sotoinpcb(so); struct sockaddr_in *addr = (struct sockaddr_in *)nam; @@ -564,7 +564,7 @@ rip_shutdown(struct socket *so) static int rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct inpcb *inp = sotoinpcb(so); register u_long dst; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index e093896..baa972d 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1098,7 +1098,7 @@ findpcb: if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) inp->in6p_laddr = ip6->ip6_dst; if (in6_pcbconnect(inp, (struct sockaddr *)sin6, - &proc0)) { + thread0)) { inp->in6p_laddr = laddr6; FREE(sin6, M_SONAME); goto drop; @@ -1119,7 +1119,7 @@ findpcb: laddr = inp->inp_laddr; if (inp->inp_laddr.s_addr == INADDR_ANY) inp->inp_laddr = ip->ip_dst; - if (in_pcbconnect(inp, (struct sockaddr *)sin, &proc0)) { + if (in_pcbconnect(inp, (struct sockaddr *)sin, thread0)) { inp->inp_laddr = laddr; FREE(sin, M_SONAME); goto drop; diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index e093896..baa972d 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -1098,7 +1098,7 @@ findpcb: if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) inp->in6p_laddr = ip6->ip6_dst; if (in6_pcbconnect(inp, (struct sockaddr *)sin6, - &proc0)) { + thread0)) { inp->in6p_laddr = laddr6; FREE(sin6, M_SONAME); goto drop; @@ -1119,7 +1119,7 @@ findpcb: laddr = inp->inp_laddr; if (inp->inp_laddr.s_addr == INADDR_ANY) inp->inp_laddr = ip->ip_dst; - if (in_pcbconnect(inp, (struct sockaddr *)sin, &proc0)) { + if (in_pcbconnect(inp, (struct sockaddr *)sin, thread0)) { inp->inp_laddr = laddr; FREE(sin, M_SONAME); goto drop; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 6f761a0..2485a91 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -88,12 +88,12 @@ */ extern char *tcpstates[]; /* XXX ??? */ -static int tcp_attach __P((struct socket *, struct proc *)); +static int tcp_attach __P((struct socket *, struct thread *td)); static int tcp_connect __P((struct tcpcb *, struct sockaddr *, - struct proc *)); + struct thread *td)); #ifdef INET6 static int tcp6_connect __P((struct tcpcb *, struct sockaddr *, - struct proc *)); + struct thread *td)); #endif /* INET6 */ static struct tcpcb * tcp_disconnect __P((struct tcpcb *)); @@ -116,7 +116,7 @@ static struct tcpcb * * and an internet control block. */ static int -tcp_usr_attach(struct socket *so, int proto, struct proc *p) +tcp_usr_attach(struct socket *so, int proto, struct thread *td) { int s = splnet(); int error; @@ -130,7 +130,7 @@ tcp_usr_attach(struct socket *so, int proto, struct proc *p) goto out; } - error = tcp_attach(so, p); + error = tcp_attach(so, td); if (error) goto out; @@ -189,7 +189,7 @@ tcp_usr_detach(struct socket *so) * Give the socket an address. */ static int -tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { int s = splnet(); int error = 0; @@ -209,7 +209,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) error = EAFNOSUPPORT; goto out; } - error = in_pcbbind(inp, nam, p); + error = in_pcbbind(inp, nam, td); if (error) goto out; COMMON_END(PRU_BIND); @@ -218,7 +218,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) #ifdef INET6 static int -tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { int s = splnet(); int error = 0; @@ -249,11 +249,11 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) in6_sin6_2_sin(&sin, sin6p); inp->inp_vflag |= INP_IPV4; inp->inp_vflag &= ~INP_IPV6; - error = in_pcbbind(inp, (struct sockaddr *)&sin, p); + error = in_pcbbind(inp, (struct sockaddr *)&sin, td); goto out; } } - error = in6_pcbbind(inp, nam, p); + error = in6_pcbbind(inp, nam, td); if (error) goto out; COMMON_END(PRU_BIND); @@ -264,7 +264,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p) * Prepare to accept connections. */ static int -tcp_usr_listen(struct socket *so, struct proc *p) +tcp_usr_listen(struct socket *so, struct thread *td) { int s = splnet(); int error = 0; @@ -273,7 +273,7 @@ tcp_usr_listen(struct socket *so, struct proc *p) COMMON_START(); if (inp->inp_lport == 0) - error = in_pcbbind(inp, (struct sockaddr *)0, p); + error = in_pcbbind(inp, (struct sockaddr *)0, td); if (error == 0) tp->t_state = TCPS_LISTEN; COMMON_END(PRU_LISTEN); @@ -281,7 +281,7 @@ tcp_usr_listen(struct socket *so, struct proc *p) #ifdef INET6 static int -tcp6_usr_listen(struct socket *so, struct proc *p) +tcp6_usr_listen(struct socket *so, struct thread *td) { int s = splnet(); int error = 0; @@ -294,7 +294,7 @@ tcp6_usr_listen(struct socket *so, struct proc *p) if (ip6_mapped_addr_on && (inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) inp->inp_vflag |= INP_IPV4; - error = in6_pcbbind(inp, (struct sockaddr *)0, p); + error = in6_pcbbind(inp, (struct sockaddr *)0, td); } if (error == 0) tp->t_state = TCPS_LISTEN; @@ -310,7 +310,7 @@ tcp6_usr_listen(struct socket *so, struct proc *p) * Send initial segment on connection. */ static int -tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int s = splnet(); int error = 0; @@ -330,10 +330,10 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) goto out; } - if (p && jailed(p->p_ucred)) - prison_remote_ip(p->p_ucred, 0, &sinp->sin_addr.s_addr); + if (td && jailed(td->td_proc->p_ucred)) + prison_remote_ip(td->td_proc->p_ucred, 0, &sinp->sin_addr.s_addr); - if ((error = tcp_connect(tp, nam, p)) != 0) + if ((error = tcp_connect(tp, nam, td)) != 0) goto out; error = tcp_output(tp); COMMON_END(PRU_CONNECT); @@ -341,7 +341,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) #ifdef INET6 static int -tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int s = splnet(); int error = 0; @@ -371,14 +371,14 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) in6_sin6_2_sin(&sin, sin6p); inp->inp_vflag |= INP_IPV4; inp->inp_vflag &= ~INP_IPV6; - if ((error = tcp_connect(tp, (struct sockaddr *)&sin, p)) != 0) + if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0) goto out; error = tcp_output(tp); goto out; } inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; - if ((error = tcp6_connect(tp, nam, p)) != 0) + if ((error = tcp6_connect(tp, nam, td)) != 0) goto out; error = tcp_output(tp); COMMON_END(PRU_CONNECT); @@ -505,7 +505,7 @@ tcp_usr_rcvd(struct socket *so, int flags) */ static int tcp_usr_send(struct socket *so, int flags, struct mbuf *m, - struct sockaddr *nam, struct mbuf *control, struct proc *p) + struct sockaddr *nam, struct mbuf *control, struct thread *td) { int s = splnet(); int error = 0; @@ -558,10 +558,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, */ #ifdef INET6 if (isipv6) - error = tcp6_connect(tp, nam, p); + error = tcp6_connect(tp, nam, td); else #endif /* INET6 */ - error = tcp_connect(tp, nam, p); + error = tcp_connect(tp, nam, td); if (error) goto out; tp->snd_wnd = TTCP_CLIENT_SND_WND; @@ -607,10 +607,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, */ #ifdef INET6 if (isipv6) - error = tcp6_connect(tp, nam, p); + error = tcp6_connect(tp, nam, td); else #endif /* INET6 */ - error = tcp_connect(tp, nam, p); + error = tcp_connect(tp, nam, td); if (error) goto out; tp->snd_wnd = TTCP_CLIENT_SND_WND; @@ -701,10 +701,10 @@ struct pr_usrreqs tcp6_usrreqs = { * Initialize connection parameters and enter SYN-SENT state. */ static int -tcp_connect(tp, nam, p) +tcp_connect(tp, nam, td) register struct tcpcb *tp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; @@ -716,7 +716,7 @@ tcp_connect(tp, nam, p) int error; if (inp->inp_lport == 0) { - error = in_pcbbind(inp, (struct sockaddr *)0, p); + error = in_pcbbind(inp, (struct sockaddr *)0, td); if (error) return error; } @@ -784,10 +784,10 @@ tcp_connect(tp, nam, p) #ifdef INET6 static int -tcp6_connect(tp, nam, p) +tcp6_connect(tp, nam, td) register struct tcpcb *tp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; @@ -799,7 +799,7 @@ tcp6_connect(tp, nam, p) int error; if (inp->inp_lport == 0) { - error = in6_pcbbind(inp, (struct sockaddr *)0, p); + error = in6_pcbbind(inp, (struct sockaddr *)0, td); if (error) return error; } @@ -1008,9 +1008,9 @@ SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_RW, * bufer space, and entering LISTEN state if to accept connections. */ static int -tcp_attach(so, p) +tcp_attach(so, td) struct socket *so; - struct proc *p; + struct thread *td; { register struct tcpcb *tp; struct inpcb *inp; @@ -1024,7 +1024,7 @@ tcp_attach(so, p) if (error) return (error); } - error = in_pcballoc(so, &tcbinfo, p); + error = in_pcballoc(so, &tcbinfo, td); if (error) return (error); inp = sotoinpcb(so); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index ab18872..4af1870 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -134,7 +134,7 @@ static void ip_2_ip6_hdr __P((struct ip6_hdr *ip6, struct ip *ip)); static int udp_detach __P((struct socket *so)); static int udp_output __P((struct inpcb *, struct mbuf *, struct sockaddr *, - struct mbuf *, struct proc *)); + struct mbuf *, struct thread *)); void udp_init() @@ -660,12 +660,12 @@ SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred, udp_getcred, "S,xucred", "Get the xucred of a UDP connection"); static int -udp_output(inp, m, addr, control, p) +udp_output(inp, m, addr, control, td) register struct inpcb *inp; struct mbuf *m; struct sockaddr *addr; struct mbuf *control; - struct proc *p; + struct thread *td; { register struct udpiphdr *ui; register int len = m->m_pkthdr.len; @@ -683,8 +683,8 @@ udp_output(inp, m, addr, control, p) if (addr) { sin = (struct sockaddr_in *)addr; - if (p && jailed(p->p_ucred)) - prison_remote_ip(p->p_ucred, 0, &sin->sin_addr.s_addr); + if (td && jailed(td->td_proc->p_ucred)) + prison_remote_ip(td->td_proc->p_ucred, 0, &sin->sin_addr.s_addr); laddr = inp->inp_laddr; if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; @@ -694,7 +694,7 @@ udp_output(inp, m, addr, control, p) * Must block input while temporarily connected. */ s = splnet(); - error = in_pcbconnect(inp, addr, p); + error = in_pcbconnect(inp, addr, td); if (error) { splx(s); goto release; @@ -800,7 +800,7 @@ udp_abort(struct socket *so) } static int -udp_attach(struct socket *so, int proto, struct proc *p) +udp_attach(struct socket *so, int proto, struct thread *td) { struct inpcb *inp; int s, error; @@ -813,7 +813,7 @@ udp_attach(struct socket *so, int proto, struct proc *p) if (error) return error; s = splnet(); - error = in_pcballoc(so, &udbinfo, p); + error = in_pcballoc(so, &udbinfo, td); splx(s); if (error) return error; @@ -825,7 +825,7 @@ udp_attach(struct socket *so, int proto, struct proc *p) } static int -udp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp; int s, error; @@ -834,13 +834,13 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) if (inp == 0) return EINVAL; s = splnet(); - error = in_pcbbind(inp, nam, p); + error = in_pcbbind(inp, nam, td); splx(s); return error; } static int -udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp; int s, error; @@ -853,9 +853,9 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) return EISCONN; s = splnet(); sin = (struct sockaddr_in *)nam; - if (p && jailed(p->p_ucred)) - prison_remote_ip(p->p_ucred, 0, &sin->sin_addr.s_addr); - error = in_pcbconnect(inp, nam, p); + if (td && jailed(td->td_proc->p_ucred)) + prison_remote_ip(td->td_proc->p_ucred, 0, &sin->sin_addr.s_addr); + error = in_pcbconnect(inp, nam, td); splx(s); if (error == 0) soisconnected(so); @@ -899,7 +899,7 @@ udp_disconnect(struct socket *so) static int udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct inpcb *inp; @@ -908,7 +908,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, m_freem(m); return EINVAL; } - return udp_output(inp, m, addr, control, p); + return udp_output(inp, m, addr, control, td); } int diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index c6d0d60..c17bf55 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -131,7 +131,7 @@ const struct sockaddr_in6 sa6_any = {sizeof(sa6_any), AF_INET6, 0, 0, IN6ADDR_ANY_INIT, 0}; static int in6_lifaddr_ioctl __P((struct socket *, u_long, caddr_t, - struct ifnet *, struct proc *)); + struct ifnet *, struct thread *)); static int in6_ifinit __P((struct ifnet *, struct in6_ifaddr *, struct sockaddr_in6 *, int)); static void in6_unlink_ifa __P((struct in6_ifaddr *, struct ifnet *)); @@ -361,12 +361,12 @@ in6_len2mask(mask, len) #define ia62ifa(ia6) (&((ia6)->ia_ifa)) int -in6_control(so, cmd, data, ifp, p) +in6_control(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; struct ifnet *ifp; - struct proc *p; + struct thread *td; { struct in6_ifreq *ifr = (struct in6_ifreq *)data; struct in6_ifaddr *ia = NULL; @@ -374,7 +374,7 @@ in6_control(so, cmd, data, ifp, p) int privileged; privileged = 0; - if (p == NULL || !suser(p)) + if (td == NULL || !suser_td(td)) privileged++; switch (cmd) { @@ -438,7 +438,7 @@ in6_control(so, cmd, data, ifp, p) return(EPERM); /*fall through*/ case SIOCGLIFADDR: - return in6_lifaddr_ioctl(so, cmd, data, ifp, p); + return in6_lifaddr_ioctl(so, cmd, data, ifp, td); } /* @@ -1317,12 +1317,12 @@ in6_purgeif(ifp) * address encoding scheme. (see figure on page 8) */ static int -in6_lifaddr_ioctl(so, cmd, data, ifp, p) +in6_lifaddr_ioctl(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; struct ifnet *ifp; - struct proc *p; + struct thread *td; { struct if_laddrreq *iflr = (struct if_laddrreq *)data; struct ifaddr *ifa; @@ -1430,7 +1430,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, p) in6_len2mask(&ifra.ifra_prefixmask.sin6_addr, prefixlen); ifra.ifra_flags = iflr->flags & ~IFLR_PREFIX; - return in6_control(so, SIOCAIFADDR_IN6, (caddr_t)&ifra, ifp, p); + return in6_control(so, SIOCAIFADDR_IN6, (caddr_t)&ifra, ifp, td); } case SIOCGLIFADDR: case SIOCDLIFADDR: @@ -1558,7 +1558,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, p) ifra.ifra_flags = ia->ia6_flags; return in6_control(so, SIOCDIFADDR_IN6, (caddr_t)&ifra, - ifp, p); + ifp, td); } } } diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 5e8b3dd..fa67043 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -120,10 +120,10 @@ struct in6_addr zeroin6_addr; int -in6_pcbbind(inp, nam, p) +in6_pcbbind(inp, nam, td) register struct inpcb *inp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct socket *so = inp->inp_socket; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; @@ -187,8 +187,8 @@ in6_pcbbind(inp, nam, p) struct inpcb *t; /* GROSS */ - if (ntohs(lport) < IPV6PORT_RESERVED && p && - suser_xxx(0, p, PRISON_ROOT)) + if (ntohs(lport) < IPV6PORT_RESERVED && td && + suser_xxx(0, td->td_proc, PRISON_ROOT)) return(EACCES); if (so->so_cred->cr_uid != 0 && !IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { @@ -246,7 +246,7 @@ in6_pcbbind(inp, nam, p) } if (lport == 0) { int e; - if ((e = in6_pcbsetport(&inp->in6p_laddr, inp, p)) != 0) + if ((e = in6_pcbsetport(&inp->in6p_laddr, inp, td)) != 0) return(e); } else { @@ -337,10 +337,10 @@ in6_pcbladdr(inp, nam, plocal_addr6) * then pick one. */ int -in6_pcbconnect(inp, nam, p) +in6_pcbconnect(inp, nam, td) register struct inpcb *inp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct in6_addr *addr6; register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; @@ -361,7 +361,7 @@ in6_pcbconnect(inp, nam, p) } if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { if (inp->inp_lport == 0) { - error = in6_pcbbind(inp, (struct sockaddr *)0, p); + error = in6_pcbbind(inp, (struct sockaddr *)0, td); if (error) return (error); } diff --git a/sys/netinet6/in6_pcb.h b/sys/netinet6/in6_pcb.h index df8e2c8..c1d038d 100644 --- a/sys/netinet6/in6_pcb.h +++ b/sys/netinet6/in6_pcb.h @@ -76,9 +76,9 @@ void in6_pcbpurgeif0 __P((struct in6pcb *, struct ifnet *)); void in6_losing __P((struct inpcb *)); -int in6_pcballoc __P((struct socket *, struct inpcbinfo *, struct proc *)); -int in6_pcbbind __P((struct inpcb *, struct sockaddr *, struct proc *)); -int in6_pcbconnect __P((struct inpcb *, struct sockaddr *, struct proc *)); +int in6_pcballoc __P((struct socket *, struct inpcbinfo *, struct thread *)); +int in6_pcbbind __P((struct inpcb *, struct sockaddr *, struct thread *)); +int in6_pcbconnect __P((struct inpcb *, struct sockaddr *, struct thread *)); void in6_pcbdetach __P((struct inpcb *)); void in6_pcbdisconnect __P((struct inpcb *)); int in6_pcbladdr __P((struct inpcb *, struct sockaddr *, @@ -104,7 +104,7 @@ struct in6_addr *in6_selectsrc __P((struct sockaddr_in6 *, struct route_in6 *, struct in6_addr *, int *)); int in6_selecthlim __P((struct in6pcb *, struct ifnet *)); -int in6_pcbsetport __P((struct in6_addr *, struct inpcb *, struct proc *)); +int in6_pcbsetport __P((struct in6_addr *, struct inpcb *, struct thread *)); void init_sin6 __P((struct sockaddr_in6 *sin6, struct mbuf *m)); #endif /* _KERNEL */ diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 708c4f5..3cee6cb 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -325,10 +325,10 @@ in6_selecthlim(in6p, ifp) * share this function by all *bsd*... */ int -in6_pcbsetport(laddr, inp, p) +in6_pcbsetport(laddr, inp, td) struct in6_addr *laddr; struct inpcb *inp; - struct proc *p; + struct thread *td; { struct socket *so = inp->inp_socket; u_int16_t lport = 0, first, last, *lastport; @@ -346,7 +346,7 @@ in6_pcbsetport(laddr, inp, p) last = ipport_hilastauto; lastport = &pcbinfo->lasthi; } else if (inp->inp_flags & INP_LOWPORT) { - if (p && (error = suser(p))) + if (td && (error = suser_td(td))) return error; first = ipport_lowfirstauto; /* 1023 */ last = ipport_lowlastauto; /* 600 */ diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index bb5abc9..c109bfc 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -571,7 +571,7 @@ extern int in6_ifindex2scopeid __P((int)); extern int in6_mask2len __P((struct in6_addr *, u_char *)); extern void in6_len2mask __P((struct in6_addr *, int)); int in6_control __P((struct socket *, - u_long, caddr_t, struct ifnet *, struct proc *)); + u_long, caddr_t, struct ifnet *, struct thread *)); int in6_update_ifa __P((struct ifnet *, struct in6_aliasreq *, struct in6_ifaddr *)); void in6_purgeaddr __P((struct ifaddr *)); diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index f4a0307..c426e13 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -75,6 +75,7 @@ #include <sys/systm.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/domain.h> #include <sys/protosw.h> #include <sys/socket.h> diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 41b25b6c..99e8ddd 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -74,6 +74,7 @@ #include <sys/param.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/proc.h> #include <sys/errno.h> #include <sys/protosw.h> #include <sys/socket.h> @@ -1271,20 +1272,20 @@ ip6_ctloutput(so, sopt) int error, optval; int level, op, optname; int optlen; - struct proc *p; + struct thread *td; if (sopt) { level = sopt->sopt_level; op = sopt->sopt_dir; optname = sopt->sopt_name; optlen = sopt->sopt_valsize; - p = sopt->sopt_p; + td = sopt->sopt_td; } else { panic("ip6_ctloutput: arg soopt is NULL"); } error = optval = 0; - privileged = (p == 0 || suser(p)) ? 0 : 1; + privileged = (td == 0 || suser_td(td)) ? 0 : 1; if (level == IPPROTO_IPV6) { switch (op) { @@ -1440,7 +1441,7 @@ do { \ break; } /* XXX */ - MGET(m, sopt->sopt_p ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); + MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); if (m == 0) { error = ENOBUFS; break; @@ -1708,7 +1709,7 @@ ip6_pcbopts(pktopt, m, so, sopt) { struct ip6_pktopts *opt = *pktopt; int error = 0; - struct proc *p = sopt->sopt_p; + struct thread *td = sopt->sopt_td; int priv = 0; /* turn off any old options. */ @@ -1734,7 +1735,7 @@ ip6_pcbopts(pktopt, m, so, sopt) } /* set options specified by user. */ - if (p && !suser(p)) + if (td && !suser_td(td)) priv = 1; if ((error = ip6_setpktoptions(m, opt, priv, 1)) != 0) { ip6_clearpktopts(opt, 1, -1); /* XXX: discard all options */ @@ -1895,7 +1896,7 @@ ip6_setmoptions(optname, im6op, m) struct route_in6 ro; struct sockaddr_in6 *dst; struct in6_multi_mship *imm; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ if (im6o == NULL) { /* @@ -1990,7 +1991,7 @@ ip6_setmoptions(optname, im6op, m) * all multicast addresses. Only super user is allowed * to do this. */ - if (suser(p)) + if (suser_td(td)) { error = EACCES; break; @@ -2097,7 +2098,7 @@ ip6_setmoptions(optname, im6op, m) } mreq = mtod(m, struct ipv6_mreq *); if (IN6_IS_ADDR_UNSPECIFIED(&mreq->ipv6mr_multiaddr)) { - if (suser(p)) { + if (suser_td(td)) { error = EACCES; break; } diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index dea9c07..f226cc6 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -345,7 +345,7 @@ void rip6_ctlinput __P((int, struct sockaddr *, void *)); int rip6_ctloutput __P((struct socket *so, struct sockopt *sopt)); int rip6_output __P((struct mbuf *, ...)); int rip6_usrreq __P((struct socket *, - int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *)); + int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *)); int dest6_input __P((struct mbuf **, int *, int)); int none_input __P((struct mbuf **, int *, int)); diff --git a/sys/netinet6/ip6protosw.h b/sys/netinet6/ip6protosw.h index c2f38fc..541402b 100644 --- a/sys/netinet6/ip6protosw.h +++ b/sys/netinet6/ip6protosw.h @@ -85,7 +85,7 @@ struct mbuf; struct sockaddr; struct socket; struct domain; -struct proc; +struct thread; struct ip6_hdr; struct icmp6_hdr; struct in6_addr; @@ -140,7 +140,7 @@ struct ip6protosw { /* user-protocol hook */ int (*pr_usrreq) /* user request: see list below */ __P((struct socket *, int, struct mbuf *, - struct mbuf *, struct mbuf *, struct proc *)); + struct mbuf *, struct mbuf *, struct thread *)); /* utility hooks */ void (*pr_init) /* initialization hook */ diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 43aa54e..5f89668 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -543,7 +543,7 @@ rip6_ctloutput(so, sopt) } static int -rip6_attach(struct socket *so, int proto, struct proc *p) +rip6_attach(struct socket *so, int proto, struct thread *td) { struct inpcb *inp; int error, s; @@ -551,14 +551,14 @@ rip6_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("rip6_attach"); - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return error; error = soreserve(so, rip_sendspace, rip_recvspace); if (error) return error; s = splnet(); - error = in_pcballoc(so, &ripcbinfo, p); + error = in_pcballoc(so, &ripcbinfo, td); splx(s); if (error) return error; @@ -611,7 +611,7 @@ rip6_disconnect(struct socket *so) } static int -rip6_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = sotoinpcb(so); struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; @@ -641,7 +641,7 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct proc *p) } static int -rip6_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = sotoinpcb(so); struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; @@ -686,7 +686,7 @@ rip6_shutdown(struct socket *so) static int rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct inpcb *inp = sotoinpcb(so); struct sockaddr_in6 tmp; diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c index 0092f50..37a820d 100644 --- a/sys/netinet6/udp6_output.c +++ b/sys/netinet6/udp6_output.c @@ -121,12 +121,12 @@ #define udp6s_opackets udps_opackets int -udp6_output(in6p, m, addr6, control, p) +udp6_output(in6p, m, addr6, control, td) struct in6pcb *in6p; struct mbuf *m; struct mbuf *control; struct sockaddr *addr6; - struct proc *p; + struct thread *td; { u_int32_t ulen = m->m_pkthdr.len; u_int32_t plen = sizeof(struct udphdr) + ulen; @@ -142,7 +142,7 @@ udp6_output(in6p, m, addr6, control, p) struct sockaddr_in6 tmp; priv = 0; - if (p && !suser(p)) + if (td && !suser_td(td)) priv = 1; if (control) { if ((error = ip6_setpktoptions(control, &opt, priv, 0)) != 0) @@ -215,7 +215,7 @@ udp6_output(in6p, m, addr6, control, p) goto release; } if (in6p->in6p_lport == 0 && - (error = in6_pcbsetport(laddr, in6p, p)) != 0) + (error = in6_pcbsetport(laddr, in6p, td)) != 0) goto release; } else { if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 631e57c..6440dbe 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -523,7 +523,7 @@ udp6_abort(struct socket *so) } static int -udp6_attach(struct socket *so, int proto, struct proc *p) +udp6_attach(struct socket *so, int proto, struct thread *td) { struct inpcb *inp; int s, error; @@ -538,7 +538,7 @@ udp6_attach(struct socket *so, int proto, struct proc *p) return error; } s = splnet(); - error = in_pcballoc(so, &udbinfo, p); + error = in_pcballoc(so, &udbinfo, td); splx(s); if (error) return error; @@ -557,7 +557,7 @@ udp6_attach(struct socket *so, int proto, struct proc *p) } static int -udp6_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp; int s, error; @@ -582,20 +582,20 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct proc *p) inp->inp_vflag |= INP_IPV4; inp->inp_vflag &= ~INP_IPV6; s = splnet(); - error = in_pcbbind(inp, (struct sockaddr *)&sin, p); + error = in_pcbbind(inp, (struct sockaddr *)&sin, td); splx(s); return error; } } s = splnet(); - error = in6_pcbbind(inp, nam, p); + error = in6_pcbbind(inp, nam, td); splx(s); return error; } static int -udp6_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { struct inpcb *inp; int s, error; @@ -615,7 +615,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct proc *p) return EISCONN; in6_sin6_2_sin(&sin, sin6_p); s = splnet(); - error = in_pcbconnect(inp, (struct sockaddr *)&sin, p); + error = in_pcbconnect(inp, (struct sockaddr *)&sin, td); splx(s); if (error == 0) { inp->inp_vflag |= INP_IPV4; @@ -629,7 +629,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct proc *p) if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) return EISCONN; s = splnet(); - error = in6_pcbconnect(inp, nam, p); + error = in6_pcbconnect(inp, nam, td); splx(s); if (error == 0) { if (ip6_mapped_addr_on) { /* should be non mapped addr */ @@ -686,7 +686,7 @@ udp6_disconnect(struct socket *so) static int udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { struct inpcb *inp; int error = 0; @@ -726,13 +726,13 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, in6_sin6_2_sin_in_sock(addr); pru = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs; error = ((*pru->pru_send)(so, flags, m, addr, control, - p)); + td)); /* addr will just be freed in sendit(). */ return error; } } - return udp6_output(inp, m, addr, control, p); + return udp6_output(inp, m, addr, control, td); bad: m_freem(m); diff --git a/sys/netinet6/udp6_var.h b/sys/netinet6/udp6_var.h index 5c3efbc..2da5057 100644 --- a/sys/netinet6/udp6_var.h +++ b/sys/netinet6/udp6_var.h @@ -76,7 +76,7 @@ void udp6_ctlinput __P((int, struct sockaddr *, void *)); int udp6_input __P((struct mbuf **, int *, int)); int udp6_output __P((struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, - struct proc *p)); + struct thread *td)); #endif #endif /*_NETINET6_UDP6_VAR_H_*/ diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c index 6dfc32f..2727875 100644 --- a/sys/netipx/ipx.c +++ b/sys/netipx/ipx.c @@ -59,12 +59,12 @@ static int ipx_ifinit(struct ifnet *ifp, struct ipx_ifaddr *ia, * Generic internet control operations (ioctl's). */ int -ipx_control(so, cmd, data, ifp, p) +ipx_control(so, cmd, data, ifp, td) struct socket *so; u_long cmd; caddr_t data; register struct ifnet *ifp; - struct proc *p; + struct thread *td; { register struct ifreq *ifr = (struct ifreq *)data; register struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data; @@ -108,7 +108,7 @@ ipx_control(so, cmd, data, ifp, p) return (0); } - if (p && (error = suser(p)) != 0) + if (td && (error = suser_td(td)) != 0) return (error); switch (cmd) { diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c index d4c9693..4dea458 100644 --- a/sys/netipx/ipx_ip.c +++ b/sys/netipx/ipx_ip.c @@ -384,14 +384,14 @@ ipxip_route(so, sopt) ifr_ipxip.ifr_name[4] = '0' + ipxipif.if_unit - 1; ifr_ipxip.ifr_dstaddr = *(struct sockaddr *)ipx_dst; ipx_control(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, sopt->sopt_p); + (struct ifnet *)ifn, sopt->sopt_td); /* use any of our addresses */ satoipx_addr(ifr_ipxip.ifr_addr).x_host = ipx_ifaddr->ia_addr.sipx_addr.x_host; return (ipx_control(so, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, sopt->sopt_p)); + (struct ifnet *)ifn, sopt->sopt_td)); } static int diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c index 0ae2462..fc0c6dd 100644 --- a/sys/netipx/ipx_pcb.c +++ b/sys/netipx/ipx_pcb.c @@ -53,10 +53,10 @@ static struct ipx_addr zeroipx_addr; int -ipx_pcballoc(so, head, p) +ipx_pcballoc(so, head, td) struct socket *so; struct ipxpcb *head; - struct proc *p; + struct thread *td; { register struct ipxpcb *ipxp; @@ -72,10 +72,10 @@ ipx_pcballoc(so, head, p) } int -ipx_pcbbind(ipxp, nam, p) +ipx_pcbbind(ipxp, nam, td) register struct ipxpcb *ipxp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { register struct sockaddr_ipx *sipx; u_short lport = 0; @@ -99,7 +99,7 @@ ipx_pcbbind(ipxp, nam, p) int error; if (aport < IPXPORT_RESERVED && - p != NULL && (error = suser(p)) != 0) + td != NULL && (error = suser_td(td)) != 0) return (error); if (ipx_pcblookup(&zeroipx_addr, lport, 0)) return (EADDRINUSE); @@ -125,10 +125,10 @@ noname: * then pick one. */ int -ipx_pcbconnect(ipxp, nam, p) +ipx_pcbconnect(ipxp, nam, td) struct ipxpcb *ipxp; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct ipx_ifaddr *ia; register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; @@ -242,7 +242,7 @@ ipx_pcbconnect(ipxp, nam, p) if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0)) return (EADDRINUSE); if (ipxp->ipxp_lport == 0) - ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p); + ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); /* XXX just leave it zero if we can't find a route */ diff --git a/sys/netipx/ipx_pcb.h b/sys/netipx/ipx_pcb.h index 13bd9f9..482f812 100644 --- a/sys/netipx/ipx_pcb.h +++ b/sys/netipx/ipx_pcb.h @@ -83,11 +83,11 @@ struct ipxpcb { extern struct ipxpcb ipxpcb; /* head of list */ int ipx_pcballoc __P((struct socket *so, struct ipxpcb *head, - struct proc *p)); + struct thread *p)); int ipx_pcbbind __P((struct ipxpcb *ipxp, struct sockaddr *nam, - struct proc *p)); + struct thread *p)); int ipx_pcbconnect __P((struct ipxpcb *ipxp, struct sockaddr *nam, - struct proc *p)); + struct thread *p)); void ipx_pcbdetach __P((struct ipxpcb *ipxp)); void ipx_pcbdisconnect __P((struct ipxpcb *ipxp)); struct ipxpcb * diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c index 4939568..fdd6917 100644 --- a/sys/netipx/ipx_usrreq.c +++ b/sys/netipx/ipx_usrreq.c @@ -70,17 +70,17 @@ SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, &ipxrecvspace, 0, ""); static int ipx_usr_abort(struct socket *so); -static int ipx_attach(struct socket *so, int proto, struct proc *p); -static int ipx_bind(struct socket *so, struct sockaddr *nam, struct proc *p); +static int ipx_attach(struct socket *so, int proto, struct thread *td); +static int ipx_bind(struct socket *so, struct sockaddr *nam, struct thread *td); static int ipx_connect(struct socket *so, struct sockaddr *nam, - struct proc *p); + struct thread *td); static int ipx_detach(struct socket *so); static int ipx_disconnect(struct socket *so); static int ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, - struct proc *p); + struct thread *td); static int ipx_shutdown(struct socket *so); -static int ripx_attach(struct socket *so, int proto, struct proc *p); +static int ripx_attach(struct socket *so, int proto, struct thread *td); static int ipx_output(struct ipxpcb *ipxp, struct mbuf *m0); struct pr_usrreqs ipx_usrreqs = { @@ -432,10 +432,10 @@ ipx_usr_abort(so) } static int -ipx_attach(so, proto, p) +ipx_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { int error; int s; @@ -444,7 +444,7 @@ ipx_attach(so, proto, p) if (ipxp != NULL) return (EINVAL); s = splnet(); - error = ipx_pcballoc(so, &ipxpcb, p); + error = ipx_pcballoc(so, &ipxpcb, td); splx(s); if (error == 0) error = soreserve(so, ipxsendspace, ipxrecvspace); @@ -452,21 +452,21 @@ ipx_attach(so, proto, p) } static int -ipx_bind(so, nam, p) +ipx_bind(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct ipxpcb *ipxp = sotoipxpcb(so); - return (ipx_pcbbind(ipxp, nam, p)); + return (ipx_pcbbind(ipxp, nam, td)); } static int -ipx_connect(so, nam, p) +ipx_connect(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { int error; int s; @@ -475,7 +475,7 @@ ipx_connect(so, nam, p) if (!ipx_nullhost(ipxp->ipxp_faddr)) return (EISCONN); s = splnet(); - error = ipx_pcbconnect(ipxp, nam, p); + error = ipx_pcbconnect(ipxp, nam, td); splx(s); if (error == 0) soisconnected(so); @@ -525,13 +525,13 @@ ipx_peeraddr(so, nam) } static int -ipx_send(so, flags, m, nam, control, p) +ipx_send(so, flags, m, nam, control, td) struct socket *so; int flags; struct mbuf *m; struct sockaddr *nam; struct mbuf *control; - struct proc *p; + struct thread *td; { int error; struct ipxpcb *ipxp = sotoipxpcb(so); @@ -548,7 +548,7 @@ ipx_send(so, flags, m, nam, control, p) * Must block input while temporarily connected. */ s = splnet(); - error = ipx_pcbconnect(ipxp, nam, p); + error = ipx_pcbconnect(ipxp, nam, td); if (error) { splx(s); goto send_release; @@ -593,19 +593,19 @@ ipx_sockaddr(so, nam) } static int -ripx_attach(so, proto, p) +ripx_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { int error = 0; int s; struct ipxpcb *ipxp = sotoipxpcb(so); - if (p != NULL && (error = suser(p)) != 0) + if (td != NULL && (error = suser_td(td)) != 0) return (error); s = splnet(); - error = ipx_pcballoc(so, &ipxrawpcb, p); + error = ipx_pcballoc(so, &ipxrawpcb, td); splx(s); if (error) return (error); diff --git a/sys/netipx/ipx_var.h b/sys/netipx/ipx_var.h index c387738..7e7b5ef 100644 --- a/sys/netipx/ipx_var.h +++ b/sys/netipx/ipx_var.h @@ -80,7 +80,7 @@ extern union ipx_host ipx_broadhost; struct ifnet; struct ipx_addr; struct mbuf; -struct proc; +struct thread; struct route; struct sockaddr; struct socket; @@ -89,7 +89,7 @@ struct sockopt; void ipx_abort __P((struct ipxpcb *ipxp)); u_short ipx_cksum __P((struct mbuf *m, int len)); int ipx_control __P((struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p)); + struct ifnet *ifp, struct thread *td)); void ipx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy)); int ipx_ctloutput __P((struct socket *so, struct sockopt *sopt)); void ipx_drop __P((struct ipxpcb *ipxp, int errno)); diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index 19ebab9..7f1a1ae 100644 --- a/sys/netipx/spx_usrreq.c +++ b/sys/netipx/spx_usrreq.c @@ -89,20 +89,20 @@ static struct spxpcb *spx_usrclosed(struct spxpcb *cb); static int spx_usr_abort(struct socket *so); static int spx_accept(struct socket *so, struct sockaddr **nam); -static int spx_attach(struct socket *so, int proto, struct proc *p); -static int spx_bind(struct socket *so, struct sockaddr *nam, struct proc *p); +static int spx_attach(struct socket *so, int proto, struct thread *td); +static int spx_bind(struct socket *so, struct sockaddr *nam, struct thread *td); static int spx_connect(struct socket *so, struct sockaddr *nam, - struct proc *p); + struct thread *td); static int spx_detach(struct socket *so); static int spx_usr_disconnect(struct socket *so); -static int spx_listen(struct socket *so, struct proc *p); +static int spx_listen(struct socket *so, struct thread *td); static int spx_rcvd(struct socket *so, int flags); static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags); static int spx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, - struct proc *p); + struct thread *td); static int spx_shutdown(struct socket *so); -static int spx_sp_attach(struct socket *so, int proto, struct proc *p); +static int spx_sp_attach(struct socket *so, int proto, struct thread *td); struct pr_usrreqs spx_usrreqs = { spx_usr_abort, spx_accept, spx_attach, spx_bind, @@ -223,7 +223,7 @@ spx_input(m, ipxp) laddr = ipxp->ipxp_laddr; if (ipx_nullhost(laddr)) ipxp->ipxp_laddr = si->si_dna; - if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &proc0)) { + if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, thread0)) { ipxp->ipxp_laddr = laddr; spx_istat.noconn++; goto drop; @@ -1304,10 +1304,10 @@ spx_accept(so, nam) } static int -spx_attach(so, proto, p) +spx_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { int error; int s; @@ -1322,7 +1322,7 @@ spx_attach(so, proto, p) if (ipxp != NULL) return (EISCONN); s = splnet(); - error = ipx_pcballoc(so, &ipxpcb, p); + error = ipx_pcballoc(so, &ipxpcb, td); if (error) goto spx_attach_end; if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { @@ -1370,16 +1370,16 @@ spx_attach_end: } static int -spx_bind(so, nam, p) +spx_bind(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { struct ipxpcb *ipxp; ipxp = sotoipxpcb(so); - return (ipx_pcbbind(ipxp, nam, p)); + return (ipx_pcbbind(ipxp, nam, td)); } /* @@ -1389,10 +1389,10 @@ spx_bind(so, nam, p) * Send initial system packet requesting connection. */ static int -spx_connect(so, nam, p) +spx_connect(so, nam, td) struct socket *so; struct sockaddr *nam; - struct proc *p; + struct thread *td; { int error; int s; @@ -1404,11 +1404,11 @@ spx_connect(so, nam, p) s = splnet(); if (ipxp->ipxp_lport == 0) { - error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p); + error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); if (error) goto spx_connect_end; } - error = ipx_pcbconnect(ipxp, nam, p); + error = ipx_pcbconnect(ipxp, nam, td); if (error) goto spx_connect_end; soisconnecting(so); @@ -1478,9 +1478,9 @@ spx_usr_disconnect(so) } static int -spx_listen(so, p) +spx_listen(so, td) struct socket *so; - struct proc *p; + struct thread *td; { int error; struct ipxpcb *ipxp; @@ -1491,7 +1491,7 @@ spx_listen(so, p) cb = ipxtospxpcb(ipxp); if (ipxp->ipxp_lport == 0) - error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p); + error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); if (error == 0) cb->s_state = TCPS_LISTEN; return (error); @@ -1543,13 +1543,13 @@ spx_rcvoob(so, m, flags) } static int -spx_send(so, flags, m, addr, controlp, p) +spx_send(so, flags, m, addr, controlp, td) struct socket *so; int flags; struct mbuf *m; struct sockaddr *addr; struct mbuf *controlp; - struct proc *p; + struct thread *td; { int error; int s; @@ -1612,15 +1612,15 @@ spx_shutdown(so) } static int -spx_sp_attach(so, proto, p) +spx_sp_attach(so, proto, td) struct socket *so; int proto; - struct proc *p; + struct thread *td; { int error; struct ipxpcb *ipxp; - error = spx_attach(so, proto, p); + error = spx_attach(so, proto, td); if (error == 0) { ipxp = sotoipxpcb(so); ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |= diff --git a/sys/netkey/keysock.c b/sys/netkey/keysock.c index 5eab147..76f6482 100644 --- a/sys/netkey/keysock.c +++ b/sys/netkey/keysock.c @@ -411,7 +411,7 @@ key_abort(struct socket *so) * derived from net/rtsock.c:rts_attach() */ static int -key_attach(struct socket *so, int proto, struct proc *p) +key_attach(struct socket *so, int proto, struct thread *td) { struct keycb *kp; int s, error; @@ -432,7 +432,7 @@ key_attach(struct socket *so, int proto, struct proc *p) */ s = splnet(); so->so_pcb = (caddr_t)kp; - error = raw_usrreqs.pru_attach(so, proto, p); + error = raw_usrreqs.pru_attach(so, proto, td); kp = (struct keycb *)sotorawcb(so); if (error) { free(kp, M_PCB); @@ -461,11 +461,11 @@ key_attach(struct socket *so, int proto, struct proc *p) * derived from net/rtsock.c:rts_bind() */ static int -key_bind(struct socket *so, struct sockaddr *nam, struct proc *p) +key_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_bind(so, nam, p); /* xxx just EINVAL */ + error = raw_usrreqs.pru_bind(so, nam, td); /* xxx just EINVAL */ splx(s); return error; } @@ -475,11 +475,11 @@ key_bind(struct socket *so, struct sockaddr *nam, struct proc *p) * derived from net/rtsock.c:rts_connect() */ static int -key_connect(struct socket *so, struct sockaddr *nam, struct proc *p) +key_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_connect(so, nam, p); /* XXX just EINVAL */ + error = raw_usrreqs.pru_connect(so, nam, td); /* XXX just EINVAL */ splx(s); return error; } @@ -542,11 +542,11 @@ key_peeraddr(struct socket *so, struct sockaddr **nam) */ static int key_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct proc *p) + struct mbuf *control, struct thread *td) { int s, error; s = splnet(); - error = raw_usrreqs.pru_send(so, flags, m, nam, control, p); + error = raw_usrreqs.pru_send(so, flags, m, nam, control, td); splx(s); return error; } diff --git a/sys/netncp/ncp_conn.h b/sys/netncp/ncp_conn.h index 707cac0..a163eed 100644 --- a/sys/netncp/ncp_conn.h +++ b/sys/netncp/ncp_conn.h @@ -195,33 +195,33 @@ struct ncp_conn { int ncp_conn_init(void); int ncp_conn_destroy(void); int ncp_conn_alloc(struct ncp_conn_args *cap, - struct proc *p, struct ucred *cred, struct ncp_conn **connid); + struct thread *td, struct ucred *cred, struct ncp_conn **connid); int ncp_conn_free(struct ncp_conn *conn); int ncp_conn_access(struct ncp_conn *conn,struct ucred *cred,mode_t mode); -int ncp_conn_lock(struct ncp_conn *conn,struct proc *p,struct ucred *cred,int mode); -void ncp_conn_unlock(struct ncp_conn *conn,struct proc *p); -int ncp_conn_assert_locked(struct ncp_conn *conn,char *checker,struct proc *p); +int ncp_conn_lock(struct ncp_conn *conn,struct thread *td, struct ucred *cred,int mode); +void ncp_conn_unlock(struct ncp_conn *conn,struct thread *td); +int ncp_conn_assert_locked(struct ncp_conn *conn,char *checker,struct thread *td); void ncp_conn_invalidate(struct ncp_conn *ncp); int ncp_conn_invalid(struct ncp_conn *ncp); /*int ncp_conn_ref(struct ncp_conn *conn, pid_t pid); int ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force); void ncp_conn_list_rm_ref(pid_t pid);*/ -int ncp_conn_getbyref(int connRef,struct proc *p,struct ucred *cred, int mode, +int ncp_conn_getbyref(int connRef,struct thread *td, struct ucred *cred, int mode, struct ncp_conn **connpp); -int ncp_conn_getbyli(struct ncp_conn_loginfo *li,struct proc *p,struct ucred *cred, +int ncp_conn_getbyli(struct ncp_conn_loginfo *li,struct thread *td, struct ucred *cred, int mode, struct ncp_conn **connpp); int ncp_conn_setprimary(struct ncp_conn *conn, int on); -int ncp_conn_locklist(int flags, struct proc *p); -void ncp_conn_unlocklist(struct proc *p); -int ncp_conn_gethandle(struct ncp_conn *conn, struct proc *p, struct ncp_handle **handle); -int ncp_conn_puthandle(struct ncp_handle *handle, struct proc *p, int force); -int ncp_conn_findhandle(int connHandle, struct proc *p, struct ncp_handle **handle); -int ncp_conn_getattached(struct ncp_conn_args *li,struct proc *p,struct ucred *cred,int mode, struct ncp_conn **connpp); -int ncp_conn_putprochandles(struct proc *p); +int ncp_conn_locklist(int flags, struct thread *td); +void ncp_conn_unlocklist(struct thread *td); +int ncp_conn_gethandle(struct ncp_conn *conn, struct thread *td, struct ncp_handle **handle); +int ncp_conn_puthandle(struct ncp_handle *handle, struct thread *td, int force); +int ncp_conn_findhandle(int connHandle, struct thread *td, struct ncp_handle **handle); +int ncp_conn_getattached(struct ncp_conn_args *li,struct thread *td, struct ucred *cred,int mode, struct ncp_conn **connpp); +int ncp_conn_putprochandles(struct thread *td); int ncp_conn_getinfo(struct ncp_conn *ncp, struct ncp_conn_stat *ncs); int ncp_conn_reconnect(struct ncp_conn *ncp); -int ncp_conn_login(struct ncp_conn *conn, struct proc *p, struct ucred *cred); +int ncp_conn_login(struct ncp_conn *conn, struct thread *td, struct ucred *cred); extern struct ncp_conn_head conn_list; extern int ncp_burst_enabled; diff --git a/sys/netncp/ncp_rq.h b/sys/netncp/ncp_rq.h index bff912d..106537f 100644 --- a/sys/netncp/ncp_rq.h +++ b/sys/netncp/ncp_rq.h @@ -99,21 +99,21 @@ struct ncp_rq { int nr_rpsize; /* reply size minus ncp header */ int nr_cc; /* completion code */ int nr_cs; /* connection state */ - struct proc * nr_p; /* proc that did rq */ + struct thread * nr_td; /* thread that did rq */ struct ucred * nr_cred; /* user that did rq */ int rexmit; struct ncp_conn*nr_conn; /* back link */ }; -int ncp_rq_alloc(u_int8_t fn, struct ncp_conn *ncp, struct proc *p, +int ncp_rq_alloc(u_int8_t fn, struct ncp_conn *ncp, struct thread *td, struct ucred *cred, struct ncp_rq **rqpp); int ncp_rq_alloc_any(u_int32_t ptype, u_int8_t fn, struct ncp_conn *ncp, - struct proc *p, struct ucred *cred, struct ncp_rq **rqpp); + struct thread *td, struct ucred *cred, struct ncp_rq **rqpp); int ncp_rq_alloc_subfn(u_int8_t fn, u_int8_t subfn, struct ncp_conn *ncp, - struct proc *p, struct ucred *cred, struct ncp_rq **rqpp); + struct thread *td, struct ucred *cred, struct ncp_rq **rqpp); int ncp_rq_init_any(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn, struct ncp_conn *ncp, - struct proc *p, struct ucred *cred); + struct thread *td, struct ucred *cred); void ncp_rq_done(struct ncp_rq *rqp); int ncp_request(struct ncp_rq *rqp); int ncp_request_int(struct ncp_rq *rqp); diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 72fc393..063f77f 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -213,11 +213,11 @@ extern struct nfsv3_diskless nfsv3_diskless; /* mountd RPC */ static int md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp, int *fhsizep, - struct nfs_args *args,struct proc *procp); + struct nfs_args *args,struct thread *td); static int md_lookup_swap(struct sockaddr_in *mdsin,char *path, u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp); + struct thread *td); static int setfs(struct sockaddr_in *addr, char *path, char *p); static int getdec(char **ptr); static char *substr(char *a,char *b); @@ -231,7 +231,7 @@ static struct bootpc_ifcontext *allocifctx(struct bootpc_globalcontext *gctx); static void bootpc_compose_query(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static unsigned char *bootpc_tag(struct bootpc_tagcontext *tctx, struct bootp_packet *bp, int len, int tag); static void bootpc_tag_helper(struct bootpc_tagcontext *tctx, @@ -248,15 +248,15 @@ void bootpboot_p_iflist(void); #endif static int bootpc_call(struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static int bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static int bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static void bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, @@ -581,7 +581,7 @@ bootpc_received(struct bootpc_globalcontext *gctx, static int bootpc_call(struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { struct socket *so; struct sockaddr_in *sin, dst; @@ -601,7 +601,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, /* * Create socket and set its recieve timeout. */ - error = socreate(AF_INET, &so, SOCK_DGRAM, 0, procp); + error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td); if (error != 0) goto out; @@ -648,7 +648,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, sin = &dst; clear_sinaddr(sin); sin->sin_port = htons(IPPORT_BOOTPC); - error = sobind(so, (struct sockaddr *)sin, procp); + error = sobind(so, (struct sockaddr *)sin, td); if (error != 0) { printf("bind failed\n"); goto out; @@ -706,7 +706,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, (ifctx->state == IF_BOOTP_UNRESOLVED && ifctx->dhcpquerytype != DHCP_NOMSG)) { ifctx->sentmsg = 0; - bootpc_compose_query(ifctx, gctx, procp); + bootpc_compose_query(ifctx, gctx, td); } /* Send BOOTP request (or re-send). */ @@ -743,21 +743,21 @@ bootpc_call(struct bootpc_globalcontext *gctx, auio.uio_rw = UIO_WRITE; auio.uio_offset = 0; auio.uio_resid = sizeof(ifctx->call); - auio.uio_procp = procp; + auio.uio_td = td; /* Set netmask to 0.0.0.0 */ sin = (struct sockaddr_in *) &ifctx->ireq.ifr_addr; clear_sinaddr(sin); error = ifioctl(ifctx->so, SIOCSIFNETMASK, - (caddr_t) &ifctx->ireq, procp); + (caddr_t) &ifctx->ireq, td); if (error != 0) panic("bootpc_call:" "set if netmask, error=%d", error); error = sosend(so, (struct sockaddr *) &dst, - &auio, NULL, NULL, 0, procp); + &auio, NULL, NULL, 0, td); if (error != 0) { printf("bootpc_call: sosend: %d state %08x\n", error, (int) so->so_state); @@ -772,7 +772,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, clear_sinaddr(sin); sin->sin_addr.s_addr = htonl(0xff000000u); error = ifioctl(ifctx->so, SIOCSIFNETMASK, - (caddr_t) &ifctx->ireq, procp); + (caddr_t) &ifctx->ireq, td); if (error != 0) panic("bootpc_call:" "set if netmask, error=%d", @@ -810,7 +810,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(gctx->reply); - auio.uio_procp = procp; + auio.uio_td = td; rcvflg = 0; error = soreceive(so, NULL, &auio, @@ -979,7 +979,7 @@ out: static int bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { struct sockaddr_in *sin; int error; @@ -989,7 +989,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct ifaddr *ifa; struct sockaddr_dl *sdl; - error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, procp); + error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, td); if (error != 0) panic("nfs_boot: socreate, error=%d", error); @@ -1002,11 +1002,11 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, * Get the old interface flags and or IFF_UP into them; if * IFF_UP set blindly, interface selection can be clobbered. */ - error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: GIFFLAGS, error=%d", error); ireq->ifr_flags |= IFF_UP; - error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: SIFFLAGS, error=%d", error); @@ -1019,7 +1019,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); - error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_fakeup_interface: " "set if addr, error=%d", error); @@ -1029,7 +1029,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); sin->sin_addr.s_addr = htonl(0xff000000u); - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: set if netmask, error=%d", error); @@ -1042,7 +1042,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin->sin_addr.s_addr = htonl(INADDR_BROADCAST); ifctx->broadcast.sin_addr.s_addr = sin->sin_addr.s_addr; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: " "set if broadcast addr, error=%d", @@ -1071,7 +1071,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, static int bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { int error; struct sockaddr_in defdst; @@ -1095,19 +1095,19 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, /* Shutdown interfaces where BOOTP failed */ printf("Shutdown interface %s\n", ifctx->ireq.ifr_name); - error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "SIOCGIFFLAGS, error=%d", error); ireq->ifr_flags &= ~IFF_UP; - error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "SIOCSIFFLAGS, error=%d", error); sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); - error = ifioctl(so, SIOCDIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCDIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_adjust_interface: " @@ -1122,7 +1122,7 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, * can talk to the servers. (just set the address) */ bcopy(netmask, &ireq->ifr_addr, sizeof(*netmask)); - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFNETMASK, (caddr_t) ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "set if netmask, error=%d", error); @@ -1133,13 +1133,13 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, clear_sinaddr(sin); sin->sin_addr.s_addr = myaddr->sin_addr.s_addr | ~ netmask->sin_addr.s_addr; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t) ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "set if broadcast addr, error=%d", error); bcopy(myaddr, &ireq->ifr_addr, sizeof(*myaddr)); - error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_adjust_interface: " "set if addr, error=%d", error); @@ -1326,10 +1326,10 @@ print_in_addr(struct in_addr addr) } static void -bootpc_compose_query(ifctx, gctx, procp) +bootpc_compose_query(ifctx, gctx, td) struct bootpc_ifcontext *ifctx; struct bootpc_globalcontext *gctx; - struct proc *procp; + struct thread *td; { unsigned char *vendp; uint32_t leasetime; @@ -1670,10 +1670,10 @@ bootpc_init(void) struct ifnet *ifp; int error; struct nfsv3_diskless *nd; - struct proc *procp; + struct thread *td; nd = &nfsv3_diskless; - procp = curproc; + td = curthread; /* * If already filled in, don't touch it here @@ -1745,13 +1745,13 @@ bootpc_init(void) gctx->gotgw = 0; for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) - bootpc_fakeup_interface(ifctx, gctx, procp); + bootpc_fakeup_interface(ifctx, gctx, td); for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) - bootpc_compose_query(ifctx, gctx, procp); + bootpc_compose_query(ifctx, gctx, td); ifctx = gctx->interfaces; - error = bootpc_call(gctx, procp); + error = bootpc_call(gctx, td); if (error != 0) { #ifdef BOOTP_NFSROOT @@ -1777,7 +1777,7 @@ bootpc_init(void) #endif for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) { - bootpc_adjust_interface(ifctx, gctx, procp); + bootpc_adjust_interface(ifctx, gctx, td); soclose(ifctx->so); } @@ -1799,7 +1799,7 @@ bootpc_init(void) error = md_mount(&nd->root_saddr, nd->root_hostnam, nd->root_fh, &nd->root_fhsize, - &nd->root_args, procp); + &nd->root_args, td); if (error != 0) panic("nfs_boot: mountd root, error=%d", error); @@ -1808,7 +1808,7 @@ bootpc_init(void) error = md_mount(&nd->swap_saddr, nd->swap_hostnam, nd->swap_fh, &nd->swap_fhsize, - &nd->swap_args, procp); + &nd->swap_args, td); if (error != 0) panic("nfs_boot: mountd swap, error=%d", error); @@ -1816,7 +1816,7 @@ bootpc_init(void) error = md_lookup_swap(&nd->swap_saddr, gctx->lookup_path, nd->swap_fh, &nd->swap_fhsize, - &nd->swap_args, procp); + &nd->swap_args, td); if (error != 0) panic("nfs_boot: lookup swap, error=%d", error); @@ -1852,7 +1852,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp) + struct thread *td) { struct mbuf *m; int error; @@ -1864,13 +1864,13 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* First try NFS v3 */ /* Get port number for MOUNTD. */ error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER3, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); if (error == 0) { m = xdr_string_encode(path, strlen(path)); /* Do RPC to mountd. */ error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER3, - RPCMNT_MOUNT, &m, NULL, procp); + RPCMNT_MOUNT, &m, NULL, td); } if (error == 0) { args->flags |= NFSMNT_NFSV3; @@ -1880,7 +1880,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* Get port number for MOUNTD. */ error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER1, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); if (error != 0) return error; @@ -1888,7 +1888,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* Do RPC to mountd. */ error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1, - RPCMNT_MOUNT, &m, NULL, procp); + RPCMNT_MOUNT, &m, NULL, td); if (error != 0) return error; /* message already freed */ @@ -1931,7 +1931,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ error = krpc_portmap(mdsin, NFS_PROG, (args->flags & NFSMNT_NFSV3) ? NFS_VER3 : NFS_VER2, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); goto out; @@ -1950,7 +1950,7 @@ md_lookup_swap(struct sockaddr_in *mdsin, /* mountd server address */ u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp) + struct thread *td) { struct mbuf *m; int error; @@ -1984,10 +1984,10 @@ md_lookup_swap(struct sockaddr_in *mdsin, /* mountd server address */ /* Do RPC to nfsd. */ if ((args->flags & NFSMNT_NFSV3) != 0) error = krpc_call(mdsin, NFS_PROG, NFS_VER3, - NFSPROC_LOOKUP, &m, NULL, procp); + NFSPROC_LOOKUP, &m, NULL, td); else error = krpc_call(mdsin, NFS_PROG, NFS_VER2, - NFSV2PROC_LOOKUP, &m, NULL, procp); + NFSV2PROC_LOOKUP, &m, NULL, td); if (error != 0) return error; /* message already freed */ diff --git a/sys/nfs/krpc.h b/sys/nfs/krpc.h index 6c889b5..b6136e3 100644 --- a/sys/nfs/krpc.h +++ b/sys/nfs/krpc.h @@ -4,16 +4,16 @@ #include <sys/cdefs.h> struct mbuf; -struct proc; +struct thread; struct sockaddr; struct sockaddr_in; int krpc_call __P((struct sockaddr_in *_sin, u_int prog, u_int vers, u_int func, - struct mbuf **data, struct sockaddr **from, struct proc *procp)); + struct mbuf **data, struct sockaddr **from, struct thread *td)); int krpc_portmap __P((struct sockaddr_in *_sin, - u_int prog, u_int vers, u_int16_t *portp,struct proc *procp)); + u_int prog, u_int vers, u_int16_t *portp,struct thread *td)); struct mbuf *xdr_string_encode __P((char *str, int len)); diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c index b7b1d2c..709af4a 100644 --- a/sys/nfs/krpc_subr.c +++ b/sys/nfs/krpc_subr.c @@ -124,11 +124,11 @@ struct rpc_reply { * Returns non-zero error on failure. */ int -krpc_portmap(sin, prog, vers, portp, procp) +krpc_portmap(sin, prog, vers, portp, td) struct sockaddr_in *sin; /* server address */ u_int prog, vers; /* host order */ u_int16_t *portp; /* network order */ - struct proc *procp; + struct thread *td; { struct sdata { u_int32_t prog; /* call program */ @@ -163,7 +163,7 @@ krpc_portmap(sin, prog, vers, portp, procp) sin->sin_port = htons(PMAPPORT); error = krpc_call(sin, PMAPPROG, PMAPVERS, - PMAPPROC_GETPORT, &m, NULL, procp); + PMAPPROC_GETPORT, &m, NULL, td); if (error) return error; @@ -185,12 +185,12 @@ krpc_portmap(sin, prog, vers, portp, procp) * the address from whence the response came is saved there. */ int -krpc_call(sa, prog, vers, func, data, from_p, procp) +krpc_call(sa, prog, vers, func, data, from_p, td) struct sockaddr_in *sa; u_int prog, vers, func; struct mbuf **data; /* input/output */ struct sockaddr **from_p; /* output */ - struct proc *procp; + struct thread *td; { struct socket *so; struct sockaddr_in *sin, ssin; @@ -220,7 +220,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) /* * Create socket and set its recieve timeout. */ - if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, procp))) + if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td))) goto out; tv.tv_sec = 1; @@ -260,7 +260,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) do { tport--; sin->sin_port = htons(tport); - error = sobind(so, (struct sockaddr *)sin, procp); + error = sobind(so, (struct sockaddr *)sin, td); } while (error == EADDRINUSE && tport > IPPORT_RESERVED / 2); if (error) { @@ -321,7 +321,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) goto out; } error = sosend(so, (struct sockaddr *)sa, NULL, m, - NULL, 0, procp); + NULL, 0, td); if (error) { printf("krpc_call: sosend: %d\n", error); goto out; diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h index 44d04b9..d5d0796 100644 --- a/sys/nfs/nfs.h +++ b/sys/nfs/nfs.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 3bcdb32..e48cd5c 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -72,7 +72,7 @@ static int nfs_bwrite(struct buf *bp) { - return (nfs_writebp(bp, 1, curproc)); + return (nfs_writebp(bp, 1, curthread)); } struct buf_ops buf_ops_nfs = { @@ -82,7 +82,7 @@ struct buf_ops buf_ops_nfs = { static struct buf *nfs_getcacheblk __P((struct vnode *vp, daddr_t bn, int size, - struct proc *p)); + struct thread *td)); extern int nfs_numasync; extern int nfs_pbuf_freecnt; @@ -107,7 +107,7 @@ nfs_getpages(ap) vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; struct nfsmount *nmp; vm_page_t *pages; @@ -115,8 +115,8 @@ nfs_getpages(ap) GIANT_REQUIRED; vp = ap->a_vp; - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + td = curthread; /* XXX */ + cred = curthread->td_proc->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -128,7 +128,7 @@ nfs_getpages(ap) if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) { - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); } npages = btoc(count); @@ -172,7 +172,7 @@ nfs_getpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; error = nfs_readrpc(vp, &uio, cred); pmap_qremove(kva, npages); @@ -268,7 +268,7 @@ nfs_putpages(ap) off_t offset; int *rtvals; struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; struct nfsmount *nmp; struct nfsnode *np; @@ -278,8 +278,8 @@ nfs_putpages(ap) vp = ap->a_vp; np = VTONFS(vp); - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + td = curthread; /* XXX */ + cred = curthread->td_proc->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -291,7 +291,7 @@ nfs_putpages(ap) if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) { - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); } for (i = 0; i < npages; i++) { @@ -327,7 +327,7 @@ nfs_putpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; if ((ap->a_sync & VM_PAGER_PUT_SYNC) == 0) iomode = NFSV3WRITE_UNSTABLE; @@ -366,7 +366,7 @@ nfs_bioread(vp, uio, ioflag, cred) register int biosize, i; struct buf *bp = 0, *rabp; struct vattr vattr; - struct proc *p; + struct thread *td; struct nfsmount *nmp = VFSTONFS(vp->v_mount); daddr_t lbn, rabn; int bcount; @@ -381,11 +381,11 @@ nfs_bioread(vp, uio, ioflag, cred) return (0); if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */ return (EINVAL); - p = uio->uio_procp; + td = uio->uio_td; if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); if (vp->v_type != VDIR && (uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize) return (EFBIG); @@ -414,23 +414,23 @@ nfs_bioread(vp, uio, ioflag, cred) if (vp->v_type != VDIR) panic("nfs: bioread, not dir"); nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } np->n_attrstamp = 0; - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { if (vp->v_type == VDIR) nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; @@ -445,7 +445,7 @@ nfs_bioread(vp, uio, ioflag, cred) if (nmp->nm_flag & NFSMNT_NQNFS) { if (NQNFS_CKINVALID(vp, np, ND_READ)) { do { - error = nqnfs_getlease(vp, ND_READ, cred, p); + error = nqnfs_getlease(vp, ND_READ, cred, td); } while (error == NQNFS_EXPIRED); if (error) return (error); @@ -454,14 +454,14 @@ nfs_bioread(vp, uio, ioflag, cred) ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) { if (vp->v_type == VDIR) nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); np->n_brev = np->n_lrev; } } else if (vp->v_type == VDIR && (np->n_flag & NMODIFIED)) { nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } @@ -493,14 +493,14 @@ nfs_bioread(vp, uio, ioflag, cred) (off_t)(lbn + 1 + nra) * biosize < np->n_size; nra++) { rabn = lbn + 1 + nra; if (!incore(vp, rabn)) { - rabp = nfs_getcacheblk(vp, rabn, biosize, p); + rabp = nfs_getcacheblk(vp, rabn, biosize, td); if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { rabp->b_flags |= B_ASYNC; rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL; rabp->b_ioflags |= BIO_ERROR; vfs_unbusy_pages(rabp); @@ -534,7 +534,7 @@ again: bcount = np->n_size - (off_t)lbn * biosize; } if (bcount != biosize) { - switch(nfs_rslock(np, p)) { + switch(nfs_rslock(np, td)) { case ENOLCK: goto again; /* not reached */ @@ -547,10 +547,10 @@ again: } } - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (bcount != biosize) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); if (!bp) return (EINTR); @@ -562,7 +562,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); return (error); @@ -583,13 +583,13 @@ again: break; case VLNK: nfsstats.biocache_readlinks++; - bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, p); + bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { bp->b_ioflags |= BIO_ERROR; brelse(bp); @@ -607,20 +607,20 @@ again: } lbn = (uoff_t)uio->uio_offset / NFS_DIRBLKSIZ; on = uio->uio_offset & (NFS_DIRBLKSIZ - 1); - bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, p); + bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); } while (error == NFSERR_BAD_COOKIE) { printf("got bad cookie vp %p bp %p\n", vp, bp); nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, 0, cred, p, 1); + error = nfs_vinvalbuf(vp, 0, cred, td, 1); /* * Yuck! The directory has been modified on the * server. The only way to get the block is by @@ -635,13 +635,13 @@ again: if (np->n_direofoffset && (i * NFS_DIRBLKSIZ) >= np->n_direofoffset) return (0); - bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, p); + bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); /* * no error + B_INVAL == directory EOF, * use the block. @@ -679,13 +679,13 @@ again: (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) && !(np->n_flag & NQNFSNONCACHE) && !incore(vp, lbn + 1)) { - rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); + rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, td); if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { rabp->b_flags |= B_ASYNC; rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL; rabp->b_ioflags |= BIO_ERROR; vfs_unbusy_pages(rabp); @@ -756,7 +756,7 @@ nfs_write(ap) { int biosize; struct uio *uio = ap->a_uio; - struct proc *p = uio->uio_procp; + struct thread *td = uio->uio_td; struct vnode *vp = ap->a_vp; struct nfsnode *np = VTONFS(vp); struct ucred *cred = ap->a_cred; @@ -768,13 +768,14 @@ nfs_write(ap) int bcount; int n, on, error = 0, iomode, must_commit; int haverslock = 0; + struct proc *p = td?td->td_proc:NULL; GIANT_REQUIRED; #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("nfs_write mode"); - if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) + if (uio->uio_segflg == UIO_USERSPACE && uio->uio_td != curthread) panic("nfs_write proc"); #endif if (vp->v_type != VREG) @@ -785,7 +786,7 @@ nfs_write(ap) } if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); /* * Synchronously flush pending buffers if we are in synchronous @@ -794,7 +795,7 @@ nfs_write(ap) if (ioflag & (IO_APPEND | IO_SYNC)) { if (np->n_flag & NMODIFIED) { np->n_attrstamp = 0; - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } @@ -807,7 +808,7 @@ nfs_write(ap) restart: if (ioflag & IO_APPEND) { np->n_attrstamp = 0; - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); uio->uio_offset = np->n_size; @@ -836,7 +837,7 @@ restart: */ if ((ioflag & IO_APPEND) || uio->uio_offset + uio->uio_resid > np->n_size) { - switch(nfs_rslock(np, p)) { + switch(nfs_rslock(np, td)) { case ENOLCK: goto restart; /* not reached */ @@ -860,7 +861,7 @@ restart: psignal(p, SIGXFSZ); PROC_UNLOCK(p); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (EFBIG); } @@ -873,13 +874,13 @@ restart: if ((nmp->nm_flag & NFSMNT_NQNFS) && NQNFS_CKINVALID(vp, np, ND_WRITE)) { do { - error = nqnfs_getlease(vp, ND_WRITE, cred, p); + error = nqnfs_getlease(vp, ND_WRITE, cred, td); } while (error == NQNFS_EXPIRED); if (error) break; if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; np->n_brev = np->n_lrev; @@ -910,7 +911,7 @@ again: * readers from reading garbage. */ bcount = on; - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (bp != NULL) { long save; @@ -939,7 +940,7 @@ again: bcount = np->n_size - (off_t)lbn * biosize; } - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (uio->uio_offset + n > np->n_size) { np->n_size = uio->uio_offset + n; @@ -981,7 +982,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); break; @@ -1047,7 +1048,7 @@ again: if ((nmp->nm_flag & NFSMNT_NQNFS) && NQNFS_CKINVALID(vp, np, ND_WRITE)) { do { - error = nqnfs_getlease(vp, ND_WRITE, cred, p); + error = nqnfs_getlease(vp, ND_WRITE, cred, td); } while (error == NQNFS_EXPIRED); if (error) { brelse(bp); @@ -1056,7 +1057,7 @@ again: if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { brelse(bp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; np->n_brev = np->n_lrev; @@ -1108,7 +1109,7 @@ again: if (error) break; if (np->n_flag & NQNFSNONCACHE) { - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; } @@ -1122,7 +1123,7 @@ again: } while (uio->uio_resid > 0 && n > 0); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (error); } @@ -1143,11 +1144,11 @@ again: * its EOF. */ static struct buf * -nfs_getcacheblk(vp, bn, size, p) +nfs_getcacheblk(vp, bn, size, td) struct vnode *vp; daddr_t bn; int size; - struct proc *p; + struct thread *td; { register struct buf *bp; struct mount *mp; @@ -1159,7 +1160,7 @@ nfs_getcacheblk(vp, bn, size, p) if (nmp->nm_flag & NFSMNT_INT) { bp = getblk(vp, bn, size, PCATCH, 0); while (bp == (struct buf *)0) { - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) return ((struct buf *)0); bp = getblk(vp, bn, size, 0, 2 * hz); } @@ -1181,11 +1182,11 @@ nfs_getcacheblk(vp, bn, size, p) * doing the flush, just wait for completion. */ int -nfs_vinvalbuf(vp, flags, cred, p, intrflg) +nfs_vinvalbuf(vp, flags, cred, td, intrflg) struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; int intrflg; { register struct nfsnode *np = VTONFS(vp); @@ -1212,7 +1213,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) np->n_flag |= NFLUSHWANT; error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nfsvinval", slptimeo); - if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) + if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) return (EINTR); } @@ -1220,9 +1221,9 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) * Now, flush as required. */ np->n_flag |= NFLUSHINPROG; - error = vinvalbuf(vp, flags, cred, p, slpflag, 0); + error = vinvalbuf(vp, flags, cred, td, slpflag, 0); while (error) { - if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { np->n_flag &= ~NFLUSHINPROG; if (np->n_flag & NFLUSHWANT) { np->n_flag &= ~NFLUSHWANT; @@ -1230,7 +1231,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) } return (EINTR); } - error = vinvalbuf(vp, flags, cred, p, 0, slptimeo); + error = vinvalbuf(vp, flags, cred, td, 0, slptimeo); } np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); if (np->n_flag & NFLUSHWANT) { @@ -1249,10 +1250,10 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) * is eventually dequeued by the async daemon, nfs_doio() *will*. */ int -nfs_asyncio(bp, cred, procp) +nfs_asyncio(bp, cred, td) register struct buf *bp; struct ucred *cred; - struct proc *procp; + struct thread *td; { struct nfsmount *nmp; int i; @@ -1334,7 +1335,7 @@ again: error = tsleep(&nmp->nm_bufq, slpflag | PRIBIO, "nfsaio", slptimeo); if (error) { - if (nfs_sigintr(nmp, NULL, procp)) + if (nfs_sigintr(nmp, NULL, td->td_proc)) return (EINTR); if (slpflag == PCATCH) { slpflag = 0; @@ -1384,10 +1385,10 @@ again: * synchronously or from an nfsiod. */ int -nfs_doio(bp, cr, p) +nfs_doio(bp, cr, td) struct buf *bp; struct ucred *cr; - struct proc *p; + struct thread *td; { struct uio *uiop; struct vnode *vp; @@ -1396,6 +1397,7 @@ nfs_doio(bp, cr, p) int error = 0, iomode, must_commit = 0; struct uio uio; struct iovec io; + struct proc *p = td?td->td_proc:NULL; vp = bp->b_vp; np = VTONFS(vp); @@ -1404,7 +1406,7 @@ nfs_doio(bp, cr, p) uiop->uio_iov = &io; uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = p; + uiop->uio_td = td; /* * clear BIO_ERROR and B_INVAL state prior to initiating the I/O. We @@ -1525,7 +1527,7 @@ nfs_doio(bp, cr, p) bp->b_flags |= B_WRITEINPROG; retv = nfs_commit( bp->b_vp, off, bp->b_dirtyend-bp->b_dirtyoff, - bp->b_wcred, p); + bp->b_wcred, td); bp->b_flags &= ~B_WRITEINPROG; if (retv == 0) { bp->b_dirtyoff = bp->b_dirtyend = 0; diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index ad8891c..4425129 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -554,11 +554,11 @@ extern struct nfsnodehashhead *nfsnodehashtbl; extern u_long nfsnodehash; struct nfssvc_args; -extern int nfssvc(struct proc *, struct nfssvc_args *, int *); +extern int nfssvc(struct thread *, struct nfssvc_args *, int *); LIST_HEAD(nfsnodehashhead, nfsnode); -int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *)); +int nfs_webnamei __P((struct nameidata *, struct vnode *, struct thread *)); u_quad_t nfs_curusec() @@ -950,7 +950,7 @@ nfsm_disct(mdp, dposp, siz, left, cp2) { register struct mbuf *mp, *mp2; register int siz2, xfer; - register caddr_t p; + register caddr_t ptr; mp = *mdp; while (left == 0) { @@ -973,10 +973,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = p = mtod(mp, caddr_t); - bcopy(*dposp, p, left); /* Copy what was left */ + *cp2 = ptr = mtod(mp, caddr_t); + bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; - p += left; + ptr += left; mp2 = mp->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { @@ -984,10 +984,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) return (EBADRPC); xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { - bcopy(mtod(mp2, caddr_t), p, xfer); + bcopy(mtod(mp2, caddr_t), ptr, xfer); NFSMADV(mp2, xfer); mp2->m_len -= xfer; - p += xfer; + ptr += xfer; siz2 -= xfer; } if (siz2 > 0) @@ -1464,7 +1464,7 @@ nfs_getattrcache(vp, vaper) * released by the caller. */ int -nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) +nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, td, kerbflag, pubflag) register struct nameidata *ndp; fhandle_t *fhp; int len; @@ -1473,7 +1473,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) struct mbuf **mdp; caddr_t *dposp; struct vnode **retdirp; - struct proc *p; + struct thread *td; int kerbflag, pubflag; { register int i, rem; @@ -1613,7 +1613,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * becuase lookup() will dereference ni_startdir. */ - cnp->cn_proc = p; + cnp->cn_thread = td; VREF(dp); ndp->ni_startdir = dp; @@ -1649,7 +1649,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * Validate symlink */ if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); if (!pubflag) { error = EINVAL; goto badlink2; @@ -1670,7 +1670,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -1924,7 +1924,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) int kerbflag; int pubflag; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register struct mount *mp; register int i; struct ucred *credanon; @@ -1988,7 +1988,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) nfsrv_object_create(*vpp); if (!lockflag) - VOP_UNLOCK(*vpp, 0, p); + VOP_UNLOCK(*vpp, 0, td); return (0); } @@ -2196,8 +2196,8 @@ nfsrv_object_create(vp) if (vp == NULL || vp->v_type != VREG) return (1); - return (vfs_object_create(vp, curproc, - curproc ? curproc->p_ucred : NULL)); + return (vfs_object_create(vp, curthread, + curthread ? curthread->td_proc->p_ucred : NULL)); } /* diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index e2fa91c..b97b3b8 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -87,14 +87,17 @@ nfs_dolock(ap) { LOCKD_MSG msg; struct nameidata nd; - struct proc *p; + struct thread *td; uid_t saved_uid; struct vnode *vp, *wvp; int error, error1; struct flock *fl; int fmode, ioflg; + struct proc *p; + + td = curthread; + p = td->td_proc; - p = curproc; vp = ap->a_vp; fl = ap->a_fl; @@ -148,7 +151,7 @@ nfs_dolock(ap) * complain that the user's file is missing, which isn't the case. * Note that we use proc0's cred, so the fifo is opened as root. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, td); /* * XXX Hack to temporarily allow this process (regardless of it's creds) @@ -166,15 +169,15 @@ nfs_dolock(ap) return (error == ENOENT ? EOPNOTSUPP : error); } wvp = nd.ni_vp; - VOP_UNLOCK(wvp, 0, p); /* vn_open leaves it locked */ + VOP_UNLOCK(wvp, 0, td); /* vn_open leaves it locked */ ioflg = IO_UNIT; for (;;) { - VOP_LEASE(wvp, p, proc0.p_ucred, LEASE_WRITE); + VOP_LEASE(wvp, td, proc0.p_ucred, LEASE_WRITE); error = vn_rdwr(UIO_WRITE, wvp, (caddr_t)&msg, sizeof(msg), 0, - UIO_SYSSPACE, ioflg, proc0.p_ucred, NULL, p); + UIO_SYSSPACE, ioflg, proc0.p_ucred, NULL, td); if (error && (((ioflg & IO_NDELAY) == 0) || error != EAGAIN)) { break; @@ -224,7 +227,7 @@ nfs_dolock(ap) break; } - if ((error1 = vn_close(wvp, FWRITE, proc0.p_ucred, p)) && error == 0) + if ((error1 = vn_close(wvp, FWRITE, proc0.p_ucred, td)) && error == 0) return (error1); return (error); diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index dc21bc3..5fe3abc 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -169,7 +169,7 @@ nfs_nget(mntp, fhp, fhsize, npp) int fhsize; struct nfsnode **npp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct nfsnode *np, *np2; struct nfsnodehashhead *nhpp; register struct vnode *vp; @@ -196,7 +196,7 @@ loop: bcmp((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize)) continue; vp = NFSTOV(np); - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) goto loop; *npp = np; return(0); @@ -266,7 +266,7 @@ loop: /* * Lock the new nfsnode. */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); return (0); } @@ -275,12 +275,12 @@ int nfs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct nfsnode *np; register struct sillyrename *sp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ np = VTONFS(ap->a_vp); if (prtactive && ap->a_vp->v_usecount != 0) @@ -299,11 +299,11 @@ nfs_inactive(ap) * have our own reference. */ if (ap->a_vp->v_usecount > 0) - (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1); - else if (vget(ap->a_vp, 0, p)) + (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, td, 1); + else if (vget(ap->a_vp, 0, td)) panic("nfs_inactive: lost vnode"); else { - (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1); + (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, td, 1); vrele(ap->a_vp); } /* @@ -316,7 +316,7 @@ nfs_inactive(ap) } np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT | NQNFSEVICTED | NQNFSNONCACHE | NQNFSWRITE); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); return (0); } @@ -459,7 +459,7 @@ int nfs_islocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { return VTONFS(ap->a_vp)->n_flag & NLOCKED ? 1 : 0; diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c index 55b44ba..86b5ef6 100644 --- a/sys/nfs/nfs_nqlease.c +++ b/sys/nfs/nfs_nqlease.c @@ -174,12 +174,12 @@ extern struct nfsstats nfsstats; * queue yet. (Ditto for the splsoftclock() and splx(s) calls) */ int -nqsrv_getlease(vp, duration, flags, slp, procp, nam, cachablep, frev, cred) +nqsrv_getlease(vp, duration, flags, slp, td, nam, cachablep, frev, cred) struct vnode *vp; u_int32_t *duration; int flags; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct sockaddr *nam; int *cachablep; u_quad_t *frev; @@ -198,7 +198,7 @@ nqsrv_getlease(vp, duration, flags, slp, procp, nam, cachablep, frev, cred) return (0); if (*duration > nqsrv_maxlease) *duration = nqsrv_maxlease; - error = VOP_GETATTR(vp, &vattr, cred, procp); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); *frev = vattr.va_filerev; @@ -340,9 +340,9 @@ doreply: * OS needs. */ void -nqnfs_lease_check(vp, p, cred, flag) +nqnfs_lease_check(vp, td, cred, flag) struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; int flag; { @@ -351,14 +351,14 @@ nqnfs_lease_check(vp, p, cred, flag) u_quad_t frev; (void) nqsrv_getlease(vp, &duration, ND_CHECK | flag, NQLOCALSLP, - p, (struct sockaddr *)0, &cache, &frev, cred); + td, (struct sockaddr *)0, &cache, &frev, cred); } int nqnfs_vop_lease_check(ap) struct vop_lease_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; struct ucred *a_cred; int a_flag; } */ *ap; @@ -368,7 +368,7 @@ nqnfs_vop_lease_check(ap) u_quad_t frev; (void) nqsrv_getlease(ap->a_vp, &duration, ND_CHECK | ap->a_flag, - NQLOCALSLP, ap->a_p, (struct sockaddr *)0, + NQLOCALSLP, ap->a_td, (struct sockaddr *)0, &cache, &frev, ap->a_cred); return (0); } @@ -723,10 +723,10 @@ nqnfs_serverd() * do the real work. */ int -nqnfsrv_getlease(nfsd, slp, procp, mrq) +nqnfsrv_getlease(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -764,9 +764,9 @@ nqnfsrv_getlease(nfsd, slp, procp, mrq) vput(vp); nfsm_reply(0); } - (void) nqsrv_getlease(vp, &nfsd->nd_duration, flags, slp, procp, + (void) nqsrv_getlease(vp, &nfsd->nd_duration, flags, slp, td, nam, &cache, &frev, cred); - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); nfsm_reply(NFSX_V3FATTR + 4 * NFSX_UNSIGNED); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); @@ -783,10 +783,10 @@ nqnfsrv_getlease(nfsd, slp, procp, mrq) * client. Find the entry and expire it. */ int -nqnfsrv_vacated(nfsd, slp, procp, mrq) +nqnfsrv_vacated(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -861,11 +861,11 @@ nfsmout: * Client get lease rpc function. */ int -nqnfs_getlease(vp, rwflag, cred, p) +nqnfs_getlease(vp, rwflag, cred, td) register struct vnode *vp; int rwflag; struct ucred *cred; - struct proc *p; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -887,7 +887,7 @@ nqnfs_getlease(vp, rwflag, cred, p) *tl++ = txdr_unsigned(rwflag); *tl = txdr_unsigned(nmp->nm_leaseterm); reqtime = time_second; - nfsm_request(vp, NQNFSPROC_GETLEASE, p, cred); + nfsm_request(vp, NQNFSPROC_GETLEASE, td, cred); np = VTONFS(vp); nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); cachable = fxdr_unsigned(int, *tl++); @@ -1018,13 +1018,13 @@ nqnfs_callback(nmp, mrep, md, dpos) * the list asynchronously. */ int -nqnfs_clientd(nmp, cred, ncd, flag, argp, p) +nqnfs_clientd(nmp, cred, ncd, flag, argp, td) register struct nfsmount *nmp; struct ucred *cred; struct nfsd_cargs *ncd; int flag; caddr_t argp; - struct proc *p; + struct thread *td; { register struct nfsnode *np; struct vnode *vp; @@ -1078,7 +1078,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) myrep.r_flags = R_GETONEREP; myrep.r_nmp = nmp; myrep.r_mrep = (struct mbuf *)0; - myrep.r_procp = (struct proc *)0; + myrep.r_td = (struct thread *)0; (void) nfs_reply(&myrep); } @@ -1091,7 +1091,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) vp = NFSTOV(np); vpid = vp->v_id; if (np->n_expiry < time_second) { - if (vget(vp, LK_EXCLUSIVE, p) == 0) { + if (vget(vp, LK_EXCLUSIVE, td) == 0) { nmp->nm_inprog = vp; if (vpid == vp->v_id) { TAILQ_REMOVE(&nmp->nm_timerhead, np, n_timer); @@ -1102,12 +1102,12 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) nfs_invaldir(vp); cache_purge(vp); (void) nfs_vinvalbuf(vp, - V_SAVE, cred, p, 0); + V_SAVE, cred, td, 0); np->n_flag &= ~NQNFSEVICTED; (void) nqnfs_vacated(vp, cred); } else if (vp->v_type == VREG) { (void) VOP_FSYNC(vp, cred, - MNT_WAIT, p); + MNT_WAIT, td); np->n_flag &= ~NMODIFIED; } } @@ -1119,10 +1119,10 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) if ((np->n_flag & (NQNFSWRITE | NQNFSNONCACHE)) == NQNFSWRITE && !TAILQ_EMPTY(&vp->v_dirtyblkhd) && - vget(vp, LK_EXCLUSIVE, p) == 0) { + vget(vp, LK_EXCLUSIVE, td) == 0) { nmp->nm_inprog = vp; if (vpid == vp->v_id && - nqnfs_getlease(vp, ND_WRITE, cred, p)==0) + nqnfs_getlease(vp, ND_WRITE, cred, td)==0) np->n_brev = np->n_lrev; vput(vp); nmp->nm_inprog = NULLVP; @@ -1151,7 +1151,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) error = tsleep((caddr_t)&nmp->nm_authstr, PSOCK | PCATCH, "nqnfstimr", hz / 3); if (error == EINTR || error == ERESTART) - (void) dounmount(nmp->nm_mountp, 0, p); + (void) dounmount(nmp->nm_mountp, 0, td); } } @@ -1180,7 +1180,7 @@ void nqnfs_lease_updatetime(deltat) register int deltat; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct nqlease *lp; struct nfsnode *np; struct mount *mp, *nxtmp; @@ -1200,7 +1200,7 @@ nqnfs_lease_updatetime(deltat) */ mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nxtmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) { nxtmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -1214,7 +1214,7 @@ nqnfs_lease_updatetime(deltat) } mtx_lock(&mountlist_mtx); nxtmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); } diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index e015d17..0469388 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -145,7 +145,7 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_blks, CTLFLAG_RW, &nfs_commit_blks, 0, "") SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_miss, CTLFLAG_RW, &nfs_commit_miss, 0, ""); static int nfsrv_access __P((struct vnode *,int,struct ucred *,int, - struct proc *, int)); + struct thread *, int)); static void nfsrvw_coalesce __P((struct nfsrv_descript *, struct nfsrv_descript *)); @@ -168,10 +168,10 @@ ndclear(struct nameidata *nd) * nfs v3 access service */ int -nfsrv3_access(nfsd, slp, procp, mrq) +nfsrv3_access(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -208,7 +208,7 @@ nfsrv3_access(nfsd, slp, procp, mrq) } nfsmode = fxdr_unsigned(u_int32_t, *tl); if ((nfsmode & NFSV3ACCESS_READ) && - nfsrv_access(vp, VREAD, cred, rdonly, procp, 0)) + nfsrv_access(vp, VREAD, cred, rdonly, td, 0)) nfsmode &= ~NFSV3ACCESS_READ; if (vp->v_type == VDIR) testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | @@ -216,16 +216,16 @@ nfsrv3_access(nfsd, slp, procp, mrq) else testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if ((nfsmode & testmode) && - nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0)) + nfsrv_access(vp, VWRITE, cred, rdonly, td, 0)) nfsmode &= ~testmode; if (vp->v_type == VDIR) testmode = NFSV3ACCESS_LOOKUP; else testmode = NFSV3ACCESS_EXECUTE; if ((nfsmode & testmode) && - nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0)) + nfsrv_access(vp, VEXEC, cred, rdonly, td, 0)) nfsmode &= ~testmode; - getret = VOP_GETATTR(vp, vap, cred, procp); + getret = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); @@ -242,10 +242,10 @@ nfsmout: * nfs getattr service */ int -nfsrv_getattr(nfsd, slp, procp, mrq) +nfsrv_getattr(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -277,7 +277,7 @@ nfsrv_getattr(nfsd, slp, procp, mrq) goto nfsmout; } nqsrv_getl(vp, ND_READ); - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); @@ -299,10 +299,10 @@ nfsmout: * nfs setattr service */ int -nfsrv_setattr(nfsd, slp, procp, mrq) +nfsrv_setattr(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -399,7 +399,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_WRITE); if (v3) { - error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); + error = preat_ret = VOP_GETATTR(vp, &preat, cred, td); if (!error && gcheck && (preat.va_ctime.tv_sec != guard.tv_sec || preat.va_ctime.tv_nsec != guard.tv_nsec)) @@ -428,11 +428,11 @@ nfsrv_setattr(nfsd, slp, procp, mrq) error = EISDIR; goto out; } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly, - procp, 0)) != 0) + td, 0)) != 0) goto out; } - error = VOP_SETATTR(vp, vap, cred, procp); - postat_ret = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_SETATTR(vp, vap, cred, td); + postat_ret = VOP_GETATTR(vp, vap, cred, td); if (!error) error = postat_ret; out: @@ -462,10 +462,10 @@ nfsmout: * nfs lookup rpc */ int -nfsrv_lookup(nfsd, slp, procp, mrq) +nfsrv_lookup(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -501,7 +501,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), pubflag); /* * namei failure, only dirp to cleanup. Clear out garbarge from @@ -512,7 +512,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -544,7 +544,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) * via the original nd. Confused? You aren't alone! */ ind = nd; - VOP_UNLOCK(nd.ni_vp, 0, procp); + VOP_UNLOCK(nd.ni_vp, 0, td); ind.ni_pathlen = strlen(nfs_pub.np_index); ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf = nfs_pub.np_index; @@ -586,7 +586,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -624,7 +624,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); ndp->ni_vp = NULL; @@ -658,10 +658,10 @@ nfsmout: * nfs readlink service */ int -nfsrv_readlink(nfsd, slp, procp, mrq) +nfsrv_readlink(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -720,7 +720,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq) uiop->uio_resid = len; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE); if (error) { @@ -739,7 +739,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_READ); error = VOP_READLINK(vp, uiop, cred); out: - getret = VOP_GETATTR(vp, &attr, cred, procp); + getret = VOP_GETATTR(vp, &attr, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); @@ -771,10 +771,10 @@ nfsmout: * nfs read service */ int -nfsrv_read(nfsd, slp, procp, mrq) +nfsrv_read(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -840,10 +840,10 @@ nfsrv_read(nfsd, slp, procp, mrq) } if (!error) { nqsrv_getl(vp, ND_READ); - if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0) - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1); + if ((error = nfsrv_access(vp, VREAD, cred, rdonly, td, 1)) != 0) + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 1); } - getret = VOP_GETATTR(vp, vap, cred, procp); + getret = VOP_GETATTR(vp, vap, cred, td); if (!error) error = getret; if (error) { @@ -982,7 +982,7 @@ nfsrv_read(nfsd, slp, procp, mrq) off = uiop->uio_offset; nh->nh_nextr = off; FREE((caddr_t)iv2, M_TEMP); - if (error || (getret = VOP_GETATTR(vp, vap, cred, procp))) { + if (error || (getret = VOP_GETATTR(vp, vap, cred, td))) { if (!error) error = getret; m_freem(mreq); @@ -1022,10 +1022,10 @@ nfsmout: * nfs write service */ int -nfsrv_write(nfsd, slp, procp, mrq) +nfsrv_write(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1137,7 +1137,7 @@ nfsrv_write(nfsd, slp, procp, mrq) goto nfsmout; } if (v3) - forat_ret = VOP_GETATTR(vp, &forat, cred, procp); + forat_ret = VOP_GETATTR(vp, &forat, cred, td); if (vp->v_type != VREG) { if (v3) error = EINVAL; @@ -1146,7 +1146,7 @@ nfsrv_write(nfsd, slp, procp, mrq) } if (!error) { nqsrv_getl(vp, ND_WRITE); - error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); + error = nfsrv_access(vp, VWRITE, cred, rdonly, td, 1); } if (error) { vput(vp); @@ -1188,13 +1188,13 @@ nfsrv_write(nfsd, slp, procp, mrq) uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; uiop->uio_offset = off; error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; FREE((caddr_t)iv, M_TEMP); } - aftat_ret = VOP_GETATTR(vp, vap, cred, procp); + aftat_ret = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; if (!error) @@ -1246,10 +1246,10 @@ nfsmout: * Jan. 1994. */ int -nfsrv_writegather(ndp, slp, procp, mrq) +nfsrv_writegather(ndp, slp, td, mrq) struct nfsrv_descript **ndp; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { register struct iovec *ivp; @@ -1427,7 +1427,7 @@ loop1: nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE); if (!error) { if (v3) - forat_ret = VOP_GETATTR(vp, &forat, cred, procp); + forat_ret = VOP_GETATTR(vp, &forat, cred, td); if (vp->v_type != VREG) { if (v3) error = EINVAL; @@ -1439,7 +1439,7 @@ loop1: } if (!error) { nqsrv_getl(vp, ND_WRITE); - error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); + error = nfsrv_access(vp, VWRITE, cred, rdonly, td, 1); } if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) @@ -1450,7 +1450,7 @@ loop1: ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; if (uiop->uio_resid > 0) { @@ -1476,9 +1476,9 @@ loop1: } if (!error) { if (vn_start_write(vp, &mntp, V_NOWAIT) != 0) { - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); error = vn_start_write(NULL, &mntp, V_WAIT); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); } } if (!error) { @@ -1490,7 +1490,7 @@ loop1: } m_freem(mrep); if (vp) { - aftat_ret = VOP_GETATTR(vp, &va, cred, procp); + aftat_ret = VOP_GETATTR(vp, &va, cred, td); vput(vp); vp = NULL; } @@ -1631,10 +1631,10 @@ nfsrvw_coalesce(owp, nfsd) * now does a truncate to 0 length via. setattr if it already exists */ int -nfsrv_create(nfsd, slp, procp, mrq) +nfsrv_create(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1696,11 +1696,11 @@ nfsrv_create(nfsd, slp, procp, mrq) * prior to calling nfsm_reply ( which might goto nfsmout ). */ error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -1793,7 +1793,7 @@ nfsrv_create(nfsd, slp, procp, mrq) bcopy(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF); error = VOP_SETATTR(nd.ni_vp, vap, cred, - procp); + td); } } } else if ( @@ -1836,7 +1836,7 @@ nfsrv_create(nfsd, slp, procp, mrq) */ nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT); - nd.ni_cnd.cn_proc = procp; + nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -1857,14 +1857,14 @@ nfsrv_create(nfsd, slp, procp, mrq) } else { if (vap->va_size != -1) { error = nfsrv_access(nd.ni_vp, VWRITE, cred, - (nd.ni_cnd.cn_flags & RDONLY), procp, 0); + (nd.ni_cnd.cn_flags & RDONLY), td, 0); if (!error) { nqsrv_getl(nd.ni_vp, ND_WRITE); tempsize = vap->va_size; VATTR_NULL(vap); vap->va_size = tempsize; error = VOP_SETATTR(nd.ni_vp, vap, cred, - procp); + td); } } } @@ -1874,13 +1874,13 @@ nfsrv_create(nfsd, slp, procp, mrq) fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(nd.ni_vp, vap, cred, procp); + error = VOP_GETATTR(nd.ni_vp, vap, cred, td); } if (v3) { if (exclusive_flag && !error && bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF)) error = EEXIST; - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -1930,10 +1930,10 @@ nfsmout: * nfs v3 mknod service */ int -nfsrv_mknod(nfsd, slp, procp, mrq) +nfsrv_mknod(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1986,9 +1986,9 @@ nfsrv_mknod(nfsd, slp, procp, mrq) */ error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) - dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); @@ -2046,8 +2046,8 @@ nfsrv_mknod(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT); - nd.ni_cnd.cn_proc = procp; - nd.ni_cnd.cn_cred = procp->p_ucred; + nd.ni_cnd.cn_thread = td; + nd.ni_cnd.cn_cred = td->td_proc->p_ucred; error = lookup(&nd); nd.ni_dvp = NULL; @@ -2080,12 +2080,12 @@ out: fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nd.ni_vp = NULL; } - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); if (dirp) { vrele(dirp); dirp = NULL; @@ -2121,10 +2121,10 @@ nfsmout: * nfs remove service */ int -nfsrv_remove(nfsd, slp, procp, mrq) +nfsrv_remove(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2169,11 +2169,11 @@ nfsrv_remove(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2200,7 +2200,7 @@ out: } } if (dirp && v3) { - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -2228,10 +2228,10 @@ nfsmout: * nfs rename service */ int -nfsrv_rename(nfsd, slp, procp, mrq) +nfsrv_rename(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2293,11 +2293,11 @@ nfsrv_rename(nfsd, slp, procp, mrq) fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md, - &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dpos, &fdirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (fdirp) { if (v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, - procp); + td); } else { vrele(fdirp); fdirp = NULL; @@ -2318,11 +2318,11 @@ nfsrv_rename(nfsd, slp, procp, mrq) tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; error = nfs_namei(&tond, tfhp, len2, slp, nam, &md, - &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dpos, &tdirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (tdirp) { if (v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, - procp); + td); } else { vrele(tdirp); tdirp = NULL; @@ -2415,9 +2415,9 @@ out: out1: if (fdirp) - fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); + fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, td); if (tdirp) - tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); + tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, td); nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); @@ -2465,10 +2465,10 @@ nfsmout: * nfs link service */ int -nfsrv_link(nfsd, slp, procp, mrq) +nfsrv_link(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2528,11 +2528,11 @@ nfsrv_link(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2560,9 +2560,9 @@ out: out1: if (v3) - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); ereply: nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { @@ -2594,10 +2594,10 @@ nfsmout: * nfs symbolic link service */ int -nfsrv_symlink(nfsd, slp, procp, mrq) +nfsrv_symlink(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2644,11 +2644,11 @@ nfsrv_symlink(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2670,7 +2670,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) io.uio_iovcnt = 1; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; nfsm_mtouio(&io, len2); if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -2712,7 +2712,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | FOLLOW); nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); - nd.ni_cnd.cn_proc = procp; + nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -2724,7 +2724,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, vap, cred, - procp); + td); vput(nd.ni_vp); nd.ni_vp = NULL; } @@ -2740,7 +2740,7 @@ out: pathcp = NULL; } if (dirp) { - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -2784,10 +2784,10 @@ nfsmout: * nfs mkdir service */ int -nfsrv_mkdir(nfsd, slp, procp, mrq) +nfsrv_mkdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2836,11 +2836,11 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2890,11 +2890,11 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(nd.ni_vp, vap, cred, procp); + error = VOP_GETATTR(nd.ni_vp, vap, cred, td); } out: if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { @@ -2935,10 +2935,10 @@ nfsmout: * nfs rmdir service */ int -nfsrv_rmdir(nfsd, slp, procp, mrq) +nfsrv_rmdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2981,11 +2981,11 @@ nfsrv_rmdir(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -3027,7 +3027,7 @@ out: NDFREE(&nd, NDF_ONLY_PNBUF); if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); @@ -3091,10 +3091,10 @@ struct flrep { }; int -nfsrv_readdir(nfsd, slp, procp, mrq) +nfsrv_readdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3163,7 +3163,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_READ); if (v3) { - error = getret = VOP_GETATTR(vp, &at, cred, procp); + error = getret = VOP_GETATTR(vp, &at, cred, td); #if 0 /* * XXX This check may be too strict for Solaris 2.5 clients. @@ -3173,7 +3173,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) #endif } if (!error) - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 0); if (error) { vput(vp); vp = NULL; @@ -3182,7 +3182,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); /* * end section. Allocate rbuf and continue @@ -3197,9 +3197,9 @@ again: io.uio_resid = fullsiz; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; @@ -3209,11 +3209,11 @@ again: if (!cookies && !error) error = NFSERR_PERM; if (v3) { - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); if (!error) error = getret; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); if (error) { vrele(vp); vp = NULL; @@ -3384,10 +3384,10 @@ nfsmout: } int -nfsrv_readdirplus(nfsd, slp, procp, mrq) +nfsrv_readdirplus(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3445,7 +3445,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - error = getret = VOP_GETATTR(vp, &at, cred, procp); + error = getret = VOP_GETATTR(vp, &at, cred, td); #if 0 /* * XXX This check may be too strict for Solaris 2.5 clients. @@ -3455,7 +3455,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) #endif if (!error) { nqsrv_getl(vp, ND_READ); - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 0); } if (error) { vput(vp); @@ -3465,7 +3465,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; @@ -3476,17 +3476,17 @@ again: io.uio_resid = fullsiz; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); off = (u_quad_t)io.uio_offset; - getret = VOP_GETATTR(vp, &at, cred, procp); - VOP_UNLOCK(vp, 0, procp); + getret = VOP_GETATTR(vp, &at, cred, td); + VOP_UNLOCK(vp, 0, td); if (!cookies && !error) error = NFSERR_PERM; if (!error) @@ -3603,7 +3603,7 @@ again: nvp = NULL; goto invalid; } - if (VOP_GETATTR(nvp, vap, cred, procp)) { + if (VOP_GETATTR(nvp, vap, cred, td)) { vput(nvp); nvp = NULL; goto invalid; @@ -3721,10 +3721,10 @@ nfsmout: * nfs commit service */ int -nfsrv_commit(nfsd, slp, procp, mrq) +nfsrv_commit(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3778,7 +3778,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - for_ret = VOP_GETATTR(vp, &bfor, cred, procp); + for_ret = VOP_GETATTR(vp, &bfor, cred, td); if (cnt > MAX_COMMIT_COUNT) { /* @@ -3788,7 +3788,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) { vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC); } - error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); + error = VOP_FSYNC(vp, cred, MNT_WAIT, td); } else { /* * Locate and synchronously write any buffers that fall @@ -3846,7 +3846,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) splx(s); } - aft_ret = VOP_GETATTR(vp, &aft, cred, procp); + aft_ret = VOP_GETATTR(vp, &aft, cred, td); vput(vp); vp = NULL; ereply: @@ -3872,10 +3872,10 @@ nfsmout: * nfs statfs service */ int -nfsrv_statfs(nfsd, slp, procp, mrq) +nfsrv_statfs(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3913,8 +3913,8 @@ nfsrv_statfs(nfsd, slp, procp, mrq) goto nfsmout; } sf = &statfs; - error = VFS_STATFS(vp->v_mount, sf, procp); - getret = VOP_GETATTR(vp, &at, cred, procp); + error = VFS_STATFS(vp->v_mount, sf, td); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); @@ -3959,10 +3959,10 @@ nfsmout: * nfs fsinfo service */ int -nfsrv_fsinfo(nfsd, slp, procp, mrq) +nfsrv_fsinfo(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3999,10 +3999,10 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq) } /* XXX Try to make a guess on the max file size. */ - VFS_STATFS(vp->v_mount, &sb, procp); + VFS_STATFS(vp->v_mount, &sb, td); maxfsize = (u_quad_t)0x80000000 * sb.f_bsize - 1; - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); @@ -4041,10 +4041,10 @@ nfsmout: * nfs pathconf service */ int -nfsrv_pathconf(nfsd, slp, procp, mrq) +nfsrv_pathconf(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -4086,7 +4086,7 @@ nfsrv_pathconf(nfsd, slp, procp, mrq) error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres); if (!error) error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc); - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); @@ -4120,10 +4120,10 @@ nfsmout: */ /* ARGSUSED */ int -nfsrv_null(nfsd, slp, procp, mrq) +nfsrv_null(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep; @@ -4145,10 +4145,10 @@ nfsrv_null(nfsd, slp, procp, mrq) */ /* ARGSUSED */ int -nfsrv_noop(nfsd, slp, procp, mrq) +nfsrv_noop(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep; @@ -4184,12 +4184,12 @@ nfsrv_noop(nfsd, slp, procp, mrq) * will return EPERM instead of EACCESS. EPERM is always an error. */ static int -nfsrv_access(vp, flags, cred, rdonly, p, override) +nfsrv_access(vp, flags, cred, rdonly, td, override) register struct vnode *vp; int flags; register struct ucred *cred; int rdonly; - struct proc *p; + struct thread *td; int override; { struct vattr vattr; @@ -4220,10 +4220,10 @@ nfsrv_access(vp, flags, cred, rdonly, p, override) if (vp->v_flag & VTEXT) return (ETXTBSY); } - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); - error = VOP_ACCESS(vp, flags, cred, p); + error = VOP_ACCESS(vp, flags, cred, td); /* * Allow certain operations for the owner (reads and writes * on files that are already open). diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 5772e4b..8991672 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -149,7 +149,7 @@ int nfsrtton = 0; struct nfsrtt nfsrtt; struct callout_handle nfs_timer_handle; -static int nfs_msg __P((struct proc *,char *,char *)); +static int nfs_msg __P((struct thread *,char *,char *)); static int nfs_rcvlock __P((struct nfsreq *)); static void nfs_rcvunlock __P((struct nfsreq *)); static void nfs_realign __P((struct mbuf **pm, int hsiz)); @@ -162,7 +162,7 @@ static int nfsrv_getstream __P((struct nfssvc_sock *,int)); int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)) = { nfsrv_null, nfsrv_getattr, @@ -207,12 +207,12 @@ nfs_connect(nmp, rep) int pktscale; struct sockaddr *saddr; struct sockaddr_in *sin; - struct proc *p = &proc0; /* only used for socreate and sobind */ + struct thread *td = thread0; /* only used for socreate and sobind */ nmp->nm_so = (struct socket *)0; saddr = nmp->nm_nam; error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype, - nmp->nm_soproto, p); + nmp->nm_soproto, td); if (error) goto bad; so = nmp->nm_so; @@ -233,7 +233,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -243,7 +243,7 @@ nfs_connect(nmp, rep) sin->sin_family = AF_INET; sin->sin_addr.s_addr = INADDR_ANY; sin->sin_port = htons(0); - error = sobind(so, (struct sockaddr *)sin, p); + error = sobind(so, (struct sockaddr *)sin, td); if (error) goto bad; bzero(&sopt, sizeof sopt); @@ -253,7 +253,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -269,7 +269,7 @@ nfs_connect(nmp, rep) goto bad; } } else { - error = soconnect(so, nmp->nm_nam, p); + error = soconnect(so, nmp->nm_nam, td); if (error) goto bad; @@ -284,7 +284,8 @@ nfs_connect(nmp, rep) "nfscon", 2 * hz); if ((so->so_state & SS_ISCONNECTING) && so->so_error == 0 && rep && - (error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){ + (error = nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) != 0){ so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -489,7 +490,7 @@ nfs_send(so, nam, top, rep) flags = 0; error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0, - flags, curproc /*XXX*/); + flags, curthread /*XXX*/); /* * ENOBUFS for dgram sockets is transient and non fatal. * No need to log, and no need to break a soft mount. @@ -547,7 +548,7 @@ nfs_receive(rep, aname, mp) u_int32_t len; struct sockaddr **getnam; int error, sotype, rcvflg; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ /* * Set up arguments for soreceive() @@ -614,7 +615,7 @@ tryagain: auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(u_int32_t); - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = MSG_WAITALL; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -682,7 +683,7 @@ tryagain: * on. */ auio.uio_resid = len = 100000000; /* Anything Big */ - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -727,7 +728,7 @@ errout: else getnam = aname; auio.uio_resid = len = 1000000; - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -937,11 +938,11 @@ nfsmout: * nb: always frees up mreq mbuf list */ int -nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) +nfs_request(vp, mrest, procnum, td, cred, mrp, mdp, dposp) struct vnode *vp; struct mbuf *mrest; int procnum; - struct proc *procp; + struct thread *td; struct ucred *cred; struct mbuf **mrp; struct mbuf **mdp; @@ -969,7 +970,7 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK); rep->r_nmp = nmp; rep->r_vp = vp; - rep->r_procp = procp; + rep->r_td = td; rep->r_procnum = procnum; i = 0; m = mrest; @@ -1100,7 +1101,7 @@ tryagain: * tprintf a response. */ if (!error && (rep->r_flags & R_TPRINTFMSG)) - nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "is alive again"); mrep = rep->r_mrep; md = rep->r_md; @@ -1394,14 +1395,15 @@ nfs_timer(arg) register struct nfssvc_sock *slp; u_quad_t cur_usec; #endif /* NFS_NOSERVER */ - struct proc *p = &proc0; /* XXX for credentials, will break if sleep */ + struct thread *td = thread0; /* XXX for credentials, will break if sleep */ s = splnet(); for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) { nmp = rep->r_nmp; if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) continue; - if (nfs_sigintr(nmp, rep, rep->r_procp)) { + if (nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) { nfs_softterm(rep); continue; } @@ -1423,7 +1425,7 @@ nfs_timer(arg) */ if ((rep->r_flags & R_TPRINTFMSG) == 0 && rep->r_rexmit > nmp->nm_deadthresh) { - nfs_msg(rep->r_procp, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "not responding"); rep->r_flags |= R_TPRINTFMSG; @@ -1455,11 +1457,11 @@ nfs_timer(arg) if ((nmp->nm_flag & NFSMNT_NOCONN) == 0) error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, (struct sockaddr *)0, - (struct mbuf *)0, p); + (struct mbuf *)0, td); else error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, nmp->nm_nam, (struct mbuf *)0, - p); + td); if (error) { if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) so->so_error = 0; @@ -1566,17 +1568,17 @@ nfs_sndlock(rep) struct nfsreq *rep; { register int *statep = &rep->r_nmp->nm_state; - struct proc *p; + struct thread *td; int slpflag = 0, slptimeo = 0; if (rep) { - p = rep->r_procp; + td = rep->r_td; if (rep->r_nmp->nm_flag & NFSMNT_INT) slpflag = PCATCH; } else - p = (struct proc *)0; + td = (struct thread *)0; while (*statep & NFSSTA_SNDLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, p)) + if (nfs_sigintr(rep->r_nmp, rep, td ? td->td_proc : NULL)) return (EINTR); *statep |= NFSSTA_WANTSND; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), @@ -1620,7 +1622,8 @@ nfs_rcvlock(rep) else slpflag = 0; while (*statep & NFSSTA_RCVLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp)) + if (nfs_sigintr(rep->r_nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) return (EINTR); *statep |= NFSSTA_WANTRCV; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk", @@ -1966,12 +1969,12 @@ nfsmout: #endif static int -nfs_msg(p, server, msg) - struct proc *p; +nfs_msg(td, server, msg) + struct thread *td; char *server, *msg; { - tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg); + tprintf(td->td_proc, LOG_INFO, "nfs server %s: %s\n", server, msg); return (0); } @@ -2005,7 +2008,7 @@ nfsrv_rcv(so, arg, waitflag) slp->ns_flag |= SLP_NEEDQ; goto dorecs; } #endif - auio.uio_procp = NULL; + auio.uio_td = NULL; if (so->so_type == SOCK_STREAM) { /* * If there are already records on the queue, defer soreceive() diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index ad8891c..4425129 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -554,11 +554,11 @@ extern struct nfsnodehashhead *nfsnodehashtbl; extern u_long nfsnodehash; struct nfssvc_args; -extern int nfssvc(struct proc *, struct nfssvc_args *, int *); +extern int nfssvc(struct thread *, struct nfssvc_args *, int *); LIST_HEAD(nfsnodehashhead, nfsnode); -int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *)); +int nfs_webnamei __P((struct nameidata *, struct vnode *, struct thread *)); u_quad_t nfs_curusec() @@ -950,7 +950,7 @@ nfsm_disct(mdp, dposp, siz, left, cp2) { register struct mbuf *mp, *mp2; register int siz2, xfer; - register caddr_t p; + register caddr_t ptr; mp = *mdp; while (left == 0) { @@ -973,10 +973,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = p = mtod(mp, caddr_t); - bcopy(*dposp, p, left); /* Copy what was left */ + *cp2 = ptr = mtod(mp, caddr_t); + bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; - p += left; + ptr += left; mp2 = mp->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { @@ -984,10 +984,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) return (EBADRPC); xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { - bcopy(mtod(mp2, caddr_t), p, xfer); + bcopy(mtod(mp2, caddr_t), ptr, xfer); NFSMADV(mp2, xfer); mp2->m_len -= xfer; - p += xfer; + ptr += xfer; siz2 -= xfer; } if (siz2 > 0) @@ -1464,7 +1464,7 @@ nfs_getattrcache(vp, vaper) * released by the caller. */ int -nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) +nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, td, kerbflag, pubflag) register struct nameidata *ndp; fhandle_t *fhp; int len; @@ -1473,7 +1473,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) struct mbuf **mdp; caddr_t *dposp; struct vnode **retdirp; - struct proc *p; + struct thread *td; int kerbflag, pubflag; { register int i, rem; @@ -1613,7 +1613,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * becuase lookup() will dereference ni_startdir. */ - cnp->cn_proc = p; + cnp->cn_thread = td; VREF(dp); ndp->ni_startdir = dp; @@ -1649,7 +1649,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * Validate symlink */ if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); if (!pubflag) { error = EINVAL; goto badlink2; @@ -1670,7 +1670,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -1924,7 +1924,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) int kerbflag; int pubflag; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register struct mount *mp; register int i; struct ucred *credanon; @@ -1988,7 +1988,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) nfsrv_object_create(*vpp); if (!lockflag) - VOP_UNLOCK(*vpp, 0, p); + VOP_UNLOCK(*vpp, 0, td); return (0); } @@ -2196,8 +2196,8 @@ nfsrv_object_create(vp) if (vp == NULL || vp->v_type != VREG) return (1); - return (vfs_object_create(vp, curproc, - curproc ? curproc->p_ucred : NULL)); + return (vfs_object_create(vp, curthread, + curthread ? curthread->td_proc->p_ucred : NULL)); } /* diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index e378cc5..657f299 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -78,7 +78,7 @@ static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure"); /* Global defs. */ extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)); extern int nfs_numasync; extern time_t nqnfsstarttime; @@ -92,7 +92,7 @@ static int nuidhash_max = NFS_MAXUIDHASH; #ifndef NFS_NOSERVER static void nfsrv_zapsock __P((struct nfssvc_sock *slp)); #endif -static int nfssvc_iod __P((struct proc *)); +static int nfssvc_iod __P((struct thread *)); #define TRUE 1 #define FALSE 0 @@ -110,8 +110,9 @@ static int modify_flag = 0; static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd, int cacherep)); static int nfssvc_addsock __P((struct file *, struct sockaddr *, - struct proc *)); -static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); + struct thread *)); +static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t, + struct thread *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); @@ -140,8 +141,8 @@ struct nfssvc_args { * MPSAFE */ int -nfssvc(p, uap) - struct proc *p; +nfssvc(td, uap) + struct thread *td; register struct nfssvc_args *uap; { #ifndef NFS_NOSERVER @@ -165,13 +166,13 @@ nfssvc(p, uap) error = copyin(uap->argp, &la, sizeof(la)); if (error == 0) - error = nfslockdans(p, &la); + error = nfslockdans(td->td_proc, &la); goto done2; } /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) goto done2; while (nfssvc_sockhead_flag & SLP_INIT) { @@ -179,7 +180,7 @@ nfssvc(p, uap) (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0); } if (uap->flag & NFSSVC_BIOD) - error = nfssvc_iod(p); + error = nfssvc_iod(td); #ifdef NFS_NOSERVER else error = ENXIO; @@ -189,7 +190,7 @@ nfssvc(p, uap) if (error) goto done2; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - ncd.ncd_dirp, p); + ncd.ncd_dirp, td); error = namei(&nd); if (error) goto done2; @@ -206,13 +207,13 @@ nfssvc(p, uap) goto done2; } nmp->nm_state |= NFSSTA_MNTD; - error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag, - uap->argp, p); + error = nqnfs_clientd(nmp, td->td_proc->p_ucred, &ncd, uap->flag, + uap->argp, td); } else if (uap->flag & NFSSVC_ADDSOCK) { error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg)); if (error) goto done2; - error = holdsock(p->p_fd, nfsdarg.sock, &fp); + error = holdsock(td->td_proc->p_fd, nfsdarg.sock, &fp); if (error) goto done2; /* @@ -224,12 +225,12 @@ nfssvc(p, uap) error = getsockaddr(&nam, nfsdarg.name, nfsdarg.namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } } - error = nfssvc_addsock(fp, nam, p); - fdrop(fp, p); + error = nfssvc_addsock(fp, nam, td); + fdrop(fp, td); } else { error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd)); if (error) @@ -327,7 +328,7 @@ nfssvc(p, uap) } if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd)) nfsd->nfsd_flag |= NFSD_AUTHFAIL; - error = nfssvc_nfsd(nsd, uap->argp, p); + error = nfssvc_nfsd(nsd, uap->argp, td); } #endif /* NFS_NOSERVER */ if (error == EINTR || error == ERESTART) @@ -342,10 +343,10 @@ done2: * Adds a socket to the list for servicing by nfsds. */ static int -nfssvc_addsock(fp, mynam, p) +nfssvc_addsock(fp, mynam, td) struct file *fp; struct sockaddr *mynam; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -439,10 +440,10 @@ nfssvc_addsock(fp, mynam, p) * until it is killed by a signal. */ static int -nfssvc_nfsd(nsd, argp, p) +nfssvc_nfsd(nsd, argp, td) struct nfsd_srvargs *nsd; caddr_t argp; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -461,7 +462,7 @@ nfssvc_nfsd(nsd, argp, p) nsd->nsd_nfsd = nfsd = (struct nfsd *) malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); - nfsd->nfsd_procp = p; + nfsd->nfsd_td = td; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); nfs_numnfsd++; } else @@ -622,10 +623,10 @@ nfssvc_nfsd(nsd, argp, p) if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, - nfsd->nfsd_procp, &mreq); + nfsd->nfsd_td, &mreq); else error = (*(nfsrv3_procs[nd->nd_procnum]))(nd, - slp, nfsd->nfsd_procp, &mreq); + slp, nfsd->nfsd_td, &mreq); if (mreq == NULL) break; if (error != 0 && error != NFSERR_RETVOID) { @@ -757,7 +758,7 @@ nfsrv_zapsock(slp) so->so_upcall = NULL; so->so_upcallarg = NULL; soshutdown(so, 2); - closef(fp, (struct proc *)0); + closef(fp, (struct thread *)0); if (slp->ns_nam) FREE(slp->ns_nam, M_SONAME); m_freem(slp->ns_raw); @@ -935,8 +936,8 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, ""); * Never returns unless it fails or gets killed. */ static int -nfssvc_iod(p) - struct proc *p; +nfssvc_iod(td) + struct thread *td; { register struct buf *bp; register int i, myiod; @@ -965,7 +966,7 @@ nfssvc_iod(p) && error == 0) { if (nmp) nmp->nm_bufqiods--; - nfs_iodwant[myiod] = p; + nfs_iodwant[myiod] = td->td_proc; nfs_iodmount[myiod] = NULL; error = tsleep((caddr_t)&nfs_iodwant[myiod], PWAIT | PCATCH, "nfsidl", 0); @@ -988,9 +989,9 @@ nfssvc_iod(p) wakeup(&nmp->nm_bufq); } if (bp->b_iocmd == BIO_READ) - (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_rcred, (struct thread *)0); else - (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_wcred, (struct thread *)0); /* * If there are more than one iod on this mount, then defect * so that the iods can be shared out fairly between the mounts @@ -1029,7 +1030,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) nmp->nm_state |= NFSSTA_WANTAUTH; (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK, "nfsauth1", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); if (error) { nmp->nm_state &= ~NFSSTA_WANTAUTH; return (error); @@ -1049,7 +1050,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) { (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK, "nfsauth2", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); } if (nmp->nm_state & NFSSTA_AUTHERR) { nmp->nm_state &= ~NFSSTA_AUTHERR; diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index bc6f3c0..c70600f 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -101,14 +101,14 @@ static void nfs_decode_args __P((struct nfsmount *nmp, static int mountnfs __P((struct nfs_args *,struct mount *, struct sockaddr *,char *,char *,struct vnode **)); static int nfs_mount __P(( struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *p)); static int nfs_unmount __P(( struct mount *mp, int mntflags, - struct proc *p)); + struct thread *p)); static int nfs_root __P(( struct mount *mp, struct vnode **vpp)); static int nfs_statfs __P(( struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *p)); static int nfs_sync __P(( struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *p)); /* * nfs vfs operations. @@ -161,7 +161,7 @@ SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD, void nfsargs_ntoh __P((struct nfs_args *)); static int nfs_mountdiskless __P((char *, char *, int, struct sockaddr_in *, struct nfs_args *, - struct proc *, struct vnode **, + struct thread *, struct vnode **, struct mount **)); static void nfs_convert_diskless __P((void)); static void nfs_convert_oargs __P((struct nfs_args *args, @@ -241,10 +241,10 @@ nfs_convert_diskless() * nfs statfs call */ int -nfs_statfs(mp, sbp, p) +nfs_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { register struct vnode *vp; register struct nfs_statfs *sfp; @@ -266,11 +266,11 @@ nfs_statfs(mp, sbp, p) return (error); vp = NFSTOV(np); if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, p->p_ucred, p); + (void)nfs_fsinfo(nmp, vp, td->td_proc->p_ucred, td); nfsstats.rpccnt[NFSPROC_FSSTAT]++; nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_FSSTAT, p, p->p_ucred); + nfsm_request(vp, NFSPROC_FSSTAT, td, td->td_proc->p_ucred); if (v3) nfsm_postop_attr(vp, retattr); if (error) { @@ -315,11 +315,11 @@ nfs_statfs(mp, sbp, p) * nfs version 3 fsinfo rpc call */ int -nfs_fsinfo(nmp, vp, cred, p) +nfs_fsinfo(nmp, vp, cred, td) register struct nfsmount *nmp; register struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct nfsv3_fsinfo *fsp; register caddr_t cp; @@ -333,7 +333,7 @@ nfs_fsinfo(nmp, vp, cred, p) nfsstats.rpccnt[NFSPROC_FSINFO]++; nfsm_reqhead(vp, NFSPROC_FSINFO, NFSX_FH(1)); nfsm_fhtom(vp, 1); - nfsm_request(vp, NFSPROC_FSINFO, p, cred); + nfsm_request(vp, NFSPROC_FSINFO, td, cred); nfsm_postop_attr(vp, retattr); if (!error) { nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO); @@ -394,7 +394,7 @@ nfs_mountroot(mp) struct nfsv3_diskless *nd = &nfsv3_diskless; struct socket *so; struct vnode *vp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int error, i; u_long l; char buf[128]; @@ -433,7 +433,7 @@ nfs_mountroot(mp) * Do enough of ifconfig(8) so that the critical net interface can * talk to the server. */ - error = socreate(nd->myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0, p); + error = socreate(nd->myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0, td); if (error) panic("nfs_mountroot: socreate(%04x): %d", nd->myif.ifra_addr.sa_family, error); @@ -449,12 +449,12 @@ nfs_mountroot(mp) nd->myif.ifra_name[i] >= '0' && nd->myif.ifra_name[i] <= '9'; nd->myif.ifra_name[i] ++) { - error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, p); + error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); if(!error) break; } #endif - error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, p); + error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); if (error) panic("nfs_mountroot: SIOCAIFADDR: %d", error); soclose(so); @@ -488,7 +488,7 @@ nfs_mountroot(mp) (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam); printf("NFS ROOT: %s\n",buf); if ((error = nfs_mountdiskless(buf, "/", MNT_RDONLY, - &nd->root_saddr, &nd->root_args, p, &vp, &mp)) != 0) { + &nd->root_saddr, &nd->root_args, td, &vp, &mp)) != 0) { if (swap_mp) { mp->mnt_vfc->vfc_refcount--; free(swap_mp, M_MOUNT); @@ -514,9 +514,9 @@ nfs_mountroot(mp) (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam); printf("NFS SWAP: %s\n",buf); if ((error = nfs_mountdiskless(buf, "/swap", 0, - &nd->swap_saddr, &nd->swap_args, p, &vp, &swap_mp)) != 0) + &nd->swap_saddr, &nd->swap_args, td, &vp, &swap_mp)) != 0) return (error); - vfs_unbusy(swap_mp, p); + vfs_unbusy(swap_mp, td); VTONFS(vp)->n_size = VTONFS(vp)->n_vattr.va_size = nd->swap_nblks * DEV_BSIZE ; @@ -528,13 +528,13 @@ nfs_mountroot(mp) vp->v_type = VREG; vp->v_flag = 0; VREF(vp); - swaponvp(p, vp, NODEV, nd->swap_nblks); + swaponvp(td, vp, NODEV, nd->swap_nblks); } mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; rootvp = vp; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); /* * This is not really an nfs issue, but it is much easier to @@ -554,13 +554,13 @@ nfs_mountroot(mp) * Internal version of mount system call for diskless setup. */ static int -nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp) +nfs_mountdiskless(path, which, mountflag, sin, args, td, vpp, mpp) char *path; char *which; int mountflag; struct sockaddr_in *sin; struct nfs_args *args; - struct proc *p; + struct thread *td; struct vnode **vpp; struct mount **mpp; { @@ -581,7 +581,7 @@ nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp) if ((error = mountnfs(args, mp, nam, which, path, vpp)) != 0) { printf("nfs_mountroot: mount %s on %s: %d", path, which, error); mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); free(mp, M_MOUNT); FREE(nam, M_SONAME); return (error); @@ -750,12 +750,12 @@ nfs_decode_args(nmp, argp) */ /* ARGSUSED */ static int -nfs_mount(mp, path, data, ndp, p) +nfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error; struct nfs_args args; @@ -930,12 +930,12 @@ mountnfs(argp, mp, nam, pth, hst, vpp) * Get file attributes for the mountpoint. This has the side * effect of filling in (*vpp)->v_type with the correct value. */ - VOP_GETATTR(*vpp, &attrs, curproc->p_ucred, curproc); + VOP_GETATTR(*vpp, &attrs, curthread->td_proc->p_ucred, curthread); /* * Lose the lock but keep the ref. */ - VOP_UNLOCK(*vpp, 0, curproc); + VOP_UNLOCK(*vpp, 0, curthread); return (0); bad: @@ -949,10 +949,10 @@ bad: * unmount system call */ static int -nfs_unmount(mp, mntflags, p) +nfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct nfsmount *nmp; int error, flags = 0; @@ -1027,11 +1027,11 @@ extern int syncprt; */ /* ARGSUSED */ static int -nfs_sync(mp, waitfor, cred, p) +nfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *vp, *vnp; int error, allerror = 0; @@ -1059,11 +1059,11 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { mtx_lock(&mntvnode_mtx); goto loop; } - error = VOP_FSYNC(vp, cred, waitfor, p); + error = VOP_FSYNC(vp, cred, waitfor, td); if (error) allerror = error; vput(vp); diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 5b84741..8f9ff7d 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -102,8 +102,8 @@ static int nfsfifo_write __P((struct vop_write_args *)); static int nfsspec_close __P((struct vop_close_args *)); static int nfsfifo_close __P((struct vop_close_args *)); #define nfs_poll vop_nopoll -static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); -static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); +static int nfs_flush __P((struct vnode *,struct ucred *,int,struct thread *,int)); +static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct thread *)); static int nfs_lookup __P((struct vop_lookup_args *)); static int nfs_create __P((struct vop_create_args *)); static int nfs_mknod __P((struct vop_mknod_args *)); @@ -123,7 +123,7 @@ static int nfs_symlink __P((struct vop_symlink_args *)); static int nfs_readdir __P((struct vop_readdir_args *)); static int nfs_strategy __P((struct vop_strategy_args *)); static int nfs_lookitup __P((struct vnode *, const char *, int, - struct ucred *, struct proc *, struct nfsnode **)); + struct ucred *, struct thread *, struct nfsnode **)); static int nfs_sillyrename __P((struct vnode *,struct vnode *,struct componentname *)); static int nfsspec_access __P((struct vop_access_args *)); static int nfs_readlink __P((struct vop_readlink_args *)); @@ -224,11 +224,11 @@ static int nfs_mknodrpc __P((struct vnode *dvp, struct vnode **vpp, struct vattr *vap)); static int nfs_removerpc __P((struct vnode *dvp, const char *name, int namelen, - struct ucred *cred, struct proc *proc)); + struct ucred *cred, struct thread *td)); static int nfs_renamerpc __P((struct vnode *fdvp, const char *fnameptr, int fnamelen, struct vnode *tdvp, const char *tnameptr, int tnamelen, - struct ucred *cred, struct proc *proc)); + struct ucred *cred, struct thread *td)); static int nfs_renameit __P((struct vnode *sdvp, struct componentname *scnp, struct sillyrename *sp)); @@ -268,7 +268,7 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, static int nfs3_access_otw(struct vnode *vp, int wmode, - struct proc *p, + struct thread *td, struct ucred *cred) { const int v3 = 1; @@ -287,7 +287,7 @@ nfs3_access_otw(struct vnode *vp, nfsm_fhtom(vp, v3); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(wmode); - nfsm_request(vp, NFSPROC_ACCESS, p, cred); + nfsm_request(vp, NFSPROC_ACCESS, td, cred); nfsm_postop_attr(vp, attrflag); if (!error) { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); @@ -312,7 +312,7 @@ nfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -383,7 +383,7 @@ nfs_access(ap) * Either a no, or a don't know. Go to the wire. */ nfsstats.accesscache_misses++; - error = nfs3_access_otw(vp, wmode, ap->a_p,ap->a_cred); + error = nfs3_access_otw(vp, wmode, ap->a_td,ap->a_cred); if (!error) { if ((np->n_mode & mode) != mode) { error = EACCES; @@ -416,7 +416,7 @@ nfs_access(ap) auio.uio_resid = 1; auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = ap->a_p; + auio.uio_td = ap->a_td; if (vp->v_type == VREG) error = nfs_readrpc(vp, &auio, ap->a_cred); @@ -450,7 +450,7 @@ nfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -472,14 +472,14 @@ nfs_open(ap) if (NQNFS_CKINVALID(vp, np, ND_READ)) { do { error = nqnfs_getlease(vp, ND_READ, ap->a_cred, - ap->a_p); + ap->a_td); } while (error == NQNFS_EXPIRED); if (error) return (error); if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); np->n_brev = np->n_lrev; } @@ -487,24 +487,24 @@ nfs_open(ap) } else { if (np->n_flag & NMODIFIED) { if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); np->n_attrstamp = 0; if (vp->v_type == VDIR) np->n_direofoffset = 0; - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { if (vp->v_type == VDIR) np->n_direofoffset = 0; if ((error = nfs_vinvalbuf(vp, V_SAVE, - ap->a_cred, ap->a_p, 1)) == EINTR) + ap->a_cred, ap->a_td, 1)) == EINTR) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } @@ -553,7 +553,7 @@ nfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -578,10 +578,10 @@ nfs_close(ap) * cannot clear it if we don't commit. */ int cm = nfsv3_commit_on_close ? 1 : 0; - error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_p, cm); + error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_td, cm); /* np->n_flag &= ~NMODIFIED; */ } else { - error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1); } np->n_attrstamp = 0; } @@ -602,7 +602,7 @@ nfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -628,7 +628,7 @@ nfs_getattr(ap) if (v3 && nfsaccess_cache_timeout > 0) { nfsstats.accesscache_misses++; - nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_p, ap->a_cred); + nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_td, ap->a_cred); if (nfs_getattrcache(vp, ap->a_vap) == 0) return (0); } @@ -636,7 +636,7 @@ nfs_getattr(ap) nfsstats.rpccnt[NFSPROC_GETATTR]++; nfsm_reqhead(vp, NFSPROC_GETATTR, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_GETATTR, ap->a_p, ap->a_cred); + nfsm_request(vp, NFSPROC_GETATTR, ap->a_td, ap->a_cred); if (!error) { nfsm_loadattr(vp, ap->a_vap); } @@ -654,7 +654,7 @@ nfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -708,10 +708,10 @@ nfs_setattr(ap) if (np->n_flag & NMODIFIED) { if (vap->va_size == 0) error = nfs_vinvalbuf(vp, 0, - ap->a_cred, ap->a_p, 1); + ap->a_cred, ap->a_td, 1); else error = nfs_vinvalbuf(vp, V_SAVE, - ap->a_cred, ap->a_p, 1); + ap->a_cred, ap->a_td, 1); if (error) { vnode_pager_setsize(vp, np->n_size); return (error); @@ -724,9 +724,9 @@ nfs_setattr(ap) vap->va_atime.tv_sec != VNOVAL) && (np->n_flag & NMODIFIED) && vp->v_type == VREG && (error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); - error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_p); + error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_td); if (error && vap->va_size != VNOVAL) { np->n_size = np->n_vattr.va_size = tsize; vnode_pager_setsize(vp, np->n_size); @@ -738,11 +738,11 @@ nfs_setattr(ap) * Do an nfs setattr rpc. */ static int -nfs_setattrrpc(vp, vap, cred, procp) +nfs_setattrrpc(vp, vap, cred, td) register struct vnode *vp; register struct vattr *vap; struct ucred *cred; - struct proc *procp; + struct thread *td; { register struct nfsv2_sattr *sp; register caddr_t cp; @@ -778,7 +778,7 @@ nfs_setattrrpc(vp, vap, cred, procp) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(vp, NFSPROC_SETATTR, procp, cred); + nfsm_request(vp, NFSPROC_SETATTR, td, cred); if (v3) { nfsm_wcc_data(vp, wccflag); } else @@ -817,7 +817,7 @@ nfs_lookup(ap) struct nfsnode *np; int lockparent, wantparent, error = 0, attrflag, fhsize; int v3 = NFS_ISV3(dvp); - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; *vpp = NULLVP; cnp->cn_flags &= ~PDIRUNLOCK; @@ -834,7 +834,7 @@ nfs_lookup(ap) struct vattr vattr; int vpid; - if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) != 0) { + if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) { *vpp = NULLVP; return (error); } @@ -849,24 +849,24 @@ nfs_lookup(ap) VREF(newvp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; - error = vget(newvp, LK_EXCLUSIVE, p); + error = vget(newvp, LK_EXCLUSIVE, td); if (!error && lockparent && (flags & ISLASTCN)) { - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error == 0) cnp->cn_flags &= ~PDIRUNLOCK; } } else { - error = vget(newvp, LK_EXCLUSIVE, p); + error = vget(newvp, LK_EXCLUSIVE, td); if (!lockparent || error || !(flags & ISLASTCN)) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } if (!error) { if (vpid == newvp->v_id) { - if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, p) + if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td) && vattr.va_ctime.tv_sec == VTONFS(newvp)->n_ctime) { nfsstats.lookupcache_hits++; if (cnp->cn_nameiop != LOOKUP && @@ -878,9 +878,9 @@ nfs_lookup(ap) } vput(newvp); if (lockparent && dvp != newvp && (flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); *vpp = NULLVP; if (error) { cnp->cn_flags |= PDIRUNLOCK; @@ -897,7 +897,7 @@ nfs_lookup(ap) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_thread, cnp->cn_cred); if (error) { nfsm_postop_attr(dvp, attrflag); m_freem(mrep); @@ -928,22 +928,22 @@ nfs_lookup(ap) m_freem(mrep); cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); } if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); error = nfs_nget(dvp->v_mount, fhp, fhsize, &np); if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } newvp = NFSTOV(np); if (lockparent && (flags & ISLASTCN)) { - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error) { cnp->cn_flags |= PDIRUNLOCK; vput(newvp); @@ -962,7 +962,7 @@ nfs_lookup(ap) } if (!lockparent || !(flags & ISLASTCN)) { cnp->cn_flags |= PDIRUNLOCK; - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } newvp = NFSTOV(np); } @@ -988,7 +988,7 @@ nfs_lookup(ap) if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && (flags & ISLASTCN) && error == ENOENT) { if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } if (dvp->v_mount->mnt_flag & MNT_RDONLY) @@ -1061,7 +1061,7 @@ nfs_readlinkrpc(vp, uiop, cred) nfsstats.rpccnt[NFSPROC_READLINK]++; nfsm_reqhead(vp, NFSPROC_READLINK, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_READLINK, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READLINK, uiop->uio_td, cred); if (v3) nfsm_postop_attr(vp, attrflag); if (!error) { @@ -1117,7 +1117,7 @@ nfs_readrpc(vp, uiop, cred) *tl++ = txdr_unsigned(len); *tl = 0; } - nfsm_request(vp, NFSPROC_READ, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READ, uiop->uio_td, cred); if (v3) { nfsm_postop_attr(vp, attrflag); if (error) { @@ -1195,7 +1195,7 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit) *tl = x; /* size of this write */ } nfsm_uiotom(uiop, len); - nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_WRITE, uiop->uio_td, cred); if (v3) { wccflag = NFSV3_WCCCHK; nfsm_wcc_data(vp, wccflag); @@ -1288,7 +1288,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) else { return (EOPNOTSUPP); } - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } nfsstats.rpccnt[NFSPROC_MKNOD]++; @@ -1314,7 +1314,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_MKNOD, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_MKNOD, cnp->cn_thread, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1323,7 +1323,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1396,7 +1396,7 @@ nfs_create(ap) if (vap->va_type == VSOCK) return (nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap)); - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } if (vap->va_vaflags & VA_EXCLUSIVE) @@ -1432,7 +1432,7 @@ again: txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_thread, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1441,7 +1441,7 @@ again: newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1469,7 +1469,7 @@ again: vfs_timestamp(&vap->va_mtime); if (vap->va_atime.tv_sec == VNOVAL) vap->va_atime = vap->va_mtime; - error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_proc); + error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_thread); } if (!error) { if (cnp->cn_flags & MAKEENTRY) @@ -1518,7 +1518,7 @@ nfs_remove(ap) if (vp->v_type == VDIR) error = EPERM; else if (vp->v_usecount == 1 || (np->n_sillyrename && - VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_proc) == 0 && + VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_thread) == 0 && vattr.va_nlink > 1)) { /* * Purge the name cache so that the chance of a lookup for @@ -1532,11 +1532,11 @@ nfs_remove(ap) * throw away biocache buffers, mainly to avoid * unnecessary delayed writes later. */ - error = nfs_vinvalbuf(vp, 0, cnp->cn_cred, cnp->cn_proc, 1); + error = nfs_vinvalbuf(vp, 0, cnp->cn_cred, cnp->cn_thread, 1); /* Do the rpc */ if (error != EINTR) error = nfs_removerpc(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread); /* * Kludge City: If the first reply to the remove rpc is lost.. * the reply to the retransmitted request will be ENOENT @@ -1560,19 +1560,19 @@ nfs_removeit(sp) { return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, sp->s_cred, - (struct proc *)0)); + (struct thread *)0)); } /* * Nfs remove rpc, called from nfs_remove() and nfs_removeit(). */ static int -nfs_removerpc(dvp, name, namelen, cred, proc) +nfs_removerpc(dvp, name, namelen, cred, td) register struct vnode *dvp; const char *name; int namelen; struct ucred *cred; - struct proc *proc; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -1587,7 +1587,7 @@ nfs_removerpc(dvp, name, namelen, cred, proc) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen)); nfsm_fhtom(dvp, v3); nfsm_strtom(name, namelen, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_REMOVE, proc, cred); + nfsm_request(dvp, NFSPROC_REMOVE, td, cred); if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; @@ -1640,9 +1640,9 @@ nfs_rename(ap) * often. */ - VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_proc); + VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); if (tvp) - VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc); + VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); /* * If the tvp exists and is in use, sillyrename it before doing the @@ -1657,7 +1657,7 @@ nfs_rename(ap) error = nfs_renamerpc(fdvp, fcnp->cn_nameptr, fcnp->cn_namelen, tdvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred, - tcnp->cn_proc); + tcnp->cn_thread); if (fvp->v_type == VDIR) { if (tvp != NULL && tvp->v_type == VDIR) @@ -1692,14 +1692,14 @@ nfs_renameit(sdvp, scnp, sp) register struct sillyrename *sp; { return (nfs_renamerpc(sdvp, scnp->cn_nameptr, scnp->cn_namelen, - sdvp, sp->s_name, sp->s_namlen, scnp->cn_cred, scnp->cn_proc)); + sdvp, sp->s_name, sp->s_namlen, scnp->cn_cred, scnp->cn_thread)); } /* * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit(). */ static int -nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) +nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, td) register struct vnode *fdvp; const char *fnameptr; int fnamelen; @@ -1707,7 +1707,7 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) const char *tnameptr; int tnamelen; struct ucred *cred; - struct proc *proc; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -1725,7 +1725,7 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN); nfsm_fhtom(tdvp, v3); nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN); - nfsm_request(fdvp, NFSPROC_RENAME, proc, cred); + nfsm_request(fdvp, NFSPROC_RENAME, td, cred); if (v3) { nfsm_wcc_data(fdvp, fwccflag); nfsm_wcc_data(tdvp, twccflag); @@ -1771,7 +1771,7 @@ nfs_link(ap) * doesn't get "out of sync" with the server. * XXX There should be a better way! */ - VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc); + VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_thread); v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; @@ -1780,7 +1780,7 @@ nfs_link(ap) nfsm_fhtom(vp, v3); nfsm_fhtom(tdvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred); + nfsm_request(vp, NFSPROC_LINK, cnp->cn_thread, cnp->cn_cred); if (v3) { nfsm_postop_attr(vp, attrflag); nfsm_wcc_data(tdvp, wccflag); @@ -1852,7 +1852,7 @@ nfs_symlink(ap) * a file handle that can be converted into newvp without having * to do an extra lookup rpc. */ - nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_thread, cnp->cn_cred); if (v3) { if (error == 0) nfsm_mtofh(dvp, newvp, v3, gotvp); @@ -1882,7 +1882,7 @@ nfs_symlink(ap) struct nfsnode *np = NULL; error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1927,7 +1927,7 @@ nfs_mkdir(ap) struct vattr vattr; int v3 = NFS_ISV3(dvp); - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } len = cnp->cn_namelen; @@ -1947,7 +1947,7 @@ nfs_mkdir(ap) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_thread, cnp->cn_cred); if (!error) nfsm_mtofh(dvp, newvp, v3, gotvp); if (v3) @@ -1966,7 +1966,7 @@ nfs_mkdir(ap) newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred, - cnp->cn_proc, &np); + cnp->cn_thread, &np); if (!error) { newvp = NFSTOV(np); if (newvp->v_type != VDIR) @@ -2010,7 +2010,7 @@ nfs_rmdir(ap) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_thread, cnp->cn_cred); if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; @@ -2056,7 +2056,7 @@ nfs_readdir(ap) nfsstats.direofcache_hits++; return (0); } - } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) == 0 && + } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_td) == 0 && np->n_mtime == vattr.va_mtime.tv_sec) { nfsstats.direofcache_hits++; return (0); @@ -2136,7 +2136,7 @@ nfs_readdirrpc(vp, uiop, cred) *tl++ = cookie.nfsuquad[0]; } *tl = txdr_unsigned(nmp->nm_readdirsize); - nfsm_request(vp, NFSPROC_READDIR, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READDIR, uiop->uio_td, cred); if (v3) { nfsm_postop_attr(vp, attrflag); if (!error) { @@ -2326,7 +2326,7 @@ nfs_readdirplusrpc(vp, uiop, cred) *tl++ = dnp->n_cookieverf.nfsuquad[1]; *tl++ = txdr_unsigned(nmp->nm_readdirsize); *tl = txdr_unsigned(nmp->nm_rsize); - nfsm_request(vp, NFSPROC_READDIRPLUS, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READDIRPLUS, uiop->uio_td, cred); nfsm_postop_attr(vp, attrflag); if (error) { m_freem(mrep); @@ -2525,12 +2525,12 @@ nfs_sillyrename(dvp, vp, cnp) VREF(dvp); /* Fudge together a funny name */ - pid = cnp->cn_proc->p_pid; + pid = cnp->cn_thread->td_proc->p_pid; sp->s_namlen = sprintf(sp->s_name, ".nfsA%04x4.4", pid); /* Try lookitups until we get one that isn't there */ while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_proc, (struct nfsnode **)0) == 0) { + cnp->cn_thread, (struct nfsnode **)0) == 0) { sp->s_name[4]++; if (sp->s_name[4] > 'z') { error = EINVAL; @@ -2541,7 +2541,7 @@ nfs_sillyrename(dvp, vp, cnp) if (error) goto bad; error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_proc, &np); + cnp->cn_thread, &np); np->n_sillyrename = sp; return (0); bad: @@ -2560,12 +2560,12 @@ bad: * *npp != NULL --> update the file handle in the vnode */ static int -nfs_lookitup(dvp, name, len, cred, procp, npp) +nfs_lookitup(dvp, name, len, cred, td, npp) register struct vnode *dvp; const char *name; int len; struct ucred *cred; - struct proc *procp; + struct thread *td; struct nfsnode **npp; { register u_int32_t *tl; @@ -2584,7 +2584,7 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); nfsm_fhtom(dvp, v3); nfsm_strtom(name, len, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_LOOKUP, procp, cred); + nfsm_request(dvp, NFSPROC_LOOKUP, td, cred); if (npp && !error) { nfsm_getfh(nfhp, fhlen, v3); if (*npp) { @@ -2640,12 +2640,12 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) * Nfs Version 3 commit rpc */ int -nfs_commit(vp, offset, cnt, cred, procp) +nfs_commit(vp, offset, cnt, cred, td) struct vnode *vp; u_quad_t offset; int cnt; struct ucred *cred; - struct proc *procp; + struct thread *td; { register caddr_t cp; register u_int32_t *tl; @@ -2664,7 +2664,7 @@ nfs_commit(vp, offset, cnt, cred, procp) txdr_hyper(offset, tl); tl += 2; *tl = txdr_unsigned(cnt); - nfsm_request(vp, NFSPROC_COMMIT, procp, cred); + nfsm_request(vp, NFSPROC_COMMIT, td, cred); nfsm_wcc_data(vp, wccflag); if (!error) { nfsm_dissect(tl, u_int32_t *, NFSX_V3WRITEVERF); @@ -2691,7 +2691,7 @@ nfs_strategy(ap) { register struct buf *bp = ap->a_bp; struct ucred *cr; - struct proc *p; + struct thread *td; int error = 0; KASSERT(!(bp->b_flags & B_DONE), ("nfs_strategy: buffer %p unexpectedly marked B_DONE", bp)); @@ -2701,9 +2701,9 @@ nfs_strategy(ap) panic("nfs physio"); if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; + td = (struct thread *)0; else - p = curproc; /* XXX */ + td = curthread; /* XXX */ if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; @@ -2716,8 +2716,8 @@ nfs_strategy(ap) * otherwise just do it ourselves. */ if ((bp->b_flags & B_ASYNC) == 0 || - nfs_asyncio(bp, NOCRED, p)) - error = nfs_doio(bp, cr, p); + nfs_asyncio(bp, NOCRED, td)) + error = nfs_doio(bp, cr, td); return (error); } @@ -2732,11 +2732,11 @@ nfs_fsync(ap) struct vnode * a_vp; struct ucred * a_cred; int a_waitfor; - struct proc * a_p; + struct thread * a_td; } */ *ap; { - return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1)); + return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1)); } /* @@ -2745,11 +2745,11 @@ nfs_fsync(ap) * associated with the vnode. */ static int -nfs_flush(vp, cred, waitfor, p, commit) +nfs_flush(vp, cred, waitfor, td, commit) register struct vnode *vp; struct ucred *cred; int waitfor; - struct proc *p; + struct thread *td; int commit; { register struct nfsnode *np = VTONFS(vp); @@ -2878,7 +2878,7 @@ again: */ if (wcred != NOCRED) retv = nfs_commit(vp, off, (int)(endoff - off), - wcred, p); + wcred, td); else { retv = 0; for (i = 0; i < bvecpos; i++) { @@ -2889,7 +2889,7 @@ again: size = (u_quad_t)(bp->b_dirtyend - bp->b_dirtyoff); retv = nfs_commit(vp, off, (int)size, - bp->b_wcred, p); + bp->b_wcred, td); if (retv) break; } } @@ -2949,7 +2949,7 @@ loop: panic("nfs_fsync: inconsistent lock"); if (error == ENOLCK) goto loop; - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { error = EINTR; goto done; } @@ -2985,7 +2985,7 @@ loop: error = tsleep((caddr_t)&vp->v_numoutput, slpflag | (PRIBIO + 1), "nfsfsync", slptimeo); if (error) { - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { error = EINTR; goto done; } @@ -3053,10 +3053,10 @@ nfs_print(ap) * We set B_CACHE if this is a VMIO buffer. */ int -nfs_writebp(bp, force, procp) +nfs_writebp(bp, force, td) register struct buf *bp; int force; - struct proc *procp; + struct thread *td; { int s; int oldflags = bp->b_flags; @@ -3086,7 +3086,7 @@ nfs_writebp(bp, force, procp) bp->b_iocmd = BIO_WRITE; bp->b_vp->v_numoutput++; - curproc->p_stats->p_ru.ru_oublock++; + curthread->td_proc->p_stats->p_ru.ru_oublock++; splx(s); /* @@ -3127,7 +3127,7 @@ nfsspec_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vattr *vap; @@ -3161,7 +3161,7 @@ nfsspec_access(ap) if (cred->cr_uid == 0) return (0); vap = &vattr; - error = VOP_GETATTR(vp, vap, cred, ap->a_p); + error = VOP_GETATTR(vp, vap, cred, ap->a_td); if (error) return (error); /* @@ -3238,7 +3238,7 @@ nfsspec_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -3254,7 +3254,7 @@ nfsspec_close(ap) vattr.va_atime = np->n_atim; if (np->n_flag & NUPD) vattr.va_mtime = np->n_mtim; - (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p); + (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td); } } return (VOCALL(spec_vnodeop_p, VOFFSET(vop_close), ap)); @@ -3315,7 +3315,7 @@ nfsfifo_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -3337,7 +3337,7 @@ nfsfifo_close(ap) vattr.va_atime = np->n_atim; if (np->n_flag & NUPD) vattr.va_mtime = np->n_mtim; - (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p); + (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td); } } return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap)); diff --git a/sys/nfs/nfsnode.h b/sys/nfs/nfsnode.h index 968f39c..ba99fea 100644 --- a/sys/nfs/nfsnode.h +++ b/sys/nfs/nfsnode.h @@ -171,16 +171,16 @@ extern struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; static __inline int -nfs_rslock(struct nfsnode *np, struct proc *p) +nfs_rslock(struct nfsnode *np, struct thread *td) { - return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, p)); + return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, td)); } static __inline void -nfs_rsunlock(struct nfsnode *np, struct proc *p) +nfs_rsunlock(struct nfsnode *np, struct thread *td) { - (void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, p); + (void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, td); } extern vop_t **fifo_nfsv2nodeop_p; diff --git a/sys/nfs/nqnfs.h b/sys/nfs/nqnfs.h index 94a8e27..ce8d692 100644 --- a/sys/nfs/nqnfs.h +++ b/sys/nfs/nqnfs.h @@ -146,7 +146,7 @@ struct nqm { (void) nqsrv_getlease((v), &nfsd->nd_duration, \ ((nfsd->nd_flag & ND_LEASE) ? (nfsd->nd_flag & ND_LEASE) : \ ((l) | ND_CHECK)), \ - slp, procp, nfsd->nd_nam, &cache, &frev, cred) + slp, td, nfsd->nd_nam, &cache, &frev, cred) /* * Client side macros that check for a valid lease. @@ -189,20 +189,20 @@ extern u_long nqfhhash; #define NQNFS_EXPIRED 500 #define NQNFS_TRYLATER 501 -void nqnfs_lease_check __P((struct vnode *, struct proc *, struct ucred *, int)); +void nqnfs_lease_check __P((struct vnode *, struct thread *, struct ucred *, int)); void nqnfs_lease_updatetime __P((int)); int nqsrv_getlease __P((struct vnode *, u_int32_t *, int, - struct nfssvc_sock *, struct proc *, + struct nfssvc_sock *, struct thread *, struct sockaddr *, int *, u_quad_t *, struct ucred *)); -int nqnfs_getlease __P((struct vnode *,int,struct ucred *,struct proc *)); +int nqnfs_getlease __P((struct vnode *,int,struct ucred *,struct thread *)); int nqnfs_callback __P((struct nfsmount *,struct mbuf *,struct mbuf *,caddr_t)); -int nqnfs_clientd __P((struct nfsmount *,struct ucred *,struct nfsd_cargs *,int,caddr_t,struct proc *)); +int nqnfs_clientd __P((struct nfsmount *,struct ucred *,struct nfsd_cargs *,int,caddr_t,struct thread *)); struct nfsnode; void nqnfs_clientlease __P((struct nfsmount *, struct nfsnode *, int, int, time_t, u_quad_t)); void nqnfs_serverd __P((void)); -int nqnfsrv_getlease __P((struct nfsrv_descript *, struct nfssvc_sock *, struct proc *, struct mbuf **)); -int nqnfsrv_vacated __P((struct nfsrv_descript *, struct nfssvc_sock *, struct proc *, struct mbuf **)); +int nqnfsrv_getlease __P((struct nfsrv_descript *, struct nfssvc_sock *, struct thread *, struct mbuf **)); +int nqnfsrv_vacated __P((struct nfsrv_descript *, struct nfssvc_sock *, struct thread *, struct mbuf **)); #endif #endif diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c index 72fc393..063f77f 100644 --- a/sys/nfsclient/bootp_subr.c +++ b/sys/nfsclient/bootp_subr.c @@ -213,11 +213,11 @@ extern struct nfsv3_diskless nfsv3_diskless; /* mountd RPC */ static int md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp, int *fhsizep, - struct nfs_args *args,struct proc *procp); + struct nfs_args *args,struct thread *td); static int md_lookup_swap(struct sockaddr_in *mdsin,char *path, u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp); + struct thread *td); static int setfs(struct sockaddr_in *addr, char *path, char *p); static int getdec(char **ptr); static char *substr(char *a,char *b); @@ -231,7 +231,7 @@ static struct bootpc_ifcontext *allocifctx(struct bootpc_globalcontext *gctx); static void bootpc_compose_query(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static unsigned char *bootpc_tag(struct bootpc_tagcontext *tctx, struct bootp_packet *bp, int len, int tag); static void bootpc_tag_helper(struct bootpc_tagcontext *tctx, @@ -248,15 +248,15 @@ void bootpboot_p_iflist(void); #endif static int bootpc_call(struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static int bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static int bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp); + struct thread *td); static void bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, @@ -581,7 +581,7 @@ bootpc_received(struct bootpc_globalcontext *gctx, static int bootpc_call(struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { struct socket *so; struct sockaddr_in *sin, dst; @@ -601,7 +601,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, /* * Create socket and set its recieve timeout. */ - error = socreate(AF_INET, &so, SOCK_DGRAM, 0, procp); + error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td); if (error != 0) goto out; @@ -648,7 +648,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, sin = &dst; clear_sinaddr(sin); sin->sin_port = htons(IPPORT_BOOTPC); - error = sobind(so, (struct sockaddr *)sin, procp); + error = sobind(so, (struct sockaddr *)sin, td); if (error != 0) { printf("bind failed\n"); goto out; @@ -706,7 +706,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, (ifctx->state == IF_BOOTP_UNRESOLVED && ifctx->dhcpquerytype != DHCP_NOMSG)) { ifctx->sentmsg = 0; - bootpc_compose_query(ifctx, gctx, procp); + bootpc_compose_query(ifctx, gctx, td); } /* Send BOOTP request (or re-send). */ @@ -743,21 +743,21 @@ bootpc_call(struct bootpc_globalcontext *gctx, auio.uio_rw = UIO_WRITE; auio.uio_offset = 0; auio.uio_resid = sizeof(ifctx->call); - auio.uio_procp = procp; + auio.uio_td = td; /* Set netmask to 0.0.0.0 */ sin = (struct sockaddr_in *) &ifctx->ireq.ifr_addr; clear_sinaddr(sin); error = ifioctl(ifctx->so, SIOCSIFNETMASK, - (caddr_t) &ifctx->ireq, procp); + (caddr_t) &ifctx->ireq, td); if (error != 0) panic("bootpc_call:" "set if netmask, error=%d", error); error = sosend(so, (struct sockaddr *) &dst, - &auio, NULL, NULL, 0, procp); + &auio, NULL, NULL, 0, td); if (error != 0) { printf("bootpc_call: sosend: %d state %08x\n", error, (int) so->so_state); @@ -772,7 +772,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, clear_sinaddr(sin); sin->sin_addr.s_addr = htonl(0xff000000u); error = ifioctl(ifctx->so, SIOCSIFNETMASK, - (caddr_t) &ifctx->ireq, procp); + (caddr_t) &ifctx->ireq, td); if (error != 0) panic("bootpc_call:" "set if netmask, error=%d", @@ -810,7 +810,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(gctx->reply); - auio.uio_procp = procp; + auio.uio_td = td; rcvflg = 0; error = soreceive(so, NULL, &auio, @@ -979,7 +979,7 @@ out: static int bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { struct sockaddr_in *sin; int error; @@ -989,7 +989,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, struct ifaddr *ifa; struct sockaddr_dl *sdl; - error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, procp); + error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, td); if (error != 0) panic("nfs_boot: socreate, error=%d", error); @@ -1002,11 +1002,11 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, * Get the old interface flags and or IFF_UP into them; if * IFF_UP set blindly, interface selection can be clobbered. */ - error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: GIFFLAGS, error=%d", error); ireq->ifr_flags |= IFF_UP; - error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: SIFFLAGS, error=%d", error); @@ -1019,7 +1019,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); - error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_fakeup_interface: " "set if addr, error=%d", error); @@ -1029,7 +1029,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); sin->sin_addr.s_addr = htonl(0xff000000u); - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: set if netmask, error=%d", error); @@ -1042,7 +1042,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, sin->sin_addr.s_addr = htonl(INADDR_BROADCAST); ifctx->broadcast.sin_addr.s_addr = sin->sin_addr.s_addr; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, td); if (error != 0) panic("bootpc_fakeup_interface: " "set if broadcast addr, error=%d", @@ -1071,7 +1071,7 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx, static int bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, struct bootpc_globalcontext *gctx, - struct proc *procp) + struct thread *td) { int error; struct sockaddr_in defdst; @@ -1095,19 +1095,19 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, /* Shutdown interfaces where BOOTP failed */ printf("Shutdown interface %s\n", ifctx->ireq.ifr_name); - error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "SIOCGIFFLAGS, error=%d", error); ireq->ifr_flags &= ~IFF_UP; - error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp); + error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "SIOCSIFFLAGS, error=%d", error); sin = (struct sockaddr_in *) &ireq->ifr_addr; clear_sinaddr(sin); - error = ifioctl(so, SIOCDIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCDIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_adjust_interface: " @@ -1122,7 +1122,7 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, * can talk to the servers. (just set the address) */ bcopy(netmask, &ireq->ifr_addr, sizeof(*netmask)); - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFNETMASK, (caddr_t) ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "set if netmask, error=%d", error); @@ -1133,13 +1133,13 @@ bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, clear_sinaddr(sin); sin->sin_addr.s_addr = myaddr->sin_addr.s_addr | ~ netmask->sin_addr.s_addr; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t) ireq, td); if (error != 0) panic("bootpc_adjust_interface: " "set if broadcast addr, error=%d", error); bcopy(myaddr, &ireq->ifr_addr, sizeof(*myaddr)); - error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, procp); + error = ifioctl(so, SIOCSIFADDR, (caddr_t) ireq, td); if (error != 0 && (error != EEXIST || ifctx == gctx->interfaces)) panic("bootpc_adjust_interface: " "set if addr, error=%d", error); @@ -1326,10 +1326,10 @@ print_in_addr(struct in_addr addr) } static void -bootpc_compose_query(ifctx, gctx, procp) +bootpc_compose_query(ifctx, gctx, td) struct bootpc_ifcontext *ifctx; struct bootpc_globalcontext *gctx; - struct proc *procp; + struct thread *td; { unsigned char *vendp; uint32_t leasetime; @@ -1670,10 +1670,10 @@ bootpc_init(void) struct ifnet *ifp; int error; struct nfsv3_diskless *nd; - struct proc *procp; + struct thread *td; nd = &nfsv3_diskless; - procp = curproc; + td = curthread; /* * If already filled in, don't touch it here @@ -1745,13 +1745,13 @@ bootpc_init(void) gctx->gotgw = 0; for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) - bootpc_fakeup_interface(ifctx, gctx, procp); + bootpc_fakeup_interface(ifctx, gctx, td); for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) - bootpc_compose_query(ifctx, gctx, procp); + bootpc_compose_query(ifctx, gctx, td); ifctx = gctx->interfaces; - error = bootpc_call(gctx, procp); + error = bootpc_call(gctx, td); if (error != 0) { #ifdef BOOTP_NFSROOT @@ -1777,7 +1777,7 @@ bootpc_init(void) #endif for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) { - bootpc_adjust_interface(ifctx, gctx, procp); + bootpc_adjust_interface(ifctx, gctx, td); soclose(ifctx->so); } @@ -1799,7 +1799,7 @@ bootpc_init(void) error = md_mount(&nd->root_saddr, nd->root_hostnam, nd->root_fh, &nd->root_fhsize, - &nd->root_args, procp); + &nd->root_args, td); if (error != 0) panic("nfs_boot: mountd root, error=%d", error); @@ -1808,7 +1808,7 @@ bootpc_init(void) error = md_mount(&nd->swap_saddr, nd->swap_hostnam, nd->swap_fh, &nd->swap_fhsize, - &nd->swap_args, procp); + &nd->swap_args, td); if (error != 0) panic("nfs_boot: mountd swap, error=%d", error); @@ -1816,7 +1816,7 @@ bootpc_init(void) error = md_lookup_swap(&nd->swap_saddr, gctx->lookup_path, nd->swap_fh, &nd->swap_fhsize, - &nd->swap_args, procp); + &nd->swap_args, td); if (error != 0) panic("nfs_boot: lookup swap, error=%d", error); @@ -1852,7 +1852,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp) + struct thread *td) { struct mbuf *m; int error; @@ -1864,13 +1864,13 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* First try NFS v3 */ /* Get port number for MOUNTD. */ error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER3, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); if (error == 0) { m = xdr_string_encode(path, strlen(path)); /* Do RPC to mountd. */ error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER3, - RPCMNT_MOUNT, &m, NULL, procp); + RPCMNT_MOUNT, &m, NULL, td); } if (error == 0) { args->flags |= NFSMNT_NFSV3; @@ -1880,7 +1880,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* Get port number for MOUNTD. */ error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER1, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); if (error != 0) return error; @@ -1888,7 +1888,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ /* Do RPC to mountd. */ error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1, - RPCMNT_MOUNT, &m, NULL, procp); + RPCMNT_MOUNT, &m, NULL, td); if (error != 0) return error; /* message already freed */ @@ -1931,7 +1931,7 @@ md_mount(struct sockaddr_in *mdsin, /* mountd server address */ error = krpc_portmap(mdsin, NFS_PROG, (args->flags & NFSMNT_NFSV3) ? NFS_VER3 : NFS_VER2, - &mdsin->sin_port, procp); + &mdsin->sin_port, td); goto out; @@ -1950,7 +1950,7 @@ md_lookup_swap(struct sockaddr_in *mdsin, /* mountd server address */ u_char *fhp, int *fhsizep, struct nfs_args *args, - struct proc *procp) + struct thread *td) { struct mbuf *m; int error; @@ -1984,10 +1984,10 @@ md_lookup_swap(struct sockaddr_in *mdsin, /* mountd server address */ /* Do RPC to nfsd. */ if ((args->flags & NFSMNT_NFSV3) != 0) error = krpc_call(mdsin, NFS_PROG, NFS_VER3, - NFSPROC_LOOKUP, &m, NULL, procp); + NFSPROC_LOOKUP, &m, NULL, td); else error = krpc_call(mdsin, NFS_PROG, NFS_VER2, - NFSV2PROC_LOOKUP, &m, NULL, procp); + NFSV2PROC_LOOKUP, &m, NULL, td); if (error != 0) return error; /* message already freed */ diff --git a/sys/nfsclient/krpc.h b/sys/nfsclient/krpc.h index 6c889b5..b6136e3 100644 --- a/sys/nfsclient/krpc.h +++ b/sys/nfsclient/krpc.h @@ -4,16 +4,16 @@ #include <sys/cdefs.h> struct mbuf; -struct proc; +struct thread; struct sockaddr; struct sockaddr_in; int krpc_call __P((struct sockaddr_in *_sin, u_int prog, u_int vers, u_int func, - struct mbuf **data, struct sockaddr **from, struct proc *procp)); + struct mbuf **data, struct sockaddr **from, struct thread *td)); int krpc_portmap __P((struct sockaddr_in *_sin, - u_int prog, u_int vers, u_int16_t *portp,struct proc *procp)); + u_int prog, u_int vers, u_int16_t *portp,struct thread *td)); struct mbuf *xdr_string_encode __P((char *str, int len)); diff --git a/sys/nfsclient/krpc_subr.c b/sys/nfsclient/krpc_subr.c index b7b1d2c..709af4a 100644 --- a/sys/nfsclient/krpc_subr.c +++ b/sys/nfsclient/krpc_subr.c @@ -124,11 +124,11 @@ struct rpc_reply { * Returns non-zero error on failure. */ int -krpc_portmap(sin, prog, vers, portp, procp) +krpc_portmap(sin, prog, vers, portp, td) struct sockaddr_in *sin; /* server address */ u_int prog, vers; /* host order */ u_int16_t *portp; /* network order */ - struct proc *procp; + struct thread *td; { struct sdata { u_int32_t prog; /* call program */ @@ -163,7 +163,7 @@ krpc_portmap(sin, prog, vers, portp, procp) sin->sin_port = htons(PMAPPORT); error = krpc_call(sin, PMAPPROG, PMAPVERS, - PMAPPROC_GETPORT, &m, NULL, procp); + PMAPPROC_GETPORT, &m, NULL, td); if (error) return error; @@ -185,12 +185,12 @@ krpc_portmap(sin, prog, vers, portp, procp) * the address from whence the response came is saved there. */ int -krpc_call(sa, prog, vers, func, data, from_p, procp) +krpc_call(sa, prog, vers, func, data, from_p, td) struct sockaddr_in *sa; u_int prog, vers, func; struct mbuf **data; /* input/output */ struct sockaddr **from_p; /* output */ - struct proc *procp; + struct thread *td; { struct socket *so; struct sockaddr_in *sin, ssin; @@ -220,7 +220,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) /* * Create socket and set its recieve timeout. */ - if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, procp))) + if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td))) goto out; tv.tv_sec = 1; @@ -260,7 +260,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) do { tport--; sin->sin_port = htons(tport); - error = sobind(so, (struct sockaddr *)sin, procp); + error = sobind(so, (struct sockaddr *)sin, td); } while (error == EADDRINUSE && tport > IPPORT_RESERVED / 2); if (error) { @@ -321,7 +321,7 @@ krpc_call(sa, prog, vers, func, data, from_p, procp) goto out; } error = sosend(so, (struct sockaddr *)sa, NULL, m, - NULL, 0, procp); + NULL, 0, td); if (error) { printf("krpc_call: sosend: %d\n", error); goto out; diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h index 44d04b9..d5d0796 100644 --- a/sys/nfsclient/nfs.h +++ b/sys/nfsclient/nfs.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index 3bcdb32..e48cd5c 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -72,7 +72,7 @@ static int nfs_bwrite(struct buf *bp) { - return (nfs_writebp(bp, 1, curproc)); + return (nfs_writebp(bp, 1, curthread)); } struct buf_ops buf_ops_nfs = { @@ -82,7 +82,7 @@ struct buf_ops buf_ops_nfs = { static struct buf *nfs_getcacheblk __P((struct vnode *vp, daddr_t bn, int size, - struct proc *p)); + struct thread *td)); extern int nfs_numasync; extern int nfs_pbuf_freecnt; @@ -107,7 +107,7 @@ nfs_getpages(ap) vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; struct nfsmount *nmp; vm_page_t *pages; @@ -115,8 +115,8 @@ nfs_getpages(ap) GIANT_REQUIRED; vp = ap->a_vp; - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + td = curthread; /* XXX */ + cred = curthread->td_proc->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -128,7 +128,7 @@ nfs_getpages(ap) if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) { - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); } npages = btoc(count); @@ -172,7 +172,7 @@ nfs_getpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; error = nfs_readrpc(vp, &uio, cred); pmap_qremove(kva, npages); @@ -268,7 +268,7 @@ nfs_putpages(ap) off_t offset; int *rtvals; struct vnode *vp; - struct proc *p; + struct thread *td; struct ucred *cred; struct nfsmount *nmp; struct nfsnode *np; @@ -278,8 +278,8 @@ nfs_putpages(ap) vp = ap->a_vp; np = VTONFS(vp); - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + td = curthread; /* XXX */ + cred = curthread->td_proc->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -291,7 +291,7 @@ nfs_putpages(ap) if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) { - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); } for (i = 0; i < npages; i++) { @@ -327,7 +327,7 @@ nfs_putpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; if ((ap->a_sync & VM_PAGER_PUT_SYNC) == 0) iomode = NFSV3WRITE_UNSTABLE; @@ -366,7 +366,7 @@ nfs_bioread(vp, uio, ioflag, cred) register int biosize, i; struct buf *bp = 0, *rabp; struct vattr vattr; - struct proc *p; + struct thread *td; struct nfsmount *nmp = VFSTONFS(vp->v_mount); daddr_t lbn, rabn; int bcount; @@ -381,11 +381,11 @@ nfs_bioread(vp, uio, ioflag, cred) return (0); if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */ return (EINVAL); - p = uio->uio_procp; + td = uio->uio_td; if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); if (vp->v_type != VDIR && (uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize) return (EFBIG); @@ -414,23 +414,23 @@ nfs_bioread(vp, uio, ioflag, cred) if (vp->v_type != VDIR) panic("nfs: bioread, not dir"); nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } np->n_attrstamp = 0; - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { if (vp->v_type == VDIR) nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; @@ -445,7 +445,7 @@ nfs_bioread(vp, uio, ioflag, cred) if (nmp->nm_flag & NFSMNT_NQNFS) { if (NQNFS_CKINVALID(vp, np, ND_READ)) { do { - error = nqnfs_getlease(vp, ND_READ, cred, p); + error = nqnfs_getlease(vp, ND_READ, cred, td); } while (error == NQNFS_EXPIRED); if (error) return (error); @@ -454,14 +454,14 @@ nfs_bioread(vp, uio, ioflag, cred) ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) { if (vp->v_type == VDIR) nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); np->n_brev = np->n_lrev; } } else if (vp->v_type == VDIR && (np->n_flag & NMODIFIED)) { nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } @@ -493,14 +493,14 @@ nfs_bioread(vp, uio, ioflag, cred) (off_t)(lbn + 1 + nra) * biosize < np->n_size; nra++) { rabn = lbn + 1 + nra; if (!incore(vp, rabn)) { - rabp = nfs_getcacheblk(vp, rabn, biosize, p); + rabp = nfs_getcacheblk(vp, rabn, biosize, td); if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { rabp->b_flags |= B_ASYNC; rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL; rabp->b_ioflags |= BIO_ERROR; vfs_unbusy_pages(rabp); @@ -534,7 +534,7 @@ again: bcount = np->n_size - (off_t)lbn * biosize; } if (bcount != biosize) { - switch(nfs_rslock(np, p)) { + switch(nfs_rslock(np, td)) { case ENOLCK: goto again; /* not reached */ @@ -547,10 +547,10 @@ again: } } - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (bcount != biosize) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); if (!bp) return (EINTR); @@ -562,7 +562,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); return (error); @@ -583,13 +583,13 @@ again: break; case VLNK: nfsstats.biocache_readlinks++; - bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, p); + bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { bp->b_ioflags |= BIO_ERROR; brelse(bp); @@ -607,20 +607,20 @@ again: } lbn = (uoff_t)uio->uio_offset / NFS_DIRBLKSIZ; on = uio->uio_offset & (NFS_DIRBLKSIZ - 1); - bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, p); + bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); } while (error == NFSERR_BAD_COOKIE) { printf("got bad cookie vp %p bp %p\n", vp, bp); nfs_invaldir(vp); - error = nfs_vinvalbuf(vp, 0, cred, p, 1); + error = nfs_vinvalbuf(vp, 0, cred, td, 1); /* * Yuck! The directory has been modified on the * server. The only way to get the block is by @@ -635,13 +635,13 @@ again: if (np->n_direofoffset && (i * NFS_DIRBLKSIZ) >= np->n_direofoffset) return (0); - bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, p); + bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, td); if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); /* * no error + B_INVAL == directory EOF, * use the block. @@ -679,13 +679,13 @@ again: (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) && !(np->n_flag & NQNFSNONCACHE) && !incore(vp, lbn + 1)) { - rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); + rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, td); if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { rabp->b_flags |= B_ASYNC; rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL; rabp->b_ioflags |= BIO_ERROR; vfs_unbusy_pages(rabp); @@ -756,7 +756,7 @@ nfs_write(ap) { int biosize; struct uio *uio = ap->a_uio; - struct proc *p = uio->uio_procp; + struct thread *td = uio->uio_td; struct vnode *vp = ap->a_vp; struct nfsnode *np = VTONFS(vp); struct ucred *cred = ap->a_cred; @@ -768,13 +768,14 @@ nfs_write(ap) int bcount; int n, on, error = 0, iomode, must_commit; int haverslock = 0; + struct proc *p = td?td->td_proc:NULL; GIANT_REQUIRED; #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_WRITE) panic("nfs_write mode"); - if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc) + if (uio->uio_segflg == UIO_USERSPACE && uio->uio_td != curthread) panic("nfs_write proc"); #endif if (vp->v_type != VREG) @@ -785,7 +786,7 @@ nfs_write(ap) } if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); /* * Synchronously flush pending buffers if we are in synchronous @@ -794,7 +795,7 @@ nfs_write(ap) if (ioflag & (IO_APPEND | IO_SYNC)) { if (np->n_flag & NMODIFIED) { np->n_attrstamp = 0; - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return (error); } @@ -807,7 +808,7 @@ nfs_write(ap) restart: if (ioflag & IO_APPEND) { np->n_attrstamp = 0; - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); uio->uio_offset = np->n_size; @@ -836,7 +837,7 @@ restart: */ if ((ioflag & IO_APPEND) || uio->uio_offset + uio->uio_resid > np->n_size) { - switch(nfs_rslock(np, p)) { + switch(nfs_rslock(np, td)) { case ENOLCK: goto restart; /* not reached */ @@ -860,7 +861,7 @@ restart: psignal(p, SIGXFSZ); PROC_UNLOCK(p); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (EFBIG); } @@ -873,13 +874,13 @@ restart: if ((nmp->nm_flag & NFSMNT_NQNFS) && NQNFS_CKINVALID(vp, np, ND_WRITE)) { do { - error = nqnfs_getlease(vp, ND_WRITE, cred, p); + error = nqnfs_getlease(vp, ND_WRITE, cred, td); } while (error == NQNFS_EXPIRED); if (error) break; if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; np->n_brev = np->n_lrev; @@ -910,7 +911,7 @@ again: * readers from reading garbage. */ bcount = on; - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (bp != NULL) { long save; @@ -939,7 +940,7 @@ again: bcount = np->n_size - (off_t)lbn * biosize; } - bp = nfs_getcacheblk(vp, lbn, bcount, p); + bp = nfs_getcacheblk(vp, lbn, bcount, td); if (uio->uio_offset + n > np->n_size) { np->n_size = uio->uio_offset + n; @@ -981,7 +982,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); break; @@ -1047,7 +1048,7 @@ again: if ((nmp->nm_flag & NFSMNT_NQNFS) && NQNFS_CKINVALID(vp, np, ND_WRITE)) { do { - error = nqnfs_getlease(vp, ND_WRITE, cred, p); + error = nqnfs_getlease(vp, ND_WRITE, cred, td); } while (error == NQNFS_EXPIRED); if (error) { brelse(bp); @@ -1056,7 +1057,7 @@ again: if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { brelse(bp); - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; np->n_brev = np->n_lrev; @@ -1108,7 +1109,7 @@ again: if (error) break; if (np->n_flag & NQNFSNONCACHE) { - error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) break; } @@ -1122,7 +1123,7 @@ again: } while (uio->uio_resid > 0 && n > 0); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (error); } @@ -1143,11 +1144,11 @@ again: * its EOF. */ static struct buf * -nfs_getcacheblk(vp, bn, size, p) +nfs_getcacheblk(vp, bn, size, td) struct vnode *vp; daddr_t bn; int size; - struct proc *p; + struct thread *td; { register struct buf *bp; struct mount *mp; @@ -1159,7 +1160,7 @@ nfs_getcacheblk(vp, bn, size, p) if (nmp->nm_flag & NFSMNT_INT) { bp = getblk(vp, bn, size, PCATCH, 0); while (bp == (struct buf *)0) { - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) return ((struct buf *)0); bp = getblk(vp, bn, size, 0, 2 * hz); } @@ -1181,11 +1182,11 @@ nfs_getcacheblk(vp, bn, size, p) * doing the flush, just wait for completion. */ int -nfs_vinvalbuf(vp, flags, cred, p, intrflg) +nfs_vinvalbuf(vp, flags, cred, td, intrflg) struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; int intrflg; { register struct nfsnode *np = VTONFS(vp); @@ -1212,7 +1213,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) np->n_flag |= NFLUSHWANT; error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nfsvinval", slptimeo); - if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) + if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) return (EINTR); } @@ -1220,9 +1221,9 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) * Now, flush as required. */ np->n_flag |= NFLUSHINPROG; - error = vinvalbuf(vp, flags, cred, p, slpflag, 0); + error = vinvalbuf(vp, flags, cred, td, slpflag, 0); while (error) { - if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { np->n_flag &= ~NFLUSHINPROG; if (np->n_flag & NFLUSHWANT) { np->n_flag &= ~NFLUSHWANT; @@ -1230,7 +1231,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) } return (EINTR); } - error = vinvalbuf(vp, flags, cred, p, 0, slptimeo); + error = vinvalbuf(vp, flags, cred, td, 0, slptimeo); } np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); if (np->n_flag & NFLUSHWANT) { @@ -1249,10 +1250,10 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) * is eventually dequeued by the async daemon, nfs_doio() *will*. */ int -nfs_asyncio(bp, cred, procp) +nfs_asyncio(bp, cred, td) register struct buf *bp; struct ucred *cred; - struct proc *procp; + struct thread *td; { struct nfsmount *nmp; int i; @@ -1334,7 +1335,7 @@ again: error = tsleep(&nmp->nm_bufq, slpflag | PRIBIO, "nfsaio", slptimeo); if (error) { - if (nfs_sigintr(nmp, NULL, procp)) + if (nfs_sigintr(nmp, NULL, td->td_proc)) return (EINTR); if (slpflag == PCATCH) { slpflag = 0; @@ -1384,10 +1385,10 @@ again: * synchronously or from an nfsiod. */ int -nfs_doio(bp, cr, p) +nfs_doio(bp, cr, td) struct buf *bp; struct ucred *cr; - struct proc *p; + struct thread *td; { struct uio *uiop; struct vnode *vp; @@ -1396,6 +1397,7 @@ nfs_doio(bp, cr, p) int error = 0, iomode, must_commit = 0; struct uio uio; struct iovec io; + struct proc *p = td?td->td_proc:NULL; vp = bp->b_vp; np = VTONFS(vp); @@ -1404,7 +1406,7 @@ nfs_doio(bp, cr, p) uiop->uio_iov = &io; uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = p; + uiop->uio_td = td; /* * clear BIO_ERROR and B_INVAL state prior to initiating the I/O. We @@ -1525,7 +1527,7 @@ nfs_doio(bp, cr, p) bp->b_flags |= B_WRITEINPROG; retv = nfs_commit( bp->b_vp, off, bp->b_dirtyend-bp->b_dirtyoff, - bp->b_wcred, p); + bp->b_wcred, td); bp->b_flags &= ~B_WRITEINPROG; if (retv == 0) { bp->b_dirtyoff = bp->b_dirtyend = 0; diff --git a/sys/nfsclient/nfs_lock.c b/sys/nfsclient/nfs_lock.c index e2fa91c..b97b3b8 100644 --- a/sys/nfsclient/nfs_lock.c +++ b/sys/nfsclient/nfs_lock.c @@ -87,14 +87,17 @@ nfs_dolock(ap) { LOCKD_MSG msg; struct nameidata nd; - struct proc *p; + struct thread *td; uid_t saved_uid; struct vnode *vp, *wvp; int error, error1; struct flock *fl; int fmode, ioflg; + struct proc *p; + + td = curthread; + p = td->td_proc; - p = curproc; vp = ap->a_vp; fl = ap->a_fl; @@ -148,7 +151,7 @@ nfs_dolock(ap) * complain that the user's file is missing, which isn't the case. * Note that we use proc0's cred, so the fifo is opened as root. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, td); /* * XXX Hack to temporarily allow this process (regardless of it's creds) @@ -166,15 +169,15 @@ nfs_dolock(ap) return (error == ENOENT ? EOPNOTSUPP : error); } wvp = nd.ni_vp; - VOP_UNLOCK(wvp, 0, p); /* vn_open leaves it locked */ + VOP_UNLOCK(wvp, 0, td); /* vn_open leaves it locked */ ioflg = IO_UNIT; for (;;) { - VOP_LEASE(wvp, p, proc0.p_ucred, LEASE_WRITE); + VOP_LEASE(wvp, td, proc0.p_ucred, LEASE_WRITE); error = vn_rdwr(UIO_WRITE, wvp, (caddr_t)&msg, sizeof(msg), 0, - UIO_SYSSPACE, ioflg, proc0.p_ucred, NULL, p); + UIO_SYSSPACE, ioflg, proc0.p_ucred, NULL, td); if (error && (((ioflg & IO_NDELAY) == 0) || error != EAGAIN)) { break; @@ -224,7 +227,7 @@ nfs_dolock(ap) break; } - if ((error1 = vn_close(wvp, FWRITE, proc0.p_ucred, p)) && error == 0) + if ((error1 = vn_close(wvp, FWRITE, proc0.p_ucred, td)) && error == 0) return (error1); return (error); diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index e378cc5..657f299 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -78,7 +78,7 @@ static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure"); /* Global defs. */ extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)); extern int nfs_numasync; extern time_t nqnfsstarttime; @@ -92,7 +92,7 @@ static int nuidhash_max = NFS_MAXUIDHASH; #ifndef NFS_NOSERVER static void nfsrv_zapsock __P((struct nfssvc_sock *slp)); #endif -static int nfssvc_iod __P((struct proc *)); +static int nfssvc_iod __P((struct thread *)); #define TRUE 1 #define FALSE 0 @@ -110,8 +110,9 @@ static int modify_flag = 0; static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd, int cacherep)); static int nfssvc_addsock __P((struct file *, struct sockaddr *, - struct proc *)); -static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); + struct thread *)); +static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t, + struct thread *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); @@ -140,8 +141,8 @@ struct nfssvc_args { * MPSAFE */ int -nfssvc(p, uap) - struct proc *p; +nfssvc(td, uap) + struct thread *td; register struct nfssvc_args *uap; { #ifndef NFS_NOSERVER @@ -165,13 +166,13 @@ nfssvc(p, uap) error = copyin(uap->argp, &la, sizeof(la)); if (error == 0) - error = nfslockdans(p, &la); + error = nfslockdans(td->td_proc, &la); goto done2; } /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) goto done2; while (nfssvc_sockhead_flag & SLP_INIT) { @@ -179,7 +180,7 @@ nfssvc(p, uap) (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0); } if (uap->flag & NFSSVC_BIOD) - error = nfssvc_iod(p); + error = nfssvc_iod(td); #ifdef NFS_NOSERVER else error = ENXIO; @@ -189,7 +190,7 @@ nfssvc(p, uap) if (error) goto done2; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - ncd.ncd_dirp, p); + ncd.ncd_dirp, td); error = namei(&nd); if (error) goto done2; @@ -206,13 +207,13 @@ nfssvc(p, uap) goto done2; } nmp->nm_state |= NFSSTA_MNTD; - error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag, - uap->argp, p); + error = nqnfs_clientd(nmp, td->td_proc->p_ucred, &ncd, uap->flag, + uap->argp, td); } else if (uap->flag & NFSSVC_ADDSOCK) { error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg)); if (error) goto done2; - error = holdsock(p->p_fd, nfsdarg.sock, &fp); + error = holdsock(td->td_proc->p_fd, nfsdarg.sock, &fp); if (error) goto done2; /* @@ -224,12 +225,12 @@ nfssvc(p, uap) error = getsockaddr(&nam, nfsdarg.name, nfsdarg.namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } } - error = nfssvc_addsock(fp, nam, p); - fdrop(fp, p); + error = nfssvc_addsock(fp, nam, td); + fdrop(fp, td); } else { error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd)); if (error) @@ -327,7 +328,7 @@ nfssvc(p, uap) } if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd)) nfsd->nfsd_flag |= NFSD_AUTHFAIL; - error = nfssvc_nfsd(nsd, uap->argp, p); + error = nfssvc_nfsd(nsd, uap->argp, td); } #endif /* NFS_NOSERVER */ if (error == EINTR || error == ERESTART) @@ -342,10 +343,10 @@ done2: * Adds a socket to the list for servicing by nfsds. */ static int -nfssvc_addsock(fp, mynam, p) +nfssvc_addsock(fp, mynam, td) struct file *fp; struct sockaddr *mynam; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -439,10 +440,10 @@ nfssvc_addsock(fp, mynam, p) * until it is killed by a signal. */ static int -nfssvc_nfsd(nsd, argp, p) +nfssvc_nfsd(nsd, argp, td) struct nfsd_srvargs *nsd; caddr_t argp; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -461,7 +462,7 @@ nfssvc_nfsd(nsd, argp, p) nsd->nsd_nfsd = nfsd = (struct nfsd *) malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); - nfsd->nfsd_procp = p; + nfsd->nfsd_td = td; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); nfs_numnfsd++; } else @@ -622,10 +623,10 @@ nfssvc_nfsd(nsd, argp, p) if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, - nfsd->nfsd_procp, &mreq); + nfsd->nfsd_td, &mreq); else error = (*(nfsrv3_procs[nd->nd_procnum]))(nd, - slp, nfsd->nfsd_procp, &mreq); + slp, nfsd->nfsd_td, &mreq); if (mreq == NULL) break; if (error != 0 && error != NFSERR_RETVOID) { @@ -757,7 +758,7 @@ nfsrv_zapsock(slp) so->so_upcall = NULL; so->so_upcallarg = NULL; soshutdown(so, 2); - closef(fp, (struct proc *)0); + closef(fp, (struct thread *)0); if (slp->ns_nam) FREE(slp->ns_nam, M_SONAME); m_freem(slp->ns_raw); @@ -935,8 +936,8 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, ""); * Never returns unless it fails or gets killed. */ static int -nfssvc_iod(p) - struct proc *p; +nfssvc_iod(td) + struct thread *td; { register struct buf *bp; register int i, myiod; @@ -965,7 +966,7 @@ nfssvc_iod(p) && error == 0) { if (nmp) nmp->nm_bufqiods--; - nfs_iodwant[myiod] = p; + nfs_iodwant[myiod] = td->td_proc; nfs_iodmount[myiod] = NULL; error = tsleep((caddr_t)&nfs_iodwant[myiod], PWAIT | PCATCH, "nfsidl", 0); @@ -988,9 +989,9 @@ nfssvc_iod(p) wakeup(&nmp->nm_bufq); } if (bp->b_iocmd == BIO_READ) - (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_rcred, (struct thread *)0); else - (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_wcred, (struct thread *)0); /* * If there are more than one iod on this mount, then defect * so that the iods can be shared out fairly between the mounts @@ -1029,7 +1030,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) nmp->nm_state |= NFSSTA_WANTAUTH; (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK, "nfsauth1", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); if (error) { nmp->nm_state &= ~NFSSTA_WANTAUTH; return (error); @@ -1049,7 +1050,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) { (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK, "nfsauth2", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); } if (nmp->nm_state & NFSSTA_AUTHERR) { nmp->nm_state &= ~NFSSTA_AUTHERR; diff --git a/sys/nfsclient/nfs_node.c b/sys/nfsclient/nfs_node.c index dc21bc3..5fe3abc 100644 --- a/sys/nfsclient/nfs_node.c +++ b/sys/nfsclient/nfs_node.c @@ -169,7 +169,7 @@ nfs_nget(mntp, fhp, fhsize, npp) int fhsize; struct nfsnode **npp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct nfsnode *np, *np2; struct nfsnodehashhead *nhpp; register struct vnode *vp; @@ -196,7 +196,7 @@ loop: bcmp((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize)) continue; vp = NFSTOV(np); - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) goto loop; *npp = np; return(0); @@ -266,7 +266,7 @@ loop: /* * Lock the new nfsnode. */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); return (0); } @@ -275,12 +275,12 @@ int nfs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct nfsnode *np; register struct sillyrename *sp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ np = VTONFS(ap->a_vp); if (prtactive && ap->a_vp->v_usecount != 0) @@ -299,11 +299,11 @@ nfs_inactive(ap) * have our own reference. */ if (ap->a_vp->v_usecount > 0) - (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1); - else if (vget(ap->a_vp, 0, p)) + (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, td, 1); + else if (vget(ap->a_vp, 0, td)) panic("nfs_inactive: lost vnode"); else { - (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1); + (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, td, 1); vrele(ap->a_vp); } /* @@ -316,7 +316,7 @@ nfs_inactive(ap) } np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT | NQNFSEVICTED | NQNFSNONCACHE | NQNFSWRITE); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); return (0); } @@ -459,7 +459,7 @@ int nfs_islocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { return VTONFS(ap->a_vp)->n_flag & NLOCKED ? 1 : 0; diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c index 5772e4b..8991672 100644 --- a/sys/nfsclient/nfs_socket.c +++ b/sys/nfsclient/nfs_socket.c @@ -149,7 +149,7 @@ int nfsrtton = 0; struct nfsrtt nfsrtt; struct callout_handle nfs_timer_handle; -static int nfs_msg __P((struct proc *,char *,char *)); +static int nfs_msg __P((struct thread *,char *,char *)); static int nfs_rcvlock __P((struct nfsreq *)); static void nfs_rcvunlock __P((struct nfsreq *)); static void nfs_realign __P((struct mbuf **pm, int hsiz)); @@ -162,7 +162,7 @@ static int nfsrv_getstream __P((struct nfssvc_sock *,int)); int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)) = { nfsrv_null, nfsrv_getattr, @@ -207,12 +207,12 @@ nfs_connect(nmp, rep) int pktscale; struct sockaddr *saddr; struct sockaddr_in *sin; - struct proc *p = &proc0; /* only used for socreate and sobind */ + struct thread *td = thread0; /* only used for socreate and sobind */ nmp->nm_so = (struct socket *)0; saddr = nmp->nm_nam; error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype, - nmp->nm_soproto, p); + nmp->nm_soproto, td); if (error) goto bad; so = nmp->nm_so; @@ -233,7 +233,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -243,7 +243,7 @@ nfs_connect(nmp, rep) sin->sin_family = AF_INET; sin->sin_addr.s_addr = INADDR_ANY; sin->sin_port = htons(0); - error = sobind(so, (struct sockaddr *)sin, p); + error = sobind(so, (struct sockaddr *)sin, td); if (error) goto bad; bzero(&sopt, sizeof sopt); @@ -253,7 +253,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -269,7 +269,7 @@ nfs_connect(nmp, rep) goto bad; } } else { - error = soconnect(so, nmp->nm_nam, p); + error = soconnect(so, nmp->nm_nam, td); if (error) goto bad; @@ -284,7 +284,8 @@ nfs_connect(nmp, rep) "nfscon", 2 * hz); if ((so->so_state & SS_ISCONNECTING) && so->so_error == 0 && rep && - (error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){ + (error = nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) != 0){ so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -489,7 +490,7 @@ nfs_send(so, nam, top, rep) flags = 0; error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0, - flags, curproc /*XXX*/); + flags, curthread /*XXX*/); /* * ENOBUFS for dgram sockets is transient and non fatal. * No need to log, and no need to break a soft mount. @@ -547,7 +548,7 @@ nfs_receive(rep, aname, mp) u_int32_t len; struct sockaddr **getnam; int error, sotype, rcvflg; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ /* * Set up arguments for soreceive() @@ -614,7 +615,7 @@ tryagain: auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(u_int32_t); - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = MSG_WAITALL; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -682,7 +683,7 @@ tryagain: * on. */ auio.uio_resid = len = 100000000; /* Anything Big */ - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -727,7 +728,7 @@ errout: else getnam = aname; auio.uio_resid = len = 1000000; - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -937,11 +938,11 @@ nfsmout: * nb: always frees up mreq mbuf list */ int -nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) +nfs_request(vp, mrest, procnum, td, cred, mrp, mdp, dposp) struct vnode *vp; struct mbuf *mrest; int procnum; - struct proc *procp; + struct thread *td; struct ucred *cred; struct mbuf **mrp; struct mbuf **mdp; @@ -969,7 +970,7 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK); rep->r_nmp = nmp; rep->r_vp = vp; - rep->r_procp = procp; + rep->r_td = td; rep->r_procnum = procnum; i = 0; m = mrest; @@ -1100,7 +1101,7 @@ tryagain: * tprintf a response. */ if (!error && (rep->r_flags & R_TPRINTFMSG)) - nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "is alive again"); mrep = rep->r_mrep; md = rep->r_md; @@ -1394,14 +1395,15 @@ nfs_timer(arg) register struct nfssvc_sock *slp; u_quad_t cur_usec; #endif /* NFS_NOSERVER */ - struct proc *p = &proc0; /* XXX for credentials, will break if sleep */ + struct thread *td = thread0; /* XXX for credentials, will break if sleep */ s = splnet(); for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) { nmp = rep->r_nmp; if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) continue; - if (nfs_sigintr(nmp, rep, rep->r_procp)) { + if (nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) { nfs_softterm(rep); continue; } @@ -1423,7 +1425,7 @@ nfs_timer(arg) */ if ((rep->r_flags & R_TPRINTFMSG) == 0 && rep->r_rexmit > nmp->nm_deadthresh) { - nfs_msg(rep->r_procp, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "not responding"); rep->r_flags |= R_TPRINTFMSG; @@ -1455,11 +1457,11 @@ nfs_timer(arg) if ((nmp->nm_flag & NFSMNT_NOCONN) == 0) error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, (struct sockaddr *)0, - (struct mbuf *)0, p); + (struct mbuf *)0, td); else error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, nmp->nm_nam, (struct mbuf *)0, - p); + td); if (error) { if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) so->so_error = 0; @@ -1566,17 +1568,17 @@ nfs_sndlock(rep) struct nfsreq *rep; { register int *statep = &rep->r_nmp->nm_state; - struct proc *p; + struct thread *td; int slpflag = 0, slptimeo = 0; if (rep) { - p = rep->r_procp; + td = rep->r_td; if (rep->r_nmp->nm_flag & NFSMNT_INT) slpflag = PCATCH; } else - p = (struct proc *)0; + td = (struct thread *)0; while (*statep & NFSSTA_SNDLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, p)) + if (nfs_sigintr(rep->r_nmp, rep, td ? td->td_proc : NULL)) return (EINTR); *statep |= NFSSTA_WANTSND; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), @@ -1620,7 +1622,8 @@ nfs_rcvlock(rep) else slpflag = 0; while (*statep & NFSSTA_RCVLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp)) + if (nfs_sigintr(rep->r_nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) return (EINTR); *statep |= NFSSTA_WANTRCV; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk", @@ -1966,12 +1969,12 @@ nfsmout: #endif static int -nfs_msg(p, server, msg) - struct proc *p; +nfs_msg(td, server, msg) + struct thread *td; char *server, *msg; { - tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg); + tprintf(td->td_proc, LOG_INFO, "nfs server %s: %s\n", server, msg); return (0); } @@ -2005,7 +2008,7 @@ nfsrv_rcv(so, arg, waitflag) slp->ns_flag |= SLP_NEEDQ; goto dorecs; } #endif - auio.uio_procp = NULL; + auio.uio_td = NULL; if (so->so_type == SOCK_STREAM) { /* * If there are already records on the queue, defer soreceive() diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index ad8891c..4425129 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -554,11 +554,11 @@ extern struct nfsnodehashhead *nfsnodehashtbl; extern u_long nfsnodehash; struct nfssvc_args; -extern int nfssvc(struct proc *, struct nfssvc_args *, int *); +extern int nfssvc(struct thread *, struct nfssvc_args *, int *); LIST_HEAD(nfsnodehashhead, nfsnode); -int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *)); +int nfs_webnamei __P((struct nameidata *, struct vnode *, struct thread *)); u_quad_t nfs_curusec() @@ -950,7 +950,7 @@ nfsm_disct(mdp, dposp, siz, left, cp2) { register struct mbuf *mp, *mp2; register int siz2, xfer; - register caddr_t p; + register caddr_t ptr; mp = *mdp; while (left == 0) { @@ -973,10 +973,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = p = mtod(mp, caddr_t); - bcopy(*dposp, p, left); /* Copy what was left */ + *cp2 = ptr = mtod(mp, caddr_t); + bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; - p += left; + ptr += left; mp2 = mp->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { @@ -984,10 +984,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) return (EBADRPC); xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { - bcopy(mtod(mp2, caddr_t), p, xfer); + bcopy(mtod(mp2, caddr_t), ptr, xfer); NFSMADV(mp2, xfer); mp2->m_len -= xfer; - p += xfer; + ptr += xfer; siz2 -= xfer; } if (siz2 > 0) @@ -1464,7 +1464,7 @@ nfs_getattrcache(vp, vaper) * released by the caller. */ int -nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) +nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, td, kerbflag, pubflag) register struct nameidata *ndp; fhandle_t *fhp; int len; @@ -1473,7 +1473,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) struct mbuf **mdp; caddr_t *dposp; struct vnode **retdirp; - struct proc *p; + struct thread *td; int kerbflag, pubflag; { register int i, rem; @@ -1613,7 +1613,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * becuase lookup() will dereference ni_startdir. */ - cnp->cn_proc = p; + cnp->cn_thread = td; VREF(dp); ndp->ni_startdir = dp; @@ -1649,7 +1649,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * Validate symlink */ if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); if (!pubflag) { error = EINVAL; goto badlink2; @@ -1670,7 +1670,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -1924,7 +1924,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) int kerbflag; int pubflag; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register struct mount *mp; register int i; struct ucred *credanon; @@ -1988,7 +1988,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) nfsrv_object_create(*vpp); if (!lockflag) - VOP_UNLOCK(*vpp, 0, p); + VOP_UNLOCK(*vpp, 0, td); return (0); } @@ -2196,8 +2196,8 @@ nfsrv_object_create(vp) if (vp == NULL || vp->v_type != VREG) return (1); - return (vfs_object_create(vp, curproc, - curproc ? curproc->p_ucred : NULL)); + return (vfs_object_create(vp, curthread, + curthread ? curthread->td_proc->p_ucred : NULL)); } /* diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index bc6f3c0..c70600f 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -101,14 +101,14 @@ static void nfs_decode_args __P((struct nfsmount *nmp, static int mountnfs __P((struct nfs_args *,struct mount *, struct sockaddr *,char *,char *,struct vnode **)); static int nfs_mount __P(( struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *p)); static int nfs_unmount __P(( struct mount *mp, int mntflags, - struct proc *p)); + struct thread *p)); static int nfs_root __P(( struct mount *mp, struct vnode **vpp)); static int nfs_statfs __P(( struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *p)); static int nfs_sync __P(( struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *p)); /* * nfs vfs operations. @@ -161,7 +161,7 @@ SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD, void nfsargs_ntoh __P((struct nfs_args *)); static int nfs_mountdiskless __P((char *, char *, int, struct sockaddr_in *, struct nfs_args *, - struct proc *, struct vnode **, + struct thread *, struct vnode **, struct mount **)); static void nfs_convert_diskless __P((void)); static void nfs_convert_oargs __P((struct nfs_args *args, @@ -241,10 +241,10 @@ nfs_convert_diskless() * nfs statfs call */ int -nfs_statfs(mp, sbp, p) +nfs_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { register struct vnode *vp; register struct nfs_statfs *sfp; @@ -266,11 +266,11 @@ nfs_statfs(mp, sbp, p) return (error); vp = NFSTOV(np); if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, p->p_ucred, p); + (void)nfs_fsinfo(nmp, vp, td->td_proc->p_ucred, td); nfsstats.rpccnt[NFSPROC_FSSTAT]++; nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_FSSTAT, p, p->p_ucred); + nfsm_request(vp, NFSPROC_FSSTAT, td, td->td_proc->p_ucred); if (v3) nfsm_postop_attr(vp, retattr); if (error) { @@ -315,11 +315,11 @@ nfs_statfs(mp, sbp, p) * nfs version 3 fsinfo rpc call */ int -nfs_fsinfo(nmp, vp, cred, p) +nfs_fsinfo(nmp, vp, cred, td) register struct nfsmount *nmp; register struct vnode *vp; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct nfsv3_fsinfo *fsp; register caddr_t cp; @@ -333,7 +333,7 @@ nfs_fsinfo(nmp, vp, cred, p) nfsstats.rpccnt[NFSPROC_FSINFO]++; nfsm_reqhead(vp, NFSPROC_FSINFO, NFSX_FH(1)); nfsm_fhtom(vp, 1); - nfsm_request(vp, NFSPROC_FSINFO, p, cred); + nfsm_request(vp, NFSPROC_FSINFO, td, cred); nfsm_postop_attr(vp, retattr); if (!error) { nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO); @@ -394,7 +394,7 @@ nfs_mountroot(mp) struct nfsv3_diskless *nd = &nfsv3_diskless; struct socket *so; struct vnode *vp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int error, i; u_long l; char buf[128]; @@ -433,7 +433,7 @@ nfs_mountroot(mp) * Do enough of ifconfig(8) so that the critical net interface can * talk to the server. */ - error = socreate(nd->myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0, p); + error = socreate(nd->myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0, td); if (error) panic("nfs_mountroot: socreate(%04x): %d", nd->myif.ifra_addr.sa_family, error); @@ -449,12 +449,12 @@ nfs_mountroot(mp) nd->myif.ifra_name[i] >= '0' && nd->myif.ifra_name[i] <= '9'; nd->myif.ifra_name[i] ++) { - error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, p); + error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); if(!error) break; } #endif - error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, p); + error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, td); if (error) panic("nfs_mountroot: SIOCAIFADDR: %d", error); soclose(so); @@ -488,7 +488,7 @@ nfs_mountroot(mp) (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam); printf("NFS ROOT: %s\n",buf); if ((error = nfs_mountdiskless(buf, "/", MNT_RDONLY, - &nd->root_saddr, &nd->root_args, p, &vp, &mp)) != 0) { + &nd->root_saddr, &nd->root_args, td, &vp, &mp)) != 0) { if (swap_mp) { mp->mnt_vfc->vfc_refcount--; free(swap_mp, M_MOUNT); @@ -514,9 +514,9 @@ nfs_mountroot(mp) (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam); printf("NFS SWAP: %s\n",buf); if ((error = nfs_mountdiskless(buf, "/swap", 0, - &nd->swap_saddr, &nd->swap_args, p, &vp, &swap_mp)) != 0) + &nd->swap_saddr, &nd->swap_args, td, &vp, &swap_mp)) != 0) return (error); - vfs_unbusy(swap_mp, p); + vfs_unbusy(swap_mp, td); VTONFS(vp)->n_size = VTONFS(vp)->n_vattr.va_size = nd->swap_nblks * DEV_BSIZE ; @@ -528,13 +528,13 @@ nfs_mountroot(mp) vp->v_type = VREG; vp->v_flag = 0; VREF(vp); - swaponvp(p, vp, NODEV, nd->swap_nblks); + swaponvp(td, vp, NODEV, nd->swap_nblks); } mp->mnt_flag |= MNT_ROOTFS; mp->mnt_vnodecovered = NULLVP; rootvp = vp; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); /* * This is not really an nfs issue, but it is much easier to @@ -554,13 +554,13 @@ nfs_mountroot(mp) * Internal version of mount system call for diskless setup. */ static int -nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp) +nfs_mountdiskless(path, which, mountflag, sin, args, td, vpp, mpp) char *path; char *which; int mountflag; struct sockaddr_in *sin; struct nfs_args *args; - struct proc *p; + struct thread *td; struct vnode **vpp; struct mount **mpp; { @@ -581,7 +581,7 @@ nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp) if ((error = mountnfs(args, mp, nam, which, path, vpp)) != 0) { printf("nfs_mountroot: mount %s on %s: %d", path, which, error); mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); free(mp, M_MOUNT); FREE(nam, M_SONAME); return (error); @@ -750,12 +750,12 @@ nfs_decode_args(nmp, argp) */ /* ARGSUSED */ static int -nfs_mount(mp, path, data, ndp, p) +nfs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { int error; struct nfs_args args; @@ -930,12 +930,12 @@ mountnfs(argp, mp, nam, pth, hst, vpp) * Get file attributes for the mountpoint. This has the side * effect of filling in (*vpp)->v_type with the correct value. */ - VOP_GETATTR(*vpp, &attrs, curproc->p_ucred, curproc); + VOP_GETATTR(*vpp, &attrs, curthread->td_proc->p_ucred, curthread); /* * Lose the lock but keep the ref. */ - VOP_UNLOCK(*vpp, 0, curproc); + VOP_UNLOCK(*vpp, 0, curthread); return (0); bad: @@ -949,10 +949,10 @@ bad: * unmount system call */ static int -nfs_unmount(mp, mntflags, p) +nfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct nfsmount *nmp; int error, flags = 0; @@ -1027,11 +1027,11 @@ extern int syncprt; */ /* ARGSUSED */ static int -nfs_sync(mp, waitfor, cred, p) +nfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *vp, *vnp; int error, allerror = 0; @@ -1059,11 +1059,11 @@ loop: mtx_lock(&mntvnode_mtx); continue; } - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { mtx_lock(&mntvnode_mtx); goto loop; } - error = VOP_FSYNC(vp, cred, waitfor, p); + error = VOP_FSYNC(vp, cred, waitfor, td); if (error) allerror = error; vput(vp); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 5b84741..8f9ff7d 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -102,8 +102,8 @@ static int nfsfifo_write __P((struct vop_write_args *)); static int nfsspec_close __P((struct vop_close_args *)); static int nfsfifo_close __P((struct vop_close_args *)); #define nfs_poll vop_nopoll -static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); -static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); +static int nfs_flush __P((struct vnode *,struct ucred *,int,struct thread *,int)); +static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct thread *)); static int nfs_lookup __P((struct vop_lookup_args *)); static int nfs_create __P((struct vop_create_args *)); static int nfs_mknod __P((struct vop_mknod_args *)); @@ -123,7 +123,7 @@ static int nfs_symlink __P((struct vop_symlink_args *)); static int nfs_readdir __P((struct vop_readdir_args *)); static int nfs_strategy __P((struct vop_strategy_args *)); static int nfs_lookitup __P((struct vnode *, const char *, int, - struct ucred *, struct proc *, struct nfsnode **)); + struct ucred *, struct thread *, struct nfsnode **)); static int nfs_sillyrename __P((struct vnode *,struct vnode *,struct componentname *)); static int nfsspec_access __P((struct vop_access_args *)); static int nfs_readlink __P((struct vop_readlink_args *)); @@ -224,11 +224,11 @@ static int nfs_mknodrpc __P((struct vnode *dvp, struct vnode **vpp, struct vattr *vap)); static int nfs_removerpc __P((struct vnode *dvp, const char *name, int namelen, - struct ucred *cred, struct proc *proc)); + struct ucred *cred, struct thread *td)); static int nfs_renamerpc __P((struct vnode *fdvp, const char *fnameptr, int fnamelen, struct vnode *tdvp, const char *tnameptr, int tnamelen, - struct ucred *cred, struct proc *proc)); + struct ucred *cred, struct thread *td)); static int nfs_renameit __P((struct vnode *sdvp, struct componentname *scnp, struct sillyrename *sp)); @@ -268,7 +268,7 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, static int nfs3_access_otw(struct vnode *vp, int wmode, - struct proc *p, + struct thread *td, struct ucred *cred) { const int v3 = 1; @@ -287,7 +287,7 @@ nfs3_access_otw(struct vnode *vp, nfsm_fhtom(vp, v3); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(wmode); - nfsm_request(vp, NFSPROC_ACCESS, p, cred); + nfsm_request(vp, NFSPROC_ACCESS, td, cred); nfsm_postop_attr(vp, attrflag); if (!error) { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); @@ -312,7 +312,7 @@ nfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -383,7 +383,7 @@ nfs_access(ap) * Either a no, or a don't know. Go to the wire. */ nfsstats.accesscache_misses++; - error = nfs3_access_otw(vp, wmode, ap->a_p,ap->a_cred); + error = nfs3_access_otw(vp, wmode, ap->a_td,ap->a_cred); if (!error) { if ((np->n_mode & mode) != mode) { error = EACCES; @@ -416,7 +416,7 @@ nfs_access(ap) auio.uio_resid = 1; auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = ap->a_p; + auio.uio_td = ap->a_td; if (vp->v_type == VREG) error = nfs_readrpc(vp, &auio, ap->a_cred); @@ -450,7 +450,7 @@ nfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -472,14 +472,14 @@ nfs_open(ap) if (NQNFS_CKINVALID(vp, np, ND_READ)) { do { error = nqnfs_getlease(vp, ND_READ, ap->a_cred, - ap->a_p); + ap->a_td); } while (error == NQNFS_EXPIRED); if (error) return (error); if (np->n_lrev != np->n_brev || (np->n_flag & NQNFSNONCACHE)) { if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); np->n_brev = np->n_lrev; } @@ -487,24 +487,24 @@ nfs_open(ap) } else { if (np->n_flag & NMODIFIED) { if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); np->n_attrstamp = 0; if (vp->v_type == VDIR) np->n_direofoffset = 0; - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } else { - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); + error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td); if (error) return (error); if (np->n_mtime != vattr.va_mtime.tv_sec) { if (vp->v_type == VDIR) np->n_direofoffset = 0; if ((error = nfs_vinvalbuf(vp, V_SAVE, - ap->a_cred, ap->a_p, 1)) == EINTR) + ap->a_cred, ap->a_td, 1)) == EINTR) return (error); np->n_mtime = vattr.va_mtime.tv_sec; } @@ -553,7 +553,7 @@ nfs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -578,10 +578,10 @@ nfs_close(ap) * cannot clear it if we don't commit. */ int cm = nfsv3_commit_on_close ? 1 : 0; - error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_p, cm); + error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_td, cm); /* np->n_flag &= ~NMODIFIED; */ } else { - error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1); + error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1); } np->n_attrstamp = 0; } @@ -602,7 +602,7 @@ nfs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -628,7 +628,7 @@ nfs_getattr(ap) if (v3 && nfsaccess_cache_timeout > 0) { nfsstats.accesscache_misses++; - nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_p, ap->a_cred); + nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_td, ap->a_cred); if (nfs_getattrcache(vp, ap->a_vap) == 0) return (0); } @@ -636,7 +636,7 @@ nfs_getattr(ap) nfsstats.rpccnt[NFSPROC_GETATTR]++; nfsm_reqhead(vp, NFSPROC_GETATTR, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_GETATTR, ap->a_p, ap->a_cred); + nfsm_request(vp, NFSPROC_GETATTR, ap->a_td, ap->a_cred); if (!error) { nfsm_loadattr(vp, ap->a_vap); } @@ -654,7 +654,7 @@ nfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -708,10 +708,10 @@ nfs_setattr(ap) if (np->n_flag & NMODIFIED) { if (vap->va_size == 0) error = nfs_vinvalbuf(vp, 0, - ap->a_cred, ap->a_p, 1); + ap->a_cred, ap->a_td, 1); else error = nfs_vinvalbuf(vp, V_SAVE, - ap->a_cred, ap->a_p, 1); + ap->a_cred, ap->a_td, 1); if (error) { vnode_pager_setsize(vp, np->n_size); return (error); @@ -724,9 +724,9 @@ nfs_setattr(ap) vap->va_atime.tv_sec != VNOVAL) && (np->n_flag & NMODIFIED) && vp->v_type == VREG && (error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, - ap->a_p, 1)) == EINTR) + ap->a_td, 1)) == EINTR) return (error); - error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_p); + error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_td); if (error && vap->va_size != VNOVAL) { np->n_size = np->n_vattr.va_size = tsize; vnode_pager_setsize(vp, np->n_size); @@ -738,11 +738,11 @@ nfs_setattr(ap) * Do an nfs setattr rpc. */ static int -nfs_setattrrpc(vp, vap, cred, procp) +nfs_setattrrpc(vp, vap, cred, td) register struct vnode *vp; register struct vattr *vap; struct ucred *cred; - struct proc *procp; + struct thread *td; { register struct nfsv2_sattr *sp; register caddr_t cp; @@ -778,7 +778,7 @@ nfs_setattrrpc(vp, vap, cred, procp) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(vp, NFSPROC_SETATTR, procp, cred); + nfsm_request(vp, NFSPROC_SETATTR, td, cred); if (v3) { nfsm_wcc_data(vp, wccflag); } else @@ -817,7 +817,7 @@ nfs_lookup(ap) struct nfsnode *np; int lockparent, wantparent, error = 0, attrflag, fhsize; int v3 = NFS_ISV3(dvp); - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; *vpp = NULLVP; cnp->cn_flags &= ~PDIRUNLOCK; @@ -834,7 +834,7 @@ nfs_lookup(ap) struct vattr vattr; int vpid; - if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) != 0) { + if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) { *vpp = NULLVP; return (error); } @@ -849,24 +849,24 @@ nfs_lookup(ap) VREF(newvp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; - error = vget(newvp, LK_EXCLUSIVE, p); + error = vget(newvp, LK_EXCLUSIVE, td); if (!error && lockparent && (flags & ISLASTCN)) { - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error == 0) cnp->cn_flags &= ~PDIRUNLOCK; } } else { - error = vget(newvp, LK_EXCLUSIVE, p); + error = vget(newvp, LK_EXCLUSIVE, td); if (!lockparent || error || !(flags & ISLASTCN)) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } if (!error) { if (vpid == newvp->v_id) { - if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, p) + if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td) && vattr.va_ctime.tv_sec == VTONFS(newvp)->n_ctime) { nfsstats.lookupcache_hits++; if (cnp->cn_nameiop != LOOKUP && @@ -878,9 +878,9 @@ nfs_lookup(ap) } vput(newvp); if (lockparent && dvp != newvp && (flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); *vpp = NULLVP; if (error) { cnp->cn_flags |= PDIRUNLOCK; @@ -897,7 +897,7 @@ nfs_lookup(ap) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_thread, cnp->cn_cred); if (error) { nfsm_postop_attr(dvp, attrflag); m_freem(mrep); @@ -928,22 +928,22 @@ nfs_lookup(ap) m_freem(mrep); cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); } if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); error = nfs_nget(dvp->v_mount, fhp, fhsize, &np); if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } newvp = NFSTOV(np); if (lockparent && (flags & ISLASTCN)) { - error = vn_lock(dvp, LK_EXCLUSIVE, p); + error = vn_lock(dvp, LK_EXCLUSIVE, td); if (error) { cnp->cn_flags |= PDIRUNLOCK; vput(newvp); @@ -962,7 +962,7 @@ nfs_lookup(ap) } if (!lockparent || !(flags & ISLASTCN)) { cnp->cn_flags |= PDIRUNLOCK; - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); } newvp = NFSTOV(np); } @@ -988,7 +988,7 @@ nfs_lookup(ap) if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && (flags & ISLASTCN) && error == ENOENT) { if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } if (dvp->v_mount->mnt_flag & MNT_RDONLY) @@ -1061,7 +1061,7 @@ nfs_readlinkrpc(vp, uiop, cred) nfsstats.rpccnt[NFSPROC_READLINK]++; nfsm_reqhead(vp, NFSPROC_READLINK, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_READLINK, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READLINK, uiop->uio_td, cred); if (v3) nfsm_postop_attr(vp, attrflag); if (!error) { @@ -1117,7 +1117,7 @@ nfs_readrpc(vp, uiop, cred) *tl++ = txdr_unsigned(len); *tl = 0; } - nfsm_request(vp, NFSPROC_READ, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READ, uiop->uio_td, cred); if (v3) { nfsm_postop_attr(vp, attrflag); if (error) { @@ -1195,7 +1195,7 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit) *tl = x; /* size of this write */ } nfsm_uiotom(uiop, len); - nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_WRITE, uiop->uio_td, cred); if (v3) { wccflag = NFSV3_WCCCHK; nfsm_wcc_data(vp, wccflag); @@ -1288,7 +1288,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) else { return (EOPNOTSUPP); } - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } nfsstats.rpccnt[NFSPROC_MKNOD]++; @@ -1314,7 +1314,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_MKNOD, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_MKNOD, cnp->cn_thread, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1323,7 +1323,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1396,7 +1396,7 @@ nfs_create(ap) if (vap->va_type == VSOCK) return (nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap)); - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } if (vap->va_vaflags & VA_EXCLUSIVE) @@ -1432,7 +1432,7 @@ again: txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_thread, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1441,7 +1441,7 @@ again: newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1469,7 +1469,7 @@ again: vfs_timestamp(&vap->va_mtime); if (vap->va_atime.tv_sec == VNOVAL) vap->va_atime = vap->va_mtime; - error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_proc); + error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_thread); } if (!error) { if (cnp->cn_flags & MAKEENTRY) @@ -1518,7 +1518,7 @@ nfs_remove(ap) if (vp->v_type == VDIR) error = EPERM; else if (vp->v_usecount == 1 || (np->n_sillyrename && - VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_proc) == 0 && + VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_thread) == 0 && vattr.va_nlink > 1)) { /* * Purge the name cache so that the chance of a lookup for @@ -1532,11 +1532,11 @@ nfs_remove(ap) * throw away biocache buffers, mainly to avoid * unnecessary delayed writes later. */ - error = nfs_vinvalbuf(vp, 0, cnp->cn_cred, cnp->cn_proc, 1); + error = nfs_vinvalbuf(vp, 0, cnp->cn_cred, cnp->cn_thread, 1); /* Do the rpc */ if (error != EINTR) error = nfs_removerpc(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc); + cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread); /* * Kludge City: If the first reply to the remove rpc is lost.. * the reply to the retransmitted request will be ENOENT @@ -1560,19 +1560,19 @@ nfs_removeit(sp) { return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, sp->s_cred, - (struct proc *)0)); + (struct thread *)0)); } /* * Nfs remove rpc, called from nfs_remove() and nfs_removeit(). */ static int -nfs_removerpc(dvp, name, namelen, cred, proc) +nfs_removerpc(dvp, name, namelen, cred, td) register struct vnode *dvp; const char *name; int namelen; struct ucred *cred; - struct proc *proc; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -1587,7 +1587,7 @@ nfs_removerpc(dvp, name, namelen, cred, proc) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen)); nfsm_fhtom(dvp, v3); nfsm_strtom(name, namelen, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_REMOVE, proc, cred); + nfsm_request(dvp, NFSPROC_REMOVE, td, cred); if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; @@ -1640,9 +1640,9 @@ nfs_rename(ap) * often. */ - VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_proc); + VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); if (tvp) - VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc); + VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); /* * If the tvp exists and is in use, sillyrename it before doing the @@ -1657,7 +1657,7 @@ nfs_rename(ap) error = nfs_renamerpc(fdvp, fcnp->cn_nameptr, fcnp->cn_namelen, tdvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred, - tcnp->cn_proc); + tcnp->cn_thread); if (fvp->v_type == VDIR) { if (tvp != NULL && tvp->v_type == VDIR) @@ -1692,14 +1692,14 @@ nfs_renameit(sdvp, scnp, sp) register struct sillyrename *sp; { return (nfs_renamerpc(sdvp, scnp->cn_nameptr, scnp->cn_namelen, - sdvp, sp->s_name, sp->s_namlen, scnp->cn_cred, scnp->cn_proc)); + sdvp, sp->s_name, sp->s_namlen, scnp->cn_cred, scnp->cn_thread)); } /* * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit(). */ static int -nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) +nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, td) register struct vnode *fdvp; const char *fnameptr; int fnamelen; @@ -1707,7 +1707,7 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) const char *tnameptr; int tnamelen; struct ucred *cred; - struct proc *proc; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -1725,7 +1725,7 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN); nfsm_fhtom(tdvp, v3); nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN); - nfsm_request(fdvp, NFSPROC_RENAME, proc, cred); + nfsm_request(fdvp, NFSPROC_RENAME, td, cred); if (v3) { nfsm_wcc_data(fdvp, fwccflag); nfsm_wcc_data(tdvp, twccflag); @@ -1771,7 +1771,7 @@ nfs_link(ap) * doesn't get "out of sync" with the server. * XXX There should be a better way! */ - VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc); + VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_thread); v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; @@ -1780,7 +1780,7 @@ nfs_link(ap) nfsm_fhtom(vp, v3); nfsm_fhtom(tdvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred); + nfsm_request(vp, NFSPROC_LINK, cnp->cn_thread, cnp->cn_cred); if (v3) { nfsm_postop_attr(vp, attrflag); nfsm_wcc_data(tdvp, wccflag); @@ -1852,7 +1852,7 @@ nfs_symlink(ap) * a file handle that can be converted into newvp without having * to do an extra lookup rpc. */ - nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_thread, cnp->cn_cred); if (v3) { if (error == 0) nfsm_mtofh(dvp, newvp, v3, gotvp); @@ -1882,7 +1882,7 @@ nfs_symlink(ap) struct nfsnode *np = NULL; error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_proc, &np); + cnp->cn_cred, cnp->cn_thread, &np); if (!error) newvp = NFSTOV(np); } @@ -1927,7 +1927,7 @@ nfs_mkdir(ap) struct vattr vattr; int v3 = NFS_ISV3(dvp); - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_thread)) != 0) { return (error); } len = cnp->cn_namelen; @@ -1947,7 +1947,7 @@ nfs_mkdir(ap) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_thread, cnp->cn_cred); if (!error) nfsm_mtofh(dvp, newvp, v3, gotvp); if (v3) @@ -1966,7 +1966,7 @@ nfs_mkdir(ap) newvp = (struct vnode *)0; } error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred, - cnp->cn_proc, &np); + cnp->cn_thread, &np); if (!error) { newvp = NFSTOV(np); if (newvp->v_type != VDIR) @@ -2010,7 +2010,7 @@ nfs_rmdir(ap) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_proc, cnp->cn_cred); + nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_thread, cnp->cn_cred); if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; @@ -2056,7 +2056,7 @@ nfs_readdir(ap) nfsstats.direofcache_hits++; return (0); } - } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) == 0 && + } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_td) == 0 && np->n_mtime == vattr.va_mtime.tv_sec) { nfsstats.direofcache_hits++; return (0); @@ -2136,7 +2136,7 @@ nfs_readdirrpc(vp, uiop, cred) *tl++ = cookie.nfsuquad[0]; } *tl = txdr_unsigned(nmp->nm_readdirsize); - nfsm_request(vp, NFSPROC_READDIR, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READDIR, uiop->uio_td, cred); if (v3) { nfsm_postop_attr(vp, attrflag); if (!error) { @@ -2326,7 +2326,7 @@ nfs_readdirplusrpc(vp, uiop, cred) *tl++ = dnp->n_cookieverf.nfsuquad[1]; *tl++ = txdr_unsigned(nmp->nm_readdirsize); *tl = txdr_unsigned(nmp->nm_rsize); - nfsm_request(vp, NFSPROC_READDIRPLUS, uiop->uio_procp, cred); + nfsm_request(vp, NFSPROC_READDIRPLUS, uiop->uio_td, cred); nfsm_postop_attr(vp, attrflag); if (error) { m_freem(mrep); @@ -2525,12 +2525,12 @@ nfs_sillyrename(dvp, vp, cnp) VREF(dvp); /* Fudge together a funny name */ - pid = cnp->cn_proc->p_pid; + pid = cnp->cn_thread->td_proc->p_pid; sp->s_namlen = sprintf(sp->s_name, ".nfsA%04x4.4", pid); /* Try lookitups until we get one that isn't there */ while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_proc, (struct nfsnode **)0) == 0) { + cnp->cn_thread, (struct nfsnode **)0) == 0) { sp->s_name[4]++; if (sp->s_name[4] > 'z') { error = EINVAL; @@ -2541,7 +2541,7 @@ nfs_sillyrename(dvp, vp, cnp) if (error) goto bad; error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_proc, &np); + cnp->cn_thread, &np); np->n_sillyrename = sp; return (0); bad: @@ -2560,12 +2560,12 @@ bad: * *npp != NULL --> update the file handle in the vnode */ static int -nfs_lookitup(dvp, name, len, cred, procp, npp) +nfs_lookitup(dvp, name, len, cred, td, npp) register struct vnode *dvp; const char *name; int len; struct ucred *cred; - struct proc *procp; + struct thread *td; struct nfsnode **npp; { register u_int32_t *tl; @@ -2584,7 +2584,7 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); nfsm_fhtom(dvp, v3); nfsm_strtom(name, len, NFS_MAXNAMLEN); - nfsm_request(dvp, NFSPROC_LOOKUP, procp, cred); + nfsm_request(dvp, NFSPROC_LOOKUP, td, cred); if (npp && !error) { nfsm_getfh(nfhp, fhlen, v3); if (*npp) { @@ -2640,12 +2640,12 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) * Nfs Version 3 commit rpc */ int -nfs_commit(vp, offset, cnt, cred, procp) +nfs_commit(vp, offset, cnt, cred, td) struct vnode *vp; u_quad_t offset; int cnt; struct ucred *cred; - struct proc *procp; + struct thread *td; { register caddr_t cp; register u_int32_t *tl; @@ -2664,7 +2664,7 @@ nfs_commit(vp, offset, cnt, cred, procp) txdr_hyper(offset, tl); tl += 2; *tl = txdr_unsigned(cnt); - nfsm_request(vp, NFSPROC_COMMIT, procp, cred); + nfsm_request(vp, NFSPROC_COMMIT, td, cred); nfsm_wcc_data(vp, wccflag); if (!error) { nfsm_dissect(tl, u_int32_t *, NFSX_V3WRITEVERF); @@ -2691,7 +2691,7 @@ nfs_strategy(ap) { register struct buf *bp = ap->a_bp; struct ucred *cr; - struct proc *p; + struct thread *td; int error = 0; KASSERT(!(bp->b_flags & B_DONE), ("nfs_strategy: buffer %p unexpectedly marked B_DONE", bp)); @@ -2701,9 +2701,9 @@ nfs_strategy(ap) panic("nfs physio"); if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; + td = (struct thread *)0; else - p = curproc; /* XXX */ + td = curthread; /* XXX */ if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; @@ -2716,8 +2716,8 @@ nfs_strategy(ap) * otherwise just do it ourselves. */ if ((bp->b_flags & B_ASYNC) == 0 || - nfs_asyncio(bp, NOCRED, p)) - error = nfs_doio(bp, cr, p); + nfs_asyncio(bp, NOCRED, td)) + error = nfs_doio(bp, cr, td); return (error); } @@ -2732,11 +2732,11 @@ nfs_fsync(ap) struct vnode * a_vp; struct ucred * a_cred; int a_waitfor; - struct proc * a_p; + struct thread * a_td; } */ *ap; { - return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1)); + return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1)); } /* @@ -2745,11 +2745,11 @@ nfs_fsync(ap) * associated with the vnode. */ static int -nfs_flush(vp, cred, waitfor, p, commit) +nfs_flush(vp, cred, waitfor, td, commit) register struct vnode *vp; struct ucred *cred; int waitfor; - struct proc *p; + struct thread *td; int commit; { register struct nfsnode *np = VTONFS(vp); @@ -2878,7 +2878,7 @@ again: */ if (wcred != NOCRED) retv = nfs_commit(vp, off, (int)(endoff - off), - wcred, p); + wcred, td); else { retv = 0; for (i = 0; i < bvecpos; i++) { @@ -2889,7 +2889,7 @@ again: size = (u_quad_t)(bp->b_dirtyend - bp->b_dirtyoff); retv = nfs_commit(vp, off, (int)size, - bp->b_wcred, p); + bp->b_wcred, td); if (retv) break; } } @@ -2949,7 +2949,7 @@ loop: panic("nfs_fsync: inconsistent lock"); if (error == ENOLCK) goto loop; - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { error = EINTR; goto done; } @@ -2985,7 +2985,7 @@ loop: error = tsleep((caddr_t)&vp->v_numoutput, slpflag | (PRIBIO + 1), "nfsfsync", slptimeo); if (error) { - if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) { + if (nfs_sigintr(nmp, (struct nfsreq *)0, td->td_proc)) { error = EINTR; goto done; } @@ -3053,10 +3053,10 @@ nfs_print(ap) * We set B_CACHE if this is a VMIO buffer. */ int -nfs_writebp(bp, force, procp) +nfs_writebp(bp, force, td) register struct buf *bp; int force; - struct proc *procp; + struct thread *td; { int s; int oldflags = bp->b_flags; @@ -3086,7 +3086,7 @@ nfs_writebp(bp, force, procp) bp->b_iocmd = BIO_WRITE; bp->b_vp->v_numoutput++; - curproc->p_stats->p_ru.ru_oublock++; + curthread->td_proc->p_stats->p_ru.ru_oublock++; splx(s); /* @@ -3127,7 +3127,7 @@ nfsspec_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vattr *vap; @@ -3161,7 +3161,7 @@ nfsspec_access(ap) if (cred->cr_uid == 0) return (0); vap = &vattr; - error = VOP_GETATTR(vp, vap, cred, ap->a_p); + error = VOP_GETATTR(vp, vap, cred, ap->a_td); if (error) return (error); /* @@ -3238,7 +3238,7 @@ nfsspec_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -3254,7 +3254,7 @@ nfsspec_close(ap) vattr.va_atime = np->n_atim; if (np->n_flag & NUPD) vattr.va_mtime = np->n_mtim; - (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p); + (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td); } } return (VOCALL(spec_vnodeop_p, VOFFSET(vop_close), ap)); @@ -3315,7 +3315,7 @@ nfsfifo_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -3337,7 +3337,7 @@ nfsfifo_close(ap) vattr.va_atime = np->n_atim; if (np->n_flag & NUPD) vattr.va_mtime = np->n_mtim; - (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p); + (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td); } } return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap)); diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h index 44d04b9..d5d0796 100644 --- a/sys/nfsclient/nfsargs.h +++ b/sys/nfsclient/nfsargs.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/nfsclient/nfsnode.h b/sys/nfsclient/nfsnode.h index 968f39c..ba99fea 100644 --- a/sys/nfsclient/nfsnode.h +++ b/sys/nfsclient/nfsnode.h @@ -171,16 +171,16 @@ extern struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; static __inline int -nfs_rslock(struct nfsnode *np, struct proc *p) +nfs_rslock(struct nfsnode *np, struct thread *td) { - return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, p)); + return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, td)); } static __inline void -nfs_rsunlock(struct nfsnode *np, struct proc *p) +nfs_rsunlock(struct nfsnode *np, struct thread *td) { - (void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, p); + (void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, td); } extern vop_t **fifo_nfsv2nodeop_p; diff --git a/sys/nfsclient/nfsstats.h b/sys/nfsclient/nfsstats.h index 44d04b9..d5d0796 100644 --- a/sys/nfsclient/nfsstats.h +++ b/sys/nfsclient/nfsstats.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h index 44d04b9..d5d0796 100644 --- a/sys/nfsserver/nfs.h +++ b/sys/nfsserver/nfs.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index e015d17..0469388 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -145,7 +145,7 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_blks, CTLFLAG_RW, &nfs_commit_blks, 0, "") SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_miss, CTLFLAG_RW, &nfs_commit_miss, 0, ""); static int nfsrv_access __P((struct vnode *,int,struct ucred *,int, - struct proc *, int)); + struct thread *, int)); static void nfsrvw_coalesce __P((struct nfsrv_descript *, struct nfsrv_descript *)); @@ -168,10 +168,10 @@ ndclear(struct nameidata *nd) * nfs v3 access service */ int -nfsrv3_access(nfsd, slp, procp, mrq) +nfsrv3_access(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -208,7 +208,7 @@ nfsrv3_access(nfsd, slp, procp, mrq) } nfsmode = fxdr_unsigned(u_int32_t, *tl); if ((nfsmode & NFSV3ACCESS_READ) && - nfsrv_access(vp, VREAD, cred, rdonly, procp, 0)) + nfsrv_access(vp, VREAD, cred, rdonly, td, 0)) nfsmode &= ~NFSV3ACCESS_READ; if (vp->v_type == VDIR) testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | @@ -216,16 +216,16 @@ nfsrv3_access(nfsd, slp, procp, mrq) else testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if ((nfsmode & testmode) && - nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0)) + nfsrv_access(vp, VWRITE, cred, rdonly, td, 0)) nfsmode &= ~testmode; if (vp->v_type == VDIR) testmode = NFSV3ACCESS_LOOKUP; else testmode = NFSV3ACCESS_EXECUTE; if ((nfsmode & testmode) && - nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0)) + nfsrv_access(vp, VEXEC, cred, rdonly, td, 0)) nfsmode &= ~testmode; - getret = VOP_GETATTR(vp, vap, cred, procp); + getret = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); @@ -242,10 +242,10 @@ nfsmout: * nfs getattr service */ int -nfsrv_getattr(nfsd, slp, procp, mrq) +nfsrv_getattr(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -277,7 +277,7 @@ nfsrv_getattr(nfsd, slp, procp, mrq) goto nfsmout; } nqsrv_getl(vp, ND_READ); - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); @@ -299,10 +299,10 @@ nfsmout: * nfs setattr service */ int -nfsrv_setattr(nfsd, slp, procp, mrq) +nfsrv_setattr(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -399,7 +399,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_WRITE); if (v3) { - error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); + error = preat_ret = VOP_GETATTR(vp, &preat, cred, td); if (!error && gcheck && (preat.va_ctime.tv_sec != guard.tv_sec || preat.va_ctime.tv_nsec != guard.tv_nsec)) @@ -428,11 +428,11 @@ nfsrv_setattr(nfsd, slp, procp, mrq) error = EISDIR; goto out; } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly, - procp, 0)) != 0) + td, 0)) != 0) goto out; } - error = VOP_SETATTR(vp, vap, cred, procp); - postat_ret = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_SETATTR(vp, vap, cred, td); + postat_ret = VOP_GETATTR(vp, vap, cred, td); if (!error) error = postat_ret; out: @@ -462,10 +462,10 @@ nfsmout: * nfs lookup rpc */ int -nfsrv_lookup(nfsd, slp, procp, mrq) +nfsrv_lookup(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -501,7 +501,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), pubflag); /* * namei failure, only dirp to cleanup. Clear out garbarge from @@ -512,7 +512,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -544,7 +544,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) * via the original nd. Confused? You aren't alone! */ ind = nd; - VOP_UNLOCK(nd.ni_vp, 0, procp); + VOP_UNLOCK(nd.ni_vp, 0, td); ind.ni_pathlen = strlen(nfs_pub.np_index); ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf = nfs_pub.np_index; @@ -586,7 +586,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -624,7 +624,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); ndp->ni_vp = NULL; @@ -658,10 +658,10 @@ nfsmout: * nfs readlink service */ int -nfsrv_readlink(nfsd, slp, procp, mrq) +nfsrv_readlink(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -720,7 +720,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq) uiop->uio_resid = len; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE); if (error) { @@ -739,7 +739,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_READ); error = VOP_READLINK(vp, uiop, cred); out: - getret = VOP_GETATTR(vp, &attr, cred, procp); + getret = VOP_GETATTR(vp, &attr, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); @@ -771,10 +771,10 @@ nfsmout: * nfs read service */ int -nfsrv_read(nfsd, slp, procp, mrq) +nfsrv_read(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -840,10 +840,10 @@ nfsrv_read(nfsd, slp, procp, mrq) } if (!error) { nqsrv_getl(vp, ND_READ); - if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0) - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1); + if ((error = nfsrv_access(vp, VREAD, cred, rdonly, td, 1)) != 0) + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 1); } - getret = VOP_GETATTR(vp, vap, cred, procp); + getret = VOP_GETATTR(vp, vap, cred, td); if (!error) error = getret; if (error) { @@ -982,7 +982,7 @@ nfsrv_read(nfsd, slp, procp, mrq) off = uiop->uio_offset; nh->nh_nextr = off; FREE((caddr_t)iv2, M_TEMP); - if (error || (getret = VOP_GETATTR(vp, vap, cred, procp))) { + if (error || (getret = VOP_GETATTR(vp, vap, cred, td))) { if (!error) error = getret; m_freem(mreq); @@ -1022,10 +1022,10 @@ nfsmout: * nfs write service */ int -nfsrv_write(nfsd, slp, procp, mrq) +nfsrv_write(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1137,7 +1137,7 @@ nfsrv_write(nfsd, slp, procp, mrq) goto nfsmout; } if (v3) - forat_ret = VOP_GETATTR(vp, &forat, cred, procp); + forat_ret = VOP_GETATTR(vp, &forat, cred, td); if (vp->v_type != VREG) { if (v3) error = EINVAL; @@ -1146,7 +1146,7 @@ nfsrv_write(nfsd, slp, procp, mrq) } if (!error) { nqsrv_getl(vp, ND_WRITE); - error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); + error = nfsrv_access(vp, VWRITE, cred, rdonly, td, 1); } if (error) { vput(vp); @@ -1188,13 +1188,13 @@ nfsrv_write(nfsd, slp, procp, mrq) uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; uiop->uio_offset = off; error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; FREE((caddr_t)iv, M_TEMP); } - aftat_ret = VOP_GETATTR(vp, vap, cred, procp); + aftat_ret = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; if (!error) @@ -1246,10 +1246,10 @@ nfsmout: * Jan. 1994. */ int -nfsrv_writegather(ndp, slp, procp, mrq) +nfsrv_writegather(ndp, slp, td, mrq) struct nfsrv_descript **ndp; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { register struct iovec *ivp; @@ -1427,7 +1427,7 @@ loop1: nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE); if (!error) { if (v3) - forat_ret = VOP_GETATTR(vp, &forat, cred, procp); + forat_ret = VOP_GETATTR(vp, &forat, cred, td); if (vp->v_type != VREG) { if (v3) error = EINVAL; @@ -1439,7 +1439,7 @@ loop1: } if (!error) { nqsrv_getl(vp, ND_WRITE); - error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); + error = nfsrv_access(vp, VWRITE, cred, rdonly, td, 1); } if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) @@ -1450,7 +1450,7 @@ loop1: ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = (struct proc *)0; + uiop->uio_td = (struct thread *)0; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; if (uiop->uio_resid > 0) { @@ -1476,9 +1476,9 @@ loop1: } if (!error) { if (vn_start_write(vp, &mntp, V_NOWAIT) != 0) { - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); error = vn_start_write(NULL, &mntp, V_WAIT); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); } } if (!error) { @@ -1490,7 +1490,7 @@ loop1: } m_freem(mrep); if (vp) { - aftat_ret = VOP_GETATTR(vp, &va, cred, procp); + aftat_ret = VOP_GETATTR(vp, &va, cred, td); vput(vp); vp = NULL; } @@ -1631,10 +1631,10 @@ nfsrvw_coalesce(owp, nfsd) * now does a truncate to 0 length via. setattr if it already exists */ int -nfsrv_create(nfsd, slp, procp, mrq) +nfsrv_create(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1696,11 +1696,11 @@ nfsrv_create(nfsd, slp, procp, mrq) * prior to calling nfsm_reply ( which might goto nfsmout ). */ error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -1793,7 +1793,7 @@ nfsrv_create(nfsd, slp, procp, mrq) bcopy(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF); error = VOP_SETATTR(nd.ni_vp, vap, cred, - procp); + td); } } } else if ( @@ -1836,7 +1836,7 @@ nfsrv_create(nfsd, slp, procp, mrq) */ nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT); - nd.ni_cnd.cn_proc = procp; + nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -1857,14 +1857,14 @@ nfsrv_create(nfsd, slp, procp, mrq) } else { if (vap->va_size != -1) { error = nfsrv_access(nd.ni_vp, VWRITE, cred, - (nd.ni_cnd.cn_flags & RDONLY), procp, 0); + (nd.ni_cnd.cn_flags & RDONLY), td, 0); if (!error) { nqsrv_getl(nd.ni_vp, ND_WRITE); tempsize = vap->va_size; VATTR_NULL(vap); vap->va_size = tempsize; error = VOP_SETATTR(nd.ni_vp, vap, cred, - procp); + td); } } } @@ -1874,13 +1874,13 @@ nfsrv_create(nfsd, slp, procp, mrq) fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(nd.ni_vp, vap, cred, procp); + error = VOP_GETATTR(nd.ni_vp, vap, cred, td); } if (v3) { if (exclusive_flag && !error && bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF)) error = EEXIST; - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -1930,10 +1930,10 @@ nfsmout: * nfs v3 mknod service */ int -nfsrv_mknod(nfsd, slp, procp, mrq) +nfsrv_mknod(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -1986,9 +1986,9 @@ nfsrv_mknod(nfsd, slp, procp, mrq) */ error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) - dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); @@ -2046,8 +2046,8 @@ nfsrv_mknod(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT); - nd.ni_cnd.cn_proc = procp; - nd.ni_cnd.cn_cred = procp->p_ucred; + nd.ni_cnd.cn_thread = td; + nd.ni_cnd.cn_cred = td->td_proc->p_ucred; error = lookup(&nd); nd.ni_dvp = NULL; @@ -2080,12 +2080,12 @@ out: fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(vp, vap, cred, procp); + error = VOP_GETATTR(vp, vap, cred, td); vput(vp); vp = NULL; nd.ni_vp = NULL; } - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); if (dirp) { vrele(dirp); dirp = NULL; @@ -2121,10 +2121,10 @@ nfsmout: * nfs remove service */ int -nfsrv_remove(nfsd, slp, procp, mrq) +nfsrv_remove(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2169,11 +2169,11 @@ nfsrv_remove(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2200,7 +2200,7 @@ out: } } if (dirp && v3) { - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -2228,10 +2228,10 @@ nfsmout: * nfs rename service */ int -nfsrv_rename(nfsd, slp, procp, mrq) +nfsrv_rename(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2293,11 +2293,11 @@ nfsrv_rename(nfsd, slp, procp, mrq) fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md, - &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dpos, &fdirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (fdirp) { if (v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, - procp); + td); } else { vrele(fdirp); fdirp = NULL; @@ -2318,11 +2318,11 @@ nfsrv_rename(nfsd, slp, procp, mrq) tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; error = nfs_namei(&tond, tfhp, len2, slp, nam, &md, - &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dpos, &tdirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (tdirp) { if (v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, - procp); + td); } else { vrele(tdirp); tdirp = NULL; @@ -2415,9 +2415,9 @@ out: out1: if (fdirp) - fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); + fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, td); if (tdirp) - tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); + tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, td); nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); @@ -2465,10 +2465,10 @@ nfsmout: * nfs link service */ int -nfsrv_link(nfsd, slp, procp, mrq) +nfsrv_link(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2528,11 +2528,11 @@ nfsrv_link(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2560,9 +2560,9 @@ out: out1: if (v3) - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); ereply: nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { @@ -2594,10 +2594,10 @@ nfsmout: * nfs symbolic link service */ int -nfsrv_symlink(nfsd, slp, procp, mrq) +nfsrv_symlink(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2644,11 +2644,11 @@ nfsrv_symlink(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2670,7 +2670,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) io.uio_iovcnt = 1; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; nfsm_mtouio(&io, len2); if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -2712,7 +2712,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | FOLLOW); nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); - nd.ni_cnd.cn_proc = procp; + nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -2724,7 +2724,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, vap, cred, - procp); + td); vput(nd.ni_vp); nd.ni_vp = NULL; } @@ -2740,7 +2740,7 @@ out: pathcp = NULL; } if (dirp) { - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); vrele(dirp); dirp = NULL; } @@ -2784,10 +2784,10 @@ nfsmout: * nfs mkdir service */ int -nfsrv_mkdir(nfsd, slp, procp, mrq) +nfsrv_mkdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2836,11 +2836,11 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -2890,11 +2890,11 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) - error = VOP_GETATTR(nd.ni_vp, vap, cred, procp); + error = VOP_GETATTR(nd.ni_vp, vap, cred, td); } out: if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { @@ -2935,10 +2935,10 @@ nfsmout: * nfs rmdir service */ int -nfsrv_rmdir(nfsd, slp, procp, mrq) +nfsrv_rmdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -2981,11 +2981,11 @@ nfsrv_rmdir(nfsd, slp, procp, mrq) nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, - &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); + &dirp, td, (nfsd->nd_flag & ND_KERBAUTH), FALSE); if (dirp) { if (v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, - procp); + td); } else { vrele(dirp); dirp = NULL; @@ -3027,7 +3027,7 @@ out: NDFREE(&nd, NDF_ONLY_PNBUF); if (dirp) - diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); + diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td); nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); @@ -3091,10 +3091,10 @@ struct flrep { }; int -nfsrv_readdir(nfsd, slp, procp, mrq) +nfsrv_readdir(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3163,7 +3163,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nqsrv_getl(vp, ND_READ); if (v3) { - error = getret = VOP_GETATTR(vp, &at, cred, procp); + error = getret = VOP_GETATTR(vp, &at, cred, td); #if 0 /* * XXX This check may be too strict for Solaris 2.5 clients. @@ -3173,7 +3173,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) #endif } if (!error) - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 0); if (error) { vput(vp); vp = NULL; @@ -3182,7 +3182,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); /* * end section. Allocate rbuf and continue @@ -3197,9 +3197,9 @@ again: io.uio_resid = fullsiz; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; @@ -3209,11 +3209,11 @@ again: if (!cookies && !error) error = NFSERR_PERM; if (v3) { - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); if (!error) error = getret; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); if (error) { vrele(vp); vp = NULL; @@ -3384,10 +3384,10 @@ nfsmout: } int -nfsrv_readdirplus(nfsd, slp, procp, mrq) +nfsrv_readdirplus(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3445,7 +3445,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - error = getret = VOP_GETATTR(vp, &at, cred, procp); + error = getret = VOP_GETATTR(vp, &at, cred, td); #if 0 /* * XXX This check may be too strict for Solaris 2.5 clients. @@ -3455,7 +3455,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) #endif if (!error) { nqsrv_getl(vp, ND_READ); - error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); + error = nfsrv_access(vp, VEXEC, cred, rdonly, td, 0); } if (error) { vput(vp); @@ -3465,7 +3465,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - VOP_UNLOCK(vp, 0, procp); + VOP_UNLOCK(vp, 0, td); MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; @@ -3476,17 +3476,17 @@ again: io.uio_resid = fullsiz; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; - io.uio_procp = (struct proc *)0; + io.uio_td = (struct thread *)0; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); off = (u_quad_t)io.uio_offset; - getret = VOP_GETATTR(vp, &at, cred, procp); - VOP_UNLOCK(vp, 0, procp); + getret = VOP_GETATTR(vp, &at, cred, td); + VOP_UNLOCK(vp, 0, td); if (!cookies && !error) error = NFSERR_PERM; if (!error) @@ -3603,7 +3603,7 @@ again: nvp = NULL; goto invalid; } - if (VOP_GETATTR(nvp, vap, cred, procp)) { + if (VOP_GETATTR(nvp, vap, cred, td)) { vput(nvp); nvp = NULL; goto invalid; @@ -3721,10 +3721,10 @@ nfsmout: * nfs commit service */ int -nfsrv_commit(nfsd, slp, procp, mrq) +nfsrv_commit(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3778,7 +3778,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) error = 0; goto nfsmout; } - for_ret = VOP_GETATTR(vp, &bfor, cred, procp); + for_ret = VOP_GETATTR(vp, &bfor, cred, td); if (cnt > MAX_COMMIT_COUNT) { /* @@ -3788,7 +3788,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) { vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC); } - error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); + error = VOP_FSYNC(vp, cred, MNT_WAIT, td); } else { /* * Locate and synchronously write any buffers that fall @@ -3846,7 +3846,7 @@ nfsrv_commit(nfsd, slp, procp, mrq) splx(s); } - aft_ret = VOP_GETATTR(vp, &aft, cred, procp); + aft_ret = VOP_GETATTR(vp, &aft, cred, td); vput(vp); vp = NULL; ereply: @@ -3872,10 +3872,10 @@ nfsmout: * nfs statfs service */ int -nfsrv_statfs(nfsd, slp, procp, mrq) +nfsrv_statfs(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3913,8 +3913,8 @@ nfsrv_statfs(nfsd, slp, procp, mrq) goto nfsmout; } sf = &statfs; - error = VFS_STATFS(vp->v_mount, sf, procp); - getret = VOP_GETATTR(vp, &at, cred, procp); + error = VFS_STATFS(vp->v_mount, sf, td); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); @@ -3959,10 +3959,10 @@ nfsmout: * nfs fsinfo service */ int -nfsrv_fsinfo(nfsd, slp, procp, mrq) +nfsrv_fsinfo(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -3999,10 +3999,10 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq) } /* XXX Try to make a guess on the max file size. */ - VFS_STATFS(vp->v_mount, &sb, procp); + VFS_STATFS(vp->v_mount, &sb, td); maxfsize = (u_quad_t)0x80000000 * sb.f_bsize - 1; - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); @@ -4041,10 +4041,10 @@ nfsmout: * nfs pathconf service */ int -nfsrv_pathconf(nfsd, slp, procp, mrq) +nfsrv_pathconf(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; @@ -4086,7 +4086,7 @@ nfsrv_pathconf(nfsd, slp, procp, mrq) error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres); if (!error) error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc); - getret = VOP_GETATTR(vp, &at, cred, procp); + getret = VOP_GETATTR(vp, &at, cred, td); vput(vp); vp = NULL; nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); @@ -4120,10 +4120,10 @@ nfsmout: */ /* ARGSUSED */ int -nfsrv_null(nfsd, slp, procp, mrq) +nfsrv_null(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep; @@ -4145,10 +4145,10 @@ nfsrv_null(nfsd, slp, procp, mrq) */ /* ARGSUSED */ int -nfsrv_noop(nfsd, slp, procp, mrq) +nfsrv_noop(nfsd, slp, td, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; - struct proc *procp; + struct thread *td; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep; @@ -4184,12 +4184,12 @@ nfsrv_noop(nfsd, slp, procp, mrq) * will return EPERM instead of EACCESS. EPERM is always an error. */ static int -nfsrv_access(vp, flags, cred, rdonly, p, override) +nfsrv_access(vp, flags, cred, rdonly, td, override) register struct vnode *vp; int flags; register struct ucred *cred; int rdonly; - struct proc *p; + struct thread *td; int override; { struct vattr vattr; @@ -4220,10 +4220,10 @@ nfsrv_access(vp, flags, cred, rdonly, p, override) if (vp->v_flag & VTEXT) return (ETXTBSY); } - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return (error); - error = VOP_ACCESS(vp, flags, cred, p); + error = VOP_ACCESS(vp, flags, cred, td); /* * Allow certain operations for the owner (reads and writes * on files that are already open). diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c index 5772e4b..8991672 100644 --- a/sys/nfsserver/nfs_srvsock.c +++ b/sys/nfsserver/nfs_srvsock.c @@ -149,7 +149,7 @@ int nfsrtton = 0; struct nfsrtt nfsrtt; struct callout_handle nfs_timer_handle; -static int nfs_msg __P((struct proc *,char *,char *)); +static int nfs_msg __P((struct thread *,char *,char *)); static int nfs_rcvlock __P((struct nfsreq *)); static void nfs_rcvunlock __P((struct nfsreq *)); static void nfs_realign __P((struct mbuf **pm, int hsiz)); @@ -162,7 +162,7 @@ static int nfsrv_getstream __P((struct nfssvc_sock *,int)); int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)) = { nfsrv_null, nfsrv_getattr, @@ -207,12 +207,12 @@ nfs_connect(nmp, rep) int pktscale; struct sockaddr *saddr; struct sockaddr_in *sin; - struct proc *p = &proc0; /* only used for socreate and sobind */ + struct thread *td = thread0; /* only used for socreate and sobind */ nmp->nm_so = (struct socket *)0; saddr = nmp->nm_nam; error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype, - nmp->nm_soproto, p); + nmp->nm_soproto, td); if (error) goto bad; so = nmp->nm_so; @@ -233,7 +233,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -243,7 +243,7 @@ nfs_connect(nmp, rep) sin->sin_family = AF_INET; sin->sin_addr.s_addr = INADDR_ANY; sin->sin_port = htons(0); - error = sobind(so, (struct sockaddr *)sin, p); + error = sobind(so, (struct sockaddr *)sin, td); if (error) goto bad; bzero(&sopt, sizeof sopt); @@ -253,7 +253,7 @@ nfs_connect(nmp, rep) sopt.sopt_name = IP_PORTRANGE; sopt.sopt_val = (void *)&ip; sopt.sopt_valsize = sizeof(ip); - sopt.sopt_p = NULL; + sopt.sopt_td = NULL; error = sosetopt(so, &sopt); if (error) goto bad; @@ -269,7 +269,7 @@ nfs_connect(nmp, rep) goto bad; } } else { - error = soconnect(so, nmp->nm_nam, p); + error = soconnect(so, nmp->nm_nam, td); if (error) goto bad; @@ -284,7 +284,8 @@ nfs_connect(nmp, rep) "nfscon", 2 * hz); if ((so->so_state & SS_ISCONNECTING) && so->so_error == 0 && rep && - (error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){ + (error = nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) != 0){ so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -489,7 +490,7 @@ nfs_send(so, nam, top, rep) flags = 0; error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0, - flags, curproc /*XXX*/); + flags, curthread /*XXX*/); /* * ENOBUFS for dgram sockets is transient and non fatal. * No need to log, and no need to break a soft mount. @@ -547,7 +548,7 @@ nfs_receive(rep, aname, mp) u_int32_t len; struct sockaddr **getnam; int error, sotype, rcvflg; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ /* * Set up arguments for soreceive() @@ -614,7 +615,7 @@ tryagain: auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(u_int32_t); - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = MSG_WAITALL; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -682,7 +683,7 @@ tryagain: * on. */ auio.uio_resid = len = 100000000; /* Anything Big */ - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -727,7 +728,7 @@ errout: else getnam = aname; auio.uio_resid = len = 1000000; - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = 0; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -937,11 +938,11 @@ nfsmout: * nb: always frees up mreq mbuf list */ int -nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) +nfs_request(vp, mrest, procnum, td, cred, mrp, mdp, dposp) struct vnode *vp; struct mbuf *mrest; int procnum; - struct proc *procp; + struct thread *td; struct ucred *cred; struct mbuf **mrp; struct mbuf **mdp; @@ -969,7 +970,7 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK); rep->r_nmp = nmp; rep->r_vp = vp; - rep->r_procp = procp; + rep->r_td = td; rep->r_procnum = procnum; i = 0; m = mrest; @@ -1100,7 +1101,7 @@ tryagain: * tprintf a response. */ if (!error && (rep->r_flags & R_TPRINTFMSG)) - nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "is alive again"); mrep = rep->r_mrep; md = rep->r_md; @@ -1394,14 +1395,15 @@ nfs_timer(arg) register struct nfssvc_sock *slp; u_quad_t cur_usec; #endif /* NFS_NOSERVER */ - struct proc *p = &proc0; /* XXX for credentials, will break if sleep */ + struct thread *td = thread0; /* XXX for credentials, will break if sleep */ s = splnet(); for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) { nmp = rep->r_nmp; if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) continue; - if (nfs_sigintr(nmp, rep, rep->r_procp)) { + if (nfs_sigintr(nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) { nfs_softterm(rep); continue; } @@ -1423,7 +1425,7 @@ nfs_timer(arg) */ if ((rep->r_flags & R_TPRINTFMSG) == 0 && rep->r_rexmit > nmp->nm_deadthresh) { - nfs_msg(rep->r_procp, + nfs_msg(rep->r_td, nmp->nm_mountp->mnt_stat.f_mntfromname, "not responding"); rep->r_flags |= R_TPRINTFMSG; @@ -1455,11 +1457,11 @@ nfs_timer(arg) if ((nmp->nm_flag & NFSMNT_NOCONN) == 0) error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, (struct sockaddr *)0, - (struct mbuf *)0, p); + (struct mbuf *)0, td); else error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, nmp->nm_nam, (struct mbuf *)0, - p); + td); if (error) { if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) so->so_error = 0; @@ -1566,17 +1568,17 @@ nfs_sndlock(rep) struct nfsreq *rep; { register int *statep = &rep->r_nmp->nm_state; - struct proc *p; + struct thread *td; int slpflag = 0, slptimeo = 0; if (rep) { - p = rep->r_procp; + td = rep->r_td; if (rep->r_nmp->nm_flag & NFSMNT_INT) slpflag = PCATCH; } else - p = (struct proc *)0; + td = (struct thread *)0; while (*statep & NFSSTA_SNDLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, p)) + if (nfs_sigintr(rep->r_nmp, rep, td ? td->td_proc : NULL)) return (EINTR); *statep |= NFSSTA_WANTSND; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), @@ -1620,7 +1622,8 @@ nfs_rcvlock(rep) else slpflag = 0; while (*statep & NFSSTA_RCVLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp)) + if (nfs_sigintr(rep->r_nmp, rep, + (rep->r_td ? rep->r_td->td_proc : NULL))) return (EINTR); *statep |= NFSSTA_WANTRCV; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk", @@ -1966,12 +1969,12 @@ nfsmout: #endif static int -nfs_msg(p, server, msg) - struct proc *p; +nfs_msg(td, server, msg) + struct thread *td; char *server, *msg; { - tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg); + tprintf(td->td_proc, LOG_INFO, "nfs server %s: %s\n", server, msg); return (0); } @@ -2005,7 +2008,7 @@ nfsrv_rcv(so, arg, waitflag) slp->ns_flag |= SLP_NEEDQ; goto dorecs; } #endif - auio.uio_procp = NULL; + auio.uio_td = NULL; if (so->so_type == SOCK_STREAM) { /* * If there are already records on the queue, defer soreceive() diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index ad8891c..4425129 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -554,11 +554,11 @@ extern struct nfsnodehashhead *nfsnodehashtbl; extern u_long nfsnodehash; struct nfssvc_args; -extern int nfssvc(struct proc *, struct nfssvc_args *, int *); +extern int nfssvc(struct thread *, struct nfssvc_args *, int *); LIST_HEAD(nfsnodehashhead, nfsnode); -int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *)); +int nfs_webnamei __P((struct nameidata *, struct vnode *, struct thread *)); u_quad_t nfs_curusec() @@ -950,7 +950,7 @@ nfsm_disct(mdp, dposp, siz, left, cp2) { register struct mbuf *mp, *mp2; register int siz2, xfer; - register caddr_t p; + register caddr_t ptr; mp = *mdp; while (left == 0) { @@ -973,10 +973,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = p = mtod(mp, caddr_t); - bcopy(*dposp, p, left); /* Copy what was left */ + *cp2 = ptr = mtod(mp, caddr_t); + bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; - p += left; + ptr += left; mp2 = mp->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { @@ -984,10 +984,10 @@ nfsm_disct(mdp, dposp, siz, left, cp2) return (EBADRPC); xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { - bcopy(mtod(mp2, caddr_t), p, xfer); + bcopy(mtod(mp2, caddr_t), ptr, xfer); NFSMADV(mp2, xfer); mp2->m_len -= xfer; - p += xfer; + ptr += xfer; siz2 -= xfer; } if (siz2 > 0) @@ -1464,7 +1464,7 @@ nfs_getattrcache(vp, vaper) * released by the caller. */ int -nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) +nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, td, kerbflag, pubflag) register struct nameidata *ndp; fhandle_t *fhp; int len; @@ -1473,7 +1473,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) struct mbuf **mdp; caddr_t *dposp; struct vnode **retdirp; - struct proc *p; + struct thread *td; int kerbflag, pubflag; { register int i, rem; @@ -1613,7 +1613,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * becuase lookup() will dereference ni_startdir. */ - cnp->cn_proc = p; + cnp->cn_thread = td; VREF(dp); ndp->ni_startdir = dp; @@ -1649,7 +1649,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) * Validate symlink */ if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) - VOP_UNLOCK(ndp->ni_dvp, 0, p); + VOP_UNLOCK(ndp->ni_dvp, 0, td); if (!pubflag) { error = EINVAL; goto badlink2; @@ -1670,7 +1670,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag) auio.uio_offset = 0; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -1924,7 +1924,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) int kerbflag; int pubflag; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ register struct mount *mp; register int i; struct ucred *credanon; @@ -1988,7 +1988,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag) nfsrv_object_create(*vpp); if (!lockflag) - VOP_UNLOCK(*vpp, 0, p); + VOP_UNLOCK(*vpp, 0, td); return (0); } @@ -2196,8 +2196,8 @@ nfsrv_object_create(vp) if (vp == NULL || vp->v_type != VREG) return (1); - return (vfs_object_create(vp, curproc, - curproc ? curproc->p_ucred : NULL)); + return (vfs_object_create(vp, curthread, + curthread ? curthread->td_proc->p_ucred : NULL)); } /* diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index e378cc5..657f299 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -78,7 +78,7 @@ static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure"); /* Global defs. */ extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, struct nfssvc_sock *slp, - struct proc *procp, + struct thread *td, struct mbuf **mreqp)); extern int nfs_numasync; extern time_t nqnfsstarttime; @@ -92,7 +92,7 @@ static int nuidhash_max = NFS_MAXUIDHASH; #ifndef NFS_NOSERVER static void nfsrv_zapsock __P((struct nfssvc_sock *slp)); #endif -static int nfssvc_iod __P((struct proc *)); +static int nfssvc_iod __P((struct thread *)); #define TRUE 1 #define FALSE 0 @@ -110,8 +110,9 @@ static int modify_flag = 0; static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd, int cacherep)); static int nfssvc_addsock __P((struct file *, struct sockaddr *, - struct proc *)); -static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); + struct thread *)); +static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t, + struct thread *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); @@ -140,8 +141,8 @@ struct nfssvc_args { * MPSAFE */ int -nfssvc(p, uap) - struct proc *p; +nfssvc(td, uap) + struct thread *td; register struct nfssvc_args *uap; { #ifndef NFS_NOSERVER @@ -165,13 +166,13 @@ nfssvc(p, uap) error = copyin(uap->argp, &la, sizeof(la)); if (error == 0) - error = nfslockdans(p, &la); + error = nfslockdans(td->td_proc, &la); goto done2; } /* * Must be super user */ - error = suser(p); + error = suser_td(td); if (error) goto done2; while (nfssvc_sockhead_flag & SLP_INIT) { @@ -179,7 +180,7 @@ nfssvc(p, uap) (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0); } if (uap->flag & NFSSVC_BIOD) - error = nfssvc_iod(p); + error = nfssvc_iod(td); #ifdef NFS_NOSERVER else error = ENXIO; @@ -189,7 +190,7 @@ nfssvc(p, uap) if (error) goto done2; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - ncd.ncd_dirp, p); + ncd.ncd_dirp, td); error = namei(&nd); if (error) goto done2; @@ -206,13 +207,13 @@ nfssvc(p, uap) goto done2; } nmp->nm_state |= NFSSTA_MNTD; - error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag, - uap->argp, p); + error = nqnfs_clientd(nmp, td->td_proc->p_ucred, &ncd, uap->flag, + uap->argp, td); } else if (uap->flag & NFSSVC_ADDSOCK) { error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg)); if (error) goto done2; - error = holdsock(p->p_fd, nfsdarg.sock, &fp); + error = holdsock(td->td_proc->p_fd, nfsdarg.sock, &fp); if (error) goto done2; /* @@ -224,12 +225,12 @@ nfssvc(p, uap) error = getsockaddr(&nam, nfsdarg.name, nfsdarg.namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); goto done2; } } - error = nfssvc_addsock(fp, nam, p); - fdrop(fp, p); + error = nfssvc_addsock(fp, nam, td); + fdrop(fp, td); } else { error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd)); if (error) @@ -327,7 +328,7 @@ nfssvc(p, uap) } if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd)) nfsd->nfsd_flag |= NFSD_AUTHFAIL; - error = nfssvc_nfsd(nsd, uap->argp, p); + error = nfssvc_nfsd(nsd, uap->argp, td); } #endif /* NFS_NOSERVER */ if (error == EINTR || error == ERESTART) @@ -342,10 +343,10 @@ done2: * Adds a socket to the list for servicing by nfsds. */ static int -nfssvc_addsock(fp, mynam, p) +nfssvc_addsock(fp, mynam, td) struct file *fp; struct sockaddr *mynam; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -439,10 +440,10 @@ nfssvc_addsock(fp, mynam, p) * until it is killed by a signal. */ static int -nfssvc_nfsd(nsd, argp, p) +nfssvc_nfsd(nsd, argp, td) struct nfsd_srvargs *nsd; caddr_t argp; - struct proc *p; + struct thread *td; { register int siz; register struct nfssvc_sock *slp; @@ -461,7 +462,7 @@ nfssvc_nfsd(nsd, argp, p) nsd->nsd_nfsd = nfsd = (struct nfsd *) malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); - nfsd->nfsd_procp = p; + nfsd->nfsd_td = td; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); nfs_numnfsd++; } else @@ -622,10 +623,10 @@ nfssvc_nfsd(nsd, argp, p) if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, - nfsd->nfsd_procp, &mreq); + nfsd->nfsd_td, &mreq); else error = (*(nfsrv3_procs[nd->nd_procnum]))(nd, - slp, nfsd->nfsd_procp, &mreq); + slp, nfsd->nfsd_td, &mreq); if (mreq == NULL) break; if (error != 0 && error != NFSERR_RETVOID) { @@ -757,7 +758,7 @@ nfsrv_zapsock(slp) so->so_upcall = NULL; so->so_upcallarg = NULL; soshutdown(so, 2); - closef(fp, (struct proc *)0); + closef(fp, (struct thread *)0); if (slp->ns_nam) FREE(slp->ns_nam, M_SONAME); m_freem(slp->ns_raw); @@ -935,8 +936,8 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, ""); * Never returns unless it fails or gets killed. */ static int -nfssvc_iod(p) - struct proc *p; +nfssvc_iod(td) + struct thread *td; { register struct buf *bp; register int i, myiod; @@ -965,7 +966,7 @@ nfssvc_iod(p) && error == 0) { if (nmp) nmp->nm_bufqiods--; - nfs_iodwant[myiod] = p; + nfs_iodwant[myiod] = td->td_proc; nfs_iodmount[myiod] = NULL; error = tsleep((caddr_t)&nfs_iodwant[myiod], PWAIT | PCATCH, "nfsidl", 0); @@ -988,9 +989,9 @@ nfssvc_iod(p) wakeup(&nmp->nm_bufq); } if (bp->b_iocmd == BIO_READ) - (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_rcred, (struct thread *)0); else - (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_wcred, (struct thread *)0); /* * If there are more than one iod on this mount, then defect * so that the iods can be shared out fairly between the mounts @@ -1029,7 +1030,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) nmp->nm_state |= NFSSTA_WANTAUTH; (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK, "nfsauth1", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); if (error) { nmp->nm_state &= ~NFSSTA_WANTAUTH; return (error); @@ -1049,7 +1050,7 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key) while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) { (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK, "nfsauth2", 2 * hz); - error = nfs_sigintr(nmp, rep, rep->r_procp); + error = nfs_sigintr(nmp, rep, rep->r_td->td_proc); } if (nmp->nm_state & NFSSTA_AUTHERR) { nmp->nm_state &= ~NFSSTA_AUTHERR; diff --git a/sys/nfsserver/nfsrvstats.h b/sys/nfsserver/nfsrvstats.h index 44d04b9..d5d0796 100644 --- a/sys/nfsserver/nfsrvstats.h +++ b/sys/nfsserver/nfsrvstats.h @@ -348,7 +348,7 @@ struct nfsreq { int r_timer; /* tick counter on reply */ u_int32_t r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ + struct thread *r_td; /* Proc that did I/O system call */ }; /* @@ -469,7 +469,7 @@ struct nfsd { u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ + struct thread *nfsd_td; /* daemon thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,16 +592,16 @@ void nfs_sndunlock __P((struct nfsreq *)); int nfs_slplock __P((struct nfssvc_sock *, int)); void nfs_slpunlock __P((struct nfssvc_sock *)); int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, +int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct thread *, int)); int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, int *)); int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt, - struct ucred *cred, struct proc *procp)); + struct ucred *cred, struct thread *)); int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); -int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); -int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); +int nfs_asyncio __P((struct buf *, struct ucred *, struct thread *)); +int nfs_doio __P((struct buf *, struct ucred *, struct thread *)); int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); @@ -613,14 +613,14 @@ void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, struct mbuf **, char **)); int netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); -int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, +int nfs_request __P((struct vnode *, struct mbuf *, int, struct thread *, struct ucred *, struct mbuf **, struct mbuf **, caddr_t *)); int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, struct vattr *, int)); int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **, - caddr_t *, struct vnode **, struct proc *, int, int)); + caddr_t *, struct vnode **, struct thread *, int, int)); void nfsm_adj __P((struct mbuf *, int, int)); int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); void nfsrv_initcache __P((void)); @@ -652,21 +652,21 @@ void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); void nfsrvw_sort __P((gid_t *, int)); void nfsrv_setcred __P((struct ucred *, struct ucred *)); -int nfs_writebp __P((struct buf *, int, struct proc *)); +int nfs_writebp __P((struct buf *, int, struct thread *)); int nfsrv_object_create __P((struct vnode *)); void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); + struct thread *, struct mbuf **)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); + struct thread *p)); int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct sockaddr *, int *, int, int)); @@ -674,52 +674,52 @@ int nfsrv_setpublicfs __P((struct mount *, struct netexport *, struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, + struct nfssvc_sock *slp, struct thread *td, struct mbuf **mrq)); int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); + struct thread *td, struct mbuf **mrq)); void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* _KERNEL */ diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index c78aa589..ed9657f 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -49,7 +49,7 @@ #include "opt_msgbuf.h" #include "opt_npx.h" #include "opt_perfmon.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" /* #include "opt_userconfig.h" */ #include <sys/param.h> diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index c78aa589..ed9657f 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -49,7 +49,7 @@ #include "opt_msgbuf.h" #include "opt_npx.h" #include "opt_perfmon.h" -#include "opt_upages.h" +#include "opt_kstack_pages.h" /* #include "opt_userconfig.h" */ #include <sys/param.h> diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index 0a02e02..f98bf0a 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -330,7 +330,7 @@ pccard_event(struct slot *slt, enum card_event event) * Device driver interface. */ static int -crdopen(dev_t dev, int oflags, int devtype, struct proc *p) +crdopen(dev_t dev, int oflags, int devtype, struct thread *td) { struct slot *slt = PCCARD_DEV2SOFTC(dev); @@ -346,7 +346,7 @@ crdopen(dev_t dev, int oflags, int devtype, struct proc *p) * slots may be assigned to drivers already. */ static int -crdclose(dev_t dev, int fflag, int devtype, struct proc *p) +crdclose(dev_t dev, int fflag, int devtype, struct thread *td) { return (0); } @@ -447,7 +447,7 @@ crdwrite(dev_t dev, struct uio *uio, int ioflag) * descriptors, and assignment of drivers. */ static int -crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) +crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { u_int32_t addr; int err; @@ -497,7 +497,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) * At the very least, we only allow root to set the context. */ case PIOCSMEM: - if (suser(p)) + if (suser_td(td)) return (EPERM); if (slt->state != filled) return (ENXIO); @@ -522,7 +522,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) * Set I/O port context. */ case PIOCSIO: - if (suser(p)) + if (suser_td(td)) return (EPERM); if (slt->state != filled) return (ENXIO); @@ -548,7 +548,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) *(unsigned long *)data = pccard_mem; break; } - if (suser(p)) + if (suser_td(td)) return (EPERM); /* * Validate the memory by checking it against the I/O @@ -580,7 +580,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) * Allocate a driver to this slot. */ case PIOCSDRV: - if (suser(p)) + if (suser_td(td)) return (EPERM); err = allocate_driver(slt, (struct dev_desc *)data); if (!err) @@ -617,7 +617,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) * when a change in card status occurs. */ static int -crdpoll(dev_t dev, int events, struct proc *p) +crdpoll(dev_t dev, int events, struct thread *td) { int revents = 0; int s; @@ -638,7 +638,7 @@ crdpoll(dev_t dev, int events, struct proc *p) revents |= POLLRDBAND; if (revents == 0) - selrecord(p, &slt->selp); + selrecord(td, &slt->selp); splx(s); return (revents); diff --git a/sys/pci/agp.c b/sys/pci/agp.c index 333c4c8..138fe45 100644 --- a/sys/pci/agp.c +++ b/sys/pci/agp.c @@ -270,7 +270,7 @@ agp_generic_detach(device_t dev) { struct agp_softc *sc = device_get_softc(dev); bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture); - lockmgr(&sc->as_lock, LK_DRAIN, 0, curproc); + lockmgr(&sc->as_lock, LK_DRAIN, 0, curthread); lockdestroy(&sc->as_lock); destroy_dev(sc->as_devnode); agp_flush_cache(); @@ -389,7 +389,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, vm_page_t m; int error; - lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curthread); if (mem->am_is_bound) { device_printf(dev, "memory already bound\n"); @@ -450,7 +450,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, OFF_TO_IDX(k)); vm_page_unwire(m, 0); } - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return error; } } @@ -471,7 +471,7 @@ agp_generic_bind_memory(device_t dev, struct agp_memory *mem, mem->am_offset = offset; mem->am_is_bound = 1; - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return 0; } @@ -483,7 +483,7 @@ agp_generic_unbind_memory(device_t dev, struct agp_memory *mem) vm_page_t m; int i; - lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curproc); + lockmgr(&sc->as_lock, LK_EXCLUSIVE, 0, curthread); if (!mem->am_is_bound) { device_printf(dev, "memory is not bound\n"); @@ -508,7 +508,7 @@ agp_generic_unbind_memory(device_t dev, struct agp_memory *mem) mem->am_offset = 0; mem->am_is_bound = 0; - lockmgr(&sc->as_lock, LK_RELEASE, 0, curproc); + lockmgr(&sc->as_lock, LK_RELEASE, 0, curthread); return 0; } @@ -645,7 +645,7 @@ agp_unbind_user(device_t dev, agp_unbind *unbind) } static int -agp_open(dev_t kdev, int oflags, int devtype, struct proc *p) +agp_open(dev_t kdev, int oflags, int devtype, struct thread *td) { device_t dev = KDEV2DEV(kdev); struct agp_softc *sc = device_get_softc(dev); @@ -659,7 +659,7 @@ agp_open(dev_t kdev, int oflags, int devtype, struct proc *p) } static int -agp_close(dev_t kdev, int fflag, int devtype, struct proc *p) +agp_close(dev_t kdev, int fflag, int devtype, struct thread *td) { device_t dev = KDEV2DEV(kdev); struct agp_softc *sc = device_get_softc(dev); @@ -676,7 +676,7 @@ agp_close(dev_t kdev, int fflag, int devtype, struct proc *p) } static int -agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct proc *p) +agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct thread *td) { device_t dev = KDEV2DEV(kdev); diff --git a/sys/pci/meteor.c b/sys/pci/meteor.c index 72c6988..4c701c4 100644 --- a/sys/pci/meteor.c +++ b/sys/pci/meteor.c @@ -1171,7 +1171,7 @@ struct saa7116_regs *m; int -meteor_open(dev_t dev, int flags, int fmt, struct proc *p) +meteor_open(dev_t dev, int flags, int fmt, struct thread *td) { meteor_reg_t *mtr; int unit; @@ -1215,7 +1215,7 @@ meteor_open(dev_t dev, int flags, int fmt, struct proc *p) } int -meteor_close(dev_t dev, int flags, int fmt, struct proc *p) +meteor_close(dev_t dev, int flags, int fmt, struct thread *td) { meteor_reg_t *mtr; int unit; @@ -1338,7 +1338,7 @@ meteor_write(dev_t dev, struct uio *uio, int ioflag) } int -meteor_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *pr) +meteor_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { int error; int unit; @@ -1402,7 +1402,7 @@ meteor_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *pr) case METEORSSIGNAL: mtr->signal = *(int *) arg; if (mtr->signal) { - mtr->proc = pr; + mtr->proc = td->td_proc; } else { mtr->proc = (struct proc *)0; } diff --git a/sys/pci/xrpu.c b/sys/pci/xrpu.c index a1a8d6c..1cae322 100644 --- a/sys/pci/xrpu.c +++ b/sys/pci/xrpu.c @@ -115,7 +115,7 @@ xrpu_poll_pps(struct timecounter *tc) } static int -xrpu_open(dev_t dev, int flag, int mode, struct proc *p) +xrpu_open(dev_t dev, int flag, int mode, struct thread *td) { struct softc *sc = devclass_get_softc(xrpu_devclass, dev2unit(dev)); @@ -126,7 +126,7 @@ xrpu_open(dev_t dev, int flag, int mode, struct proc *p) } static int -xrpu_close(dev_t dev, int flag, int mode, struct proc *p) +xrpu_close(dev_t dev, int flag, int mode, struct thread *td) { return (0); } @@ -141,7 +141,7 @@ xrpu_mmap(dev_t dev, vm_offset_t offset, int nprot) } static int -xrpu_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *pr) +xrpu_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *tdr) { struct softc *sc = dev->si_drv1; int i, error; diff --git a/sys/posix4/ksched.c b/sys/posix4/ksched.c index d118b93..6ad2a07 100644 --- a/sys/posix4/ksched.c +++ b/sys/posix4/ksched.c @@ -62,9 +62,9 @@ int ksched_attach(struct ksched **p) return 0; } -int ksched_detach(struct ksched *p) +int ksched_detach(struct ksched *ks) { - p31b_free(p); + p31b_free(ks); return 0; } @@ -94,13 +94,13 @@ int ksched_detach(struct ksched *p) #define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN) static __inline int -getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) +getscheduler(register_t *ret, struct ksched *ksched, struct thread *td) { struct rtprio rtp; int e = 0; mtx_lock_spin(&sched_lock); - pri_to_rtp(&p->p_pri, &rtp); + pri_to_rtp(&td->td_ksegrp->kg_pri, &rtp); mtx_unlock_spin(&sched_lock); switch (rtp.type) { @@ -121,31 +121,31 @@ getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) } int ksched_setparam(register_t *ret, struct ksched *ksched, - struct proc *p, const struct sched_param *param) + struct thread *td, const struct sched_param *param) { register_t policy; int e; - e = getscheduler(&policy, ksched, p); + e = getscheduler(&policy, ksched, td); if (e == 0) { if (policy == SCHED_OTHER) e = EINVAL; else - e = ksched_setscheduler(ret, ksched, p, policy, param); + e = ksched_setscheduler(ret, ksched, td, policy, param); } return e; } int ksched_getparam(register_t *ret, struct ksched *ksched, - struct proc *p, struct sched_param *param) + struct thread *td, struct sched_param *param) { struct rtprio rtp; mtx_lock_spin(&sched_lock); - pri_to_rtp(&p->p_pri, &rtp); + pri_to_rtp(&td->td_ksegrp->kg_pri, &rtp); mtx_unlock_spin(&sched_lock); if (RTP_PRIO_IS_REALTIME(rtp.type)) param->sched_priority = rtpprio_to_p4prio(rtp.prio); @@ -161,7 +161,7 @@ int ksched_getparam(register_t *ret, struct ksched *ksched, * */ int ksched_setscheduler(register_t *ret, struct ksched *ksched, - struct proc *p, int policy, const struct sched_param *param) + struct thread *td, int policy, const struct sched_param *param) { int e = 0; struct rtprio rtp; @@ -179,8 +179,8 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; mtx_lock_spin(&sched_lock); - rtp_to_pri(&rtp, &p->p_pri); - p->p_sflag |= PS_NEEDRESCHED; + rtp_to_pri(&rtp, &td->td_ksegrp->kg_pri); + td->td_last_kse->ke_flags |= KEF_NEEDRESCHED; /* XXXKSE */ mtx_unlock_spin(&sched_lock); } else @@ -194,7 +194,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, rtp.type = RTP_PRIO_NORMAL; rtp.prio = p4prio_to_rtpprio(param->sched_priority); mtx_lock_spin(&sched_lock); - rtp_to_pri(&rtp, &p->p_pri); + rtp_to_pri(&rtp, &td->td_ksegrp->kg_pri); /* XXX Simply revert to whatever we had for last * normal scheduler priorities. @@ -202,7 +202,7 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, * on the scheduling code: You must leave the * scheduling info alone. */ - p->p_sflag |= PS_NEEDRESCHED; + td->td_last_kse->ke_flags |= KEF_NEEDRESCHED; /* XXXKSE */ mtx_unlock_spin(&sched_lock); } break; @@ -211,9 +211,9 @@ int ksched_setscheduler(register_t *ret, struct ksched *ksched, return e; } -int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) +int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct thread *td) { - return getscheduler(ret, ksched, p); + return getscheduler(ret, ksched, td); } /* ksched_yield: Yield the CPU. @@ -221,7 +221,7 @@ int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p) int ksched_yield(register_t *ret, struct ksched *ksched) { mtx_lock_spin(&sched_lock); - curproc->p_sflag |= PS_NEEDRESCHED; + curthread->td_kse->ke_flags |= KEF_NEEDRESCHED; mtx_unlock_spin(&sched_lock); return 0; } @@ -271,7 +271,7 @@ int ksched_get_priority_min(register_t *ret, struct ksched *ksched, int policy) } int ksched_rr_get_interval(register_t *ret, struct ksched *ksched, - struct proc *p, struct timespec *timespec) + struct thread *td, struct timespec *timespec) { *timespec = ksched->rr_interval; diff --git a/sys/posix4/p1003_1b.c b/sys/posix4/p1003_1b.c index 4e43b22..0409d63 100644 --- a/sys/posix4/p1003_1b.c +++ b/sys/posix4/p1003_1b.c @@ -56,10 +56,10 @@ MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B"); * start to use this when they shouldn't. That will be removed if annoying. */ int -syscall_not_present(struct proc *p, const char *s, struct nosys_args *uap) +syscall_not_present(struct thread *td, const char *s, struct nosys_args *uap) { log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n", - p->p_comm, p->p_pid, s); + td->td_proc->p_comm, td->td_proc->p_pid, s); /* a " return nosys(p, uap); " here causes a core dump. */ @@ -105,9 +105,10 @@ static int sched_attach(void) /* * MPSAFE */ -int sched_setparam(struct proc *p, +int sched_setparam(struct thread *td, struct sched_setparam_args *uap) { + struct thread *targettd; struct proc *targetp; int e; struct sched_param sched_param; @@ -118,7 +119,8 @@ int sched_setparam(struct proc *p, mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -126,12 +128,13 @@ int sched_setparam(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansched(p, targetp); + e = p_cansched(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_setparam(&p->p_retval[0], ksched, targetp, + e = ksched_setparam(&td->td_retval[0], ksched, targettd, (const struct sched_param *)&sched_param); } done2: @@ -142,16 +145,18 @@ done2: /* * MPSAFE */ -int sched_getparam(struct proc *p, +int sched_getparam(struct thread *td, struct sched_getparam_args *uap) { int e; struct sched_param sched_param; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -159,28 +164,31 @@ int sched_getparam(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e) goto done2; - e = ksched_getparam(&p->p_retval[0], ksched, targetp, &sched_param); + e = ksched_getparam(&td->td_retval[0], ksched, targettd, &sched_param); if (e == 0) e = copyout(&sched_param, uap->param, sizeof(sched_param)); done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_setscheduler(struct proc *p, +int sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap) { int e; struct sched_param sched_param; + struct thread *targettd; struct proc *targetp; e = copyin(uap->param, &sched_param, sizeof(sched_param)); @@ -189,7 +197,8 @@ int sched_setscheduler(struct proc *p, mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -197,31 +206,34 @@ int sched_setscheduler(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansched(p, targetp); + e = p_cansched(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_setscheduler(&p->p_retval[0], ksched, - targetp, uap->policy, - (const struct sched_param *)&sched_param); + e = ksched_setscheduler(&td->td_retval[0], ksched, targettd, + uap->policy, (const struct sched_param *)&sched_param); } done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_getscheduler(struct proc *p, +int sched_getscheduler(struct thread *td, struct sched_getscheduler_args *uap) { int e; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targetp = td->td_proc; + targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -229,67 +241,75 @@ int sched_getscheduler(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) - e = ksched_getscheduler(&p->p_retval[0], ksched, targetp); + e = ksched_getscheduler(&td->td_retval[0], ksched, targettd); done2: mtx_unlock(&Giant); return (e); } + /* * MPSAFE */ -int sched_yield(struct proc *p, +int sched_yield(struct thread *td, struct sched_yield_args *uap) { int error; mtx_lock(&Giant); - error = ksched_yield(&p->p_retval[0], ksched); + error = ksched_yield(&td->td_retval[0], ksched); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_get_priority_max(struct proc *p, +int sched_get_priority_max(struct thread *td, struct sched_get_priority_max_args *uap) { int error; mtx_lock(&Giant); - error = ksched_get_priority_max(&p->p_retval[0], ksched, uap->policy); + error = ksched_get_priority_max(&td->td_retval[0], ksched, uap->policy); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_get_priority_min(struct proc *p, +int sched_get_priority_min(struct thread *td, struct sched_get_priority_min_args *uap) { int error; + mtx_lock(&Giant); - error = ksched_get_priority_min(&p->p_retval[0], ksched, uap->policy); + error = ksched_get_priority_min(&td->td_retval[0], ksched, uap->policy); mtx_unlock(&Giant); return (error); } + /* * MPSAFE */ -int sched_rr_get_interval(struct proc *p, +int sched_rr_get_interval(struct thread *td, struct sched_rr_get_interval_args *uap) { int e; + struct thread *targettd; struct proc *targetp; mtx_lock(&Giant); if (uap->pid == 0) { - targetp = p; + targettd = td; + targetp = td->td_proc; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); @@ -297,12 +317,13 @@ int sched_rr_get_interval(struct proc *p, e = ESRCH; goto done2; } + targettd = &targetp->p_thread; /* XXXKSE */ } - e = p_cansee(p, targetp); + e = p_cansee(td->td_proc, targetp); PROC_UNLOCK(targetp); if (e == 0) { - e = ksched_rr_get_interval(&p->p_retval[0], ksched, targetp, + e = ksched_rr_get_interval(&td->td_retval[0], ksched, targettd, uap->interval); } done2: diff --git a/sys/posix4/posix4.h b/sys/posix4/posix4.h index 232435a..626d6d8 100644 --- a/sys/posix4/posix4.h +++ b/sys/posix4/posix4.h @@ -47,12 +47,12 @@ */ struct proc; struct nosys_args; -extern int syscall_not_present(struct proc *, const char *, struct nosys_args *); +extern int syscall_not_present(struct thread *, const char *, struct nosys_args *); #define SYSCALL_NOT_PRESENT_GEN(SC) \ -int SC (struct proc *p, struct SC##_args *uap) \ +int SC (struct thread *td, struct SC##_args *uap) \ { \ - return syscall_not_present(p, #SC , (struct nosys_args *)uap); \ + return syscall_not_present(td, #SC , (struct nosys_args *)uap); \ } @@ -95,13 +95,13 @@ int ksched_attach(struct ksched **); int ksched_detach(struct ksched *); int ksched_setparam(register_t *, struct ksched *, - struct proc *, const struct sched_param *); + struct thread *, const struct sched_param *); int ksched_getparam(register_t *, struct ksched *, - struct proc *, struct sched_param *); + struct thread *, struct sched_param *); int ksched_setscheduler(register_t *, struct ksched *, - struct proc *, int, const struct sched_param *); -int ksched_getscheduler(register_t *, struct ksched *, struct proc *); + struct thread *, int, const struct sched_param *); +int ksched_getscheduler(register_t *, struct ksched *, struct thread *); int ksched_yield(register_t *, struct ksched *); @@ -109,7 +109,7 @@ int ksched_get_priority_max(register_t *, struct ksched *, int); int ksched_get_priority_min(register_t *, struct ksched *, int); int ksched_rr_get_interval(register_t *, struct ksched *, - struct proc *, struct timespec *); + struct thread *, struct timespec *); #endif /* _KPOSIX_PRIORITY_SCHEDULING */ diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index e5b6198..ad79c602 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -1441,15 +1441,15 @@ next: * is the current process, load the new MMU context. */ void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { struct pcb *pcb; pmap_t pmap; pmap_t rpm; int psl, i, ksr, seg; - pcb = &p->p_addr->u_pcb; - pmap = p->p_vmspace->vm_map.pmap; + pcb = td->td_pcb; + pmap = td->td_pric->p_vmspace->vm_map.pmap; /* * XXX Normally performed in cpu_fork(). @@ -1460,7 +1460,7 @@ pmap_activate(struct proc *p) (vm_offset_t)pcb->pcb_pm); } - if (p == curproc) { + if (td == curthread) { /* Disable interrupts while switching. */ psl = mfmsr(); mtmsr(psl & ~PSL_EE); diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S index 35a5ed5..af18976 100644 --- a/sys/powerpc/aim/swtch.S +++ b/sys/powerpc/aim/swtch.S @@ -143,7 +143,7 @@ ENTRY(cpu_switch) mr 30,3 mfsprg 3,0 xor 31,31,31 - stw 31,GD_CURPROC(3) /* Zero to not accumulate cpu time */ + stw 31,GD_CURTHREAD(3) /* Zero to not accumulate cpu time */ mfsprg 3,0 lwz 31,GD_CURPCB(3) @@ -159,7 +159,7 @@ ENTRY(cpu_switch) 1: /* record new process */ mfsprg 4,0 - stw 3,GD_CURPROC(4) + stw 3,GD_CURTHREAD(4) cmpl 0,31,30 /* is it the same process? */ beq switch_return @@ -172,7 +172,7 @@ ENTRY(cpu_switch) mr 12,2 /* save r2 */ stwu 1,-SFRAMELEN(1) /* still running on old stack */ stmw 10,8(1) - lwz 3,P_ADDR(30) + lwz 3,TD_ADDR(30) stw 1,PCB_SP(3) /* save SP */ switch_exited: @@ -182,7 +182,7 @@ switch_exited: mtmsr 3 /* indicate new pcb */ - lwz 4,P_ADDR(31) + lwz 4,TD_ADDR(31) mfsprg 5,0 stw 4,GD_CURPCB(5) @@ -227,7 +227,7 @@ switch_return: bl lcsplx #endif - mr 3,30 /* get curproc for special fork + mr 3,30 /* get curthread for special fork returns */ lwz 31,12(1) diff --git a/sys/powerpc/include/globaldata.h b/sys/powerpc/include/globaldata.h index b51592a..c95a725 100644 --- a/sys/powerpc/include/globaldata.h +++ b/sys/powerpc/include/globaldata.h @@ -44,15 +44,16 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - int gd_inside_intr; + struct thread *gd_curthread; /* current thread */ + struct proc *gd_idleproc; /* idle process */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct proc *gd_fpcurproc; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ + int gd_inside_intr; u_int32_t gd_next_asn; /* next ASN to allocate */ u_int32_t gd_current_asngen; /* ASN rollover check */ u_int32_t gd_intr_nesting_level; /* interrupt recursion */ diff --git a/sys/powerpc/include/globals.h b/sys/powerpc/include/globals.h index 26c21e8..6aa1a7a 100644 --- a/sys/powerpc/include/globals.h +++ b/sys/powerpc/include/globals.h @@ -45,12 +45,16 @@ * other hand, kernel modules should always use these macros to maintain * portability between UP and SMP kernels. */ -#define CURPROC PCPU_GET(curproc) -#define CURTHD PCPU_GET(curproc) /* temporary */ -#define curproc PCPU_GET(curproc) +#define curthread PCPU_GET(curthread) +#define CURPROC (curthread->td_proc) +#define curproc (curthread->td_proc) +#define curksegrp (curthread->td_ksegrp) +#define curkse (curthread->td_kse) + #define idleproc PCPU_GET(idleproc) #define curpcb PCPU_GET(curpcb) #define fpcurproc PCPU_GET(fpcurproc) +#define fpcurthread PCPU_GET(fpcurthread) #define switchtime PCPU_GET(switchtime) #define switchticks PCPU_GET(switchticks) #define witness_spin_check PCPU_GET(witness_spin_check) diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h index b51592a..c95a725 100644 --- a/sys/powerpc/include/pcpu.h +++ b/sys/powerpc/include/pcpu.h @@ -44,15 +44,16 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ - struct proc *gd_fpcurproc; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - int gd_inside_intr; + struct thread *gd_curthread; /* current thread */ + struct proc *gd_idleproc; /* idle process */ + struct thread *gd_fpcurthread; /* fp state owner */ + struct proc *gd_fpcurproc; /* fp state owner */ + struct pcb *gd_curpcb; /* current pcb */ + struct timeval gd_switchtime; + int gd_switchticks; + u_int gd_cpuid; /* this cpu number */ + u_int gd_other_cpus; /* all other cpus */ + int gd_inside_intr; u_int32_t gd_next_asn; /* next ASN to allocate */ u_int32_t gd_current_asngen; /* ASN rollover check */ u_int32_t gd_intr_nesting_level; /* interrupt recursion */ diff --git a/sys/powerpc/include/proc.h b/sys/powerpc/include/proc.h index 21b9b32..33eb778 100644 --- a/sys/powerpc/include/proc.h +++ b/sys/powerpc/include/proc.h @@ -37,5 +37,8 @@ /* * Machine-dependent part of the proc structure */ +struct mdthread { +}; + struct mdproc { }; diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c index c140bcb..07c972b 100644 --- a/sys/powerpc/powerpc/genassym.c +++ b/sys/powerpc/powerpc/genassym.c @@ -64,7 +64,7 @@ #include <machine/pcb.h> #include <machine/pmap.h> -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); @@ -95,6 +95,6 @@ ASSYM(SFRAMELEN, roundup(sizeof(struct switchframe), 16)); ASSYM(PCB_PMR, offsetof(struct pcb, pcb_pmreal)); ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); ASSYM(PCB_SPL, offsetof(struct pcb, pcb_spl)); -ASSYM(PCB_FAULT, offsetof(struct pcb, pcb_onfault)); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_ADDR, offsetof(struct thread, td_addr)); diff --git a/sys/powerpc/powerpc/mmu_oea.c b/sys/powerpc/powerpc/mmu_oea.c index e5b6198..ad79c602 100644 --- a/sys/powerpc/powerpc/mmu_oea.c +++ b/sys/powerpc/powerpc/mmu_oea.c @@ -1441,15 +1441,15 @@ next: * is the current process, load the new MMU context. */ void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { struct pcb *pcb; pmap_t pmap; pmap_t rpm; int psl, i, ksr, seg; - pcb = &p->p_addr->u_pcb; - pmap = p->p_vmspace->vm_map.pmap; + pcb = td->td_pcb; + pmap = td->td_pric->p_vmspace->vm_map.pmap; /* * XXX Normally performed in cpu_fork(). @@ -1460,7 +1460,7 @@ pmap_activate(struct proc *p) (vm_offset_t)pcb->pcb_pm); } - if (p == curproc) { + if (td == curthread) { /* Disable interrupts while switching. */ psl = mfmsr(); mtmsr(psl & ~PSL_EE); diff --git a/sys/powerpc/powerpc/pmap.c b/sys/powerpc/powerpc/pmap.c index e5b6198..ad79c602 100644 --- a/sys/powerpc/powerpc/pmap.c +++ b/sys/powerpc/powerpc/pmap.c @@ -1441,15 +1441,15 @@ next: * is the current process, load the new MMU context. */ void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { struct pcb *pcb; pmap_t pmap; pmap_t rpm; int psl, i, ksr, seg; - pcb = &p->p_addr->u_pcb; - pmap = p->p_vmspace->vm_map.pmap; + pcb = td->td_pcb; + pmap = td->td_pric->p_vmspace->vm_map.pmap; /* * XXX Normally performed in cpu_fork(). @@ -1460,7 +1460,7 @@ pmap_activate(struct proc *p) (vm_offset_t)pcb->pcb_pm); } - if (p == curproc) { + if (td == curthread) { /* Disable interrupts while switching. */ psl = mfmsr(); mtmsr(psl & ~PSL_EE); diff --git a/sys/powerpc/powerpc/swtch.S b/sys/powerpc/powerpc/swtch.S index 35a5ed5..af18976 100644 --- a/sys/powerpc/powerpc/swtch.S +++ b/sys/powerpc/powerpc/swtch.S @@ -143,7 +143,7 @@ ENTRY(cpu_switch) mr 30,3 mfsprg 3,0 xor 31,31,31 - stw 31,GD_CURPROC(3) /* Zero to not accumulate cpu time */ + stw 31,GD_CURTHREAD(3) /* Zero to not accumulate cpu time */ mfsprg 3,0 lwz 31,GD_CURPCB(3) @@ -159,7 +159,7 @@ ENTRY(cpu_switch) 1: /* record new process */ mfsprg 4,0 - stw 3,GD_CURPROC(4) + stw 3,GD_CURTHREAD(4) cmpl 0,31,30 /* is it the same process? */ beq switch_return @@ -172,7 +172,7 @@ ENTRY(cpu_switch) mr 12,2 /* save r2 */ stwu 1,-SFRAMELEN(1) /* still running on old stack */ stmw 10,8(1) - lwz 3,P_ADDR(30) + lwz 3,TD_ADDR(30) stw 1,PCB_SP(3) /* save SP */ switch_exited: @@ -182,7 +182,7 @@ switch_exited: mtmsr 3 /* indicate new pcb */ - lwz 4,P_ADDR(31) + lwz 4,TD_ADDR(31) mfsprg 5,0 stw 4,GD_CURPCB(5) @@ -227,7 +227,7 @@ switch_return: bl lcsplx #endif - mr 3,30 /* get curproc for special fork + mr 3,30 /* get curthread for special fork returns */ lwz 31,12(1) diff --git a/sys/powerpc/powerpc/swtch.s b/sys/powerpc/powerpc/swtch.s index 35a5ed5..af18976 100644 --- a/sys/powerpc/powerpc/swtch.s +++ b/sys/powerpc/powerpc/swtch.s @@ -143,7 +143,7 @@ ENTRY(cpu_switch) mr 30,3 mfsprg 3,0 xor 31,31,31 - stw 31,GD_CURPROC(3) /* Zero to not accumulate cpu time */ + stw 31,GD_CURTHREAD(3) /* Zero to not accumulate cpu time */ mfsprg 3,0 lwz 31,GD_CURPCB(3) @@ -159,7 +159,7 @@ ENTRY(cpu_switch) 1: /* record new process */ mfsprg 4,0 - stw 3,GD_CURPROC(4) + stw 3,GD_CURTHREAD(4) cmpl 0,31,30 /* is it the same process? */ beq switch_return @@ -172,7 +172,7 @@ ENTRY(cpu_switch) mr 12,2 /* save r2 */ stwu 1,-SFRAMELEN(1) /* still running on old stack */ stmw 10,8(1) - lwz 3,P_ADDR(30) + lwz 3,TD_ADDR(30) stw 1,PCB_SP(3) /* save SP */ switch_exited: @@ -182,7 +182,7 @@ switch_exited: mtmsr 3 /* indicate new pcb */ - lwz 4,P_ADDR(31) + lwz 4,TD_ADDR(31) mfsprg 5,0 stw 4,GD_CURPCB(5) @@ -227,7 +227,7 @@ switch_return: bl lcsplx #endif - mr 3,30 /* get curproc for special fork + mr 3,30 /* get curthread for special fork returns */ lwz 31,12(1) diff --git a/sys/sparc64/include/cpu.h b/sys/sparc64/include/cpu.h index 3a84287..91e04fa 100644 --- a/sys/sparc64/include/cpu.h +++ b/sys/sparc64/include/cpu.h @@ -50,8 +50,8 @@ #define TRAPF_PC(tfp) ((tfp)->tf_tpc) #define TRAPF_USERMODE(tfp) (((tfp)->tf_tstate & TSTATE_PRIV) == 0) -#define cpu_getstack(p) ((p)->p_frame->tf_sp) -#define cpu_setstack(p, sp) ((p)->p_frame->tf_sp = (sp)) +#define cpu_getstack(td) ((td)->td_frame->tf_sp) +#define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) /* * CTL_MACHDEP definitions. diff --git a/sys/sparc64/include/fp.h b/sys/sparc64/include/fp.h index 6305c2b..699dba8 100644 --- a/sys/sparc64/include/fp.h +++ b/sys/sparc64/include/fp.h @@ -75,8 +75,8 @@ struct fpstate { u_long fp_fprs; }; -void fp_init_proc(struct pcb *); -int fp_enable_proc(struct proc *); +void fp_init_thread(struct pcb *); +int fp_enable_thread(struct thread *); /* * Note: The pointers passed to the next two functions must be aligned on * 64 byte boundaries. diff --git a/sys/sparc64/include/frame.h b/sys/sparc64/include/frame.h index 9d1c0c6..5151ef2 100644 --- a/sys/sparc64/include/frame.h +++ b/sys/sparc64/include/frame.h @@ -80,10 +80,10 @@ struct rwindow { u_long rw_in[8]; }; -struct proc; +struct thread; -int rwindow_save(struct proc *p); -int rwindow_load(struct proc *p, struct trapframe *tf, int n); +int rwindow_save(struct thread *td); +int rwindow_load(struct thread *td, struct trapframe *tf, int n); int kdb_trap(struct trapframe *tf); diff --git a/sys/sparc64/include/globaldata.h b/sys/sparc64/include/globaldata.h index 69a7ab2..325bd08 100644 --- a/sys/sparc64/include/globaldata.h +++ b/sys/sparc64/include/globaldata.h @@ -46,8 +46,8 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ struct pcb *gd_curpcb; /* current pcb */ struct timeval gd_switchtime; int gd_switchticks; diff --git a/sys/sparc64/include/globals.h b/sys/sparc64/include/globals.h index 01d48a8..951d1e2 100644 --- a/sys/sparc64/include/globals.h +++ b/sys/sparc64/include/globals.h @@ -40,9 +40,11 @@ register struct globaldata *globalp __asm__("%g7"); #define PCPU_PTR(member) (&GLOBALP->gd_ ## member) #define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value)) -#define CURPROC PCPU_GET(curproc) -#define CURTHD PCPU_GET(curproc) /* temporary */ -#define curproc PCPU_GET(curproc) +#define curthread PCPU_GET(curthread) +#define CURPROC (curthread->td_proc) +#define curproc (curthread->td_proc) +#define curksegrp (curthread->td_ksegrp) +#define curkse (curthread->td_kse) #endif /* _KERNEL */ diff --git a/sys/sparc64/include/md_var.h b/sys/sparc64/include/md_var.h index d411cf4..7a0733b 100644 --- a/sys/sparc64/include/md_var.h +++ b/sys/sparc64/include/md_var.h @@ -39,14 +39,14 @@ extern int Maxmem; struct dbreg; struct fpreg; -struct proc; +struct thread; struct reg; void cpu_halt(void); void cpu_reset(void); -int fill_dbregs(struct proc *p, struct dbreg *dbregs); -int fill_fpregs(struct proc *p, struct fpreg *fpregs); -int fill_regs(struct proc *p, struct reg *regs); +int fill_dbregs(struct thread *td, struct dbreg *dbregs); +int fill_fpregs(struct thread *td, struct fpreg *fpregs); +int fill_regs(struct thread *td, struct reg *regs); void swi_vm(void *v); #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/sparc64/include/param.h b/sys/sparc64/include/param.h index e669f45..2f8d6a6 100644 --- a/sys/sparc64/include/param.h +++ b/sys/sparc64/include/param.h @@ -116,7 +116,11 @@ #define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) #define IOPAGES 2 /* pages of i/o permission bitmap */ -#define UPAGES 4 /* pages of u-area */ + +#define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */ +#define UAREA_PAGES 1 /* pages of user area */ + +/* #define KSTACK_GUARD */ /* compile in kstack guard page */ /* * Constants related to network buffer management. diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h index 69a7ab2..325bd08 100644 --- a/sys/sparc64/include/pcpu.h +++ b/sys/sparc64/include/pcpu.h @@ -46,8 +46,8 @@ * point at the globaldata structure. */ struct globaldata { - struct proc *gd_curproc; /* current process */ - struct proc *gd_idleproc; /* idle process */ + struct thread *gd_curthread; /* current thread */ + struct thread *gd_idlethread; /* idle thread */ struct pcb *gd_curpcb; /* current pcb */ struct timeval gd_switchtime; int gd_switchticks; diff --git a/sys/sparc64/include/proc.h b/sys/sparc64/include/proc.h index c6df75d..84ada25 100644 --- a/sys/sparc64/include/proc.h +++ b/sys/sparc64/include/proc.h @@ -41,6 +41,9 @@ #include <machine/globals.h> #include <machine/tte.h> +struct mdthread { +}; + struct mdproc { }; diff --git a/sys/sparc64/include/reg.h b/sys/sparc64/include/reg.h index b0b7a61..bd3414c 100644 --- a/sys/sparc64/include/reg.h +++ b/sys/sparc64/include/reg.h @@ -39,10 +39,10 @@ struct dbreg { }; #ifdef _KERNEL -int set_fpregs(struct proc *p, struct fpreg *fpregs); -int set_regs(struct proc *p, struct reg *regs); -void setregs(struct proc *p, u_long e, u_long s, u_long ps); -int set_dbregs(struct proc *p, struct dbreg *dbregs); +int set_fpregs(struct thread *td, struct fpreg *fpregs); +int set_regs(struct thread *td, struct reg *regs); +void setregs(struct thread *td, u_long e, u_long s, u_long ps); +int set_dbregs(struct thread *td, struct dbreg *dbregs); #endif #endif /* !_MACHINE_REG_H_ */ diff --git a/sys/sparc64/sparc64/exception.S b/sys/sparc64/sparc64/exception.S index 8a10c17..b9090b3 100644 --- a/sys/sparc64/sparc64/exception.S +++ b/sys/sparc64/sparc64/exception.S @@ -313,8 +313,9 @@ ENTRY(tl0_kstack_fixup) wrpr %o1, 0, %wstate wrpr %o0, 0, %otherwin wrpr %g0, 0, %canrestore - ldx [PCPU(CURPCB)], %o0 - set UPAGES * PAGE_SIZE - SPOFF - CCFSZ, %o1 + ldx [PCPU(CURTHREAD)], %o0 + ldx [%o0 + TD_KSTACK], %o0 + set KSTACK_PAGES * PAGE_SIZE - SPOFF - CCFSZ, %o1 retl add %o0, %o1, %sp END(tl0_kstack_fixup) @@ -1021,9 +1022,9 @@ END(tl1_align_trap) ENTRY(intr_enqueue) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "intr_enqueue: p=%p (%s) tl=%#lx pc=%#lx sp=%#lx" + CATR(KTR_CT1, "intr_enqueue: td=%p (%s) tl=%#lx pc=%#lx sp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g2 stx %g2, [%g1 + KTR_PARM2] @@ -1818,9 +1819,9 @@ ENTRY(tl0_trap) stx %g7, [%sp + SPOFF + CCFSZ + TF_G7] #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_trap: p=%p type=%#x arg=%#lx pil=%#lx ws=%#lx" + CATR(KTR_CT1, "tl0_trap: td=%p type=%#x arg=%#lx pil=%#lx ws=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] stx %o0, [%g1 + KTR_PARM2] stx %o1, [%g1 + KTR_PARM3] @@ -1848,9 +1849,9 @@ END(tl0_trap) /* Return to tl0 (user process). */ ENTRY(tl0_ret) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_ret: p=%p (%s) pil=%#lx sflag=%#x" + CATR(KTR_CT1, "tl0_ret: td=%p (%s) pil=%#lx sflag=%#x" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g3 stx %g3, [%g1 + KTR_PARM2] @@ -1862,9 +1863,10 @@ ENTRY(tl0_ret) #endif wrpr %g0, PIL_TICK, %pil - ldx [PCPU(CURPROC)], %o0 - lduw [%o0 + P_SFLAG], %o1 - and %o1, PS_ASTPENDING | PS_NEEDRESCHED, %o1 + ldx [PCPU(CURTHREAD)], %o0 + ldx [%o0 + TD_KSE], %o0 + lduw [%o0 + KE_FLAGS], %o1 + and %o1, KEF_ASTPENDING | KEF_NEEDRESCHED, %o1 brz,pt %o1, 1f nop call ast @@ -1927,9 +1929,9 @@ ENTRY(tl0_ret) tl0_ret_fill: #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_ret: return p=%#lx pil=%#lx ts=%#lx pc=%#lx sp=%#lx" + CATR(KTR_CT1, "tl0_ret: return td=%#lx pil=%#lx ts=%#lx pc=%#lx sp=%#lx" , %g2, %g3, %g4, 7, 8, 9) - ldx [PCPU(CURPROC)], %g3 + ldx [PCPU(CURTHREAD)], %g3 stx %g3, [%g2 + KTR_PARM1] rdpr %tstate, %g3 stx %g3, [%g2 + KTR_PARM2] @@ -1993,9 +1995,9 @@ ENTRY(tl1_trap) and %l4, %l5, %l4 brz %l4, 9f nop - CATR(KTR_CT1, "tl1_trap: p=%p pil=%#lx type=%#lx arg=%#lx pc=%#lx" + CATR(KTR_CT1, "tl1_trap: td=%p pil=%#lx type=%#lx arg=%#lx pc=%#lx" , %l3, %l4, %l5, 7, 8, 9) - ldx [PCPU(CURPROC)], %l4 + ldx [PCPU(CURTHREAD)], %l4 stx %l4, [%l3 + KTR_PARM1] #if 0 add %l4, P_COMM, %l4 @@ -2062,9 +2064,9 @@ ENTRY(tl1_trap) and %l4, %l5, %l4 brz %l4, 9f nop - CATR(KTR_CT1, "tl1_trap: return p=%p pil=%#lx sp=%#lx pc=%#lx" + CATR(KTR_CT1, "tl1_trap: return td=%p pil=%#lx sp=%#lx pc=%#lx" , %l3, %l4, %l5, 7, 8, 9) - ldx [PCPU(CURPROC)], %l4 + ldx [PCPU(CURTHREAD)], %l4 stx %l4, [%l3 + KTR_PARM1] stx %l0, [%l3 + KTR_PARM2] stx %sp, [%l3 + KTR_PARM3] @@ -2083,9 +2085,9 @@ END(tl1_trap) */ ENTRY(fork_trampoline) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "fork_trampoline: p=%p (%s) cwp=%#lx" + CATR(KTR_CT1, "fork_trampoline: td=%p (%s) cwp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g2 stx %g2, [%g1 + KTR_PARM2] diff --git a/sys/sparc64/sparc64/exception.s b/sys/sparc64/sparc64/exception.s index 8a10c17..b9090b3 100644 --- a/sys/sparc64/sparc64/exception.s +++ b/sys/sparc64/sparc64/exception.s @@ -313,8 +313,9 @@ ENTRY(tl0_kstack_fixup) wrpr %o1, 0, %wstate wrpr %o0, 0, %otherwin wrpr %g0, 0, %canrestore - ldx [PCPU(CURPCB)], %o0 - set UPAGES * PAGE_SIZE - SPOFF - CCFSZ, %o1 + ldx [PCPU(CURTHREAD)], %o0 + ldx [%o0 + TD_KSTACK], %o0 + set KSTACK_PAGES * PAGE_SIZE - SPOFF - CCFSZ, %o1 retl add %o0, %o1, %sp END(tl0_kstack_fixup) @@ -1021,9 +1022,9 @@ END(tl1_align_trap) ENTRY(intr_enqueue) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "intr_enqueue: p=%p (%s) tl=%#lx pc=%#lx sp=%#lx" + CATR(KTR_CT1, "intr_enqueue: td=%p (%s) tl=%#lx pc=%#lx sp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g2 stx %g2, [%g1 + KTR_PARM2] @@ -1818,9 +1819,9 @@ ENTRY(tl0_trap) stx %g7, [%sp + SPOFF + CCFSZ + TF_G7] #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_trap: p=%p type=%#x arg=%#lx pil=%#lx ws=%#lx" + CATR(KTR_CT1, "tl0_trap: td=%p type=%#x arg=%#lx pil=%#lx ws=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] stx %o0, [%g1 + KTR_PARM2] stx %o1, [%g1 + KTR_PARM3] @@ -1848,9 +1849,9 @@ END(tl0_trap) /* Return to tl0 (user process). */ ENTRY(tl0_ret) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_ret: p=%p (%s) pil=%#lx sflag=%#x" + CATR(KTR_CT1, "tl0_ret: td=%p (%s) pil=%#lx sflag=%#x" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g3 stx %g3, [%g1 + KTR_PARM2] @@ -1862,9 +1863,10 @@ ENTRY(tl0_ret) #endif wrpr %g0, PIL_TICK, %pil - ldx [PCPU(CURPROC)], %o0 - lduw [%o0 + P_SFLAG], %o1 - and %o1, PS_ASTPENDING | PS_NEEDRESCHED, %o1 + ldx [PCPU(CURTHREAD)], %o0 + ldx [%o0 + TD_KSE], %o0 + lduw [%o0 + KE_FLAGS], %o1 + and %o1, KEF_ASTPENDING | KEF_NEEDRESCHED, %o1 brz,pt %o1, 1f nop call ast @@ -1927,9 +1929,9 @@ ENTRY(tl0_ret) tl0_ret_fill: #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "tl0_ret: return p=%#lx pil=%#lx ts=%#lx pc=%#lx sp=%#lx" + CATR(KTR_CT1, "tl0_ret: return td=%#lx pil=%#lx ts=%#lx pc=%#lx sp=%#lx" , %g2, %g3, %g4, 7, 8, 9) - ldx [PCPU(CURPROC)], %g3 + ldx [PCPU(CURTHREAD)], %g3 stx %g3, [%g2 + KTR_PARM1] rdpr %tstate, %g3 stx %g3, [%g2 + KTR_PARM2] @@ -1993,9 +1995,9 @@ ENTRY(tl1_trap) and %l4, %l5, %l4 brz %l4, 9f nop - CATR(KTR_CT1, "tl1_trap: p=%p pil=%#lx type=%#lx arg=%#lx pc=%#lx" + CATR(KTR_CT1, "tl1_trap: td=%p pil=%#lx type=%#lx arg=%#lx pc=%#lx" , %l3, %l4, %l5, 7, 8, 9) - ldx [PCPU(CURPROC)], %l4 + ldx [PCPU(CURTHREAD)], %l4 stx %l4, [%l3 + KTR_PARM1] #if 0 add %l4, P_COMM, %l4 @@ -2062,9 +2064,9 @@ ENTRY(tl1_trap) and %l4, %l5, %l4 brz %l4, 9f nop - CATR(KTR_CT1, "tl1_trap: return p=%p pil=%#lx sp=%#lx pc=%#lx" + CATR(KTR_CT1, "tl1_trap: return td=%p pil=%#lx sp=%#lx pc=%#lx" , %l3, %l4, %l5, 7, 8, 9) - ldx [PCPU(CURPROC)], %l4 + ldx [PCPU(CURTHREAD)], %l4 stx %l4, [%l3 + KTR_PARM1] stx %l0, [%l3 + KTR_PARM2] stx %sp, [%l3 + KTR_PARM3] @@ -2083,9 +2085,9 @@ END(tl1_trap) */ ENTRY(fork_trampoline) #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "fork_trampoline: p=%p (%s) cwp=%#lx" + CATR(KTR_CT1, "fork_trampoline: td=%p (%s) cwp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g2 stx %g2, [%g1 + KTR_PARM2] diff --git a/sys/sparc64/sparc64/fp.c b/sys/sparc64/sparc64/fp.c index 756869a..e6762f2 100644 --- a/sys/sparc64/sparc64/fp.c +++ b/sys/sparc64/sparc64/fp.c @@ -36,7 +36,7 @@ #include <machine/tstate.h> void -fp_init_proc(struct pcb *pcb) +fp_init_thread(struct pcb *pcb) { bzero(&pcb->pcb_fpstate.fp_fb, sizeof(pcb->pcb_fpstate.fp_fb)); @@ -45,12 +45,12 @@ fp_init_proc(struct pcb *pcb) } int -fp_enable_proc(struct proc *p) +fp_enable_thread(struct thread *td) { struct pcb *pcb; - pcb = &p->p_addr->u_pcb; - if ((p->p_frame->tf_tstate & TSTATE_PEF) != 0 && + pcb = td->td_pcb; + if ((td->td_frame->tf_tstate & TSTATE_PEF) != 0 && (pcb->pcb_fpstate.fp_fprs & FPRS_FEF) == 0) { /* * Enable FEF for now. The SCD mandates that this should be @@ -61,10 +61,10 @@ fp_enable_proc(struct proc *p) return (1); } - if ((p->p_frame->tf_tstate & TSTATE_PEF) != 0) + if ((td->td_frame->tf_tstate & TSTATE_PEF) != 0) return (0); mtx_lock_spin(&sched_lock); - p->p_frame->tf_tstate |= TSTATE_PEF; + td->td_frame->tf_tstate |= TSTATE_PEF; /* Actually load the FP state into the registers. */ restorefpctx(&pcb->pcb_fpstate); mtx_unlock_spin(&sched_lock); diff --git a/sys/sparc64/sparc64/genassym.c b/sys/sparc64/sparc64/genassym.c index fa85ebc..6039621 100644 --- a/sys/sparc64/sparc64/genassym.c +++ b/sys/sparc64/sparc64/genassym.c @@ -68,7 +68,8 @@ ASSYM(ASI_BLK_S, ASI_BLK_S); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); -ASSYM(UPAGES, UPAGES); +ASSYM(KSTACK_PAGES, KSTACK_PAGES); +ASSYM(UAREA_PAGES, UAREA_PAGES); ASSYM(PAGE_SIZE, PAGE_SIZE); ASSYM(PIL_TICK, PIL_TICK); @@ -122,7 +123,7 @@ ASSYM(TT_VA_MASK, TT_VA_MASK); ASSYM(TT_VA_SHIFT, TT_VA_SHIFT); ASSYM(TT_CTX_SHIFT, TT_CTX_SHIFT); -ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc)); +ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid)); @@ -149,15 +150,21 @@ ASSYM(JB_FP, offsetof(struct _jmp_buf, _jb[_JB_FP])); ASSYM(JB_PC, offsetof(struct _jmp_buf, _jb[_JB_PC])); ASSYM(JB_SP, offsetof(struct _jmp_buf, _jb[_JB_SP])); -ASSYM(PS_ASTPENDING, PS_ASTPENDING); -ASSYM(PS_NEEDRESCHED, PS_NEEDRESCHED); +ASSYM(KEF_ASTPENDING, KEF_ASTPENDING); +ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED); -ASSYM(P_ADDR, offsetof(struct proc, p_addr)); ASSYM(P_COMM, offsetof(struct proc, p_comm)); -ASSYM(P_FRAME, offsetof(struct proc, p_frame)); ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); +ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags)); + +ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); +ASSYM(TD_KSE, offsetof(struct thread, td_kse)); +ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); + ASSYM(PCB_FPSTATE, offsetof(struct pcb, pcb_fpstate)); ASSYM(PCB_FP, offsetof(struct pcb, pcb_fp)); ASSYM(PCB_PC, offsetof(struct pcb, pcb_pc)); @@ -170,8 +177,6 @@ ASSYM(PCB_RW, offsetof(struct pcb, pcb_rw)); ASSYM(PCB_CWP_EMPTY, PCB_CWP_EMPTY); -ASSYM(U_PCB, offsetof(struct user, u_pcb)); - ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_CONTEXT, offsetof(struct pmap, pm_context)); ASSYM(PM_STTE, offsetof(struct pmap, pm_stte)); diff --git a/sys/sparc64/sparc64/locore.S b/sys/sparc64/sparc64/locore.S index 31ce6e0..34a9d6f 100644 --- a/sys/sparc64/sparc64/locore.S +++ b/sys/sparc64/sparc64/locore.S @@ -45,7 +45,7 @@ ENTRY(_start) wrpr %g0, 0, %cleanwin wrpr %g0, 0, %pil - setx user0 + UPAGES * PAGE_SIZE - SPOFF, %l0, %o5 + setx kstack0 + KSTACK_PAGES * PAGE_SIZE - SPOFF, %l0, %o5 save %o5, -CCFSZ, %sp mov %g1, %o0 diff --git a/sys/sparc64/sparc64/locore.s b/sys/sparc64/sparc64/locore.s index 31ce6e0..34a9d6f 100644 --- a/sys/sparc64/sparc64/locore.s +++ b/sys/sparc64/sparc64/locore.s @@ -45,7 +45,7 @@ ENTRY(_start) wrpr %g0, 0, %cleanwin wrpr %g0, 0, %pil - setx user0 + UPAGES * PAGE_SIZE - SPOFF, %l0, %o5 + setx kstack0 + KSTACK_PAGES * PAGE_SIZE - SPOFF, %l0, %o5 save %o5, -CCFSZ, %sp mov %g1, %o0 diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index b26a9a7..f17d935 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -77,6 +77,7 @@ #include <machine/bootinfo.h> #include <machine/clock.h> #include <machine/cpu.h> +#include <machine/fp.h> #include <machine/intr_machdep.h> #include <machine/md_var.h> #include <machine/pmap.h> @@ -109,8 +110,10 @@ struct globaldata __globaldata; * does not have an fp state (which it doesn't normally). * This constraint is only here for debugging. */ -char user0[UPAGES * PAGE_SIZE] __attribute__ ((aligned (64))); -struct user *proc0paddr; +char uarea0[UAREA_PAGES * PAGE_SIZE] __attribute__ ((aligned (64))); +char kstack0[KSTACK_PAGES * PAGE_SIZE] __attribute__ ((aligned (64))); +struct user *proc0uarea; +vm_offset_t proc0kstack; struct kva_md_info kmi; @@ -232,17 +235,21 @@ sparc64_init(struct bootinfo *bi, ofw_vec_t *vec) wrpr(tl, 0, 1); wrpr(tba, tl0_base, 0); + proc_linkup(&proc0); /* * Initialize proc0 stuff (p_contested needs to be done early). */ - LIST_INIT(&proc0.p_contested); - proc0paddr = (struct user *)user0; - proc0.p_addr = (struct user *)user0; - proc0.p_stats = &proc0.p_addr->u_stats; - tf = (struct trapframe *)(user0 + UPAGES * PAGE_SIZE - - sizeof(struct frame) - sizeof(*tf)); - proc0.p_frame = tf; - tf->tf_tstate = 0; + proc0uarea = (struct user *)uarea0; + proc0kstack = (vm_offset_t)kstack0; + proc0.p_uarea = proc0uarea; + proc0.p_stats = &proc0.p_uarea->u_stats; + thread0 = &proc0.p_thread; + thread0->td_kstack = proc0kstack; + tf = (struct trapframe *)(thread0->td_kstack + KSTACK_PAGES * + PAGE_SIZE) - 1; + tf->tf_tstate = TSTATE_IE; + thread0->td_frame = tf; + LIST_INIT(&thread0->td_contested); /* * Initialize the per-cpu pointer so we can set curproc. @@ -275,8 +282,8 @@ sparc64_init(struct bootinfo *bi, ofw_vec_t *vec) /* * Initialize curproc so that mutexes work. */ - PCPU_SET(curproc, &proc0); - PCPU_SET(curpcb, &((struct user *)user0)->u_pcb); + PCPU_SET(curthread, thread0); + PCPU_SET(curpcb, thread0->td_pcb); PCPU_SET(spinlocks, NULL); /* @@ -303,19 +310,21 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) struct sigframe *sfp; struct sigacts *psp; struct sigframe sf; + struct thread *td; struct proc *p; u_long sp; int oonstack; oonstack = 0; - p = curproc; + td = curthread; + p = td->td_proc; PROC_LOCK(p); psp = p->p_sigacts; - tf = p->p_frame; + tf = td->td_frame; sp = tf->tf_sp + SPOFF; oonstack = sigonstack(sp); - CTR4(KTR_SIG, "sendsig: p=%p (%s) catcher=%p sig=%d", p, p->p_comm, + CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, catcher, sig); /* Save user context. */ @@ -356,7 +365,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ - CTR2(KTR_SIG, "sendsig: trashed stack p=%p sfp=%p", p, sfp); + CTR2(KTR_SIG, "sendsig: trashed stack td=%p sfp=%p", td, sfp); PROC_LOCK(p); SIGACTION(p, SIGILL) = SIG_DFL; SIGDELSET(p->p_sigignore, SIGILL); @@ -392,14 +401,14 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) PROC_UNLOCK(p); /* Copy the sigframe out to the user's stack. */ - if (rwindow_save(p) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0) { + if (rwindow_save(td) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0) { /* * Something is wrong with the stack pointer. * ...Kill the process. */ - CTR2(KTR_SIG, "sendsig: sigexit p=%p sfp=%p", p, sfp); + CTR2(KTR_SIG, "sendsig: sigexit td=%p sfp=%p", td, sfp); PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); /* NOTREACHED */ } @@ -407,7 +416,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) tf->tf_tnpc = tf->tf_tpc + 4; tf->tf_sp = (u_long)sfp - SPOFF; - CTR3(KTR_SIG, "sendsig: return p=%p pc=%#lx sp=%#lx", p, tf->tf_tpc, + CTR3(KTR_SIG, "sendsig: return td=%p pc=%#lx sp=%#lx", td, tf->tf_tpc, tf->tf_sp); } @@ -418,26 +427,28 @@ struct sigreturn_args { #endif int -sigreturn(struct proc *p, struct sigreturn_args *uap) +sigreturn(struct thread *td, struct sigreturn_args *uap) { struct trapframe *tf; + struct proc *p; ucontext_t uc; - if (rwindow_save(p)) { + p = td->td_proc; + if (rwindow_save(td)) { PROC_LOCK(p); - sigexit(p, SIGILL); + sigexit(td, SIGILL); } - CTR2(KTR_SIG, "sigreturn: p=%p ucp=%p", p, uap->sigcntxp); + CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { - CTR1(KTR_SIG, "sigreturn: efault p=%p", p); + CTR1(KTR_SIG, "sigreturn: efault td=%p", td); return (EFAULT); } if (((uc.uc_mcontext.mc_tpc | uc.uc_mcontext.mc_tnpc) & 3) != 0) return (EINVAL); - tf = p->p_frame; + tf = td->td_frame; bcopy(uc.uc_mcontext.mc_global, tf->tf_global, sizeof(tf->tf_global)); bcopy(uc.uc_mcontext.mc_out, tf->tf_out, sizeof(tf->tf_out)); @@ -456,8 +467,8 @@ sigreturn(struct proc *p, struct sigreturn_args *uap) p->p_sigmask = uc.uc_sigmask; SIG_CANTMASK(p->p_sigmask); PROC_UNLOCK(p); - CTR4(KTR_SIG, "sigreturn: return p=%p pc=%#lx sp=%#lx tstate=%#lx", - p, tf->tf_tpc, tf->tf_sp, tf->tf_tstate); + CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx", + td, tf->tf_tpc, tf->tf_sp, tf->tf_tstate); return (EJUSTRETURN); } @@ -468,43 +479,43 @@ cpu_halt(void) } int -ptrace_set_pc(struct proc *p, u_long addr) +ptrace_set_pc(struct thread *td, u_long addr) { - p->p_frame->tf_tpc = addr; - p->p_frame->tf_tnpc = addr + 4; + td->td_frame->tf_tpc = addr; + td->td_frame->tf_tnpc = addr + 4; return (0); } int -ptrace_single_step(struct proc *p) +ptrace_single_step(struct thread *td) { TODO; return (0); } void -setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) +setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) { struct pcb *pcb; struct frame *fp; /* Round the stack down to a multiple of 16 bytes. */ stack = ((stack) / 16) * 16; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; /* XXX: honor the real number of windows... */ bzero(pcb->pcb_rw, sizeof(pcb->pcb_rw)); /* The inital window for the process (%cw = 0). */ - fp = (struct frame *)((caddr_t)p->p_addr + UPAGES * PAGE_SIZE) - 1; + fp = (struct frame *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; /* Make sure the frames that are frobbed are actually flushed. */ __asm __volatile("flushw"); mtx_lock_spin(&sched_lock); - fp_init_proc(pcb); + fp_init_thread(pcb); /* Setup state in the trap frame. */ - p->p_frame->tf_tstate = TSTATE_IE; - p->p_frame->tf_tpc = entry; - p->p_frame->tf_tnpc = entry + 4; - p->p_frame->tf_pil = 0; + td->td_frame->tf_tstate = TSTATE_IE; + td->td_frame->tf_tpc = entry; + td->td_frame->tf_tnpc = entry + 4; + td->td_frame->tf_pil = 0; /* * Set up the registers for the user. * The SCD (2.4.1) mandates: @@ -514,11 +525,11 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) * - %g1, if != 0, passes a function pointer which should be registered * with atexit(). */ - bzero(p->p_frame->tf_out, sizeof(p->p_frame->tf_out)); - bzero(p->p_frame->tf_global, sizeof(p->p_frame->tf_global)); + bzero(td->td_frame->tf_out, sizeof(td->td_frame->tf_out)); + bzero(td->td_frame->tf_global, sizeof(td->td_frame->tf_global)); /* Set up user stack. */ fp->f_fp = stack - SPOFF; - p->p_frame->tf_out[6] = stack - SPOFF - sizeof(struct frame); + td->td_frame->tf_out[6] = stack - SPOFF - sizeof(struct frame); wr(y, 0, 0); mtx_unlock_spin(&sched_lock); } @@ -532,42 +543,42 @@ Debugger(const char *msg) } int -fill_dbregs(struct proc *p, struct dbreg *dbregs) +fill_dbregs(struct thread *td, struct dbreg *dbregs) { TODO; return (0); } int -set_dbregs(struct proc *p, struct dbreg *dbregs) +set_dbregs(struct thread *td, struct dbreg *dbregs) { TODO; return (0); } int -fill_regs(struct proc *p, struct reg *regs) +fill_regs(struct thread *td, struct reg *regs) { TODO; return (0); } int -set_regs(struct proc *p, struct reg *regs) +set_regs(struct thread *td, struct reg *regs) { TODO; return (0); } int -fill_fpregs(struct proc *p, struct fpreg *fpregs) +fill_fpregs(struct thread *td, struct fpreg *fpregs) { TODO; return (0); } int -set_fpregs(struct proc *p, struct fpreg *fpregs) +set_fpregs(struct thread *td, struct fpreg *fpregs) { TODO; return (0); diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index 368f931..bc119d6 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -560,7 +560,7 @@ pmap_pageable(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, } /* - * Create the kernel stack and user structure for a new process. This + * Create the user structure for a new process. This * routine directly affects the performance of fork(). */ void @@ -573,16 +573,16 @@ pmap_new_proc(struct proc *p) o = p->p_upages_obj; if (o == NULL) { - o = vm_object_allocate(OBJT_DEFAULT, UPAGES); + o = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES); p->p_upages_obj = o; } - u = (vm_offset_t)p->p_addr; + u = (vm_offset_t)p->p_uarea; if (u == 0) { - u = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE); + u = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE); KASSERT(u != NULL, ("pmap_new_proc: u area\n")); - p->p_addr = (struct user *)u; + p->p_uarea = (struct user *)u; } - for (i = 0; i < UPAGES; i++) { + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_grab(o, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); m->wire_count++; cnt.v_wire_count++; @@ -603,8 +603,8 @@ pmap_dispose_proc(struct proc *p) int i; upobj = p->p_upages_obj; - up = (vm_offset_t)p->p_addr; - for (i = 0; i < UPAGES; i++) { + up = (vm_offset_t)p->p_uarea; + for (i = 0; i < UAREA_PAGES; i++) { m = vm_page_lookup(upobj, i); if (m == NULL) panic("pmap_dispose_proc: upage already missing?"); @@ -615,6 +615,62 @@ pmap_dispose_proc(struct proc *p) } } +/* + * Create the kernel stack for a new thread. This + * routine directly affects the performance of fork(). + */ +void +pmap_new_thread(struct thread *td) +{ + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + u_int i; + + ksobj = td->td_kstack_obj; + if (ksobj == NULL) { + ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES); + td->td_kstack_obj = ksobj; + } + ks = td->td_kstack; + if (ks == 0) { + ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE); + KASSERT(ks != NULL, ("pmap_new_thread: kstack\n")); + td->td_kstack = ks; + } + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY); + m->wire_count++; + cnt.v_wire_count++; + pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m)); + vm_page_wakeup(m); + vm_page_flag_clear(m, PG_ZERO); + vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE); + m->valid = VM_PAGE_BITS_ALL; + } +} + +void +pmap_dispose_thread(struct thread *td) +{ + vm_object_t ksobj; + vm_offset_t ks; + vm_page_t m; + int i; + + ksobj = td->td_kstack_obj; + ks = td->td_kstack; + for (i = 0; i < KSTACK_PAGES; i++) { + m = vm_page_lookup(ksobj, i); + if (m == NULL) + panic("pmap_dispose_proc: upage already missing?"); + vm_page_busy(m); + pmap_kremove(ks + i * PAGE_SIZE); + vm_page_unwire(m, 0); + vm_page_free(m); + } +} + void pmap_page_protect(vm_page_t m, vm_prot_t prot) { @@ -664,7 +720,7 @@ pmap_ts_referenced(vm_page_t m) } void -pmap_activate(struct proc *p) +pmap_activate(struct thread *td) { TODO; } @@ -839,3 +895,15 @@ pmap_swapout_proc(struct proc *p) { TODO; } + +void +pmap_swapin_thread(struct thread *td) +{ + TODO; +} + +void +pmap_swapout_thread(struct thread *td) +{ + TODO; +} diff --git a/sys/sparc64/sparc64/procfs_machdep.c b/sys/sparc64/sparc64/procfs_machdep.c index 4fb0471..f813f19 100644 --- a/sys/sparc64/sparc64/procfs_machdep.c +++ b/sys/sparc64/sparc64/procfs_machdep.c @@ -85,7 +85,7 @@ int error; \ \ mtx_lock_spin(&sched_lock); \ - if ((p->p_sflag & PS_INMEM) == 0) \ + if ((td->td_proc->p_sflag & PS_INMEM) == 0) \ error = EIO; \ else \ error = (action); \ @@ -94,31 +94,31 @@ } while(0) int -procfs_read_regs(struct proc *p, struct reg *regs) +procfs_read_regs(struct thread *td, struct reg *regs) { - PROCFS_ACTION(fill_regs(p, regs)); + PROCFS_ACTION(fill_regs(td, regs)); } int -procfs_write_regs(struct proc *p, struct reg *regs) +procfs_write_regs(struct thread *td, struct reg *regs) { - PROCFS_ACTION(set_regs(p, regs)); + PROCFS_ACTION(set_regs(td, regs)); } int -procfs_read_dbregs(struct proc *p, struct dbreg *dbregs) +procfs_read_dbregs(struct thread *td, struct dbreg *dbregs) { - PROCFS_ACTION(fill_dbregs(p, dbregs)); + PROCFS_ACTION(fill_dbregs(td, dbregs)); } int -procfs_write_dbregs(struct proc *p, struct dbreg *dbregs) +procfs_write_dbregs(struct thread *td, struct dbreg *dbregs) { - PROCFS_ACTION(set_dbregs(p, dbregs)); + PROCFS_ACTION(set_dbregs(td, dbregs)); } /* @@ -127,22 +127,22 @@ procfs_write_dbregs(struct proc *p, struct dbreg *dbregs) */ int -procfs_read_fpregs(struct proc *p, struct fpreg *fpregs) +procfs_read_fpregs(struct thread *td, struct fpreg *fpregs) { - PROCFS_ACTION(fill_fpregs(p, fpregs)); + PROCFS_ACTION(fill_fpregs(td, fpregs)); } int -procfs_write_fpregs(struct proc *p, struct fpreg *fpregs) +procfs_write_fpregs(struct thread *td, struct fpreg *fpregs) { - PROCFS_ACTION(set_fpregs(p, fpregs)); + PROCFS_ACTION(set_fpregs(td, fpregs)); } int -procfs_sstep(struct proc *p) +procfs_sstep(struct thread *td) { - PROCFS_ACTION(ptrace_single_step(p)); + PROCFS_ACTION(ptrace_single_step(td)); } diff --git a/sys/sparc64/sparc64/rwindow.c b/sys/sparc64/sparc64/rwindow.c index 474e6a9..5bcd9fb 100644 --- a/sys/sparc64/sparc64/rwindow.c +++ b/sys/sparc64/sparc64/rwindow.c @@ -38,7 +38,7 @@ #include <machine/frame.h> int -rwindow_load(struct proc *p, struct trapframe *tf, int n) +rwindow_load(struct thread *td, struct trapframe *tf, int n) { struct rwindow rw; u_long usp; @@ -49,11 +49,11 @@ rwindow_load(struct proc *p, struct trapframe *tf, int n) * In case current window is still only on-chip, push it out; * if it cannot get all the way out, we cannot continue either. */ - if ((error = rwindow_save(p)) != 0) + if ((error = rwindow_save(td)) != 0) return (error); usp = tf->tf_out[6]; - CTR3(KTR_TRAP, "rwindow_load: p=%p (%s) n=%d", - p, p->p_comm, n); + CTR3(KTR_TRAP, "rwindow_load: td=%p (%s) n=%d", + td, td->td_proc->p_comm, n); for (i = 0; i < n; i++) { CTR1(KTR_TRAP, "rwindow_load: usp=%#lx", usp); usp += SPOFF; @@ -65,7 +65,7 @@ rwindow_load(struct proc *p, struct trapframe *tf, int n) } int -rwindow_save(struct proc *p) +rwindow_save(struct thread *td) { struct rwindow *rw; struct pcb *pcb; @@ -75,9 +75,10 @@ rwindow_save(struct proc *p) int i; flushw(); - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; i = pcb->pcb_nsaved; - CTR3(KTR_TRAP, "rwindow_save: p=%p (%s) nsaved=%d", p, p->p_comm, i); + CTR3(KTR_TRAP, "rwindow_save: td=%p (%s) nsaved=%d", td, + td->td_proc->p_comm, i); if (i == 0) return (0); ausp = pcb->pcb_rwsp; diff --git a/sys/sparc64/sparc64/swtch.S b/sys/sparc64/sparc64/swtch.S index e3d7466..a490811 100644 --- a/sys/sparc64/sparc64/swtch.S +++ b/sys/sparc64/sparc64/swtch.S @@ -70,8 +70,8 @@ ENTRY(cpu_throw) save %sp, -CCFSZ, %sp - call chooseproc - ldx [PCPU(CURPROC)], %l0 + call choosethread + ldx [PCPU(CURTHREAD)], %l0 flushw b,a .Lsw1 END(cpu_throw) @@ -82,8 +82,8 @@ ENTRY(cpu_switch) * nothing. */ save %sp, -CCFSZ, %sp - call chooseproc - ldx [PCPU(CURPROC)], %l0 + call choosethread + ldx [PCPU(CURTHREAD)], %l0 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: from=%p (%s) to=%p (%s)" , %g1, %g2, %g3, 7, 8, 9) @@ -104,7 +104,7 @@ ENTRY(cpu_switch) * and are therefore not saved in the trap frame. * If the process was using floating point, save its context. */ - ldx [%l0 + P_FRAME], %l1 + ldx [%l0 + TD_FRAME], %l1 ldx [PCPU(CURPCB)], %l2 rd %y, %l3 stx %l3, [%l2 + PCB_Y] @@ -131,41 +131,42 @@ ENTRY(cpu_switch) * Load the new process's frame pointer and program counter, and set * the current process and pcb. */ -.Lsw1: ldx [%o0 + P_ADDR], %o1 +.Lsw1: ldx [%o0 + TD_PCB], %o1 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: to=%p pc=%#lx fp=%#lx sp=%#lx cwp=%#lx" , %g1, %g2, %g3, 7, 8, 9) stx %o0, [%g1 + KTR_PARM1] - ldx [%o1 + U_PCB + PCB_PC], %g2 + ldx [%o1 + PCB_PC], %g2 stx %g2, [%g1 + KTR_PARM2] - ldx [%o1 + U_PCB + PCB_FP], %g2 + ldx [%o1 + PCB_FP], %g2 stx %g2, [%g1 + KTR_PARM3] sub %g2, CCFSZ, %g2 stx %g2, [%g1 + KTR_PARM4] - ldx [%o1 + U_PCB + PCB_CWP], %g2 + ldx [%o1 + PCB_CWP], %g2 stx %g2, [%g1 + KTR_PARM5] 9: #endif #if 1 mov %o0, %g4 mov %l0, %g5 - ldx [%o1 + U_PCB + PCB_CWP], %o2 + ldx [%o1 + PCB_CWP], %o2 wrpr %o2, %cwp mov %g4, %o0 mov %g5, %l0 #endif - ldx [%o0 + P_ADDR], %o1 - ldx [%o1 + U_PCB + PCB_FP], %fp - ldx [%o1 + U_PCB + PCB_PC], %i7 + ldx [%o0 + TD_PCB], %o1 + ldx [%o1 + PCB_FP], %fp + ldx [%o1 + PCB_PC], %i7 sub %fp, CCFSZ, %sp - stx %o0, [PCPU(CURPROC)] + stx %o0, [PCPU(CURTHREAD)] stx %o1, [PCPU(CURPCB)] /* * Point to the new process's vmspace and load its vm context number. * If its nucleus context we are done. */ - ldx [%o0 + P_VMSPACE], %o2 + ldx [%o0 + TD_PROC], %o2 + ldx [%o2 + P_VMSPACE], %o2 lduw [%o2 + VM_PMAP + PM_CONTEXT], %o3 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: to=%p vm=%p context=%#x" @@ -182,12 +183,12 @@ ENTRY(cpu_switch) * If the new process was using floating point, restore its context. * Always restore %fprs and %y. */ - ldx [%o0 + P_FRAME], %o4 + ldx [%o0 + TD_FRAME], %o4 ldx [%o4 + TF_TSTATE], %o4 andcc %o4, TSTATE_PEF, %o4 be,pt %xcc, 2f nop - restrfp %o1 + U_PCB + PCB_FPSTATE, %o4 + restrfp %o1 + PCB_FPSTATE, %o4 2: ldx [%o1 + PCB_FPSTATE + FP_FPRS], %o4 wr %o4, 0, %fprs @@ -199,7 +200,8 @@ ENTRY(cpu_switch) * context number. If its the same as the new process, we are * done. */ - ldx [%l0 + P_VMSPACE], %l1 + ldx [%l0 + TD_PROC], %l1 + ldx [%l1 + P_VMSPACE], %l1 lduw [%l1 + VM_PMAP + PM_CONTEXT], %l3 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: from=%p vm=%p context=%#x" @@ -247,9 +249,9 @@ ENTRY(cpu_switch) */ 3: #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "cpu_switch: return p=%p (%s)" + CATR(KTR_CT1, "cpu_switch: return td=%p (%s)" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g3 stx %g3, [%g1 + KTR_PARM2] @@ -266,8 +268,8 @@ ENTRY(savectx) stx %l0, [%i0 + PCB_Y] rd %fprs, %l0 stx %l0, [%i0 + PCB_FPSTATE + FP_FPRS] - ldx [PCPU(CURPROC)], %l0 - ldx [%l0 + P_FRAME], %l0 + ldx [PCPU(CURTHREAD)], %l0 + ldx [%l0 + TD_FRAME], %l0 ldx [%l0 + TF_TSTATE], %l0 andcc %l0, TSTATE_PEF, %l0 be,pt %xcc, 1f diff --git a/sys/sparc64/sparc64/swtch.s b/sys/sparc64/sparc64/swtch.s index e3d7466..a490811 100644 --- a/sys/sparc64/sparc64/swtch.s +++ b/sys/sparc64/sparc64/swtch.s @@ -70,8 +70,8 @@ ENTRY(cpu_throw) save %sp, -CCFSZ, %sp - call chooseproc - ldx [PCPU(CURPROC)], %l0 + call choosethread + ldx [PCPU(CURTHREAD)], %l0 flushw b,a .Lsw1 END(cpu_throw) @@ -82,8 +82,8 @@ ENTRY(cpu_switch) * nothing. */ save %sp, -CCFSZ, %sp - call chooseproc - ldx [PCPU(CURPROC)], %l0 + call choosethread + ldx [PCPU(CURTHREAD)], %l0 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: from=%p (%s) to=%p (%s)" , %g1, %g2, %g3, 7, 8, 9) @@ -104,7 +104,7 @@ ENTRY(cpu_switch) * and are therefore not saved in the trap frame. * If the process was using floating point, save its context. */ - ldx [%l0 + P_FRAME], %l1 + ldx [%l0 + TD_FRAME], %l1 ldx [PCPU(CURPCB)], %l2 rd %y, %l3 stx %l3, [%l2 + PCB_Y] @@ -131,41 +131,42 @@ ENTRY(cpu_switch) * Load the new process's frame pointer and program counter, and set * the current process and pcb. */ -.Lsw1: ldx [%o0 + P_ADDR], %o1 +.Lsw1: ldx [%o0 + TD_PCB], %o1 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: to=%p pc=%#lx fp=%#lx sp=%#lx cwp=%#lx" , %g1, %g2, %g3, 7, 8, 9) stx %o0, [%g1 + KTR_PARM1] - ldx [%o1 + U_PCB + PCB_PC], %g2 + ldx [%o1 + PCB_PC], %g2 stx %g2, [%g1 + KTR_PARM2] - ldx [%o1 + U_PCB + PCB_FP], %g2 + ldx [%o1 + PCB_FP], %g2 stx %g2, [%g1 + KTR_PARM3] sub %g2, CCFSZ, %g2 stx %g2, [%g1 + KTR_PARM4] - ldx [%o1 + U_PCB + PCB_CWP], %g2 + ldx [%o1 + PCB_CWP], %g2 stx %g2, [%g1 + KTR_PARM5] 9: #endif #if 1 mov %o0, %g4 mov %l0, %g5 - ldx [%o1 + U_PCB + PCB_CWP], %o2 + ldx [%o1 + PCB_CWP], %o2 wrpr %o2, %cwp mov %g4, %o0 mov %g5, %l0 #endif - ldx [%o0 + P_ADDR], %o1 - ldx [%o1 + U_PCB + PCB_FP], %fp - ldx [%o1 + U_PCB + PCB_PC], %i7 + ldx [%o0 + TD_PCB], %o1 + ldx [%o1 + PCB_FP], %fp + ldx [%o1 + PCB_PC], %i7 sub %fp, CCFSZ, %sp - stx %o0, [PCPU(CURPROC)] + stx %o0, [PCPU(CURTHREAD)] stx %o1, [PCPU(CURPCB)] /* * Point to the new process's vmspace and load its vm context number. * If its nucleus context we are done. */ - ldx [%o0 + P_VMSPACE], %o2 + ldx [%o0 + TD_PROC], %o2 + ldx [%o2 + P_VMSPACE], %o2 lduw [%o2 + VM_PMAP + PM_CONTEXT], %o3 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: to=%p vm=%p context=%#x" @@ -182,12 +183,12 @@ ENTRY(cpu_switch) * If the new process was using floating point, restore its context. * Always restore %fprs and %y. */ - ldx [%o0 + P_FRAME], %o4 + ldx [%o0 + TD_FRAME], %o4 ldx [%o4 + TF_TSTATE], %o4 andcc %o4, TSTATE_PEF, %o4 be,pt %xcc, 2f nop - restrfp %o1 + U_PCB + PCB_FPSTATE, %o4 + restrfp %o1 + PCB_FPSTATE, %o4 2: ldx [%o1 + PCB_FPSTATE + FP_FPRS], %o4 wr %o4, 0, %fprs @@ -199,7 +200,8 @@ ENTRY(cpu_switch) * context number. If its the same as the new process, we are * done. */ - ldx [%l0 + P_VMSPACE], %l1 + ldx [%l0 + TD_PROC], %l1 + ldx [%l1 + P_VMSPACE], %l1 lduw [%l1 + VM_PMAP + PM_CONTEXT], %l3 #if KTR_COMPILE & KTR_CT1 CATR(KTR_CT1, "cpu_switch: from=%p vm=%p context=%#x" @@ -247,9 +249,9 @@ ENTRY(cpu_switch) */ 3: #if KTR_COMPILE & KTR_CT1 - CATR(KTR_CT1, "cpu_switch: return p=%p (%s)" + CATR(KTR_CT1, "cpu_switch: return td=%p (%s)" , %g1, %g2, %g3, 7, 8, 9) - ldx [PCPU(CURPROC)], %g2 + ldx [PCPU(CURTHREAD)], %g2 stx %g2, [%g1 + KTR_PARM1] add %g2, P_COMM, %g3 stx %g3, [%g1 + KTR_PARM2] @@ -266,8 +268,8 @@ ENTRY(savectx) stx %l0, [%i0 + PCB_Y] rd %fprs, %l0 stx %l0, [%i0 + PCB_FPSTATE + FP_FPRS] - ldx [PCPU(CURPROC)], %l0 - ldx [%l0 + P_FRAME], %l0 + ldx [PCPU(CURTHREAD)], %l0 + ldx [%l0 + TD_FRAME], %l0 ldx [%l0 + TF_TSTATE], %l0 andcc %l0, TSTATE_PEF, %l0 be,pt %xcc, 1f diff --git a/sys/sparc64/sparc64/sys_machdep.c b/sys/sparc64/sparc64/sys_machdep.c index 0fd7a66..df0c16e 100644 --- a/sys/sparc64/sparc64/sys_machdep.c +++ b/sys/sparc64/sparc64/sys_machdep.c @@ -38,7 +38,7 @@ struct sysarch_args { #endif int -sysarch(struct proc *p, struct sysarch_args *uap) +sysarch(struct thread *td, struct sysarch_args *uap) { TODO; return (0); diff --git a/sys/sparc64/sparc64/trap.c b/sys/sparc64/sparc64/trap.c index e3f60a2..f1fa544 100644 --- a/sys/sparc64/sparc64/trap.c +++ b/sys/sparc64/sparc64/trap.c @@ -76,8 +76,8 @@ #include <machine/watch.h> void trap(struct trapframe *tf); -int trap_mmu_fault(struct proc *p, struct trapframe *tf); -void syscall(struct proc *p, struct trapframe *tf, u_int sticks); +int trap_mmu_fault(struct thread *td, struct trapframe *tf); +void syscall(struct thread *td, struct trapframe *tf, u_int sticks); u_long trap_mask = 0xffffffffffffffffL & ~(1 << T_INTR); @@ -124,6 +124,7 @@ void trap(struct trapframe *tf) { u_int sticks; + struct thread *td; struct proc *p; int error; int ucode; @@ -131,11 +132,12 @@ trap(struct trapframe *tf) int sig; int mask; - KASSERT(PCPU_GET(curproc) != NULL, ("trap: curproc NULL")); + KASSERT(PCPU_GET(curthread) != NULL, ("trap: curthread NULL")); KASSERT(PCPU_GET(curpcb) != NULL, ("trap: curpcb NULL")); error = 0; - p = PCPU_GET(curproc); + td = PCPU_GET(curthread); + p = td->td_proc; type = tf->tf_type; ucode = type; /* XXX */ sticks = 0; @@ -157,8 +159,8 @@ trap(struct trapframe *tf) cnt.v_trap++; if ((type & T_KERNEL) == 0) { - sticks = p->p_sticks; - p->p_frame = tf; + sticks = td->td_kse->ke_sticks; + td->td_frame = tf; } switch (type) { @@ -174,7 +176,7 @@ trap(struct trapframe *tf) sig = SIGFPE; goto trapsig; case T_FP_DISABLED: - if (fp_enable_proc(p)) + if (fp_enable_thread(td)) goto user; /* Fallthrough. */ case T_FP_IEEE: @@ -190,18 +192,18 @@ trap(struct trapframe *tf) case T_DMMU_MISS: case T_DMMU_PROT: case T_IMMU_MISS: - error = trap_mmu_fault(p, tf); + error = trap_mmu_fault(td, tf); if (error == 0) goto user; sig = error; goto trapsig; case T_FILL: - if (rwindow_load(p, tf, 2)) - sigexit(p, SIGILL); + if (rwindow_load(td, tf, 2)) + sigexit(td, SIGILL); goto out; case T_FILL_RET: - if (rwindow_load(p, tf, 1)) - sigexit(p, SIGILL); + if (rwindow_load(td, tf, 1)) + sigexit(td, SIGILL); goto out; case T_INSN_ILLEGAL: sig = SIGILL; @@ -217,12 +219,12 @@ trap(struct trapframe *tf) sig = SIGILL; goto trapsig; case T_SPILL: - if (rwindow_save(p)) - sigexit(p, SIGILL); + if (rwindow_save(td)) + sigexit(td, SIGILL); goto out; case T_SYSCALL: /* syscall() calls userret(), so we need goto out; */ - syscall(p, tf, sticks); + syscall(td, tf, sticks); goto out; case T_TAG_OVFLW: sig = SIGEMT; @@ -235,7 +237,7 @@ trap(struct trapframe *tf) #endif case T_DMMU_MISS | T_KERNEL: case T_DMMU_PROT | T_KERNEL: - error = trap_mmu_fault(p, tf); + error = trap_mmu_fault(td, tf); if (error == 0) goto out; break; @@ -292,7 +294,7 @@ trapsig: sig = (p->p_sysent->sv_transtrap)(sig, type); trapsignal(p, sig, ucode); user: - userret(p, tf, sticks); + userret(td, tf, sticks); out: #if KTR_COMPILE & KTR_TRAP if (trap_mask & (1 << (type & ~T_KERNEL))) { @@ -303,13 +305,14 @@ out: } int -trap_mmu_fault(struct proc *p, struct trapframe *tf) +trap_mmu_fault(struct thread *td, struct trapframe *tf) { struct mmuframe *mf; struct vmspace *vm; struct stte *stp; struct pcb *pcb; struct tte tte; + struct proc *p; vm_offset_t va; vm_prot_t prot; u_long ctx; @@ -318,6 +321,7 @@ trap_mmu_fault(struct proc *p, struct trapframe *tf) int type; int rv; + p = td->td_proc; KASSERT(p->p_vmspace != NULL, ("trap_dmmu_miss: vmspace NULL")); rv = KERN_SUCCESS; @@ -327,8 +331,8 @@ trap_mmu_fault(struct proc *p, struct trapframe *tf) type = tf->tf_type & ~T_KERNEL; va = TLB_TAR_VA(mf->mf_tar); - CTR4(KTR_TRAP, "trap_mmu_fault: p=%p pm_ctx=%#lx va=%#lx ctx=%#lx", - p, p->p_vmspace->vm_pmap.pm_context, va, ctx); + CTR4(KTR_TRAP, "trap_mmu_fault: td=%p pm_ctx=%#lx va=%#lx ctx=%#lx", + td, p->p_vmspace->vm_pmap.pm_context, va, ctx); if (type == T_DMMU_PROT) { prot = VM_PROT_WRITE; @@ -354,7 +358,7 @@ trap_mmu_fault(struct proc *p, struct trapframe *tf) tlb_store(TLB_DTLB, va, ctx, tte); } } else if (tf->tf_type & T_KERNEL && - (p->p_intr_nesting_level != 0 || pcb->pcb_onfault == NULL)) { + (td->td_intr_nesting_level != 0 || pcb->pcb_onfault == NULL)) { rv = KERN_FAILURE; } else { mtx_lock(&Giant); @@ -424,9 +428,10 @@ trap_mmu_fault(struct proc *p, struct trapframe *tf) * in %g1 (and also saved in the trap frame). */ void -syscall(struct proc *p, struct trapframe *tf, u_int sticks) +syscall(struct thread *td, struct trapframe *tf, u_int sticks) { struct sysent *callp; + struct proc *p; u_long code; u_long tpc; int reg; @@ -441,6 +446,7 @@ syscall(struct proc *p, struct trapframe *tf, u_int sticks) reg = 0; regcnt = REG_MAXARGS; code = tf->tf_global[1]; + p = td->td_proc; /* * For syscalls, we don't want to retry the faulting instruction * (usually), instead we need to advance one instruction. @@ -485,7 +491,7 @@ syscall(struct proc *p, struct trapframe *tf, u_int sticks) goto bad; } - CTR5(KTR_SYSC, "syscall: p=%p %s(%#lx, %#lx, %#lx)", p, + CTR5(KTR_SYSC, "syscall: td=%p %s(%#lx, %#lx, %#lx)", td, syscallnames[code], argp[0], argp[1], argp[2]); /* @@ -504,23 +510,23 @@ syscall(struct proc *p, struct trapframe *tf, u_int sticks) ktrsyscall(p->p_tracep, code, narg, args); } #endif - p->p_retval[0] = 0; - p->p_retval[1] = tf->tf_out[1]; + td->td_retval[0] = 0; + td->td_retval[1] = tf->tf_out[1]; STOPEVENT(p, S_SCE, narg); /* MP aware */ - error = (*callp->sy_call)(p, argp); + error = (*callp->sy_call)(td, argp); CTR5(KTR_SYSC, "syscall: p=%p error=%d %s return %#lx %#lx ", p, - error, syscallnames[code], p->p_retval[0], p->p_retval[1]); + error, syscallnames[code], td->td_retval[0], td->td_retval[1]); /* * MP SAFE (we may or may not have the MP lock at this point) */ switch (error) { case 0: - tf->tf_out[0] = p->p_retval[0]; - tf->tf_out[1] = p->p_retval[1]; + tf->tf_out[0] = td->td_retval[0]; + tf->tf_out[1] = td->td_retval[1]; tf->tf_tstate &= ~TSTATE_XCC_C; break; @@ -552,11 +558,11 @@ bad: /* * Handle reschedule and other end-of-syscall issues */ - userret(p, tf, sticks); + userret(td, tf, sticks); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - ktrsysret(p->p_tracep, code, error, p->p_retval[0]); + ktrsysret(p->p_tracep, code, error, td->td_retval[0]); } #endif @@ -575,7 +581,7 @@ bad: STOPEVENT(p, S_SCX, code); #ifdef WITNESS - if (witness_list(p)) { + if (witness_list(td)) { panic("system call %s returning with mutex(s) held\n", syscallnames[code]); } diff --git a/sys/sparc64/sparc64/vm_machdep.c b/sys/sparc64/sparc64/vm_machdep.c index addec1b..1e94d40 100644 --- a/sys/sparc64/sparc64/vm_machdep.c +++ b/sys/sparc64/sparc64/vm_machdep.c @@ -64,7 +64,7 @@ #include <machine/tstate.h> void -cpu_exit(struct proc *p) +cpu_exit(struct thread *td) { } @@ -74,25 +74,29 @@ cpu_exit(struct proc *p) * ready to run and return to user mode. */ void -cpu_fork(struct proc *p1, struct proc *p2, int flags) +cpu_fork(struct thread *td1, struct proc *p2, int flags) { + struct thread *td2; struct trapframe *tf; struct frame *fp; struct pcb *pcb; - KASSERT(p1 == curproc || p1 == &proc0, + KASSERT(td1 == curthread || td1 == thread0, ("cpu_fork: p1 not curproc and not proc0")); if ((flags & RFPROC) == 0) return; + td2 = &p2->p_thread; + pcb = (struct pcb *)td2->td_kstack; + td2->td_pcb = pcb; + /* * Ensure that p1's pcb is up to date. */ - pcb = &p2->p_addr->u_pcb; - p1->p_addr->u_pcb.pcb_y = rd(y); - p1->p_addr->u_pcb.pcb_fpstate.fp_fprs = rd(fprs); - if ((p1->p_frame->tf_tstate & TSTATE_PEF) != 0) { + td1->td_pcb->pcb_y = rd(y); + td1->td_pcb->pcb_fpstate.fp_fprs = rd(fprs); + if ((td1->td_frame->tf_tstate & TSTATE_PEF) != 0) { mtx_lock_spin(&sched_lock); savefpctx(&pcb->pcb_fpstate); mtx_unlock_spin(&sched_lock); @@ -100,8 +104,7 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) /* Make sure the copied windows are spilled. */ __asm __volatile("flushw"); /* Copy the pcb (this will copy the windows saved in the pcb, too). */ - pcb = &p2->p_addr->u_pcb; - bcopy(&p1->p_addr->u_pcb, pcb, sizeof(*pcb)); + bcopy(td1->td_pcb, pcb, sizeof(*pcb)); pcb->pcb_cwp = 2; /* @@ -109,17 +112,18 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ - tf = (struct trapframe *)((caddr_t)p2->p_addr + UPAGES * PAGE_SIZE) - 1; - bcopy(p1->p_frame, tf, sizeof(*tf)); + tf = (struct trapframe *) + (td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + bcopy(td1->td_frame, tf, sizeof(*tf)); tf->tf_out[0] = 0; /* Child returns zero */ tf->tf_out[1] = 1; /* XXX i386 returns 1 in %edx */ tf->tf_tstate &= ~(TSTATE_XCC_C | TSTATE_CWP_MASK); /* success */ - p2->p_frame = tf; + td2->td_frame = tf; fp = (struct frame *)tf - 1; fp->f_local[0] = (u_long)fork_return; - fp->f_local[1] = (u_long)p2; + fp->f_local[1] = (u_long)td2; fp->f_local[2] = (u_long)tf; pcb->pcb_cwp = 2; pcb->pcb_fp = (u_long)fp - SPOFF; @@ -143,12 +147,12 @@ cpu_reset(void) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(struct proc *p, void (*func)(void *), void *arg) +cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg) { struct frame *fp; struct pcb *pcb; - pcb = &p->p_addr->u_pcb; + pcb = td->td_pcb; fp = (struct frame *)(pcb->pcb_fp + SPOFF); fp->f_local[0] = (u_long)func; fp->f_local[1] = (u_long)arg; diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h index 539e402..82f3648 100644 --- a/sys/sys/_mutex.h +++ b/sys/sys/_mutex.h @@ -40,7 +40,7 @@ struct mtx { volatile uintptr_t mtx_lock; /* owner (and state for sleep locks) */ volatile u_int mtx_recurse; /* number of recursive holds */ critical_t mtx_savecrit; /* saved flags (for spin locks) */ - TAILQ_HEAD(, proc) mtx_blocked; /* threads blocked on this lock */ + TAILQ_HEAD(, thread) mtx_blocked; /* threads blocked on this lock */ LIST_ENTRY(mtx) mtx_contested; /* list of all contested locks */ }; diff --git a/sys/sys/acct.h b/sys/sys/acct.h index 9896295..114b609 100644 --- a/sys/sys/acct.h +++ b/sys/sys/acct.h @@ -85,9 +85,9 @@ struct acct { #define AHZ 64 #ifdef _KERNEL -struct proc; +struct thread; -int acct_process __P((struct proc *p)); +int acct_process __P((struct thread *td)); #endif #endif /* !_SYS_ACCT_H_ */ diff --git a/sys/sys/aio.h b/sys/sys/aio.h index 5b54132..7dc5f05 100644 --- a/sys/sys/aio.h +++ b/sys/sys/aio.h @@ -140,9 +140,9 @@ struct aiocblist { int inputcharge, outputcharge; struct callout_handle timeouthandle; struct buf *bp; /* Buffer pointer */ - struct proc *userproc; /* User process */ + struct proc *userproc; /* User process */ /* Not td! */ struct file *fd_file; /* Pointer to file structure */ - struct aioproclist *jobaioproc;/* AIO process descriptor */ + struct aiothreadlist *jobaiothread; /* AIO process descriptor */ struct aio_liojob *lio; /* Optional lio job */ struct aiocb *uuaiocb; /* Pointer in userspace of aiocb */ struct klist klist; /* list of knotes */ diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 21646ad..28c22ae 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -249,7 +249,7 @@ struct buf { extern struct mtx buftimelock; /* Interlock on setting prio and timo */ extern char *buf_wmesg; /* Default buffer lock message */ #define BUF_WMESG "bufwait" -#include <sys/proc.h> /* XXX for curproc */ +#include <sys/proc.h> /* XXX for curthread */ #include <sys/mutex.h> /* @@ -273,7 +273,7 @@ BUF_LOCK(struct buf *bp, int locktype) bp->b_lock.lk_wmesg = buf_wmesg; bp->b_lock.lk_prio = PRIBIO + 4; bp->b_lock.lk_timo = 0; - ret = lockmgr(&(bp)->b_lock, locktype, &buftimelock, curproc); + ret = lockmgr(&(bp)->b_lock, locktype, &buftimelock, curthread); splx(s); return ret; } @@ -292,7 +292,7 @@ BUF_TIMELOCK(struct buf *bp, int locktype, char *wmesg, int catch, int timo) bp->b_lock.lk_wmesg = wmesg; bp->b_lock.lk_prio = (PRIBIO + 4) | catch; bp->b_lock.lk_timo = timo; - ret = lockmgr(&(bp)->b_lock, (locktype), &buftimelock, curproc); + ret = lockmgr(&(bp)->b_lock, (locktype), &buftimelock, curthread); splx(s); return ret; } @@ -307,7 +307,7 @@ BUF_UNLOCK(struct buf *bp) int s; s = splbio(); - lockmgr(&(bp)->b_lock, LK_RELEASE, NULL, curproc); + lockmgr(&(bp)->b_lock, LK_RELEASE, NULL, curthread); splx(s); } @@ -332,10 +332,11 @@ static __inline void BUF_KERNPROC __P((struct buf *)); static __inline void BUF_KERNPROC(struct buf *bp) { - struct proc *p = curproc; + struct thread *td = curthread; - if (p != PCPU_GET(idleproc) && bp->b_lock.lk_lockholder == p->p_pid) - p->p_locks--; + if ((td != PCPU_GET(idlethread)) + && bp->b_lock.lk_lockholder == td->td_proc->p_pid) + td->td_locks--; bp->b_lock.lk_lockholder = LK_KERNPROC; } #endif diff --git a/sys/sys/capability.h b/sys/sys/capability.h index 5aff598..eb3d9e2 100644 --- a/sys/sys/capability.h +++ b/sys/sys/capability.h @@ -190,6 +190,7 @@ typedef struct cap *cap_t; #ifdef _KERNEL +struct thread; struct proc; struct ucred; struct vnode; diff --git a/sys/sys/condvar.h b/sys/sys/condvar.h index 5446a5e..72b1513 100644 --- a/sys/sys/condvar.h +++ b/sys/sys/condvar.h @@ -33,9 +33,9 @@ #include <sys/queue.h> struct mtx; -struct proc; +struct thread; -TAILQ_HEAD(cv_waitq, proc); +TAILQ_HEAD(cv_waitq, thread); /* * Condition variable. @@ -61,7 +61,7 @@ int cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo); void cv_signal(struct cv *cvp); void cv_broadcast(struct cv *cvp); -void cv_waitq_remove(struct proc *p); +void cv_waitq_remove(struct thread *td); #define cv_waitq_empty(cvp) (TAILQ_EMPTY(&(cvp)->cv_waitq)) #define cv_wmesg(cvp) ((cvp)->cv_description) diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 41556cc..1ecbcf8 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -110,21 +110,21 @@ struct specinfo { struct bio; struct buf; -struct proc; +struct thread; struct uio; struct knote; -typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p)); -typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p)); +typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct thread *td)); +typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct thread *td)); typedef void d_strategy_t __P((struct bio *bp)); typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data, - int fflag, struct proc *p)); + int fflag, struct thread *td)); typedef int d_dump_t __P((dev_t dev)); typedef int d_psize_t __P((dev_t dev)); typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag)); typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag)); -typedef int d_poll_t __P((dev_t dev, int events, struct proc *p)); +typedef int d_poll_t __P((dev_t dev, int events, struct thread *td)); typedef int d_kqfilter_t __P((dev_t dev, struct knote *kn)); typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot)); @@ -133,7 +133,7 @@ typedef int l_close_t __P((struct tty *tp, int flag)); typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag)); typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag)); typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p)); + int flag, struct thread *td)); typedef int l_rint_t __P((int c, struct tty *tp)); typedef int l_start_t __P((struct tty *tp)); typedef int l_modem_t __P((struct tty *tp, int flag)); diff --git a/sys/sys/event.h b/sys/sys/event.h index fb16e54..19cb893 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -157,13 +157,14 @@ struct knote { #define kn_fp kn_ptr.p_fp }; +struct thread; struct proc; extern void knote(struct klist *list, long hint); -extern void knote_remove(struct proc *p, struct klist *list); -extern void knote_fdclose(struct proc *p, int fd); +extern void knote_remove(struct thread *p, struct klist *list); +extern void knote_fdclose(struct thread *p, int fd); extern int kqueue_register(struct kqueue *kq, - struct kevent *kev, struct proc *p); + struct kevent *kev, struct thread *p); #else /* !_KERNEL */ diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index 5effcda..8d91641 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -87,7 +87,7 @@ do { \ struct eventhandler_entry *_ep, *_en; \ \ if (_el->el_flags & EHE_INITTED) { \ - lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, CURPROC); \ + lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, curthread); \ _ep = TAILQ_FIRST(&(_el->el_entries)); \ while (_ep != NULL) { \ _en = TAILQ_NEXT(_ep, ee_link); \ @@ -95,7 +95,7 @@ do { \ ## args); \ _ep = _en; \ } \ - lockmgr(&_el->el_lock, LK_RELEASE, NULL, CURPROC); \ + lockmgr(&_el->el_lock, LK_RELEASE, NULL, curthread); \ } \ } while (0) @@ -127,7 +127,7 @@ do { \ \ if (((_el = eventhandler_find_list(#name)) != NULL) && \ (_el->el_flags & EHE_INITTED)) { \ - lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, CURPROC); \ + lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, curthread); \ _ep = TAILQ_FIRST(&(_el->el_entries)); \ while (_ep != NULL) { \ _en = TAILQ_NEXT(_ep, ee_link); \ @@ -135,7 +135,7 @@ do { \ ## args); \ _ep = _en; \ } \ - lockmgr(&_el->el_lock, LK_RELEASE, NULL, CURPROC); \ + lockmgr(&_el->el_lock, LK_RELEASE, NULL, curthread); \ } \ } while (0) diff --git a/sys/sys/file.h b/sys/sys/file.h index 6e04352..0416d3a 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -46,7 +46,7 @@ #include <sys/queue.h> struct stat; -struct proc; +struct thread; struct uio; struct knote; @@ -69,20 +69,20 @@ struct file { struct fileops { int (*fo_read) __P((struct file *fp, struct uio *uio, struct ucred *cred, int flags, - struct proc *p)); + struct thread *td)); int (*fo_write) __P((struct file *fp, struct uio *uio, struct ucred *cred, int flags, - struct proc *p)); + struct thread *td)); #define FOF_OFFSET 1 int (*fo_ioctl) __P((struct file *fp, u_long com, - caddr_t data, struct proc *p)); + caddr_t data, struct thread *td)); int (*fo_poll) __P((struct file *fp, int events, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); int (*fo_kqfilter) __P((struct file *fp, struct knote *kn)); int (*fo_stat) __P((struct file *fp, struct stat *sb, - struct proc *p)); - int (*fo_close) __P((struct file *fp, struct proc *p)); + struct thread *td)); + int (*fo_close) __P((struct file *fp, struct thread *td)); } *f_ops; int f_seqcount; /* * count of sequential accesses -- cleared @@ -109,7 +109,7 @@ extern int maxfilesperproc; /* per process limit on number of open files */ extern int nfiles; /* actual number of open files */ static __inline void fhold __P((struct file *fp)); -int fdrop __P((struct file *fp, struct proc *p)); +int fdrop __P((struct file *fp, struct thread *td)); static __inline void fhold(fp) @@ -120,101 +120,101 @@ fhold(fp) } static __inline int fo_read __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); static __inline int fo_write __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); + struct ucred *cred, int flags, struct thread *td)); static __inline int fo_ioctl __P((struct file *fp, u_long com, caddr_t data, - struct proc *p)); + struct thread *td)); static __inline int fo_poll __P((struct file *fp, int events, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); static __inline int fo_stat __P((struct file *fp, struct stat *sb, - struct proc *p)); -static __inline int fo_close __P((struct file *fp, struct proc *p)); + struct thread *td)); +static __inline int fo_close __P((struct file *fp, struct thread *td)); static __inline int fo_kqfilter __P((struct file *fp, struct knote *kn)); static __inline int -fo_read(fp, uio, cred, flags, p) +fo_read(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { int error; fhold(fp); - error = (*fp->f_ops->fo_read)(fp, uio, cred, flags, p); - fdrop(fp, p); + error = (*fp->f_ops->fo_read)(fp, uio, cred, flags, td); + fdrop(fp, td); return (error); } static __inline int -fo_write(fp, uio, cred, flags, p) +fo_write(fp, uio, cred, flags, td) struct file *fp; struct uio *uio; struct ucred *cred; - struct proc *p; + struct thread *td; int flags; { int error; fhold(fp); - error = (*fp->f_ops->fo_write)(fp, uio, cred, flags, p); - fdrop(fp, p); + error = (*fp->f_ops->fo_write)(fp, uio, cred, flags, td); + fdrop(fp, td); return (error); } static __inline int -fo_ioctl(fp, com, data, p) +fo_ioctl(fp, com, data, td) struct file *fp; u_long com; caddr_t data; - struct proc *p; + struct thread *td; { int error; fhold(fp); - error = (*fp->f_ops->fo_ioctl)(fp, com, data, p); - fdrop(fp, p); + error = (*fp->f_ops->fo_ioctl)(fp, com, data, td); + fdrop(fp, td); return (error); } static __inline int -fo_poll(fp, events, cred, p) +fo_poll(fp, events, cred, td) struct file *fp; int events; struct ucred *cred; - struct proc *p; + struct thread *td; { int error; fhold(fp); - error = (*fp->f_ops->fo_poll)(fp, events, cred, p); - fdrop(fp, p); + error = (*fp->f_ops->fo_poll)(fp, events, cred, td); + fdrop(fp, td); return (error); } static __inline int -fo_stat(fp, sb, p) +fo_stat(fp, sb, td) struct file *fp; struct stat *sb; - struct proc *p; + struct thread *td; { int error; fhold(fp); - error = (*fp->f_ops->fo_stat)(fp, sb, p); - fdrop(fp, p); + error = (*fp->f_ops->fo_stat)(fp, sb, td); + fdrop(fp, td); return (error); } static __inline int -fo_close(fp, p) +fo_close(fp, td) struct file *fp; - struct proc *p; + struct thread *td; { - return ((*fp->f_ops->fo_close)(fp, p)); + return ((*fp->f_ops->fo_close)(fp, td)); } static __inline int diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index feebb62..3c1cb8d 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -125,16 +125,16 @@ struct sigio { SLIST_HEAD(sigiolst, sigio); #ifdef _KERNEL -int closef __P((struct file *fp, struct proc *p)); -int dupfdopen __P((struct proc *p, struct filedesc *fdp, int indx, int dfd, int mode, +int closef __P((struct file *fp, struct thread *p)); +int dupfdopen __P((struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error)); -int falloc __P((struct proc *p, struct file **resultfp, int *resultfd)); -int fdalloc __P((struct proc *p, int want, int *result)); -int fdavail __P((struct proc *p, int n)); -void fdcloseexec __P((struct proc *p)); -struct filedesc *fdcopy __P((struct proc *p)); -void fdfree __P((struct proc *p)); -struct filedesc *fdinit __P((struct proc *p)); +int falloc __P((struct thread *p, struct file **resultfp, int *resultfd)); +int fdalloc __P((struct thread *p, int want, int *result)); +int fdavail __P((struct thread *td, int n)); +void fdcloseexec __P((struct thread *td)); +struct filedesc *fdcopy __P((struct thread *td)); +void fdfree __P((struct thread *td)); +struct filedesc *fdinit __P((struct thread *td)); struct filedesc *fdshare __P((struct proc *p)); void ffree __P((struct file *fp)); pid_t fgetown __P((struct sigio *sigio)); @@ -143,7 +143,7 @@ void funsetown __P((struct sigio *sigio)); void funsetownlst __P((struct sigiolst *sigiolst)); struct file *holdfp __P((struct filedesc *fdp, int fd, int flag)); int getvnode __P((struct filedesc *fdp, int fd, struct file **fpp)); -void setugidsafety __P((struct proc *p)); +void setugidsafety __P((struct thread *td)); #endif /* _KERNEL */ diff --git a/sys/sys/imgact_aout.h b/sys/sys/imgact_aout.h index ed276c6..39d6baf 100644 --- a/sys/sys/imgact_aout.h +++ b/sys/sys/imgact_aout.h @@ -148,9 +148,9 @@ struct exec { #define EX_DPMASK 0x30 /* mask for the above */ #ifdef _KERNEL -struct proc; +struct thread; -int aout_coredump __P((struct proc *p, struct vnode *vp, off_t limit)); +int aout_coredump __P((struct thread *td, struct vnode *vp, off_t limit)); #endif #endif /* !_IMGACT_AOUT_H_ */ diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index 0753122..b50f6e8 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -103,9 +103,9 @@ int elf_remove_brand_entry __P((Elf64_Brandinfo *entry)); #endif /* ELF_TARG_CLASS == ELFCLASS32 */ -struct proc; +struct thread; -int elf_coredump __P((struct proc *, struct vnode *, off_t)); +int elf_coredump __P((struct thread *, struct vnode *, off_t)); #endif /* _KERNEL */ diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h index 527a5e6..fda8495 100644 --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -63,7 +63,7 @@ struct intrhand { */ struct ithd { struct mtx it_lock; - struct proc *it_proc; /* Interrupt process. */ + struct thread *it_td; /* Interrupt process. */ LIST_ENTRY(ithd) it_list; /* All interrupt threads. */ TAILQ_HEAD(, intrhand) it_handlers; /* Interrupt handlers. */ struct ithd *it_interrupted; /* Who we interrupted. */ diff --git a/sys/sys/ipc.h b/sys/sys/ipc.h index 1a153c5..463a541 100644 --- a/sys/sys/ipc.h +++ b/sys/sys/ipc.h @@ -82,9 +82,10 @@ struct ipc_perm { #define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff) #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff)) +struct thread; struct proc; -int ipcperm __P((struct proc *, struct ipc_perm *, int)); +int ipcperm __P((struct thread *, struct ipc_perm *, int)); extern void (*semexit_hook)(struct proc *); extern void (*shmfork_hook)(struct proc *, struct proc *); extern void (*shmexit_hook)(struct proc *); diff --git a/sys/sys/kthread.h b/sys/sys/kthread.h index 91d59eb..279f597 100644 --- a/sys/sys/kthread.h +++ b/sys/sys/kthread.h @@ -47,8 +47,8 @@ void kproc_start __P((const void *)); int kthread_create __P((void (*)(void *), void *, struct proc **, int flags, const char *, ...)) __printflike(5, 6); void kthread_exit __P((int)) __dead2; -int kthread_resume __P((struct proc *)); -int kthread_suspend __P((struct proc *, int)); -void kthread_suspend_check __P((struct proc *)); +int kthread_resume __P((struct proc *)); /* XXXKSE */ +int kthread_suspend __P((struct proc *, int)); /* XXXKSE */ +void kthread_suspend_check __P((struct proc *)); /* XXXKSE */ #endif /* !_SYS_KTHREAD_H_ */ diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 41556cc..1ecbcf8 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -110,21 +110,21 @@ struct specinfo { struct bio; struct buf; -struct proc; +struct thread; struct uio; struct knote; -typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p)); -typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p)); +typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct thread *td)); +typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct thread *td)); typedef void d_strategy_t __P((struct bio *bp)); typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data, - int fflag, struct proc *p)); + int fflag, struct thread *td)); typedef int d_dump_t __P((dev_t dev)); typedef int d_psize_t __P((dev_t dev)); typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag)); typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag)); -typedef int d_poll_t __P((dev_t dev, int events, struct proc *p)); +typedef int d_poll_t __P((dev_t dev, int events, struct thread *td)); typedef int d_kqfilter_t __P((dev_t dev, struct knote *kn)); typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot)); @@ -133,7 +133,7 @@ typedef int l_close_t __P((struct tty *tp, int flag)); typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag)); typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag)); typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data, - int flag, struct proc *p)); + int flag, struct thread *td)); typedef int l_rint_t __P((int c, struct tty *tp)); typedef int l_start_t __P((struct tty *tp)); typedef int l_modem_t __P((struct tty *tp, int flag)); diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 6e6f7e6..081c6ce 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -182,7 +182,7 @@ void witness_unlock(struct lock_object *, int, const char *, int); void witness_save(struct lock_object *, const char **, int *); void witness_restore(struct lock_object *, const char *, int); int witness_list_locks(struct lock_list_entry **); -int witness_list(struct proc *); +int witness_list(struct thread *); int witness_sleep(int, struct lock_object *, const char *, int); void witness_assert(struct lock_object *, int, const char *, int); diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h index 477ef50..0b4ca9d 100644 --- a/sys/sys/lockmgr.h +++ b/sys/sys/lockmgr.h @@ -196,7 +196,7 @@ struct lock { #endif /* INVARIANTS */ void dumplockinfo(struct lock *lkp); -struct proc; +struct thread; void lockinit __P((struct lock *, int prio, char *wmesg, int timo, int flags)); @@ -204,7 +204,7 @@ void lockdestroy __P((struct lock *)); #ifdef DEBUG_LOCKS int debuglockmgr __P((struct lock *, u_int flags, - struct mtx *, struct proc *p, + struct mtx *, struct thread *p, const char *, const char *, int)); @@ -213,10 +213,10 @@ int debuglockmgr __P((struct lock *, u_int flags, "lockmgr", __FILE__, __LINE__) #else int lockmgr __P((struct lock *, u_int flags, - struct mtx *, struct proc *p)); + struct mtx *, struct thread *p)); #endif void lockmgr_printinfo __P((struct lock *)); -int lockstatus __P((struct lock *, struct proc *)); +int lockstatus __P((struct lock *, struct thread *)); int lockcount __P((struct lock *)); #endif /* !_SYS_LOCKMGR_H_ */ diff --git a/sys/sys/mount.h b/sys/sys/mount.h index e2d53ab..f3975ca 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -328,18 +328,18 @@ struct mount_args; struct vfsops { int (*vfs_mount) __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); int (*vfs_start) __P((struct mount *mp, int flags, - struct proc *p)); + struct thread *td)); int (*vfs_unmount) __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); int (*vfs_root) __P((struct mount *mp, struct vnode **vpp)); int (*vfs_quotactl) __P((struct mount *mp, int cmds, uid_t uid, - caddr_t arg, struct proc *p)); + caddr_t arg, struct thread *td)); int (*vfs_statfs) __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); int (*vfs_sync) __P((struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); int (*vfs_vget) __P((struct mount *mp, ino_t ino, struct vnode **vpp)); int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp, @@ -352,7 +352,7 @@ struct vfsops { int (*vfs_extattrctl) __P((struct mount *mp, int cmd, struct vnode *filename_vp, int attrnamespace, const char *attrname, - struct proc *p)); + struct thread *td)); }; #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ @@ -394,15 +394,15 @@ extern char *mountrootfsname; /* * exported vnode operations */ -int dounmount __P((struct mount *, int, struct proc *)); -int vfs_mount __P((struct proc *p, const char *type, char *path, +int dounmount __P((struct mount *, int, struct thread *td)); +int vfs_mount __P((struct thread *td, const char *type, char *path, int flags, void *data)); int vfs_setpublicfs /* set publicly exported fs */ __P((struct mount *, struct netexport *, struct export_args *)); int vfs_lock __P((struct mount *)); /* lock a vfs */ void vfs_msync __P((struct mount *, int)); void vfs_unlock __P((struct mount *)); /* unlock a vfs */ -int vfs_busy __P((struct mount *, int, struct mtx *, struct proc *)); +int vfs_busy __P((struct mount *, int, struct mtx *, struct thread *td)); int vfs_export /* process mount export info */ __P((struct mount *, struct export_args *)); struct netcred *vfs_export_lookup /* lookup host in fs export list */ @@ -414,7 +414,7 @@ struct mount *vfs_getvfs __P((fsid_t *)); /* return vfs given fsid */ int vfs_modevent __P((module_t, int, void *)); int vfs_mountedon __P((struct vnode *)); /* is a vfs mounted on vp */ int vfs_rootmountalloc __P((char *, char *, struct mount **)); -void vfs_unbusy __P((struct mount *, struct proc *)); +void vfs_unbusy __P((struct mount *, struct thread *td)); void vfs_unmountall __P((void)); int vfs_register __P((struct vfsconf *)); int vfs_unregister __P((struct vfsconf *)); @@ -428,15 +428,15 @@ extern struct nfs_public nfs_pub; * functions or casting entries in the VFS op table to "enopnotsupp()". */ int vfs_stdmount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); -int vfs_stdstart __P((struct mount *mp, int flags, struct proc *p)); -int vfs_stdunmount __P((struct mount *mp, int mntflags, struct proc *p)); + struct nameidata *ndp, struct thread *td)); +int vfs_stdstart __P((struct mount *mp, int flags, struct thread *td)); +int vfs_stdunmount __P((struct mount *mp, int mntflags, struct thread *td)); int vfs_stdroot __P((struct mount *mp, struct vnode **vpp)); int vfs_stdquotactl __P((struct mount *mp, int cmds, uid_t uid, - caddr_t arg, struct proc *p)); -int vfs_stdstatfs __P((struct mount *mp, struct statfs *sbp, struct proc *p)); + caddr_t arg, struct thread *td)); +int vfs_stdstatfs __P((struct mount *mp, struct statfs *sbp, struct thread *td)); int vfs_stdsync __P((struct mount *mp, int waitfor, struct ucred *cred, - struct proc *p)); + struct thread *td)); int vfs_stdvget __P((struct mount *mp, ino_t ino, struct vnode **vpp)); int vfs_stdfhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp)); int vfs_stdcheckexp __P((struct mount *mp, struct sockaddr *nam, @@ -446,7 +446,7 @@ int vfs_stdinit __P((struct vfsconf *)); int vfs_stduninit __P((struct vfsconf *)); int vfs_stdextattrctl __P((struct mount *mp, int cmd, struct vnode *filename_vp, int attrnamespace, const char *attrname, - struct proc *p)); + struct thread *td)); /* XXX - these should be indirect functions!!! */ int softdep_process_worklist __P((struct mount *)); diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 9137eac..b7c51b6 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -259,10 +259,10 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); #endif #define __mtx_lock_flags(m, opts, file, line) do { \ - MPASS(curproc != NULL); \ + MPASS(curthread != NULL); \ KASSERT(((opts) & MTX_NOSWITCH) == 0, \ ("MTX_NOSWITCH used at %s:%d", (file), (line))); \ - _get_sleep_lock((m), curproc, (opts), (file), (line)); \ + _get_sleep_lock((m), curthread, (opts), (file), (line)); \ LOCK_LOG_LOCK("LOCK", &(m)->mtx_object, opts, m->mtx_recurse, \ (file), (line)); \ WITNESS_LOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, (file), \ @@ -270,8 +270,8 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); } while (0) #define __mtx_lock_spin_flags(m, opts, file, line) do { \ - MPASS(curproc != NULL); \ - _get_spin_lock((m), curproc, (opts), (file), (line)); \ + MPASS(curthread != NULL); \ + _get_spin_lock((m), curthread, (opts), (file), (line)); \ LOCK_LOG_LOCK("LOCK", &(m)->mtx_object, opts, m->mtx_recurse, \ (file), (line)); \ WITNESS_LOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, (file), \ @@ -279,17 +279,17 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); } while (0) #define __mtx_unlock_flags(m, opts, file, line) do { \ - MPASS(curproc != NULL); \ + MPASS(curthread != NULL); \ mtx_assert((m), MA_OWNED); \ WITNESS_UNLOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, \ (file), (line)); \ LOCK_LOG_LOCK("UNLOCK", &(m)->mtx_object, (opts), \ (m)->mtx_recurse, (file), (line)); \ - _rel_sleep_lock((m), curproc, (opts), (file), (line)); \ + _rel_sleep_lock((m), curthread, (opts), (file), (line)); \ } while (0) #define __mtx_unlock_spin_flags(m, opts, file, line) do { \ - MPASS(curproc != NULL); \ + MPASS(curthread != NULL); \ mtx_assert((m), MA_OWNED); \ WITNESS_UNLOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, \ (file), (line)); \ @@ -303,7 +303,7 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); #define mtx_initialized(m) ((m)->mtx_object.lo_flags & LO_INITIALIZED) -#define mtx_owned(m) (((m)->mtx_lock & MTX_FLAGMASK) == (uintptr_t)curproc) +#define mtx_owned(m) (((m)->mtx_lock & MTX_FLAGMASK) == (uintptr_t)curthread) #define mtx_recursed(m) ((m)->mtx_recurse != 0) diff --git a/sys/sys/namei.h b/sys/sys/namei.h index 1d50937..69daed1 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -81,7 +81,7 @@ struct nameidata { */ u_long cn_nameiop; /* namei operation */ u_long cn_flags; /* flags to namei */ - struct proc *cn_proc; /* process requesting lookup */ + struct thread *cn_thread;/* thread requesting lookup */ struct ucred *cn_cred; /* credentials */ /* * Shared between lookup and commit routines. @@ -142,24 +142,25 @@ struct nameidata { #define ISUNICODE 0x100000 /* current component name is unicode*/ #define PDIRUNLOCK 0x200000 /* file system lookup() unlocked parent dir */ #define PARAMASK 0x1fff00 /* mask of parameter descriptors */ + /* * Initialization of an nameidata structure. */ static void NDINIT __P((struct nameidata *, u_long, u_long, enum uio_seg, - const char *, struct proc *)); + const char *, struct thread *)); static __inline void -NDINIT(ndp, op, flags, segflg, namep, p) +NDINIT(ndp, op, flags, segflg, namep, td) struct nameidata *ndp; u_long op, flags; enum uio_seg segflg; const char *namep; - struct proc *p; + struct thread *td; { ndp->ni_cnd.cn_nameiop = op; ndp->ni_cnd.cn_flags = flags; ndp->ni_segflg = segflg; ndp->ni_dirp = namep; - ndp->ni_cnd.cn_proc = p; + ndp->ni_cnd.cn_thread = td; } #define NDF_NO_DVP_RELE 0x00000001 diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h index 232435a..626d6d8 100644 --- a/sys/sys/posix4.h +++ b/sys/sys/posix4.h @@ -47,12 +47,12 @@ */ struct proc; struct nosys_args; -extern int syscall_not_present(struct proc *, const char *, struct nosys_args *); +extern int syscall_not_present(struct thread *, const char *, struct nosys_args *); #define SYSCALL_NOT_PRESENT_GEN(SC) \ -int SC (struct proc *p, struct SC##_args *uap) \ +int SC (struct thread *td, struct SC##_args *uap) \ { \ - return syscall_not_present(p, #SC , (struct nosys_args *)uap); \ + return syscall_not_present(td, #SC , (struct nosys_args *)uap); \ } @@ -95,13 +95,13 @@ int ksched_attach(struct ksched **); int ksched_detach(struct ksched *); int ksched_setparam(register_t *, struct ksched *, - struct proc *, const struct sched_param *); + struct thread *, const struct sched_param *); int ksched_getparam(register_t *, struct ksched *, - struct proc *, struct sched_param *); + struct thread *, struct sched_param *); int ksched_setscheduler(register_t *, struct ksched *, - struct proc *, int, const struct sched_param *); -int ksched_getscheduler(register_t *, struct ksched *, struct proc *); + struct thread *, int, const struct sched_param *); +int ksched_getscheduler(register_t *, struct ksched *, struct thread *); int ksched_yield(register_t *, struct ksched *); @@ -109,7 +109,7 @@ int ksched_get_priority_max(register_t *, struct ksched *, int); int ksched_get_priority_min(register_t *, struct ksched *, int); int ksched_rr_get_interval(register_t *, struct ksched *, - struct proc *, struct timespec *); + struct thread *, struct timespec *); #endif /* _KPOSIX_PRIORITY_SCHEDULING */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0a321a5..dd53274 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -142,132 +142,301 @@ struct ithd; struct nlminfo; struct trapframe; -struct proc { - TAILQ_ENTRY(proc) p_procq; /* (j) Run/mutex queue. */ - TAILQ_ENTRY(proc) p_slpq; /* (j) Sleep queue. */ - LIST_ENTRY(proc) p_list; /* (d) List of all processes. */ +/* + * Here we define the four structures used for process information. + * + * The first is the thread. It might be though of as a "Kernel + * Schedulable Entity Context". + * This structure contains all the information as to where a thread of + * execution is now, or was when it was suspended, why it was suspended, + * and anything else that will be needed to restart it when it is + * rescheduled. Always associated with a KSE when running, but can be + * reassigned to an equivalent KSE when being restarted for + * load balancing. Each of these is associated with a kernel stack + * and a pcb. + * + * It is important to remember that a particular thread structure only + * exists as long as the system call or kernel entrance (e.g. by pagefault) + * which it is currently executing. It should threfore NEVER be referenced + * by pointers in long lived structures that live longer than a single + * request. If several threads complete their work at the same time, + * they will all rewind their stacks to the uer boundary, report their + * completion state, and all but one will be freed. That last one will + * be kept to provide a kernel stack and pcb for the NEXT syscall or kernel + * entrance. (basically to save freeing and then re-allocating it) A process + * might keep a cache of threads available to allow it to quickly + * get one when it needs a new one. There would probably also be a system + * cache of free threads. + */ +struct thread; + +/* + * The second structure is the Kernel Schedulable Entity. (KSE) + * As long as this is scheduled, it will continue to run any threads that + * are assigned to it or the KSEGRP (see later) until either it runs out + * of runnable threads or CPU. + * It runs on one CPU and is assigned a quantum of time. When a thread is + * blocked, The KSE continues to run and will search for another thread + * in a runnable state amongst those it has. It May decide to return to user + * mode with a new 'empty' thread if there are no runnable threads. + * threads are associated with a KSE for cache reasons, but a sheduled KSE with + * no runnable thread will try take a thread from a sibling KSE before + * surrendering its quantum. In some schemes it gets it's quantum from the KSEG + * and contributes to draining that quantum, along withthe other KSEs in + * the group. (undecided) + */ +struct kse; - /* substructures: */ - struct ucred *p_ucred; /* (c + k) Process owner's identity. */ - struct filedesc *p_fd; /* (b) Ptr to open files structure. */ - struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */ - struct plimit *p_limit; /* (m) Process limits. */ - struct vm_object *p_upages_obj;/* (a) Upages object. */ - struct procsig *p_procsig; /* (c) Signal actions, state (CPU). */ -#define p_sigacts p_procsig->ps_sigacts -#define p_sigignore p_procsig->ps_sigignore -#define p_sigcatch p_procsig->ps_sigcatch +/* + * The KSEGRP is allocated resources across a number of CPUs. + * (Including a number of CPUxQUANTA. It parcels these QUANTA up among + * Its KSEs, each of which should be running in a different CPU. + * Priority and total available sheduled quanta are properties of a KSEGRP. + * Multiple KSEGRPs in a single process compete against each other + * for total quanta in the same way that a forked child competes against + * it's parent process. + */ +struct ksegrp; -#define p_rlimit p_limit->pl_rlimit +/* + * A process is the owner of all system resources allocated to a task + * except CPU quanta. + * All KSEGs under one process see, and have the same access to, these + * resources (e.g. files, memory, sockets, permissions kqueues). + * A process may compete for CPU cycles on the same basis as a + * forked process cluster by spawning several KSEGRPs. + */ +struct proc; + +/*************** + * In pictures: + With a single run queue used by all processors: + + RUNQ: --->KSE---KSE--... SLEEPQ:[]---THREAD---THREAD---THREAD + | / []---THREAD + KSEG---THREAD--THREAD--THREAD [] + []---THREAD---THREAD + + (processors run THREADs from the KSEG until they are exhausted or + the KSEG exhausts its quantum) + +With PER-CPU run queues: +KSEs on the separate run queues directly +They would be given priorities calculated from the KSEG. + + * + *****************/ + +/* + * Kernel runnable context (thread). + * This is what is put to sleep and reactivated. + * The first KSE available in the correct group will run this thread. + * If several are available, use the one on the same CPU as last time. + */ +struct thread { + struct proc *td_proc; /* Associated process. */ + struct ksegrp *td_ksegrp; /* Associated KSEG. */ + struct kse *td_last_kse; /* Where it wants to be if possible */ + struct kse *td_kse; /* and is now if running */ + + TAILQ_ENTRY(thread) td_plist; /* All threads in this proc */ + TAILQ_ENTRY(thread) td_kglist; /* All threads in this ksegrp */ + + /* The two queues below should someday be merged */ + TAILQ_ENTRY(thread) td_slpq; /* (j) Sleep queue. XXXKSE */ + TAILQ_ENTRY(thread) td_blkq; /* (j) mutex queue. XXXKSE */ + TAILQ_ENTRY(thread) td_runq; /* (j) run queue(s). XXXKSE */ + +#define td_startzero td_flags + int td_flags; /* (c) P_* flags. */ + int td_dupfd; /* (c) ret value from fdopen. XXX */ + void *td_wchan; /* (j) Sleep address. */ + const char *td_wmesg; /* (j) Reason for sleep. */ + u_char td_lastcpu; /* (j) Last cpu we were on. */ + short td_locks; /* (*) DEBUG: lockmgr count of locks */ + struct mtx *td_blocked; /* (j) Mutex process is blocked on. */ + struct ithd *td_ithd; /* (b) For interrupt threads only. */ + const char *td_mtxname; /* (j) Name of mutex blocked on. */ + LIST_HEAD(, mtx) td_contested; /* (j) Contested locks. */ + struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */ + int td_intr_nesting_level; /* (k) Interrupt recursion. */ +#define td_endzero td_md + +#define td_startcopy td_endzero + /* XXXKSE p_md is in the "on your own" section in old struct proc */ + struct mdthread td_md; /* (k) Any machine-dependent fields. */ + register_t td_retval[2]; /* (k) Syscall aux returns. */ +#define td_endcopy td_pcb + + struct pcb *td_pcb; /* (k) Kv addr of pcb and kstack. */ + struct callout td_slpcallout; /* (h) Callout for sleep. */ + struct trapframe *td_frame; /* (k) */ + struct vm_object *td_kstack_obj;/* (a) kstack object. */ + vm_offset_t td_kstack; /* kstack mapped address */ +}; +#define TDF_ONRUNQ 0x00000001 /* This KE is on a run queue */ + +/* + * The schedulable entity that can be given a context to run. + * A process may have several of these. Probably one per processor + * but posibly a few more. In this universe they are grouped + * with a KSEG that contains the priority and niceness + * for the group. + */ +struct kse { + struct proc *ke_proc; /* Associated process. */ + struct ksegrp *ke_ksegrp; /* Associated KSEG. */ + struct thread *ke_thread; /* Associated thread, if running. */ + TAILQ_ENTRY(kse) ke_kglist; /* Queue of all KSEs in ke_ksegrp. */ + TAILQ_ENTRY(kse) ke_kgrlist; /* Queue of all KSEs in this state. */ + TAILQ_ENTRY(kse) ke_procq; /* (j) Run queue. */ + TAILQ_HEAD(, thread) ke_runq; /* (td_runq) RUNNABLE bound to KSE. */ + +#define ke_startzero ke_flags + int ke_flags; /* (c) P_* flags. */ + /*u_int ke_estcpu; */ /* (j) Time averaged val of cpticks. */ + int ke_cpticks; /* (j) Ticks of cpu time. */ + fixpt_t ke_pctcpu; /* (j) %cpu during p_swtime. */ + u_int64_t ke_uu; /* (j) Previous user time in usec. */ + u_int64_t ke_su; /* (j) Previous system time in usec. */ + u_int64_t ke_iu; /* (j) Previous intr time in usec. */ + u_int64_t ke_uticks; /* (j) Statclock hits in user mode. */ + u_int64_t ke_sticks; /* (j) Statclock hits in system mode. */ + u_int64_t ke_iticks; /* (j) Statclock hits in intr. */ + u_char ke_oncpu; /* (j) Which cpu we are on. */ + u_int ke_slptime; /* (j) Time since last idle. */ + char ke_rqindex; /* (j) Run queue index. */ +#define ke_endzero ke_priority + +#define ke_startcopy ke_endzero + u_char ke_priority; /* (j) Process priority. */ + u_char ke_usrpri; /* (j) User pri from cpu & nice. */ +#define ke_endcopy ke_end + + int ke_end; /* dummy entry */ +}; + +/* + * Kernel-scheduled entity group (KSEG). The scheduler considers each KSEG to + * be an indivisible unit from a time-sharing perspective, though each KSEG may + * contain multiple KSEs. + */ +struct ksegrp { + struct proc *kg_proc; /* Process that contains this KSEG. */ + TAILQ_ENTRY(ksegrp) kg_ksegrp; /* Queue of KSEGs in kg_proc. */ + TAILQ_HEAD(, kse) kg_kseq; /* (ke_kglist) All KSEs */ + TAILQ_HEAD(, kse) kg_rq; /* (ke_kgrlist) Runnable KSEs */ + TAILQ_HEAD(, kse) kg_iq; /* (ke_kgrlist) Idle KSEs */ + TAILQ_HEAD(, thread) kg_threads;/* (td_kglist) All threads. */ + TAILQ_HEAD(, thread) kg_runq; /* (td_runq)unbound RUNNABLE threads */ + TAILQ_HEAD(, thread) kg_slpq; /* (td_runq)NONRUNNABLE threads. */ + +#define kg_startzero kg_estcpu + u_int kg_slptime; /* (j) how long completely blocked. */ + u_int kg_estcpu; /* sum of the same field in kses */ +#define kg_endzero kg_pri + +#define kg_startcopy kg_endzero + struct priority kg_pri; /* (j) Process priority. */ + char kg_nice; /* (j?/k?) Process "nice" value. */ + struct rtprio kg_rtprio; /* (j) Realtime priority. */ +#define kg_endcopy kg_runnable + + int kg_runnable; /* # runnable threads on queue */ + int kg_runq_kses; /* # kse's on runq. */ + int kg_kses; /* # kse's in group. */ +}; - int p_flag; /* (c) P_* flags. */ - int p_sflag; /* (j) PS_* flags. */ - int p_stat; /* (j) S* process status. */ +/* + * The old fashionned process. May have multiple threads, KSEGRPs + * and KSEs. Starts off with a single embedded KSEGRP, KSE and THREAD. + */ +struct proc { + LIST_ENTRY(proc) p_list; /* (d) List of all processes. */ + TAILQ_HEAD(, ksegrp) p_ksegrps; /* (kg_ksegrp) All KSEGs. */ + TAILQ_HEAD(, thread) p_threads; /* (td_plist) threads. (shortcut) */ + struct ucred *p_ucred; /* (c + k) Process owner's identity. */ + struct filedesc *p_fd; /* (b) Ptr to open files structure. */ + /* accumulated stats for all KSEs? */ + struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */ + struct plimit *p_limit; /* (m) Process limits. */ + struct vm_object *p_upages_obj; /* (a) Upages object. */ + struct procsig *p_procsig; /* (c) Signal actions, state (CPU). */ + + struct ksegrp p_ksegrp; + struct kse p_kse; + struct thread p_thread; + + /* + * The following don't make too much sense.. + * See the td_ or ke_ versions of the same flags + */ + int p_flag; /* (c) P_* flags. */ + int p_sflag; /* (j) PS_* flags. */ + int p_stat; /* (j) S* process status. */ pid_t p_pid; /* (b) Process identifier. */ LIST_ENTRY(proc) p_hash; /* (d) Hash chain. */ LIST_ENTRY(proc) p_pglist; /* (c) List of processes in pgrp. */ - struct proc *p_pptr; /* (c + e) Pointer to parent process. */ + struct proc *p_pptr; /* (c + e) Pointer to parent process. */ LIST_ENTRY(proc) p_sibling; /* (e) List of sibling processes. */ LIST_HEAD(, proc) p_children; /* (e) Pointer to list of children. */ /* The following fields are all zeroed upon creation in fork. */ #define p_startzero p_oppid - - pid_t p_oppid; /* (c + e) Save parent pid during ptrace. XXX */ - int p_dupfd; /* (c) Sideways ret value from fdopen. XXX */ - struct vmspace *p_vmspace; /* (b) Address space. */ - - /* scheduling */ - u_int p_estcpu; /* (j) Time averaged value of p_cpticks. */ - int p_cpticks; /* (j) Ticks of cpu time. */ - fixpt_t p_pctcpu; /* (j) %cpu during p_swtime. */ - struct callout p_slpcallout; /* (h) Callout for sleep. */ - void *p_wchan; /* (j) Sleep address. */ - const char *p_wmesg; /* (j) Reason for sleep. */ - u_int p_swtime; /* (j) Time swapped in or out. */ - u_int p_slptime; /* (j) Time since last blocked. */ - - struct callout p_itcallout; /* (h) Interval timer callout. */ - struct itimerval p_realtimer; /* (h?/k?) Alarm timer. */ - u_int64_t p_runtime; /* (j) Real time in microsec. */ - u_int64_t p_uu; /* (j) Previous user time in microsec. */ - u_int64_t p_su; /* (j) Previous system time in microsec. */ - u_int64_t p_iu; /* (j) Previous interrupt time in microsec. */ - u_int64_t p_uticks; /* (j) Statclock hits in user mode. */ - u_int64_t p_sticks; /* (j) Statclock hits in system mode. */ - u_int64_t p_iticks; /* (j) Statclock hits processing intr. */ - - int p_traceflag; /* (j?) Kernel trace points. */ - struct vnode *p_tracep; /* (j?) Trace to vnode. */ - - sigset_t p_siglist; /* (c) Signals arrived but not delivered. */ - - struct vnode *p_textvp; /* (b) Vnode of executable. */ - - struct mtx p_mtx; /* (k) Lock for this struct. */ - char p_lock; /* (c) Process lock (prevent swap) count. */ - u_char p_oncpu; /* (j) Which cpu we are on. */ - u_char p_lastcpu; /* (j) Last cpu we were on. */ - char p_rqindex; /* (j) Run queue index. */ - - short p_locks; /* (*) DEBUG: lockmgr count of held locks */ - u_int p_stops; /* (c) Procfs event bitmask. */ - u_int p_stype; /* (c) Procfs stop event type. */ - char p_step; /* (c) Procfs stop *once* flag. */ - u_char p_pfsflags; /* (c) Procfs flags. */ - char p_pad3[2]; /* Alignment. */ - register_t p_retval[2]; /* (k) Syscall aux returns. */ - struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ - int p_sigparent; /* (c) Signal to parent on exit. */ - sigset_t p_oldsigmask; /* (c) Saved mask from before sigpause. */ - int p_sig; /* (n) For core dump/debugger XXX. */ - u_long p_code; /* (n) For core dump/debugger XXX. */ - struct klist p_klist; /* (c) Knotes attached to this process. */ - struct lock_list_entry *p_sleeplocks; /* (k) Held sleep locks. */ - struct mtx *p_blocked; /* (j) Mutex process is blocked on. */ - const char *p_mtxname; /* (j) Name of mutex blocked on. */ - LIST_HEAD(, mtx) p_contested; /* (j) Contested locks. */ - + pid_t p_oppid; /* (c + e) Save ppid in ptrace. XXX */ + struct vmspace *p_vmspace; /* (b) Address space. */ + u_int p_swtime; /* (j) Time swapped in or out. */ + struct itimerval p_realtimer; /* (h?/k?) Alarm timer. */ + u_int64_t p_runtime; /* (j) Real time in microsec. */ + int p_traceflag; /* (j?) Kernel trace points. */ + struct vnode *p_tracep; /* (j?) Trace to vnode. */ + sigset_t p_siglist; /* (c) Sigs arrived, not delivered. */ + struct vnode *p_textvp; /* (b) Vnode of executable. */ + struct mtx p_mtx; /* (k) Lock for this struct. */ + char p_lock; /* (c) Proclock (prevent swap) count. */ + struct klist p_klist; /* (c) Knotes attached to this proc. */ + struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ + int p_sigparent; /* (c) Signal to parent on exit. */ + sigset_t p_oldsigmask; /* (c) Saved mask from pre sigpause. */ + int p_sig; /* (n) For core dump/debugger XXX. */ + u_long p_code; /* (n) For core dump/debugger XXX. */ + u_int p_stops; /* (c) Procfs event bitmask. */ + u_int p_stype; /* (c) Procfs stop event type. */ + char p_step; /* (c) Procfs stop *once* flag. */ + u_char p_pfsflags; /* (c) Procfs flags. */ struct nlminfo *p_nlminfo; /* (?) only used by/for lockd */ - void *p_aioinfo; /* (c) ASYNC I/O info. */ - struct ithd *p_ithd; /* (b) For interrupt threads only. */ - int p_intr_nesting_level; /* (k) Interrupt recursion. */ - + void *p_aioinfo; /* (c) ASYNC I/O info. */ /* End area that is zeroed on creation. */ -#define p_endzero p_startcopy - -/* The following fields are all copied upon creation in fork. */ #define p_startcopy p_sigmask - sigset_t p_sigmask; /* (c) Current signal mask. */ - stack_t p_sigstk; /* (c) Stack pointer and on-stack flag. */ - - int p_magic; /* (b) Magic number. */ - struct priority p_pri; /* (j) Process priority. */ - char p_nice; /* (j?/k?) Process "nice" value. */ - char p_comm[MAXCOMLEN + 1]; /* (b) Process name. */ - - struct pgrp *p_pgrp; /* (e?/c?) Pointer to process group. */ - struct sysentvec *p_sysent; /* (b) System call dispatch information. */ - struct pargs *p_args; /* (c + k) Process arguments. */ - +/* The following fields are all copied upon creation in fork. */ +#define p_endzero p_startcopy + sigset_t p_sigmask; /* (c) Current signal mask. */ + stack_t p_sigstk; /* (c) Stack ptr and on-stack flag. */ + int p_magic; /* (b) Magic number. */ + char p_comm[MAXCOMLEN + 1]; /* (b) Process name. */ + struct pgrp *p_pgrp; /* (e?/c?) Pointer to process group. */ + struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */ + struct pargs *p_args; /* (c + k) Process arguments. */ /* End area that is copied on creation. */ -#define p_endcopy p_addr - - struct user *p_addr; /* (k) Kernel virtual addr of u-area (CPU). */ - struct mdproc p_md; /* (k) Any machine-dependent fields. */ - - u_short p_xstat; /* (c) Exit status for wait; also stop sig. */ - u_short p_acflag; /* (c) Accounting flags. */ - struct rusage *p_ru; /* (a) Exit information. XXX */ - - struct proc *p_peers; /* (c) */ - struct proc *p_leader; /* (c) */ - void *p_emuldata; /* (c) Emulator state data. */ - struct trapframe *p_frame; /* (k) */ +#define p_endcopy p_xstat + + u_short p_xstat; /* (c) Exit status; also stop sig. */ + struct mdproc p_md; /* (k) Any machine-dependent fields. */ + struct callout p_itcallout; /* (h) Interval timer callout. */ + struct user *p_uarea; /* was p_addr. changed to break stuff */ + u_short p_acflag; /* (c) Accounting flags. */ + struct rusage *p_ru; /* (a) Exit information. XXX */ + struct proc *p_peers; /* (c) */ + struct proc *p_leader; /* (c) */ + void *p_emuldata; /* (c) Emulator state data. */ }; +#define p_rlimit p_limit->pl_rlimit +#define p_sigacts p_procsig->ps_sigacts +#define p_sigignore p_procsig->ps_sigignore +#define p_sigcatch p_procsig->ps_sigcatch #define p_session p_pgrp->pg_session #define p_pgid p_pgrp->pg_id @@ -283,25 +452,25 @@ struct proc { #define SMTX 7 /* Blocked on a mutex. */ /* These flags are kept in p_flag. */ +/* In a KSE world some go to a thread or a KSE (*)*/ #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ #define P_CONTROLT 0x00002 /* Has a controlling terminal. */ -#define P_KTHREAD 0x00004 /* Kernel thread. */ +#define P_KTHREAD 0x00004 /* Kernel thread. (*)*/ #define P_NOLOAD 0x00008 /* Ignore during load avg calculations. */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ -#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ #define P_SUGID 0x00100 /* Had set id privileges since last exec. */ #define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */ #define P_TRACED 0x00800 /* Debugged process being traced. */ #define P_WAITED 0x01000 /* Debugging process has waited for child. */ #define P_WEXIT 0x02000 /* Working on exiting. */ #define P_EXEC 0x04000 /* Process called exec. */ +#define P_KSES 0x08000 /* Process is using KSEs. */ /* Should be moved to machine-dependent areas. */ #define P_BUFEXHAUST 0x100000 /* Dirty buffers flush is in progress. */ #define P_COWINPROGRESS 0x400000 /* Snapshot copy-on-write in progress. */ -#define P_DEADLKTREAT 0x800000 /* Lock aquisition - deadlock treatment. */ #define P_JAILED 0x1000000 /* Process is in jail. */ #define P_OLDMASK 0x2000000 /* Need to restore mask after suspend. */ @@ -309,18 +478,24 @@ struct proc { /* These flags are kept in p_sflag and are protected with sched_lock. */ #define PS_INMEM 0x00001 /* Loaded into memory. */ -#define PS_OWEUPC 0x00002 /* Owe process an addupc() call at next ast. */ #define PS_PROFIL 0x00004 /* Has started profiling. */ -#define PS_SINTR 0x00008 /* Sleep is interruptible. */ -#define PS_TIMEOUT 0x00010 /* Timing out during sleep. */ #define PS_ALRMPEND 0x00020 /* Pending SIGVTALRM needs to be posted. */ #define PS_PROFPEND 0x00040 /* Pending SIGPROF needs to be posted. */ -#define PS_CVWAITQ 0x00080 /* Proces is on a cv_waitq (not slpq). */ #define PS_SWAPINREQ 0x00100 /* Swapin request due to wakeup. */ #define PS_SWAPPING 0x00200 /* Process is being swapped. */ -#define PS_ASTPENDING 0x00400 /* Process has a pending ast. */ -#define PS_NEEDRESCHED 0x00800 /* Process needs to yield. */ -#define PS_TIMOFAIL 0x01000 /* Timeout from sleep after we were awake. */ + +#define TDF_SINTR 0x00008 /* Sleep is interruptible. */ +#define TDF_TIMEOUT 0x00010 /* Timing out during sleep. */ +#define TDF_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ +#define TDF_CVWAITQ 0x00080 /* Proces is on a cv_waitq (not slpq). */ +#define TDF_DEADLKTREAT 0x800000 /* Lock aquisition - deadlock treatment. */ + +#define KEF_OWEUPC 0x00002 /* Owe process an addupc() call at next ast. */ +#define KEF_ASTPENDING 0x00400 /* KSE has a pending ast. */ +#define KEF_NEEDRESCHED 0x00800 /* Process needs to yield. */ +#define TDF_TIMOFAIL 0x01000 /* Timeout from sleep after we were awake. */ + +#define KEF_ONRUNQ 0x00000001 /* This KE is on a run queue */ #define P_MAGIC 0xbeefface @@ -333,10 +508,22 @@ MALLOC_DECLARE(M_SUBPROC); MALLOC_DECLARE(M_ZOMBIE); #endif +#define FOREACH_PROC_IN_SYSTEM(p) \ + LIST_FOREACH((p), &allproc, p_list) +#define FOREACH_KSEGRP_IN_PROC(p, kg) \ + TAILQ_FOREACH((kg), &(p)->p_ksegrps, kg_ksegrp) +#define FOREACH_THREAD_IN_GROUP(kg, td) \ + TAILQ_FOREACH((td), &(kg)->kg_threads, td_kglist) +#define FOREACH_KSE_IN_GROUP(kg, ke) \ + TAILQ_FOREACH((ke), &(kg)->kg_kseq, ke_kglist) +#define FOREACH_THREAD_IN_PROC(p, td) \ + TAILQ_FOREACH((td), &(p)->p_threads, td_plist) + static __inline int sigonstack(size_t sp) { - register struct proc *p = curproc; + register struct thread *td = curthread; + struct proc *p = td->td_proc; return ((p->p_flag & P_ALTSTACK) ? #if defined(COMPAT_43) || defined(COMPAT_SUNOS) @@ -352,9 +539,9 @@ sigonstack(size_t sp) * Notify the current process (p) that it has a signal pending, * process as soon as possible. */ -#define signotify(p) do { \ +#define signotify(ke) do { \ mtx_assert(&sched_lock, MA_OWNED); \ - (p)->p_sflag |= PS_ASTPENDING; \ + (ke)->ke_flags |= KEF_ASTPENDING; \ } while (0) /* Handy macro to determine if p1 can mangle p2. */ @@ -429,6 +616,7 @@ extern u_long pgrphash; extern struct sx allproc_lock; extern struct sx proctree_lock; extern struct proc proc0; /* Process slot for swapper. */ +extern struct thread *thread0; /* Primary thread in proc0 */ extern int hogticks; /* Limit on kernel cpu hogs. */ extern int nprocs, maxproc; /* Current and max number of procs. */ extern int maxprocperuid; /* Max procs per uid. */ @@ -439,6 +627,7 @@ extern int sched_quantum; /* Scheduling quantum in ticks. */ LIST_HEAD(proclist, proc); TAILQ_HEAD(procqueue, proc); +TAILQ_HEAD(threadqueue, thread); extern struct proclist allproc; /* List of all processes. */ extern struct proclist zombproc; /* List of zombie processes. */ extern struct proc *initproc, *pageproc; /* Process slots for init, pager. */ @@ -465,14 +654,14 @@ struct pgrp *pgfind __P((pid_t)); /* Find process group by id. */ struct proc *zpfind __P((pid_t)); /* Find zombie process by id. */ void ast __P((struct trapframe *framep)); -struct proc *chooseproc __P((void)); +struct thread *choosethread __P((void)); int enterpgrp __P((struct proc *p, pid_t pgid, int mksess)); void faultin __P((struct proc *p)); void fixjobc __P((struct proc *p, struct pgrp *pgrp, int entering)); -int fork1 __P((struct proc *, int, struct proc **)); +int fork1 __P((struct thread *, int, struct proc **)); void fork_exit __P((void (*)(void *, struct trapframe *), void *, struct trapframe *)); -void fork_return __P((struct proc *, struct trapframe *)); +void fork_return __P((struct thread *, struct trapframe *)); int inferior __P((struct proc *p)); int leavepgrp __P((struct proc *p)); void mi_switch __P((void)); @@ -482,32 +671,33 @@ int p_cansched __P((struct proc *p1, struct proc *p2)); int p_cansignal __P((struct proc *p1, struct proc *p2, int signum)); int p_trespass __P((struct proc *p1, struct proc *p2)); void procinit __P((void)); +void proc_linkup __P((struct proc *p)); void proc_reparent __P((struct proc *child, struct proc *newparent)); int procrunnable __P((void)); -void remrunqueue __P((struct proc *)); -void resetpriority __P((struct proc *)); +void remrunqueue __P((struct thread *)); +void resetpriority __P((struct ksegrp *)); int roundrobin_interval __P((void)); -void schedclock __P((struct proc *)); -void setrunnable __P((struct proc *)); -void setrunqueue __P((struct proc *)); +void schedclock __P((struct thread *)); +void setrunnable __P((struct thread *)); +void setrunqueue __P((struct thread *)); void setsugid __P((struct proc *p)); void sleepinit __P((void)); void stopevent __P((struct proc *, u_int, u_int)); void cpu_idle __P((void)); void cpu_switch __P((void)); void cpu_throw __P((void)) __dead2; -void unsleep __P((struct proc *)); -void updatepri __P((struct proc *)); -void userret __P((struct proc *, struct trapframe *, u_int)); -void maybe_resched __P((struct proc *)); - -void cpu_exit __P((struct proc *)); -void exit1 __P((struct proc *, int)) __dead2; -void cpu_fork __P((struct proc *, struct proc *, int)); -void cpu_set_fork_handler __P((struct proc *, void (*)(void *), void *)); +void unsleep __P((struct thread *)); +void updatepri __P((struct thread *)); +void userret __P((struct thread *, struct trapframe *, u_int)); +void maybe_resched __P((struct ksegrp *)); + +void cpu_exit __P((struct thread *)); +void exit1 __P((struct thread *, int)) __dead2; +void cpu_fork __P((struct thread *, struct proc *, int)); +void cpu_set_fork_handler __P((struct thread *, void (*)(void *), void *)); int trace_req __P((struct proc *)); void cpu_wait __P((struct proc *)); -int cpu_coredump __P((struct proc *, struct vnode *, struct ucred *)); +int cpu_coredump __P((struct thread *, struct vnode *, struct ucred *)); #endif /* _KERNEL */ #endif /* !_SYS_PROC_H_ */ diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 3bff666..81ff300 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -44,7 +44,7 @@ /* Forward declare these structures referenced from prototypes below. */ struct mbuf; -struct proc; +struct thread; struct sockaddr; struct socket; struct sockopt; @@ -86,7 +86,7 @@ typedef void pr_slowtimo_t (void); typedef void pr_drain_t (void); typedef int pr_usrreq_t(struct socket *, int, struct mbuf *, - struct mbuf *, struct mbuf *, struct proc *); + struct mbuf *, struct mbuf *, struct thread *); struct protosw { short pr_type; /* socket type used for */ @@ -199,17 +199,17 @@ struct pr_usrreqs { int (*pru_abort) __P((struct socket *so)); int (*pru_accept) __P((struct socket *so, struct sockaddr **nam)); int (*pru_attach) __P((struct socket *so, int proto, - struct proc *p)); + struct thread *td)); int (*pru_bind) __P((struct socket *so, struct sockaddr *nam, - struct proc *p)); + struct thread *td)); int (*pru_connect) __P((struct socket *so, struct sockaddr *nam, - struct proc *p)); + struct thread *td)); int (*pru_connect2) __P((struct socket *so1, struct socket *so2)); int (*pru_control) __P((struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p)); + struct ifnet *ifp, struct thread *td)); int (*pru_detach) __P((struct socket *so)); int (*pru_disconnect) __P((struct socket *so)); - int (*pru_listen) __P((struct socket *so, struct proc *p)); + int (*pru_listen) __P((struct socket *so, struct thread *td)); int (*pru_peeraddr) __P((struct socket *so, struct sockaddr **nam)); int (*pru_rcvd) __P((struct socket *so, int flags)); @@ -217,7 +217,7 @@ struct pr_usrreqs { int flags)); int (*pru_send) __P((struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, - struct proc *p)); + struct thread *td)); #define PRUS_OOB 0x1 #define PRUS_EOF 0x2 #define PRUS_MORETOCOME 0x4 @@ -237,22 +237,22 @@ struct pr_usrreqs { int (*pru_sosend) __P((struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, - struct proc *p)); + struct thread *td)); int (*pru_soreceive) __P((struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)); int (*pru_sopoll) __P((struct socket *so, int events, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); }; int pru_accept_notsupp __P((struct socket *so, struct sockaddr **nam)); int pru_connect_notsupp __P((struct socket *so, struct sockaddr *nam, - struct proc *p)); + struct thread *td)); int pru_connect2_notsupp __P((struct socket *so1, struct socket *so2)); int pru_control_notsupp __P((struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct proc *p)); -int pru_listen_notsupp __P((struct socket *so, struct proc *p)); + struct ifnet *ifp, struct thread *td)); +int pru_listen_notsupp __P((struct socket *so, struct thread *td)); int pru_rcvd_notsupp __P((struct socket *so, int flags)); int pru_rcvoob_notsupp __P((struct socket *so, struct mbuf *m, int flags)); int pru_sense_null __P((struct socket *so, struct stat *sb)); diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 77b797d..de4e5e9 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -55,8 +55,8 @@ #include <machine/ptrace.h> /* machine-specific requests, if any */ #ifdef _KERNEL -int ptrace_set_pc __P((struct proc *p, unsigned long addr)); -int ptrace_single_step __P((struct proc *p)); +int ptrace_set_pc __P((struct thread *td, unsigned long addr)); +int ptrace_single_step __P((struct thread *td)); #else /* !_KERNEL */ #include <sys/cdefs.h> diff --git a/sys/sys/resource.h b/sys/sys/resource.h index acc9cd1..2d868f3 100644 --- a/sys/sys/resource.h +++ b/sys/sys/resource.h @@ -135,7 +135,7 @@ struct loadavg { #ifdef _KERNEL extern struct loadavg averunnable; -int dosetrlimit __P((struct proc *, u_int, struct rlimit *)); +int dosetrlimit __P((struct thread *, u_int, struct rlimit *)); #else #include <sys/cdefs.h> diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index 53ceac6..e414de8 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -99,10 +99,12 @@ struct uidinfo { struct mtx ui_mtx; /* protect all counts/limits */ }; +struct thread; +struct kse; struct proc; -void addupc_intr __P((struct proc *p, uintptr_t pc, u_int ticks)); -void addupc_task __P((struct proc *p, uintptr_t pc, u_int ticks)); +void addupc_intr __P((struct kse *ke, uintptr_t pc, u_int ticks)); +void addupc_task __P((struct kse *ke, uintptr_t pc, u_int ticks)); void calcru __P((struct proc *p, struct timeval *up, struct timeval *sp, struct timeval *ip)); int chgproccnt __P((struct uidinfo *uip, int diff, int max)); diff --git a/sys/sys/runq.h b/sys/sys/runq.h index 20286c5..4636e7a 100644 --- a/sys/sys/runq.h +++ b/sys/sys/runq.h @@ -29,6 +29,8 @@ #ifndef _RUNQ_H_ #define _RUNQ_H_ +struct kse; + /* * Run queue parameters. */ @@ -52,7 +54,7 @@ typedef u_int32_t rqb_word_t; /* * Head of run queues. */ -TAILQ_HEAD(rqhead, proc); +TAILQ_HEAD(rqhead, kse); /* * Bit array which maintains the status of a run queue. When a queue is @@ -71,10 +73,10 @@ struct runq { struct rqhead rq_queues[RQ_NQS]; }; -void runq_add(struct runq *, struct proc *); +void runq_add(struct runq *, struct kse *); int runq_check(struct runq *); -struct proc *runq_choose(struct runq *); +struct kse *runq_choose(struct runq *); void runq_init(struct runq *); -void runq_remove(struct runq *, struct proc *); +void runq_remove(struct runq *, struct kse *); #endif diff --git a/sys/sys/selinfo.h b/sys/sys/selinfo.h index f0ca515..cbfa55d 100644 --- a/sys/sys/selinfo.h +++ b/sys/sys/selinfo.h @@ -39,21 +39,23 @@ #include <sys/event.h> /* for struct klist */ +struct thread; /* * Used to maintain information about processes that wish to be * notified when I/O becomes possible. */ struct selinfo { pid_t si_pid; /* process to be notified */ + struct thread *si_thread; /* thread in that process XXXKSE */ struct klist si_note; /* kernel note list */ short si_flags; /* see below */ }; #define SI_COLL 0x0001 /* collision occurred */ #ifdef _KERNEL -struct proc; +struct thread; -void selrecord __P((struct proc *selector, struct selinfo *)); +void selrecord __P((struct thread *selector, struct selinfo *)); void selwakeup __P((struct selinfo *)); #endif diff --git a/sys/sys/shm.h b/sys/sys/shm.h index 444539e..48aa303 100644 --- a/sys/sys/shm.h +++ b/sys/sys/shm.h @@ -79,6 +79,7 @@ struct shminfo { extern struct shminfo shminfo; extern struct shmid_ds *shmsegs; +struct thread; struct proc; void shmexit __P((struct proc *)); diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 97f2513..2ad0960 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -188,6 +188,7 @@ __sigseteq(sigset_t *set1, sigset_t *set2) #ifdef _KERNEL struct pgrp; +struct thread; struct proc; struct sigio; @@ -205,7 +206,7 @@ void pgsigio __P((struct sigio *, int signum, int checkctty)); void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); void postsig __P((int sig)); void psignal __P((struct proc *p, int sig)); -void sigexit __P((struct proc *p, int signum)) __dead2; +void sigexit __P((struct thread *td, int signum)) __dead2; void siginit __P((struct proc *p)); void trapsignal __P((struct proc *p, int sig, u_long code)); diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 1245fd4..f887d08 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -52,7 +52,7 @@ void cpu_mp_announce(void); int cpu_mp_probe(void); void cpu_mp_start(void); -void forward_signal(struct proc *); +void forward_signal(struct thread *); void forward_roundrobin(void); int restart_cpus(u_int); int stop_cpus(u_int); diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 3ce3c28..efd555f 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -267,7 +267,7 @@ struct sockopt { int sopt_name; /* third arg of [gs]etsockopt */ void *sopt_val; /* fourth arg of [gs]etsockopt */ size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */ - struct proc *sopt_p; /* calling process or null if kernel */ + struct thread *sopt_td; /* calling thread or null if kernel */ }; struct sf_buf { @@ -311,15 +311,15 @@ struct knote; * File operations on sockets. */ int soo_read __P((struct file *fp, struct uio *uio, struct ucred *cred, - int flags, struct proc *p)); + int flags, struct thread *td)); int soo_write __P((struct file *fp, struct uio *uio, struct ucred *cred, - int flags, struct proc *p)); -int soo_close __P((struct file *fp, struct proc *p)); + int flags, struct thread *td)); +int soo_close __P((struct file *fp, struct thread *td)); int soo_ioctl __P((struct file *fp, u_long cmd, caddr_t data, - struct proc *p)); + struct thread *td)); int soo_poll __P((struct file *fp, int events, struct ucred *cred, - struct proc *p)); -int soo_stat __P((struct file *fp, struct stat *ub, struct proc *p)); + struct thread *td)); +int soo_stat __P((struct file *fp, struct stat *ub, struct thread *td)); int sokqfilter __P((struct file *fp, struct knote *kn)); /* @@ -345,21 +345,21 @@ void sbflush __P((struct sockbuf *sb)); void sbinsertoob __P((struct sockbuf *sb, struct mbuf *m0)); void sbrelease __P((struct sockbuf *sb, struct socket *so)); int sbreserve __P((struct sockbuf *sb, u_long cc, struct socket *so, - struct proc *p)); + struct thread *td)); void sbtoxsockbuf __P((struct sockbuf *sb, struct xsockbuf *xsb)); int sbwait __P((struct sockbuf *sb)); int sb_lock __P((struct sockbuf *sb)); int soabort __P((struct socket *so)); int soaccept __P((struct socket *so, struct sockaddr **nam)); struct socket *soalloc __P((int waitok)); -int sobind __P((struct socket *so, struct sockaddr *nam, struct proc *p)); +int sobind __P((struct socket *so, struct sockaddr *nam, struct thread *td)); void socantrcvmore __P((struct socket *so)); void socantsendmore __P((struct socket *so)); int soclose __P((struct socket *so)); -int soconnect __P((struct socket *so, struct sockaddr *nam, struct proc *p)); +int soconnect __P((struct socket *so, struct sockaddr *nam, struct thread *td)); int soconnect2 __P((struct socket *so1, struct socket *so2)); int socreate __P((int dom, struct socket **aso, int type, int proto, - struct proc *p)); + struct thread *td)); void sodealloc __P((struct socket *so)); int sodisconnect __P((struct socket *so)); void sofree __P((struct socket *so)); @@ -369,13 +369,13 @@ void soisconnected __P((struct socket *so)); void soisconnecting __P((struct socket *so)); void soisdisconnected __P((struct socket *so)); void soisdisconnecting __P((struct socket *so)); -int solisten __P((struct socket *so, int backlog, struct proc *p)); +int solisten __P((struct socket *so, int backlog, struct thread *td)); struct socket * sodropablereq __P((struct socket *head)); struct socket * sonewconn __P((struct socket *head, int connstatus)); struct socket * - sonewconn3 __P((struct socket *head, int connstatus, struct proc *p)); + sonewconn3 __P((struct socket *head, int connstatus, struct thread *td)); int sooptcopyin __P((struct sockopt *sopt, void *buf, size_t len, size_t minlen)); int sooptcopyout __P((struct sockopt *sopt, void *buf, size_t len)); @@ -386,7 +386,7 @@ int soopt_mcopyin __P((struct sockopt *sopt, struct mbuf *m)); int soopt_mcopyout __P((struct sockopt *sopt, struct mbuf *m)); int sopoll __P((struct socket *so, int events, struct ucred *cred, - struct proc *p)); + struct thread *td)); int soreceive __P((struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)); @@ -394,7 +394,7 @@ int soreserve __P((struct socket *so, u_long sndcc, u_long rcvcc)); void sorflush __P((struct socket *so)); int sosend __P((struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, - struct proc *p)); + struct thread *td)); int sosetopt __P((struct socket *so, struct sockopt *sopt)); int soshutdown __P((struct socket *so, int how)); void sotoxsocket __P((struct socket *so, struct xsocket *xso)); diff --git a/sys/sys/sx.h b/sys/sys/sx.h index 42b269f..f6fef05 100644 --- a/sys/sys/sx.h +++ b/sys/sys/sx.h @@ -43,7 +43,7 @@ struct sx { int sx_shrd_wcnt; /* Number of slock waiters. */ struct cv sx_excl_cv; /* xlock waiters. */ int sx_excl_wcnt; /* Number of xlock waiters. */ - struct proc *sx_xholder; /* Thread presently holding xlock. */ + struct thread *sx_xholder; /* Thread presently holding xlock. */ }; #ifdef _KERNEL @@ -80,7 +80,7 @@ void _sx_downgrade(struct sx *sx, const char *file, int line); witness_assert(&(sx)->sx_object, LA_SLOCKED, file, line) #else #define _SX_ASSERT_LOCKED(sx, file, line) do { \ - KASSERT(((sx)->sx_cnt > 0 || (sx)->sx_xholder == curproc), \ + KASSERT(((sx)->sx_cnt > 0 || (sx)->sx_xholder == curthread), \ ("Lock %s not locked @ %s:%d", (sx)->sx_object.lo_name, \ file, line)); \ } while (0) @@ -96,7 +96,7 @@ void _sx_downgrade(struct sx *sx, const char *file, int line); * SX_ASSERT_XLOCKED() detects and guarantees that *we* own the xlock. */ #define _SX_ASSERT_XLOCKED(sx, file, line) do { \ - KASSERT(((sx)->sx_xholder == curproc), \ + KASSERT(((sx)->sx_xholder == curthread), \ ("Lock %s not exclusively locked @ %s:%d", \ (sx)->sx_object.lo_name, file, line)); \ } while (0) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index e83d626..7f4923c 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -43,6 +43,7 @@ #include <sys/_posix.h> #include <sys/queue.h> +struct thread; /* * Definitions for sysctl call. The sysctl call uses a hierarchical name * for objects that can be examined or modified. The name is expressed as @@ -110,7 +111,7 @@ struct ctlname { * so that we can use the interface from the kernel or from user-space. */ struct sysctl_req { - struct proc *p; + struct proc *p; /* used for access checking */ int lock; void *oldptr; size_t oldlen; @@ -582,13 +583,13 @@ struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, struct sysctl_oid *oidp); -int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, +int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval); -int kernel_sysctlbyname(struct proc *p, char *name, +int kernel_sysctlbyname(struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval); -int userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, +int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval); int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index fca23e0..c74ee41 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -36,9 +36,9 @@ #ifndef _SYS_SYSENT_H_ #define _SYS_SYSENT_H_ -struct proc; +struct thread; -typedef int sy_call_t __P((struct proc *, void *)); +typedef int sy_call_t __P((struct thread *, void *)); struct sysent { /* system call table */ int sy_narg; /* number of arguments */ @@ -76,7 +76,7 @@ struct sysentvec { void (*sv_prepsyscall) __P((struct trapframe *, int *, u_int *, caddr_t *)); char *sv_name; /* name of binary type */ - int (*sv_coredump) __P((struct proc *, struct vnode *, + int (*sv_coredump) __P((struct thread *, struct vnode *, off_t)); /* function to dump core, or NULL */ int (*sv_imgact_try) __P((struct image_params *)); diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index c509d4c..e97f811 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -13,6 +13,7 @@ #include <sys/acl.h> +struct thread; struct proc; #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ @@ -1071,246 +1072,246 @@ struct extattr_delete_fd_args { struct __setugid_args { char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)]; }; -int nosys __P((struct proc *, struct nosys_args *)); -void sys_exit __P((struct proc *, struct sys_exit_args *)); -int fork __P((struct proc *, struct fork_args *)); -int read __P((struct proc *, struct read_args *)); -int write __P((struct proc *, struct write_args *)); -int open __P((struct proc *, struct open_args *)); -int close __P((struct proc *, struct close_args *)); -int wait4 __P((struct proc *, struct wait_args *)); -int link __P((struct proc *, struct link_args *)); -int unlink __P((struct proc *, struct unlink_args *)); -int chdir __P((struct proc *, struct chdir_args *)); -int fchdir __P((struct proc *, struct fchdir_args *)); -int mknod __P((struct proc *, struct mknod_args *)); -int chmod __P((struct proc *, struct chmod_args *)); -int chown __P((struct proc *, struct chown_args *)); -int obreak __P((struct proc *, struct obreak_args *)); -int getfsstat __P((struct proc *, struct getfsstat_args *)); -int getpid __P((struct proc *, struct getpid_args *)); -int mount __P((struct proc *, struct mount_args *)); -int unmount __P((struct proc *, struct unmount_args *)); -int setuid __P((struct proc *, struct setuid_args *)); -int getuid __P((struct proc *, struct getuid_args *)); -int geteuid __P((struct proc *, struct geteuid_args *)); -int ptrace __P((struct proc *, struct ptrace_args *)); -int recvmsg __P((struct proc *, struct recvmsg_args *)); -int sendmsg __P((struct proc *, struct sendmsg_args *)); -int recvfrom __P((struct proc *, struct recvfrom_args *)); -int accept __P((struct proc *, struct accept_args *)); -int getpeername __P((struct proc *, struct getpeername_args *)); -int getsockname __P((struct proc *, struct getsockname_args *)); -int access __P((struct proc *, struct access_args *)); -int chflags __P((struct proc *, struct chflags_args *)); -int fchflags __P((struct proc *, struct fchflags_args *)); -int sync __P((struct proc *, struct sync_args *)); -int kill __P((struct proc *, struct kill_args *)); -int getppid __P((struct proc *, struct getppid_args *)); -int dup __P((struct proc *, struct dup_args *)); -int pipe __P((struct proc *, struct pipe_args *)); -int getegid __P((struct proc *, struct getegid_args *)); -int profil __P((struct proc *, struct profil_args *)); -int ktrace __P((struct proc *, struct ktrace_args *)); -int getgid __P((struct proc *, struct getgid_args *)); -int getlogin __P((struct proc *, struct getlogin_args *)); -int setlogin __P((struct proc *, struct setlogin_args *)); -int acct __P((struct proc *, struct acct_args *)); -int sigaltstack __P((struct proc *, struct sigaltstack_args *)); -int ioctl __P((struct proc *, struct ioctl_args *)); -int reboot __P((struct proc *, struct reboot_args *)); -int revoke __P((struct proc *, struct revoke_args *)); -int symlink __P((struct proc *, struct symlink_args *)); -int readlink __P((struct proc *, struct readlink_args *)); -int execve __P((struct proc *, struct execve_args *)); -int umask __P((struct proc *, struct umask_args *)); -int chroot __P((struct proc *, struct chroot_args *)); -int msync __P((struct proc *, struct msync_args *)); -int vfork __P((struct proc *, struct vfork_args *)); -int sbrk __P((struct proc *, struct sbrk_args *)); -int sstk __P((struct proc *, struct sstk_args *)); -int ovadvise __P((struct proc *, struct ovadvise_args *)); -int munmap __P((struct proc *, struct munmap_args *)); -int mprotect __P((struct proc *, struct mprotect_args *)); -int madvise __P((struct proc *, struct madvise_args *)); -int mincore __P((struct proc *, struct mincore_args *)); -int getgroups __P((struct proc *, struct getgroups_args *)); -int setgroups __P((struct proc *, struct setgroups_args *)); -int getpgrp __P((struct proc *, struct getpgrp_args *)); -int setpgid __P((struct proc *, struct setpgid_args *)); -int setitimer __P((struct proc *, struct setitimer_args *)); -int swapon __P((struct proc *, struct swapon_args *)); -int getitimer __P((struct proc *, struct getitimer_args *)); -int getdtablesize __P((struct proc *, struct getdtablesize_args *)); -int dup2 __P((struct proc *, struct dup2_args *)); -int fcntl __P((struct proc *, struct fcntl_args *)); -int select __P((struct proc *, struct select_args *)); -int fsync __P((struct proc *, struct fsync_args *)); -int setpriority __P((struct proc *, struct setpriority_args *)); -int socket __P((struct proc *, struct socket_args *)); -int connect __P((struct proc *, struct connect_args *)); -int getpriority __P((struct proc *, struct getpriority_args *)); -int bind __P((struct proc *, struct bind_args *)); -int setsockopt __P((struct proc *, struct setsockopt_args *)); -int listen __P((struct proc *, struct listen_args *)); -int gettimeofday __P((struct proc *, struct gettimeofday_args *)); -int getrusage __P((struct proc *, struct getrusage_args *)); -int getsockopt __P((struct proc *, struct getsockopt_args *)); -int readv __P((struct proc *, struct readv_args *)); -int writev __P((struct proc *, struct writev_args *)); -int settimeofday __P((struct proc *, struct settimeofday_args *)); -int fchown __P((struct proc *, struct fchown_args *)); -int fchmod __P((struct proc *, struct fchmod_args *)); -int setreuid __P((struct proc *, struct setreuid_args *)); -int setregid __P((struct proc *, struct setregid_args *)); -int rename __P((struct proc *, struct rename_args *)); -int flock __P((struct proc *, struct flock_args *)); -int mkfifo __P((struct proc *, struct mkfifo_args *)); -int sendto __P((struct proc *, struct sendto_args *)); -int shutdown __P((struct proc *, struct shutdown_args *)); -int socketpair __P((struct proc *, struct socketpair_args *)); -int mkdir __P((struct proc *, struct mkdir_args *)); -int rmdir __P((struct proc *, struct rmdir_args *)); -int utimes __P((struct proc *, struct utimes_args *)); -int adjtime __P((struct proc *, struct adjtime_args *)); -int setsid __P((struct proc *, struct setsid_args *)); -int quotactl __P((struct proc *, struct quotactl_args *)); -int nfssvc __P((struct proc *, struct nfssvc_args *)); -int statfs __P((struct proc *, struct statfs_args *)); -int fstatfs __P((struct proc *, struct fstatfs_args *)); -int getfh __P((struct proc *, struct getfh_args *)); -int getdomainname __P((struct proc *, struct getdomainname_args *)); -int setdomainname __P((struct proc *, struct setdomainname_args *)); -int uname __P((struct proc *, struct uname_args *)); -int sysarch __P((struct proc *, struct sysarch_args *)); -int rtprio __P((struct proc *, struct rtprio_args *)); -int semsys __P((struct proc *, struct semsys_args *)); -int msgsys __P((struct proc *, struct msgsys_args *)); -int shmsys __P((struct proc *, struct shmsys_args *)); -int pread __P((struct proc *, struct pread_args *)); -int pwrite __P((struct proc *, struct pwrite_args *)); -int ntp_adjtime __P((struct proc *, struct ntp_adjtime_args *)); -int setgid __P((struct proc *, struct setgid_args *)); -int setegid __P((struct proc *, struct setegid_args *)); -int seteuid __P((struct proc *, struct seteuid_args *)); -int stat __P((struct proc *, struct stat_args *)); -int fstat __P((struct proc *, struct fstat_args *)); -int lstat __P((struct proc *, struct lstat_args *)); -int pathconf __P((struct proc *, struct pathconf_args *)); -int fpathconf __P((struct proc *, struct fpathconf_args *)); -int getrlimit __P((struct proc *, struct __getrlimit_args *)); -int setrlimit __P((struct proc *, struct __setrlimit_args *)); -int getdirentries __P((struct proc *, struct getdirentries_args *)); -int mmap __P((struct proc *, struct mmap_args *)); -int lseek __P((struct proc *, struct lseek_args *)); -int truncate __P((struct proc *, struct truncate_args *)); -int ftruncate __P((struct proc *, struct ftruncate_args *)); -int __sysctl __P((struct proc *, struct sysctl_args *)); -int mlock __P((struct proc *, struct mlock_args *)); -int munlock __P((struct proc *, struct munlock_args *)); -int undelete __P((struct proc *, struct undelete_args *)); -int futimes __P((struct proc *, struct futimes_args *)); -int getpgid __P((struct proc *, struct getpgid_args *)); -int poll __P((struct proc *, struct poll_args *)); -int lkmnosys __P((struct proc *, struct nosys_args *)); -int __semctl __P((struct proc *, struct __semctl_args *)); -int semget __P((struct proc *, struct semget_args *)); -int semop __P((struct proc *, struct semop_args *)); -int msgctl __P((struct proc *, struct msgctl_args *)); -int msgget __P((struct proc *, struct msgget_args *)); -int msgsnd __P((struct proc *, struct msgsnd_args *)); -int msgrcv __P((struct proc *, struct msgrcv_args *)); -int shmat __P((struct proc *, struct shmat_args *)); -int shmctl __P((struct proc *, struct shmctl_args *)); -int shmdt __P((struct proc *, struct shmdt_args *)); -int shmget __P((struct proc *, struct shmget_args *)); -int clock_gettime __P((struct proc *, struct clock_gettime_args *)); -int clock_settime __P((struct proc *, struct clock_settime_args *)); -int clock_getres __P((struct proc *, struct clock_getres_args *)); -int nanosleep __P((struct proc *, struct nanosleep_args *)); -int minherit __P((struct proc *, struct minherit_args *)); -int rfork __P((struct proc *, struct rfork_args *)); -int openbsd_poll __P((struct proc *, struct openbsd_poll_args *)); -int issetugid __P((struct proc *, struct issetugid_args *)); -int lchown __P((struct proc *, struct lchown_args *)); -int getdents __P((struct proc *, struct getdents_args *)); -int lchmod __P((struct proc *, struct lchmod_args *)); -int lutimes __P((struct proc *, struct lutimes_args *)); -int nstat __P((struct proc *, struct nstat_args *)); -int nfstat __P((struct proc *, struct nfstat_args *)); -int nlstat __P((struct proc *, struct nlstat_args *)); -int fhstatfs __P((struct proc *, struct fhstatfs_args *)); -int fhopen __P((struct proc *, struct fhopen_args *)); -int fhstat __P((struct proc *, struct fhstat_args *)); -int modnext __P((struct proc *, struct modnext_args *)); -int modstat __P((struct proc *, struct modstat_args *)); -int modfnext __P((struct proc *, struct modfnext_args *)); -int modfind __P((struct proc *, struct modfind_args *)); -int kldload __P((struct proc *, struct kldload_args *)); -int kldunload __P((struct proc *, struct kldunload_args *)); -int kldfind __P((struct proc *, struct kldfind_args *)); -int kldnext __P((struct proc *, struct kldnext_args *)); -int kldstat __P((struct proc *, struct kldstat_args *)); -int kldfirstmod __P((struct proc *, struct kldfirstmod_args *)); -int getsid __P((struct proc *, struct getsid_args *)); -int setresuid __P((struct proc *, struct setresuid_args *)); -int setresgid __P((struct proc *, struct setresgid_args *)); -int aio_return __P((struct proc *, struct aio_return_args *)); -int aio_suspend __P((struct proc *, struct aio_suspend_args *)); -int aio_cancel __P((struct proc *, struct aio_cancel_args *)); -int aio_error __P((struct proc *, struct aio_error_args *)); -int aio_read __P((struct proc *, struct aio_read_args *)); -int aio_write __P((struct proc *, struct aio_write_args *)); -int lio_listio __P((struct proc *, struct lio_listio_args *)); -int yield __P((struct proc *, struct yield_args *)); -int mlockall __P((struct proc *, struct mlockall_args *)); -int munlockall __P((struct proc *, struct munlockall_args *)); -int __getcwd __P((struct proc *, struct __getcwd_args *)); -int sched_setparam __P((struct proc *, struct sched_setparam_args *)); -int sched_getparam __P((struct proc *, struct sched_getparam_args *)); -int sched_setscheduler __P((struct proc *, struct sched_setscheduler_args *)); -int sched_getscheduler __P((struct proc *, struct sched_getscheduler_args *)); -int sched_yield __P((struct proc *, struct sched_yield_args *)); -int sched_get_priority_max __P((struct proc *, struct sched_get_priority_max_args *)); -int sched_get_priority_min __P((struct proc *, struct sched_get_priority_min_args *)); -int sched_rr_get_interval __P((struct proc *, struct sched_rr_get_interval_args *)); -int utrace __P((struct proc *, struct utrace_args *)); -int sendfile __P((struct proc *, struct sendfile_args *)); -int kldsym __P((struct proc *, struct kldsym_args *)); -int jail __P((struct proc *, struct jail_args *)); -int sigprocmask __P((struct proc *, struct sigprocmask_args *)); -int sigsuspend __P((struct proc *, struct sigsuspend_args *)); -int sigaction __P((struct proc *, struct sigaction_args *)); -int sigpending __P((struct proc *, struct sigpending_args *)); -int sigreturn __P((struct proc *, struct sigreturn_args *)); -int __acl_get_file __P((struct proc *, struct __acl_get_file_args *)); -int __acl_set_file __P((struct proc *, struct __acl_set_file_args *)); -int __acl_get_fd __P((struct proc *, struct __acl_get_fd_args *)); -int __acl_set_fd __P((struct proc *, struct __acl_set_fd_args *)); -int __acl_delete_file __P((struct proc *, struct __acl_delete_file_args *)); -int __acl_delete_fd __P((struct proc *, struct __acl_delete_fd_args *)); -int __acl_aclcheck_file __P((struct proc *, struct __acl_aclcheck_file_args *)); -int __acl_aclcheck_fd __P((struct proc *, struct __acl_aclcheck_fd_args *)); -int extattrctl __P((struct proc *, struct extattrctl_args *)); -int extattr_set_file __P((struct proc *, struct extattr_set_file_args *)); -int extattr_get_file __P((struct proc *, struct extattr_get_file_args *)); -int extattr_delete_file __P((struct proc *, struct extattr_delete_file_args *)); -int aio_waitcomplete __P((struct proc *, struct aio_waitcomplete_args *)); -int getresuid __P((struct proc *, struct getresuid_args *)); -int getresgid __P((struct proc *, struct getresgid_args *)); -int kqueue __P((struct proc *, struct kqueue_args *)); -int kevent __P((struct proc *, struct kevent_args *)); -int __cap_get_proc __P((struct proc *, struct __cap_get_proc_args *)); -int __cap_set_proc __P((struct proc *, struct __cap_set_proc_args *)); -int __cap_get_fd __P((struct proc *, struct __cap_get_fd_args *)); -int __cap_get_file __P((struct proc *, struct __cap_get_file_args *)); -int __cap_set_fd __P((struct proc *, struct __cap_set_fd_args *)); -int __cap_set_file __P((struct proc *, struct __cap_set_file_args *)); -int lkmressys __P((struct proc *, struct nosys_args *)); -int extattr_set_fd __P((struct proc *, struct extattr_set_fd_args *)); -int extattr_get_fd __P((struct proc *, struct extattr_get_fd_args *)); -int extattr_delete_fd __P((struct proc *, struct extattr_delete_fd_args *)); -int __setugid __P((struct proc *, struct __setugid_args *)); +int nosys __P((struct thread *, struct nosys_args *)); +void sys_exit __P((struct thread *, struct sys_exit_args *)); +int fork __P((struct thread *, struct fork_args *)); +int read __P((struct thread *, struct read_args *)); +int write __P((struct thread *, struct write_args *)); +int open __P((struct thread *, struct open_args *)); +int close __P((struct thread *, struct close_args *)); +int wait4 __P((struct thread *, struct wait_args *)); +int link __P((struct thread *, struct link_args *)); +int unlink __P((struct thread *, struct unlink_args *)); +int chdir __P((struct thread *, struct chdir_args *)); +int fchdir __P((struct thread *, struct fchdir_args *)); +int mknod __P((struct thread *, struct mknod_args *)); +int chmod __P((struct thread *, struct chmod_args *)); +int chown __P((struct thread *, struct chown_args *)); +int obreak __P((struct thread *, struct obreak_args *)); +int getfsstat __P((struct thread *, struct getfsstat_args *)); +int getpid __P((struct thread *, struct getpid_args *)); +int mount __P((struct thread *, struct mount_args *)); +int unmount __P((struct thread *, struct unmount_args *)); +int setuid __P((struct thread *, struct setuid_args *)); +int getuid __P((struct thread *, struct getuid_args *)); +int geteuid __P((struct thread *, struct geteuid_args *)); +int ptrace __P((struct thread *, struct ptrace_args *)); +int recvmsg __P((struct thread *, struct recvmsg_args *)); +int sendmsg __P((struct thread *, struct sendmsg_args *)); +int recvfrom __P((struct thread *, struct recvfrom_args *)); +int accept __P((struct thread *, struct accept_args *)); +int getpeername __P((struct thread *, struct getpeername_args *)); +int getsockname __P((struct thread *, struct getsockname_args *)); +int access __P((struct thread *, struct access_args *)); +int chflags __P((struct thread *, struct chflags_args *)); +int fchflags __P((struct thread *, struct fchflags_args *)); +int sync __P((struct thread *, struct sync_args *)); +int kill __P((struct thread *, struct kill_args *)); +int getppid __P((struct thread *, struct getppid_args *)); +int dup __P((struct thread *, struct dup_args *)); +int pipe __P((struct thread *, struct pipe_args *)); +int getegid __P((struct thread *, struct getegid_args *)); +int profil __P((struct thread *, struct profil_args *)); +int ktrace __P((struct thread *, struct ktrace_args *)); +int getgid __P((struct thread *, struct getgid_args *)); +int getlogin __P((struct thread *, struct getlogin_args *)); +int setlogin __P((struct thread *, struct setlogin_args *)); +int acct __P((struct thread *, struct acct_args *)); +int sigaltstack __P((struct thread *, struct sigaltstack_args *)); +int ioctl __P((struct thread *, struct ioctl_args *)); +int reboot __P((struct thread *, struct reboot_args *)); +int revoke __P((struct thread *, struct revoke_args *)); +int symlink __P((struct thread *, struct symlink_args *)); +int readlink __P((struct thread *, struct readlink_args *)); +int execve __P((struct thread *, struct execve_args *)); +int umask __P((struct thread *, struct umask_args *)); +int chroot __P((struct thread *, struct chroot_args *)); +int msync __P((struct thread *, struct msync_args *)); +int vfork __P((struct thread *, struct vfork_args *)); +int sbrk __P((struct thread *, struct sbrk_args *)); +int sstk __P((struct thread *, struct sstk_args *)); +int ovadvise __P((struct thread *, struct ovadvise_args *)); +int munmap __P((struct thread *, struct munmap_args *)); +int mprotect __P((struct thread *, struct mprotect_args *)); +int madvise __P((struct thread *, struct madvise_args *)); +int mincore __P((struct thread *, struct mincore_args *)); +int getgroups __P((struct thread *, struct getgroups_args *)); +int setgroups __P((struct thread *, struct setgroups_args *)); +int getpgrp __P((struct thread *, struct getpgrp_args *)); +int setpgid __P((struct thread *, struct setpgid_args *)); +int setitimer __P((struct thread *, struct setitimer_args *)); +int swapon __P((struct thread *, struct swapon_args *)); +int getitimer __P((struct thread *, struct getitimer_args *)); +int getdtablesize __P((struct thread *, struct getdtablesize_args *)); +int dup2 __P((struct thread *, struct dup2_args *)); +int fcntl __P((struct thread *, struct fcntl_args *)); +int select __P((struct thread *, struct select_args *)); +int fsync __P((struct thread *, struct fsync_args *)); +int setpriority __P((struct thread *, struct setpriority_args *)); +int socket __P((struct thread *, struct socket_args *)); +int connect __P((struct thread *, struct connect_args *)); +int getpriority __P((struct thread *, struct getpriority_args *)); +int bind __P((struct thread *, struct bind_args *)); +int setsockopt __P((struct thread *, struct setsockopt_args *)); +int listen __P((struct thread *, struct listen_args *)); +int gettimeofday __P((struct thread *, struct gettimeofday_args *)); +int getrusage __P((struct thread *, struct getrusage_args *)); +int getsockopt __P((struct thread *, struct getsockopt_args *)); +int readv __P((struct thread *, struct readv_args *)); +int writev __P((struct thread *, struct writev_args *)); +int settimeofday __P((struct thread *, struct settimeofday_args *)); +int fchown __P((struct thread *, struct fchown_args *)); +int fchmod __P((struct thread *, struct fchmod_args *)); +int setreuid __P((struct thread *, struct setreuid_args *)); +int setregid __P((struct thread *, struct setregid_args *)); +int rename __P((struct thread *, struct rename_args *)); +int flock __P((struct thread *, struct flock_args *)); +int mkfifo __P((struct thread *, struct mkfifo_args *)); +int sendto __P((struct thread *, struct sendto_args *)); +int shutdown __P((struct thread *, struct shutdown_args *)); +int socketpair __P((struct thread *, struct socketpair_args *)); +int mkdir __P((struct thread *, struct mkdir_args *)); +int rmdir __P((struct thread *, struct rmdir_args *)); +int utimes __P((struct thread *, struct utimes_args *)); +int adjtime __P((struct thread *, struct adjtime_args *)); +int setsid __P((struct thread *, struct setsid_args *)); +int quotactl __P((struct thread *, struct quotactl_args *)); +int nfssvc __P((struct thread *, struct nfssvc_args *)); +int statfs __P((struct thread *, struct statfs_args *)); +int fstatfs __P((struct thread *, struct fstatfs_args *)); +int getfh __P((struct thread *, struct getfh_args *)); +int getdomainname __P((struct thread *, struct getdomainname_args *)); +int setdomainname __P((struct thread *, struct setdomainname_args *)); +int uname __P((struct thread *, struct uname_args *)); +int sysarch __P((struct thread *, struct sysarch_args *)); +int rtprio __P((struct thread *, struct rtprio_args *)); +int semsys __P((struct thread *, struct semsys_args *)); +int msgsys __P((struct thread *, struct msgsys_args *)); +int shmsys __P((struct thread *, struct shmsys_args *)); +int pread __P((struct thread *, struct pread_args *)); +int pwrite __P((struct thread *, struct pwrite_args *)); +int ntp_adjtime __P((struct thread *, struct ntp_adjtime_args *)); +int setgid __P((struct thread *, struct setgid_args *)); +int setegid __P((struct thread *, struct setegid_args *)); +int seteuid __P((struct thread *, struct seteuid_args *)); +int stat __P((struct thread *, struct stat_args *)); +int fstat __P((struct thread *, struct fstat_args *)); +int lstat __P((struct thread *, struct lstat_args *)); +int pathconf __P((struct thread *, struct pathconf_args *)); +int fpathconf __P((struct thread *, struct fpathconf_args *)); +int getrlimit __P((struct thread *, struct __getrlimit_args *)); +int setrlimit __P((struct thread *, struct __setrlimit_args *)); +int getdirentries __P((struct thread *, struct getdirentries_args *)); +int mmap __P((struct thread *, struct mmap_args *)); +int lseek __P((struct thread *, struct lseek_args *)); +int truncate __P((struct thread *, struct truncate_args *)); +int ftruncate __P((struct thread *, struct ftruncate_args *)); +int __sysctl __P((struct thread *, struct sysctl_args *)); +int mlock __P((struct thread *, struct mlock_args *)); +int munlock __P((struct thread *, struct munlock_args *)); +int undelete __P((struct thread *, struct undelete_args *)); +int futimes __P((struct thread *, struct futimes_args *)); +int getpgid __P((struct thread *, struct getpgid_args *)); +int poll __P((struct thread *, struct poll_args *)); +int lkmnosys __P((struct thread *, struct nosys_args *)); +int __semctl __P((struct thread *, struct __semctl_args *)); +int semget __P((struct thread *, struct semget_args *)); +int semop __P((struct thread *, struct semop_args *)); +int msgctl __P((struct thread *, struct msgctl_args *)); +int msgget __P((struct thread *, struct msgget_args *)); +int msgsnd __P((struct thread *, struct msgsnd_args *)); +int msgrcv __P((struct thread *, struct msgrcv_args *)); +int shmat __P((struct thread *, struct shmat_args *)); +int shmctl __P((struct thread *, struct shmctl_args *)); +int shmdt __P((struct thread *, struct shmdt_args *)); +int shmget __P((struct thread *, struct shmget_args *)); +int clock_gettime __P((struct thread *, struct clock_gettime_args *)); +int clock_settime __P((struct thread *, struct clock_settime_args *)); +int clock_getres __P((struct thread *, struct clock_getres_args *)); +int nanosleep __P((struct thread *, struct nanosleep_args *)); +int minherit __P((struct thread *, struct minherit_args *)); +int rfork __P((struct thread *, struct rfork_args *)); +int openbsd_poll __P((struct thread *, struct openbsd_poll_args *)); +int issetugid __P((struct thread *, struct issetugid_args *)); +int lchown __P((struct thread *, struct lchown_args *)); +int getdents __P((struct thread *, struct getdents_args *)); +int lchmod __P((struct thread *, struct lchmod_args *)); +int lutimes __P((struct thread *, struct lutimes_args *)); +int nstat __P((struct thread *, struct nstat_args *)); +int nfstat __P((struct thread *, struct nfstat_args *)); +int nlstat __P((struct thread *, struct nlstat_args *)); +int fhstatfs __P((struct thread *, struct fhstatfs_args *)); +int fhopen __P((struct thread *, struct fhopen_args *)); +int fhstat __P((struct thread *, struct fhstat_args *)); +int modnext __P((struct thread *, struct modnext_args *)); +int modstat __P((struct thread *, struct modstat_args *)); +int modfnext __P((struct thread *, struct modfnext_args *)); +int modfind __P((struct thread *, struct modfind_args *)); +int kldload __P((struct thread *, struct kldload_args *)); +int kldunload __P((struct thread *, struct kldunload_args *)); +int kldfind __P((struct thread *, struct kldfind_args *)); +int kldnext __P((struct thread *, struct kldnext_args *)); +int kldstat __P((struct thread *, struct kldstat_args *)); +int kldfirstmod __P((struct thread *, struct kldfirstmod_args *)); +int getsid __P((struct thread *, struct getsid_args *)); +int setresuid __P((struct thread *, struct setresuid_args *)); +int setresgid __P((struct thread *, struct setresgid_args *)); +int aio_return __P((struct thread *, struct aio_return_args *)); +int aio_suspend __P((struct thread *, struct aio_suspend_args *)); +int aio_cancel __P((struct thread *, struct aio_cancel_args *)); +int aio_error __P((struct thread *, struct aio_error_args *)); +int aio_read __P((struct thread *, struct aio_read_args *)); +int aio_write __P((struct thread *, struct aio_write_args *)); +int lio_listio __P((struct thread *, struct lio_listio_args *)); +int yield __P((struct thread *, struct yield_args *)); +int mlockall __P((struct thread *, struct mlockall_args *)); +int munlockall __P((struct thread *, struct munlockall_args *)); +int __getcwd __P((struct thread *, struct __getcwd_args *)); +int sched_setparam __P((struct thread *, struct sched_setparam_args *)); +int sched_getparam __P((struct thread *, struct sched_getparam_args *)); +int sched_setscheduler __P((struct thread *, struct sched_setscheduler_args *)); +int sched_getscheduler __P((struct thread *, struct sched_getscheduler_args *)); +int sched_yield __P((struct thread *, struct sched_yield_args *)); +int sched_get_priority_max __P((struct thread *, struct sched_get_priority_max_args *)); +int sched_get_priority_min __P((struct thread *, struct sched_get_priority_min_args *)); +int sched_rr_get_interval __P((struct thread *, struct sched_rr_get_interval_args *)); +int utrace __P((struct thread *, struct utrace_args *)); +int sendfile __P((struct thread *, struct sendfile_args *)); +int kldsym __P((struct thread *, struct kldsym_args *)); +int jail __P((struct thread *, struct jail_args *)); +int sigprocmask __P((struct thread *, struct sigprocmask_args *)); +int sigsuspend __P((struct thread *, struct sigsuspend_args *)); +int sigaction __P((struct thread *, struct sigaction_args *)); +int sigpending __P((struct thread *, struct sigpending_args *)); +int sigreturn __P((struct thread *, struct sigreturn_args *)); +int __acl_get_file __P((struct thread *, struct __acl_get_file_args *)); +int __acl_set_file __P((struct thread *, struct __acl_set_file_args *)); +int __acl_get_fd __P((struct thread *, struct __acl_get_fd_args *)); +int __acl_set_fd __P((struct thread *, struct __acl_set_fd_args *)); +int __acl_delete_file __P((struct thread *, struct __acl_delete_file_args *)); +int __acl_delete_fd __P((struct thread *, struct __acl_delete_fd_args *)); +int __acl_aclcheck_file __P((struct thread *, struct __acl_aclcheck_file_args *)); +int __acl_aclcheck_fd __P((struct thread *, struct __acl_aclcheck_fd_args *)); +int extattrctl __P((struct thread *, struct extattrctl_args *)); +int extattr_set_file __P((struct thread *, struct extattr_set_file_args *)); +int extattr_get_file __P((struct thread *, struct extattr_get_file_args *)); +int extattr_delete_file __P((struct thread *, struct extattr_delete_file_args *)); +int aio_waitcomplete __P((struct thread *, struct aio_waitcomplete_args *)); +int getresuid __P((struct thread *, struct getresuid_args *)); +int getresgid __P((struct thread *, struct getresgid_args *)); +int kqueue __P((struct thread *, struct kqueue_args *)); +int kevent __P((struct thread *, struct kevent_args *)); +int __cap_get_proc __P((struct thread *, struct __cap_get_proc_args *)); +int __cap_set_proc __P((struct thread *, struct __cap_set_proc_args *)); +int __cap_get_fd __P((struct thread *, struct __cap_get_fd_args *)); +int __cap_get_file __P((struct thread *, struct __cap_get_file_args *)); +int __cap_set_fd __P((struct thread *, struct __cap_set_fd_args *)); +int __cap_set_file __P((struct thread *, struct __cap_set_file_args *)); +int lkmressys __P((struct thread *, struct nosys_args *)); +int extattr_set_fd __P((struct thread *, struct extattr_set_fd_args *)); +int extattr_get_fd __P((struct thread *, struct extattr_get_fd_args *)); +int extattr_delete_fd __P((struct thread *, struct extattr_delete_fd_args *)); +int __setugid __P((struct thread *, struct __setugid_args *)); #ifdef COMPAT_43 @@ -1443,43 +1444,43 @@ struct ogetdirentries_args { char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)]; char basep_l_[PADL_(long *)]; long * basep; char basep_r_[PADR_(long *)]; }; -int ocreat __P((struct proc *, struct ocreat_args *)); -int olseek __P((struct proc *, struct olseek_args *)); -int ostat __P((struct proc *, struct ostat_args *)); -int olstat __P((struct proc *, struct olstat_args *)); -int osigaction __P((struct proc *, struct osigaction_args *)); -int osigprocmask __P((struct proc *, struct osigprocmask_args *)); -int osigpending __P((struct proc *, struct osigpending_args *)); -int ofstat __P((struct proc *, struct ofstat_args *)); -int ogetkerninfo __P((struct proc *, struct getkerninfo_args *)); -int ogetpagesize __P((struct proc *, struct getpagesize_args *)); -int ommap __P((struct proc *, struct ommap_args *)); -int owait __P((struct proc *, struct owait_args *)); -int ogethostname __P((struct proc *, struct gethostname_args *)); -int osethostname __P((struct proc *, struct sethostname_args *)); -int oaccept __P((struct proc *, struct accept_args *)); -int osend __P((struct proc *, struct osend_args *)); -int orecv __P((struct proc *, struct orecv_args *)); -int osigreturn __P((struct proc *, struct osigreturn_args *)); -int osigvec __P((struct proc *, struct osigvec_args *)); -int osigblock __P((struct proc *, struct osigblock_args *)); -int osigsetmask __P((struct proc *, struct osigsetmask_args *)); -int osigsuspend __P((struct proc *, struct osigsuspend_args *)); -int osigstack __P((struct proc *, struct osigstack_args *)); -int orecvmsg __P((struct proc *, struct orecvmsg_args *)); -int osendmsg __P((struct proc *, struct osendmsg_args *)); -int orecvfrom __P((struct proc *, struct recvfrom_args *)); -int otruncate __P((struct proc *, struct otruncate_args *)); -int oftruncate __P((struct proc *, struct oftruncate_args *)); -int ogetpeername __P((struct proc *, struct ogetpeername_args *)); -int ogethostid __P((struct proc *, struct ogethostid_args *)); -int osethostid __P((struct proc *, struct osethostid_args *)); -int ogetrlimit __P((struct proc *, struct ogetrlimit_args *)); -int osetrlimit __P((struct proc *, struct osetrlimit_args *)); -int okillpg __P((struct proc *, struct okillpg_args *)); -int oquota __P((struct proc *, struct oquota_args *)); -int ogetsockname __P((struct proc *, struct getsockname_args *)); -int ogetdirentries __P((struct proc *, struct ogetdirentries_args *)); +int ocreat __P((struct thread *, struct ocreat_args *)); +int olseek __P((struct thread *, struct olseek_args *)); +int ostat __P((struct thread *, struct ostat_args *)); +int olstat __P((struct thread *, struct olstat_args *)); +int osigaction __P((struct thread *, struct osigaction_args *)); +int osigprocmask __P((struct thread *, struct osigprocmask_args *)); +int osigpending __P((struct thread *, struct osigpending_args *)); +int ofstat __P((struct thread *, struct ofstat_args *)); +int ogetkerninfo __P((struct thread *, struct getkerninfo_args *)); +int ogetpagesize __P((struct thread *, struct getpagesize_args *)); +int ommap __P((struct thread *, struct ommap_args *)); +int owait __P((struct thread *, struct owait_args *)); +int ogethostname __P((struct thread *, struct gethostname_args *)); +int osethostname __P((struct thread *, struct sethostname_args *)); +int oaccept __P((struct thread *, struct accept_args *)); +int osend __P((struct thread *, struct osend_args *)); +int orecv __P((struct thread *, struct orecv_args *)); +int osigreturn __P((struct thread *, struct osigreturn_args *)); +int osigvec __P((struct thread *, struct osigvec_args *)); +int osigblock __P((struct thread *, struct osigblock_args *)); +int osigsetmask __P((struct thread *, struct osigsetmask_args *)); +int osigsuspend __P((struct thread *, struct osigsuspend_args *)); +int osigstack __P((struct thread *, struct osigstack_args *)); +int orecvmsg __P((struct thread *, struct orecvmsg_args *)); +int osendmsg __P((struct thread *, struct osendmsg_args *)); +int orecvfrom __P((struct thread *, struct recvfrom_args *)); +int otruncate __P((struct thread *, struct otruncate_args *)); +int oftruncate __P((struct thread *, struct oftruncate_args *)); +int ogetpeername __P((struct thread *, struct ogetpeername_args *)); +int ogethostid __P((struct thread *, struct ogethostid_args *)); +int osethostid __P((struct thread *, struct osethostid_args *)); +int ogetrlimit __P((struct thread *, struct ogetrlimit_args *)); +int osetrlimit __P((struct thread *, struct osetrlimit_args *)); +int okillpg __P((struct thread *, struct okillpg_args *)); +int oquota __P((struct thread *, struct oquota_args *)); +int ogetsockname __P((struct thread *, struct getsockname_args *)); +int ogetdirentries __P((struct thread *, struct ogetdirentries_args *)); #endif /* COMPAT_43 */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index afc3e4b..e287a35 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -88,6 +88,8 @@ struct clockframe; struct malloc_type; struct mtx; struct proc; +struct kse; +struct thread; struct timeval; struct tty; struct ucred; @@ -101,7 +103,7 @@ int dumpstatus __P((vm_offset_t addr, long count)); int nullop __P((void)); int eopnotsupp __P((void)); int einval __P((void)); -int seltrue __P((dev_t dev, int which, struct proc *p)); +int seltrue __P((dev_t dev, int which, struct thread *td)); int ureadc __P((int, struct uio *)); void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask)); void *phashinit __P((int count, struct malloc_type *type, u_long *nentries)); @@ -134,7 +136,7 @@ void bcopy __P((const void *from, void *to, size_t len)); void ovbcopy __P((const void *from, void *to, size_t len)); #ifdef __i386__ -extern void (*bzero) __P((void *buf, size_t len)); +extern void (*bzero) __P((volatile void *buf, size_t len)); #else void bzero __P((void *buf, size_t len)); #endif @@ -159,10 +161,10 @@ int susword __P((void *base, int word)); void realitexpire __P((void *)); void hardclock __P((struct clockframe *frame)); -void hardclock_process __P((struct proc *p, int user)); +void hardclock_process __P((struct thread *td, int user)); void softclock __P((void *)); void statclock __P((struct clockframe *frame)); -void statclock_process __P((struct proc *p, register_t pc, int user)); +void statclock_process __P((struct kse *ke, register_t pc, int user)); void startprofclock __P((struct proc *)); void stopprofclock __P((struct proc *)); @@ -172,7 +174,9 @@ void setstatclockrate __P((int hzrate)); #define PRISON_ROOT 1 int suser __P((struct proc *)); +int suser_td __P((struct thread *)); int suser_xxx __P((struct ucred *cred, struct proc *proc, int flag)); +int suser_xxx_td __P((struct ucred *cred, struct thread *thread, int flag)); int u_cansee __P((struct ucred *u1, struct ucred *u2)); char *getenv __P((const char *name)); diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 82f79f3..70946bc 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -268,7 +268,7 @@ int ttylclose __P((struct tty *tp, int flag)); struct tty *ttymalloc __P((struct tty *tp)); int ttymodem __P((struct tty *tp, int flag)); int ttyopen __P((dev_t device, struct tty *tp)); -int ttypoll __P((dev_t dev, int events, struct proc *p)); +int ttypoll __P((dev_t dev, int events, struct thread *td)); int ttyread __P((dev_t dev, struct uio *uio, int flag)); void ttyregister __P((struct tty *tp)); int ttysleep __P((struct tty *tp, void *chan, int pri, char *wmesg, diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index 356cca2..1675bc0 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -80,7 +80,6 @@ struct xucred { #ifdef _KERNEL -struct proc; void change_egid __P((struct ucred *newcred, gid_t egid)); void change_euid __P((struct ucred *newcred, uid_t euid)); diff --git a/sys/sys/uio.h b/sys/sys/uio.h index fcf1570..48f6c97 100644 --- a/sys/sys/uio.h +++ b/sys/sys/uio.h @@ -65,7 +65,7 @@ struct uio { int uio_resid; enum uio_seg uio_segflg; enum uio_rw uio_rw; - struct proc *uio_procp; + struct thread *uio_td;; }; /* diff --git a/sys/sys/user.h b/sys/sys/user.h index 789b325..350707b 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -161,7 +161,10 @@ struct kinfo_proc { struct rusage ki_rusage; /* process rusage statistics */ long ki_sflag; /* PS_* flags */ struct priority ki_pri; /* process priority */ - long ki_spare[25]; /* spare constants */ + long ki_tdflags; /* XXXKSE kthread flag */ + struct pcb *ki_pcb; /* kernel virtual addr of pcb */ + void *ki_kstack; /* kernel virtual addr of stack */ + long ki_spare[22]; /* spare constants */ }; void fill_kinfo_proc __P((struct proc *, struct kinfo_proc *)); @@ -178,15 +181,15 @@ void fill_kinfo_proc __P((struct proc *, struct kinfo_proc *)); */ struct user { - struct pcb u_pcb; - struct sigacts u_sigacts; /* p_sigacts points here (use it!) */ - struct pstats u_stats; /* p_stats points here (use it!) */ + struct sigacts u_sigacts; /* *p_sigacts */ + struct pstats u_stats; /* *p_stats */ /* - * Remaining fields only for core dump and/or ptrace-- + * Remaining fields only for + * core dump and/or ptrace-- * not valid at other times! */ - struct kinfo_proc u_kproc; /* proc + eproc */ - struct md_coredump u_md; /* machine dependent glop */ + struct kinfo_proc u_kproc; /* eproc */ + struct md_coredump u_md; /* glop */ }; #endif diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index b4d7828..68029ac 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -135,7 +135,7 @@ struct vnode { short vpi_events; /* what they are looking for */ short vpi_revents; /* what has happened */ } v_pollinfo; - struct proc *v_vxproc; /* proc owning VXLOCK */ + struct thread *v_vxproc; /* thread owning VXLOCK */ #ifdef DEBUG_LOCKS const char *filename; /* Source file doing locking */ int line; /* Line number doing locking */ @@ -161,7 +161,7 @@ struct vnode { #define VSYSTEM 0x00004 /* vnode being used by kernel */ #define VISTTY 0x00008 /* vnode represents a tty */ #define VXLOCK 0x00100 /* vnode is locked to change underlying type */ -#define VXWANT 0x00200 /* process is waiting for vnode */ +#define VXWANT 0x00200 /* thread is waiting for vnode */ #define VBWAIT 0x00400 /* waiting for output to complete */ #define VNOSYNC 0x01000 /* unlinked, stop syncing */ /* open for business 0x01000 */ @@ -169,7 +169,7 @@ struct vnode { #define VCOPYONWRITE 0x04000 /* vnode is doing copy-on-write */ #define VAGE 0x08000 /* Insert vnode at head of free list */ #define VOLOCK 0x10000 /* vnode is locked waiting for an object */ -#define VOWANT 0x20000 /* a process is waiting for VOLOCK */ +#define VOWANT 0x20000 /* a thread is waiting for VOLOCK */ #define VDOOMED 0x40000 /* This vnode is being recycled */ #define VFREE 0x80000 /* This vnode is on the freelist */ /* open for business 0x100000 */ @@ -361,7 +361,7 @@ struct vnodeop_desc { int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ int vdesc_vpp_offset; /* return vpp location */ int vdesc_cred_offset; /* cred location, if any */ - int vdesc_proc_offset; /* proc location, if any */ + int vdesc_thread_offset; /* thread location, if any */ int vdesc_componentname_offset; /* if any */ /* * Finally, we've got a list of private data (about each operation) @@ -423,8 +423,8 @@ struct vop_generic_args { #ifdef DEBUG_VFS_LOCKS /* * Macros to aid in tracing VFS locking problems. Not totally - * reliable since if the process sleeps between changing the lock - * state and checking it with the assert, some other process could + * reliable since if the thread sleeps between changing the lock + * state and checking it with the assert, some other thread could * change the state. They are good enough for debugging a single * filesystem using a single-threaded test. I find that 'cvs co src' * is a pretty good test. @@ -454,7 +454,7 @@ do { \ int lockstate; \ \ if (_vp && IS_LOCKING_VFS(_vp)) { \ - lockstate = VOP_ISLOCKED(_vp, curproc); \ + lockstate = VOP_ISLOCKED(_vp, curthread); \ if (lockstate == LK_EXCLUSIVE) \ panic("%s: %p is locked but should not be", \ str, _vp); \ @@ -466,7 +466,7 @@ do { \ struct vnode *_vp = (vp); \ \ if (_vp && IS_LOCKING_VFS(_vp) && \ - VOP_ISLOCKED(_vp, curproc) != LK_EXCLUSIVE) \ + VOP_ISLOCKED(_vp, curthread) != LK_EXCLUSIVE) \ panic("%s: %p is not exclusive locked but should be", \ str, _vp); \ } while (0) @@ -476,8 +476,8 @@ do { \ struct vnode *_vp = (vp); \ \ if (_vp && IS_LOCKING_VFS(_vp) && \ - VOP_ISLOCKED(_vp, curproc) != LK_EXCLOTHER) \ - panic("%s: %p is not exclusive locked by another proc", \ + VOP_ISLOCKED(_vp, curthread) != LK_EXCLOTHER) \ + panic("%s: %p is not exclusive locked by another thread", \ str, _vp); \ } while (0) @@ -539,6 +539,7 @@ struct file; struct mount; struct nameidata; struct ostat; +struct thread; struct proc; struct stat; struct nstat; @@ -580,51 +581,52 @@ int vfinddev __P((dev_t dev, enum vtype type, struct vnode **vpp)); void vfs_add_vnodeops __P((const void *)); void vfs_rm_vnodeops __P((const void *)); int vflush __P((struct mount *mp, int rootrefs, int flags)); -int vget __P((struct vnode *vp, int lockflag, struct proc *p)); +int vget __P((struct vnode *vp, int lockflag, struct thread *td)); void vgone __P((struct vnode *vp)); -void vgonel __P((struct vnode *vp, struct proc *p)); +void vgonel __P((struct vnode *vp, struct thread *td)); void vhold __P((struct vnode *)); int vinvalbuf __P((struct vnode *vp, int save, struct ucred *cred, - struct proc *p, int slpflag, int slptimeo)); -int vtruncbuf __P((struct vnode *vp, struct ucred *cred, struct proc *p, + struct thread *td, int slpflag, int slptimeo)); +int vtruncbuf __P((struct vnode *vp, struct ucred *cred, struct thread *td, off_t length, int blksize)); void vprint __P((char *label, struct vnode *vp)); int vrecycle __P((struct vnode *vp, struct mtx *inter_lkp, - struct proc *p)); + struct thread *td)); int vn_close __P((struct vnode *vp, - int flags, struct ucred *cred, struct proc *p)); + int flags, struct ucred *cred, struct thread *td)); void vn_finished_write __P((struct mount *mp)); int vn_isdisk __P((struct vnode *vp, int *errp)); -int vn_lock __P((struct vnode *vp, int flags, struct proc *p)); +int vn_lock __P((struct vnode *vp, int flags, struct thread *td)); #ifdef DEBUG_LOCKS -int debug_vn_lock __P((struct vnode *vp, int flags, struct proc *p, +int debug_vn_lock __P((struct vnode *vp, int flags, struct thread *p, const char *filename, int line)); #define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__) #endif +int vn_mkdir __P((char *path, int mode, enum uio_seg segflg, struct thread *td)); int vn_open __P((struct nameidata *ndp, int *flagp, int cmode)); void vn_pollevent __P((struct vnode *vp, int events)); void vn_pollgone __P((struct vnode *vp)); -int vn_pollrecord __P((struct vnode *vp, struct proc *p, int events)); +int vn_pollrecord __P((struct vnode *vp, struct thread *p, int events)); int vn_rdwr __P((enum uio_rw rw, struct vnode *vp, caddr_t base, int len, off_t offset, enum uio_seg segflg, int ioflg, - struct ucred *cred, int *aresid, struct proc *p)); + struct ucred *cred, int *aresid, struct thread *td)); int vn_rdwr_inchunks __P((enum uio_rw rw, struct vnode *vp, caddr_t base, int len, off_t offset, enum uio_seg segflg, int ioflg, - struct ucred *cred, int *aresid, struct proc *p)); -int vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p)); + struct ucred *cred, int *aresid, struct thread *td)); +int vn_stat __P((struct vnode *vp, struct stat *sb, struct thread *td)); int vn_start_write __P((struct vnode *vp, struct mount **mpp, int flags)); dev_t vn_todev __P((struct vnode *vp)); int vn_write_suspend_wait __P((struct vnode *vp, struct mount *mp, int flags)); int vn_writechk __P((struct vnode *vp)); int vn_extattr_get __P((struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, int *buflen, char *buf, struct proc *p)); + const char *attrname, int *buflen, char *buf, struct thread *td)); int vn_extattr_set __P((struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, int buflen, char *buf, struct proc *p)); + const char *attrname, int buflen, char *buf, struct thread *td)); int vn_extattr_rm(struct vnode *vp, int ioflg, int attrnamespace, - const char *attrname, struct proc *p); + const char *attrname, struct thread *td); int vfs_cache_lookup __P((struct vop_lookup_args *ap)); -int vfs_object_create __P((struct vnode *vp, struct proc *p, +int vfs_object_create __P((struct vnode *vp, struct thread *td, struct ucred *cred)); void vfs_timestamp __P((struct timespec *)); void vfs_write_resume __P((struct mount *mp)); diff --git a/sys/tools/vnode_if.awk b/sys/tools/vnode_if.awk index 53236e5..32eabfe 100644 --- a/sys/tools/vnode_if.awk +++ b/sys/tools/vnode_if.awk @@ -322,8 +322,8 @@ line: while (<SRC>) { printf CFILE "\t%s,\n", &find_arg_with_type('struct vnode **'); # cred (if any) printf CFILE "\t%s,\n", &find_arg_with_type('struct ucred *'); - # proc (if any) - printf CFILE "\t%s,\n", &find_arg_with_type('struct proc *'); + # thread (if any) + printf CFILE "\t%s,\n", &find_arg_with_type('struct thread *'); # componentname printf CFILE "\t%s,\n", &find_arg_with_type('struct componentname *'); # transport layer information diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index cf57bc7..26747fc 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -72,7 +72,7 @@ ffs_balloc(struct vnode *a_vp, off_t a_startoffset, int a_size, int deallocated, osize, nsize, num, i, error; ufs_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1]; int unwindidx = -1; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ vp = a_vp; ip = VTOI(vp); @@ -350,7 +350,7 @@ fail: * occurence. The error return from fsync is ignored as we already * have an error to return to the user. */ - (void) VOP_FSYNC(vp, cred, MNT_WAIT, p); + (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); for (deallocated = 0, blkp = allociblk; blkp < allocblk; blkp++) { ffs_blkfree(ip, *blkp, fs->fs_bsize); deallocated += fs->fs_bsize; @@ -387,6 +387,6 @@ fail: ip->i_blocks -= btodb(deallocated); ip->i_flag |= IN_CHANGE | IN_UPDATE; } - (void) VOP_FSYNC(vp, cred, MNT_WAIT, p); + (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); return (error); } diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index e7cdc17..49f0279 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -44,7 +44,7 @@ struct fs; struct inode; struct malloc_type; struct mount; -struct proc; +struct thread; struct sockaddr; struct statfs; struct ucred; @@ -64,16 +64,16 @@ ufs_daddr_t ffs_blkpref __P((struct inode *, ufs_daddr_t, int, ufs_daddr_t *)); void ffs_clrblock __P((struct fs *, u_char *, ufs_daddr_t)); void ffs_clusteracct __P((struct fs *, struct cg *, ufs_daddr_t, int)); int ffs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); -int ffs_flushfiles __P((struct mount *, int, struct proc *)); +int ffs_flushfiles __P((struct mount *, int, struct thread *)); void ffs_fragacct __P((struct fs *, int, int32_t [], int)); int ffs_freefile __P((struct inode *, ino_t, int )); int ffs_isblock __P((struct fs *, u_char *, ufs_daddr_t)); int ffs_isfreeblock __P((struct fs *, unsigned char *, ufs_daddr_t)); -int ffs_mountfs __P((struct vnode *, struct mount *, struct proc *, +int ffs_mountfs __P((struct vnode *, struct mount *, struct thread *, struct malloc_type *)); int ffs_mountroot __P((void)); int ffs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, - struct proc *)); + struct thread *)); int ffs_reallocblks __P((struct vop_reallocblks_args *)); int ffs_realloccg __P((struct inode *, ufs_daddr_t, ufs_daddr_t, int, int, struct ucred *, struct buf **)); @@ -83,10 +83,10 @@ void ffs_snapremove __P((struct vnode *vp)); int ffs_snapshot __P((struct mount *mp, char *snapfile)); void ffs_snapshot_mount __P((struct mount *mp)); void ffs_snapshot_unmount __P((struct mount *mp)); -int ffs_statfs __P((struct mount *, struct statfs *, struct proc *)); -int ffs_sync __P((struct mount *, int, struct ucred *, struct proc *)); -int ffs_truncate __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); -int ffs_unmount __P((struct mount *, int, struct proc *)); +int ffs_statfs __P((struct mount *, struct statfs *, struct thread *)); +int ffs_sync __P((struct mount *, int, struct ucred *, struct thread *)); +int ffs_truncate __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); +int ffs_unmount __P((struct mount *, int, struct thread *)); int ffs_update __P((struct vnode *, int)); int ffs_valloc __P((struct vnode *, int, struct ucred *, struct vnode **)); @@ -104,8 +104,8 @@ extern vop_t **ffs_fifoop_p; void softdep_initialize __P((void)); int softdep_mount __P((struct vnode *, struct mount *, struct fs *, struct ucred *)); -int softdep_flushworklist __P((struct mount *, int *, struct proc *)); -int softdep_flushfiles __P((struct mount *, int, struct proc *)); +int softdep_flushworklist __P((struct mount *, int *, struct thread *)); +int softdep_flushfiles __P((struct mount *, int, struct thread *)); void softdep_update_inodeblock __P((struct inode *, struct buf *, int)); void softdep_load_inodeblock __P((struct inode *)); void softdep_freefile __P((struct vnode *, ino_t, int)); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 3af19b5..d0cd063 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -130,12 +130,12 @@ ffs_update(vp, waitfor) * disk blocks. */ int -ffs_truncate(vp, length, flags, cred, p) +ffs_truncate(vp, length, flags, cred, td) struct vnode *vp; off_t length; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *ovp = vp; ufs_daddr_t lastblock; @@ -191,7 +191,7 @@ ffs_truncate(vp, length, flags, cred, p) * so that it will have no data structures left. */ if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT, - p)) != 0) + td)) != 0) return (error); if (oip->i_flag & IN_SPACECOUNTED) fs->fs_pendingblocks -= oip->i_blocks; @@ -200,7 +200,7 @@ ffs_truncate(vp, length, flags, cred, p) (void) chkdq(oip, -oip->i_blocks, NOCRED, 0); #endif softdep_setup_freeblocks(oip, length); - vinvalbuf(ovp, 0, cred, p, 0, 0); + vinvalbuf(ovp, 0, cred, td, 0, 0); oip->i_flag |= IN_CHANGE | IN_UPDATE; return (ffs_update(ovp, 0)); } @@ -302,7 +302,7 @@ ffs_truncate(vp, length, flags, cred, p) bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks); oip->i_size = osize; - error = vtruncbuf(ovp, cred, p, length, fs->fs_bsize); + error = vtruncbuf(ovp, cred, td, length, fs->fs_bsize); if (error && (allerror == 0)) allerror = error; diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 1cbfe28..8085103 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -105,7 +105,7 @@ ffs_snapshot(mp, snapfile) void *space; struct fs *copy_fs = NULL, *fs = VFSTOUFS(mp)->um_fs; struct snaphead *snaphead; - struct proc *p = CURPROC; + struct thread *td = curthread; struct inode *ip, *xp; struct buf *bp, *nbp, *ibp, *sbp = NULL; struct nameidata nd; @@ -129,7 +129,7 @@ ffs_snapshot(mp, snapfile) * Create the snapshot file. */ restart: - NDINIT(&nd, CREATE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, snapfile, p); + NDINIT(&nd, CREATE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, snapfile, td); if ((error = namei(&nd)) != 0) return (error); if (nd.ni_vp != NULL) { @@ -162,7 +162,7 @@ restart: return (error); goto restart; } - VOP_LEASE(nd.ni_dvp, p, KERNCRED, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, KERNCRED, LEASE_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vat); vput(nd.ni_dvp); if (error) { @@ -199,7 +199,7 @@ restart: */ for (blkno = NDADDR; blkno < numblks; blkno += NINDIR(fs)) { error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno), - fs->fs_bsize, p->p_ucred, B_METAONLY, &ibp); + fs->fs_bsize, td->td_proc->p_ucred, B_METAONLY, &ibp); if (error) goto out; bdwrite(ibp); @@ -260,7 +260,7 @@ restart: /* * Ensure that the snapshot is completely on disk. */ - if ((error = VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p)) != 0) + if ((error = VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td)) != 0) goto out; /* * All allocations are done, so we can now snapshot the system. @@ -464,12 +464,12 @@ out1: out: mp->mnt_flag = flag; if (error) - (void) UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, p); - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); + (void) UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, td); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); if (error) vput(vp); else - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vn_finished_write(wrtmp); return (error); } @@ -840,7 +840,7 @@ ffs_snapblkfree(freeip, bno, size) { struct buf *ibp, *cbp, *savedcbp = 0; struct fs *fs = freeip->i_fs; - struct proc *p = CURPROC; + struct thread *td = curthread; struct inode *ip; struct vnode *vp; ufs_daddr_t lbn, blkno; @@ -857,12 +857,12 @@ ffs_snapblkfree(freeip, bno, size) if (lbn < NDADDR) { blkno = ip->i_db[lbn]; } else { - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - p->p_flag |= P_COWINPROGRESS; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + td->td_proc->p_flag |= P_COWINPROGRESS; error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, B_METAONLY, &ibp); - p->p_flag &= ~P_COWINPROGRESS; - VOP_UNLOCK(vp, 0, p); + td->td_proc->p_flag &= ~P_COWINPROGRESS; + VOP_UNLOCK(vp, 0, td); if (error) break; indiroff = (lbn - NDADDR) % NINDIR(fs); @@ -888,7 +888,7 @@ ffs_snapblkfree(freeip, bno, size) case BLK_SNAP: if (claimedblk) panic("snapblkfree: inconsistent block type"); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (lbn < NDADDR) { ip->i_db[lbn] = BLK_NOCOPY; ip->i_flag |= IN_CHANGE | IN_UPDATE; @@ -897,7 +897,7 @@ ffs_snapblkfree(freeip, bno, size) BLK_NOCOPY; bdwrite(ibp); } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); continue; /* * A block that we map is being freed. If it has not been @@ -921,7 +921,7 @@ ffs_snapblkfree(freeip, bno, size) "Grabonremove: snapino", ip->i_number, lbn, freeip->i_number); #endif - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (lbn < NDADDR) { ip->i_db[lbn] = bno; } else { @@ -930,7 +930,7 @@ ffs_snapblkfree(freeip, bno, size) } ip->i_blocks += btodb(size); ip->i_flag |= IN_CHANGE | IN_UPDATE; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (1); } if (lbn >= NDADDR) @@ -940,13 +940,13 @@ ffs_snapblkfree(freeip, bno, size) * allocation will never require any additional allocations for * the snapshot inode. */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - p->p_flag |= P_COWINPROGRESS; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + td->td_proc->p_flag |= P_COWINPROGRESS; error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, 0, &cbp); - p->p_flag &= ~P_COWINPROGRESS; + td->td_proc->p_flag &= ~P_COWINPROGRESS; if (error) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); break; } #ifdef DEBUG @@ -966,8 +966,8 @@ ffs_snapblkfree(freeip, bno, size) bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); continue; } /* @@ -977,11 +977,11 @@ ffs_snapblkfree(freeip, bno, size) bzero(cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); break; } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); savedcbp = cbp; } /* @@ -993,9 +993,9 @@ ffs_snapblkfree(freeip, bno, size) vp = savedcbp->b_vp; bawrite(savedcbp); if (dopersistence && VTOI(vp)->i_effnlink > 0) { - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); } } /* @@ -1016,7 +1016,7 @@ ffs_snapshot_mount(mp) { struct ufsmount *ump = VFSTOUFS(mp); struct fs *fs = ump->um_fs; - struct proc *p = CURPROC; + struct thread *td = curthread; struct snaphead *snaphead; struct vnode *vp; struct inode *ip; @@ -1052,7 +1052,7 @@ ffs_snapshot_mount(mp) vp->v_flag |= VSYSTEM; ump->um_devvp->v_rdev->si_copyonwrite = ffs_copyonwrite; ump->um_devvp->v_flag |= VCOPYONWRITE; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } } @@ -1087,7 +1087,7 @@ ffs_copyonwrite(devvp, bp) struct buf *bp; { struct buf *ibp, *cbp, *savedcbp = 0; - struct proc *p = CURPROC; + struct thread *td = curthread; struct fs *fs; struct inode *ip; struct vnode *vp; @@ -1096,7 +1096,7 @@ ffs_copyonwrite(devvp, bp) fs = TAILQ_FIRST(&devvp->v_rdev->si_snapshots)->i_fs; lbn = fragstoblks(fs, dbtofsb(fs, bp->b_blkno)); - if (p->p_flag & P_COWINPROGRESS) + if (td->td_proc->p_flag & P_COWINPROGRESS) panic("ffs_copyonwrite: recursive call"); TAILQ_FOREACH(ip, &devvp->v_rdev->si_snapshots, i_nextsnap) { vp = ITOV(ip); @@ -1117,19 +1117,19 @@ ffs_copyonwrite(devvp, bp) * sleep briefly, and try again. */ retry: - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (lbn < NDADDR) { blkno = ip->i_db[lbn]; } else { - p->p_flag |= P_COWINPROGRESS; + td->td_proc->p_flag |= P_COWINPROGRESS; error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, B_METAONLY | B_NOWAIT, &ibp); - p->p_flag &= ~P_COWINPROGRESS; + td->td_proc->p_flag &= ~P_COWINPROGRESS; if (error) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error != EWOULDBLOCK) break; - tsleep(vp, p->p_pri.pri_user, "nap", 1); + tsleep(vp, td->td_ksegrp->kg_pri.pri_user, "nap", 1); goto retry; } indiroff = (lbn - NDADDR) % NINDIR(fs); @@ -1141,7 +1141,7 @@ retry: panic("ffs_copyonwrite: bad copy block"); #endif if (blkno != 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); continue; } /* @@ -1149,15 +1149,15 @@ retry: * allocation will never require any additional allocations for * the snapshot inode. */ - p->p_flag |= P_COWINPROGRESS; + td->td_proc->p_flag |= P_COWINPROGRESS; error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, B_NOWAIT, &cbp); - p->p_flag &= ~P_COWINPROGRESS; + td->td_proc->p_flag &= ~P_COWINPROGRESS; if (error) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (error != EWOULDBLOCK) break; - tsleep(vp, p->p_pri.pri_user, "nap", 1); + tsleep(vp, td->td_ksegrp->kg_pri.pri_user, "nap", 1); goto retry; } #ifdef DEBUG @@ -1183,8 +1183,8 @@ retry: bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); continue; } /* @@ -1194,12 +1194,12 @@ retry: bzero(cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); break; } savedcbp = cbp; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } /* * Note that we need to synchronously write snapshots that @@ -1210,9 +1210,9 @@ retry: vp = savedcbp->b_vp; bawrite(savedcbp); if (dopersistence && VTOI(vp)->i_effnlink > 0) { - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + VOP_UNLOCK(vp, 0, td); } } return (error); @@ -1229,7 +1229,7 @@ readblock(bp, lbn) { struct uio auio; struct iovec aiov; - struct proc *p = CURPROC; + struct thread *td = curthread; struct inode *ip = VTOI(bp->b_vp); aiov.iov_base = bp->b_data; @@ -1240,6 +1240,6 @@ readblock(bp, lbn) auio.uio_resid = bp->b_bcount; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; return (physio(ip->i_devvp->v_rdev, &auio, 0)); } diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 86f9111..a4a35bc 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -149,8 +149,8 @@ static struct malloc_type *memtype[] = { static void softdep_error __P((char *, int)); static void drain_output __P((struct vnode *, int)); static int getdirtybuf __P((struct buf **, int)); -static void clear_remove __P((struct proc *)); -static void clear_inodedeps __P((struct proc *)); +static void clear_remove __P((struct thread *)); +static void clear_inodedeps __P((struct thread *)); static int flush_pagedep_deps __P((struct vnode *, struct mount *, struct diraddhd *)); static int flush_inodedep_deps __P((struct fs *, ino_t)); @@ -239,10 +239,11 @@ static struct lockit { #define FREE_LOCK_INTERLOCKED(lk) #else /* DEBUG */ +#define NOHOLDER ((struct thread *)-1) static struct lockit { int lkt_spl; - pid_t lkt_held; -} lk = { 0, -1 }; + struct thread * lkt_held; +} lk = { 0, NOHOLDER }; static int lockcnt; static void acquire_lock __P((struct lockit *)); @@ -259,18 +260,18 @@ static void acquire_lock(lk) struct lockit *lk; { - pid_t holder; + struct thread *holder; - if (lk->lkt_held != -1) { + if (lk->lkt_held != NOHOLDER) { holder = lk->lkt_held; FREE_LOCK(lk); - if (holder == CURPROC->p_pid) + if (holder == curthread) panic("softdep_lock: locking against myself"); else - panic("softdep_lock: lock held by %d", holder); + panic("softdep_lock: lock held by %p", holder); } lk->lkt_spl = splbio(); - lk->lkt_held = CURPROC->p_pid; + lk->lkt_held = curthread; lockcnt++; } @@ -279,9 +280,9 @@ free_lock(lk) struct lockit *lk; { - if (lk->lkt_held == -1) + if (lk->lkt_held == NOHOLDER) panic("softdep_unlock: lock not held"); - lk->lkt_held = -1; + lk->lkt_held = NOHOLDER; splx(lk->lkt_spl); } @@ -289,18 +290,18 @@ static void acquire_lock_interlocked(lk) struct lockit *lk; { - pid_t holder; + struct thread *holder; - if (lk->lkt_held != -1) { + if (lk->lkt_held != NOHOLDER) { holder = lk->lkt_held; FREE_LOCK(lk); - if (holder == CURPROC->p_pid) + if (holder == curthread) panic("softdep_lock_interlocked: locking against self"); else - panic("softdep_lock_interlocked: lock held by %d", + panic("softdep_lock_interlocked: lock held by %p", holder); } - lk->lkt_held = CURPROC->p_pid; + lk->lkt_held = curthread; lockcnt++; } @@ -309,9 +310,9 @@ free_lock_interlocked(lk) struct lockit *lk; { - if (lk->lkt_held == -1) + if (lk->lkt_held == NOHOLDER) panic("softdep_unlock_interlocked: lock not held"); - lk->lkt_held = -1; + lk->lkt_held = NOHOLDER; } #endif /* DEBUG */ @@ -320,7 +321,7 @@ free_lock_interlocked(lk) */ struct sema { int value; - pid_t holder; + struct thread *holder; char *name; int prio; int timo; @@ -336,7 +337,7 @@ sema_init(semap, name, prio, timo) int prio, timo; { - semap->holder = -1; + semap->holder = NOHOLDER; semap->value = 0; semap->name = name; semap->prio = prio; @@ -359,7 +360,7 @@ sema_get(semap, interlock) } return (0); } - semap->holder = CURPROC->p_pid; + semap->holder = curthread; if (interlock != NULL) FREE_LOCK(interlock); return (1); @@ -370,8 +371,8 @@ sema_release(semap) struct sema *semap; { - if (semap->value <= 0 || semap->holder != CURPROC->p_pid) { - if (lk.lkt_held != -1) + if (semap->value <= 0 || semap->holder != curthread) { + if (lk.lkt_held != NOHOLDER) FREE_LOCK(&lk); panic("sema_release: not held"); } @@ -379,7 +380,7 @@ sema_release(semap) semap->value = 0; wakeup(semap); } - semap->holder = -1; + semap->holder = NOHOLDER; } /* @@ -412,7 +413,7 @@ worklist_insert(head, item) struct worklist *item; { - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("worklist_insert: lock not held"); if (item->wk_state & ONWORKLIST) { FREE_LOCK(&lk); @@ -427,7 +428,7 @@ worklist_remove(item) struct worklist *item; { - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("worklist_remove: lock not held"); if ((item->wk_state & ONWORKLIST) == 0) { FREE_LOCK(&lk); @@ -444,12 +445,12 @@ workitem_free(item, type) { if (item->wk_state & ONWORKLIST) { - if (lk.lkt_held != -1) + if (lk.lkt_held != NOHOLDER) FREE_LOCK(&lk); panic("workitem_free: still on list"); } if (item->wk_type != type) { - if (lk.lkt_held != -1) + if (lk.lkt_held != NOHOLDER) FREE_LOCK(&lk); panic("workitem_free: type mismatch"); } @@ -469,7 +470,7 @@ static int tickdelay = 2; /* number of ticks to pause during slowdown */ static int proc_waiting; /* tracks whether we have a timeout posted */ static int *stat_countp; /* statistic to count in proc_waiting timeout */ static struct callout_handle handle; /* handle on posted proc_waiting timeout */ -static struct proc *filesys_syncer; /* proc of filesystem syncer process */ +static struct thread *filesys_syncer; /* proc of filesystem syncer process */ static int req_clear_inodedeps; /* syncer process flush some inodedeps */ #define FLUSH_INODES 1 static int req_clear_remove; /* syncer process flush some freeblks */ @@ -518,7 +519,7 @@ add_to_worklist(wk) static struct worklist *worklist_tail; if (wk->wk_state & ONWORKLIST) { - if (lk.lkt_held != -1) + if (lk.lkt_held != NOHOLDER) FREE_LOCK(&lk); panic("add_to_worklist: already on list"); } @@ -544,7 +545,7 @@ int softdep_process_worklist(matchmnt) struct mount *matchmnt; { - struct proc *p = CURPROC; + struct thread *td = curthread; int matchcnt, loopcount; long starttime; @@ -552,7 +553,7 @@ softdep_process_worklist(matchmnt) * Record the process identifier of our caller so that we can give * this process preferential treatment in request_cleanup below. */ - filesys_syncer = p; + filesys_syncer = td; matchcnt = 0; /* @@ -571,12 +572,12 @@ softdep_process_worklist(matchmnt) * If requested, try removing inode or removal dependencies. */ if (req_clear_inodedeps) { - clear_inodedeps(p); + clear_inodedeps(td); req_clear_inodedeps -= 1; wakeup_one(&proc_waiting); } if (req_clear_remove) { - clear_remove(p); + clear_remove(td); req_clear_remove -= 1; wakeup_one(&proc_waiting); } @@ -598,12 +599,12 @@ softdep_process_worklist(matchmnt) * If requested, try removing inode or removal dependencies. */ if (req_clear_inodedeps) { - clear_inodedeps(p); + clear_inodedeps(td); req_clear_inodedeps -= 1; wakeup_one(&proc_waiting); } if (req_clear_remove) { - clear_remove(p); + clear_remove(td); req_clear_remove -= 1; wakeup_one(&proc_waiting); } @@ -658,7 +659,7 @@ process_worklist_item(matchmnt, flags) dirrem = WK_DIRREM(wk); vp = ufs_ihashlookup(VFSTOUFS(dirrem->dm_mnt)->um_dev, dirrem->dm_oldinum); - if (vp == NULL || !VOP_ISLOCKED(vp, CURPROC)) + if (vp == NULL || !VOP_ISLOCKED(vp, curthread)) break; } if (wk == 0) { @@ -751,10 +752,10 @@ softdep_move_dependencies(oldbp, newbp) * Purge the work list of all items associated with a particular mount point. */ int -softdep_flushworklist(oldmnt, countp, p) +softdep_flushworklist(oldmnt, countp, td) struct mount *oldmnt; int *countp; - struct proc *p; + struct thread *td; { struct vnode *devvp; int count, error = 0; @@ -778,9 +779,9 @@ softdep_flushworklist(oldmnt, countp, p) devvp = VFSTOUFS(oldmnt)->um_devvp; while ((count = softdep_process_worklist(oldmnt)) > 0) { *countp += count; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_FSYNC(devvp, p->p_ucred, MNT_WAIT, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_FSYNC(devvp, td->td_proc->p_ucred, MNT_WAIT, td); + VOP_UNLOCK(devvp, 0, td); if (error) break; } @@ -794,10 +795,10 @@ softdep_flushworklist(oldmnt, countp, p) * Flush all vnodes and worklist items associated with a specified mount point. */ int -softdep_flushfiles(oldmnt, flags, p) +softdep_flushfiles(oldmnt, flags, td) struct mount *oldmnt; int flags; - struct proc *p; + struct thread *td; { int error, count, loopcnt; @@ -812,9 +813,9 @@ softdep_flushfiles(oldmnt, flags, p) * Do another flush in case any vnodes were brought in * as part of the cleanup operations. */ - if ((error = ffs_flushfiles(oldmnt, flags, p)) != 0) + if ((error = ffs_flushfiles(oldmnt, flags, td)) != 0) break; - if ((error = softdep_flushworklist(oldmnt, &count, p)) != 0 || + if ((error = softdep_flushworklist(oldmnt, &count, td)) != 0 || count == 0) break; } @@ -885,7 +886,7 @@ pagedep_lookup(ip, lbn, flags, pagedeppp) int i; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("pagedep_lookup: lock not held"); #endif mp = ITOV(ip)->v_mount; @@ -953,7 +954,7 @@ inodedep_lookup(fs, inum, flags, inodedeppp) int firsttry; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("inodedep_lookup: lock not held"); #endif firsttry = 1; @@ -1226,7 +1227,7 @@ bmsafemap_lookup(bp) struct worklist *wk; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("bmsafemap_lookup: lock not held"); #endif LIST_FOREACH(wk, &bp->b_dep, wk_list) @@ -1398,7 +1399,7 @@ allocdirect_merge(adphead, newadp, oldadp) struct newdirblk *newdirblk; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("allocdirect_merge: lock not held"); #endif if (newadp->ad_oldblkno != oldadp->ad_newblkno || @@ -1986,7 +1987,7 @@ free_allocdirect(adphead, adp, delay) struct worklist *wk; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("free_allocdirect: lock not held"); #endif if ((adp->ad_state & DEPCOMPLETE) == 0) @@ -2028,7 +2029,7 @@ free_newdirblk(newdirblk) int i; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("free_newdirblk: lock not held"); #endif /* @@ -2351,7 +2352,7 @@ free_allocindir(aip, inodedep) struct freefrag *freefrag; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("free_allocindir: lock not held"); #endif if ((aip->ai_state & DEPCOMPLETE) == 0) @@ -2609,7 +2610,7 @@ free_diradd(dap) struct mkdir *mkdir, *nextmd; #ifdef DEBUG - if (lk.lkt_held == -1) + if (lk.lkt_held == NOHOLDER) panic("free_diradd: lock not held"); #endif WORKLIST_REMOVE(&dap->da_list); @@ -2989,7 +2990,7 @@ static void handle_workitem_remove(dirrem) struct dirrem *dirrem; { - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; struct inodedep *inodedep; struct vnode *vp; struct inode *ip; @@ -3038,7 +3039,7 @@ handle_workitem_remove(dirrem) } inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink; FREE_LOCK(&lk); - if ((error = UFS_TRUNCATE(vp, (off_t)0, 0, p->p_ucred, p)) != 0) + if ((error = UFS_TRUNCATE(vp, (off_t)0, 0, td->td_proc->p_ucred, td)) != 0) softdep_error("handle_workitem_remove: truncate", error); /* * Rename a directory to a new parent. Since, we are both deleting @@ -3422,9 +3423,10 @@ softdep_disk_write_complete(bp) struct bmsafemap *bmsafemap; #ifdef DEBUG - if (lk.lkt_held != -1) +#define SPECIAL_FLAG NOHOLDER-1 + if (lk.lkt_held != NOHOLDER) panic("softdep_disk_write_complete: lock is held"); - lk.lkt_held = -2; + lk.lkt_held = SPECIAL_FLAG; #endif LIST_INIT(&reattach); while ((wk = LIST_FIRST(&bp->b_dep)) != NULL) { @@ -3490,7 +3492,7 @@ softdep_disk_write_complete(bp) case D_INDIRDEP: indirdep = WK_INDIRDEP(wk); if (indirdep->ir_state & GOINGAWAY) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("disk_write_complete: indirdep gone"); } bcopy(indirdep->ir_saveddata, bp->b_data, bp->b_bcount); @@ -3501,7 +3503,7 @@ softdep_disk_write_complete(bp) while ((aip = LIST_FIRST(&indirdep->ir_donehd)) != 0) { handle_allocindir_partdone(aip); if (aip == LIST_FIRST(&indirdep->ir_donehd)) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("disk_write_complete: not gone"); } } @@ -3512,7 +3514,7 @@ softdep_disk_write_complete(bp) continue; default: - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_disk_write_complete: Unknown type %s", TYPENAME(wk->wk_type)); /* NOTREACHED */ @@ -3526,9 +3528,9 @@ softdep_disk_write_complete(bp) WORKLIST_INSERT(&bp->b_dep, wk); } #ifdef DEBUG - if (lk.lkt_held != -2) + if (lk.lkt_held != SPECIAL_FLAG) panic("softdep_disk_write_complete: lock lost"); - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; #endif } @@ -3548,7 +3550,7 @@ handle_allocdirect_partdone(adp) if ((adp->ad_state & ALLCOMPLETE) != ALLCOMPLETE) return; if (adp->ad_buf != NULL) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_allocdirect_partdone: dangling dep"); } /* @@ -3586,7 +3588,7 @@ handle_allocdirect_partdone(adp) if (listadp == adp) break; if (listadp == NULL) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_allocdirect_partdone: lost dep"); } #endif /* DEBUG */ @@ -3622,7 +3624,7 @@ handle_allocindir_partdone(aip) if ((aip->ai_state & ALLCOMPLETE) != ALLCOMPLETE) return; if (aip->ai_buf != NULL) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_allocindir_partdone: dangling dependency"); } indirdep = aip->ai_indirdep; @@ -3656,7 +3658,7 @@ handle_written_inodeblock(inodedep, bp) int hadchanges; if ((inodedep->id_state & IOSTARTED) == 0) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: not started"); } inodedep->id_state &= ~IOSTARTED; @@ -3687,12 +3689,12 @@ handle_written_inodeblock(inodedep, bp) for (adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp; adp = nextadp) { nextadp = TAILQ_NEXT(adp, ad_next); if (adp->ad_state & ATTACHED) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: new entry"); } if (adp->ad_lbn < NDADDR) { if (dp->di_db[adp->ad_lbn] != adp->ad_oldblkno) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("%s: %s #%ld mismatch %d != %d", "handle_written_inodeblock", "direct pointer", adp->ad_lbn, @@ -3701,7 +3703,7 @@ handle_written_inodeblock(inodedep, bp) dp->di_db[adp->ad_lbn] = adp->ad_newblkno; } else { if (dp->di_ib[adp->ad_lbn - NDADDR] != 0) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("%s: %s #%ld allocated as %d", "handle_written_inodeblock", "indirect pointer", adp->ad_lbn - NDADDR, @@ -3719,7 +3721,7 @@ handle_written_inodeblock(inodedep, bp) * Reset the file size to its most up-to-date value. */ if (inodedep->id_savedsize == -1) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: bad size"); } if (dp->di_size != inodedep->id_savedsize) { @@ -3759,7 +3761,7 @@ handle_written_inodeblock(inodedep, bp) * have been freed. */ if (filefree != NULL) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: filefree"); } filefree = wk; @@ -3784,7 +3786,7 @@ handle_written_inodeblock(inodedep, bp) continue; default: - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: Unknown type %s", TYPENAME(wk->wk_type)); /* NOTREACHED */ @@ -3792,7 +3794,7 @@ handle_written_inodeblock(inodedep, bp) } if (filefree != NULL) { if (free_inodedep(inodedep) == 0) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_inodeblock: live inodedep"); } add_to_worklist(filefree); @@ -3842,7 +3844,7 @@ handle_written_mkdir(mkdir, type) struct pagedep *pagedep; if (mkdir->md_state != type) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_mkdir: bad type"); } dap = mkdir->md_diradd; @@ -3879,7 +3881,7 @@ handle_written_filepage(pagedep, bp) int i, chgs; if ((pagedep->pd_state & IOSTARTED) == 0) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_filepage: not started"); } pagedep->pd_state &= ~IOSTARTED; @@ -3907,7 +3909,7 @@ handle_written_filepage(pagedep, bp) dap = nextdap) { nextdap = LIST_NEXT(dap, da_pdlist); if (dap->da_state & ATTACHED) { - lk.lkt_held = -1; + lk.lkt_held = NOHOLDER; panic("handle_written_filepage: attached"); } ep = (struct direct *) @@ -4124,7 +4126,7 @@ softdep_fsync(vp) struct inode *ip; struct buf *bp; struct fs *fs; - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; int error, flushparent; ino_t parentino; ufs_lbn_t lbn; @@ -4190,9 +4192,9 @@ softdep_fsync(vp) * ufs_lookup for details on possible races. */ FREE_LOCK(&lk); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = VFS_VGET(mnt, parentino, &pvp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error != 0) return (error); /* @@ -4209,7 +4211,7 @@ softdep_fsync(vp) return (error); } if ((pagedep->pd_state & NEWBLOCK) && - (error = VOP_FSYNC(pvp, p->p_ucred, MNT_WAIT, p))) { + (error = VOP_FSYNC(pvp, td->td_proc->p_ucred, MNT_WAIT, td))) { vput(pvp); return (error); } @@ -4217,7 +4219,7 @@ softdep_fsync(vp) /* * Flush directory page containing the inode's name. */ - error = bread(pvp, lbn, blksize(fs, VTOI(pvp), lbn), p->p_ucred, + error = bread(pvp, lbn, blksize(fs, VTOI(pvp), lbn), td->td_proc->p_ucred, &bp); if (error == 0) error = BUF_WRITE(bp); @@ -4294,7 +4296,7 @@ softdep_sync_metadata(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -4539,7 +4541,7 @@ loop: if (vn_isdisk(vp, NULL) && vp->v_rdev->si_mountpoint && !VOP_ISLOCKED(vp, NULL) && (error = VFS_SYNC(vp->v_rdev->si_mountpoint, MNT_WAIT, ap->a_cred, - ap->a_p)) != 0) + ap->a_td)) != 0) return (error); return (0); } @@ -4643,7 +4645,7 @@ flush_pagedep_deps(pvp, mp, diraddhdp) struct mount *mp; struct diraddhd *diraddhdp; { - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; struct inodedep *inodedep; struct ufsmount *ump; struct diradd *dap; @@ -4690,8 +4692,8 @@ flush_pagedep_deps(pvp, mp, diraddhdp) FREE_LOCK(&lk); if ((error = VFS_VGET(mp, inum, &vp)) != 0) break; - if ((error=VOP_FSYNC(vp, p->p_ucred, MNT_NOWAIT, p)) || - (error=VOP_FSYNC(vp, p->p_ucred, MNT_NOWAIT, p))) { + if ((error=VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_NOWAIT, td)) || + (error=VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_NOWAIT, td))) { vput(vp); break; } @@ -4792,12 +4794,12 @@ request_cleanup(resource, islocked) int resource; int islocked; { - struct proc *p = CURPROC; + struct thread *td = curthread; /* * We never hold up the filesystem syncer process. */ - if (p == filesys_syncer) + if (td == filesys_syncer) return (0); /* * First check to see if the work list has gotten backlogged. @@ -4891,8 +4893,8 @@ pause_timer(arg) * reduce the number of dirrem, freefile, and freeblks dependency structures. */ static void -clear_remove(p) - struct proc *p; +clear_remove(td) + struct thread *td; { struct pagedep_hashhead *pagedephd; struct pagedep *pagedep; @@ -4920,7 +4922,7 @@ clear_remove(p) vn_finished_write(mp); return; } - if ((error = VOP_FSYNC(vp, p->p_ucred, MNT_NOWAIT, p))) + if ((error = VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_NOWAIT, td))) softdep_error("clear_remove: fsync", error); drain_output(vp, 0); vput(vp); @@ -4936,8 +4938,8 @@ clear_remove(p) * the number of inodedep dependency structures. */ static void -clear_inodedeps(p) - struct proc *p; +clear_inodedeps(td) + struct thread *td; { struct inodedep_hashhead *inodedephd; struct inodedep *inodedep; @@ -4994,10 +4996,10 @@ clear_inodedeps(p) return; } if (ino == lastino) { - if ((error = VOP_FSYNC(vp, p->p_ucred, MNT_WAIT, p))) + if ((error = VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_WAIT, td))) softdep_error("clear_inodedeps: fsync1", error); } else { - if ((error = VOP_FSYNC(vp, p->p_ucred, MNT_NOWAIT, p))) + if ((error = VOP_FSYNC(vp, td->td_proc->p_ucred, MNT_NOWAIT, td))) softdep_error("clear_inodedeps: fsync2", error); drain_output(vp, 0); } diff --git a/sys/ufs/ffs/ffs_softdep_stub.c b/sys/ufs/ffs/ffs_softdep_stub.c index 7511533..c47fdb5 100644 --- a/sys/ufs/ffs/ffs_softdep_stub.c +++ b/sys/ufs/ffs/ffs_softdep_stub.c @@ -55,10 +55,10 @@ #include <ufs/ufs/ufs_extern.h> int -softdep_flushfiles(oldmnt, flags, p) +softdep_flushfiles(oldmnt, flags, td) struct mount *oldmnt; int flags; - struct proc *p; + struct thread *td; { panic("softdep_flushfiles called"); @@ -244,10 +244,10 @@ softdep_fsync_mountdev(vp) } int -softdep_flushworklist(oldmnt, countp, p) +softdep_flushworklist(oldmnt, countp, td) struct mount *oldmnt; int *countp; - struct proc *p; + struct thread *td; { *countp = 0; @@ -260,7 +260,7 @@ softdep_sync_metadata(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index f741036..48a8ba97 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -67,7 +67,7 @@ static MALLOC_DEFINE(M_FFSNODE, "FFS node", "FFS vnode private part"); static int ffs_sbupdate __P((struct ufsmount *, int)); -int ffs_reload __P((struct mount *,struct ucred *,struct proc *)); +int ffs_reload __P((struct mount *,struct ucred *,struct thread *)); static int ffs_oldfscompat __P((struct fs *)); static int ffs_init __P((struct vfsconf *)); @@ -132,12 +132,12 @@ VFS_SET(ufs_vfsops, ufs, 0); * namei() if it is a genuine NULL from the user. */ int -ffs_mount(mp, path, data, ndp, p) +ffs_mount(mp, path, data, ndp, td) struct mount *mp; /* mount struct pointer*/ char *path; /* path to mount point*/ caddr_t data; /* arguments to FS specific mount*/ struct nameidata *ndp; /* mount point credentials*/ - struct proc *p; /* process requesting mount*/ + struct thread *td; /* process requesting mount*/ { size_t size; struct vnode *devvp; @@ -156,10 +156,10 @@ ffs_mount(mp, path, data, ndp, p) return (error); } - if ((error = ffs_mountfs(rootvp, mp, p, M_FFSNODE)) != 0) + if ((error = ffs_mountfs(rootvp, mp, td, M_FFSNODE)) != 0) return (error); - (void)VFS_STATFS(mp, &mp->mnt_stat, p); + (void)VFS_STATFS(mp, &mp->mnt_stat, td); return (0); } @@ -184,9 +184,9 @@ ffs_mount(mp, path, data, ndp, p) if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; if (mp->mnt_flag & MNT_SOFTDEP) { - error = softdep_flushfiles(mp, flags, p); + error = softdep_flushfiles(mp, flags, td); } else { - error = ffs_flushfiles(mp, flags, p); + error = ffs_flushfiles(mp, flags, td); } if (error) { vn_finished_write(mp); @@ -212,21 +212,21 @@ ffs_mount(mp, path, data, ndp, p) vn_finished_write(mp); } if ((mp->mnt_flag & MNT_RELOAD) && - (error = ffs_reload(mp, ndp->ni_cnd.cn_cred, p)) != 0) + (error = ffs_reload(mp, ndp->ni_cnd.cn_cred, td)) != 0) return (error); if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { /* * If upgrade to read-write by non-root, then verify * that user has necessary permissions on the device. */ - if (p->p_ucred->cr_uid != 0) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); + if (td->td_proc->p_ucred->cr_uid != 0) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, - p->p_ucred, p)) != 0) { - VOP_UNLOCK(devvp, 0, p); + td->td_proc->p_ucred, td)) != 0) { + VOP_UNLOCK(devvp, 0, td); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } fs->fs_flags &= ~FS_UNCLEAN; if (fs->fs_clean == 0) { @@ -253,7 +253,7 @@ ffs_mount(mp, path, data, ndp, p) } /* check to see if we need to start softdep */ if ((fs->fs_flags & FS_DOSOFTDEP) && - (error = softdep_mount(devvp, mp, fs, p->p_ucred))){ + (error = softdep_mount(devvp, mp, fs, td->td_proc->p_ucred))){ vn_finished_write(mp); return (error); } @@ -286,7 +286,7 @@ ffs_mount(mp, path, data, ndp, p) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); if ((error = namei(ndp)) != 0) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -300,16 +300,16 @@ ffs_mount(mp, path, data, ndp, p) * If mount by non-root, then verify that user has necessary * permissions on the device. */ - if (p->p_ucred->cr_uid != 0) { + if (td->td_proc->p_ucred->cr_uid != 0) { accessmode = VREAD; if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p))!= 0){ + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_ACCESS(devvp, accessmode, td->td_proc->p_ucred, td))!= 0){ vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if (mp->mnt_flag & MNT_UPDATE) { @@ -335,7 +335,7 @@ ffs_mount(mp, path, data, ndp, p) * the mount point is discarded by the upper level code. * Note that vfs_mount() populates f_mntonname for us. */ - if ((error = ffs_mountfs(devvp, mp, p, M_FFSNODE)) != 0) { + if ((error = ffs_mountfs(devvp, mp, td, M_FFSNODE)) != 0) { vrele(devvp); return (error); } @@ -348,7 +348,7 @@ ffs_mount(mp, path, data, ndp, p) /* * Initialize filesystem stat information in mount struct. */ - (void)VFS_STATFS(mp, &mp->mnt_stat, p); + (void)VFS_STATFS(mp, &mp->mnt_stat, td); return (0); } @@ -366,10 +366,10 @@ ffs_mount(mp, path, data, ndp, p) * 6) re-read inode data for all active vnodes. */ int -ffs_reload(mp, cred, p) +ffs_reload(mp, cred, td) register struct mount *mp; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct vnode *vp, *nvp, *devvp; struct inode *ip; @@ -387,9 +387,9 @@ ffs_reload(mp, cred, p) * Step 1: invalidate all cached meta-data. */ devvp = VFSTOUFS(mp)->um_devvp; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = vinvalbuf(devvp, 0, cred, p, 0, 0); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = vinvalbuf(devvp, 0, cred, td, 0, 0); + VOP_UNLOCK(devvp, 0, td); if (error) panic("ffs_reload: dirty1"); @@ -400,16 +400,16 @@ ffs_reload(mp, cred, p) * block device. */ if (vn_isdisk(devvp, NULL)) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - vfs_object_create(devvp, p, p->p_ucred); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + vfs_object_create(devvp, td, td->td_proc->p_ucred); mtx_lock(&devvp->v_interlock); - VOP_UNLOCK(devvp, LK_INTERLOCK, p); + VOP_UNLOCK(devvp, LK_INTERLOCK, td); } /* * Step 2: re-read superblock from disk. */ - if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) + if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, td) != 0) size = DEV_BSIZE; else size = dpart.disklab->d_secsize; @@ -486,16 +486,16 @@ loop: /* * Step 4: invalidate all inactive vnodes. */ - if (vrecycle(vp, NULL, p)) + if (vrecycle(vp, NULL, td)) goto loop; /* * Step 5: invalidate all cached file data. */ mtx_lock(&vp->v_interlock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { goto loop; } - if (vinvalbuf(vp, 0, cred, p, 0, 0)) + if (vinvalbuf(vp, 0, cred, td, 0, 0)) panic("ffs_reload: dirty2"); /* * Step 6: re-read inode data for all active vnodes. @@ -527,10 +527,10 @@ SYSCTL_INT(_debug, OID_AUTO, bigcgs, CTLFLAG_RW, &bigcgs, 0, ""); * Common code for mount and mountroot */ int -ffs_mountfs(devvp, mp, p, malloctype) +ffs_mountfs(devvp, mp, td, malloctype) register struct vnode *devvp; struct mount *mp; - struct proc *p; + struct thread *td; struct malloc_type *malloctype; { register struct ufsmount *ump; @@ -547,7 +547,7 @@ ffs_mountfs(devvp, mp, p, malloctype) int ncount; dev = devvp->v_rdev; - cred = p ? p->p_ucred : NOCRED; + cred = td ? td->td_proc->p_ucred : NOCRED; /* * Disallow multiple mounts of the same device. * Disallow mounting of a device that is currently in use @@ -561,9 +561,9 @@ ffs_mountfs(devvp, mp, p, malloctype) if (ncount > 1 && devvp != rootvp) return (EBUSY); - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = vinvalbuf(devvp, V_SAVE, cred, td, 0, 0); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); @@ -574,16 +574,16 @@ ffs_mountfs(devvp, mp, p, malloctype) * increases the opportunity for metadata caching. */ if (vn_isdisk(devvp, NULL)) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - vfs_object_create(devvp, p, cred); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + vfs_object_create(devvp, td, cred); mtx_lock(&devvp->v_interlock); - VOP_UNLOCK(devvp, LK_INTERLOCK, p); + VOP_UNLOCK(devvp, LK_INTERLOCK, td); } ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); - VOP_UNLOCK(devvp, 0, p); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td); + VOP_UNLOCK(devvp, 0, td); if (error) return (error); if (devvp->v_rdev->si_iosize_max > mp->mnt_iosize_max) @@ -591,7 +591,7 @@ ffs_mountfs(devvp, mp, p, malloctype) if (mp->mnt_iosize_max > MAXPHYS) mp->mnt_iosize_max = MAXPHYS; - if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0) + if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, td) != 0) size = DEV_BSIZE; else size = dpart.disklab->d_secsize; @@ -767,7 +767,7 @@ ffs_mountfs(devvp, mp, p, malloctype) * This would all happen while the file system was busy/not * available, so would effectively be "atomic". */ - (void) ufs_extattr_autostart(mp, p); + (void) ufs_extattr_autostart(mp, td); #endif /* !UFS_EXTATTR_AUTOSTART */ #endif /* !UFS_EXTATTR */ return (0); @@ -775,7 +775,7 @@ out: devvp->v_rdev->si_mountpoint = NULL; if (bp) brelse(bp); - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, cred, p); + (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, cred, td); if (ump) { free(ump->um_fs, M_UFSMNT); free(ump, M_UFSMNT); @@ -820,10 +820,10 @@ ffs_oldfscompat(fs) * unmount system call */ int -ffs_unmount(mp, mntflags, p) +ffs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump = VFSTOUFS(mp); register struct fs *fs; @@ -834,7 +834,7 @@ ffs_unmount(mp, mntflags, p) flags |= FORCECLOSE; } #ifdef UFS_EXTATTR - if ((error = ufs_extattr_stop(mp, p))) { + if ((error = ufs_extattr_stop(mp, td))) { if (error != EOPNOTSUPP) printf("ffs_unmount: ufs_extattr_stop returned %d\n", error); @@ -843,10 +843,10 @@ ffs_unmount(mp, mntflags, p) } #endif if (mp->mnt_flag & MNT_SOFTDEP) { - if ((error = softdep_flushfiles(mp, flags, p)) != 0) + if ((error = softdep_flushfiles(mp, flags, td)) != 0) return (error); } else { - if ((error = ffs_flushfiles(mp, flags, p)) != 0) + if ((error = ffs_flushfiles(mp, flags, td)) != 0) return (error); } fs = ump->um_fs; @@ -870,9 +870,9 @@ ffs_unmount(mp, mntflags, p) } ump->um_devvp->v_rdev->si_mountpoint = NULL; - vinvalbuf(ump->um_devvp, V_SAVE, NOCRED, p, 0, 0); + vinvalbuf(ump->um_devvp, V_SAVE, NOCRED, td, 0, 0); error = VOP_CLOSE(ump->um_devvp, fs->fs_ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); + NOCRED, td); vrele(ump->um_devvp); @@ -888,10 +888,10 @@ ffs_unmount(mp, mntflags, p) * Flush out all the files in a filesystem. */ int -ffs_flushfiles(mp, flags, p) +ffs_flushfiles(mp, flags, td) register struct mount *mp; int flags; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; int error; @@ -906,7 +906,7 @@ ffs_flushfiles(mp, flags, p) for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] == NULLVP) continue; - quotaoff(p, mp, i); + quotaoff(td, mp, i); } /* * Here we fall through to vflush again to ensure @@ -931,9 +931,9 @@ ffs_flushfiles(mp, flags, p) /* * Flush filesystem metadata. */ - vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_FSYNC(ump->um_devvp, p->p_ucred, MNT_WAIT, p); - VOP_UNLOCK(ump->um_devvp, 0, p); + vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_FSYNC(ump->um_devvp, td->td_proc->p_ucred, MNT_WAIT, td); + VOP_UNLOCK(ump->um_devvp, 0, td); return (error); } @@ -941,10 +941,10 @@ ffs_flushfiles(mp, flags, p) * Get file system statistics. */ int -ffs_statfs(mp, sbp, p) +ffs_statfs(mp, sbp, td) struct mount *mp; register struct statfs *sbp; - struct proc *p; + struct thread *td; { register struct ufsmount *ump; register struct fs *fs; @@ -980,11 +980,11 @@ ffs_statfs(mp, sbp, p) * Note: we are always called with the filesystem marked `MPBUSY'. */ int -ffs_sync(mp, waitfor, cred, p) +ffs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *nvp, *vp, *devvp; struct inode *ip; @@ -1028,15 +1028,15 @@ loop: continue; } if (vp->v_type != VCHR) { - if ((error = vget(vp, lockreq, p)) != 0) { + if ((error = vget(vp, lockreq, td)) != 0) { mtx_lock(&mntvnode_mtx); if (error == ENOENT) goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0) + if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vrele(vp); } else { mtx_unlock(&vp->v_interlock); @@ -1049,7 +1049,7 @@ loop: * Force stale file system control information to be flushed. */ if (waitfor == MNT_WAIT) { - if ((error = softdep_flushworklist(ump->um_mountp, &count, p))) + if ((error = softdep_flushworklist(ump->um_mountp, &count, td))) allerror = error; /* Flushed work items may create new vnodes to clean */ if (count) { @@ -1065,10 +1065,10 @@ loop: if (waitfor != MNT_LAZY && (devvp->v_numoutput > 0 || TAILQ_FIRST(&devvp->v_dirtyblkhd))) { mtx_unlock(&devvp->v_interlock); - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((error = VOP_FSYNC(devvp, cred, waitfor, p)) != 0) + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + if ((error = VOP_FSYNC(devvp, cred, waitfor, td)) != 0) allerror = error; - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); if (waitfor == MNT_WAIT) { mtx_lock(&mntvnode_mtx); goto loop; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index c50fe0f..78c32ea 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -130,7 +130,7 @@ ffs_fsync(ap) struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -147,7 +147,7 @@ ffs_fsync(ap) * out from underneath us. */ if (ip->i_flags & SF_SNAPSHOT) - VOP_UNLOCK(vp, 0, ap->a_p); + VOP_UNLOCK(vp, 0, ap->a_td); wait = (ap->a_waitfor == MNT_WAIT); if (vn_isdisk(vp, NULL)) { lbn = INT_MAX; @@ -291,6 +291,6 @@ loop: splx(s); error = UFS_UPDATE(vp, wait); if (ip->i_flags & SF_SNAPSHOT) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td); return (error); } diff --git a/sys/ufs/ifs/ifs_extern.h b/sys/ufs/ifs/ifs_extern.h index 62d3581..df3af4a 100644 --- a/sys/ufs/ifs/ifs_extern.h +++ b/sys/ufs/ifs/ifs_extern.h @@ -64,7 +64,6 @@ struct fs; struct inode; struct malloc_type; struct mount; -struct proc; struct sockaddr; struct statfs; struct ucred; diff --git a/sys/ufs/ifs/ifs_lookup.c b/sys/ufs/ifs/ifs_lookup.c index 7f65967..c6e5873 100644 --- a/sys/ufs/ifs/ifs_lookup.c +++ b/sys/ufs/ifs/ifs_lookup.c @@ -119,7 +119,7 @@ ifs_lookup(ap) int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; int error, lockparent, wantparent; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; ufs_daddr_t inodenum; char *endp; @@ -140,12 +140,12 @@ ifs_lookup(ap) return (EPERM); } /* Deal with the '.' directory */ - /* VOP_UNLOCK(vdp, 0, p); */ + /* VOP_UNLOCK(vdp, 0, td); */ if (cnp->cn_namelen == 1 && *(cnp->cn_nameptr) == '.') { /* We don't unlock the parent dir since the're the same */ *vpp = vdp; VREF(vdp); - /* vn_lock(vdp, LK_SHARED | LK_RETRY, p); */ + /* vn_lock(vdp, LK_SHARED | LK_RETRY, td); */ return (0); } /* @@ -155,12 +155,12 @@ ifs_lookup(ap) if ((cnp->cn_namelen) == 7 && (strncmp(cnp->cn_nameptr, "newfile", 7) == 0)) { if (nameiop == CREATE) { /* Check for write permissions in . */ - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) return (error); *vpp = NULL; if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); cnp->cn_flags |= SAVENAME; return (EJUSTRETURN); } else { @@ -246,7 +246,7 @@ ifs_lookup(ap) if (error) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); *vpp = tdp; return (0); } diff --git a/sys/ufs/ifs/ifs_vfsops.c b/sys/ufs/ifs/ifs_vfsops.c index 41b1d5f..0cbf5d0 100644 --- a/sys/ufs/ifs/ifs_vfsops.c +++ b/sys/ufs/ifs/ifs_vfsops.c @@ -70,7 +70,7 @@ static MALLOC_DEFINE(M_IFSNODE, "IFS node", "IFS vnode private part"); static int ifs_init (struct vfsconf *); static int ifs_mount (struct mount *, char *, caddr_t, - struct nameidata *, struct proc *); + struct nameidata *, struct thread *); extern int ifs_vget (struct mount *, ino_t, struct vnode **); @@ -101,16 +101,16 @@ VFS_SET(ifs_vfsops, ifs, 0); * deal with softupdates so we make sure the user isn't trying to use it. */ static int -ifs_mount(mp, path, data, ndp, p) +ifs_mount(mp, path, data, ndp, td) struct mount *mp; char *path; caddr_t data; struct nameidata *ndp; - struct proc *p; + struct thread *td; { /* Clear the softdep flag */ mp->mnt_flag &= ~MNT_SOFTDEP; - return (ffs_mount(mp, path, data, ndp, p)); + return (ffs_mount(mp, path, data, ndp, td)); } diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h index b609ded..0eca43f 100644 --- a/sys/ufs/ufs/extattr.h +++ b/sys/ufs/ufs/extattr.h @@ -93,14 +93,14 @@ struct ufs_extattr_per_mount { void ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm); void ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm); -int ufs_extattr_start(struct mount *mp, struct proc *p); -int ufs_extattr_autostart(struct mount *mp, struct proc *p); -int ufs_extattr_stop(struct mount *mp, struct proc *p); +int ufs_extattr_start(struct mount *mp, struct thread *td); +int ufs_extattr_autostart(struct mount *mp, struct thread *td); +int ufs_extattr_stop(struct mount *mp, struct thread *td); int ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename, - int attrnamespace, const char *attrname, struct proc *p); + int attrnamespace, const char *attrname, struct thread *td); int ufs_vop_getextattr(struct vop_getextattr_args *ap); int ufs_vop_setextattr(struct vop_setextattr_args *ap); -void ufs_extattr_vnode_inactive(struct vnode *vp, struct proc *p); +void ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td); #endif /* !_KERNEL */ diff --git a/sys/ufs/ufs/quota.h b/sys/ufs/ufs/quota.h index efa714e..080569c 100644 --- a/sys/ufs/ufs/quota.h +++ b/sys/ufs/ufs/quota.h @@ -174,7 +174,7 @@ struct dquot { struct inode; struct mount; -struct proc; +struct thread; struct ucred; struct vnode; @@ -185,11 +185,11 @@ void dqrele __P((struct vnode *, struct dquot *)); int getinoquota __P((struct inode *)); int getquota __P((struct mount *, u_long, int, caddr_t)); int qsync __P((struct mount *mp)); -int quotaoff __P((struct proc *, struct mount *, int)); -int quotaon __P((struct proc *, struct mount *, int, caddr_t)); +int quotaoff __P((struct thread *td, struct mount *, int)); +int quotaon __P((struct thread *td, struct mount *, int, caddr_t)); int setquota __P((struct mount *, u_long, int, caddr_t)); int setuse __P((struct mount *, u_long, int, caddr_t)); -int ufs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); +int ufs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct thread *td)); #else /* !_KERNEL */ diff --git a/sys/ufs/ufs/ufs_acl.c b/sys/ufs/ufs/ufs_acl.c index d5ab20b..56e4828 100644 --- a/sys/ufs/ufs/ufs_acl.c +++ b/sys/ufs/ufs/ufs_acl.c @@ -217,7 +217,7 @@ ufs_getacl(ap) struct acl_type_t type; struct acl *aclp; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { struct inode *ip = VTOI(ap->a_vp); @@ -241,7 +241,7 @@ ufs_getacl(ap) error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE, POSIX1E_ACL_ACCESS_EXTATTR_NAME, &len, (char *) ap->a_aclp, - ap->a_p); + ap->a_td); switch (error) { /* XXX: Will be ENOATTR. */ /* XXX: If ufs_getacl() should work on file systems without @@ -294,7 +294,7 @@ ufs_getacl(ap) error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE, POSIX1E_ACL_DEFAULT_EXTATTR_NAME, &len, - (char *) ap->a_aclp, ap->a_p); + (char *) ap->a_aclp, ap->a_td); /* * Unlike ACL_TYPE_ACCESS, there is no relationship between * the inode contents and the ACL, and it is therefore @@ -370,7 +370,7 @@ ufs_setacl(ap) * Set operation. */ error = VOP_ACLCHECK(ap->a_vp, ap->a_type, ap->a_aclp, - ap->a_cred, ap->a_p); + ap->a_cred, ap->a_td); if (error != 0) return (error); } else { @@ -397,7 +397,7 @@ ufs_setacl(ap) /* * Must hold VADMIN (be file owner) or have appropriate privilege. */ - if ((error = VOP_ACCESS(ap->a_vp, VADMIN, ap->a_cred, ap->a_p))) + if ((error = VOP_ACCESS(ap->a_vp, VADMIN, ap->a_cred, ap->a_td))) return (error); switch(ap->a_type) { @@ -405,14 +405,14 @@ ufs_setacl(ap) error = vn_extattr_set(ap->a_vp, IO_NODELOCKED, POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE, POSIX1E_ACL_ACCESS_EXTATTR_NAME, sizeof(*ap->a_aclp), - (char *) ap->a_aclp, ap->a_p); + (char *) ap->a_aclp, ap->a_td); break; case ACL_TYPE_DEFAULT: if (ap->a_aclp == NULL) { error = vn_extattr_rm(ap->a_vp, IO_NODELOCKED, POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE, - POSIX1E_ACL_DEFAULT_EXTATTR_NAME, ap->a_p); + POSIX1E_ACL_DEFAULT_EXTATTR_NAME, ap->a_td); /* * Attempting to delete a non-present default ACL * will return success for portability purposes. @@ -425,7 +425,7 @@ ufs_setacl(ap) error = vn_extattr_set(ap->a_vp, IO_NODELOCKED, POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE, POSIX1E_ACL_DEFAULT_EXTATTR_NAME, - sizeof(*ap->a_aclp), (char *) ap->a_aclp, ap->a_p); + sizeof(*ap->a_aclp), (char *) ap->a_aclp, ap->a_td); break; default: @@ -466,7 +466,7 @@ ufs_aclcheck(ap) acl_type_t type; struct acl *aclp; struct ucred *cred; - struct proc *p; + struct thread *td; } */ *ap; { diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c index b713267..60dc574 100644 --- a/sys/ufs/ufs/ufs_extattr.c +++ b/sys/ufs/ufs/ufs_extattr.c @@ -66,20 +66,20 @@ SYSCTL_INT(_debug, OID_AUTO, ufs_extattr_sync, CTLFLAG_RW, &ufs_extattr_sync, static int ufs_extattr_valid_attrname(const char *attrname); static int ufs_extattr_credcheck(struct vnode *vp, - struct ufs_extattr_list_entry *uele, struct ucred *cred, struct proc *p, + struct ufs_extattr_list_entry *uele, struct ucred *cred, struct thread *td, int access); static int ufs_extattr_enable_with_open(struct ufsmount *ump, - struct vnode *vp, int attrnamespace, const char *attrname, struct proc *p); + struct vnode *vp, int attrnamespace, const char *attrname, struct thread *td); static int ufs_extattr_enable(struct ufsmount *ump, int attrnamespace, - const char *attrname, struct vnode *backing_vnode, struct proc *p); + const char *attrname, struct vnode *backing_vnode, struct thread *td); static int ufs_extattr_disable(struct ufsmount *ump, int attrnamespace, - const char *attrname, struct proc *p); + const char *attrname, struct thread *td); static int ufs_extattr_get(struct vnode *vp, int attrnamespace, - const char *name, struct uio *uio, struct ucred *cred, struct proc *p); + const char *name, struct uio *uio, struct ucred *cred, struct thread *td); static int ufs_extattr_set(struct vnode *vp, int attrnamespace, - const char *name, struct uio *uio, struct ucred *cred, struct proc *p); + const char *name, struct uio *uio, struct ucred *cred, struct thread *td); static int ufs_extattr_rm(struct vnode *vp, int attrnamespace, - const char *name, struct ucred *cred, struct proc *p); + const char *name, struct ucred *cred, struct thread *td); /* * Per-FS attribute lock protecting attribute operations. @@ -87,19 +87,19 @@ static int ufs_extattr_rm(struct vnode *vp, int attrnamespace, * lock per-FS; really, this should be far more fine-grained. */ static void -ufs_extattr_uepm_lock(struct ufsmount *ump, struct proc *p) +ufs_extattr_uepm_lock(struct ufsmount *ump, struct thread *td) { /* Ideally, LK_CANRECURSE would not be used, here. */ lockmgr(&ump->um_extattr.uepm_lock, LK_EXCLUSIVE | LK_RETRY | - LK_CANRECURSE, 0, p); + LK_CANRECURSE, 0, td); } static void -ufs_extattr_uepm_unlock(struct ufsmount *ump, struct proc *p) +ufs_extattr_uepm_unlock(struct ufsmount *ump, struct thread *td) { - lockmgr(&ump->um_extattr.uepm_lock, LK_RELEASE, 0, p); + lockmgr(&ump->um_extattr.uepm_lock, LK_RELEASE, 0, td); } /* @@ -190,14 +190,14 @@ ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm) * Start extended attribute support on an FS. */ int -ufs_extattr_start(struct mount *mp, struct proc *p) +ufs_extattr_start(struct mount *mp, struct thread *td) { struct ufsmount *ump; int error = 0; ump = VFSTOUFS(mp); - ufs_extattr_uepm_lock(ump, p); + ufs_extattr_uepm_lock(ump, td); if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED)) { error = EOPNOTSUPP; @@ -210,11 +210,11 @@ ufs_extattr_start(struct mount *mp, struct proc *p) ump->um_extattr.uepm_flags |= UFS_EXTATTR_UEPM_STARTED; - crhold(p->p_ucred); - ump->um_extattr.uepm_ucred = p->p_ucred; + crhold(td->td_proc->p_ucred); + ump->um_extattr.uepm_ucred = td->td_proc->p_ucred; unlock: - ufs_extattr_uepm_unlock(ump, p); + ufs_extattr_uepm_unlock(ump, td); return (error); } @@ -232,7 +232,7 @@ unlock: #define UE_GETDIR_LOCKPARENT_DONT 2 static int ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, - struct vnode **vp, struct proc *p) + struct vnode **vp, struct thread *td) { struct vop_cachedlookup_args vargs; struct componentname cnp; @@ -244,15 +244,15 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, cnp.cn_flags = ISLASTCN; if (lockparent == UE_GETDIR_LOCKPARENT) cnp.cn_flags |= LOCKPARENT; - cnp.cn_proc = p; - cnp.cn_cred = p->p_ucred; + cnp.cn_thread = td; + cnp.cn_cred = td->td_proc->p_ucred; cnp.cn_pnbuf = zalloc(namei_zone); cnp.cn_nameptr = cnp.cn_pnbuf; error = copystr(dirname, cnp.cn_pnbuf, MAXPATHLEN, (size_t *) &cnp.cn_namelen); if (error) { if (lockparent == UE_GETDIR_LOCKPARENT_DONT) { - VOP_UNLOCK(start_dvp, 0, p); + VOP_UNLOCK(start_dvp, 0, td); } zfree(namei_zone, cnp.cn_pnbuf); printf("ufs_extattr_lookup: copystr failed\n"); @@ -272,7 +272,7 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, */ if (!(cnp.cn_flags & PDIRUNLOCK) && (lockparent == UE_GETDIR_LOCKPARENT_DONT)) - VOP_UNLOCK(start_dvp, 0, p); + VOP_UNLOCK(start_dvp, 0, td); /* * Check that ufs_lookup() didn't release the lock when we @@ -313,15 +313,15 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, char *dirname, */ static int ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp, - int attrnamespace, const char *attrname, struct proc *p) + int attrnamespace, const char *attrname, struct thread *td) { int error; - error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p); + error = VOP_OPEN(vp, FREAD|FWRITE, td->td_proc->p_ucred, td); if (error) { printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed " "with %d\n", error); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -330,12 +330,12 @@ ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp, * to a similar piece of code in vn_open(), we don't. */ if (vn_canvmio(vp) == TRUE) - if ((error = vfs_object_create(vp, p, p->p_ucred)) != 0) { + if ((error = vfs_object_create(vp, td, td->td_proc->p_ucred)) != 0) { /* * XXX: bug replicated from vn_open(): should * VOP_CLOSE() here. */ - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -343,11 +343,11 @@ ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp, vref(vp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); - error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, p); + error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td); if (error != 0) - vn_close(vp, FREAD|FWRITE, p->p_ucred, p); + vn_close(vp, FREAD|FWRITE, td->td_proc->p_ucred, td); return (error); } @@ -361,7 +361,7 @@ ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp, */ static int ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp, - int attrnamespace, struct proc *p) + int attrnamespace, struct thread *td) { struct vop_readdir_args vargs; struct dirent *dp, *edp; @@ -380,13 +380,13 @@ ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp, auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; + auio.uio_td = td; auio.uio_offset = 0; vargs.a_desc = NULL; vargs.a_vp = dvp; vargs.a_uio = &auio; - vargs.a_cred = p->p_ucred; + vargs.a_cred = td->td_proc->p_ucred; vargs.a_eofflag = &eofflag; vargs.a_ncookies = NULL; vargs.a_cookies = NULL; @@ -413,7 +413,7 @@ ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp, if (dp->d_reclen == 0) break; error = ufs_extattr_lookup(dvp, UE_GETDIR_LOCKPARENT, - dp->d_name, &attr_vp, p); + dp->d_name, &attr_vp, td); if (error) { printf("ufs_extattr_iterate_directory: lookup " "%s %d\n", dp->d_name, error); @@ -429,7 +429,7 @@ ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp, vput(attr_vp); } else { error = ufs_extattr_enable_with_open(ump, - attr_vp, attrnamespace, dp->d_name, p); + attr_vp, attrnamespace, dp->d_name, td); vrele(attr_vp); if (error) { printf("ufs_extattr_iterate_directory: " @@ -458,7 +458,7 @@ ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp, * mount-time. */ int -ufs_extattr_autostart(struct mount *mp, struct proc *p) +ufs_extattr_autostart(struct mount *mp, struct thread *td) { struct vnode *rvp, *attr_dvp, *attr_system_dvp, *attr_user_dvp; int error; @@ -474,7 +474,7 @@ ufs_extattr_autostart(struct mount *mp, struct proc *p) } error = ufs_extattr_lookup(rvp, UE_GETDIR_LOCKPARENT_DONT, - UFS_EXTATTR_FSROOTSUBDIR, &attr_dvp, p); + UFS_EXTATTR_FSROOTSUBDIR, &attr_dvp, td); if (error) { /* rvp ref'd but now unlocked */ vrele(rvp); @@ -494,7 +494,7 @@ ufs_extattr_autostart(struct mount *mp, struct proc *p) goto return_vput_attr_dvp; } - error = ufs_extattr_start(mp, p); + error = ufs_extattr_start(mp, td); if (error) { printf("ufs_extattr_autostart: ufs_extattr_start failed (%d)\n", error); @@ -509,10 +509,10 @@ ufs_extattr_autostart(struct mount *mp, struct proc *p) * be cleaned up on exit. */ error = ufs_extattr_lookup(attr_dvp, UE_GETDIR_LOCKPARENT, - UFS_EXTATTR_SUBDIR_SYSTEM, &attr_system_dvp, p); + UFS_EXTATTR_SUBDIR_SYSTEM, &attr_system_dvp, td); if (!error) { error = ufs_extattr_iterate_directory(VFSTOUFS(mp), - attr_system_dvp, EXTATTR_NAMESPACE_SYSTEM, p); + attr_system_dvp, EXTATTR_NAMESPACE_SYSTEM, td); if (error) printf("ufs_extattr_iterate_directory returned %d\n", error); @@ -520,10 +520,10 @@ ufs_extattr_autostart(struct mount *mp, struct proc *p) } error = ufs_extattr_lookup(attr_dvp, UE_GETDIR_LOCKPARENT, - UFS_EXTATTR_SUBDIR_USER, &attr_user_dvp, p); + UFS_EXTATTR_SUBDIR_USER, &attr_user_dvp, td); if (!error) { error = ufs_extattr_iterate_directory(VFSTOUFS(mp), - attr_user_dvp, EXTATTR_NAMESPACE_USER, p); + attr_user_dvp, EXTATTR_NAMESPACE_USER, td); if (error) printf("ufs_extattr_iterate_directory returned %d\n", error); @@ -544,13 +544,13 @@ return_vput_attr_dvp: * Stop extended attribute support on an FS. */ int -ufs_extattr_stop(struct mount *mp, struct proc *p) +ufs_extattr_stop(struct mount *mp, struct thread *td) { struct ufs_extattr_list_entry *uele; struct ufsmount *ump = VFSTOUFS(mp); int error = 0; - ufs_extattr_uepm_lock(ump, p); + ufs_extattr_uepm_lock(ump, td); if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) { error = EOPNOTSUPP; @@ -560,7 +560,7 @@ ufs_extattr_stop(struct mount *mp, struct proc *p) while (LIST_FIRST(&ump->um_extattr.uepm_list) != NULL) { uele = LIST_FIRST(&ump->um_extattr.uepm_list); ufs_extattr_disable(ump, uele->uele_attrnamespace, - uele->uele_attrname, p); + uele->uele_attrname, td); } ump->um_extattr.uepm_flags &= ~UFS_EXTATTR_UEPM_STARTED; @@ -569,7 +569,7 @@ ufs_extattr_stop(struct mount *mp, struct proc *p) ump->um_extattr.uepm_ucred = NULL; unlock: - ufs_extattr_uepm_unlock(ump, p); + ufs_extattr_uepm_unlock(ump, td); return (error); } @@ -580,7 +580,7 @@ unlock: */ static int ufs_extattr_enable(struct ufsmount *ump, int attrnamespace, - const char *attrname, struct vnode *backing_vnode, struct proc *p) + const char *attrname, struct vnode *backing_vnode, struct thread *td) { struct ufs_extattr_list_entry *attribute; struct iovec aiov; @@ -622,13 +622,13 @@ ufs_extattr_enable(struct ufsmount *ump, int attrnamespace, auio.uio_offset = (off_t) 0; auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = (struct proc *) p; + auio.uio_td = td; - VOP_LEASE(backing_vnode, p, p->p_ucred, LEASE_WRITE); - vn_lock(backing_vnode, LK_SHARED | LK_NOPAUSE | LK_RETRY, p); + VOP_LEASE(backing_vnode, td, td->td_proc->p_ucred, LEASE_WRITE); + vn_lock(backing_vnode, LK_SHARED | LK_NOPAUSE | LK_RETRY, td); error = VOP_READ(backing_vnode, &auio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); - VOP_UNLOCK(backing_vnode, 0, p); + VOP_UNLOCK(backing_vnode, 0, td); if (error) goto free_exit; @@ -667,7 +667,7 @@ free_exit: */ static int ufs_extattr_disable(struct ufsmount *ump, int attrnamespace, - const char *attrname, struct proc *p) + const char *attrname, struct thread *td) { struct ufs_extattr_list_entry *uele; int error = 0; @@ -682,7 +682,7 @@ ufs_extattr_disable(struct ufsmount *ump, int attrnamespace, LIST_REMOVE(uele, uele_entries); uele->uele_backing_vnode->v_flag &= ~VSYSTEM; - error = vn_close(uele->uele_backing_vnode, FREAD|FWRITE, p->p_ucred, p); + error = vn_close(uele->uele_backing_vnode, FREAD|FWRITE, td->td_proc->p_ucred, td); FREE(uele, M_UFS_EXTATTR); @@ -696,7 +696,7 @@ ufs_extattr_disable(struct ufsmount *ump, int attrnamespace, */ int ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, - int attrnamespace, const char *attrname, struct proc *p) + int attrnamespace, const char *attrname, struct thread *td) { struct ufsmount *ump = VFSTOUFS(mp); int error; @@ -705,34 +705,34 @@ ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, * Processes with privilege, but in jail, are not allowed to * configure extended attributes. */ - if ((error = suser_xxx(p->p_ucred, p, 0))) { + if ((error = suser_xxx(td->td_proc->p_ucred, td->td_proc, 0))) { if (filename_vp != NULL) - VOP_UNLOCK(filename_vp, 0, p); + VOP_UNLOCK(filename_vp, 0, td); return (error); } switch(cmd) { case UFS_EXTATTR_CMD_START: if (filename_vp != NULL) { - VOP_UNLOCK(filename_vp, 0, p); + VOP_UNLOCK(filename_vp, 0, td); return (EINVAL); } if (attrname != NULL) return (EINVAL); - error = ufs_extattr_start(mp, p); + error = ufs_extattr_start(mp, td); return (error); case UFS_EXTATTR_CMD_STOP: if (filename_vp != NULL) { - VOP_UNLOCK(filename_vp, 0, p); + VOP_UNLOCK(filename_vp, 0, td); return (EINVAL); } if (attrname != NULL) return (EINVAL); - error = ufs_extattr_stop(mp, p); + error = ufs_extattr_stop(mp, td); return (error); @@ -741,7 +741,7 @@ ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, if (filename_vp == NULL) return (EINVAL); if (attrname == NULL) { - VOP_UNLOCK(filename_vp, 0, p); + VOP_UNLOCK(filename_vp, 0, td); return (EINVAL); } @@ -749,25 +749,25 @@ ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, * ufs_extattr_enable_with_open() will always unlock the * vnode, regardless of failure. */ - ufs_extattr_uepm_lock(ump, p); + ufs_extattr_uepm_lock(ump, td); error = ufs_extattr_enable_with_open(ump, filename_vp, - attrnamespace, attrname, p); - ufs_extattr_uepm_unlock(ump, p); + attrnamespace, attrname, td); + ufs_extattr_uepm_unlock(ump, td); return (error); case UFS_EXTATTR_CMD_DISABLE: if (filename_vp != NULL) { - VOP_UNLOCK(filename_vp, 0, p); + VOP_UNLOCK(filename_vp, 0, td); return (EINVAL); } if (attrname == NULL) return (EINVAL); - ufs_extattr_uepm_lock(ump, p); - error = ufs_extattr_disable(ump, attrnamespace, attrname, p); - ufs_extattr_uepm_unlock(ump, p); + ufs_extattr_uepm_lock(ump, td); + error = ufs_extattr_disable(ump, attrnamespace, attrname, td); + ufs_extattr_uepm_unlock(ump, td); return (error); @@ -782,7 +782,7 @@ ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, */ static int ufs_extattr_credcheck(struct vnode *vp, struct ufs_extattr_list_entry *uele, - struct ucred *cred, struct proc *p, int access) + struct ucred *cred, struct thread *td, int access) { /* @@ -800,9 +800,9 @@ ufs_extattr_credcheck(struct vnode *vp, struct ufs_extattr_list_entry *uele, */ switch (uele->uele_attrnamespace) { case EXTATTR_NAMESPACE_SYSTEM: - return (suser_xxx(cred, p, 0)); + return (suser_xxx(cred, td->td_proc, 0)); case EXTATTR_NAMESPACE_USER: - return (VOP_ACCESS(vp, access, cred, p)); + return (VOP_ACCESS(vp, access, cred, td)); default: return (EPERM); } @@ -820,7 +820,7 @@ vop_getextattr { IN const char *a_name; INOUT struct uio *a_uio; IN struct ucred *a_cred; - IN struct proc *a_p; + IN struct thread *a_td; }; */ { @@ -828,12 +828,12 @@ vop_getextattr { struct ufsmount *ump = VFSTOUFS(mp); int error; - ufs_extattr_uepm_lock(ump, ap->a_p); + ufs_extattr_uepm_lock(ump, ap->a_td); error = ufs_extattr_get(ap->a_vp, ap->a_attrnamespace, ap->a_name, - ap->a_uio, ap->a_cred, ap->a_p); + ap->a_uio, ap->a_cred, ap->a_td); - ufs_extattr_uepm_unlock(ump, ap->a_p); + ufs_extattr_uepm_unlock(ump, ap->a_td); return (error); } @@ -844,7 +844,7 @@ vop_getextattr { */ static int ufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name, - struct uio *uio, struct ucred *cred, struct proc *p) + struct uio *uio, struct ucred *cred, struct thread *td) { struct ufs_extattr_list_entry *attribute; struct ufs_extattr_header ueh; @@ -870,7 +870,7 @@ ufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name, if (!attribute) return (ENOENT); - if ((error = ufs_extattr_credcheck(vp, attribute, cred, p, IREAD))) + if ((error = ufs_extattr_credcheck(vp, attribute, cred, td, IREAD))) return (error); /* @@ -900,21 +900,21 @@ ufs_extattr_get(struct vnode *vp, int attrnamespace, const char *name, local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_READ; local_aio.uio_segflg = UIO_SYSSPACE; - local_aio.uio_procp = p; + local_aio.uio_td = td; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ufs_extattr_header); /* * Acquire locks. */ - VOP_LEASE(attribute->uele_backing_vnode, p, cred, LEASE_READ); + VOP_LEASE(attribute->uele_backing_vnode, td, cred, LEASE_READ); /* * Don't need to get a lock on the backing file if the getattr is * being applied to the backing file, as the lock is already held. */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, LK_SHARED | - LK_NOPAUSE | LK_RETRY, p); + LK_NOPAUSE | LK_RETRY, td); error = VOP_READ(attribute->uele_backing_vnode, &local_aio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); @@ -970,7 +970,7 @@ vopunlock_exit: uio->uio_offset = 0; if (attribute->uele_backing_vnode != vp) - VOP_UNLOCK(attribute->uele_backing_vnode, 0, p); + VOP_UNLOCK(attribute->uele_backing_vnode, 0, td); return (error); } @@ -987,7 +987,7 @@ vop_setextattr { IN const char *a_name; INOUT struct uio *a_uio; IN struct ucred *a_cred; - IN struct proc *a_p; + IN struct thread *a_td; }; */ { @@ -996,16 +996,16 @@ vop_setextattr { int error; - ufs_extattr_uepm_lock(ump, ap->a_p); + ufs_extattr_uepm_lock(ump, ap->a_td); if (ap->a_uio != NULL) error = ufs_extattr_set(ap->a_vp, ap->a_attrnamespace, - ap->a_name, ap->a_uio, ap->a_cred, ap->a_p); + ap->a_name, ap->a_uio, ap->a_cred, ap->a_td); else error = ufs_extattr_rm(ap->a_vp, ap->a_attrnamespace, - ap->a_name, ap->a_cred, ap->a_p); + ap->a_name, ap->a_cred, ap->a_td); - ufs_extattr_uepm_unlock(ump, ap->a_p); + ufs_extattr_uepm_unlock(ump, ap->a_td); return (error); } @@ -1016,7 +1016,7 @@ vop_setextattr { */ static int ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, - struct uio *uio, struct ucred *cred, struct proc *p) + struct uio *uio, struct ucred *cred, struct thread *td) { struct ufs_extattr_list_entry *attribute; struct ufs_extattr_header ueh; @@ -1039,7 +1039,7 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, if (!attribute) return (ENOENT); - if ((error = ufs_extattr_credcheck(vp, attribute, cred, p, IWRITE))) + if ((error = ufs_extattr_credcheck(vp, attribute, cred, td, IWRITE))) return (error); /* @@ -1071,14 +1071,14 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_WRITE; local_aio.uio_segflg = UIO_SYSSPACE; - local_aio.uio_procp = p; + local_aio.uio_td = td; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ufs_extattr_header); /* * Acquire locks. */ - VOP_LEASE(attribute->uele_backing_vnode, p, cred, LEASE_WRITE); + VOP_LEASE(attribute->uele_backing_vnode, td, cred, LEASE_WRITE); /* * Don't need to get a lock on the backing file if the setattr is @@ -1086,7 +1086,7 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name, */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, - LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, p); + LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, td); ioflag = IO_NODELOCKED; if (ufs_extattr_sync) @@ -1116,7 +1116,7 @@ vopunlock_exit: uio->uio_offset = 0; if (attribute->uele_backing_vnode != vp) - VOP_UNLOCK(attribute->uele_backing_vnode, 0, p); + VOP_UNLOCK(attribute->uele_backing_vnode, 0, td); return (error); } @@ -1127,7 +1127,7 @@ vopunlock_exit: */ static int ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { struct ufs_extattr_list_entry *attribute; struct ufs_extattr_header ueh; @@ -1150,7 +1150,7 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, if (!attribute) return (ENOENT); - if ((error = ufs_extattr_credcheck(vp, attribute, cred, p, IWRITE))) + if ((error = ufs_extattr_credcheck(vp, attribute, cred, td, IWRITE))) return (error); /* @@ -1172,11 +1172,11 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_READ; local_aio.uio_segflg = UIO_SYSSPACE; - local_aio.uio_procp = p; + local_aio.uio_td = td; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ufs_extattr_header); - VOP_LEASE(attribute->uele_backing_vnode, p, cred, LEASE_WRITE); + VOP_LEASE(attribute->uele_backing_vnode, td, cred, LEASE_WRITE); /* * Don't need to get the lock on the backing vnode if the vnode we're @@ -1184,7 +1184,7 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, */ if (attribute->uele_backing_vnode != vp) vn_lock(attribute->uele_backing_vnode, - LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, p); + LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, td); error = VOP_READ(attribute->uele_backing_vnode, &local_aio, IO_NODELOCKED, ump->um_extattr.uepm_ucred); @@ -1221,7 +1221,7 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, local_aio.uio_iovcnt = 1; local_aio.uio_rw = UIO_WRITE; local_aio.uio_segflg = UIO_SYSSPACE; - local_aio.uio_procp = p; + local_aio.uio_td = td; local_aio.uio_offset = base_offset; local_aio.uio_resid = sizeof(struct ufs_extattr_header); @@ -1237,7 +1237,7 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, error = ENXIO; vopunlock_exit: - VOP_UNLOCK(attribute->uele_backing_vnode, 0, p); + VOP_UNLOCK(attribute->uele_backing_vnode, 0, td); return (error); } @@ -1247,7 +1247,7 @@ vopunlock_exit: * attributes stripped. */ void -ufs_extattr_vnode_inactive(struct vnode *vp, struct proc *p) +ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td) { struct ufs_extattr_list_entry *uele; struct mount *mp = vp->v_mount; @@ -1261,18 +1261,18 @@ ufs_extattr_vnode_inactive(struct vnode *vp, struct proc *p) if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED)) return; - ufs_extattr_uepm_lock(ump, p); + ufs_extattr_uepm_lock(ump, td); if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) { - ufs_extattr_uepm_unlock(ump, p); + ufs_extattr_uepm_unlock(ump, td); return; } LIST_FOREACH(uele, &ump->um_extattr.uepm_list, uele_entries) ufs_extattr_rm(vp, uele->uele_attrnamespace, - uele->uele_attrname, NULL, p); + uele->uele_attrname, NULL, td); - ufs_extattr_uepm_unlock(ump, p); + ufs_extattr_uepm_unlock(ump, td); } #endif /* !UFS_EXTATTR */ diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index d95013b..c4e2795 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -43,7 +43,7 @@ struct indir; struct inode; struct mount; struct netcred; -struct proc; +struct thread; struct sockaddr; struct ucred; struct ufid; @@ -89,7 +89,7 @@ int ufs_readdir __P((struct vop_readdir_args *)); int ufs_reclaim __P((struct vop_reclaim_args *)); void ffs_snapgone __P((struct inode *)); int ufs_root __P((struct mount *, struct vnode **)); -int ufs_start __P((struct mount *, int, struct proc *)); +int ufs_start __P((struct mount *, int, struct thread *)); int ufs_vinit __P((struct mount *, vop_t **, vop_t **, struct vnode **)); /* diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c index 1fd39e9..d1537af 100644 --- a/sys/ufs/ufs/ufs_ihash.c +++ b/sys/ufs/ufs/ufs_ihash.c @@ -40,6 +40,7 @@ #include <sys/lock.h> #include <sys/vnode.h> #include <sys/malloc.h> +#include <sys/proc.h> #include <sys/mutex.h> #include <ufs/ufs/quota.h> @@ -97,7 +98,7 @@ ufs_ihashget(dev, inum) dev_t dev; ino_t inum; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct inode *ip; struct vnode *vp; @@ -108,7 +109,7 @@ loop: vp = ITOV(ip); mtx_lock(&vp->v_interlock); mtx_unlock(&ufs_ihash_mtx); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -124,11 +125,11 @@ void ufs_ihashins(ip) struct inode *ip; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct ihashhead *ipp; /* lock the inode, then put it on the appropriate hash list */ - lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, p); + lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, td); mtx_lock(&ufs_ihash_mtx); ipp = INOHASH(ip->i_dev, ip->i_number); diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 028e3b9..9858297 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -65,12 +65,12 @@ int ufs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int mode, error = 0; if (prtactive && vp->v_usecount != 0) @@ -90,9 +90,9 @@ ufs_inactive(ap) (void)chkiq(ip, -1, NOCRED, 0); #endif #ifdef UFS_EXTATTR - ufs_extattr_vnode_inactive(ap->a_vp, ap->a_p); + ufs_extattr_vnode_inactive(ap->a_vp, ap->a_td); #endif - error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, p); + error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, td); /* * Setting the mode to zero needs to wait for the inode * to be written just as does a change to the link count. @@ -117,13 +117,13 @@ ufs_inactive(ap) } } out: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * If we are done with the inode, reclaim it * so that it can be reused immediately. */ if (ip->i_mode == 0) - vrecycle(vp, NULL, p); + vrecycle(vp, NULL, td); return (error); } @@ -134,7 +134,7 @@ int ufs_reclaim(ap) struct vop_reclaim_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct inode *ip; diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index a062330..da1c0e9 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -156,7 +156,7 @@ ufs_lookup(ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; bp = NULL; slotoffset = -1; @@ -400,7 +400,7 @@ notfound: * Access for write is interpreted as allowing * creation of files in the directory. */ - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) return (error); /* @@ -445,7 +445,7 @@ notfound: */ cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (EJUSTRETURN); @@ -490,7 +490,7 @@ found: /* * Write access to directory required to delete files. */ - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc); + error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) return (error); /* @@ -509,10 +509,10 @@ found: return (0); } if (flags & ISDOTDOT) - VOP_UNLOCK(vdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(vdp, 0, td); /* race to get the inode */ error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp); if (flags & ISDOTDOT) { - if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p) != 0) + if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, td) != 0) cnp->cn_flags |= PDIRUNLOCK; } if (error) @@ -524,14 +524,14 @@ found: * implements append-only directories. */ if ((dp->i_mode & ISVTX) && - VOP_ACCESS(vdp, VADMIN, cred, cnp->cn_proc) && - VOP_ACCESS(tdp, VADMIN, cred, cnp->cn_proc)) { + VOP_ACCESS(vdp, VADMIN, cred, cnp->cn_thread) && + VOP_ACCESS(tdp, VADMIN, cred, cnp->cn_thread)) { vput(tdp); return (EPERM); } *vpp = tdp; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); @@ -544,7 +544,7 @@ found: * regular file, or empty directory. */ if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) { - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) return (error); /* * Careful about locking second inode. @@ -553,10 +553,10 @@ found: if (dp->i_number == dp->i_ino) return (EISDIR); if (flags & ISDOTDOT) - VOP_UNLOCK(vdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(vdp, 0, td); /* race to get the inode */ error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp); if (flags & ISDOTDOT) { - if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p) != 0) + if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, td) != 0) cnp->cn_flags |= PDIRUNLOCK; } if (error) @@ -564,7 +564,7 @@ found: *vpp = tdp; cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); @@ -591,15 +591,15 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ cnp->cn_flags |= PDIRUNLOCK; if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) { - if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p) == 0) + if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td) == 0) cnp->cn_flags &= ~PDIRUNLOCK; return (error); } if (lockparent && (flags & ISLASTCN)) { - if ((error = vn_lock(pdp, LK_EXCLUSIVE, p)) != 0) { + if ((error = vn_lock(pdp, LK_EXCLUSIVE, td)) != 0) { vput(tdp); return (error); } @@ -614,7 +614,7 @@ found: if (error) return (error); if (!lockparent || !(flags & ISLASTCN)) { - VOP_UNLOCK(pdp, 0, p); + VOP_UNLOCK(pdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } *vpp = tdp; @@ -739,7 +739,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) struct buf *newdirbp; { struct ucred *cr; - struct proc *p; + struct thread *td; int newentrysize; struct inode *dp; struct buf *bp; @@ -748,8 +748,8 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) int error, ret, blkoff, loc, spacefree, flags; char *dirbuf; - p = curproc; /* XXX */ - cr = p->p_ucred; + td = curthread; /* XXX */ + cr = td->td_proc->p_ucred; dp = VTOI(dvp); newentrysize = DIRSIZ(OFSFMT(dvp), dirp); @@ -818,10 +818,10 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) if ((error = BUF_WRITE(bp))) return (error); if (tvp != NULL) - VOP_UNLOCK(tvp, 0, p); - error = VOP_FSYNC(dvp, p->p_ucred, MNT_WAIT, p); + VOP_UNLOCK(tvp, 0, td); + error = VOP_FSYNC(dvp, td->td_proc->p_ucred, MNT_WAIT, td); if (tvp != NULL) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); } if (DOINGASYNC(dvp)) { @@ -966,14 +966,14 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) */ if (error == 0 && dp->i_endoff && dp->i_endoff < dp->i_size) { if (tvp != NULL) - VOP_UNLOCK(tvp, 0, p); + VOP_UNLOCK(tvp, 0, td); #ifdef UFS_DIRHASH if (dp->i_dirhash != NULL) ufsdirhash_dirtrunc(dp, dp->i_endoff); #endif - (void) UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, cr, p); + (void) UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, cr, td); if (tvp != NULL) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, td); } return (error); } @@ -1159,7 +1159,7 @@ ufs_dirempty(ip, parentino, cred) for (off = 0; off < ip->i_size; off += dp->d_reclen) { error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, - UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); + UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct thread *)0); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. @@ -1230,7 +1230,7 @@ ufs_checkpath(source, target, cred) } error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf, sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, (int *)0, (struct proc *)0); + IO_NODELOCKED, cred, (int *)0, (struct thread *)0); if (error != 0) break; # if (BYTE_ORDER == LITTLE_ENDIAN) diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 6992160..4c10d88 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -386,8 +386,8 @@ chkdquot(ip) * Q_QUOTAON - set up a quota file for a particular file system. */ int -quotaon(p, mp, type, fname) - struct proc *p; +quotaon(td, mp, type, fname) + struct thread *td; struct mount *mp; register int type; caddr_t fname; @@ -400,20 +400,20 @@ quotaon(p, mp, type, fname) struct nameidata nd; vpp = &ump->um_quotas[type]; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td); flags = FREAD | FWRITE; error = vn_open(&nd, &flags, 0); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); if (vp->v_type != VREG) { - (void) vn_close(vp, FREAD|FWRITE, p->p_ucred, p); + (void) vn_close(vp, FREAD|FWRITE, td->td_proc->p_ucred, td); return (EACCES); } if (*vpp != vp) - quotaoff(p, mp, type); + quotaoff(td, mp, type); ump->um_qflags[type] |= QTF_OPENING; mp->mnt_flag |= MNT_QUOTA; vp->v_flag |= VSYSTEM; @@ -422,8 +422,8 @@ quotaon(p, mp, type, fname) * Save the credential of the process that turned on quotas. * Set up the time limits for this quota. */ - crhold(p->p_ucred); - ump->um_cred[type] = p->p_ucred; + crhold(td->td_proc->p_ucred); + ump->um_cred[type] = td->td_proc->p_ucred; ump->um_btime[type] = MAX_DQ_TIME; ump->um_itime[type] = MAX_IQ_TIME; if (dqget(NULLVP, 0, ump, type, &dq) == 0) { @@ -452,7 +452,7 @@ again: mtx_lock(&mntvnode_mtx); continue; } - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { mtx_lock(&mntvnode_mtx); goto again; } @@ -467,7 +467,7 @@ again: mtx_unlock(&mntvnode_mtx); ump->um_qflags[type] &= ~QTF_OPENING; if (error) - quotaoff(p, mp, type); + quotaoff(td, mp, type); return (error); } @@ -475,8 +475,8 @@ again: * Q_QUOTAOFF - turn off disk quotas for a filesystem. */ int -quotaoff(p, mp, type) - struct proc *p; +quotaoff(td, mp, type) + struct thread *td; struct mount *mp; register int type; { @@ -508,7 +508,7 @@ again: mtx_lock(&mntvnode_mtx); continue; } - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { mtx_lock(&mntvnode_mtx); goto again; } @@ -524,7 +524,7 @@ again: mtx_unlock(&mntvnode_mtx); dqflush(qvp); qvp->v_flag &= ~VSYSTEM; - error = vn_close(qvp, FREAD|FWRITE, p->p_ucred, p); + error = vn_close(qvp, FREAD|FWRITE, td->td_proc->p_ucred, td); ump->um_quotas[type] = NULLVP; crfree(ump->um_cred[type]); ump->um_cred[type] = NOCRED; @@ -675,7 +675,7 @@ qsync(mp) struct mount *mp; { struct ufsmount *ump = VFSTOUFS(mp); - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp, *nextvp; struct dquot *dq; int i, error; @@ -706,7 +706,7 @@ again: mtx_lock(&mntvnode_mtx); continue; } - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { mtx_lock(&mntvnode_mtx); if (error == ENOENT) @@ -765,7 +765,7 @@ dqget(vp, id, ump, type, dqp) register int type; struct dquot **dqp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct dquot *dq; struct dqhash *dqh; struct vnode *dqvp; @@ -821,7 +821,7 @@ dqget(vp, id, ump, type, dqp) * Initialize the contents of the dquot structure. */ if (vp != dqvp) - vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY, td); LIST_INSERT_HEAD(dqh, dq, dq_hash); DQREF(dq); dq->dq_flags = DQ_LOCK; @@ -836,12 +836,12 @@ dqget(vp, id, ump, type, dqp) auio.uio_offset = (off_t)(id * sizeof (struct dqblk)); auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]); if (auio.uio_resid == sizeof(struct dqblk) && error == 0) bzero((caddr_t)&dq->dq_dqb, sizeof(struct dqblk)); if (vp != dqvp) - VOP_UNLOCK(dqvp, 0, p); + VOP_UNLOCK(dqvp, 0, td); if (dq->dq_flags & DQ_WANT) wakeup((caddr_t)dq); dq->dq_flags = 0; @@ -915,7 +915,7 @@ dqsync(vp, dq) struct vnode *vp; struct dquot *dq; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *dqvp; struct iovec aiov; struct uio auio; @@ -929,13 +929,13 @@ dqsync(vp, dq) panic("dqsync: file"); (void) vn_write_suspend_wait(dqvp, NULL, V_WAIT); if (vp != dqvp) - vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY, td); while (dq->dq_flags & DQ_LOCK) { dq->dq_flags |= DQ_WANT; (void) tsleep((caddr_t)dq, PINOD+2, "dqsync", 0); if ((dq->dq_flags & DQ_MOD) == 0) { if (vp != dqvp) - VOP_UNLOCK(dqvp, 0, p); + VOP_UNLOCK(dqvp, 0, td); return (0); } } @@ -948,7 +948,7 @@ dqsync(vp, dq) auio.uio_offset = (off_t)(dq->dq_id * sizeof (struct dqblk)); auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_WRITE; - auio.uio_procp = (struct proc *)0; + auio.uio_td = (struct thread *)0; error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]); if (auio.uio_resid && error == 0) error = EIO; @@ -956,7 +956,7 @@ dqsync(vp, dq) wakeup((caddr_t)dq); dq->dq_flags &= ~(DQ_MOD|DQ_LOCK|DQ_WANT); if (vp != dqvp) - VOP_UNLOCK(dqvp, 0, p); + VOP_UNLOCK(dqvp, 0, td); return (error); } diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 0308895..83673eb 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -395,7 +395,7 @@ WRITE(ap) register struct inode *ip; register FS *fs; struct buf *bp; - struct proc *p; + struct thread *td; ufs_daddr_t lbn; off_t osize; int seqcount; @@ -456,13 +456,13 @@ WRITE(ap) * Maybe this should be above the vnode op call, but so long as * file servers have no limits, I don't think it matters. */ - p = uio->uio_procp; - if (vp->v_type == VREG && p && + td = uio->uio_td; + if (vp->v_type == VREG && td && uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - PROC_LOCK(p); - psignal(p, SIGXFSZ); - PROC_UNLOCK(p); + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + PROC_LOCK(td->td_proc); + psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); if (object) { vm_object_vndeallocate(object); } @@ -573,7 +573,7 @@ WRITE(ap) if (error) { if (ioflag & IO_UNIT) { (void)UFS_TRUNCATE(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_procp); + ioflag & IO_SYNC, ap->a_cred, uio->uio_td); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 1fcd530..7b42452 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -64,10 +64,10 @@ MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure"); */ /* ARGSUSED */ int -ufs_start(mp, flags, p) +ufs_start(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { return (0); @@ -95,12 +95,12 @@ ufs_root(mp, vpp) * Do operations associated with quotas */ int -ufs_quotactl(mp, cmds, uid, arg, p) +ufs_quotactl(mp, cmds, uid, arg, td) struct mount *mp; int cmds; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { #ifndef QUOTA return (EOPNOTSUPP); @@ -108,35 +108,35 @@ ufs_quotactl(mp, cmds, uid, arg, p) int cmd, type, error; if (uid == -1) - uid = p->p_ucred->cr_ruid; + uid = td->td_proc->p_ucred->cr_ruid; cmd = cmds >> SUBCMDSHIFT; switch (cmd) { case Q_SYNC: break; case Q_GETQUOTA: - if (uid == p->p_ucred->cr_ruid) + if (uid == td->td_proc->p_ucred->cr_ruid) break; /* fall through */ default: - if ((error = suser_xxx(0, p, PRISON_ROOT)) != 0) + if ((error = suser_xxx(0, td->td_proc, PRISON_ROOT)) != 0) return (error); } type = cmds & SUBCMDMASK; if ((u_int)type >= MAXQUOTAS) return (EINVAL); - if (vfs_busy(mp, LK_NOWAIT, 0, p)) + if (vfs_busy(mp, LK_NOWAIT, 0, td)) return (0); switch (cmd) { case Q_QUOTAON: - error = quotaon(p, mp, type, arg); + error = quotaon(td, mp, type, arg); break; case Q_QUOTAOFF: - error = quotaoff(p, mp, type); + error = quotaoff(td, mp, type); break; case Q_SETQUOTA: @@ -159,7 +159,7 @@ ufs_quotactl(mp, cmds, uid, arg, p) error = EINVAL; break; } - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (error); #endif } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index e52bf93..c108c90 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -83,8 +83,8 @@ static int ufs_access __P((struct vop_access_args *)); static int ufs_advlock __P((struct vop_advlock_args *)); -static int ufs_chmod __P((struct vnode *, int, struct ucred *, struct proc *)); -static int ufs_chown __P((struct vnode *, uid_t, gid_t, struct ucred *, struct proc *)); +static int ufs_chmod __P((struct vnode *, int, struct ucred *, struct thread *)); +static int ufs_chown __P((struct vnode *, uid_t, gid_t, struct ucred *, struct thread *)); static int ufs_close __P((struct vop_close_args *)); static int ufs_create __P((struct vop_create_args *)); static int ufs_getattr __P((struct vop_getattr_args *)); @@ -267,7 +267,7 @@ ufs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -292,7 +292,7 @@ ufs_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -332,7 +332,7 @@ ufs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -373,7 +373,7 @@ ufs_access(ap) #ifdef UFS_ACL MALLOC(acl, struct acl *, sizeof(*acl), M_ACL, M_WAITOK); len = sizeof(*acl); - error = VOP_GETACL(vp, ACL_TYPE_ACCESS, acl, ap->a_cred, ap->a_p); + error = VOP_GETACL(vp, ACL_TYPE_ACCESS, acl, ap->a_cred, ap->a_td); switch (error) { case EOPNOTSUPP: error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, @@ -408,7 +408,7 @@ ufs_getattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -452,14 +452,14 @@ ufs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vattr *vap = ap->a_vap; struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct ucred *cred = ap->a_cred; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; int error; /* @@ -478,7 +478,7 @@ ufs_setattr(ap) * Callers may only modify the file flags on objects they * have VADMIN rights for. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* * Unprivileged processes and privileged processes in @@ -519,7 +519,7 @@ ufs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if ((error = ufs_chown(vp, vap->va_uid, vap->va_gid, cred, - p)) != 0) + td)) != 0) return (error); } if (vap->va_size != VNOVAL) { @@ -541,7 +541,7 @@ ufs_setattr(ap) default: break; } - if ((error = UFS_TRUNCATE(vp, vap->va_size, 0, cred, p)) != 0) + if ((error = UFS_TRUNCATE(vp, vap->va_size, 0, cred, td)) != 0) return (error); } if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { @@ -557,9 +557,9 @@ ufs_setattr(ap) * If times is non-NULL, ... The caller must be the owner of * the file or be the super-user. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p)) && + if ((error = VOP_ACCESS(vp, VADMIN, cred, td)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(vp, VWRITE, cred, p)))) + (error = VOP_ACCESS(vp, VWRITE, cred, td)))) return (error); if (vap->va_atime.tv_sec != VNOVAL) ip->i_flag |= IN_ACCESS; @@ -585,7 +585,7 @@ ufs_setattr(ap) if ((ip->i_flags & SF_SNAPSHOT) != 0 && (vap->va_mode & (S_IXUSR | S_IWUSR | S_IXGRP | S_IWGRP | S_IXOTH | S_IWOTH))) return (EPERM); - error = ufs_chmod(vp, (int)vap->va_mode, cred, p); + error = ufs_chmod(vp, (int)vap->va_mode, cred, td); } VN_KNOTE(vp, NOTE_ATTRIB); return (error); @@ -596,11 +596,11 @@ ufs_setattr(ap) * Inode must be locked before calling. */ static int -ufs_chmod(vp, mode, cred, p) +ufs_chmod(vp, mode, cred, td) register struct vnode *vp; register int mode; register struct ucred *cred; - struct proc *p; + struct thread *td; { register struct inode *ip = VTOI(vp); int error; @@ -609,7 +609,7 @@ ufs_chmod(vp, mode, cred, p) * To modify the permissions on a file, must possess VADMIN * for that file. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* * Privileged processes may set the sticky bit on non-directories, @@ -633,12 +633,12 @@ ufs_chmod(vp, mode, cred, p) * inode must be locked prior to call. */ static int -ufs_chown(vp, uid, gid, cred, p) +ufs_chown(vp, uid, gid, cred, td) register struct vnode *vp; uid_t uid; gid_t gid; struct ucred *cred; - struct proc *p; + struct thread *td; { register struct inode *ip = VTOI(vp); uid_t ouid; @@ -657,7 +657,7 @@ ufs_chown(vp, uid, gid, cred, p) * To modify the ownership of a file, must possess VADMIN * for that file. */ - if ((error = VOP_ACCESS(vp, VADMIN, cred, p))) + if ((error = VOP_ACCESS(vp, VADMIN, cred, td))) return (error); /* * To change the owner of a file, or change the group of a file @@ -666,7 +666,7 @@ ufs_chown(vp, uid, gid, cred, p) */ if ((uid != ip->i_uid || (gid != ip->i_gid && !groupmember(gid, cred))) && - (error = suser_xxx(cred, p, PRISON_ROOT))) + (error = suser_xxx(cred, td->td_proc, PRISON_ROOT))) return (error); ogid = ip->i_gid; ouid = ip->i_uid; @@ -780,7 +780,7 @@ ufs_link(ap) struct vnode *vp = ap->a_vp; struct vnode *tdvp = ap->a_tdvp; struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_thread; struct inode *ip; struct direct newdir; int error; @@ -793,7 +793,7 @@ ufs_link(ap) error = EXDEV; goto out2; } - if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) { + if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, td))) { goto out2; } ip = VTOI(vp); @@ -825,7 +825,7 @@ ufs_link(ap) } out1: if (tdvp != vp) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); out2: VN_KNOTE(vp, NOTE_LINK); VN_KNOTE(tdvp, NOTE_WRITE); @@ -928,7 +928,7 @@ ufs_rename(ap) struct vnode *fdvp = ap->a_fdvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; - struct proc *p = fcnp->cn_proc; + struct thread *td = fcnp->cn_thread; struct inode *ip, *xp, *dp; struct direct newdir; int doingdirectory = 0, oldparent = 0, newparent = 0; @@ -1019,18 +1019,18 @@ abortit: vput(fvp); return (error); } - if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0) + if ((error = vn_lock(fvp, LK_EXCLUSIVE, td)) != 0) goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); if (ip->i_nlink >= LINK_MAX) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EMLINK; goto abortit; } if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || (dp->i_flags & APPEND)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EPERM; goto abortit; } @@ -1041,7 +1041,7 @@ abortit: if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || dp == ip || (fcnp->cn_flags | tcnp->cn_flags) & ISDOTDOT || (ip->i_flag & IN_RENAME)) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); error = EINVAL; goto abortit; } @@ -1074,7 +1074,7 @@ abortit: softdep_change_linkcnt(ip); if ((error = UFS_UPDATE(fvp, !(DOINGSOFTDEP(fvp) | DOINGASYNC(fvp)))) != 0) { - VOP_UNLOCK(fvp, 0, p); + VOP_UNLOCK(fvp, 0, td); goto bad; } @@ -1088,8 +1088,8 @@ abortit: * to namei, as the parent directory is unlocked by the * call to checkpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - VOP_UNLOCK(fvp, 0, p); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + VOP_UNLOCK(fvp, 0, td); if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { @@ -1172,8 +1172,8 @@ abortit: * directories. */ if ((dp->i_mode & S_ISTXT) && - VOP_ACCESS(tdvp, VADMIN, tcnp->cn_cred, p) && - VOP_ACCESS(tvp, VADMIN, tcnp->cn_cred, p)) { + VOP_ACCESS(tdvp, VADMIN, tcnp->cn_cred, td) && + VOP_ACCESS(tvp, VADMIN, tcnp->cn_cred, td)) { error = EPERM; goto bad; } @@ -1232,7 +1232,7 @@ abortit: xp->i_flag |= IN_CHANGE; ioflag = DOINGASYNC(tvp) ? 0 : IO_SYNC; if ((error = UFS_TRUNCATE(tvp, (off_t)0, ioflag, - tcnp->cn_cred, tcnp->cn_proc)) != 0) + tcnp->cn_cred, tcnp->cn_thread)) != 0) goto bad; } VN_KNOTE(tdvp, NOTE_WRITE); @@ -1307,7 +1307,7 @@ bad: out: if (doingdirectory) ip->i_flag &= ~IN_RENAME; - if (vn_lock(fvp, LK_EXCLUSIVE, p) == 0) { + if (vn_lock(fvp, LK_EXCLUSIVE, td) == 0) { ip->i_effnlink--; ip->i_nlink--; ip->i_flag |= IN_CHANGE; @@ -1432,7 +1432,7 @@ ufs_mkdir(ap) * Retrieve default ACL from parent, if any. */ error = VOP_GETACL(dvp, ACL_TYPE_DEFAULT, acl, cnp->cn_cred, - cnp->cn_proc); + cnp->cn_thread); switch (error) { case 0: /* @@ -1500,10 +1500,10 @@ ufs_mkdir(ap) * code that the EAs for the file need to be released? */ error = VOP_SETACL(tvp, ACL_TYPE_ACCESS, acl, cnp->cn_cred, - cnp->cn_proc); + cnp->cn_thread); if (error == 0) error = VOP_SETACL(tvp, ACL_TYPE_DEFAULT, dacl, - cnp->cn_cred, cnp->cn_proc); + cnp->cn_cred, cnp->cn_thread); switch (error) { case 0: break; @@ -1693,7 +1693,7 @@ ufs_rmdir(ap) ip->i_flag |= IN_CHANGE; ioflag = DOINGASYNC(vp) ? 0 : IO_SYNC; error = UFS_TRUNCATE(vp, (off_t)0, ioflag, cnp->cn_cred, - cnp->cn_proc); + cnp->cn_thread); } cache_purge(vp); #ifdef UFS_DIRHASH @@ -1738,7 +1738,7 @@ ufs_symlink(ap) } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, (int *)0, - (struct proc *)0); + (struct thread *)0); if (error) vput(vp); return (error); @@ -2014,7 +2014,7 @@ ufsspec_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -2088,7 +2088,7 @@ ufsfifo_close(ap) struct vnode *a_vp; int a_fflag; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; @@ -2310,7 +2310,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) * Retrieve default ACL for parent, if any. */ error = VOP_GETACL(dvp, ACL_TYPE_DEFAULT, acl, cnp->cn_cred, - cnp->cn_proc); + cnp->cn_thread); switch (error) { case 0: /* @@ -2372,7 +2372,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) * code that the EAs for the file need to be released? */ error = VOP_SETACL(tvp, ACL_TYPE_ACCESS, acl, cnp->cn_cred, - cnp->cn_proc); + cnp->cn_thread); switch (error) { case 0: break; diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 4c73aa3..85c9866 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -88,7 +88,7 @@ struct ufsmount { int um_i_effnlink_valid; /* i_effnlink valid? */ int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **)); int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **)); - int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *)); + int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct thread *)); int (*um_update) __P((struct vnode *, int)); int (*um_valloc) __P((struct vnode *, int, struct ucred *, struct vnode **)); int (*um_vfree) __P((struct vnode *, ino_t, int)); diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h index 4ff3321..89432aa 100644 --- a/sys/vm/pmap.h +++ b/sys/vm/pmap.h @@ -89,6 +89,7 @@ typedef struct pmap_statistics *pmap_statistics_t; #ifdef _KERNEL struct proc; +struct thread; #ifdef __alpha__ void pmap_page_is_free __P((vm_page_t m)); @@ -138,7 +139,11 @@ void pmap_new_proc __P((struct proc *p)); void pmap_dispose_proc __P((struct proc *p)); void pmap_swapout_proc __P((struct proc *p)); void pmap_swapin_proc __P((struct proc *p)); -void pmap_activate __P((struct proc *p)); +void pmap_new_thread __P((struct thread *td)); +void pmap_dispose_thread __P((struct thread *td)); +void pmap_swapout_thread __P((struct thread *td)); +void pmap_swapin_thread __P((struct thread *td)); +void pmap_activate __P((struct thread *td)); vm_offset_t pmap_addr_hint __P((vm_object_t obj, vm_offset_t addr, vm_size_t size)); void *pmap_kenter_temporary __P((vm_offset_t pa, int i)); void pmap_init2 __P((void)); diff --git a/sys/vm/vm_contig.c b/sys/vm/vm_contig.c index 50534db..b515e85 100644 --- a/sys/vm/vm_contig.c +++ b/sys/vm/vm_contig.c @@ -152,9 +152,9 @@ again1: vm_page_test_dirty(m); if (m->dirty) { if (m->object->type == OBJT_VNODE) { - vn_lock(m->object->handle, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(m->object->handle, LK_EXCLUSIVE | LK_RETRY, curthread); vm_object_page_clean(m->object, 0, 0, OBJPC_SYNC); - VOP_UNLOCK(m->object->handle, 0, curproc); + VOP_UNLOCK(m->object->handle, 0, curthread); goto again1; } else if (m->object->type == OBJT_SWAP || m->object->type == OBJT_DEFAULT) { @@ -179,9 +179,9 @@ again1: vm_page_test_dirty(m); if (m->dirty) { if (m->object->type == OBJT_VNODE) { - vn_lock(m->object->handle, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(m->object->handle, LK_EXCLUSIVE | LK_RETRY, curthread); vm_object_page_clean(m->object, 0, 0, OBJPC_SYNC); - VOP_UNLOCK(m->object->handle, 0, curproc); + VOP_UNLOCK(m->object->handle, 0, curthread); goto again1; } else if (m->object->type == OBJT_SWAP || m->object->type == OBJT_DEFAULT) { diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 9ff0191..79bd5d8 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -47,16 +47,16 @@ struct vnode; #ifdef _KERNEL #ifdef TYPEDEF_FOR_UAP -int getpagesize __P((struct proc * p, void *, int *)); -int madvise __P((struct proc *, void *, int *)); -int mincore __P((struct proc *, void *, int *)); -int mprotect __P((struct proc *, void *, int *)); -int msync __P((struct proc *, void *, int *)); -int munmap __P((struct proc *, void *, int *)); -int obreak __P((struct proc *, void *, int *)); -int sbrk __P((struct proc *, void *, int *)); -int sstk __P((struct proc *, void *, int *)); -int swapon __P((struct proc *, void *, int *)); +int getpagesize __P((struct thread *, void *, int *)); +int madvise __P((struct thread *, void *, int *)); +int mincore __P((struct thread *, void *, int *)); +int mprotect __P((struct thread *, void *, int *)); +int msync __P((struct thread *, void *, int *)); +int munmap __P((struct thread *, void *, int *)); +int obreak __P((struct thread *, void *, int *)); +int sbrk __P((struct thread *, void *, int *)); +int sstk __P((struct thread *, void *, int *)); +int swapon __P((struct thread *, void *, int *)); #endif int grow __P((struct proc *, size_t)); @@ -71,8 +71,8 @@ void kmem_free_wakeup __P((vm_map_t, vm_offset_t, vm_size_t)); void kmem_init __P((vm_offset_t, vm_offset_t)); vm_offset_t kmem_malloc __P((vm_map_t, vm_size_t, boolean_t)); vm_map_t kmem_suballoc __P((vm_map_t, vm_offset_t *, vm_offset_t *, vm_size_t)); -void munmapfd __P((struct proc *, int)); -int swaponvp __P((struct proc *, struct vnode *, dev_t , u_long)); +void munmapfd __P((struct thread *, int)); +int swaponvp __P((struct thread *, struct vnode *, dev_t , u_long)); void swapout_procs __P((int)); int useracc __P((caddr_t, int, int)); int vm_fault __P((vm_map_t, vm_offset_t, vm_prot_t, int)); @@ -80,7 +80,7 @@ void vm_fault_copy_entry __P((vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t void vm_fault_unwire __P((vm_map_t, vm_offset_t, vm_offset_t)); int vm_fault_wire __P((vm_map_t, vm_offset_t, vm_offset_t)); int vm_fault_user_wire __P((vm_map_t, vm_offset_t, vm_offset_t)); -void vm_forkproc __P((struct proc *, struct proc *, int)); +void vm_forkproc __P((struct thread *, struct proc *, int)); void vm_waitproc __P((struct proc *)); int vm_mmap __P((vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int, void *, vm_ooffset_t)); vm_offset_t vm_page_alloc_contig __P((vm_offset_t, vm_offset_t, vm_offset_t, vm_offset_t)); diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index c098088..3507353 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -666,7 +666,7 @@ readrest: * grab the lock if we need to */ (fs.lookup_still_valid || - lockmgr(&fs.map->lock, LK_EXCLUSIVE|LK_NOWAIT, (void *)0, curproc) == 0) + lockmgr(&fs.map->lock, LK_EXCLUSIVE|LK_NOWAIT, (void *)0, curthread) == 0) ) { fs.lookup_still_valid = 1; diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 5638175..d239516 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -209,10 +209,12 @@ vsunlock(addr, len) * to user mode to avoid stack copying and relocation problems. */ void -vm_forkproc(p1, p2, flags) - struct proc *p1, *p2; +vm_forkproc(td, p2, flags) + struct thread *td; + struct proc *p2; int flags; { + struct proc *p1 = td->td_proc; struct user *up; GIANT_REQUIRED; @@ -228,7 +230,7 @@ vm_forkproc(p1, p2, flags) vmspace_unshare(p1); } } - cpu_fork(p1, p2, flags); + cpu_fork(td, p2, flags); return; } @@ -251,8 +253,10 @@ vm_forkproc(p1, p2, flags) } pmap_new_proc(p2); + pmap_new_thread(&p2->p_thread); /* Initial thread */ - up = p2->p_addr; + /* XXXKSE this is unsatisfactory but should be adequate */ + up = p2->p_uarea; /* * p_stats currently points at fields in the user struct @@ -282,7 +286,7 @@ vm_forkproc(p1, p2, flags) * cpu_fork will copy and update the pcb, set up the kernel stack, * and make the child ready to run. */ - cpu_fork(p1, p2, flags); + cpu_fork(td, p2, flags); } /* @@ -294,10 +298,13 @@ void vm_waitproc(p) struct proc *p; { + struct thread *td; GIANT_REQUIRED; cpu_wait(p); pmap_dispose_proc(p); /* drop per-process resources */ + FOREACH_THREAD_IN_PROC(p, td) + pmap_dispose_thread(td); vmspace_free(p->p_vmspace); /* and clean-out the vmspace */ } @@ -338,6 +345,7 @@ void faultin(p) struct proc *p; { + struct thread *td; GIANT_REQUIRED; PROC_LOCK_ASSERT(p, MA_OWNED); @@ -348,12 +356,14 @@ faultin(p) PROC_UNLOCK(p); pmap_swapin_proc(p); + FOREACH_THREAD_IN_PROC (p, td) + pmap_swapin_thread(td); PROC_LOCK(p); mtx_lock_spin(&sched_lock); - if (p->p_stat == SRUN) { - setrunqueue(p); - } + FOREACH_THREAD_IN_PROC (p, td) + if (td->td_proc->p_stat == SRUN) /* XXXKSE */ + setrunqueue(td); p->p_sflag |= PS_INMEM; @@ -368,6 +378,8 @@ faultin(p) * is enough space for them. Of course, if a process waits for a long * time, it will be swapped in anyway. * + * XXXKSE - KSEGRP with highest priority counts.. + * * Giant is still held at this point, to be released in tsleep. */ /* ARGSUSED*/ @@ -392,24 +404,29 @@ loop: pp = NULL; ppri = INT_MIN; sx_slock(&allproc_lock); - LIST_FOREACH(p, &allproc, p_list) { + FOREACH_PROC_IN_SYSTEM(p) { + struct ksegrp *kg; mtx_lock_spin(&sched_lock); - if (p->p_stat == SRUN && - (p->p_sflag & (PS_INMEM | PS_SWAPPING)) == 0) { - - pri = p->p_swtime + p->p_slptime; - if ((p->p_sflag & PS_SWAPINREQ) == 0) { - pri -= p->p_nice * 8; - } - - /* - * if this process is higher priority and there is - * enough space, then select this process instead of - * the previous selection. - */ - if (pri > ppri) { - pp = p; - ppri = pri; + if (p->p_stat == SRUN + && (p->p_sflag & (PS_INMEM | PS_SWAPPING)) == 0) { + /* Find the minimum sleeptime for the process */ + FOREACH_KSEGRP_IN_PROC(p, kg) { + pri = p->p_swtime + kg->kg_slptime; + if ((p->p_sflag & PS_SWAPINREQ) == 0) { + pri -= kg->kg_nice * 8; + } + + + /* + * if this ksegrp is higher priority + * and there is enough space, then select + * this process instead of the previous + * selection. + */ + if (pri > ppri) { + pp = p; + ppri = pri; + } } } mtx_unlock_spin(&sched_lock); @@ -469,6 +486,7 @@ swapout_procs(action) int action; { struct proc *p; + struct ksegrp *kg; struct proc *outp, *outp2; int outpri, outpri2; int didswap = 0; @@ -481,6 +499,7 @@ retry: sx_slock(&allproc_lock); LIST_FOREACH(p, &allproc, p_list) { struct vmspace *vm; + int minslptime = 100000; PROC_LOCK(p); if (p->p_lock != 0 || @@ -511,50 +530,59 @@ retry: case SSTOP: /* * do not swapout a realtime process + * Check all the thread groups.. */ - if (PRI_IS_REALTIME(p->p_pri.pri_class)) { - mtx_unlock_spin(&sched_lock); - PROC_UNLOCK(p); - continue; + FOREACH_KSEGRP_IN_PROC(p, kg) { + if (PRI_IS_REALTIME(kg->kg_pri.pri_class)) { + mtx_unlock_spin(&sched_lock); + PROC_UNLOCK(p); + goto nextproc; + } + + /* + * Do not swapout a process waiting + * on a critical event of some kind. + * Also guarantee swap_idle_threshold1 + * time in memory. + */ + if (((kg->kg_pri.pri_level) < PSOCK) || + (kg->kg_slptime < swap_idle_threshold1)) { + mtx_unlock_spin(&sched_lock); + PROC_UNLOCK(p); + goto nextproc; + } + + /* + * If the system is under memory stress, + * or if we are swapping + * idle processes >= swap_idle_threshold2, + * then swap the process out. + */ + if (((action & VM_SWAP_NORMAL) == 0) && + (((action & VM_SWAP_IDLE) == 0) || + (kg->kg_slptime < swap_idle_threshold2))) { + mtx_unlock_spin(&sched_lock); + PROC_UNLOCK(p); + goto nextproc; + } + if (minslptime > kg->kg_slptime) + minslptime = kg->kg_slptime; } - /* - * Do not swapout a process waiting on a critical - * event of some kind. Also guarantee swap_idle_threshold1 - * time in memory. - */ - if (((p->p_pri.pri_level) < PSOCK) || - (p->p_slptime < swap_idle_threshold1)) { - mtx_unlock_spin(&sched_lock); - PROC_UNLOCK(p); - continue; - } - - /* - * If the system is under memory stress, or if we are swapping - * idle processes >= swap_idle_threshold2, then swap the process - * out. - */ - if (((action & VM_SWAP_NORMAL) == 0) && - (((action & VM_SWAP_IDLE) == 0) || - (p->p_slptime < swap_idle_threshold2))) { - mtx_unlock_spin(&sched_lock); - PROC_UNLOCK(p); - continue; - } mtx_unlock_spin(&sched_lock); - ++vm->vm_refcnt; /* - * do not swapout a process that is waiting for VM - * data structures there is a possible deadlock. + * do not swapout a process that + * is waiting for VM + * data structures there is a + * possible deadlock. */ if (lockmgr(&vm->vm_map.lock, LK_EXCLUSIVE | LK_NOWAIT, - NULL, curproc)) { + NULL, curthread)) { vmspace_free(vm); PROC_UNLOCK(p); - continue; + goto nextproc; } vm_map_unlock(&vm->vm_map); /* @@ -563,7 +591,7 @@ retry: */ if ((action & VM_SWAP_NORMAL) || ((action & VM_SWAP_IDLE) && - (p->p_slptime > swap_idle_threshold2))) { + (minslptime > swap_idle_threshold2))) { sx_sunlock(&allproc_lock); swapout(p); vmspace_free(vm); @@ -573,6 +601,7 @@ retry: PROC_UNLOCK(p); vmspace_free(vm); } +nextproc: } sx_sunlock(&allproc_lock); /* @@ -587,6 +616,7 @@ static void swapout(p) struct proc *p; { + struct thread *td; PROC_LOCK_ASSERT(p, MA_OWNED); #if defined(SWAP_DEBUG) @@ -602,11 +632,14 @@ swapout(p) p->p_sflag &= ~PS_INMEM; p->p_sflag |= PS_SWAPPING; PROC_UNLOCK_NOSWITCH(p); - if (p->p_stat == SRUN) - remrunqueue(p); + FOREACH_THREAD_IN_PROC (p, td) + if (td->td_proc->p_stat == SRUN) /* XXXKSE */ + remrunqueue(td); /* XXXKSE */ mtx_unlock_spin(&sched_lock); pmap_swapout_proc(p); + FOREACH_THREAD_IN_PROC(p, td) + pmap_swapout_thread(td); mtx_lock_spin(&sched_lock); p->p_sflag &= ~PS_SWAPPING; diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 72c0a06..e7a4898 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -266,7 +266,7 @@ void vm_map_lock(vm_map_t map) { vm_map_printf("locking map LK_EXCLUSIVE: %p\n", map); - if (lockmgr(&map->lock, LK_EXCLUSIVE, NULL, curproc) != 0) + if (lockmgr(&map->lock, LK_EXCLUSIVE, NULL, curthread) != 0) panic("vm_map_lock: failed to get lock"); map->timestamp++; } @@ -275,29 +275,29 @@ void vm_map_unlock(vm_map_t map) { vm_map_printf("locking map LK_RELEASE: %p\n", map); - lockmgr(&(map)->lock, LK_RELEASE, NULL, curproc); + lockmgr(&(map)->lock, LK_RELEASE, NULL, curthread); } void vm_map_lock_read(vm_map_t map) { vm_map_printf("locking map LK_SHARED: %p\n", map); - lockmgr(&(map)->lock, LK_SHARED, NULL, curproc); + lockmgr(&(map)->lock, LK_SHARED, NULL, curthread); } void vm_map_unlock_read(vm_map_t map) { vm_map_printf("locking map LK_RELEASE: %p\n", map); - lockmgr(&(map)->lock, LK_RELEASE, NULL, curproc); + lockmgr(&(map)->lock, LK_RELEASE, NULL, curthread); } static __inline__ int -_vm_map_lock_upgrade(vm_map_t map, struct proc *p) { +_vm_map_lock_upgrade(vm_map_t map, struct thread *td) { int error; vm_map_printf("locking map LK_EXCLUPGRADE: %p\n", map); - error = lockmgr(&map->lock, LK_EXCLUPGRADE, NULL, p); + error = lockmgr(&map->lock, LK_EXCLUPGRADE, NULL, td); if (error == 0) map->timestamp++; return error; @@ -306,14 +306,14 @@ _vm_map_lock_upgrade(vm_map_t map, struct proc *p) { int vm_map_lock_upgrade(vm_map_t map) { - return(_vm_map_lock_upgrade(map, curproc)); + return(_vm_map_lock_upgrade(map, curthread)); } void vm_map_lock_downgrade(vm_map_t map) { vm_map_printf("locking map LK_DOWNGRADE: %p\n", map); - lockmgr(&map->lock, LK_DOWNGRADE, NULL, curproc); + lockmgr(&map->lock, LK_DOWNGRADE, NULL, curthread); } void @@ -1863,7 +1863,7 @@ vm_map_clean( int flags; vm_object_reference(object); - vn_lock(object->handle, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(object->handle, LK_EXCLUSIVE | LK_RETRY, curthread); flags = (syncio || invalidate) ? OBJPC_SYNC : 0; flags |= invalidate ? OBJPC_INVAL : 0; vm_object_page_clean(object, @@ -1877,7 +1877,7 @@ vm_map_clean( OFF_TO_IDX(offset + size + PAGE_MASK), FALSE); } - VOP_UNLOCK(object->handle, 0, curproc); + VOP_UNLOCK(object->handle, 0, curthread); vm_object_deallocate(object); } start += size; @@ -2619,8 +2619,8 @@ vmspace_exec(struct proc *p) p->p_vmspace = newvmspace; pmap_pinit2(vmspace_pmap(newvmspace)); vmspace_free(oldvmspace); - if (p == curproc) - pmap_activate(p); + if (p == curthread->td_proc) /* XXXKSE ? */ + pmap_activate(curthread); } /* @@ -2641,8 +2641,8 @@ vmspace_unshare(struct proc *p) p->p_vmspace = newvmspace; pmap_pinit2(vmspace_pmap(newvmspace)); vmspace_free(oldvmspace); - if (p == curproc) - pmap_activate(p); + if (p == curthread->td_proc) /* XXXKSE ? */ + pmap_activate(curthread); } diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 8839cd8..3776a6e 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -210,7 +210,7 @@ void vm_map_entry_set_behavior(struct vm_map_entry *entry, u_char behavior); #define vm_map_lock_drain_interlock(map) \ do { \ lockmgr(&(map)->lock, LK_DRAIN|LK_INTERLOCK, \ - &(map)->ref_lock, curproc); \ + &(map)->ref_lock, curthread); \ (map)->timestamp++; \ } while(0) #endif diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index 20346fa..c3697be 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -73,27 +73,34 @@ static fixpt_t cexp[3] = { /* * Compute a tenex style load average of a quantity on * 1, 5 and 15 minute intervals. + * XXXKSE Needs complete rewrite when correct info is available. + * Completely Bogus.. only works with 1:1 (but compiles ok now :-) */ static void loadav(struct loadavg *avg) { int i, nrun; struct proc *p; + struct ksegrp *kg; sx_slock(&allproc_lock); - for (nrun = 0, p = LIST_FIRST(&allproc); p != 0; p = LIST_NEXT(p, p_list)) { - switch (p->p_stat) { - case SSLEEP: - if (p->p_pri.pri_level > PZERO || - p->p_slptime != 0) - continue; - /* FALLTHROUGH */ - case SRUN: - if ((p->p_flag & P_NOLOAD) != 0) - continue; - /* FALLTHROUGH */ - case SIDL: - nrun++; + nrun = 0; + FOREACH_PROC_IN_SYSTEM(p) { + FOREACH_KSEGRP_IN_PROC(p, kg) { + switch (p->p_stat) { + case SSLEEP: + if (kg->kg_pri.pri_level > PZERO || + kg->kg_slptime != 0) /* ke? */ + goto nextproc; + /* FALLTHROUGH */ + case SRUN: + if ((p->p_flag & P_NOLOAD) != 0) + goto nextproc; + /* FALLTHROUGH */ + case SIDL: + nrun++; + } +nextproc: } } sx_sunlock(&allproc_lock); @@ -139,6 +146,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) vm_object_t object; vm_map_t map; int paging; + struct ksegrp *kg; totalp = &total; bzero(totalp, sizeof *totalp); @@ -152,7 +160,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) * Calculate process statistics. */ sx_slock(&allproc_lock); - LIST_FOREACH(p, &allproc, p_list) { + FOREACH_PROC_IN_SYSTEM(p) { if (p->p_flag & P_SYSTEM) continue; mtx_lock_spin(&sched_lock); @@ -164,14 +172,15 @@ vmtotal(SYSCTL_HANDLER_ARGS) case SMTX: case SSLEEP: case SSTOP: + kg = &p->p_ksegrp; /* XXXKSE */ if (p->p_sflag & PS_INMEM) { - if (p->p_pri.pri_level <= PZERO) + if (kg->kg_pri.pri_level <= PZERO) totalp->t_dw++; - else if (p->p_slptime < maxslp) + else if (kg->kg_slptime < maxslp) totalp->t_sl++; - } else if (p->p_slptime < maxslp) + } else if (kg->kg_slptime < maxslp) totalp->t_sw++; - if (p->p_slptime >= maxslp) { + if (kg->kg_slptime >= maxslp) { mtx_unlock_spin(&sched_lock); continue; } diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 17fd7f2..0336529 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -112,8 +112,8 @@ vmmapentry_rsrc_init(dummy) */ /* ARGSUSED */ int -sbrk(p, uap) - struct proc *p; +sbrk(td, uap) + struct thread *td; struct sbrk_args *uap; { /* Not yet implemented */ @@ -133,8 +133,8 @@ struct sstk_args { */ /* ARGSUSED */ int -sstk(p, uap) - struct proc *p; +sstk(td, uap) + struct thread *td; struct sstk_args *uap; { /* Not yet implemented */ @@ -152,12 +152,12 @@ struct getpagesize_args { /* ARGSUSED */ int -ogetpagesize(p, uap) - struct proc *p; +ogetpagesize(td, uap) + struct thread *td; struct getpagesize_args *uap; { /* MP SAFE */ - p->p_retval[0] = PAGE_SIZE; + td->td_retval[0] = PAGE_SIZE; return (0); } #endif /* COMPAT_43 || COMPAT_SUNOS */ @@ -196,11 +196,11 @@ struct mmap_args { * MPSAFE */ int -mmap(p, uap) - struct proc *p; +mmap(td, uap) + struct thread *td; struct mmap_args *uap; { - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp = td->td_proc->p_fd; struct file *fp = NULL; struct vnode *vp; vm_offset_t addr; @@ -210,7 +210,7 @@ mmap(p, uap) int flags, error; int disablexworkaround; off_t pos; - struct vmspace *vms = p->p_vmspace; + struct vmspace *vms = td->td_proc->p_vmspace; vm_object_t obj; addr = (vm_offset_t) uap->addr; @@ -358,7 +358,7 @@ mmap(p, uap) if (securelevel >= 1) disablexworkaround = 1; else - disablexworkaround = suser(p); + disablexworkaround = suser_td(td); if (vp->v_type == VCHR && disablexworkaround && (flags & (MAP_PRIVATE|MAP_COPY))) { error = EINVAL; @@ -396,7 +396,7 @@ mmap(p, uap) struct vattr va; if ((error = VOP_GETATTR(vp, &va, - p->p_ucred, p))) { + td->td_proc->p_ucred, td))) { goto done; } if ((va.va_flags & @@ -433,11 +433,11 @@ mmap(p, uap) error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot, flags, handle, pos); if (error == 0) - p->p_retval[0] = (register_t) (addr + pageoff); + td->td_retval[0] = (register_t) (addr + pageoff); mtx_lock(&Giant); done: if (fp) - fdrop(fp, p); + fdrop(fp, td); done2: mtx_unlock(&Giant); return (error); @@ -455,8 +455,8 @@ struct ommap_args { }; #endif int -ommap(p, uap) - struct proc *p; +ommap(td, uap) + struct thread *td; struct ommap_args *uap; { struct mmap_args nargs; @@ -492,7 +492,7 @@ ommap(p, uap) nargs.flags |= MAP_FIXED; nargs.fd = uap->fd; nargs.pos = uap->pos; - return (mmap(p, &nargs)); + return (mmap(td, &nargs)); } #endif /* COMPAT_43 */ @@ -508,8 +508,8 @@ struct msync_args { * MPSAFE */ int -msync(p, uap) - struct proc *p; +msync(td, uap) + struct thread *td; struct msync_args *uap; { vm_offset_t addr; @@ -534,7 +534,7 @@ msync(p, uap) mtx_lock(&Giant); - map = &p->p_vmspace->vm_map; + map = &td->td_proc->p_vmspace->vm_map; /* * XXX Gak! If size is zero we are supposed to sync "all modified @@ -588,8 +588,8 @@ struct munmap_args { * MPSAFE */ int -munmap(p, uap) - struct proc *p; +munmap(td, uap) + struct thread *td; struct munmap_args *uap; { vm_offset_t addr; @@ -620,7 +620,7 @@ munmap(p, uap) return (EINVAL); #endif mtx_lock(&Giant); - map = &p->p_vmspace->vm_map; + map = &td->td_proc->p_vmspace->vm_map; /* * Make sure entire range is allocated. */ @@ -636,14 +636,14 @@ munmap(p, uap) #if 0 void -munmapfd(p, fd) - struct proc *p; +munmapfd(td, fd) + struct thread *td; int fd; { /* * XXX should unmap any regions mapped to this file */ - p->p_fd->fd_ofileflags[fd] &= ~UF_MAPPED; + td->td_proc->p_fd->fd_ofileflags[fd] &= ~UF_MAPPED; } #endif @@ -658,8 +658,8 @@ struct mprotect_args { * MPSAFE */ int -mprotect(p, uap) - struct proc *p; +mprotect(td, uap) + struct thread *td; struct mprotect_args *uap; { vm_offset_t addr; @@ -683,7 +683,7 @@ mprotect(p, uap) return(EINVAL); mtx_lock(&Giant); - ret = vm_map_protect(&p->p_vmspace->vm_map, addr, + ret = vm_map_protect(&td->td_proc->p_vmspace->vm_map, addr, addr + size, prot, FALSE); mtx_unlock(&Giant); switch (ret) { @@ -706,8 +706,8 @@ struct minherit_args { * MPSAFE */ int -minherit(p, uap) - struct proc *p; +minherit(td, uap) + struct thread *td; struct minherit_args *uap; { vm_offset_t addr; @@ -727,7 +727,7 @@ minherit(p, uap) return(EINVAL); mtx_lock(&Giant); - ret = vm_map_inherit(&p->p_vmspace->vm_map, addr, addr+size, + ret = vm_map_inherit(&td->td_proc->p_vmspace->vm_map, addr, addr+size, inherit); mtx_unlock(&Giant); @@ -753,8 +753,8 @@ struct madvise_args { */ /* ARGSUSED */ int -madvise(p, uap) - struct proc *p; +madvise(td, uap) + struct thread *td; struct madvise_args *uap; { vm_offset_t start, end; @@ -787,7 +787,7 @@ madvise(p, uap) end = round_page((vm_offset_t) uap->addr + uap->len); mtx_lock(&Giant); - ret = vm_map_madvise(&p->p_vmspace->vm_map, start, end, uap->behav); + ret = vm_map_madvise(&td->td_proc->p_vmspace->vm_map, start, end, uap->behav); mtx_unlock(&Giant); return (ret ? EINVAL : 0); } @@ -805,8 +805,8 @@ struct mincore_args { */ /* ARGSUSED */ int -mincore(p, uap) - struct proc *p; +mincore(td, uap) + struct thread *td; struct mincore_args *uap; { vm_offset_t addr, first_addr; @@ -838,8 +838,8 @@ mincore(p, uap) vec = uap->vec; mtx_lock(&Giant); - map = &p->p_vmspace->vm_map; - pmap = vmspace_pmap(p->p_vmspace); + map = &td->td_proc->p_vmspace->vm_map; + pmap = vmspace_pmap(td->td_proc->p_vmspace); vm_map_lock_read(map); RestartScan: @@ -1001,8 +1001,8 @@ struct mlock_args { * MPSAFE */ int -mlock(p, uap) - struct proc *p; +mlock(td, uap) + struct thread *td; struct mlock_args *uap; { vm_offset_t addr; @@ -1025,17 +1025,17 @@ mlock(p, uap) return (EAGAIN); #ifdef pmap_wired_count - if (size + ptoa(pmap_wired_count(vm_map_pmap(&p->p_vmspace->vm_map))) > - p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur) + if (size + ptoa(pmap_wired_count(vm_map_pmap(&td->td_proc->p_vmspace->vm_map))) > + td->td_proc->p_rlimit[RLIMIT_MEMLOCK].rlim_cur) return (ENOMEM); #else - error = suser(p); + error = suser_td(td); if (error) return (error); #endif mtx_lock(&Giant); - error = vm_map_user_pageable(&p->p_vmspace->vm_map, addr, + error = vm_map_user_pageable(&td->td_proc->p_vmspace->vm_map, addr, addr + size, FALSE); mtx_unlock(&Giant); return (error == KERN_SUCCESS ? 0 : ENOMEM); @@ -1051,8 +1051,8 @@ struct mlockall_args { * MPSAFE */ int -mlockall(p, uap) - struct proc *p; +mlockall(td, uap) + struct thread *td; struct mlockall_args *uap; { /* mtx_lock(&Giant); */ @@ -1070,8 +1070,8 @@ struct mlockall_args { * MPSAFE */ int -munlockall(p, uap) - struct proc *p; +munlockall(td, uap) + struct thread *td; struct munlockall_args *uap; { /* mtx_lock(&Giant); */ @@ -1089,8 +1089,8 @@ struct munlock_args { * MPSAFE */ int -munlock(p, uap) - struct proc *p; +munlock(td, uap) + struct thread *td; struct munlock_args *uap; { vm_offset_t addr; @@ -1110,13 +1110,13 @@ munlock(p, uap) return (EINVAL); #ifndef pmap_wired_count - error = suser(p); + error = suser_td(td); if (error) return (error); #endif mtx_lock(&Giant); - error = vm_map_user_pageable(&p->p_vmspace->vm_map, addr, + error = vm_map_user_pageable(&td->td_proc->p_vmspace->vm_map, addr, addr + size, TRUE); mtx_unlock(&Giant); return (error == KERN_SUCCESS ? 0 : ENOMEM); @@ -1143,7 +1143,7 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, int rv = KERN_SUCCESS; vm_ooffset_t objsize; int docow; - struct proc *p = curproc; + struct thread *td = curthread; if (size == 0) return (0); @@ -1192,7 +1192,7 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, struct vattr vat; int error; - error = VOP_GETATTR(vp, &vat, p->p_ucred, p); + error = VOP_GETATTR(vp, &vat, td->td_proc->p_ucred, td); if (error) { mtx_unlock(&Giant); return (error); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index fe7e8c6..1d5a989 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -326,7 +326,7 @@ vm_object_reference(vm_object_t object) object->ref_count++; if (object->type == OBJT_VNODE) { - while (vget((struct vnode *) object->handle, LK_RETRY|LK_NOOBJ, curproc)) { + while (vget((struct vnode *) object->handle, LK_RETRY|LK_NOOBJ, curthread)) { printf("vm_object_reference: delay in getting object\n"); } } diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 187d8ba7..be7df98 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -546,7 +546,7 @@ vm_pageout_map_deactivate_pages(map, desired) vm_object_t obj, bigobj; GIANT_REQUIRED; - if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curproc)) { + if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curthread)) { return; } @@ -863,7 +863,7 @@ rescan0: mp = NULL; if (vp->v_type == VREG) vn_start_write(vp, &mp, V_NOWAIT); - if (vget(vp, LK_EXCLUSIVE|LK_NOOBJ, curproc)) { + if (vget(vp, LK_EXCLUSIVE|LK_NOOBJ, curthread)) { vn_finished_write(mp); if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; @@ -1162,11 +1162,14 @@ rescan0: } sx_sunlock(&allproc_lock); if (bigproc != NULL) { + struct ksegrp *kg; killproc(bigproc, "out of swap space"); mtx_lock_spin(&sched_lock); - bigproc->p_estcpu = 0; - bigproc->p_nice = PRIO_MIN; - resetpriority(bigproc); + FOREACH_KSEGRP_IN_PROC(bigproc, kg) { + kg->kg_estcpu = 0; + kg->kg_nice = PRIO_MIN; /* XXXKSE ??? */ + resetpriority(kg); + } mtx_unlock_spin(&sched_lock); PROC_UNLOCK(bigproc); wakeup(&cnt.v_free_count); @@ -1358,9 +1361,9 @@ vm_pageout() if (vm_pageout_stats_free_max == 0) vm_pageout_stats_free_max = 5; - PROC_LOCK(curproc); - curproc->p_flag |= P_BUFEXHAUST; - PROC_UNLOCK(curproc); + PROC_LOCK(curthread->td_proc); + curthread->td_proc->p_flag |= P_BUFEXHAUST; + PROC_UNLOCK(curthread->td_proc); swap_pager_swap_init(); pass = 0; /* @@ -1421,7 +1424,7 @@ vm_pageout() void pagedaemon_wakeup() { - if (!vm_pages_needed && curproc != pageproc) { + if (!vm_pages_needed && curthread->td_proc != pageproc) { vm_pages_needed++; wakeup(&vm_pages_needed); } diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 72f7b9c..1a26712 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -188,8 +188,8 @@ struct swapon_args { */ /* ARGSUSED */ int -swapon(p, uap) - struct proc *p; +swapon(td, uap) + struct thread *td; struct swapon_args *uap; { struct vattr attr; @@ -198,8 +198,7 @@ swapon(p, uap) int error; mtx_lock(&Giant); - - error = suser(p); + error = suser_td(td); if (error) goto done2; @@ -212,7 +211,7 @@ swapon(p, uap) goto done2; } - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->name, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->name, td); error = namei(&nd); if (error) goto done2; @@ -221,14 +220,14 @@ swapon(p, uap) vp = nd.ni_vp; if (vn_isdisk(vp, &error)) - error = swaponvp(p, vp, vp->v_rdev, 0); + error = swaponvp(td, vp, vp->v_rdev, 0); else if (vp->v_type == VREG && vp->v_tag == VT_NFS && - (error = VOP_GETATTR(vp, &attr, p->p_ucred, p)) == 0) { + (error = VOP_GETATTR(vp, &attr, td->td_proc->p_ucred, td)) == 0) { /* * Allow direct swapping to NFS regular files in the same * way that nfs_mountroot() sets up diskless swapping. */ - error = swaponvp(p, vp, NODEV, attr.va_size / DEV_BSIZE); + error = swaponvp(td, vp, NODEV, attr.va_size / DEV_BSIZE); } if (error) @@ -250,8 +249,8 @@ done2: * XXX locking when multiple swapon's run in parallel */ int -swaponvp(p, vp, dev, nblks) - struct proc *p; +swaponvp(td, vp, dev, nblks) + struct thread *td; struct vnode *vp; dev_t dev; u_long nblks; @@ -263,6 +262,7 @@ swaponvp(p, vp, dev, nblks) swblk_t dvbase; int error; u_long aligned_nblks; + struct proc *p = td->td_proc; if (!swapdev_vp) { error = getnewvnode(VT_NON, NULL, swapdev_vnodeop_p, @@ -282,19 +282,19 @@ swaponvp(p, vp, dev, nblks) } return EINVAL; found: - (void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(vp, FREAD | FWRITE, p->p_ucred, p); - (void) VOP_UNLOCK(vp, 0, p); + (void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(vp, FREAD | FWRITE, p->p_ucred, td); + (void) VOP_UNLOCK(vp, 0, td); if (error) return (error); if (nblks == 0 && dev != NODEV && (devsw(dev)->d_psize == 0 || (nblks = (*devsw(dev)->d_psize) (dev)) == -1)) { - (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p); + (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, td); return (ENXIO); } if (nblks == 0) { - (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p); + (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, td); return (ENXIO); } @@ -305,7 +305,7 @@ swaponvp(p, vp, dev, nblks) if (nblks > 0x40000000 / BLIST_META_RADIX / nswdev) { printf("exceeded maximum of %d blocks per swap unit\n", 0x40000000 / BLIST_META_RADIX / nswdev); - (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p); + (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, td); return (ENXIO); } /* diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index 10a5f65..47a768f 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -70,11 +70,11 @@ struct obreak_args { */ /* ARGSUSED */ int -obreak(p, uap) - struct proc *p; +obreak(td, uap) + struct thread *td; struct obreak_args *uap; { - struct vmspace *vm = p->p_vmspace; + struct vmspace *vm = td->td_proc->p_vmspace; vm_offset_t new, old, base; int rv; int error = 0; @@ -90,7 +90,7 @@ obreak(p, uap) * reduce their usage, even if they remain over the limit. */ if (new > old && - (new - base) > (unsigned) p->p_rlimit[RLIMIT_DATA].rlim_cur) { + (new - base) > (unsigned) td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) { error = ENOMEM; goto done; } @@ -143,8 +143,8 @@ struct ovadvise_args { */ /* ARGSUSED */ int -ovadvise(p, uap) - struct proc *p; +ovadvise(td, uap) + struct thread *td; struct ovadvise_args *uap; { /* START_GIANT_OPTIONAL */ diff --git a/sys/vm/vm_zeroidle.c b/sys/vm/vm_zeroidle.c index 1fcab4d..a7e5685 100644 --- a/sys/vm/vm_zeroidle.c +++ b/sys/vm/vm_zeroidle.c @@ -112,14 +112,14 @@ vm_page_zero_idle_wakeup(void) static void vm_pagezero(void) { - struct proc *p = curproc; + struct thread *td = curthread; struct rtprio rtp; int pages = 0; rtp.prio = RTP_PRIO_MAX; rtp.type = RTP_PRIO_IDLE; mtx_lock_spin(&sched_lock); - rtp_to_pri(&rtp, &p->p_pri); + rtp_to_pri(&rtp, &td->td_ksegrp->kg_pri); mtx_unlock_spin(&sched_lock); for (;;) { @@ -127,8 +127,8 @@ vm_pagezero(void) pages += vm_page_zero_idle(); if (pages > idlezero_maxrun) { mtx_lock_spin(&sched_lock); - setrunqueue(p); - p->p_stats->p_ru.ru_nvcsw++; + setrunqueue(td); + td->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); pages = 0; diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 7edaebc..bad9bcf 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -434,7 +434,7 @@ vnode_pager_input_smlfs(object, m) /* build a minimal buffer header */ bp->b_iocmd = BIO_READ; bp->b_iodone = vnode_pager_iodone; - bp->b_rcred = bp->b_wcred = curproc->p_ucred; + bp->b_rcred = bp->b_wcred = curthread->td_proc->p_ucred; if (bp->b_rcred != NOCRED) crhold(bp->b_rcred); if (bp->b_wcred != NOCRED) @@ -527,9 +527,9 @@ vnode_pager_input_old(object, m) auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; auio.uio_resid = size; - auio.uio_procp = curproc; + auio.uio_td = curthread; - error = VOP_READ(vp, &auio, 0, curproc->p_ucred); + error = VOP_READ(vp, &auio, 0, curthread->td_proc->p_ucred); if (!error) { int count = size - auio.uio_resid; @@ -754,7 +754,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) bp->b_iocmd = BIO_READ; bp->b_iodone = vnode_pager_iodone; /* B_PHYS is not set, but it is nice to fill this in */ - bp->b_rcred = bp->b_wcred = curproc->p_ucred; + bp->b_rcred = bp->b_wcred = curthread->td_proc->p_ucred; if (bp->b_rcred != NOCRED) crhold(bp->b_rcred); if (bp->b_wcred != NOCRED) @@ -983,8 +983,8 @@ vnode_pager_generic_putpages(vp, m, bytecount, flags, rtvals) auio.uio_segflg = UIO_NOCOPY; auio.uio_rw = UIO_WRITE; auio.uio_resid = maxsize; - auio.uio_procp = (struct proc *) 0; - error = VOP_WRITE(vp, &auio, ioflags, curproc->p_ucred); + auio.uio_td = (struct thread *) 0; + error = VOP_WRITE(vp, &auio, ioflags, curthread->td_proc->p_ucred); cnt.v_vnodeout++; cnt.v_vnodepgsout += ncount; @@ -1005,7 +1005,7 @@ struct vnode * vnode_pager_lock(object) vm_object_t object; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ GIANT_REQUIRED; @@ -1018,7 +1018,7 @@ vnode_pager_lock(object) /* XXX; If object->handle can change, we need to cache it. */ while (vget(object->handle, - LK_NOPAUSE | LK_SHARED | LK_RETRY | LK_CANRECURSE, p)) { + LK_NOPAUSE | LK_SHARED | LK_RETRY | LK_CANRECURSE, td)){ if ((object->flags & OBJ_DEAD) || (object->type != OBJT_VNODE)) return NULL; printf("vnode_pager_lock: retrying\n"); |