From dadab5e9782225b1752766daee5c789e2266b933 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 25 Jun 2003 03:56:13 +0000 Subject: [PATCH] proc->thread stage 4: rework the VFS and DEVICE subsystems to take thread pointers instead of process pointers as arguments, similar to what FreeBSD-5 did. Note however that ultimately both APIs are going to be message-passing which means the current thread context will not be useable for creds and descriptor access. --- sbin/vinum/vinumparser.c | 3 +- sys/bus/pccard/pccard.c | 10 +- sys/bus/usb/usb.c | 4 +- sys/dev/agp/agp.c | 14 +- sys/dev/disk/ata/atapi-cd.c | 4 +- sys/dev/disk/ccd/ccd.c | 49 +- sys/dev/disk/fd/fd.c | 5 +- sys/dev/disk/vn/vn.c | 34 +- sys/dev/disk/wcd/wd_cd.c | 4 +- sys/dev/disk/wfd/wfd.c | 8 +- sys/dev/drm/drm_os_freebsd.h | 4 +- sys/dev/misc/nmdm/nmdm.c | 4 +- sys/dev/misc/snp/snp.c | 4 +- sys/dev/misc/spigot/spigot.c | 6 +- sys/dev/misc/streams/streams.c | 33 +- sys/dev/misc/syscons/syscons.c | 8 +- sys/dev/misc/syscons/sysmouse.c | 4 +- sys/dev/netif/an/if_an.c | 14 +- sys/dev/netif/awi/awi.c | 8 +- sys/dev/netif/awi/awi_wep.c | 5 +- sys/dev/netif/awi/awi_wicfg.c | 10 +- sys/dev/netif/cx/cx.c | 10 +- sys/dev/netif/sbni/if_sbni.c | 8 +- sys/dev/netif/sbsh/if_sbsh.c | 12 +- sys/dev/netif/wi/if_wi.c | 16 +- sys/dev/netif/wi/wi_hostap.c | 12 +- sys/dev/netif/wl/if_wl.c | 14 +- sys/dev/raid/aac/aac_linux.c | 10 +- sys/dev/raid/asr/asr.c | 5 +- sys/dev/raid/vinum/vinum.c | 7 +- sys/dev/raid/vinum/vinumparser.c | 3 +- sys/dev/serial/cy/cy.c | 27 +- sys/dev/serial/dgb/dgm.c | 14 +- sys/dev/serial/rc/rc.c | 6 +- sys/dev/serial/rp/rp.c | 14 +- sys/dev/serial/rp2/rp.c | 8 +- sys/dev/serial/si/si.c | 24 +- sys/dev/serial/sio/sio.c | 9 +- sys/dev/serial/stl/stallion.c | 8 +- sys/dev/serial/stli/istallion.c | 8 +- sys/dev/usbmisc/ucom/ucom.c | 7 +- sys/dev/usbmisc/ugen/ugen.c | 6 +- sys/dev/usbmisc/urio/urio.c | 4 +- sys/dev/video/pcvt/i386/pcvt_drv.c | 6 +- sys/dev/video/pcvt/i386/pcvt_ext.c | 4 +- sys/emulation/ibcs2/coff/imgact_coff.c | 35 +- sys/emulation/ibcs2/i386/ibcs2_fcntl.c | 12 +- sys/emulation/ibcs2/i386/ibcs2_ioctl.c | 37 +- sys/emulation/ibcs2/i386/ibcs2_misc.c | 28 +- sys/emulation/ibcs2/i386/ibcs2_socksys.c | 2 +- sys/emulation/ibcs2/i386/ibcs2_stat.c | 18 +- sys/emulation/ibcs2/i386/ibcs2_sysi86.c | 5 +- sys/emulation/ibcs2/i386/ibcs2_util.c | 21 +- sys/emulation/ibcs2/i386/ibcs2_xenix.c | 8 +- .../linux/i386/linprocfs/linprocfs.h | 6 +- .../linux/i386/linprocfs/linprocfs_subr.c | 22 +- .../linux/i386/linprocfs/linprocfs_vfsops.c | 22 +- .../linux/i386/linprocfs/linprocfs_vnops.c | 23 +- sys/emulation/linux/i386/linux.h | 6 +- sys/emulation/linux/i386/linux_machdep.c | 9 +- sys/emulation/linux/i386/linux_sysvec.c | 4 +- sys/emulation/linux/linux_file.c | 25 +- sys/emulation/linux/linux_getcwd.c | 46 +- sys/emulation/linux/linux_ioctl.c | 99 +-- sys/emulation/linux/linux_ioctl.h | 3 +- sys/emulation/linux/linux_mib.c | 56 +- sys/emulation/linux/linux_mib.h | 14 +- sys/emulation/linux/linux_misc.c | 101 ++- sys/emulation/linux/linux_socket.c | 9 +- sys/emulation/linux/linux_stats.c | 59 +- sys/emulation/linux/linux_uid16.c | 4 +- sys/emulation/linux/linux_util.c | 32 +- sys/emulation/linux/linux_util.h | 27 +- sys/emulation/svr4/svr4_fcntl.c | 62 +- sys/emulation/svr4/svr4_filio.c | 15 +- sys/emulation/svr4/svr4_ioctl.c | 11 +- sys/emulation/svr4/svr4_ioctl.h | 14 +- sys/emulation/svr4/svr4_misc.c | 88 ++- sys/emulation/svr4/svr4_socket.c | 22 +- sys/emulation/svr4/svr4_socket.h | 8 +- sys/emulation/svr4/svr4_sockio.c | 12 +- sys/emulation/svr4/svr4_stat.c | 25 +- sys/emulation/svr4/svr4_stream.c | 213 ++++--- sys/emulation/svr4/svr4_sysvec.c | 26 +- sys/emulation/svr4/svr4_termios.c | 21 +- sys/emulation/svr4/svr4_ttold.c | 31 +- sys/i386/gnu/isa/dgb.c | 32 +- sys/i386/i386/busdma_machdep.c | 16 +- sys/i386/i386/machdep.c | 4 +- sys/i386/i386/mem.c | 11 +- sys/i386/i386/sys_machdep.c | 8 +- sys/i386/i386/trap.c | 13 +- sys/i386/i386/vm86.c | 8 +- sys/i386/i386/vm_machdep.c | 11 +- sys/kern/imgact_aout.c | 22 +- sys/kern/imgact_elf.c | 40 +- sys/kern/init_main.c | 5 +- sys/kern/kern_acct.c | 29 +- sys/kern/kern_acl.c | 81 ++- sys/kern/kern_descrip.c | 213 +++---- sys/kern/kern_event.c | 76 ++- sys/kern/kern_exec.c | 23 +- sys/kern/kern_exit.c | 4 +- sys/kern/kern_fork.c | 5 +- sys/kern/kern_jail.c | 26 +- sys/kern/kern_ktrace.c | 38 +- sys/kern/kern_linker.c | 41 +- sys/kern/kern_lock.c | 79 ++- sys/kern/kern_memio.c | 11 +- sys/kern/kern_mib.c | 5 +- sys/kern/kern_ntptime.c | 5 +- sys/kern/kern_prot.c | 69 +-- sys/kern/kern_resource.c | 8 +- sys/kern/kern_shutdown.c | 5 +- sys/kern/kern_sig.c | 39 +- sys/kern/kern_subr.c | 6 +- sys/kern/kern_synch.c | 26 +- sys/kern/kern_sysctl.c | 11 +- sys/kern/kern_time.c | 13 +- sys/kern/kern_xxx.c | 16 +- sys/kern/link_aout.c | 17 +- sys/kern/link_elf.c | 23 +- sys/kern/subr_prf.c | 11 +- sys/kern/sys_generic.c | 105 ++-- sys/kern/sys_pipe.c | 77 +-- sys/kern/sys_process.c | 14 +- sys/kern/sys_socket.c | 61 +- sys/kern/sysv_ipc.c | 7 +- sys/kern/sysv_msg.c | 7 +- sys/kern/tty.c | 21 +- sys/kern/tty_cons.c | 4 +- sys/kern/tty_pty.c | 4 +- sys/kern/tty_tty.c | 65 +- sys/kern/uipc_socket.c | 107 ++-- sys/kern/uipc_socket2.c | 25 +- sys/kern/uipc_syscalls.c | 190 +++--- sys/kern/uipc_usrreq.c | 137 +++-- sys/kern/vfs_cache.c | 22 +- sys/kern/vfs_conf.c | 9 +- sys/kern/vfs_default.c | 115 ++-- sys/kern/vfs_lookup.c | 66 +- sys/kern/vfs_subr.c | 195 +++--- sys/kern/vfs_syscalls.c | 581 ++++++++++-------- sys/kern/vfs_vnops.c | 166 +++-- sys/kern/vnode_if.src | 44 +- sys/net/gre/if_gre.c | 20 +- sys/net/i4b/driver/i4b_ipr.c | 9 +- sys/net/if.c | 30 +- sys/net/if.h | 6 +- sys/net/if_var.h | 4 +- sys/net/ppp/if_ppp.c | 45 +- sys/net/ppp/if_pppvar.h | 8 +- sys/net/ppp_layer/ppp_tty.c | 19 +- sys/net/raw_usrreq.c | 20 +- sys/net/route.c | 7 +- sys/net/route.h | 4 +- sys/net/rtsock.c | 20 +- sys/net/sl/if_sl.c | 5 +- sys/net/tap/if_tap.c | 23 +- sys/net/tap/if_tapvar.h | 4 +- sys/net/tun/if_tun.c | 5 +- sys/netgraph/ksocket/ng_ksocket.c | 24 +- sys/netgraph/socket/ng_socket.c | 22 +- sys/netgraph/tty/ng_tty.c | 6 +- sys/netinet/in.c | 32 +- sys/netinet/in.h | 8 +- sys/netinet/in_pcb.c | 57 +- sys/netinet/in_pcb.h | 10 +- sys/netinet/in_var.h | 4 +- sys/netinet/ip_divert.c | 16 +- sys/netinet/ip_output.c | 6 +- sys/netinet/raw_ip.c | 14 +- sys/netinet/tcp_subr.c | 8 +- sys/netinet/tcp_syncache.c | 4 +- sys/netinet/tcp_usrreq.c | 72 +-- sys/netinet/udp_usrreq.c | 47 +- sys/netinet6/in6.c | 22 +- sys/netinet6/in6_pcb.c | 27 +- sys/netinet6/in6_src.c | 9 +- sys/netinet6/ip6_input.c | 6 +- sys/netinet6/ip6_output.c | 14 +- sys/netinet6/raw_ip6.c | 14 +- sys/netinet6/udp6_output.c | 16 +- sys/netinet6/udp6_usrreq.c | 28 +- sys/netproto/atalk/at_control.c | 5 +- sys/netproto/atalk/ddp_usrreq.c | 18 +- sys/netproto/atm/atm_usrreq.c | 22 +- sys/netproto/ipx/ipx.c | 12 +- sys/netproto/ipx/ipx_pcb.c | 33 +- sys/netproto/ipx/ipx_usrreq.c | 53 +- sys/netproto/ncp/ncp_conn.c | 156 ++--- sys/netproto/ncp/ncp_conn.h | 32 +- sys/netproto/ncp/ncp_login.c | 28 +- sys/netproto/ncp/ncp_mod.c | 126 ++-- sys/netproto/ncp/ncp_ncp.c | 37 +- sys/netproto/ncp/ncp_ncp.h | 7 +- sys/netproto/ncp/ncp_rq.c | 6 +- sys/netproto/ncp/ncp_rq.h | 14 +- sys/netproto/ncp/ncp_sock.c | 58 +- sys/netproto/ncp/ncp_sock.h | 5 +- sys/netproto/ncp/ncp_subr.c | 53 +- sys/netproto/ncp/ncp_subr.h | 11 +- sys/netproto/smb/smb_conn.c | 139 +++-- sys/netproto/smb/smb_conn.h | 22 +- sys/netproto/smb/smb_dev.c | 29 +- sys/netproto/smb/smb_iod.c | 34 +- sys/netproto/smb/smb_rq.c | 8 +- sys/netproto/smb/smb_smb.c | 4 +- sys/netproto/smb/smb_subr.c | 16 +- sys/netproto/smb/smb_subr.h | 11 +- sys/netproto/smb/smb_tran.h | 18 +- sys/netproto/smb/smb_trantcp.c | 82 +-- sys/opencrypto/cryptodev.c | 41 +- sys/platform/pc32/gnu/isa/dgb.c | 32 +- sys/platform/pc32/i386/busdma_machdep.c | 16 +- sys/platform/pc32/i386/machdep.c | 4 +- sys/platform/pc32/i386/mem.c | 11 +- sys/platform/pc32/i386/sys_machdep.c | 8 +- sys/platform/pc32/i386/trap.c | 13 +- sys/platform/pc32/i386/vm86.c | 8 +- sys/platform/pc32/i386/vm_machdep.c | 11 +- sys/sys/buf2.h | 16 +- sys/sys/event.h | 7 +- sys/sys/file.h | 135 +--- sys/sys/filedesc.h | 10 +- sys/sys/ktrace.h | 6 +- sys/sys/lock.h | 20 +- sys/sys/mount.h | 38 +- sys/sys/namei.h | 25 +- sys/sys/proc.h | 10 +- sys/sys/protosw.h | 26 +- sys/sys/socketvar.h | 33 +- sys/sys/sysctl.h | 4 +- sys/sys/systm.h | 4 +- sys/sys/thread.h | 4 +- sys/sys/ucred.h | 6 +- sys/sys/uio.h | 8 +- sys/sys/vnode.h | 36 +- sys/vfs/coda/coda_namecache.c | 4 +- sys/vfs/coda/coda_venus.c | 82 +-- sys/vfs/coda/coda_venus.h | 40 +- sys/vfs/coda/coda_vfsops.c | 48 +- sys/vfs/coda/coda_vfsops.h | 14 +- sys/vfs/coda/coda_vnops.c | 135 ++-- sys/vfs/coda/coda_vnops.h | 4 +- sys/vfs/fdesc/fdesc.h | 4 +- sys/vfs/fdesc/fdesc_vfsops.c | 41 +- sys/vfs/fdesc/fdesc_vnops.c | 63 +- sys/vfs/fifofs/fifo_vnops.c | 52 +- sys/vfs/gnu/ext2fs/ext2_vnops.c | 4 +- sys/vfs/hpfs/hpfs_vnops.c | 8 +- sys/vfs/isofs/cd9660/cd9660_lookup.c | 13 +- sys/vfs/isofs/cd9660/cd9660_node.c | 21 +- sys/vfs/isofs/cd9660/cd9660_vfsops.c | 101 ++- sys/vfs/isofs/cd9660/cd9660_vnops.c | 7 +- sys/vfs/mfs/mfs_extern.h | 6 +- sys/vfs/mfs/mfs_vfsops.c | 39 +- sys/vfs/mfs/mfs_vnops.c | 22 +- sys/vfs/mfs/mfsnode.h | 6 +- sys/vfs/msdosfs/denode.h | 4 +- sys/vfs/msdosfs/msdosfs_denode.c | 25 +- sys/vfs/msdosfs/msdosfs_lookup.c | 27 +- sys/vfs/msdosfs/msdosfs_vfsops.c | 94 +-- sys/vfs/msdosfs/msdosfs_vnops.c | 85 +-- sys/vfs/nfs/krpc.h | 7 +- sys/vfs/nfs/nfs.h | 74 +-- sys/vfs/nfs/nfs_bio.c | 179 +++--- sys/vfs/nfs/nfs_node.c | 33 +- sys/vfs/nfs/nfs_nqlease.c | 87 ++- sys/vfs/nfs/nfs_serv.c | 495 +++++++-------- sys/vfs/nfs/nfs_socket.c | 93 ++- sys/vfs/nfs/nfs_subs.c | 26 +- sys/vfs/nfs/nfs_syscalls.c | 74 +-- sys/vfs/nfs/nfs_vfsops.c | 99 ++- sys/vfs/nfs/nfs_vnops.c | 254 ++++---- sys/vfs/nfs/nfsnode.h | 12 +- sys/vfs/nfs/nqnfs.h | 16 +- sys/vfs/ntfs/ntfs_compr.c | 4 +- sys/vfs/ntfs/ntfs_subr.c | 8 +- sys/vfs/ntfs/ntfs_vfsops.c | 100 +-- sys/vfs/ntfs/ntfs_vfsops.h | 5 +- sys/vfs/ntfs/ntfs_vnops.c | 25 +- sys/vfs/nullfs/null_subr.c | 22 +- sys/vfs/nullfs/null_vfsops.c | 73 +-- sys/vfs/nullfs/null_vnops.c | 65 +- sys/vfs/nwfs/nwfs.h | 6 +- sys/vfs/nwfs/nwfs_io.c | 76 +-- sys/vfs/nwfs/nwfs_ioctl.c | 22 +- sys/vfs/nwfs/nwfs_node.c | 49 +- sys/vfs/nwfs/nwfs_node.h | 4 +- sys/vfs/nwfs/nwfs_subr.c | 69 ++- sys/vfs/nwfs/nwfs_subr.h | 29 +- sys/vfs/nwfs/nwfs_vfsops.c | 83 ++- sys/vfs/nwfs/nwfs_vnops.c | 116 ++-- sys/vfs/portal/portal_vfsops.c | 37 +- sys/vfs/portal/portal_vnops.c | 38 +- sys/vfs/procfs/procfs.h | 6 +- sys/vfs/procfs/procfs_subr.c | 24 +- sys/vfs/procfs/procfs_vfsops.c | 23 +- sys/vfs/procfs/procfs_vnops.c | 32 +- sys/vfs/smbfs/smbfs.h | 6 +- sys/vfs/smbfs/smbfs_io.c | 87 +-- sys/vfs/smbfs/smbfs_node.c | 47 +- sys/vfs/smbfs/smbfs_vfsops.c | 69 ++- sys/vfs/smbfs/smbfs_vnops.c | 140 +++-- sys/vfs/specfs/spec_vnops.c | 51 +- sys/vfs/ufs/ffs_balloc.c | 8 +- sys/vfs/ufs/ffs_extern.h | 17 +- sys/vfs/ufs/ffs_inode.c | 14 +- sys/vfs/ufs/ffs_rawread.c | 6 +- sys/vfs/ufs/ffs_softdep.c | 208 ++++--- sys/vfs/ufs/ffs_vfsops.c | 162 +++-- sys/vfs/ufs/quota.h | 9 +- sys/vfs/ufs/ufs_extern.h | 4 +- sys/vfs/ufs/ufs_ihash.c | 17 +- sys/vfs/ufs/ufs_inode.c | 14 +- sys/vfs/ufs/ufs_lookup.c | 54 +- sys/vfs/ufs/ufs_quota.c | 70 ++- sys/vfs/ufs/ufs_readwrite.c | 14 +- sys/vfs/ufs/ufs_vfsops.c | 30 +- sys/vfs/ufs/ufs_vnops.c | 85 ++- sys/vfs/ufs/ufsmount.h | 4 +- sys/vfs/umapfs/umap_subr.c | 6 +- sys/vfs/umapfs/umap_vfsops.c | 106 +--- sys/vfs/umapfs/umap_vnops.c | 15 +- sys/vfs/union/union.h | 12 +- sys/vfs/union/union_subr.c | 153 ++--- sys/vfs/union/union_vfsops.c | 40 +- sys/vfs/union/union_vnops.c | 254 ++++---- sys/vm/vm_extern.h | 4 +- sys/vm/vm_fault.c | 4 +- sys/vm/vm_glue.c | 4 +- sys/vm/vm_map.c | 6 +- sys/vm/vm_map.h | 32 +- sys/vm/vm_mmap.c | 30 +- sys/vm/vm_object.c | 4 +- sys/vm/vm_page.c | 10 +- sys/vm/vm_pageout.c | 6 +- sys/vm/vm_swap.c | 40 +- sys/vm/vnode_pager.c | 17 +- 340 files changed, 6117 insertions(+), 6152 deletions(-) diff --git a/sbin/vinum/vinumparser.c b/sbin/vinum/vinumparser.c index d2ad452e50..7dfe04a04a 100644 --- a/sbin/vinum/vinumparser.c +++ b/sbin/vinum/vinumparser.c @@ -35,7 +35,7 @@ * * $Id: vinumparser.c,v 1.21 2000/12/20 03:44:13 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumparser.c,v 1.20.2.5 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sbin/vinum/vinumparser.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sbin/vinum/vinumparser.c,v 1.3 2003/06/25 03:55:50 dillon Exp $ */ /* @@ -66,6 +66,7 @@ #include /* All this mess for a single struct definition */ #include +#include #include #include #include diff --git a/sys/bus/pccard/pccard.c b/sys/bus/pccard/pccard.c index c34a1da728..e0e48d78ef 100644 --- a/sys/bus/pccard/pccard.c +++ b/sys/bus/pccard/pccard.c @@ -30,7 +30,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pccard/pccard.c,v 1.106.2.15 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/pccard.c,v 1.3 2003/06/23 17:55:48 dillon Exp $ + * $DragonFly: src/sys/bus/pccard/pccard.c,v 1.4 2003/06/25 03:56:09 dillon Exp $ */ #include @@ -523,7 +523,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td) * At the very least, we only allow root to set the context. */ case PIOCSMEM: - if (suser_xxx(td->td_proc->p_ucred, 0)) + if (suser(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, d_thread_t *td) * Set I/O port context. */ case PIOCSIO: - if (suser_xxx(td->td_proc->p_ucred, 0)) + if (suser(td)) return (EPERM); if (slt->state != filled) return (ENXIO); @@ -573,7 +573,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td) *(unsigned long *)data = pccard_mem; break; } - if (suser_xxx(td->td_proc->p_ucred, 0)) + if (suser(td)) return (EPERM); /* * Validate the memory by checking it against the I/O @@ -605,7 +605,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td) * Allocate a driver to this slot. */ case PIOCSDRV: - if (suser_xxx(td->td_proc->p_ucred, 0)) + if (suser(td)) return (EPERM); err = allocate_driver(slt, (struct dev_desc *)data); if (!err) diff --git a/sys/bus/usb/usb.c b/sys/bus/usb/usb.c index b7bdfb960a..cd6f5c4b0d 100644 --- a/sys/bus/usb/usb.c +++ b/sys/bus/usb/usb.c @@ -1,6 +1,6 @@ /* $NetBSD: usb.c,v 1.33 1999/11/22 21:57:09 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb.c,v 1.26.2.9 2002/11/13 15:15:22 joe Exp $ */ -/* $DragonFly: src/sys/bus/usb/usb.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ */ +/* $DragonFly: src/sys/bus/usb/usb.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -468,7 +468,7 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, usb_proc_ptr p) uio.uio_rw = ur->ucr_request.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p->td_proc; + uio.uio_td = p; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 5ca1cc2a3d..4096a15326 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/pci/agp.c,v 1.3.2.4 2002/08/11 19:58:12 alc Exp $ - * $DragonFly: src/sys/dev/agp/agp.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/dev/agp/agp.c,v 1.4 2003/06/25 03:56:09 dillon Exp $ */ #include "opt_bus.h" @@ -271,7 +271,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); /* XXX */ destroy_dev(sc->as_devnode); agp_flush_cache(); return 0; @@ -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); /* XXX */ if (mem->am_is_bound) { device_printf(dev, "memory already bound\n"); @@ -452,7 +452,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); /* XXX */ return error; } } @@ -473,7 +473,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); /* XXX */ return 0; } @@ -485,7 +485,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); /* XXX */ if (!mem->am_is_bound) { device_printf(dev, "memory is not bound\n"); @@ -510,7 +510,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); /* XXX */ return 0; } diff --git a/sys/dev/disk/ata/atapi-cd.c b/sys/dev/disk/ata/atapi-cd.c index 3da0b35008..5cda8fbfef 100644 --- a/sys/dev/disk/ata/atapi-cd.c +++ b/sys/dev/disk/ata/atapi-cd.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-cd.c,v 1.48.2.20 2002/11/25 05:30:31 njl Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.4 2003/06/23 17:55:29 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.5 2003/06/25 03:55:46 dillon Exp $ */ #include "opt_ata.h" @@ -599,7 +599,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) break; case CDIOCRESET: - error = suser(); + error = suser(td); /* note: if no proc EPERM will be returned */ if (error) break; error = atapi_test_ready(cdp->device); diff --git a/sys/dev/disk/ccd/ccd.c b/sys/dev/disk/ccd/ccd.c index b8ca9a1740..1b432f683b 100644 --- a/sys/dev/disk/ccd/ccd.c +++ b/sys/dev/disk/ccd/ccd.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/ccd/ccd.c,v 1.73.2.1 2001/09/11 09:49:52 kris Exp $ */ -/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.4 2003/06/23 17:55:30 dillon Exp $ */ +/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.5 2003/06/25 03:55:47 dillon Exp $ */ /* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ @@ -200,8 +200,8 @@ static void ccdiodone __P((struct ccdbuf *cbp)); static void ccdstart __P((struct ccd_softc *, struct buf *)); static void ccdinterleave __P((struct ccd_softc *, int)); static void ccdintr __P((struct ccd_softc *, struct buf *)); -static int ccdinit __P((struct ccddevice *, char **, struct proc *)); -static int ccdlookup __P((char *, struct proc *p, struct vnode **)); +static int ccdinit __P((struct ccddevice *, char **, struct thread *)); +static int ccdlookup __P((char *, struct thread *td, struct vnode **)); static void ccdbuffer __P((struct ccdbuf **ret, struct ccd_softc *, struct buf *, daddr_t, caddr_t, long)); static void ccdgetdisklabel __P((dev_t)); @@ -358,10 +358,7 @@ ccd_modevent(mod, type, data) DEV_MODULE(ccd, ccd_modevent, NULL); static int -ccdinit(ccd, cpaths, p) - struct ccddevice *ccd; - char **cpaths; - struct proc *p; +ccdinit(struct ccddevice *ccd, char **cpaths, struct thread *td) { struct ccd_softc *cs = &ccd_softc[ccd->ccd_unit]; struct ccdcinfo *ci = NULL; /* XXX */ @@ -374,6 +371,10 @@ ccdinit(ccd, cpaths, p) struct ccdgeom *ccg = &cs->sc_geom; char tmppath[MAXPATHLEN]; int error = 0; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) @@ -421,7 +422,7 @@ ccdinit(ccd, cpaths, p) * Get partition information for the component. */ if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, p->p_ucred, p)) != 0) { + FREAD, cred, td)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccd%d: %s: ioctl failed, error = %d\n", @@ -1253,9 +1254,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) struct ccddevice ccd; char **cpp; struct vnode **vpp; - struct proc *p = td->td_proc; + struct ucred *cred; - KKASSERT(p != NULL); + KKASSERT(td->td_proc != NULL); + cred = td->td_proc->p_ucred; if (unit >= numccd) return (ENXIO); @@ -1329,10 +1331,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) 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); + cred, td); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); @@ -1347,10 +1349,10 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) /* * Initialize the ccd. Fills in the softc for us. */ - if ((error = ccdinit(&ccd, cpp, p)) != 0) { + if ((error = ccdinit(&ccd, cpp, td)) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - p->p_ucred, p); + cred, td); bzero(&ccd_softc[unit], sizeof(struct ccd_softc)); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); @@ -1406,7 +1408,7 @@ ccdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) cs->sc_cinfo[i].ci_vp); #endif (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE, - p->p_ucred, p); + cred, td); free(cs->sc_cinfo[i].ci_path, M_DEVBUF); } @@ -1545,16 +1547,17 @@ ccddump(dev) * set *vpp to the file's vnode. */ static int -ccdlookup(path, p, vpp) - char *path; - struct proc *p; - struct vnode **vpp; /* result */ +ccdlookup(char *path, struct thread *td, struct vnode **vpp) { struct nameidata nd; struct vnode *vp; int error; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, td); if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) { #ifdef DEBUG if (ccddebug & CCDB_FOLLOW|CCDB_INIT) @@ -1577,15 +1580,15 @@ ccdlookup(path, p, 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, cred, td); return (error); } diff --git a/sys/dev/disk/fd/fd.c b/sys/dev/disk/fd/fd.c index 9f642b372e..dee011f73d 100644 --- a/sys/dev/disk/fd/fd.c +++ b/sys/dev/disk/fd/fd.c @@ -51,7 +51,7 @@ * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 * $FreeBSD: src/sys/isa/fd.c,v 1.176.2.8 2002/05/15 21:56:14 joerg Exp $ - * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.4 2003/06/23 17:55:40 dillon Exp $ + * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.5 2003/06/25 03:55:56 dillon Exp $ * */ @@ -2325,7 +2325,6 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td) static int fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { - struct proc *p = td->td_proc; fdu_t fdu = FDUNIT(minor(dev)); fd_p fd = devclass_get_softc(fd_devclass, fdu); size_t fdblk; @@ -2396,7 +2395,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) case FD_STYPE: /* set drive type */ /* this is considered harmful; only allow for superuser */ - if (suser_xxx(p->p_ucred, 0) != 0) + if (suser(td) != 0) return EPERM; *fd->ft = *(struct fd_type *)addr; break; diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c index 56bc8be998..1c7d086950 100644 --- a/sys/dev/disk/vn/vn.c +++ b/sys/dev/disk/vn/vn.c @@ -39,7 +39,7 @@ * * from: @(#)vn.c 8.6 (Berkeley) 4/1/94 * $FreeBSD: src/sys/dev/vn/vn.c,v 1.105.2.4 2001/11/18 07:11:00 dillon Exp $ - * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ + * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.4 2003/06/25 03:55:51 dillon Exp $ */ /* @@ -64,8 +64,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -385,13 +385,13 @@ vnstrategy(struct buf *bp) else auio.uio_rw = UIO_WRITE; auio.uio_resid = bp->b_bcount; - auio.uio_procp = curproc; - vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); + auio.uio_td = curthread; + vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curthread); if (bp->b_flags & B_READ) error = VOP_READ(vn->sc_vp, &auio, IO_DIRECT, vn->sc_cred); else error = VOP_WRITE(vn->sc_vp, &auio, IO_NOWDRAIN, vn->sc_cred); - VOP_UNLOCK(vn->sc_vp, 0, curproc); + VOP_UNLOCK(vn->sc_vp, 0, curthread); bp->b_resid = auio.uio_resid; if (error) { @@ -460,7 +460,7 @@ vnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) vn_specific: - error = suser(); + error = suser(td); if (error) return (error); @@ -544,25 +544,25 @@ vniocattach_file(vn, vio, dev, flag, td) KKASSERT(p != NULL); flags = FREAD|FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_file, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_file, td); error = vn_open(&nd, flags, 0); if (error) { if (error != EACCES && error != EPERM && error != EROFS) return (error); flags &= ~FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_file, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vn_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); vn->sc_secsize = DEV_BSIZE; vn->sc_vp = nd.ni_vp; @@ -576,7 +576,7 @@ vniocattach_file(vn, vio, dev, flag, td) vn->sc_size = vattr.va_size / vn->sc_secsize; error = vnsetcred(vn, 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); } vn->sc_flags |= VNF_INITED; @@ -713,9 +713,9 @@ vnsetcred(struct vn_softc *vn, struct ucred *cred) auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; auio.uio_resid = aiov.iov_len; - vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); + vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curthread); error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred); - VOP_UNLOCK(vn->sc_vp, 0, curproc); + VOP_UNLOCK(vn->sc_vp, 0, curthread); free(tmpbuf, M_TEMP); } return (error); @@ -724,7 +724,7 @@ vnsetcred(struct vn_softc *vn, struct ucred *cred) void vnclear(struct vn_softc *vn) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ IFOPT(vn, VN_FOLLOW) printf("vnclear(%p): vp=%p\n", vn, vn->sc_vp); @@ -733,7 +733,7 @@ vnclear(struct vn_softc *vn) vn->sc_flags &= ~VNF_INITED; if (vn->sc_vp != NULL) { (void)vn_close(vn->sc_vp, vn->sc_flags & VNF_READONLY ? - FREAD : (FREAD|FWRITE), vn->sc_cred, p); + FREAD : (FREAD|FWRITE), vn->sc_cred, td); vn->sc_vp = NULL; } vn->sc_flags &= ~VNF_READONLY; diff --git a/sys/dev/disk/wcd/wd_cd.c b/sys/dev/disk/wcd/wd_cd.c index e0e0212cd9..af28f20c90 100644 --- a/sys/dev/disk/wcd/wd_cd.c +++ b/sys/dev/disk/wcd/wd_cd.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/wd_cd.c,v 1.29 2000/01/29 16:00:33 peter Exp $ - * $DragonFly: src/sys/dev/disk/wcd/Attic/wd_cd.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/disk/wcd/Attic/wd_cd.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ #include @@ -639,7 +639,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); case CDIOCRESET: - error = suser(p); + error = suser(td); if (error) return (error); return acd_request_wait(cdp, ATAPI_TEST_UNIT_READY, diff --git a/sys/dev/disk/wfd/wfd.c b/sys/dev/disk/wfd/wfd.c index a6411fe395..4faee4caec 100644 --- a/sys/dev/disk/wfd/wfd.c +++ b/sys/dev/disk/wfd/wfd.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/wfd.c,v 1.35 2000/01/29 16:00:33 peter Exp $ - * $DragonFly: src/sys/dev/disk/wfd/Attic/wfd.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/disk/wfd/Attic/wfd.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ /* @@ -631,21 +631,21 @@ int wfdioctl (dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) } switch (cmd) { case CDIOCSETDEBUG: - error = suser(p); + error = suser(td); if (error) return (error); t->flags |= F_DEBUG; atapi_debug (t->ata, 1); return 0; case CDIOCCLRDEBUG: - error = suser(p); + error = suser(td); if (error) return (error); t->flags &= ~F_DEBUG; atapi_debug (t->ata, 0); return 0; case CDIOCRESET: - error = suser(p); + error = suser(td); if (error) return (error); return wfd_request_wait (t, ATAPI_TEST_UNIT_READY, diff --git a/sys/dev/drm/drm_os_freebsd.h b/sys/dev/drm/drm_os_freebsd.h index cf5d7d5777..7a3a9e0d49 100644 --- a/sys/dev/drm/drm_os_freebsd.h +++ b/sys/dev/drm/drm_os_freebsd.h @@ -1,6 +1,6 @@ /* * $FreeBSD: src/sys/dev/drm/drm_os_freebsd.h,v 1.10.2.1 2003/04/26 07:05:28 anholt Exp $ - * $DragonFly: src/sys/dev/drm/Attic/drm_os_freebsd.h,v 1.2 2003/06/17 04:28:24 dillon Exp $ + * $DragonFly: src/sys/dev/drm/Attic/drm_os_freebsd.h,v 1.3 2003/06/25 03:55:47 dillon Exp $ */ #include #include @@ -109,7 +109,7 @@ #define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p, DRMFILE filp #define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_CURPROC) #define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_CURPROC) -#define DRM_SUSER(p) suser(p) +#define DRM_SUSER(td) suser(td) #define DRM_TASKQUEUE_ARGS void *arg, int pending #define DRM_IRQ_ARGS void *arg #define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 diff --git a/sys/dev/misc/nmdm/nmdm.c b/sys/dev/misc/nmdm/nmdm.c index a3b5e7addf..51b5e8b805 100644 --- a/sys/dev/misc/nmdm/nmdm.c +++ b/sys/dev/misc/nmdm/nmdm.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/nmdm/nmdm.c,v 1.5.2.1 2001/08/11 00:54:14 mp Exp $ - * $DragonFly: src/sys/dev/misc/nmdm/nmdm.c,v 1.3 2003/06/23 17:55:33 dillon Exp $ + * $DragonFly: src/sys/dev/misc/nmdm/nmdm.c,v 1.4 2003/06/25 03:55:47 dillon Exp $ */ /* @@ -205,7 +205,7 @@ nmdmopen(dev_t dev, int flag, int devtype, struct thread *td) 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_xxx(p->p_ucred, 0)) { + } else if (tp->t_state & TS_XCLUDE && suser(td)) { return (EBUSY); } else if (pti->pt_prison != p->p_ucred->cr_prison) { return (EBUSY); diff --git a/sys/dev/misc/snp/snp.c b/sys/dev/misc/snp/snp.c index 6f3ee7f695..45dd933bc2 100644 --- a/sys/dev/misc/snp/snp.c +++ b/sys/dev/misc/snp/snp.c @@ -13,7 +13,7 @@ * Snoop stuff. * * $FreeBSD: src/sys/dev/snp/snp.c,v 1.69.2.2 2002/05/06 07:30:02 dd Exp $ - * $DragonFly: src/sys/dev/misc/snp/snp.c,v 1.3 2003/06/23 17:55:34 dillon Exp $ + * $DragonFly: src/sys/dev/misc/snp/snp.c,v 1.4 2003/06/25 03:55:49 dillon Exp $ */ #include @@ -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; diff --git a/sys/dev/misc/spigot/spigot.c b/sys/dev/misc/spigot/spigot.c index 1db3afae73..df4514852f 100644 --- a/sys/dev/misc/spigot/spigot.c +++ b/sys/dev/misc/spigot/spigot.c @@ -43,7 +43,7 @@ * Version 1.7, December 1995. * * $FreeBSD: src/sys/i386/isa/spigot.c,v 1.44 2000/01/29 16:17:36 peter Exp $ - * $DragonFly: src/sys/dev/misc/spigot/spigot.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/misc/spigot/spigot.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ * */ @@ -171,7 +171,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); if (error != 0) return error; if (securelevel > 0) @@ -227,7 +227,7 @@ struct spigot_info *info; break; case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */ #if !defined(SPIGOT_UNSECURE) - error = suser(p); + error = suser(td); if (error != 0) return error; if (securelevel > 0) diff --git a/sys/dev/misc/streams/streams.c b/sys/dev/misc/streams/streams.c index c03e5682ef..c4c5a8183c 100644 --- a/sys/dev/misc/streams/streams.c +++ b/sys/dev/misc/streams/streams.c @@ -31,7 +31,7 @@ * in 3.0-980524-SNAP then hacked a bit (but probably not enough :-). * * $FreeBSD: src/sys/dev/streams/streams.c,v 1.16.2.1 2001/02/26 04:23:07 jlemon Exp $ - * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.3 2003/06/23 17:55:35 dillon Exp $ + * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.4 2003/06/25 03:55:49 dillon Exp $ */ #include @@ -62,12 +62,12 @@ #include #include -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 { - struct proc *p; /* Process for the socket */ + struct thread *td; /* Thread for the socket */ void *cookie; /* Internal cookie used for matching */ struct sockaddr_un sock;/* Pathname for the socket */ dev_t dev; /* Device where the socket lives on */ @@ -254,7 +254,7 @@ streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) break; case dev_ptm: - return svr4_ptm_alloc(p); + return svr4_ptm_alloc(td); default: return EOPNOTSUPP; @@ -263,7 +263,7 @@ streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) if ((error = falloc(p, &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; @@ -280,8 +280,7 @@ streamsopen(dev_t dev, int oflags, int devtype, d_thread_t *td) } static int -svr4_ptm_alloc(p) - struct proc *p; +svr4_ptm_alloc(struct thread *td) { /* * XXX this is very, very ugly. But I can't find a better @@ -305,6 +304,9 @@ svr4_ptm_alloc(p) int l = 0, n = 0; register_t fd = -1; int error; + struct proc *p = td->td_proc; + + KKASSERT(p); SCARG(&oa, path) = path; SCARG(&oa, flags) = O_RDWR; @@ -364,9 +366,7 @@ svr4_stream_get(fp) } void -svr4_delete_socket(p, fp) - struct proc *p; - struct file *fp; +svr4_delete_socket(struct thread *td, struct file *fp) { struct svr4_sockcache_entry *e; void *cookie = ((struct socket *) fp->f_data)->so_emuldata; @@ -378,24 +378,25 @@ svr4_delete_socket(p, fp) } for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next) - if (e->p == p && e->cookie == cookie) { + if (e->td == td && e->cookie == cookie) { TAILQ_REMOVE(&svr4_head, e, entries); DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n", - e->sock.sun_path, p, e->dev, e->ino)); + e->sock.sun_path, td, (int)e->dev, + (int)e->ino)); free(e, M_TEMP); return; } } 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, fp); free(so->so_emuldata, M_TEMP); - return soo_close(fp, p); + return soo_close(fp, td); return (0); } diff --git a/sys/dev/misc/syscons/syscons.c b/sys/dev/misc/syscons/syscons.c index f597925394..169ede8f1b 100644 --- a/sys/dev/misc/syscons/syscons.c +++ b/sys/dev/misc/syscons/syscons.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/syscons/syscons.c,v 1.336.2.15 2002/10/24 00:35:31 kbyanc Exp $ - * $DragonFly: src/sys/dev/misc/syscons/syscons.c,v 1.3 2003/06/23 17:55:35 dillon Exp $ + * $DragonFly: src/sys/dev/misc/syscons/syscons.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ #include "splash.h" @@ -479,7 +479,7 @@ scopen(dev_t dev, int flag, int mode, struct thread *td) (*linesw[tp->t_line].l_modem)(tp, 1); } else - if (tp->t_state & TS_XCLUDE && suser_xxx(td->td_proc->p_ucred, 0)) + if (tp->t_state & TS_XCLUDE && suser(td)) return(EBUSY); error = (*linesw[tp->t_line].l_open)(dev, tp); @@ -642,6 +642,8 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) int s; struct proc *p = td->td_proc; + KKASSERT(p); + tp = dev->si_tty; /* If there is a user_ioctl function call that first */ @@ -975,7 +977,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) return 0; case KDENABIO: /* allow io operations */ - error = suser_xxx(td->td_proc->p_ucred, 0); + error = suser(td); if (error != 0) return error; if (securelevel > 0) diff --git a/sys/dev/misc/syscons/sysmouse.c b/sys/dev/misc/syscons/sysmouse.c index f57101edb8..08f2d29b05 100644 --- a/sys/dev/misc/syscons/sysmouse.c +++ b/sys/dev/misc/syscons/sysmouse.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/syscons/sysmouse.c,v 1.2.2.2 2001/07/16 05:21:24 yokota Exp $ - * $DragonFly: src/sys/dev/misc/syscons/sysmouse.c,v 1.3 2003/06/23 17:55:35 dillon Exp $ + * $DragonFly: src/sys/dev/misc/syscons/sysmouse.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ #include "opt_syscons.h" @@ -103,7 +103,7 @@ smopen(dev_t dev, int flag, int mode, struct thread *td) 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_xxx(td->td_proc->p_ucred, 0)) { + } else if (tp->t_state & TS_XCLUDE && suser(td)) { return EBUSY; } diff --git a/sys/dev/netif/an/if_an.c b/sys/dev/netif/an/if_an.c index 3418595df0..2ebbf6599e 100644 --- a/sys/dev/netif/an/if_an.c +++ b/sys/dev/netif/an/if_an.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/an/if_an.c,v 1.2.2.13 2003/02/11 03:32:48 ambrisko Exp $ - * $DragonFly: src/sys/dev/netif/an/if_an.c,v 1.3 2003/06/23 17:55:28 dillon Exp $ + * $DragonFly: src/sys/dev/netif/an/if_an.c,v 1.4 2003/06/25 03:55:45 dillon Exp $ * * $FreeBSD: src/sys/dev/an/if_an.c,v 1.2.2.13 2003/02/11 03:32:48 ambrisko Exp $ */ @@ -1851,7 +1851,7 @@ an_ioctl(ifp, command, data) int i; struct an_softc *sc; struct ifreq *ifr; - struct proc *p = curproc; + struct thread *td = curthread; struct ieee80211req *ireq; u_int8_t tmpstr[IEEE80211_NWID_LEN*2]; u_int8_t *tmpptr; @@ -1917,7 +1917,7 @@ an_ioctl(ifp, command, data) break; #ifdef ANCACHE if (sc->areq.an_type == AN_RID_ZERO_CACHE) { - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) break; sc->an_sigitems = sc->an_nextitem = 0; @@ -1941,7 +1941,7 @@ an_ioctl(ifp, command, data) error = copyout(&sc->areq, ifr->ifr_data, sizeof(sc->areq)); break; case SIOCSAIRONET: - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq)); if (error != 0) @@ -1949,7 +1949,7 @@ an_ioctl(ifp, command, data) an_setdef(sc, &sc->areq); break; case SIOCGPRIVATE_0: /* used by Cisco client utility */ - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl)); mode = l_ioctl.command; @@ -1969,7 +1969,7 @@ an_ioctl(ifp, command, data) break; case SIOCGPRIVATE_1: /* used by Cisco client utility */ - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl)); l_ioctl.command = 0; @@ -2202,7 +2202,7 @@ an_ioctl(ifp, command, data) } break; case SIOCS80211: - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; sc->areq.an_len = sizeof(sc->areq); /* diff --git a/sys/dev/netif/awi/awi.c b/sys/dev/netif/awi/awi.c index d82e02d191..7294ac0f4d 100644 --- a/sys/dev/netif/awi/awi.c +++ b/sys/dev/netif/awi/awi.c @@ -1,6 +1,6 @@ /* $NetBSD: awi.c,v 1.26 2000/07/21 04:48:55 onoe Exp $ */ /* $FreeBSD: src/sys/dev/awi/awi.c,v 1.10.2.2 2003/01/23 21:06:42 sam Exp $ */ -/* $DragonFly: src/sys/dev/netif/awi/Attic/awi.c,v 1.3 2003/06/23 17:55:29 dillon Exp $ */ +/* $DragonFly: src/sys/dev/netif/awi/Attic/awi.c,v 1.4 2003/06/25 03:55:46 dillon Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -455,7 +455,7 @@ awi_ioctl(ifp, cmd, data) u_long cmd; caddr_t data; { - struct proc *cur = curproc; + struct thread *td = curthread; struct awi_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; @@ -521,7 +521,7 @@ awi_ioctl(ifp, cmd, data) break; case SIOCS80211NWID: #ifdef __FreeBSD__ - error = suser_xxx(cur->p_ucred, 0); + error = suser(td); /* EPERM if no proc */ if (error) break; #endif @@ -555,7 +555,7 @@ awi_ioctl(ifp, cmd, data) break; case SIOCS80211NWKEY: #ifdef __FreeBSD__ - error = suser_xxx(cur->p_ucred, 0); + error = suser(td); /* EPERM if no proc */ if (error) break; #endif diff --git a/sys/dev/netif/awi/awi_wep.c b/sys/dev/netif/awi/awi_wep.c index 773055e479..412b46c302 100644 --- a/sys/dev/netif/awi/awi_wep.c +++ b/sys/dev/netif/awi/awi_wep.c @@ -1,6 +1,6 @@ /* $NetBSD: awi_wep.c,v 1.4 2000/08/14 11:28:03 onoe Exp $ */ /* $FreeBSD: src/sys/dev/awi/awi_wep.c,v 1.3.2.2 2003/01/23 21:06:42 sam Exp $ */ -/* $DragonFly: src/sys/dev/netif/awi/Attic/awi_wep.c,v 1.3 2003/06/23 17:55:29 dillon Exp $ */ +/* $DragonFly: src/sys/dev/netif/awi/Attic/awi_wep.c,v 1.4 2003/06/25 03:55:46 dillon Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -184,7 +184,6 @@ awi_wep_getnwkey(sc, nwkey) struct awi_softc *sc; struct ieee80211_nwkey *nwkey; { - struct proc *cur = curproc; int i, len, error, suerr; u_int8_t keybuf[AWI_MAX_KEYLEN]; @@ -192,7 +191,7 @@ awi_wep_getnwkey(sc, nwkey) nwkey->i_defkid = sc->sc_wep_defkid + 1; /* do not show any keys to non-root user */ #ifdef __FreeBSD__ - suerr = suser_xxx(cur->p_ucred, 0); + suerr = suser(curthread); /* note: EPERM if no proc */ #else suerr = suser(curproc->p_ucred, &curproc->p_acflag); #endif diff --git a/sys/dev/netif/awi/awi_wicfg.c b/sys/dev/netif/awi/awi_wicfg.c index eac279d419..3e5a709898 100644 --- a/sys/dev/netif/awi/awi_wicfg.c +++ b/sys/dev/netif/awi/awi_wicfg.c @@ -1,6 +1,6 @@ /* $NetBSD: awi_wicfg.c,v 1.3 2000/07/06 17:22:25 onoe Exp $ */ /* $FreeBSD: src/sys/dev/awi/awi_wicfg.c,v 1.3.2.2 2002/06/18 08:06:15 jhay Exp $ */ -/* $DragonFly: src/sys/dev/netif/awi/Attic/awi_wicfg.c,v 1.3 2003/06/23 17:55:29 dillon Exp $ */ +/* $DragonFly: src/sys/dev/netif/awi/Attic/awi_wicfg.c,v 1.4 2003/06/25 03:55:46 dillon Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -103,7 +103,7 @@ awi_wicfg(ifp, cmd, data) caddr_t data; { int error; - struct proc *cur = curproc; + struct thread *td = curthread; switch (cmd) { case SIOCGWAVELAN: @@ -111,7 +111,7 @@ awi_wicfg(ifp, cmd, data) break; case SIOCSWAVELAN: #ifdef __FreeBSD__ - error = suser_xxx(cur->p_ucred, 0); + error = suser(td); /* note: EPERM if no proc */ #else error = suser(curproc->p_ucred, &curproc->p_acflag); #endif @@ -143,7 +143,7 @@ awi_cfgget(ifp, cmd, data) struct wi_sigcache wsc; struct awi_bss *bp; #endif /* WICACHE */ - struct proc *cur = curproc; + struct thread *td = curthread; error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); if (error) @@ -276,7 +276,7 @@ awi_cfgget(ifp, cmd, data) keys = (struct wi_ltv_keys *)&wreq; /* do not show keys to non-root user */ #ifdef __FreeBSD__ - error = suser_xxx(cur->p_ucred, 0); + error = suser(td); /* note: EPERM if no proc */ #else error = suser(curproc->p_ucred, &curproc->p_acflag); #endif diff --git a/sys/dev/netif/cx/cx.c b/sys/dev/netif/cx/cx.c index ababe59163..37958b89f8 100644 --- a/sys/dev/netif/cx/cx.c +++ b/sys/dev/netif/cx/cx.c @@ -16,7 +16,7 @@ * Version 1.9, Wed Oct 4 18:58:15 MSK 1995 * * $FreeBSD: src/sys/i386/isa/cx.c,v 1.45.2.1 2001/02/26 04:23:09 jlemon Exp $ - * $DragonFly: src/sys/dev/netif/cx/cx.c,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/dev/netif/cx/cx.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ * */ #undef DEBUG @@ -114,7 +114,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]; @@ -165,7 +165,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)) return (EBUSY); if (! (tp->t_state & TS_ISOPEN)) { ttychars (tp); @@ -250,7 +250,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]; @@ -286,7 +286,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; diff --git a/sys/dev/netif/sbni/if_sbni.c b/sys/dev/netif/sbni/if_sbni.c index 3890a9b546..ed4abcded5 100644 --- a/sys/dev/netif/sbni/if_sbni.c +++ b/sys/dev/netif/sbni/if_sbni.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sbni/if_sbni.c,v 1.1.2.4 2002/08/11 09:32:00 fjoe Exp $ - * $DragonFly: src/sys/dev/netif/sbni/if_sbni.c,v 1.3 2003/06/23 17:55:34 dillon Exp $ + * $DragonFly: src/sys/dev/netif/sbni/if_sbni.c,v 1.4 2003/06/25 03:55:48 dillon Exp $ */ /* @@ -1050,7 +1050,7 @@ timeout_change_level(struct sbni_softc *sc) static int sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct sbni_softc *sc; struct ifreq *ifr; struct sbni_in_stats *in_stats; @@ -1123,7 +1123,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data) case SIOCSHWFLAGS: /* set flags */ /* root only */ - error = suser_xxx(p->p_ucred, 0); + error = suser(td); /* NOTE: returns EPERM if no proc */ if (error) break; flags = *(struct sbni_flags*)&ifr->ifr_data; @@ -1145,7 +1145,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; case SIOCRINSTATS: - if (!(error = suser_xxx(p->p_ucred, 0))) /* root only */ + if (!(error = suser(td))) /* root only */ bzero(&sc->in_stats, sizeof(struct sbni_in_stats)); break; diff --git a/sys/dev/netif/sbsh/if_sbsh.c b/sys/dev/netif/sbsh/if_sbsh.c index 02edfe9e0c..dca68db031 100644 --- a/sys/dev/netif/sbsh/if_sbsh.c +++ b/sys/dev/netif/sbsh/if_sbsh.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sbsh/if_sbsh.c,v 1.3.2.1 2003/04/15 18:15:07 fjoe Exp $ - * $DragonFly: src/sys/dev/netif/sbsh/if_sbsh.c,v 1.3 2003/06/23 17:55:34 dillon Exp $ + * $DragonFly: src/sys/dev/netif/sbsh/if_sbsh.c,v 1.4 2003/06/25 03:55:48 dillon Exp $ */ #include @@ -404,17 +404,15 @@ sbsh_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr = (struct ifreq *) data; struct cx28975_cfg cfg; struct dsl_stats ds; - struct proc *p = curproc; + struct thread *td = curthread; int s, error = 0; u_int8_t t; - KKASSERT(p != NULL); - s = splimp(); switch(cmd) { case SIOCLOADFIRMW: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (ifp->if_flags & IFF_UP) error = EBUSY; @@ -434,7 +432,7 @@ sbsh_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCGETSTATS : - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; t = 0; @@ -468,7 +466,7 @@ sbsh_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCCLRSTATS : - if (!(error = suser_xxx(p->p_ucred, 0))) { + if (!(error = suser(td))) { bzero(&sc->in_stats, sizeof(struct sbni16_stats)); t = 2; if (issue_cx28975_cmd(sc, _DSL_CLEAR_ERROR_CTRS, &t, 1)) diff --git a/sys/dev/netif/wi/if_wi.c b/sys/dev/netif/wi/if_wi.c index bab58ece7e..1a0971490c 100644 --- a/sys/dev/netif/wi/if_wi.c +++ b/sys/dev/netif/wi/if_wi.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/wi/if_wi.c,v 1.103.2.2 2002/08/02 07:11:34 imp Exp $ - * $DragonFly: src/sys/dev/netif/wi/if_wi.c,v 1.3 2003/06/23 17:55:37 dillon Exp $ + * $DragonFly: src/sys/dev/netif/wi/if_wi.c,v 1.4 2003/06/25 03:55:51 dillon Exp $ */ /* @@ -1628,11 +1628,7 @@ wi_ioctl(ifp, command, data) struct wi_req wreq; struct ifreq *ifr; struct ieee80211req *ireq; -#if __FreeBSD_version >= 500000 struct thread *td = curthread; -#else - struct proc *p = curproc; /* Little white lie */ -#endif int s; sc = ifp->if_softc; @@ -1698,7 +1694,7 @@ wi_ioctl(ifp, command, data) break; } /* Don't show WEP keys to non-root users. */ - if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS && suser_xxx(p->p_ucred, 0)) + if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS && suser(td)) break; if (wreq.wi_type == WI_RID_IFACE_STATS) { bcopy((char *)&sc->wi_stats, (char *)&wreq.wi_val, @@ -1743,7 +1739,7 @@ wi_ioctl(ifp, command, data) error = copyout(&wreq, ifr->ifr_data, sizeof(wreq)); break; case SIOCSWAVELAN: - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); if (error) @@ -1790,7 +1786,7 @@ wi_ioctl(ifp, command, data) error = copyout(&wreq, ifr->ifr_data, sizeof(wreq)); break; case SIOCSPRISM2DEBUG: - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); if (error) @@ -1839,7 +1835,7 @@ wi_ioctl(ifp, command, data) break; } len = sc->wi_keys.wi_keys[ireq->i_val].wi_keylen; - if (suser_xxx(p->p_ucred, 0)) + if (suser(td)) bcopy(sc->wi_keys.wi_keys[ireq->i_val].wi_keydat, tmpkey, len); else @@ -1892,7 +1888,7 @@ wi_ioctl(ifp, command, data) } break; case SIOCS80211: - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) goto out; switch(ireq->i_type) { case IEEE80211_IOC_SSID: diff --git a/sys/dev/netif/wi/wi_hostap.c b/sys/dev/netif/wi/wi_hostap.c index dcee68b1fb..c78aeac064 100644 --- a/sys/dev/netif/wi/wi_hostap.c +++ b/sys/dev/netif/wi/wi_hostap.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/wi/wi_hostap.c,v 1.7.2.4 2002/08/02 07:11:34 imp Exp $ - * $DragonFly: src/sys/dev/netif/wi/Attic/wi_hostap.c,v 1.3 2003/06/23 17:55:37 dillon Exp $ + * $DragonFly: src/sys/dev/netif/wi/Attic/wi_hostap.c,v 1.4 2003/06/25 03:55:51 dillon Exp $ */ /* This is experimental Host AP software for Prism 2 802.11b interfaces. @@ -1135,18 +1135,14 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data) struct hostap_sta reqsta; struct hostap_sta stabuf; int s, error = 0, n, flag; -#if __FreeBSD_version >= 500000 struct thread *td = curthread; -#else - struct proc *proc = curproc; /* Little white lie */ -#endif if (!(sc->arpcom.ac_if.if_flags & IFF_RUNNING)) return ENODEV; switch (command) { case SIOCHOSTAP_DEL: - if ((error = suser_xxx(proc->p_ucred, 0))) + if ((error = suser(td))) break; if ((error = copyin(ifr->ifr_data, &reqsta, sizeof(reqsta)))) break; @@ -1190,7 +1186,7 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data) break; case SIOCHOSTAP_ADD: - if ((error = suser_xxx(proc->p_ucred, 0))) + if ((error = suser(td))) break; if ((error = copyin(ifr->ifr_data, &reqsta, sizeof(reqsta)))) break; @@ -1214,7 +1210,7 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data) break; case SIOCHOSTAP_SFLAGS: - if ((error = suser_xxx(proc->p_ucred, 0))) + if ((error = suser(td))) break; if ((error = copyin(ifr->ifr_data, &flag, sizeof(int)))) break; diff --git a/sys/dev/netif/wl/if_wl.c b/sys/dev/netif/wl/if_wl.c index 3e9abaaf96..581c12c3f7 100644 --- a/sys/dev/netif/wl/if_wl.c +++ b/sys/dev/netif/wl/if_wl.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/i386/isa/if_wl.c,v 1.27.2.2 2000/07/17 21:24:32 archie Exp $ */ -/* $DragonFly: src/sys/dev/netif/wl/if_wl.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ */ +/* $DragonFly: src/sys/dev/netif/wl/if_wl.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1139,10 +1139,10 @@ 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 */ int irq, irqval, i, isroot, size; caddr_t up; char * cpt; + struct thread *td = curthread; /* XXX */ #ifdef WLDEBUG @@ -1246,7 +1246,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) == 0); for (i = 0; i < 0x40; i++) { /* don't hand the DES key out to non-root users */ @@ -1261,7 +1261,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))) break; error = EINVAL; /* assume the worst */ /* pointer to buffer in user space containing data */ @@ -1315,7 +1315,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ case SIOCSWLCNWID: /* root only */ - if ((error = suser(p))) + if ((error = suser(td))) break; if (!(ifp->if_flags & IFF_UP)) { error = EIO; /* only allowed while up */ @@ -1333,7 +1333,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))) break; /* pointer to buffer in user space */ up = (void *)ifr->ifr_data; @@ -1356,7 +1356,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))) break; wl_cache_zero(unit); break; diff --git a/sys/dev/raid/aac/aac_linux.c b/sys/dev/raid/aac/aac_linux.c index 94db4f21b1..10e2a350c6 100644 --- a/sys/dev/raid/aac/aac_linux.c +++ b/sys/dev/raid/aac/aac_linux.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/aac/aac_linux.c,v 1.1.4.1 2003/03/28 19:50:17 scottl Exp $ - * $DragonFly: src/sys/dev/raid/aac/aac_linux.c,v 1.2 2003/06/17 04:28:21 dillon Exp $ + * $DragonFly: src/sys/dev/raid/aac/aac_linux.c,v 1.3 2003/06/25 03:55:45 dillon Exp $ */ #include @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -65,17 +66,20 @@ DEV_MODULE(aac_linux, aac_linux_modevent, NULL); 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 proc *p = td->td_proc; struct file *fp; u_long cmd; + KKASSERT(p); + fp = p->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)); } diff --git a/sys/dev/raid/asr/asr.c b/sys/dev/raid/asr/asr.c index f26e224011..a4d14b0e9a 100644 --- a/sys/dev/raid/asr/asr.c +++ b/sys/dev/raid/asr/asr.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/asr/asr.c,v 1.3.2.2 2001/08/23 05:21:29 scottl Exp $ */ -/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.4 2003/06/23 18:11:59 dillon Exp $ */ +/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.5 2003/06/25 03:55:46 dillon Exp $ */ /* * Copyright (c) 1996-2000 Distributed Processing Technology Corporation * Copyright (c) 2000-2001 Adaptec Corporation @@ -3882,10 +3882,11 @@ asr_open( if (ASR_get_sc (dev) == (Asr_softc_t *)NULL) { return (ENODEV); } + KKASSERT(td->td_proc); s = splcam (); if (ASR_ctlr_held) { error = EBUSY; - } else if ((error = suser_xxx(td->td_proc->p_ucred, 0)) == 0) { + } else if ((error = suser_cred(td->td_proc->p_ucred, 0)) == 0) { ++ASR_ctlr_held; } splx(s); diff --git a/sys/dev/raid/vinum/vinum.c b/sys/dev/raid/vinum/vinum.c index b738856aeb..5dc2eb0dc7 100644 --- a/sys/dev/raid/vinum/vinum.c +++ b/sys/dev/raid/vinum/vinum.c @@ -37,7 +37,7 @@ * * $Id: vinum.c,v 1.33 2001/01/09 06:19:15 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinum.c,v 1.38.2.3 2003/01/07 12:14:16 joerg Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinum.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinum.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ #define STATIC static /* nothing while we're testing XXX */ @@ -301,9 +301,6 @@ vinumopen(dev_t dev, int flags, int fmt, d_thread_t *td) struct plex *plex; struct sd *sd; int devminor; /* minor number */ - struct proc *p = td->td_proc; - - KKASSERT(p != NULL); devminor = minor(dev); error = 0; @@ -381,7 +378,7 @@ vinumopen(dev_t dev, int flags, int fmt, d_thread_t *td) } case VINUM_SUPERDEV_TYPE: - error = suser_xxx(p->p_ucred, 0); /* are we root? */ + error = suser(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 */ diff --git a/sys/dev/raid/vinum/vinumparser.c b/sys/dev/raid/vinum/vinumparser.c index bc2402cd29..5cc380aa72 100644 --- a/sys/dev/raid/vinum/vinumparser.c +++ b/sys/dev/raid/vinum/vinumparser.c @@ -35,7 +35,7 @@ * * $Id: vinumparser.c,v 1.21 2000/12/20 03:44:13 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumparser.c,v 1.20.2.5 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumparser.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumparser.c,v 1.3 2003/06/25 03:55:50 dillon Exp $ */ /* @@ -66,6 +66,7 @@ #include /* All this mess for a single struct definition */ #include +#include #include #include #include diff --git a/sys/dev/serial/cy/cy.c b/sys/dev/serial/cy/cy.c index 0bed4d19ff..b0ebe42730 100644 --- a/sys/dev/serial/cy/cy.c +++ b/sys/dev/serial/cy/cy.c @@ -28,7 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/cy.c,v 1.97.2.2 2001/08/22 13:04:58 bde Exp $ - * $DragonFly: src/sys/dev/serial/cy/cy.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/serial/cy/cy.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ #include "opt_compat.h" @@ -652,11 +652,7 @@ cyattach_common(cy_iobase, cy_align) } static int -sioopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +sioopen(dev_t dev; int flag; int mode; struct thread *td) { struct com_s *com; int error; @@ -712,7 +708,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser(td)) { error = EBUSY; goto out; } @@ -837,11 +833,7 @@ out: } static int -sioclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +sioclose(dev_t dev, int flag, int mode, struct thread *td) { struct com_s *com; int mynor; @@ -1568,12 +1560,7 @@ siointr1(com) #endif static int -sioioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +sioioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct com_s *com; int error; @@ -1602,7 +1589,7 @@ sioioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1701,7 +1688,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); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/serial/dgb/dgm.c b/sys/dev/serial/dgb/dgm.c index 2060bc85a1..616771a50b 100644 --- a/sys/dev/serial/dgb/dgm.c +++ b/sys/dev/serial/dgb/dgm.c @@ -1,6 +1,6 @@ /*- * $FreeBSD: src/sys/dev/dgb/dgm.c,v 1.31.2.3 2001/10/07 09:02:25 brian Exp $ - * $DragonFly: src/sys/dev/serial/dgb/dgm.c,v 1.2 2003/06/17 04:28:23 dillon Exp $ + * $DragonFly: src/sys/dev/serial/dgb/dgm.c,v 1.3 2003/06/25 03:55:47 dillon Exp $ * * This driver and the associated header files support the ISA PC/Xem * Digiboards. Its evolutionary roots are described below. @@ -920,7 +920,7 @@ dgmshutdown(device_t dev) /* ARGSUSED */ static int -dgmopen(dev_t dev, int flag, int mode, struct proc *p) +dgmopen(dev_t dev, int flag, int mode, struct thread *td) { struct dgm_softc *sc; struct tty *tp; @@ -1008,7 +1008,7 @@ open_top: splx(s); goto open_top; } - if (tp->t_state & TS_XCLUDE && suser(p)) { + if (tp->t_state & TS_XCLUDE && suser(td)) { error = EBUSY; goto out; } @@ -1102,7 +1102,7 @@ out: /*ARGSUSED*/ static int -dgmclose(dev_t dev, int flag, int mode, struct proc *p) +dgmclose(dev_t dev, int flag, int mode, struct thread *td) { int mynor; struct tty *tp; @@ -1476,7 +1476,7 @@ dgmpoll(void *unit_c) } static int -dgmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +dgmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct dgm_softc *sc; int unit, pnum; @@ -1519,7 +1519,7 @@ dgmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1741,7 +1741,7 @@ dgmioctl(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); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/serial/rc/rc.c b/sys/dev/serial/rc/rc.c index 9527a4fd4f..565d46257f 100644 --- a/sys/dev/serial/rc/rc.c +++ b/sys/dev/serial/rc/rc.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/rc.c,v 1.53.2.1 2001/02/26 04:23:10 jlemon Exp $ - * $DragonFly: src/sys/dev/serial/rc/rc.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/serial/rc/rc.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ * */ @@ -761,7 +761,7 @@ again: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser(td)) { error = EBUSY; goto out; } @@ -1115,7 +1115,7 @@ struct proc *p; break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/serial/rp/rp.c b/sys/dev/serial/rp/rp.c index 18681ec611..bf85046f1b 100644 --- a/sys/dev/serial/rp/rp.c +++ b/sys/dev/serial/rp/rp.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/rp/rp.c,v 1.45.2.2 2002/11/07 22:26:59 tegge Exp $ - * $DragonFly: src/sys/dev/serial/rp/rp.c,v 1.3 2003/06/23 17:55:33 dillon Exp $ + * $DragonFly: src/sys/dev/serial/rp/rp.c,v 1.4 2003/06/25 03:55:48 dillon Exp $ */ /* @@ -963,9 +963,6 @@ rpopen(dev_t dev, int flag, int mode, d_thread_t *td) struct tty *tp; int oldspl, error; unsigned int IntMask, ChanStatus; - struct proc *p = td->td_proc; - - KKASSERT(p != NULL); umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ port = (minor(dev) & 0x1f); /* SG */ @@ -1009,7 +1006,7 @@ open_top: goto open_top; } } - if(tp->t_state & TS_XCLUDE && suser_xxx(p->p_ucred, 0) != 0) { + if(tp->t_state & TS_XCLUDE && suser(td) != 0) { splx(oldspl); error = EBUSY; goto out2; @@ -1236,9 +1233,6 @@ rpioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) int error = 0; int arg, flags, result, ChanStatus; struct termios *t; - struct proc *p = td->td_proc; - - KKASSERT(p != NULL); umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ port = (minor(dev) & 0x1f); /* SG */ @@ -1261,7 +1255,7 @@ rpioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) } switch (cmd) { case TIOCSETA: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if(error != 0) return(error); *ct = *(struct termios *)data; @@ -1406,7 +1400,7 @@ rpioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) *(int *)data = result; break; case TIOCMSDTRWAIT: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if(error != 0) { splx(oldspl); return(error); diff --git a/sys/dev/serial/rp2/rp.c b/sys/dev/serial/rp2/rp.c index 17ff0a9bc4..c95e538b2a 100644 --- a/sys/dev/serial/rp2/rp.c +++ b/sys/dev/serial/rp2/rp.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/rp.c,v 1.33.2.2 2001/02/26 04:23:10 jlemon Exp $ - * $DragonFly: src/sys/dev/serial/rp2/Attic/rp.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/serial/rp2/Attic/rp.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ /* @@ -1333,7 +1333,7 @@ open_top: } } if(tp->t_state & TS_XCLUDE && - suser(p)) { + suser(td)) { splx(oldspl); return(EBUSY); } @@ -1582,7 +1582,7 @@ rpioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser(td); if(error != 0) return(error); *ct = *(struct termios *)data; @@ -1727,7 +1727,7 @@ rpioctl(dev, cmd, data, flag, p) *(int *)data = result; break; case TIOCMSDTRWAIT: - error = suser(p); + error = suser(td); if(error != 0) { splx(oldspl); return(error); diff --git a/sys/dev/serial/si/si.c b/sys/dev/serial/si/si.c index 9001397e65..628bbb438f 100644 --- a/sys/dev/serial/si/si.c +++ b/sys/dev/serial/si/si.c @@ -31,7 +31,7 @@ * NO EVENT SHALL THE AUTHORS BE LIABLE. * * $FreeBSD: src/sys/dev/si/si.c,v 1.101.2.1 2001/02/26 04:23:06 jlemon Exp $ - * $DragonFly: src/sys/dev/serial/si/si.c,v 1.2 2003/06/17 04:28:29 dillon Exp $ + * $DragonFly: src/sys/dev/serial/si/si.c,v 1.3 2003/06/25 03:55:49 dillon Exp $ */ #ifndef lint @@ -96,7 +96,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; @@ -613,7 +613,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; @@ -625,7 +625,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))) return(error); return(0); } @@ -668,7 +668,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; @@ -704,7 +704,7 @@ open_top: } } if (tp->t_state & TS_XCLUDE && - suser(p)) { + suser(td)) { DPRINT((pp, DBG_OPEN|DBG_FAIL, "already open and EXCLUSIVE set\n")); error = EBUSY; @@ -782,7 +782,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; @@ -933,7 +933,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; @@ -969,7 +969,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); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1082,7 +1082,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); if (error == 0) pp->sp_dtr_wait = *(int *)data * hz / 100; break; @@ -1105,7 +1105,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; @@ -1135,7 +1135,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))) goto out switch (cmd) { case TCSIPORTS: diff --git a/sys/dev/serial/sio/sio.c b/sys/dev/serial/sio/sio.c index ad9dc8b8a2..b1cc8b9466 100644 --- a/sys/dev/serial/sio/sio.c +++ b/sys/dev/serial/sio/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/isa/sio.c,v 1.291.2.35 2003/05/18 08:51:15 murray Exp $ - * $DragonFly: src/sys/dev/serial/sio/sio.c,v 1.3 2003/06/23 17:55:40 dillon Exp $ + * $DragonFly: src/sys/dev/serial/sio/sio.c,v 1.4 2003/06/25 03:55:56 dillon Exp $ * from: @(#)com.c 7.5 (Berkeley) 5/16/91 * from: i386/isa sio.c,v 1.234 */ @@ -1519,8 +1519,7 @@ open_top: goto open_top; } } - if (tp->t_state & TS_XCLUDE && - suser_xxx(td->td_proc->p_ucred, 0)) { + if (tp->t_state & TS_XCLUDE && suser(td)) { error = EBUSY; goto out; } @@ -2225,7 +2224,7 @@ sioioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) } switch (cmd) { case TIOCSETA: - error = suser_xxx(td->td_proc->p_ucred, 0); + error = suser(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -2316,7 +2315,7 @@ sioioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) break; case TIOCMSDTRWAIT: /* must be root since the wait applies to following logins */ - error = suser_xxx(td->td_proc->p_ucred, 0); + error = suser(td); if (error != 0) { splx(s); return (error); diff --git a/sys/dev/serial/stl/stallion.c b/sys/dev/serial/stl/stallion.c index 51db5b8db9..77113a4e1f 100644 --- a/sys/dev/serial/stl/stallion.c +++ b/sys/dev/serial/stl/stallion.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/stallion.c,v 1.39.2.2 2001/08/30 12:29:57 murray Exp $ - * $DragonFly: src/sys/dev/serial/stl/stallion.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/serial/stl/stallion.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ /*****************************************************************************/ @@ -1231,7 +1231,7 @@ stlopen_restart: goto stlopen_restart; } } - if ((tp->t_state & TS_XCLUDE) && suser(p)) { + if ((tp->t_state & TS_XCLUDE) && suser(td)) { error = EBUSY; goto stlopen_end; } @@ -1371,7 +1371,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)) == 0) *localtios = *((struct termios *) data); break; case TIOCGETA: @@ -1489,7 +1489,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)) == 0) portp->dtrwait = *((int *) data) * hz / 100; break; case TIOCMGDTRWAIT: diff --git a/sys/dev/serial/stli/istallion.c b/sys/dev/serial/stli/istallion.c index 5219089acd..6886123ea7 100644 --- a/sys/dev/serial/stli/istallion.c +++ b/sys/dev/serial/stli/istallion.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/istallion.c,v 1.36.2.2 2001/08/30 12:29:57 murray Exp $ - * $DragonFly: src/sys/dev/serial/stli/istallion.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/dev/serial/stli/istallion.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ */ /*****************************************************************************/ @@ -1014,7 +1014,7 @@ stliopen_restart: } } if ((tp->t_state & TS_XCLUDE) && - suser(p)) { + suser(td)) { error = EBUSY; goto stliopen_end; } @@ -1200,7 +1200,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)) == 0) *localtios = *((struct termios *) data); break; case TIOCGETA: @@ -1336,7 +1336,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)) == 0) portp->dtrwait = *((int *) data) * hz / 100; break; case TIOCMGDTRWAIT: diff --git a/sys/dev/usbmisc/ucom/ucom.c b/sys/dev/usbmisc/ucom/ucom.c index a130d5c449..d3f689547f 100644 --- a/sys/dev/usbmisc/ucom/ucom.c +++ b/sys/dev/usbmisc/ucom/ucom.c @@ -1,6 +1,6 @@ /* $NetBSD: ucom.c,v 1.39 2001/08/16 22:31:24 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ucom.c,v 1.24.2.2 2003/01/17 17:32:10 joe Exp $ */ -/* $DragonFly: src/sys/dev/usbmisc/ucom/ucom.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ */ +/* $DragonFly: src/sys/dev/usbmisc/ucom/ucom.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ /*- * Copyright (c) 2001-2002, Shunsuke Akiyama . @@ -267,7 +267,6 @@ ucomopen(dev_t dev, int flag, int mode, usb_proc_ptr td) struct tty *tp; int s; int error; - struct proc *p = td->td_proc; KKASSERT(p != NULL); @@ -282,8 +281,10 @@ ucomopen(dev_t dev, int flag, int mode, usb_proc_ptr td) if (ISSET(tp->t_state, TS_ISOPEN) && ISSET(tp->t_state, TS_XCLUDE) && - suser_xxx(p->p_ucred, 0)) + suser(td) + ) { return (EBUSY); + } /* * Do the following iff this is a first open. diff --git a/sys/dev/usbmisc/ugen/ugen.c b/sys/dev/usbmisc/ugen/ugen.c index 207f2f5b11..a7c9f0b7bc 100644 --- a/sys/dev/usbmisc/ugen/ugen.c +++ b/sys/dev/usbmisc/ugen/ugen.c @@ -1,6 +1,6 @@ /* $NetBSD: ugen.c,v 1.27 1999/10/28 12:08:38 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.38.2.9 2002/11/06 14:41:01 joe Exp $ */ -/* $DragonFly: src/sys/dev/usbmisc/ugen/ugen.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ */ +/* $DragonFly: src/sys/dev/usbmisc/ugen/ugen.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1213,7 +1213,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->td_proc; + uio.uio_td = p; #if defined(__NetBSD__) || defined(__OpenBSD__) error = uiomove((caddr_t)cdesc, len, &uio); #elif defined(__FreeBSD__) @@ -1263,7 +1263,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, uio.uio_rw = ur->ucr_request.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p->td_proc; + uio.uio_td = p; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); diff --git a/sys/dev/usbmisc/urio/urio.c b/sys/dev/usbmisc/urio/urio.c index f09dd5343b..450b4f4df6 100644 --- a/sys/dev/usbmisc/urio/urio.c +++ b/sys/dev/usbmisc/urio/urio.c @@ -29,7 +29,7 @@ */ /* $FreeBSD: src/sys/dev/usb/urio.c,v 1.11.2.4 2002/11/06 14:41:01 joe Exp $ */ -/* $DragonFly: src/sys/dev/usbmisc/urio/urio.c,v 1.3 2003/06/23 17:55:36 dillon Exp $ */ +/* $DragonFly: src/sys/dev/usbmisc/urio/urio.c,v 1.4 2003/06/25 03:55:50 dillon Exp $ */ /* * 2000/3/24 added NetBSD/OpenBSD support (from Alex Nemirovsky) @@ -572,7 +572,7 @@ urioioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, usb_proc_ptr p) uio.uio_rw = req.bmRequestType & UT_READ ? UIO_READ : UIO_WRITE; - uio.uio_procp = p->td_proc; + uio.uio_td = p; ptr = malloc(len, M_TEMP, M_WAITOK); if (uio.uio_rw == UIO_WRITE) { error = uiomove(ptr, len, &uio); diff --git a/sys/dev/video/pcvt/i386/pcvt_drv.c b/sys/dev/video/pcvt/i386/pcvt_drv.c index 28c05b4a92..770a369e39 100644 --- a/sys/dev/video/pcvt/i386/pcvt_drv.c +++ b/sys/dev/video/pcvt/i386/pcvt_drv.c @@ -51,7 +51,7 @@ * Last Edit-Date: [Mon Dec 27 14:03:36 1999] * * $FreeBSD: src/sys/i386/isa/pcvt/pcvt_drv.c,v 1.63.2.1 2001/02/26 04:23:13 jlemon Exp $ - * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_drv.c,v 1.2 2003/06/17 04:28:38 dillon Exp $ + * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_drv.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ * *---------------------------------------------------------------------------*/ @@ -472,7 +472,7 @@ pcopen(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)) return (EBUSY); #if PCVT_NETBSD || (PCVT_FREEBSD >= 200) @@ -1425,7 +1425,7 @@ pcvt_xmode_set(int on, struct proc *p) * This prevents us from granting the potential security hole * `IO priv' to insufficiently privileged processes. */ - error = suser(p); + error = suser(td); if (error != 0) return (error); if (securelevel > 0) diff --git a/sys/dev/video/pcvt/i386/pcvt_ext.c b/sys/dev/video/pcvt/i386/pcvt_ext.c index 0ed5d65446..b64fb06d12 100644 --- a/sys/dev/video/pcvt/i386/pcvt_ext.c +++ b/sys/dev/video/pcvt/i386/pcvt_ext.c @@ -45,7 +45,7 @@ * Last Edit-Date: [Mon Dec 27 14:05:16 1999] * * $FreeBSD: src/sys/i386/isa/pcvt/pcvt_ext.c,v 1.17 1999/12/30 16:17:09 hm Exp $ - * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_ext.c,v 1.2 2003/06/17 04:28:38 dillon Exp $ + * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_ext.c,v 1.3 2003/06/25 03:55:54 dillon Exp $ * *---------------------------------------------------------------------------*/ @@ -2667,7 +2667,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) struct syscframe *fp = (struct syscframe *)p->p_regs; #endif - error = suser(p); + error = suser(td); if (error != 0) return (error); if (securelevel > 0) diff --git a/sys/emulation/ibcs2/coff/imgact_coff.c b/sys/emulation/ibcs2/coff/imgact_coff.c index 85fe8c119a..b9403e57ae 100644 --- a/sys/emulation/ibcs2/coff/imgact_coff.c +++ b/sys/emulation/ibcs2/coff/imgact_coff.c @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/ibcs2/imgact_coff.c,v 1.40 1999/12/15 23:01:47 eivind Exp $ - * $DragonFly: src/sys/emulation/ibcs2/coff/Attic/imgact_coff.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/coff/Attic/imgact_coff.c,v 1.3 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -53,7 +54,7 @@ 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)); @@ -149,9 +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 vmspace *vmspace = p->p_vmspace; + struct vmspace *vmspace; int error; struct nameidata nd; struct vnode *vp; @@ -164,10 +165,15 @@ coff_load_file(struct proc *p, char *name) unsigned long text_offset = 0, text_address = 0, text_size = 0; unsigned long data_offset = 0, data_address = 0, data_size = 0; unsigned long bss_size = 0; + struct ucred *cred; int i; - /* XXX use of 'curproc' should be 'p'?*/ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, curproc); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + vmspace = td->td_proc->p_vmspace; + + /* XXX use of 'curthread' should be 'td'?*/ + NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, curthread); error = namei(&nd); if (error) @@ -182,7 +188,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, cred, td)) != 0) goto fail; if ((vp->v_mount->mnt_flag & MNT_NOEXEC) @@ -195,17 +201,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, cred, td)) != 0) goto fail; - if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) + if ((error = VOP_OPEN(vp, FREAD, cred, 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 +284,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,10 +399,11 @@ 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); + error = coff_load_file(imgp->proc->p_thread, libbuf); if (error) - error = coff_load_file(imgp->proc, - libname); + error = coff_load_file( + imgp->proc->p_thread, + libname); if (error) break; } diff --git a/sys/emulation/ibcs2/i386/ibcs2_fcntl.c b/sys/emulation/ibcs2/i386/ibcs2_fcntl.c index 688b1c350d..111e0c9129 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_fcntl.c +++ b/sys/emulation/ibcs2/i386/ibcs2_fcntl.c @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/ibcs2/ibcs2_fcntl.c,v 1.14 1999/09/19 17:00:14 green Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_fcntl.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_fcntl.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ #include "opt_spx_hack.h" @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -170,7 +172,8 @@ oflags2ioflags(flags) int ibcs2_open(struct ibcs2_open_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p; int noctty = SCARG(uap, flags) & IBCS2_O_NOCTTY; int ret; caddr_t sg = stackgap_init(); @@ -188,13 +191,14 @@ ibcs2_open(struct ibcs2_open_args *uap) ret = spx_open(uap); } else #endif /* SPX_HACK */ - if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { + p = td->td_proc; + if (!ret && !noctty && p && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; struct file *fp = fdp->fd_ofiles[p->p_retval[0]]; /* 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); } return ret; } diff --git a/sys/emulation/ibcs2/i386/ibcs2_ioctl.c b/sys/emulation/ibcs2/i386/ibcs2_ioctl.c index e06e8b47a1..bebc0dc98d 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_ioctl.c +++ b/sys/emulation/ibcs2/i386/ibcs2_ioctl.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/ibcs2/ibcs2_ioctl.c,v 1.13.2.1 2001/07/31 20:14:21 jon Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_ioctl.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_ioctl.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -35,9 +35,11 @@ #include #include #include +#include #include #include #include +#include #include @@ -337,20 +339,23 @@ stio2stios(t, ts) int ibcs2_ioctl(struct ibcs2_ioctl_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; int error; + KKASSERT(p); + fdp = p->p_fd; + if (SCARG(uap, fd) < 0 || SCARG(uap, fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) { - DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid, - SCARG(uap, fd))); + DPRINTF(("ibcs2_ioctl(td=%p): bad fd %d ", td, SCARG(uap, fd))); return EBADF; } if ((fp->f_flag & (FREAD|FWRITE)) == 0) { - DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid)); + DPRINTF(("ibcs2_ioctl(td=%p): bad fp flag ", td)); return EBADF; } @@ -363,7 +368,7 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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); @@ -399,7 +404,7 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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; @@ -414,7 +419,7 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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: @@ -430,7 +435,7 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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: @@ -446,11 +451,11 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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: - DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid)); + DPRINTF(("ibcs2_ioctl(td=%p): TCSBRK ", td)); return ENOSYS; case IBCS2_TCXONC: @@ -458,12 +463,12 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *uap) switch ((int)SCARG(uap, data)) { case 0: case 1: - DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid)); + DPRINTF(("ibcs2_ioctl(td=%p): TCXONC ", td)); 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; } @@ -486,7 +491,7 @@ ibcs2_ioctl(struct ibcs2_ioctl_args *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: diff --git a/sys/emulation/ibcs2/i386/ibcs2_misc.c b/sys/emulation/ibcs2/i386/ibcs2_misc.c index 25f8b34958..c37e4ab2bb 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_misc.c +++ b/sys/emulation/ibcs2/i386/ibcs2_misc.c @@ -46,7 +46,7 @@ * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93 * * $FreeBSD: src/sys/i386/ibcs2/ibcs2_misc.c,v 1.34 1999/09/29 15:12:09 marcel Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_misc.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_misc.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -286,7 +286,8 @@ ibcs2_mount(struct ibcs2_mount_args *uap) int ibcs2_getdents(struct ibcs2_getdents_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -303,6 +304,8 @@ ibcs2_getdents(struct ibcs2_getdents_args *uap) #define BSD_DIRENT(cp) ((struct dirent *)(cp)) #define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short)) + KKASSERT(p); + if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) @@ -316,7 +319,7 @@ ibcs2_getdents(struct ibcs2_getdents_args *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; @@ -324,7 +327,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; @@ -418,7 +421,7 @@ eof: out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } @@ -426,7 +429,8 @@ out: int ibcs2_read(struct ibcs2_read_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ @@ -444,6 +448,8 @@ ibcs2_read(struct ibcs2_read_args *uap) u_long *cookies = NULL, *cookiep; int ncookies; + KKASSERT(p); + if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) { if (error == EINVAL) return read((struct read_args *)uap); @@ -462,7 +468,7 @@ ibcs2_read(struct ibcs2_read_args *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; @@ -470,7 +476,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; @@ -568,7 +574,7 @@ eof: out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } @@ -959,7 +965,7 @@ ibcs2_plock(struct ibcs2_plock_args *uap) #define IBCS2_DATALOCK 4 - if ((error = suser()) != 0) + if ((error = suser(curthread)) != 0) return EPERM; switch(SCARG(uap, cmd)) { case IBCS2_UNLOCK: @@ -992,7 +998,7 @@ ibcs2_uadmin(struct ibcs2_uadmin_args *uap) #define SCO_AD_GETBMAJ 0 #define SCO_AD_GETCMAJ 1 - if (suser()) + if (suser(curthread)) return EPERM; switch(SCARG(uap, cmd)) { diff --git a/sys/emulation/ibcs2/i386/ibcs2_socksys.c b/sys/emulation/ibcs2/i386/ibcs2_socksys.c index 9048c90c1a..2e599dc926 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_socksys.c +++ b/sys/emulation/ibcs2/i386/ibcs2_socksys.c @@ -161,7 +161,7 @@ ibcs2_setipdomainname(struct setipdomainname_args *uap) char hname[MAXHOSTNAMELEN], *ptr; int error, sctl[2], hlen; - if ((error = suser())) + if ((error = suser(curthread))) return (error); /* W/out a hostname a domain-name is nonsense */ diff --git a/sys/emulation/ibcs2/i386/ibcs2_stat.c b/sys/emulation/ibcs2/i386/ibcs2_stat.c index e4596f3f8a..e42723ef5a 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_stat.c +++ b/sys/emulation/ibcs2/i386/ibcs2_stat.c @@ -26,13 +26,14 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/ibcs2/ibcs2_stat.c,v 1.10 1999/12/15 23:01:45 eivind Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_stat.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_stat.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ #include #include -#include #include +#include +#include #include #include #include @@ -99,7 +100,7 @@ cvt_statfs(sp, buf, len) int ibcs2_statfs(struct ibcs2_statfs_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct mount *mp; struct statfs *sp; int error; @@ -107,14 +108,14 @@ ibcs2_statfs(struct ibcs2_statfs_args *uap) caddr_t sg = stackgap_init(); CHECKALTEXIST(&sg, SCARG(uap, path)); - 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); 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)); @@ -123,17 +124,18 @@ ibcs2_statfs(struct ibcs2_statfs_args *uap) int ibcs2_fstatfs(struct ibcs2_fstatfs_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct file *fp; struct mount *mp; register struct statfs *sp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + KKASSERT(td->td_proc); + 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)); diff --git a/sys/emulation/ibcs2/i386/ibcs2_sysi86.c b/sys/emulation/ibcs2/i386/ibcs2_sysi86.c index 198cc4d74b..3f2e26d0c5 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_sysi86.c +++ b/sys/emulation/ibcs2/i386/ibcs2_sysi86.c @@ -53,7 +53,8 @@ extern int hw_float; int ibcs2_sysi86(struct ibcs2_sysi86_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; switch (SCARG(args, cmd)) { case SI86_FPHW: { /* Floating Point information */ @@ -75,7 +76,7 @@ ibcs2_sysi86(struct ibcs2_sysi86_args *args) int name[2]; int error; - if ((error = suser())) + if ((error = suser(td))) return (error); name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; diff --git a/sys/emulation/ibcs2/i386/ibcs2_util.c b/sys/emulation/ibcs2/i386/ibcs2_util.c index 50260a5134..8a6fcbb044 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_util.c +++ b/sys/emulation/ibcs2/i386/ibcs2_util.c @@ -28,11 +28,12 @@ * * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp * $FreeBSD: src/sys/i386/ibcs2/ibcs2_util.c,v 1.7 1999/12/15 23:01:45 eivind Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_util.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_util.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ #include #include +#include #include #include #include @@ -59,7 +60,8 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag) char **pbuf; int cflag; { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct ucred *cred; struct nameidata nd; struct nameidata ndroot; struct vattr vat; @@ -68,6 +70,9 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag) char *ptr, *buf, *cp; size_t sz, len; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK); *pbuf = path; @@ -106,7 +111,7 @@ ibcs2_emul_find(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); @@ -116,7 +121,7 @@ ibcs2_emul_find(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); @@ -131,8 +136,8 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag) * root directory and never finding it, because "/" resolves * to the emulation root directory. This is expensive :-( */ - NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, ibcs2_emul_path, - p); + NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, + ibcs2_emul_path, td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -142,11 +147,11 @@ ibcs2_emul_find(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, cred, td)) != 0) { goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, cred, td)) != 0) { goto done; } diff --git a/sys/emulation/ibcs2/i386/ibcs2_xenix.c b/sys/emulation/ibcs2/i386/ibcs2_xenix.c index 4bb8383b8e..bf09e25f3e 100644 --- a/sys/emulation/ibcs2/i386/ibcs2_xenix.c +++ b/sys/emulation/ibcs2/i386/ibcs2_xenix.c @@ -28,11 +28,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/ibcs2/ibcs2_xenix.c,v 1.20 1999/12/15 23:01:46 eivind Exp $ - * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_xenix.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_xenix.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ #include #include +#include #include #include #include @@ -193,6 +194,7 @@ xenix_scoinfo(struct xenix_scoinfo_args *uap) int xenix_eaccess(struct xenix_eaccess_args *uap) { + struct thread *td = curthread; /* XXX */ struct proc *p = curproc; struct ucred *cred = p->p_ucred; struct vnode *vp; @@ -203,7 +205,7 @@ xenix_eaccess(struct xenix_eaccess_args *uap) CHECKALTEXIST(&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; @@ -218,7 +220,7 @@ xenix_eaccess(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/emulation/linux/i386/linprocfs/linprocfs.h b/sys/emulation/linux/i386/linprocfs/linprocfs.h index 078c8100ec..61a147a420 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs.h +++ b/sys/emulation/linux/i386/linprocfs/linprocfs.h @@ -39,7 +39,7 @@ * @(#)procfs.h 8.9 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs.h,v 1.2.2.4 2001/06/25 19:46:47 pirzyk Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs.h,v 1.2 2003/06/17 04:28:39 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs.h,v 1.3 2003/06/25 03:55:55 dillon Exp $ */ /* @@ -72,7 +72,7 @@ struct pfsnode { u_short pfs_mode; /* mode bits for stat() */ u_long pfs_flags; /* open flags */ u_long pfs_fileno; /* unique file id */ - pid_t pfs_lockowner; /* pfs lock owner */ + struct thread *pfs_lockowner; /* pfs lock owner */ }; #define PROCFS_NAMELEN 8 /* max length of a filename component */ @@ -114,7 +114,7 @@ struct dbreg; #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) -void linprocfs_exit __P((struct proc *)); +void linprocfs_exit __P((struct thread *)); int linprocfs_freevp __P((struct vnode *)); int linprocfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); int linprocfs_sstep __P((struct proc *)); diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c b/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c index bd4a82f7ad..e0a2a9a1a7 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c +++ b/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c @@ -39,7 +39,7 @@ * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_subr.c,v 1.3.2.4 2001/06/25 19:46:47 pirzyk Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c,v 1.2 2003/06/17 04:28:39 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c,v 1.3 2003/06/25 03:55:55 dillon Exp $ */ #include @@ -87,7 +87,7 @@ linprocfs_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; @@ -99,7 +99,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); @@ -137,7 +137,7 @@ loop: pfs->pfs_type = pfs_type; pfs->pfs_vnode = vp; pfs->pfs_flags = 0; - pfs->pfs_lockowner = 0; + pfs->pfs_lockowner = NULL; pfs->pfs_fileno = PROCFS_FILENO(pid, pfs_type); switch (pfs_type) { @@ -237,11 +237,15 @@ linprocfs_rw(ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct proc *curp = uio->uio_procp; + struct thread *td = uio->uio_td; struct pfsnode *pfs = VTOPFS(vp); struct proc *p; + struct proc *curp; int rtval; + curp = td->td_proc; + KKASSERT(curp); + p = PFIND(pfs->pfs_pid); if (p == 0) return (EINVAL); @@ -251,7 +255,7 @@ linprocfs_rw(ap) while (pfs->pfs_lockowner) { tsleep(&pfs->pfs_lockowner, PRIBIO, "pfslck", 0); } - pfs->pfs_lockowner = curproc->p_pid; + pfs->pfs_lockowner = curthread; switch (pfs->pfs_type) { case Pmem: @@ -285,7 +289,7 @@ linprocfs_rw(ap) rtval = EOPNOTSUPP; break; } - pfs->pfs_lockowner = 0; + pfs->pfs_lockowner = NULL; wakeup(&pfs->pfs_lockowner); return rtval; } @@ -354,10 +358,10 @@ vfs_findname(nm, buf, buflen) #endif void -linprocfs_exit(struct proc *p) +linprocfs_exit(struct thread *td) { struct pfsnode *pfs; - pid_t pid = p->p_pid; + pid_t pid = (td->td_proc) ? td->td_proc->p_pid : -1; /* YYY */ /* * The reason for this loop is not obvious -- basicly, diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c b/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c index d4e126e12e..3edf894b28 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c +++ b/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c @@ -39,7 +39,7 @@ * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95 * * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_vfsops.c,v 1.2.2.3 2001/10/15 20:42:01 des Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c,v 1.2 2003/06/17 04:28:39 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c,v 1.3 2003/06/25 03:55:55 dillon Exp $ */ /* @@ -56,11 +56,11 @@ #include static int linprocfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); + struct nameidata *ndp, struct thread *td)); static int linprocfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); static int linprocfs_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); /* * VFS Operations. @@ -69,12 +69,12 @@ static int linprocfs_unmount __P((struct mount *mp, int mntflags, */ /* ARGSUSED */ static int -linprocfs_mount(mp, path, data, ndp, p) +linprocfs_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; @@ -97,7 +97,7 @@ linprocfs_mount(mp, path, data, ndp, p) size = sizeof("linprocfs") - 1; bcopy("linprocfs", mp->mnt_stat.f_mntfromname, size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)linprocfs_statfs(mp, &mp->mnt_stat, p); + (void)linprocfs_statfs(mp, &mp->mnt_stat, td); return (0); } @@ -106,10 +106,10 @@ linprocfs_mount(mp, path, data, ndp, p) * unmount system call */ static int -linprocfs_unmount(mp, mntflags, p) +linprocfs_unmount(mp, mntflags, td) struct mount *mp; int mntflags; - struct proc *p; + struct thread *td; { int error; int flags = 0; @@ -140,10 +140,10 @@ linprocfs_root(mp, vpp) * Get file system statistics. */ static int -linprocfs_statfs(mp, sbp, p) +linprocfs_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/emulation/linux/i386/linprocfs/linprocfs_vnops.c b/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c index 4cb9ecb975..129025af3d 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c +++ b/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c @@ -39,7 +39,7 @@ * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_vnops.c,v 1.3.2.5 2001/08/12 14:29:19 rwatson Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c,v 1.3 2003/06/23 17:55:40 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c,v 1.4 2003/06/25 03:55:55 dillon Exp $ */ /* @@ -124,7 +124,7 @@ linprocfs_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); @@ -170,7 +170,7 @@ linprocfs_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); @@ -213,13 +213,14 @@ linprocfs_ioctl(ap) struct vop_ioctl_args *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct proc *procp, *p; + struct proc *procp; + struct thread *td; int error; int signo; struct procfs_status *psp; unsigned char flags; - p = ap->a_p; + td = ap->a_td; procp = pfind(pfs->pfs_pid); if (procp == NULL) { return ENOTTY; @@ -242,7 +243,7 @@ linprocfs_ioctl(ap) */ #define NFLAGS (PF_ISUGID) flags = (unsigned char)*(unsigned int*)ap->a_data; - if (flags & NFLAGS && (error = suser_xxx(ap->a_cred, 0))) + if (flags & NFLAGS && (error = suser_cred(ap->a_cred, 0))) return error; procp->p_pfsflags = flags; break; @@ -337,7 +338,7 @@ linprocfs_inactive(ap) { struct vnode *vp = ap->a_vp; - VOP_UNLOCK(vp, 0, ap->a_p); + VOP_UNLOCK(vp, 0, ap->a_td); return (0); } @@ -402,7 +403,7 @@ linprocfs_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); @@ -548,7 +549,7 @@ linprocfs_setattr(ap) struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -586,7 +587,7 @@ linprocfs_access(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vattr *vap; @@ -601,7 +602,7 @@ linprocfs_access(ap) return (0); vap = &vattr; - error = VOP_GETATTR(ap->a_vp, vap, ap->a_cred, ap->a_p); + error = VOP_GETATTR(ap->a_vp, vap, ap->a_cred, ap->a_td); if (error) return (error); diff --git a/sys/emulation/linux/i386/linux.h b/sys/emulation/linux/i386/linux.h index a96c1c3841..c584c567e6 100644 --- a/sys/emulation/linux/i386/linux.h +++ b/sys/emulation/linux/i386/linux.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/linux/linux.h,v 1.41.2.4 2003/01/06 09:19:43 fjoe Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux.h,v 1.2 2003/06/17 04:28:38 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux.h,v 1.3 2003/06/25 03:55:55 dillon Exp $ */ #ifndef _I386_LINUX_LINUX_H_ @@ -455,9 +455,9 @@ extern struct sysentvec elf_linux_sysvec; */ struct linker_set; 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/emulation/linux/i386/linux_machdep.c b/sys/emulation/linux/i386/linux_machdep.c index 822cff902f..e250679d6a 100644 --- a/sys/emulation/linux/i386/linux_machdep.c +++ b/sys/emulation/linux/i386/linux_machdep.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.6.2.4 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_machdep.c,v 1.3 2003/06/23 17:55:39 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux_machdep.c,v 1.4 2003/06/25 03:55:55 dillon Exp $ */ #include @@ -555,12 +555,15 @@ linux_ioperm(struct linux_ioperm_args *args) int linux_iopl(struct linux_iopl_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; + KKASSERT(p); + if (args->level < 0 || args->level > 3) return (EINVAL); - if ((error = suser()) != 0) + if ((error = suser(td)) != 0) return (error); if (securelevel > 0) return (EPERM); diff --git a/sys/emulation/linux/i386/linux_sysvec.c b/sys/emulation/linux/i386/linux_sysvec.c index 39ce9a9082..bd151f1a52 100644 --- a/sys/emulation/linux/i386/linux_sysvec.c +++ b/sys/emulation/linux/i386/linux_sysvec.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/linux/linux_sysvec.c,v 1.55.2.9 2002/01/12 11:03:30 bde Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_sysvec.c,v 1.3 2003/06/23 17:55:39 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux_sysvec.c,v 1.4 2003/06/25 03:55:55 dillon Exp $ */ /* XXX we use functions that might not exist. */ @@ -753,7 +753,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/emulation/linux/linux_file.c b/sys/emulation/linux/linux_file.c index 2f29d7db17..96c2135911 100644 --- a/sys/emulation/linux/linux_file.c +++ b/sys/emulation/linux/linux_file.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.41.2.6 2003/01/06 09:19:43 fjoe Exp $ - * $DragonFly: src/sys/emulation/linux/linux_file.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_file.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include "opt_compat.h" @@ -49,6 +49,8 @@ #include #include +#include + #include #include #include @@ -88,7 +90,10 @@ linux_open(struct linux_open_args *args) } */ bsd_open_args; int error; caddr_t sg; - struct proc *p; + struct thread *td = curthread; + struct proc *p = td->td_proc; + + KKASSERT(p); sg = stackgap_init(); @@ -131,14 +136,13 @@ linux_open(struct linux_open_args *args) bsd_open_args.mode = args->mode; error = open(&bsd_open_args); - p = curproc; 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]]; if (fp->f_type == DTYPE_VNODE) - fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); + fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); } #ifdef DEBUG if (ldebug(open)) @@ -247,7 +251,8 @@ struct l_dirent64 { static int getdents_common(struct linux_getdents64_args *args, int is64bit) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ @@ -265,6 +270,8 @@ getdents_common(struct linux_getdents64_args *args, int is64bit) u_long *cookies = NULL, *cookiep; int ncookies; + KKASSERT(p); + if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) return (error); @@ -275,7 +282,7 @@ getdents_common(struct linux_getdents64_args *args, int is64bit) if (vp->v_type != VDIR) return (EINVAL); - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, td))) return (error); nbytes = args->count; @@ -293,7 +300,7 @@ getdents_common(struct linux_getdents64_args *args, int is64bit) 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; @@ -302,7 +309,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; @@ -432,7 +439,7 @@ out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return (error); } diff --git a/sys/emulation/linux/linux_getcwd.c b/sys/emulation/linux/linux_getcwd.c index eb96346f59..9e5da04b15 100644 --- a/sys/emulation/linux/linux_getcwd.c +++ b/sys/emulation/linux/linux_getcwd.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/compat/linux/linux_getcwd.c,v 1.2.2.3 2001/11/05 19:08:22 marcel Exp $ */ -/* $DragonFly: src/sys/emulation/linux/linux_getcwd.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ */ +/* $DragonFly: src/sys/emulation/linux/linux_getcwd.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ /* $OpenBSD: linux_getcwd.c,v 1.2 2001/05/16 12:50:21 ho Exp $ */ /* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */ @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -62,10 +62,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) @@ -105,13 +105,14 @@ 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; { + struct proc *p = td->td_proc; int error = 0; int eofflag; off_t off; @@ -128,12 +129,14 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p) int len, reclen; tries = 0; + KKASSERT(p); + /* * If we want the filename, get some info we need while the * current directory is still locked. */ if (bufp != NULL) { - error = VOP_GETATTR(lvp, &va, p->p_ucred, p); + error = VOP_GETATTR(lvp, &va, p->p_ucred, td); if (error) { vput(lvp); *lvpp = NULL; @@ -148,7 +151,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p) */ cn.cn_nameiop = LOOKUP; cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY; - cn.cn_proc = p; + cn.cn_td = td; cn.cn_cred = p->p_ucred; cn.cn_pnbuf = NULL; cn.cn_nameptr = ".."; @@ -197,7 +200,7 @@ 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; @@ -275,21 +278,25 @@ 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 proc *p = td->td_proc; + struct filedesc *fdp; struct vnode *uvp = NULL; char *bp = NULL; int error; int perms = VEXEC; + KKASSERT(p); + fdp = p->p_fd; + if (rvp == NULL) { rvp = fdp->fd_rdir; if (rvp == NULL) @@ -306,7 +313,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; @@ -336,7 +343,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, p->p_ucred, td); if (error) goto out; perms = VEXEC|VREAD; @@ -362,14 +369,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 @@ -408,11 +415,14 @@ out: int linux_getcwd(struct linux_getcwd_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct __getcwd_args bsd; caddr_t sg, bp, bend, path; int error, len, lenused; + KKASSERT(p); + #ifdef DEBUG printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid, args->buf, args->bufsize); @@ -451,7 +461,7 @@ linux_getcwd(struct linux_getcwd_args *args) */ error = linux_getcwd_common (p->p_fd->fd_cdir, NULL, - &bp, path, len/2, GETCWD_CHECK_ACCESS, p); + &bp, path, len/2, GETCWD_CHECK_ACCESS, td); if (error) goto out; diff --git a/sys/emulation/linux/linux_ioctl.c b/sys/emulation/linux/linux_ioctl.c index 82e6b41711..3daea27c5c 100644 --- a/sys/emulation/linux/linux_ioctl.c +++ b/sys/emulation/linux/linux_ioctl.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_ioctl.c,v 1.55.2.11 2003/05/01 20:16:09 anholt Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ioctl.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_ioctl.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -99,7 +100,7 @@ DATA_SET(linux_ioctl_handler_set, drm_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; }; @@ -107,15 +108,19 @@ 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 proc *p = td->td_proc; + struct file *fp; int error; struct disklabel dl; + KKASSERT(p); + fp = p->p_fd->fd_ofiles[args->fd]; + switch (args->cmd & 0xffff) { case LINUX_BLKGETSIZE: - error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); + error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p->p_thread); if (error) return (error); return (copyout(&(dl.d_secperunit), (caddr_t)args->arg, @@ -547,18 +552,20 @@ 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; int error; - switch (args->cmd & 0xffff) { + KKASSERT(td->td_proc); + fp = td->td_proc->p_fd->fd_ofiles[args->fd]; + 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); @@ -569,24 +576,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); @@ -597,21 +604,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 */ @@ -627,7 +634,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; @@ -767,13 +774,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) { @@ -896,13 +903,15 @@ 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; int error; - switch (args->cmd & 0xffff) { + KKASSERT(td->td_proc); + fp = td->td_proc->p_fd->fd_ofiles[args->fd]; + switch (args->cmd & 0xffff) { case LINUX_CDROMPAUSE: args->cmd = CDIOCPAUSE; return (ioctl((struct ioctl_args *)args)); @@ -922,7 +931,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_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; @@ -937,7 +946,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; @@ -975,7 +984,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, @@ -1030,7 +1039,7 @@ 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) { @@ -1104,7 +1113,7 @@ linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) return (ioctl((struct ioctl_args *)args)); case LINUX_OSS_GETVERSION: { - int version = linux_get_oss_version(p); + int version = linux_get_oss_version(td); return (copyout(&version, (caddr_t)args->arg, sizeof(int))); } @@ -1264,9 +1273,12 @@ 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; + + KKASSERT(td->td_proc); + fp = td->td_proc->p_fd->fd_ofiles[args->fd]; switch (args->cmd & 0xffff) { @@ -1313,7 +1325,7 @@ 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: @@ -1442,6 +1454,7 @@ linux_ifconf(struct proc *p, struct ifconf *uifc) struct iovec iov; struct uio uio; int error, ethno; + struct thread *td = p->p_thread; error = copyin(uifc, &ifc, sizeof ifc); if (error != 0) @@ -1456,7 +1469,7 @@ linux_ifconf(struct proc *p, struct ifconf *uifc) uio.uio_resid = ifc.ifc_len; uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = UIO_READ; - uio.uio_procp = p; + uio.uio_td = td; /* Keep track of eth interfaces */ ethno = 0; @@ -1556,13 +1569,15 @@ linux_gifhwaddr(struct ifnet *ifp, struct l_ifreq *ifr) */ static int -linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args) { + struct proc *p = td->td_proc; char lifname[LINUX_IFNAMSIZ], ifname[IFNAMSIZ]; struct ifnet *ifp; struct file *fp; int error, type; + KKASSERT(p); KASSERT(LINUX_IFNAMSIZ == IFNAMSIZ, (__FUNCTION__ "(): LINUX_IFNAMSIZ != IFNAMSIZ")); @@ -1580,7 +1595,7 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) case LINUX_SIOCGIFADDR: case LINUX_SIOCSIFADDR: case LINUX_SIOCGIFFLAGS: - return (linux_ioctl_special(p, args)); + return (linux_ioctl_special(td, args)); default: return (ENOIOCTL); } @@ -1776,13 +1791,14 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) * Device private ioctl handler */ static int -linux_ioctl_private(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_private(struct thread *td, struct linux_ioctl_args *args) { struct filedesc *fdp; struct file *fp; int type; - fdp = p->p_fd; + KKASSERT(td->td_proc); + fdp = td->td_proc->p_fd; if (args->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[args->fd]) == NULL) { return (EBADF); @@ -1790,7 +1806,7 @@ linux_ioctl_private(struct proc *p, struct linux_ioctl_args *args) type = fp->f_type; } if (type == DTYPE_SOCKET) - return (linux_ioctl_socket(p, args)); + return (linux_ioctl_socket(td, args)); return (ENOIOCTL); } @@ -1798,7 +1814,7 @@ linux_ioctl_private(struct proc *p, struct linux_ioctl_args *args) * DRM ioctl handler (sys/dev/drm) */ static int -linux_ioctl_drm(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_drm(struct thread *td, struct linux_ioctl_args *args) { args->cmd = SETDIR(args->cmd); return ioctl((struct ioctl_args *)args); @@ -1808,7 +1824,7 @@ linux_ioctl_drm(struct proc *p, struct linux_ioctl_args *args) * Special ioctl handler */ static int -linux_ioctl_special(struct proc *p, struct linux_ioctl_args *args) +linux_ioctl_special(struct thread *td, struct linux_ioctl_args *args) { int error; @@ -1839,12 +1855,15 @@ linux_ioctl_special(struct proc *p, struct linux_ioctl_args *args) int linux_ioctl(struct linux_ioctl_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp; struct file *fp; struct handler_element *he; int error, cmd; + KKASSERT(p); + #ifdef DEBUG if (ldebug(ioctl)) printf(ARGS(ioctl, "%d, %04lx, *"), args->fd, args->cmd); @@ -1861,7 +1880,7 @@ linux_ioctl(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/emulation/linux/linux_ioctl.h b/sys/emulation/linux/linux_ioctl.h index 5d41692242..fabeae41c0 100644 --- a/sys/emulation/linux/linux_ioctl.h +++ b/sys/emulation/linux/linux_ioctl.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_ioctl.h,v 1.4.2.4 2003/05/01 20:16:09 anholt Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ioctl.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_ioctl.h,v 1.3 2003/06/25 03:55:44 dillon Exp $ */ #ifndef _LINUX_IOCTL_H_ @@ -632,6 +632,7 @@ * This doesn't really belong here, but I can't think of a better * place to put it. */ +struct ifnet; int linux_ifname(struct ifnet *, char *, size_t); #endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/emulation/linux/linux_mib.c b/sys/emulation/linux/linux_mib.c index 95c80ea991..8aab7bce34 100644 --- a/sys/emulation/linux/linux_mib.c +++ b/sys/emulation/linux/linux_mib.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_mib.c,v 1.7.2.2 2001/11/05 19:08:22 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_mib.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_mib.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include @@ -57,11 +57,11 @@ linux_sysctl_osname(SYSCTL_HANDLER_ARGS) char osname[LINUX_MAX_UTSNAME]; int error; - strcpy(osname, linux_get_osname(req->p)); + strcpy(osname, linux_get_osname(req->td)); error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req); if (error || req->newptr == NULL) return (error); - error = linux_set_osname(req->p, osname); + error = linux_set_osname(req->td, osname); return (error); } @@ -78,11 +78,11 @@ linux_sysctl_osrelease(SYSCTL_HANDLER_ARGS) char osrelease[LINUX_MAX_UTSNAME]; int error; - strcpy(osrelease, linux_get_osrelease(req->p)); + strcpy(osrelease, linux_get_osrelease(req->td)); error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req); if (error || req->newptr == NULL) return (error); - error = linux_set_osrelease(req->p, osrelease); + error = linux_set_osrelease(req->td, osrelease); return (error); } @@ -99,11 +99,11 @@ linux_sysctl_oss_version(SYSCTL_HANDLER_ARGS) int oss_version; int error; - oss_version = linux_get_oss_version(req->p); + oss_version = linux_get_oss_version(req->td); error = sysctl_handle_int(oidp, &oss_version, 0, req); if (error || req->newptr == NULL) return (error); - error = linux_set_oss_version(req->p, oss_version); + error = linux_set_oss_version(req->td, oss_version); return (error); } @@ -113,12 +113,13 @@ SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version, "Linux OSS version"); static struct linux_prison * -get_prison(struct proc *p) +get_prison(struct thread *td) { struct prison *pr; struct linux_prison *lpr; - pr = p->p_ucred->cr_prison; + KKASSERT(td->td_proc); + pr = td->td_proc->p_ucred->cr_prison; if (pr == NULL) return (NULL); @@ -132,13 +133,13 @@ get_prison(struct proc *p) } char * -linux_get_osname(p) - struct proc *p; +linux_get_osname(struct thread *td) { register struct prison *pr; register struct linux_prison *lpr; - pr = p->p_ucred->cr_prison; + KKASSERT(td->td_proc); + pr = td->td_proc->p_ucred->cr_prison; if (pr != NULL && pr->pr_linux != NULL) { lpr = pr->pr_linux; if (lpr->pr_osname[0]) @@ -149,13 +150,12 @@ linux_get_osname(p) } int -linux_set_osname(p, osname) - struct proc *p; - char *osname; +linux_set_osname(struct thread *td, char *osname) { register struct linux_prison *lpr; - lpr = get_prison(p); + KKASSERT(td->td_proc); + lpr = get_prison(td); if (lpr != NULL) strcpy(lpr->pr_osname, osname); else @@ -165,13 +165,13 @@ linux_set_osname(p, osname) } char * -linux_get_osrelease(p) - struct proc *p; +linux_get_osrelease(struct thread *td) { register struct prison *pr; register struct linux_prison *lpr; - pr = p->p_ucred->cr_prison; + KKASSERT(td->td_proc); + pr = td->td_proc->p_ucred->cr_prison; if (pr != NULL && pr->pr_linux != NULL) { lpr = pr->pr_linux; if (lpr->pr_osrelease[0]) @@ -182,13 +182,11 @@ linux_get_osrelease(p) } int -linux_set_osrelease(p, osrelease) - struct proc *p; - char *osrelease; +linux_set_osrelease(struct thread *td, char *osrelease) { register struct linux_prison *lpr; - lpr = get_prison(p); + lpr = get_prison(td); if (lpr != NULL) strcpy(lpr->pr_osrelease, osrelease); else @@ -198,13 +196,13 @@ linux_set_osrelease(p, osrelease) } int -linux_get_oss_version(p) - struct proc *p; +linux_get_oss_version(struct thread *td) { register struct prison *pr; register struct linux_prison *lpr; - pr = p->p_ucred->cr_prison; + KKASSERT(td->td_proc); + pr = td->td_proc->p_ucred->cr_prison; if (pr != NULL && pr->pr_linux != NULL) { lpr = pr->pr_linux; if (lpr->pr_oss_version) @@ -215,13 +213,11 @@ linux_get_oss_version(p) } int -linux_set_oss_version(p, oss_version) - struct proc *p; - int oss_version; +linux_set_oss_version(struct thread *td, int oss_version) { register struct linux_prison *lpr; - lpr = get_prison(p); + lpr = get_prison(td); if (lpr != NULL) lpr->pr_oss_version = oss_version; else diff --git a/sys/emulation/linux/linux_mib.h b/sys/emulation/linux/linux_mib.h index 54be0210e1..94d4ca2288 100644 --- a/sys/emulation/linux/linux_mib.h +++ b/sys/emulation/linux/linux_mib.h @@ -26,19 +26,19 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_mib.h,v 1.3.2.1 2000/10/30 10:51:37 obrien Exp $ - * $DragonFly: src/sys/emulation/linux/linux_mib.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_mib.h,v 1.3 2003/06/25 03:55:44 dillon Exp $ */ #ifndef _LINUX_MIB_H_ #define _LINUX_MIB_H_ -char* linux_get_osname __P((struct proc *p)); -int linux_set_osname __P((struct proc *p, char *osname)); +char* linux_get_osname __P((struct thread *td)); +int linux_set_osname __P((struct thread *td, char *osname)); -char* linux_get_osrelease __P((struct proc *p)); -int linux_set_osrelease __P((struct proc *p, char *osrelease)); +char* linux_get_osrelease __P((struct thread *td)); +int linux_set_osrelease __P((struct thread *td, char *osrelease)); -int linux_get_oss_version __P((struct proc *p)); -int linux_set_oss_version __P((struct proc *p, int oss_version)); +int linux_get_oss_version __P((struct thread *td)); +int linux_set_oss_version __P((struct thread *td, int oss_version)); #endif /* _LINUX_MIB_H_ */ diff --git a/sys/emulation/linux/linux_misc.c b/sys/emulation/linux/linux_misc.c index 06ba00701b..7ff1f5479b 100644 --- a/sys/emulation/linux/linux_misc.c +++ b/sys/emulation/linux/linux_misc.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.85.2.9 2002/09/24 08:11:41 mdodd Exp $ - * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include "opt_compat.h" @@ -39,9 +39,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -166,11 +166,14 @@ linux_sysinfo(struct linux_sysinfo_args *args) int linux_alarm(struct linux_alarm_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct itimerval it, old_it; struct timeval tv; int s; + KKASSERT(p); + #ifdef DEBUG if (ldebug(alarm)) printf(ARGS(alarm, "%u"), args->secs); @@ -208,13 +211,16 @@ linux_alarm(struct linux_alarm_args *args) int linux_brk(struct linux_brk_args *args) { - struct proc *p = curproc; - struct vmspace *vm = p->p_vmspace; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct vmspace *vm; vm_offset_t new, old; struct obreak_args /* { char * nsize; } */ tmp; + KKASSERT(p); + vm = p->p_vmspace; #ifdef DEBUG if (ldebug(brk)) printf(ARGS(brk, "%p"), (void *)args->dsend); @@ -233,7 +239,8 @@ linux_brk(struct linux_brk_args *args) int linux_uselib(struct linux_uselib_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p; struct nameidata ni; struct vnode *vp; struct exec *a_out; @@ -246,6 +253,9 @@ linux_uselib(struct linux_uselib_args *args) caddr_t sg; int locked; + KKASSERT(td->td_proc); + p = td->td_proc; + sg = stackgap_init(); CHECKALTEXIST(&sg, args->library); @@ -258,7 +268,7 @@ linux_uselib(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; @@ -286,7 +296,7 @@ linux_uselib(struct linux_uselib_args *args) } /* Executable? */ - error = VOP_GETATTR(vp, &attr, p->p_ucred, p); + error = VOP_GETATTR(vp, &attr, p->p_ucred, td); if (error) goto cleanup; @@ -303,18 +313,18 @@ linux_uselib(struct linux_uselib_args *args) } /* Can we access it? */ - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, p->p_ucred, td); if (error) goto cleanup; - error = VOP_OPEN(vp, FREAD, p->p_ucred, p); + error = VOP_OPEN(vp, FREAD, p->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 */ @@ -452,7 +462,7 @@ linux_uselib(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) @@ -465,12 +475,15 @@ cleanup: int linux_select(struct linux_select_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct select_args bsa; struct timeval tv0, tv1, utv, *tvp; caddr_t sg; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(select)) printf(ARGS(select, "%d, %p, %p, %p, %p"), args->nfds, @@ -572,12 +585,15 @@ select_out: int linux_mremap(struct linux_mremap_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct munmap_args /* { void *addr; size_t len; } */ bsd_args; int error = 0; + struct proc *p = td->td_proc; + + KKASSERT(p); #ifdef DEBUG if (ldebug(mremap)) @@ -625,11 +641,14 @@ linux_msync(struct linux_msync_args *args) int linux_time(struct linux_time_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct timeval tv; l_time_t tm; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(time)) printf(ARGS(time, "*")); @@ -662,12 +681,14 @@ struct l_times_argv { int linux_times(struct linux_times_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct timeval tv; struct l_times_argv tms; struct rusage ru; int error; + KKASSERT(p); #ifdef DEBUG if (ldebug(times)) printf(ARGS(times, "*")); @@ -692,7 +713,7 @@ linux_times(struct linux_times_args *args) int linux_newuname(struct linux_newuname_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct l_new_utsname utsname; char *osrelease, *osname; @@ -701,8 +722,8 @@ linux_newuname(struct linux_newuname_args *args) printf(ARGS(newuname, "*")); #endif - osname = linux_get_osname(p); - osrelease = linux_get_osrelease(p); + osname = linux_get_osname(td); + osrelease = linux_get_osrelease(td); bzero(&utsname, sizeof(utsname)); strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1); @@ -815,7 +836,8 @@ linux_waitpid(struct linux_waitpid_args *args) int linux_wait4(struct linux_wait4_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct wait_args /* { int pid; int *status; @@ -824,6 +846,8 @@ linux_wait4(struct linux_wait4_args *args) } */ tmp; int error, tmpstat; + KKASSERT(p); + #ifdef DEBUG if (ldebug(wait4)) printf(ARGS(wait4, "%d, %p, %d, %p"), @@ -896,7 +920,10 @@ linux_mknod(struct linux_mknod_args *args) int linux_personality(struct linux_personality_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; + + KKASSERT(p); #ifdef DEBUG if (ldebug(personality)) printf(ARGS(personality, "%d"), args->per); @@ -973,12 +1000,15 @@ linux_nice(struct linux_nice_args *args) int linux_setgroups(struct linux_setgroups_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct ucred *newcred, *oldcred; l_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int ngrp, error; + KKASSERT(p); + ngrp = args->gidsetsize; oldcred = p->p_ucred; @@ -988,7 +1018,7 @@ linux_setgroups(struct linux_setgroups_args *args) * Keep cr_groups[0] unchanged to prevent that. */ - if ((error = suser_xxx(oldcred, PRISON_ROOT)) != 0) + if ((error = suser_cred(oldcred, PRISON_ROOT)) != 0) return (error); if (ngrp >= NGROUPS) @@ -1022,12 +1052,15 @@ linux_setgroups(struct linux_setgroups_args *args) int linux_getgroups(struct linux_getgroups_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct ucred *cred; l_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int bsd_gidsetsz, ngrp, error; + KKASSERT(p); + cred = p->p_ucred; bsd_gidset = cred->cr_groups; bsd_gidsetsz = cred->cr_ngroups - 1; @@ -1192,10 +1225,13 @@ linux_sched_setscheduler(struct linux_sched_setscheduler_args *args) int linux_sched_getscheduler(struct linux_sched_getscheduler_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct sched_getscheduler_args bsd; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(sched_getscheduler)) printf(ARGS(sched_getscheduler, "%d"), args->pid); @@ -1307,7 +1343,10 @@ linux_reboot(struct linux_reboot_args *args) int linux_getpid(struct linux_getpid_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; + + KKASSERT(p); p->p_retval[0] = p->p_pid; return (0); @@ -1316,7 +1355,10 @@ linux_getpid(struct linux_getpid_args *args) int linux_getgid(struct linux_getgid_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; + + KKASSERT(p); p->p_retval[0] = p->p_ucred->cr_rgid; return (0); @@ -1325,7 +1367,10 @@ linux_getgid(struct linux_getgid_args *args) int linux_getuid(struct linux_getuid_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; + + KKASSERT(p); p->p_retval[0] = p->p_ucred->cr_ruid; return (0); diff --git a/sys/emulation/linux/linux_socket.c b/sys/emulation/linux/linux_socket.c index e54a8c0c9d..70f812c759 100644 --- a/sys/emulation/linux/linux_socket.c +++ b/sys/emulation/linux/linux_socket.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.19.2.8 2001/11/07 20:33:55 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_socket.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_socket.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ /* XXX we use functions that might not exist. */ @@ -412,7 +412,8 @@ int linux_connect(struct linux_connect_args *); int linux_connect(struct linux_connect_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct linux_connect_args linux_args; struct connect_args /* { int s; @@ -423,6 +424,8 @@ linux_connect(struct linux_connect_args *args) struct file *fp; int error; + KKASSERT(p); + #ifdef __alpha__ bcopy(args, &linux_args, sizeof(linux_args)); #else @@ -453,7 +456,7 @@ linux_connect(struct linux_connect_args *args) error = so->so_error; so->so_emuldata = (void *)1; } - fdrop(fp, p); + fdrop(fp, td); return (error); } diff --git a/sys/emulation/linux/linux_stats.c b/sys/emulation/linux/linux_stats.c index 4af4f0459e..8199b07031 100644 --- a/sys/emulation/linux/linux_stats.c +++ b/sys/emulation/linux/linux_stats.c @@ -26,10 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.22.2.3 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_stats.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_stats.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include @@ -90,7 +92,7 @@ newstat_copyout(struct stat *buf, void *ubuf) int linux_newstat(struct linux_newstat_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat buf; struct nameidata nd; int error; @@ -105,13 +107,13 @@ linux_newstat(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); @@ -122,7 +124,7 @@ linux_newstat(struct linux_newstat_args *args) int linux_newlstat(struct linux_newlstat_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; int error; struct stat sb; struct nameidata nd; @@ -137,13 +139,13 @@ linux_newlstat(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); @@ -154,12 +156,15 @@ linux_newlstat(struct linux_newlstat_args *args) int linux_newfstat(struct linux_newfstat_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp; struct file *fp; struct stat buf; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(newfstat)) printf(ARGS(newfstat, "%d, *"), args->fd); @@ -170,7 +175,7 @@ linux_newfstat(struct linux_newfstat_args *args) (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); @@ -229,7 +234,7 @@ bsd_to_linux_ftype(const char *fstypename) int linux_statfs(struct linux_statfs_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct mount *mp; struct nameidata *ndp; struct statfs *bsd_statfs; @@ -246,7 +251,7 @@ linux_statfs(struct linux_statfs_args *args) 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, td); error = namei(ndp); if (error) return error; @@ -254,7 +259,7 @@ linux_statfs(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; @@ -275,13 +280,16 @@ linux_statfs(struct linux_statfs_args *args) int linux_fstatfs(struct linux_fstatfs_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct mount *mp; struct statfs *bsd_statfs; struct l_statfs linux_statfs; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(fstatfs)) printf(ARGS(fstatfs, "%d, *"), args->fd); @@ -291,7 +299,7 @@ linux_fstatfs(struct linux_fstatfs_args *args) 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; @@ -320,7 +328,7 @@ struct l_ustat int linux_ustat(struct linux_ustat_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct l_ustat lu; dev_t dev; struct vnode *vp; @@ -350,7 +358,7 @@ linux_ustat(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); @@ -397,7 +405,7 @@ stat64_copyout(struct stat *buf, void *ubuf) int linux_stat64(struct linux_stat64_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat buf; struct nameidata nd; int error; @@ -412,13 +420,13 @@ linux_stat64(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); @@ -429,7 +437,7 @@ linux_stat64(struct linux_stat64_args *args) int linux_lstat64(struct linux_lstat64_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; int error; struct stat sb; struct nameidata nd; @@ -444,13 +452,13 @@ linux_lstat64(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); @@ -461,12 +469,15 @@ linux_lstat64(struct linux_lstat64_args *args) int linux_fstat64(struct linux_fstat64_args *args) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp; struct file *fp; struct stat buf; int error; + KKASSERT(p); + #ifdef DEBUG if (ldebug(fstat64)) printf(ARGS(fstat64, "%d, *"), args->fd); @@ -477,7 +488,7 @@ linux_fstat64(struct linux_fstat64_args *args) (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/emulation/linux/linux_uid16.c b/sys/emulation/linux/linux_uid16.c index d1e24cbfc4..6147b6b248 100644 --- a/sys/emulation/linux/linux_uid16.c +++ b/sys/emulation/linux/linux_uid16.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_uid16.c,v 1.4.2.1 2001/10/21 03:57:35 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_uid16.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_uid16.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include "opt_compat.h" @@ -110,7 +110,7 @@ linux_setgroups16(struct linux_setgroups16_args *args) * Keep cr_groups[0] unchanged to prevent that. */ - if ((error = suser_xxx(oldcred, PRISON_ROOT)) != 0) + if ((error = suser_cred(oldcred, PRISON_ROOT)) != 0) return (error); if (ngrp >= NGROUPS) diff --git a/sys/emulation/linux/linux_util.c b/sys/emulation/linux/linux_util.c index 41be4a895e..0af8a889bc 100644 --- a/sys/emulation/linux/linux_util.c +++ b/sys/emulation/linux/linux_util.c @@ -28,13 +28,13 @@ * * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp * $FreeBSD: src/sys/compat/linux/linux_util.c,v 1.12.2.2 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_util.c,v 1.3 2003/06/23 17:55:27 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_util.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ #include #include -#include #include +#include #include #include @@ -51,13 +51,13 @@ const char linux_emul_path[] = "/compat/linux"; * be in exists. */ int -linux_emul_find(p, sgp, prefix, path, pbuf, cflag) - struct proc *p; - caddr_t *sgp; /* Pointer to stackgap memory */ - const char *prefix; - char *path; +linux_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; + int cflag; { struct nameidata nd; struct nameidata ndroot; @@ -66,6 +66,10 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) int error; char *ptr, *buf, *cp; size_t sz, len; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK); *pbuf = path; @@ -105,7 +109,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); @@ -115,7 +119,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,8 +134,8 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) * root directory and never finding it, because "/" resolves * to the emulation root directory. This is expensive :-( */ - NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, - p); + NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, + linux_emul_path, td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -141,11 +145,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, cred, td)) != 0) { goto bad; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, cred, td)) != 0) { goto bad; } diff --git a/sys/emulation/linux/linux_util.h b/sys/emulation/linux/linux_util.h index 594d1aa80f..a3c2ef7a88 100644 --- a/sys/emulation/linux/linux_util.h +++ b/sys/emulation/linux/linux_util.h @@ -29,7 +29,7 @@ * 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: src/sys/compat/linux/linux_util.h,v 1.12.2.2 2000/11/02 23:31:28 obrien Exp $ - * $DragonFly: src/sys/emulation/linux/linux_util.h,v 1.3 2003/06/23 17:55:27 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_util.h,v 1.4 2003/06/25 03:55:44 dillon Exp $ */ /* @@ -53,12 +53,12 @@ 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(p) (*((p)->p_sysent->sv_szsigcode)) static __inline caddr_t stackgap_init() { - return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE); + return (caddr_t)(PS_STRINGS - szsigcode(curproc) - SPARE_USRSPACE); } static __inline void * @@ -69,7 +69,7 @@ stackgap_alloc(sgp, sz) void *p = (void *) *sgp; sz = ALIGN(sz); - if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode)) + if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode(curproc))) return NULL; *sgp += sz; return p; @@ -77,13 +77,13 @@ stackgap_alloc(sgp, sz) extern const char linux_emul_path[]; -int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *, char **, int)); +int linux_emul_find __P((struct thread *, caddr_t *, const char *, char *, char **, int)); #define CHECKALT(sgp, path, i) \ do { \ int _error; \ \ - _error = linux_emul_find(curproc, sgp, linux_emul_path, path, \ + _error = linux_emul_find(curthread, sgp, linux_emul_path, path, \ &path, i); \ if (_error == EFAULT) \ return (_error); \ @@ -103,9 +103,18 @@ struct __hack static __inline int unsupported_msg(const char *fname) { - struct proc *p = curproc; - printf("linux: syscall %s is obsoleted or not implemented (pid=%ld)\n", - fname, (long)p->p_pid); + struct thread *td = curthread; + if (td->td_proc) { + printf( + "linux: syscall %s is obsoleted or not implemented (pid=%d)\n", + fname, (int)td->td_proc->p_pid + ); + } else { + printf( + "linux: syscall %s is obsoleted or not implemented (td=%p)\n", + fname, td + ); + } return (ENOSYS); } diff --git a/sys/emulation/svr4/svr4_fcntl.c b/sys/emulation/svr4/svr4_fcntl.c index 522d3b1d81..2ee3a208ff 100644 --- a/sys/emulation/svr4/svr4_fcntl.c +++ b/sys/emulation/svr4/svr4_fcntl.c @@ -29,12 +29,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_fcntl.c,v 1.7 1999/12/12 10:27:04 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_fcntl.c,v 1.4 2003/06/23 18:12:13 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_fcntl.c,v 1.5 2003/06/25 03:56:09 dillon Exp $ */ #include #include -#include #include +#include #include #include #include @@ -56,8 +56,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 *)); @@ -243,14 +243,18 @@ svr4_to_bsd_flock64(iflp, oflp) static int -fd_revoke(struct proc *p, int fd) +fd_revoke(struct thread *td, int fd) { - struct filedesc *fdp = p->p_fd; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct vnode *vp; struct vattr vattr; int error, *retval; + KKASSERT(p); + + fdp = p->p_fd; retval = p->p_retval; if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) return EBADF; @@ -265,11 +269,11 @@ fd_revoke(struct proc *p, int fd) goto out; } - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, td)) != 0) goto out; if (p->p_ucred->cr_uid != vattr.va_uid && - (error = suser_xxx(p->p_ucred, 0)) != 0) + (error = suser(p->p_thread)) != 0) goto out; if (vcount(vp) > 1) @@ -281,9 +285,10 @@ out: static int -fd_truncate(struct proc *p, int fd, struct flock *flp) +fd_truncate(struct thread *td, int fd, struct flock *flp) { - struct filedesc *fdp = p->p_fd; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; off_t start, length; struct vnode *vp; @@ -291,6 +296,8 @@ fd_truncate(struct proc *p, int fd, struct flock *flp) int error, *retval; struct ftruncate_args ft; + KKASSERT(p); + fdp = p->p_fd; retval = p->p_retval; /* @@ -303,7 +310,7 @@ fd_truncate(struct proc *p, int fd, struct flock *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, p->p_ucred, td)) != 0) return error; length = vattr.va_size; @@ -339,9 +346,10 @@ fd_truncate(struct proc *p, int fd, struct flock *flp) int svr4_sys_open(struct svr4_sys_open_args *uap) { - struct proc *p = curproc; - int error, retval; - struct open_args cup; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; + struct open_args cup; + int error, retval; caddr_t sg = stackgap_init(); CHECKALTEXIST(&sg, SCARG(uap, path)); @@ -357,6 +365,7 @@ svr4_sys_open(struct svr4_sys_open_args *uap) return error; } + KKASSERT(p); retval = p->p_retval[0]; if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) && @@ -423,13 +432,15 @@ svr4_sys_llseek(struct svr4_sys_llseek_args *v) int svr4_sys_access(struct svr4_sys_access_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct access_args cup; int *retval; caddr_t sg = stackgap_init(); CHECKALTEXIST(&sg, SCARG(uap, path)); + KKASSERT(p); retval = p->p_retval; SCARG(&cup, path) = SCARG(uap, path); @@ -459,12 +470,8 @@ svr4_sys_pread(struct svr4_sys_pread_args *uap) #if defined(NOTYET) int -svr4_sys_pread64(p, v, retval) - register struct proc *p; - void *v; - register_t *retval; +svr4_sys_pread64(struct thread *td, void *v, register_t *retval) { - struct svr4_sys_pread64_args *uap = v; struct sys_pread_args pra; @@ -502,10 +509,7 @@ svr4_sys_pwrite(struct svr4_sys_pwrite_args *uap) #if defined(NOTYET) int -svr4_sys_pwrite64(p, v, retval) - register struct proc *p; - void *v; - register_t *retval; +svr4_sys_pwrite64(struct thread *td, void *v, register_t *retval) { struct svr4_sys_pwrite64_args *uap = v; struct sys_pwrite_args pwa; @@ -526,11 +530,13 @@ svr4_sys_pwrite64(p, v, retval) int svr4_sys_fcntl(struct svr4_sys_fcntl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; int error; struct fcntl_args fa; int *retval; + KKASSERT(p); retval = p->p_retval; SCARG(&fa, fd) = SCARG(uap, fd); @@ -632,7 +638,7 @@ svr4_sys_fcntl(struct svr4_sys_fcntl_args *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: @@ -681,11 +687,11 @@ svr4_sys_fcntl(struct svr4_sys_fcntl_args *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/emulation/svr4/svr4_filio.c b/sys/emulation/svr4/svr4_filio.c index 6d6401271f..756dd85ed5 100644 --- a/sys/emulation/svr4/svr4_filio.c +++ b/sys/emulation/svr4/svr4_filio.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_filio.c,v 1.8 2000/01/15 15:30:44 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_filio.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_filio.c,v 1.4 2003/06/25 03:56:09 dillon Exp $ */ #include @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -167,17 +168,21 @@ svr4_sys_write(struct svr4_sys_write_args *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; caddr_t data; { + struct proc *p = td->td_proc; int error; int num; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp; + + KKASSERT(p); + fdp = p->p_fd; *retval = 0; @@ -209,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/emulation/svr4/svr4_ioctl.c b/sys/emulation/svr4/svr4_ioctl.c index 2354121e30..05439b0aa0 100644 --- a/sys/emulation/svr4/svr4_ioctl.c +++ b/sys/emulation/svr4/svr4_ioctl.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_ioctl.c,v 1.6 1999/12/08 12:00:48 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ioctl.c,v 1.5 2003/06/23 18:22:07 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ioctl.c,v 1.6 2003/06/25 03:56:09 dillon Exp $ */ #include @@ -81,12 +81,13 @@ svr4_decode_cmd(cmd, dir, c, num, argsiz) int svr4_sys_ioctl(struct svr4_sys_ioctl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; 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]; @@ -94,6 +95,8 @@ svr4_sys_ioctl(struct svr4_sys_ioctl_args *uap) int num; int argsiz; + KKASSERT(p); + svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz); DPRINTF(("svr4_ioctl[%lx](%d, _IO%s(%c, %d, %d), %p);\n", @@ -158,5 +161,5 @@ svr4_sys_ioctl(struct svr4_sys_ioctl_args *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/emulation/svr4/svr4_ioctl.h b/sys/emulation/svr4/svr4_ioctl.h index 3c1a0255b2..cd7af72c47 100644 --- a/sys/emulation/svr4/svr4_ioctl.h +++ b/sys/emulation/svr4/svr4_ioctl.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_ioctl.h,v 1.3 1999/08/28 00:51:17 peter Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ioctl.h,v 1.2 2003/06/17 04:28:57 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ioctl.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SVR4_IOCTL_H_ @@ -47,17 +47,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/emulation/svr4/svr4_misc.c b/sys/emulation/svr4/svr4_misc.c index 361f469031..a6daa2828a 100644 --- a/sys/emulation/svr4/svr4_misc.c +++ b/sys/emulation/svr4/svr4_misc.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_misc.c,v 1.13.2.7 2003/01/14 21:33:58 dillon Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_misc.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_misc.c,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ /* @@ -38,10 +38,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -229,7 +229,8 @@ svr4_sys_time(struct svr4_sys_time_args *v) int svr4_sys_getdents64(struct svr4_sys_getdents64_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ @@ -246,6 +247,8 @@ svr4_sys_getdents64(struct svr4_sys_getdents64_args *uap) u_long *cookies = NULL, *cookiep; int ncookies; + KKASSERT(p); + 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) { @@ -260,7 +263,7 @@ svr4_sys_getdents64(struct svr4_sys_getdents64_args *uap) if (vp->v_type != VDIR) return (EINVAL); - if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) { + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, td))) { return error; } @@ -277,7 +280,7 @@ svr4_sys_getdents64(struct svr4_sys_getdents64_args *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; @@ -285,7 +288,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; @@ -391,7 +394,7 @@ eof: out: if (cookies) free(cookies, M_TEMP); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); free(buf, M_TEMP); return error; } @@ -400,7 +403,8 @@ out: int svr4_sys_getdents(struct svr4_sys_getdents_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ @@ -416,6 +420,8 @@ svr4_sys_getdents(struct svr4_sys_getdents_args *uap) u_long *cookiebuf = NULL, *cookie; int ncookies = 0, *retval = p->p_retval; + KKASSERT(p); + if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); @@ -428,7 +434,7 @@ svr4_sys_getdents(struct svr4_sys_getdents_args *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; @@ -437,7 +443,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; /* @@ -502,7 +508,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); @@ -574,23 +580,29 @@ svr4_sys_mmap64(struct svr4_sys_mmap64_args *uap) int svr4_sys_fchroot(struct svr4_sys_fchroot_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; + struct ucred *cred; + struct filedesc *fdp; struct vnode *vp; struct file *fp; int error; - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + KKASSERT(p); + cred = p->p_ucred; + fdp = p->p_fd; + + if ((error = suser(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, cred, td); + VOP_UNLOCK(vp, 0, td); if (error) return error; VREF(vp); @@ -630,9 +642,13 @@ svr4_mknod(retval, path, mode, dev) int svr4_sys_mknod(struct svr4_sys_mknod_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; + int *retval; + + KKASSERT(p); + retval = p->p_retval; - int *retval = p->p_retval; return svr4_mknod(retval, SCARG(uap, path), SCARG(uap, mode), (svr4_dev_t)svr4_to_bsd_odev_t(SCARG(uap, dev))); } @@ -641,8 +657,13 @@ svr4_sys_mknod(struct svr4_sys_mknod_args *uap) int svr4_sys_xmknod(struct svr4_sys_xmknod_args *uap) { - struct proc *p = curproc; - int *retval = p->p_retval; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; + int *retval; + + KKASSERT(p); + retval = p->p_retval; + return svr4_mknod(retval, SCARG(uap, path), SCARG(uap, mode), (svr4_dev_t)svr4_to_bsd_dev_t(SCARG(uap, dev))); } @@ -658,9 +679,11 @@ svr4_sys_vhangup(struct svr4_sys_vhangup_args *uap) int svr4_sys_sysconfig(struct svr4_sys_sysconfig_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; int *retval; + KKASSERT(p); retval = &(p->p_retval[0]); switch (SCARG(uap, name)) { @@ -759,11 +782,15 @@ extern int swap_pager_full; int svr4_sys_break(struct svr4_sys_break_args *uap) { - struct proc *p = curproc; - struct vmspace *vm = p->p_vmspace; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; + struct vmspace *vm; vm_offset_t new, old, base, ns; int rv; + KKASSERT(p); + vm = p->p_vmspace; + base = round_page((vm_offset_t) vm->vm_daddr); ns = (vm_offset_t)SCARG(uap, nsize); new = round_page(ns); @@ -890,7 +917,7 @@ svr4_sys_ulimit(struct svr4_sys_ulimit_args *uap) return error; SCARG(&srl, which) = RLIMIT_FSIZE; - SCARG(&srl, rlp) = (struct orlimit *)url; + SCARG(&srl, rlp) = (struct rlimit *)url; error = setrlimit(&srl); if (error) @@ -1583,12 +1610,17 @@ svr4_sys_nice(struct svr4_sys_nice_args *uap) int svr4_sys_resolvepath(struct svr4_sys_resolvepath_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct nameidata nd; - int error, *retval = p->p_retval; + int error; + int *retval; + + KKASSERT(p); + retval = p->p_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/emulation/svr4/svr4_socket.c b/sys/emulation/svr4/svr4_socket.c index 74a52e1c57..a1c61cefa0 100644 --- a/sys/emulation/svr4/svr4_socket.c +++ b/sys/emulation/svr4/svr4_socket.c @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_socket.c,v 1.7 1999/12/08 12:00:48 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_socket.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_socket.c,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ /* @@ -64,7 +64,7 @@ #include struct svr4_sockcache_entry { - struct proc *p; /* Process for the socket */ + struct thread *td; /* Process for the socket */ void *cookie; /* Internal cookie used for matching */ struct sockaddr_un sock;/* Pathname for the socket */ udev_t dev; /* Device where the socket lives on */ @@ -76,8 +76,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,16 +87,16 @@ svr4_find_socket(p, fp, dev, ino) if (!svr4_str_initialized) { DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n", - p, dev, ino)); + td, dev, ino)); TAILQ_INIT(&svr4_head); svr4_str_initialized = 1; return NULL; } - DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino)); + DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", td, dev, ino)); for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next) - if (e->p == p && e->dev == dev && e->ino == ino) { + if (e->td == td && e->dev == dev && e->ino == ino) { #ifdef DIAGNOSTIC if (e->cookie != NULL && e->cookie != cookie) panic("svr4 socket cookie mismatch"); @@ -116,8 +116,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; { @@ -133,7 +133,7 @@ svr4_add_socket(p, path, st) e->cookie = NULL; e->dev = st->st_dev; e->ino = st->st_ino; - e->p = p; + e->td = td; if ((error = copyinstr(path, e->sock.sun_path, sizeof(e->sock.sun_path), &len)) != 0) { @@ -147,7 +147,7 @@ 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, e->dev, e->ino)); return 0; } diff --git a/sys/emulation/svr4/svr4_socket.h b/sys/emulation/svr4/svr4_socket.h index d8d7c4ac37..8f1fd8d3e0 100644 --- a/sys/emulation/svr4/svr4_socket.h +++ b/sys/emulation/svr4/svr4_socket.h @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_socket.h,v 1.4 1999/08/28 00:51:22 peter Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_socket.h,v 1.2 2003/06/17 04:28:57 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_socket.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SVR4_SOCKET_H_ @@ -48,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 *)); +void svr4_delete_socket __P((struct thread *, struct file *)); +int svr4_add_socket __P((struct thread *, const char *, struct stat *)); #endif /* _SVR4_SOCKET_H_ */ diff --git a/sys/emulation/svr4/svr4_sockio.c b/sys/emulation/svr4/svr4_sockio.c index 8e682bc851..661622c30a 100644 --- a/sys/emulation/svr4/svr4_sockio.c +++ b/sys/emulation/svr4/svr4_sockio.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_sockio.c,v 1.7 1999/12/08 12:00:48 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_sockio.c,v 1.2 2003/06/17 04:28:57 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_sockio.c,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #include @@ -37,7 +37,7 @@ #include #include #include - +#include #include #include @@ -71,9 +71,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; @@ -127,7 +127,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; @@ -151,7 +151,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/emulation/svr4/svr4_stat.c b/sys/emulation/svr4/svr4_stat.c index d29dd2e5cb..57528f2ae3 100644 --- a/sys/emulation/svr4/svr4_stat.c +++ b/sys/emulation/svr4/svr4_stat.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_stat.c,v 1.6 1999/12/08 12:00:48 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stat.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stat.c,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ #include @@ -156,7 +156,7 @@ bsd_to_svr4_stat64(st, st4) int svr4_sys_stat(struct svr4_sys_stat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat st; struct svr4_stat svr4_st; struct stat_args cup; @@ -178,7 +178,7 @@ svr4_sys_stat(struct svr4_sys_stat_args *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; @@ -190,7 +190,7 @@ svr4_sys_stat(struct svr4_sys_stat_args *uap) int svr4_sys_lstat(struct svr4_sys_lstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat st; struct svr4_stat svr4_st; struct lstat_args cup; @@ -211,7 +211,7 @@ svr4_sys_lstat(struct svr4_sys_lstat_args *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; @@ -342,7 +342,7 @@ svr4_sys_fxstat(struct svr4_sys_fxstat_args *uap) int svr4_sys_stat64(struct svr4_sys_stat64_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat st; struct svr4_stat64 svr4_st; struct stat_args cup; @@ -363,7 +363,7 @@ svr4_sys_stat64(struct svr4_sys_stat64_args *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; @@ -375,7 +375,7 @@ svr4_sys_stat64(struct svr4_sys_stat64_args *uap) int svr4_sys_lstat64(struct svr4_sys_lstat64_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat st; struct svr4_stat64 svr4_st; struct stat_args cup; @@ -396,7 +396,7 @@ svr4_sys_lstat64(struct svr4_sys_lstat64_args *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; @@ -481,7 +481,8 @@ svr4_sys_uname(struct svr4_sys_uname_args *uap) int svr4_sys_systeminfo(struct svr4_sys_systeminfo_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; char *str = NULL; int error = 0; register_t *retval = p->p_retval; @@ -541,13 +542,13 @@ svr4_sys_systeminfo(struct svr4_sys_systeminfo_args *uap) break; #if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES) case SVR4_SI_SET_HOSTNAME: - if ((error = suser(p)) != 0) + if ((error = suser(td)) != 0) return error; name = KERN_HOSTNAME; return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); case SVR4_SI_SET_SRPC_DOMAIN: - if ((error = suser(p)) != 0) + if ((error = suser(td)) != 0) return error; name = KERN_NISDOMAINNAME; return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); diff --git a/sys/emulation/svr4/svr4_stream.c b/sys/emulation/svr4/svr4_stream.c index eea72d382e..4d13eb8086 100644 --- a/sys/emulation/svr4/svr4_stream.c +++ b/sys/emulation/svr4/svr4_stream.c @@ -28,7 +28,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_stream.c,v 1.12.2.2 2000/11/26 04:42:27 dillon Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stream.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stream.c,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ /* @@ -61,6 +61,7 @@ #include #include #include +#include #include @@ -90,48 +91,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)); /* Ok, so we shouldn't use sendit() in uipc_syscalls.c because @@ -145,12 +146,13 @@ 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) - struct proc *p; +svr4_sendit(td, s, mp, flags) + struct thread *td; int s; struct msghdr *mp; int flags; { + struct proc *p; struct file *fp; struct uio auio; struct iovec *iov; @@ -164,6 +166,9 @@ svr4_sendit(p, s, mp, flags) struct uio ktruio; #endif + p = td->td_proc; + KKASSERT(p); + error = holdsock(p->p_fd, s, &fp); if (error) return (error); @@ -171,20 +176,20 @@ svr4_sendit(p, s, mp, flags) 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 { @@ -203,7 +208,7 @@ svr4_sendit(p, s, mp, flags) control = 0; } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(p->p_thread, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -213,8 +218,8 @@ svr4_sendit(p, s, mp, flags) #endif 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); + error = so->so_proto->pr_usrreqs->pru_sosend + (so, to, &auio, 0, control, flags, td); if (error) { if (auio.uio_resid != len && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) @@ -235,19 +240,20 @@ svr4_sendit(p, s, mp, flags) } #endif bad: - fdrop(fp, p); + fdrop(fp, td); if (to) FREE(to, M_SONAME); return (error); } static int -svr4_recvit(p, s, mp, namelenp) - struct proc *p; +svr4_recvit(td, s, mp, namelenp) + struct thread *td; int s; struct msghdr *mp; caddr_t namelenp; { + struct proc *p = td->td_proc; struct file *fp; struct uio auio; struct iovec *iov; @@ -261,6 +267,8 @@ svr4_recvit(p, s, mp, namelenp) struct iovec *ktriov = NULL; struct uio ktruio; #endif + p = td->td_proc; + KKASSERT(p); error = holdsock(p->p_fd, s, &fp); if (error) @@ -269,18 +277,18 @@ svr4_recvit(p, s, mp, namelenp) 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(p->p_thread, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -363,7 +371,7 @@ out: FREE(fromsa, M_SONAME); if (control) m_freem(control); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -658,11 +666,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; @@ -715,11 +723,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; @@ -729,11 +737,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); @@ -793,11 +801,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; @@ -852,11 +860,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; @@ -877,24 +885,24 @@ si_shutdown(fp, fd, ioc, p) 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")); @@ -918,11 +926,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)); @@ -933,11 +941,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; @@ -971,11 +979,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); @@ -1074,16 +1082,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")); @@ -1091,7 +1099,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")); @@ -1105,9 +1113,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; @@ -1247,9 +1255,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; @@ -1265,7 +1273,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) @@ -1277,9 +1285,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; @@ -1339,9 +1347,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,9 +1371,9 @@ _i_bind_rsvd(fp, p, retval, fd, cmd, dat) } 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,9 +1391,9 @@ _i_rele_rsvd(fp, p, retval, fd, cmd, dat) } 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; @@ -1404,12 +1412,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; @@ -1427,9 +1435,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; @@ -1443,11 +1451,14 @@ i_setsig(fp, p, retval, fd, cmd, dat) * We alse have to fix the O_ASYNC fcntl bit, so the * process will get SIGPOLLs. */ + struct proc *p = td->td_proc; struct fcntl_args fa; int error; register_t oflags, flags; struct svr4_strm *st = svr4_stream_get(fp); + KKASSERT(p); + if (st == NULL) { DPRINTF(("i_setsig: bad file descriptor\n")); return EINVAL; @@ -1499,9 +1510,9 @@ i_setsig(fp, p, retval, fd, cmd, dat) } 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; @@ -1526,9 +1537,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; @@ -1542,12 +1553,12 @@ 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 %x\n", dat)); + DPRINTF(("I_PUSH %p\n", dat)); #if defined(DEBUG_SVR4) - show_strbuf(dat); + show_strbuf((void *)dat); #endif return 0; @@ -1573,15 +1584,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")); @@ -1610,7 +1621,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")); @@ -1686,11 +1697,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)); @@ -1705,8 +1716,9 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) int svr4_sys_putmsg(struct svr4_sys_putmsg_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct svr4_strbuf dat, ctl; struct svr4_strmcmd sc; @@ -1718,6 +1730,8 @@ svr4_sys_putmsg(struct svr4_sys_putmsg_args *uap) int error; caddr_t sg; + KKASSERT(p); + fdp = p->p_fd; retval = p->p_retval; fp = fdp->fd_ofiles[SCARG(uap, fd)]; @@ -1819,7 +1833,7 @@ svr4_sys_putmsg(struct svr4_sys_putmsg_args *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 */ @@ -1867,10 +1881,10 @@ svr4_sys_putmsg(struct svr4_sys_putmsg_args *uap) aiov.iov_base = dat.buf; aiov.iov_len = dat.len; #if 0 - error = so->so_proto->pr_usrreqs->pru_sosend(so, 0, - uio, 0, 0, 0, uio->uio_procp); + error = so->so_proto->pr_usrreqs->pru_sosend + (so, 0, 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; @@ -1886,8 +1900,9 @@ svr4_sys_putmsg(struct svr4_sys_putmsg_args *uap) int svr4_sys_getmsg(struct svr4_sys_getmsg_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct getpeername_args ga; struct accept_args aa; @@ -1905,6 +1920,8 @@ svr4_sys_getmsg(struct svr4_sys_getmsg_args *uap) int fl; caddr_t sg; + KKASSERT(p); + fdp = p->p_fd; retval = p->p_retval; fp = fdp->fd_ofiles[SCARG(uap, fd)]; @@ -2134,7 +2151,7 @@ svr4_sys_getmsg(struct svr4_sys_getmsg_args *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)); diff --git a/sys/emulation/svr4/svr4_sysvec.c b/sys/emulation/svr4/svr4_sysvec.c index 44ab9cf1aa..f4ab874493 100644 --- a/sys/emulation/svr4/svr4_sysvec.c +++ b/sys/emulation/svr4/svr4_sysvec.c @@ -28,7 +28,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_sysvec.c,v 1.10.2.2 2002/07/09 14:12:43 robert Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_sysvec.c,v 1.3 2003/06/23 17:55:49 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_sysvec.c,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ /* XXX we use functions that might not exist. */ @@ -156,7 +156,7 @@ int bsd_to_svr4_errno[ELAST+1] = { }; -static int svr4_fixup(long **stack_base, struct image_params *imgp); +static int svr4_fixup(register_t **stack_base, struct image_params *imgp); extern struct sysent svr4_sysent[]; #undef szsigcode @@ -196,10 +196,10 @@ Elf32_Brandinfo svr4_brand = { const char svr4_emul_path[] = "/compat/svr4"; static int -svr4_fixup(long **stack_base, struct image_params *imgp) +svr4_fixup(register_t **stack_base, struct image_params *imgp) { Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs; - long *pos; + register_t *pos; pos = *stack_base + (imgp->argc + imgp->envc + 2); @@ -248,7 +248,7 @@ svr4_emul_find(sgp, prefix, path, pbuf, cflag) char **pbuf; int cflag; { - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct nameidata nd; struct nameidata ndroot; struct vattr vat; @@ -256,6 +256,10 @@ svr4_emul_find(sgp, prefix, path, pbuf, cflag) int error; char *ptr, *buf, *cp; size_t sz, len; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK); *pbuf = path; @@ -295,7 +299,7 @@ svr4_emul_find(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); @@ -306,7 +310,7 @@ svr4_emul_find(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); @@ -322,8 +326,8 @@ svr4_emul_find(sgp, prefix, path, pbuf, cflag) * root directory and never finding it, because "/" resolves * to the emulation root directory. This is expensive :-( */ - NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, svr4_emul_path, - p); + NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, + svr4_emul_path, td); if ((error = namei(&ndroot)) != 0) { /* Cannot happen! */ @@ -333,11 +337,11 @@ svr4_emul_find(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, cred, td)) != 0) { goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, cred, td)) != 0) { goto done; } diff --git a/sys/emulation/svr4/svr4_termios.c b/sys/emulation/svr4/svr4_termios.c index 442c8713d0..a7656de26b 100644 --- a/sys/emulation/svr4/svr4_termios.c +++ b/sys/emulation/svr4/svr4_termios.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_termios.c,v 1.5 1999/12/08 12:00:48 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_termios.c,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_termios.c,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #include @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -479,9 +480,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; @@ -494,13 +495,13 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data) *retval = 0; - DPRINTF(("TERM ioctl %x\n", cmd)); + DPRINTF(("TERM ioctl %lx\n", cmd)); switch (cmd) { 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)); @@ -527,7 +528,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) { @@ -578,14 +579,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)); @@ -598,11 +599,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/emulation/svr4/svr4_ttold.c b/sys/emulation/svr4/svr4_ttold.c index 99b626b0eb..23a9a79156 100644 --- a/sys/emulation/svr4/svr4_ttold.c +++ b/sys/emulation/svr4/svr4_ttold.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/svr4/svr4_ttold.c,v 1.7 1999/12/08 12:00:49 newton Exp $ - * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ttold.c,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ttold.c,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #include @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -176,9 +177,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; @@ -193,7 +194,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)); @@ -212,21 +213,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 td %p unsupported\n", td); return EINVAL; #endif } @@ -236,7 +237,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; @@ -261,7 +262,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: @@ -269,7 +270,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; @@ -292,7 +293,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: @@ -300,7 +301,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; @@ -323,13 +324,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)); @@ -357,7 +358,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/i386/gnu/isa/dgb.c b/sys/i386/gnu/isa/dgb.c index 06e9669286..72f7fc569f 100644 --- a/sys/i386/gnu/isa/dgb.c +++ b/sys/i386/gnu/isa/dgb.c @@ -1,6 +1,6 @@ /*- * dgb.c $FreeBSD: src/sys/gnu/i386/isa/dgb.c,v 1.56.2.1 2001/02/26 04:23:09 jlemon Exp $ - * dgb.c $DragonFly: src/sys/i386/gnu/isa/Attic/dgb.c,v 1.2 2003/06/17 04:28:34 dillon Exp $ + * dgb.c $DragonFly: src/sys/i386/gnu/isa/Attic/dgb.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ * * Digiboard driver. * @@ -924,11 +924,7 @@ load_fep: /* ARGSUSED */ static int -dgbopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +dgbopen(dev_t dev, int flag, int mode, struct thread *td) { struct dgb_softc *sc; struct tty *tp; @@ -1013,8 +1009,7 @@ open_top: goto open_top; } } - if (tp->t_state & TS_XCLUDE && - suser(p)) { + if (tp->t_state & TS_XCLUDE && suser(td)) { error = EBUSY; goto out; } @@ -1104,17 +1099,13 @@ out: /*ARGSUSED*/ static int -dgbclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +dgbclose(dev_t dev, int flag, int mode, struct thread *td) { - int mynor; - struct tty *tp; + struct tty *tp; int unit, pnum; struct dgb_softc *sc; struct dgb_p *port; + int mynor; int s; int i; @@ -1464,12 +1455,7 @@ dgbpoll(unit_c) } static int -dgbioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +dgbioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct dgb_softc *sc; int unit, pnum; @@ -1512,7 +1498,7 @@ dgbioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1734,7 +1720,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); if (error != 0) { splx(s); return (error); diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 0953fa8acf..cc04be8ea9 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.16.2.2 2003/01/23 00:55:27 scottl Exp $ - * $DragonFly: src/sys/i386/i386/Attic/busdma_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/busdma_machdep.c,v 1.3 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -499,7 +499,7 @@ static int _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t segs[], void *buf, bus_size_t buflen, - struct proc *p, + struct thread *td, int flags, vm_offset_t *lastaddrp, int *segp, @@ -511,8 +511,8 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, int seg; pmap_t pmap; - if (p != NULL) - pmap = vmspace_pmap(p->p_vmspace); + if (td->td_proc != NULL) + pmap = vmspace_pmap(td->td_proc->p_vmspace); else pmap = NULL; @@ -647,7 +647,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, int nsegs, error, first, i; bus_size_t resid; struct iovec *iov; - struct proc *p = NULL; + struct thread *td = NULL; KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, ("bus_dmamap_load_uio: No support for bounce pages!")); @@ -656,8 +656,8 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, iov = uio->uio_iov; if (uio->uio_segflg == UIO_USERSPACE) { - p = uio->uio_procp; - KASSERT(p != NULL, + td = uio->uio_td; + KASSERT(td != NULL && td->td_proc != NULL, ("bus_dmamap_load_uio: USERSPACE but no proc")); } @@ -676,7 +676,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_buffer(dmat, dm_segments, addr, minlen, - p, flags, &lastaddr, &nsegs, first); + td, flags, &lastaddr, &nsegs, first); first = 0; resid -= minlen; diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index b296be19bb..c96a53667d 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.11 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.12 2003/06/25 03:55:53 dillon Exp $ */ #include "apm.h" @@ -2433,7 +2433,7 @@ set_dbregs(p, dbregs) * from within kernel mode? */ - if (suser_xxx(p->p_ucred, 0) != 0) { + if (suser_cred(p->p_ucred, 0) != 0) { if (dbregs->dr7 & 0x3) { /* dr0 is enabled */ if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index a4fdaea6f5..ccfcbf7c70 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -39,7 +39,7 @@ * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/i386/mem.c,v 1.79.2.9 2003/01/04 22:58:01 njl Exp $ - * $DragonFly: src/sys/i386/i386/Attic/mem.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/mem.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -135,7 +135,7 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td) return (EPERM); break; case 14: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (securelevel > 0) @@ -440,7 +440,6 @@ mem_range_AP_init(void) static int random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - struct proc *p = td->td_proc; static intrmask_t interrupt_allowed; intrmask_t interrupt_mask; int error, intr; @@ -471,7 +470,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) case FIONBIO: break; case MEM_SETIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -488,7 +487,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_CLEARIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -502,7 +501,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_RETURNIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); *(u_int16_t *)data = interrupt_allowed; diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index 8ca1f52850..ad67da9fcf 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.4 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ * */ @@ -163,9 +163,7 @@ i386_extend_pcb(struct proc *p) } static int -i386_set_ioperm(p, args) - struct proc *p; - char *args; +i386_set_ioperm(struct proc *p, char *args) { int i, error; struct i386_ioperm_args ua; @@ -174,7 +172,7 @@ i386_set_ioperm(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0) return (error); - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser_cred(p->p_ucred, 0)) != 0) return (error); if (securelevel > 0) return (EPERM); diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 26e5fab2d0..27142c2caf 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.7 2003/06/23 23:36:05 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.8 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -1071,10 +1071,11 @@ void syscall2(frame) struct trapframe frame; { + struct thread *td = curthread; + struct proc *p = td->td_proc; caddr_t params; int i; struct sysent *callp; - struct proc *p = curproc; register_t orig_tf_eflags; u_quad_t sticks; int error; @@ -1150,7 +1151,7 @@ syscall2(frame) get_mplock(); have_mplock = 1; #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) + if (KTRPOINT(td, KTR_SYSCALL)) ktrsyscall(p->p_tracep, code, narg, args); #endif goto bad; @@ -1167,7 +1168,7 @@ syscall2(frame) } #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) { + if (KTRPOINT(td, KTR_SYSCALL)) { if (have_mplock == 0) { get_mplock(); have_mplock = 1; @@ -1239,7 +1240,7 @@ bad: have_mplock = userret(p, &frame, sticks, have_mplock); #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) { + if (KTRPOINT(td, KTR_SYSRET)) { if (have_mplock == 0) { get_mplock(); have_mplock = 1; @@ -1278,7 +1279,7 @@ fork_return(p, frame) userret(p, &frame, 0, 1); #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) + if (KTRPOINT(p->p_thread, KTR_SYSRET)) ktrsysret(p->p_tracep, SYS_fork, 0, 0); #endif } diff --git a/sys/i386/i386/vm86.c b/sys/i386/i386/vm86.c index afd41cce86..a096995384 100644 --- a/sys/i386/i386/vm86.c +++ b/sys/i386/i386/vm86.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86.c,v 1.31.2.2 2001/10/05 06:18:55 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm86.c,v 1.4 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm86.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -645,9 +645,7 @@ vm86_getptr(vmc, kva, sel, off) } int -vm86_sysarch(p, args) - struct proc *p; - char *args; +vm86_sysarch(struct proc *p, char *args) { int error = 0; struct i386_vm86_args ua; @@ -705,7 +703,7 @@ vm86_sysarch(p, args) case VM86_INTCALL: { struct vm86_intcall_args sa; - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser_cred(p->p_ucred, 0))) return (error); if ((error = copyin(ua.sub_args, &sa, sizeof(sa)))) return (error); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index bccdf9a1ac..4677ae7997 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.9 2003/06/22 04:30:39 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.10 2003/06/25 03:55:53 dillon Exp $ */ #include "npx.h" @@ -308,14 +308,13 @@ 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; - struct vnode *vp; - struct ucred *cred; +cpu_coredump(struct thread *td, struct vnode *vp, struct ucred *cred) { + struct proc *p = td->td_proc; int error; caddr_t tempuser; + KKASSERT(p); tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK); if (!tempuser) return EINVAL; @@ -328,7 +327,7 @@ cpu_coredump(p, vp, cred) bcopy(p->p_thread->td_pcb, tempuser + ((char *)p->p_thread->td_pcb - (char *)p->p_addr), sizeof(struct pcb)); error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); free(tempuser, M_TEMP); diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index dfeddbee69..0b3dbef2d1 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/imgact_aout.c,v 1.59.2.5 2001/11/03 01:41:08 ps Exp $ - * $DragonFly: src/sys/kern/imgact_aout.c,v 1.3 2003/06/24 02:11:55 dillon Exp $ + * $DragonFly: src/sys/kern/imgact_aout.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -35,15 +35,15 @@ #include #include #include +#include +#include #include #include -#include #include #include #include #include #include -#include #include #include @@ -246,29 +246,31 @@ exec_aout_imgact(imgp) */ int aout_coredump(p, vp, limit) - register struct proc *p; - register struct vnode *vp; + struct proc *p; + struct vnode *vp; off_t limit; { - register struct ucred *cred = p->p_ucred; - register struct vmspace *vm = p->p_vmspace; + struct ucred *cred = p->p_ucred; + struct vmspace *vm = p->p_vmspace; int error; if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); bcopy(p, &p->p_addr->u_kproc.kp_proc, sizeof(struct proc)); fill_eproc(p, &p->p_addr->u_kproc.kp_eproc); - error = cpu_coredump(p, vp, cred); + error = cpu_coredump(p->p_thread, 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 | IO_DIRECT | IO_CORE, cred, (int *) NULL, p); + IO_UNIT | IO_DIRECT | IO_CORE, cred, (int *) NULL, + p->p_thread); 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 | IO_DIRECT | IO_CORE, cred, (int *) NULL, p); + IO_UNIT | IO_DIRECT | IO_CORE, cred, (int *) NULL, + p->p_thread); return (error); } diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index a6798f490b..65b6dc443e 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.73.2.13 2002/12/28 19:49:41 dillon Exp $ - * $DragonFly: src/sys/kern/imgact_elf.c,v 1.3 2003/06/24 02:11:55 dillon Exp $ + * $DragonFly: src/sys/kern/imgact_elf.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -38,9 +38,10 @@ #include #include #include +#include +#include #include #include -#include #include #include #include @@ -48,7 +49,6 @@ #include #include #include -#include #include #include @@ -341,6 +341,7 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) u_long rbase; u_long base_addr = 0; int error, i, numsegs; + struct thread *td = p->p_thread; tempdata = malloc(sizeof(*tempdata), M_TEMP, M_WAITOK); nd = &tempdata->nd; @@ -362,7 +363,7 @@ 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); + NDINIT(nd, LOOKUP, LOCKLEAF|FOLLOW, UIO_SYSSPACE, file, td); if ((error = namei(nd)) != 0) { nd->ni_vp = NULL; @@ -376,7 +377,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, td); goto fail; } @@ -387,7 +388,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, td); if (error) goto fail; @@ -422,12 +423,14 @@ elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry) if (phdr[i].p_flags & PF_R) prot |= VM_PROT_READ; - if ((error = elf_load_section(p, vmspace, nd->ni_vp, - phdr[i].p_offset, - (caddr_t)phdr[i].p_vaddr + - rbase, - phdr[i].p_memsz, - phdr[i].p_filesz, prot)) != 0) + error = elf_load_section( + p, vmspace, nd->ni_vp, + phdr[i].p_offset, + (caddr_t)phdr[i].p_vaddr + + rbase, + phdr[i].p_memsz, + phdr[i].p_filesz, prot); + if (error != 0) goto fail; /* * Establish the base address if this is the @@ -768,11 +771,12 @@ extern int osreldate; int elf_coredump(p, vp, limit) - register struct proc *p; - register struct vnode *vp; + struct proc *p; + struct vnode *vp; off_t limit; { - register struct ucred *cred = p->p_ucred; + struct ucred *cred = p->p_ucred; + struct thread *td = p->p_thread; int error = 0; struct sseg_closure seginfo; void *hdr; @@ -818,7 +822,8 @@ 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 | IO_DIRECT | IO_CORE, cred, (int *)NULL, p); + IO_UNIT | IO_DIRECT | IO_CORE, cred, + (int *)NULL, td); if (error != 0) break; offset += php->p_filesz; @@ -959,6 +964,7 @@ elf_corehdr(p, vp, cred, numsegs, hdr, hdrsize) prstatus_t *status; prfpregset_t *fpregset; prpsinfo_t *psinfo; + struct thread *td = p->p_thread; tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO | M_WAITOK); status = &tempdata->status; @@ -993,7 +999,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 | IO_DIRECT | IO_CORE, cred, NULL, p); + UIO_SYSSPACE, IO_UNIT | IO_DIRECT | IO_CORE, cred, NULL, td); } static void diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 94e823fffa..85665b702f 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.11 2003/06/23 23:36:11 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.12 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_init_path.h" @@ -62,6 +62,7 @@ #include #include #include +#include #include @@ -443,7 +444,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, curthread); /* * Need just enough stack to hold the faked-up "execve()" arguments. diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 3d1535f830..368ca82e6d 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -38,7 +38,7 @@ * * @(#)kern_acct.c 8.1 (Berkeley) 6/14/93 * $FreeBSD: src/sys/kern/kern_acct.c,v 1.23.2.1 2002/07/24 18:33:55 johan Exp $ - * $DragonFly: src/sys/kern/kern_acct.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_acct.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -116,12 +116,13 @@ acct(uap) syscallarg(char *) path; } */ *uap; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; + struct proc *p = td->td_proc; /* XXX */ struct nameidata nd; int error; /* Make sure that the caller is root. */ - error = suser(); + error = suser(td); if (error) return (error); @@ -130,15 +131,15 @@ acct(uap) * appending and make sure it's a 'normal'. */ if (SCARG(uap, path) != NULL) { - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), - p); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, + SCARG(uap, path), td); error = vn_open(&nd, FWRITE | O_APPEND, 0); if (error) return (error); 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 | O_APPEND, p->p_ucred, p); + vn_close(nd.ni_vp, FWRITE | O_APPEND, p->p_ucred, td); return (EACCES); } } @@ -150,7 +151,7 @@ acct(uap) if (acctp != NULLVP || savacctp != NULLVP) { untimeout(acctwatch, NULL, acctwatch_handle); error = vn_close((acctp != NULLVP ? acctp : savacctp), - FWRITE | O_APPEND, p->p_ucred, p); + FWRITE | O_APPEND, p->p_ucred, td); acctp = savacctp = NULLVP; } if (SCARG(uap, path) == NULL) @@ -173,14 +174,14 @@ acct(uap) */ int -acct_process(p) - struct proc *p; +acct_process(struct proc *p) { struct acct acct; struct rusage *r; struct timeval ut, st, tmp; int t; struct vnode *vp; + struct thread *td = p->p_thread; /* If accounting isn't enabled, don't bother */ vp = acctp; @@ -244,10 +245,10 @@ acct_process(p) /* * Write the accounting information to the file. */ - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, p->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)); + (int *)0, td)); } /* @@ -309,7 +310,7 @@ acctwatch(a) savacctp = NULLVP; return; } - (void)VFS_STATFS(savacctp->v_mount, &sb, (struct proc *)0); + (void)VFS_STATFS(savacctp->v_mount, &sb, NULL); if (sb.f_bavail > acctresume * sb.f_blocks / 100) { acctp = savacctp; savacctp = NULLVP; @@ -323,7 +324,7 @@ acctwatch(a) acctp = NULLVP; return; } - (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0); + (void)VFS_STATFS(acctp->v_mount, &sb, NULL); 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 e3b69aeb5c..7fe5ccf76d 100644 --- a/sys/kern/kern_acl.c +++ b/sys/kern/kern_acl.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_acl.c,v 1.2.2.1 2000/07/28 18:48:16 rwatson Exp $ - * $DragonFly: src/sys/kern/kern_acl.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_acl.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -39,9 +39,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -68,17 +68,21 @@ static int vacl_aclcheck(struct vnode *vp, acl_type_t type, struct acl *aclp); static int vacl_set_acl(struct vnode *vp, acl_type_t type, struct acl *aclp) { - struct proc *p = curproc; + struct thread *td = curthread; struct acl inkernacl; + struct ucred *ucred; int error; 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); + KKASSERT(td->td_proc); + ucred = td->td_proc->p_ucred; + + VOP_LEASE(vp, td, ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, type, &inkernacl, ucred, td); + VOP_UNLOCK(vp, 0, td); return(error); } @@ -88,11 +92,14 @@ vacl_set_acl(struct vnode *vp, acl_type_t type, struct acl *aclp) static int vacl_get_acl(struct vnode *vp, acl_type_t type, struct acl *aclp) { - struct proc *p = curproc; + struct thread *td = curthread; struct acl inkernelacl; + struct ucred *ucred; int error; - error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); + KKASSERT(td->td_proc); + ucred = td->td_proc->p_ucred; + error = VOP_GETACL(vp, type, &inkernelacl, ucred, td); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -104,13 +111,16 @@ vacl_get_acl(struct vnode *vp, acl_type_t type, struct acl *aclp) static int vacl_delete(struct vnode *vp, acl_type_t type) { - struct proc *p = curproc; + struct thread *td = curthread; + struct ucred *ucred; 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); + KKASSERT(td->td_proc); + ucred = td->td_proc->p_ucred; + VOP_LEASE(vp, td, ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, ucred, td); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -120,14 +130,17 @@ vacl_delete(struct vnode *vp, acl_type_t type) static int vacl_aclcheck(struct vnode *vp, acl_type_t type, struct acl *aclp) { - struct proc *p = curproc; + struct thread *td = curthread; + struct ucred *ucred; struct acl inkernelacl; int error; + KKASSERT(td->td_proc); + ucred = td->td_proc->p_ucred; 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, ucred, td); return (error); } @@ -143,12 +156,12 @@ vacl_aclcheck(struct vnode *vp, acl_type_t type, struct acl *aclp) int __acl_get_file(struct __acl_get_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; int error; /* 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) return(error); @@ -163,11 +176,11 @@ __acl_get_file(struct __acl_get_file_args *uap) int __acl_set_file(struct __acl_set_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; int error; - 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) return(error); @@ -182,11 +195,12 @@ __acl_set_file(struct __acl_set_file_args *uap) int __acl_get_fd(struct __acl_get_fd_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct file *fp; int error; - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + KKASSERT(td->td_proc); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error) return(error); return vacl_get_acl((struct vnode *)fp->f_data, SCARG(uap, type), @@ -199,11 +213,12 @@ __acl_get_fd(struct __acl_get_fd_args *uap) int __acl_set_fd(struct __acl_set_fd_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct file *fp; int error; - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + KKASSERT(td->td_proc); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error) return(error); return vacl_set_acl((struct vnode *)fp->f_data, SCARG(uap, type), @@ -216,11 +231,11 @@ __acl_set_fd(struct __acl_set_fd_args *uap) int __acl_delete_file(struct __acl_delete_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; int error; - 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) return(error); @@ -235,11 +250,12 @@ __acl_delete_file(struct __acl_delete_file_args *uap) int __acl_delete_fd(struct __acl_delete_fd_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct file *fp; int error; - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + KKASSERT(td->td_proc); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error) return(error); error = vacl_delete((struct vnode *)fp->f_data, SCARG(uap, type)); @@ -252,11 +268,11 @@ __acl_delete_fd(struct __acl_delete_fd_args *uap) int __acl_aclcheck_file(struct __acl_aclcheck_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; int error; - 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) return(error); @@ -271,11 +287,12 @@ __acl_aclcheck_file(struct __acl_aclcheck_file_args *uap) int __acl_aclcheck_fd(struct __acl_aclcheck_fd_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct file *fp; int error; - error = getvnode(p->p_fd, SCARG(uap, filedes), &fp); + KKASSERT(td->td_proc); + error = getvnode(td->td_proc->p_fd, SCARG(uap, filedes), &fp); if (error) return(error); return vacl_aclcheck((struct vnode *)fp->f_data, SCARG(uap, type), diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 166aac662a..3e512d7b6b 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -37,7 +37,7 @@ * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.81.2.17 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/kern_descrip.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_descrip.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -63,6 +63,8 @@ #include #include +#include + static MALLOC_DEFINE(M_FILEDESC, "file desc", "Open file descriptor table"); static MALLOC_DEFINE(M_FILEDESC_TO_LEADER, "file desc to leader", "file desc to leader structures"); @@ -92,14 +94,14 @@ static struct cdevsw fildesc_cdevsw = { static int do_dup __P((struct filedesc *fdp, int old, int new, register_t *retval, struct proc *p)); 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. @@ -210,7 +212,8 @@ struct fcntl_args { int fcntl(struct fcntl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; char *pop; @@ -219,6 +222,8 @@ fcntl(struct fcntl_args *uap) struct flock fl; u_int newmin; + KKASSERT(p); + if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); @@ -252,33 +257,33 @@ fcntl(struct fcntl_args *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); return (error); } 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); return (0); } 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); return (error); 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)p->p_retval, td); + fdrop(fp, td); return(error); 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); return(error); case F_SETLKW: @@ -298,7 +303,7 @@ fcntl(struct fcntl_args *uap) error = copyin((caddr_t)(intptr_t)uap->arg, (caddr_t)&fl, sizeof(fl)); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } if (fl.l_whence == SEEK_CUR) @@ -341,7 +346,7 @@ fcntl(struct fcntl_args *uap) (void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &fl, F_POSIX); } - fdrop(fp, p); + fdrop(fp, td); return(error); case F_GETLK: @@ -356,19 +361,19 @@ fcntl(struct fcntl_args *uap) error = copyin((caddr_t)(intptr_t)uap->arg, (caddr_t)&fl, sizeof(fl)); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } if (fl.l_type != F_RDLCK && fl.l_type != F_WRLCK && fl.l_type != F_UNLCK) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } if (fl.l_whence == SEEK_CUR) fl.l_start += fp->f_offset; 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)); @@ -390,6 +395,7 @@ do_dup(fdp, old, new, retval, p) register_t *retval; struct proc *p; { + struct thread *td = p->p_thread; struct file *fp; struct file *delfp; int holdleaders; @@ -431,7 +437,7 @@ do_dup(fdp, old, new, retval, p) * close() were performed on it). */ if (delfp) { - (void) closef(delfp, p); + (void) closef(delfp, td); if (holdleaders) { fdp->fd_holdleaderscount--; if (fdp->fd_holdleaderscount == 0 && @@ -547,7 +553,7 @@ fsetown(pgid, sigiop) sigio->sio_pgrp = pgrp; } sigio->sio_pgid = pgid; - crhold(curproc->p_ucred); + curproc->p_ucred = crhold(curproc->p_ucred); sigio->sio_ucred = curproc->p_ucred; /* It would be convenient if p_ruid was in ucred. */ sigio->sio_ruid = curproc->p_ucred->cr_ruid; @@ -580,13 +586,17 @@ struct close_args { int close(struct close_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; int fd = uap->fd; int error; int holdleaders; + KKASSERT(p); + fdp = p->p_fd; + if ((unsigned)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) return (EBADF); @@ -616,7 +626,7 @@ close(struct close_args *uap) fdp->fd_freefile = fd; if (fd < fdp->fd_knlistsize) knote_fdclose(p, fd); - error = closef(fp, p); + error = closef(fp, td); if (holdleaders) { fdp->fd_holdleaderscount--; if (fdp->fd_holdleaderscount == 0 && @@ -642,23 +652,26 @@ struct ofstat_args { int ofstat(struct ofstat_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct stat ub; struct ostat oub; int error; + KKASSERT(p); + fdp = p->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); 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); return (error); } #endif /* COMPAT_43 || COMPAT_SUNOS */ @@ -676,20 +689,23 @@ struct fstat_args { int fstat(struct fstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct stat ub; int error; + KKASSERT(p); + fdp = p->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); 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); return (error); } @@ -706,23 +722,26 @@ struct nfstat_args { int nfstat(struct nfstat_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct stat ub; struct nstat nub; int error; + KKASSERT(p); + fdp = p->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); 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); return (error); } @@ -739,12 +758,15 @@ struct fpathconf_args { int fpathconf(struct fpathconf_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp; struct vnode *vp; int error = 0; + KKASSERT(p); + fdp = p->p_fd; if ((unsigned)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); @@ -770,7 +792,7 @@ fpathconf(struct fpathconf_args *uap) error = EOPNOTSUPP; break; } - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -1083,6 +1105,7 @@ fdcopy(p) void fdfree(struct proc *p) { + struct thread *td = p->p_thread; struct filedesc *fdp = p->p_fd; struct file **fpp; int i; @@ -1123,7 +1146,7 @@ fdfree(struct proc *p) F_UNLCK, &lf, F_POSIX); - fdrop(fp, p); + fdrop(fp, p->p_thread); fpp = fdp->fd_ofiles + i; } } @@ -1170,7 +1193,7 @@ fdfree(struct proc *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); @@ -1212,9 +1235,9 @@ is_unsafe(struct file *fp) * Make this setguid thing safe, if at all possible. */ void -setugidsafety(p) - struct proc *p; +setugidsafety(struct proc *p) { + struct thread *td = p->p_thread; struct filedesc *fdp = p->p_fd; int i; @@ -1247,7 +1270,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) @@ -1258,9 +1281,9 @@ setugidsafety(p) * Close any files on exec? */ void -fdcloseexec(p) - struct proc *p; +fdcloseexec(struct proc *p) { + struct thread *td = p->p_thread; struct filedesc *fdp = p->p_fd; int i; @@ -1292,7 +1315,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) @@ -1307,14 +1330,14 @@ fdcloseexec(p) * stderr that is not already open. */ int -fdcheckstd(p) - struct proc *p; +fdcheckstd(struct proc *p) { - struct nameidata nd; - struct filedesc *fdp; - struct file *fp; - register_t retval; - int fd, i, error, flags, devnull; + struct thread *td = p->p_thread; + struct nameidata nd; + struct filedesc *fdp; + struct file *fp; + register_t retval; + int fd, i, error, flags, devnull; fdp = p->p_fd; if (fdp == NULL) @@ -1328,13 +1351,13 @@ fdcheckstd(p) error = falloc(p, &fp, &fd); if (error != 0) break; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/null", - p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, + "/dev/null", td); flags = FREAD | FWRITE; error = vn_open(&nd, flags, 0); if (error != 0) { fdp->fd_ofiles[i] = NULL; - fdrop(fp, p); + fdrop(fp, td); break; } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1342,7 +1365,7 @@ fdcheckstd(p) fp->f_flag = flags; fp->f_ops = &vnops; fp->f_type = DTYPE_VNODE; - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, 0, td); devnull = fd; } else { error = fdalloc(p, 0, &fd); @@ -1359,20 +1382,25 @@ fdcheckstd(p) /* * Internal form of close. * Decrement reference count on file structure. - * Note: p may be NULL when closing a file + * Note: td and/or p may be NULL when closing a file * that was being passed in a message. */ int -closef(fp, p) - struct file *fp; - struct proc *p; +closef(struct file *fp, struct thread *td) { struct vnode *vp; struct flock lf; struct filedesc_to_leader *fdtol; + struct proc *p; if (fp == NULL) return (0); + if (td == NULL) { + td = curthread; + p = NULL; /* allow no proc association */ + } else { + p = td->td_proc; /* can also be NULL */ + } /* * POSIX record locking dictates that any close releases ALL * locks owned by this process. This is handled by setting @@ -1422,13 +1450,11 @@ closef(fp, p) } } } - return (fdrop(fp, p)); + return (fdrop(fp, td)); } int -fdrop(fp, p) - struct file *fp; - struct proc *p; +fdrop(struct file *fp, struct thread *td) { struct flock lf; struct vnode *vp; @@ -1447,7 +1473,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); @@ -1582,7 +1608,7 @@ dupfdopen(struct filedesc *fdp, int indx, int dfd, int mode, int error) * used to own. Release it. */ if (fp) - fdrop(fp, curproc); + fdrop(fp, curthread); return (0); case ENXIO: @@ -1604,7 +1630,7 @@ dupfdopen(struct filedesc *fdp, int indx, int dfd, int mode, int error) * used to own. Release it. */ if (fp) - fdrop(fp, curproc); + fdrop(fp, curthread); /* * Complete the clean up of the filedesc structure by * recomputing the various hints. @@ -1722,64 +1748,43 @@ struct fileops badfileops = { }; static int -badfo_readwrite(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; -{ - +badfo_readwrite( + struct file *fp, + struct uio *uio, + struct ucred *cred, + int flags, + struct thread *td +) { return (EBADF); } static int -badfo_ioctl(fp, com, data, p) - struct file *fp; - u_long com; - caddr_t data; - struct proc *p; +badfo_ioctl(struct file *fp, u_long com, caddr_t data, struct thread *td) { - return (EBADF); } static int -badfo_poll(fp, events, cred, p) - struct file *fp; - int events; - struct ucred *cred; - struct proc *p; +badfo_poll(struct file *fp, int events, struct ucred *cred, struct thread *td) { - return (0); } static int -badfo_kqfilter(fp, kn) - struct file *fp; - struct knote *kn; +badfo_kqfilter(struct file *fp, struct knote *kn) { - return (0); } static int -badfo_stat(fp, sb, p) - struct file *fp; - struct stat *sb; - struct proc *p; +badfo_stat(struct file *fp, struct stat *sb, struct thread *td) { - return (EBADF); } static int -badfo_close(fp, p) - struct file *fp; - struct proc *p; +badfo_close(struct file *fp, struct thread *td) { - return (EBADF); } diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index a591e9691c..bbab221137 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_event.c,v 1.2.2.9 2003/05/08 07:47:16 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_event.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_event.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -56,16 +57,16 @@ static int kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, const struct timespec *timeout, struct proc *p); 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 = { @@ -79,7 +80,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); @@ -140,7 +141,6 @@ static struct filterops *sysfilt_ops[] = { static int filt_fileattach(struct knote *kn) { - return (fo_kqfilter(kn->kn_fp, kn)); } @@ -394,14 +394,18 @@ struct kevent_args { int kevent(struct kevent_args *uap) { - struct proc *p = curproc; - struct filedesc* fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct kevent *kevp; struct kqueue *kq; struct file *fp = NULL; struct timespec ts; int i, n, nerrors, error; + KKASSERT(p); + fdp = p->p_fd; + if (((u_int)uap->fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL || (fp->f_type != DTYPE_KQUEUE)) @@ -428,7 +432,7 @@ kevent(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; @@ -456,12 +460,12 @@ kevent(struct kevent_args *uap) error = kqueue_scan(fp, uap->nevents, uap->eventlist, uap->timeout, p); done: if (fp != NULL) - fdrop(fp, p); + fdrop(fp, p->p_thread); 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; @@ -544,7 +548,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 { @@ -565,7 +569,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; } @@ -587,7 +591,7 @@ kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) done: if (fp != NULL) - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -595,6 +599,7 @@ static int kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, const struct timespec *tsp, struct proc *p) { + struct thread *td = p->p_thread; struct kqueue *kq = (struct kqueue *)fp->f_data; struct kevent *kevp; struct timeval atv, rtv, ttv; @@ -686,7 +691,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; @@ -726,7 +731,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); } @@ -734,21 +739,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; @@ -758,7 +763,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->p_thread, &kq->kq_sel); + selrecord(td, &kq->kq_sel); kq->kq_state |= KQ_SEL; } } @@ -768,7 +773,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; @@ -781,13 +786,16 @@ 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 proc *p = td->td_proc; struct kqueue *kq = (struct kqueue *)fp->f_data; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp; struct knote **knp, *kn, *kn0; int i; + KKASSERT(p); + fdp = p->p_fd; for (i = 0; i < fdp->fd_knlistsize; i++) { knp = &SLIST_FIRST(&fdp->fd_knlist[i]); kn = *knp; @@ -795,7 +803,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 { @@ -860,13 +868,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); } } @@ -879,7 +887,7 @@ knote_fdclose(struct proc *p, int fd) struct filedesc *fdp = p->p_fd; struct klist *list = &fdp->fd_knlist[fd]; - knote_remove(p, list); + knote_remove(p->p_thread, list); } static void @@ -923,11 +931,13 @@ 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; struct klist *list; + KKASSERT(td->td_proc); + fdp = td->td_proc->p_fd; if (kn->kn_fop->f_isfd) list = &fdp->fd_knlist[kn->kn_id]; else @@ -937,7 +947,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 e18713641d..9b5aebef2b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_exec.c,v 1.107.2.15 2002/07/30 15:40:46 nectar Exp $ - * $DragonFly: src/sys/kern/kern_exec.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exec.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -103,7 +103,8 @@ struct execve_args { int execve(struct execve_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct nameidata nd, *ndp; register_t *stack_base; int error, len, i; @@ -111,6 +112,7 @@ execve(struct execve_args *uap) struct vattr attr; int (*img_first) __P((struct image_params *)); + KKASSERT(p); imgp = &image_params; /* @@ -158,7 +160,7 @@ execve(struct execve_args *uap) */ ndp = &nd; NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, - UIO_USERSPACE, uap->fname, p); + UIO_USERSPACE, uap->fname, td); interpret: @@ -177,12 +179,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; @@ -225,7 +227,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; } @@ -319,7 +321,7 @@ interpret: * we do not regain any tracing during a possible block. */ setsugid(); - if (p->p_tracep && suser()) { + if (p->p_tracep && suser(td)) { struct vnode *vtmp; if ((vtmp = p->p_tracep) != NULL) { @@ -743,10 +745,11 @@ exec_check_permissions(imgp) struct proc *p = imgp->proc; struct vnode *vp = imgp->vp; struct vattr *attr = imgp->attr; + struct thread *td = p->p_thread; int error; /* Get file attributes */ - error = VOP_GETATTR(vp, attr, p->p_ucred, p); + error = VOP_GETATTR(vp, attr, p->p_ucred, td); if (error) return (error); @@ -773,7 +776,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, td); if (error) return (error); @@ -788,7 +791,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, td); if (error) return (error); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 9fc452632b..c8b16d723f 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.9 2003/06/23 23:36:11 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.10 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -156,7 +156,7 @@ exit1(int rv) * XXX what if one of these generates an error? */ TAILQ_FOREACH(ep, &exit_list, next) - (*ep->function)(p); + (*ep->function)(p->p_thread); if (p->p_flag & P_PROFIL) stopprofclock(p); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 50651cacd6..acf9b1ae85 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -37,7 +37,7 @@ * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 * $FreeBSD: src/sys/kern/kern_fork.c,v 1.72.2.13 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.7 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.8 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ktrace.h" @@ -356,8 +356,7 @@ again: p2->p_flag = P_INMEM; if (p1->p_flag & P_PROFIL) startprofclock(p2); - crhold(p1->p_ucred); - p2->p_ucred = p1->p_ucred; + p2->p_ucred = crhold(p1->p_ucred); if (p2->p_ucred->cr_prison) { p2->p_ucred->cr_prison->pr_ref++; diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 8cdb815854..321490cb18 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -7,7 +7,7 @@ * ---------------------------------------------------------------------------- * * $FreeBSD: src/sys/kern/kern_jail.c,v 1.6.2.3 2001/08/17 01:00:26 rwatson Exp $ - * $DragonFly: src/sys/kern/kern_jail.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_jail.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ * */ @@ -57,9 +57,10 @@ jail(struct jail_args *uap) struct prison *pr; struct jail j; struct chroot_args ca; - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; - error = suser(); + error = suser(td); if (error) return (error); error = copyin(uap->jail, &j, sizeof j); @@ -91,12 +92,14 @@ bail: } int -prison_ip(struct proc *p, int flag, u_int32_t *ip) +prison_ip(struct thread *td, int flag, u_int32_t *ip) { u_int32_t tmp; struct prison *pr; - if ((pr = p->p_ucred->cr_prison) == NULL) + if (td->td_proc == NULL) + return (0); + if ((pr = td->td_proc->p_ucred->cr_prison) == NULL) return (0); if (flag) tmp = *ip; @@ -122,14 +125,14 @@ prison_ip(struct proc *p, int flag, u_int32_t *ip) } void -prison_remote_ip(struct proc *p, int flag, u_int32_t *ip) +prison_remote_ip(struct thread *td, int flag, u_int32_t *ip) { u_int32_t tmp; struct prison *pr; - if (p == NULL) + if (td == NULL || td->td_proc == NULL) return; - if ((pr = p->p_ucred->cr_prison) == NULL) + if ((pr = td->td_proc->p_ucred->cr_prison) == NULL) return; if (flag) tmp = *ip; @@ -140,19 +143,20 @@ prison_remote_ip(struct proc *p, int flag, u_int32_t *ip) *ip = pr->pr_ip; else *ip = htonl(pr->pr_ip); - return; } return; } int -prison_if(struct proc *p, struct sockaddr *sa) +prison_if(struct thread *td, struct sockaddr *sa) { struct prison *pr; struct sockaddr_in *sai = (struct sockaddr_in*) sa; int ok; - pr = p->p_ucred->cr_prison; + if (td->td_proc == NULL) + return(0); + pr = td->td_proc->p_ucred->cr_prison; if ((sai->sin_family != AF_INET) && jail_socket_unixiproute_only) ok = 1; diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 36aee9351c..6399f4b34a 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -32,7 +32,7 @@ * * @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/sys/kern/kern_ktrace.c,v 1.35.2.6 2002/07/05 22:36:38 darrenr Exp $ - * $DragonFly: src/sys/kern/kern_ktrace.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_ktrace.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ktrace.h" @@ -272,7 +272,8 @@ int ktrace(struct ktrace_args *uap) { #ifdef KTRACE - struct proc *curp = curproc; + struct thread *td = curthread; + struct proc *curp = td->td_proc; struct vnode *vp = NULL; struct proc *p; struct pgrp *pg; @@ -288,7 +289,7 @@ ktrace(struct ktrace_args *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); error = vn_open(&nd, FREAD|FWRITE|O_NOFOLLOW, 0); if (error) { curp->p_traceflag &= ~KTRFAC_ACTIVE; @@ -296,9 +297,9 @@ ktrace(struct ktrace_args *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); } @@ -314,7 +315,7 @@ ktrace(struct ktrace_args *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; } @@ -365,7 +366,7 @@ ktrace(struct ktrace_args *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 @@ -382,11 +383,12 @@ utrace(struct utrace_args *uap) { #ifdef KTRACE struct ktr_header *kth; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct vnode *vp; register caddr_t cp; - if (!KTRPOINT(p, KTR_USER)) + if (!KTRPOINT(td, KTR_USER)) return (0); if (SCARG(uap, len) > KTR_USER_MAXLEN) return (EINVAL); @@ -493,14 +495,12 @@ ktrsetchildren(curp, top, ops, facs, vp) } static void -ktrwrite(vp, kth, uio) - struct vnode *vp; - register struct ktr_header *kth; - struct uio *uio; +ktrwrite(struct vnode *vp, struct ktr_header *kth, struct uio *uio) { struct uio auio; struct iovec aiov[2]; - register struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; + struct proc *p = td->td_proc; /* XXX */ int error; if (vp == NULL) @@ -513,7 +513,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_buf; @@ -522,14 +522,14 @@ ktrwrite(vp, kth, uio) if (uio != NULL) kth->ktr_len += uio->uio_resid; } - 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); if (!error) return; /* diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 5dda4a9b84..0c626d5799 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_linker.c,v 1.41.2.3 2001/11/21 17:50:35 luigi Exp $ - * $DragonFly: src/sys/kern/kern_linker.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_linker.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ddb.h" @@ -318,14 +318,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); for (lf = TAILQ_FIRST(&linker_files); lf; lf = TAILQ_NEXT(lf, 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) @@ -338,11 +338,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); for (lf = TAILQ_FIRST(&linker_files); lf; lf = TAILQ_NEXT(lf, link)) if (lf->id == fileid) break; - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); return lf; } @@ -361,7 +361,7 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops) filename = 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); namelen = strlen(filename) + 1; lf = malloc(sizeof(struct linker_file) + namelen, M_LINKER, M_WAITOK); if (!lf) @@ -384,7 +384,7 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops) TAILQ_INSERT_TAIL(&linker_files, lf, link); out: - lockmgr(&lock, LK_RELEASE, 0, curproc); + lockmgr(&lock, LK_RELEASE, 0, curthread); return lf; } @@ -401,7 +401,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")); /* @@ -416,7 +416,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; } @@ -426,7 +426,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; } @@ -437,7 +437,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); for (i = 0; i < file->ndeps; i++) linker_file_unload(file->deps[i]); @@ -651,7 +651,8 @@ linker_ddb_symbol_values(c_linker_sym_t sym, linker_symval_t *symval) int kldload(struct kldload_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; char* filename = NULL, *modulename; linker_file_t lf; int error = 0; @@ -661,7 +662,7 @@ kldload(struct kldload_args *uap) if (securelevel > 0) /* redundant, but that's OK */ return EPERM; - if ((error = suser()) != 0) + if ((error = suser(td)) != 0) return error; filename = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); @@ -694,13 +695,14 @@ out: int kldunload(struct kldunload_args *uap) { + struct thread *td = curthread; linker_file_t lf; int error = 0; if (securelevel > 0) /* redundant, but that's OK */ return EPERM; - if ((error = suser()) != 0) + if ((error = suser(td)) != 0) return error; lf = linker_find_file_by_id(SCARG(uap, fileid)); @@ -1005,11 +1007,14 @@ char * linker_search_path(const char *name) { struct nameidata nd; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; + struct proc *p = td->td_proc; char *cp, *ep, *result; int error; enum vtype type; + KKASSERT(p != NULL); + /* qualified at all? */ if (index(name, '/')) return(linker_strdup(name)); @@ -1032,13 +1037,13 @@ linker_search_path(const char *name) * 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); error = vn_open(&nd, FREAD, 0); if (error == 0) { NDFREE(&nd, NDF_ONLY_PNBUF); type = nd.ni_vp->v_type; - 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); if (type == VREG) return(result); } diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 923544ae6f..8f0fd738d3 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -39,7 +39,7 @@ * * @(#)kern_lock.c 8.18 (Berkeley) 5/21/95 * $FreeBSD: src/sys/kern/kern_lock.c,v 1.31.2.3 2001/12/25 01:44:44 dillon Exp $ - * $DragonFly: src/sys/kern/kern_lock.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_lock.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_lint.h" @@ -55,9 +55,9 @@ */ #ifdef SIMPLELOCK_DEBUG -#define COUNT(p, x) if (p) (p)->p_locks += (x) +#define COUNT(td, x) (td)->td_locks += (x) #else -#define COUNT(p, x) +#define COUNT(td, x) #endif #define LOCK_WAIT_TIME 100 @@ -176,29 +176,17 @@ acquire(struct lock *lkp, int extflags, int wanted) { */ int #ifndef DEBUG_LOCKS -lockmgr(lkp, flags, interlkp, p) +lockmgr(struct lock *lkp, u_int flags, struct simplelock *interlkp, + struct thread *td) #else -debuglockmgr(lkp, flags, interlkp, p, name, file, line) -#endif - struct lock *lkp; - u_int flags; - struct simplelock *interlkp; - struct proc *p; -#ifdef DEBUG_LOCKS - const char *name; /* Name of lock function */ - const char *file; /* Name of file call is from */ - int line; /* Line number in file */ +debuglockmgr(struct lock *lkp, u_int flags, struct simplelock *interlkp, + struct thread *td, const char *name, const char *file, int line) #endif { int error; - pid_t pid; int extflags; error = 0; - if (p == NULL) - pid = LK_KERNPROC; - else - pid = p->p_pid; simple_lock(&lkp->lk_interlock); if (flags & LK_INTERLOCK) @@ -218,8 +206,8 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) * lock requests or upgrade requests ( but not the exclusive * lock itself ). */ - if (lkp->lk_lockholder != pid) { - if (p && (p->p_flag & P_DEADLKTREAT)) { + if (lkp->lk_lockholder != td) { + if (td->td_flags & TDF_DEADLKTREAT) { error = acquire( lkp, extflags, @@ -248,12 +236,12 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) /* fall into downgrade */ case LK_DOWNGRADE: - if (lkp->lk_lockholder != pid || lkp->lk_exclusivecount == 0) + if (lkp->lk_lockholder != td || lkp->lk_exclusivecount == 0) panic("lockmgr: not holding exclusive lock"); sharelock(lkp, lkp->lk_exclusivecount); lkp->lk_exclusivecount = 0; lkp->lk_flags &= ~LK_HAVE_EXCL; - lkp->lk_lockholder = LK_NOPROC; + lkp->lk_lockholder = LK_NOTHREAD; if (lkp->lk_waitcount) wakeup((void *)lkp); break; @@ -281,7 +269,7 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) * after the upgrade). If we return an error, the file * will always be unlocked. */ - if ((lkp->lk_lockholder == pid) || (lkp->lk_sharecount <= 0)) + if ((lkp->lk_lockholder == td) || (lkp->lk_sharecount <= 0)) panic("lockmgr: upgrade exclusive lock"); shareunlock(lkp, 1); COUNT(p, -1); @@ -307,7 +295,7 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) if (error) break; lkp->lk_flags |= LK_HAVE_EXCL; - lkp->lk_lockholder = pid; + lkp->lk_lockholder = td; if (lkp->lk_exclusivecount != 0) panic("lockmgr: non-zero exclusive count"); lkp->lk_exclusivecount = 1; @@ -330,7 +318,7 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) /* fall into exclusive request */ case LK_EXCLUSIVE: - if (lkp->lk_lockholder == pid && pid != LK_KERNPROC) { + if (lkp->lk_lockholder == td && td != LK_KERNTHREAD) { /* * Recursive lock. */ @@ -365,7 +353,7 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) if (error) break; lkp->lk_flags |= LK_HAVE_EXCL; - lkp->lk_lockholder = pid; + lkp->lk_lockholder = td; if (lkp->lk_exclusivecount != 0) panic("lockmgr: non-zero exclusive count"); lkp->lk_exclusivecount = 1; @@ -379,18 +367,19 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) case LK_RELEASE: if (lkp->lk_exclusivecount != 0) { - if (lkp->lk_lockholder != pid && - lkp->lk_lockholder != LK_KERNPROC) { - panic("lockmgr: pid %d, not %s %d unlocking", - pid, "exclusive lock holder", + if (lkp->lk_lockholder != td && + lkp->lk_lockholder != LK_KERNTHREAD) { + panic("lockmgr: pid %d, not %s thr %p unlocking", + (td->td_proc ? td->td_proc->p_pid : -99), + "exclusive lock holder", lkp->lk_lockholder); } - if (lkp->lk_lockholder != LK_KERNPROC) { + if (lkp->lk_lockholder != LK_KERNTHREAD) { COUNT(p, -1); } if (lkp->lk_exclusivecount == 1) { lkp->lk_flags &= ~LK_HAVE_EXCL; - lkp->lk_lockholder = LK_NOPROC; + lkp->lk_lockholder = LK_NOTHREAD; lkp->lk_exclusivecount = 0; } else { lkp->lk_exclusivecount--; @@ -410,14 +399,14 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) * check for holding a shared lock, but at least we can * check for an exclusive one. */ - if (lkp->lk_lockholder == pid) + if (lkp->lk_lockholder == td) panic("lockmgr: draining against myself"); error = acquiredrain(lkp, extflags); if (error) break; lkp->lk_flags |= LK_DRAINING | LK_HAVE_EXCL; - lkp->lk_lockholder = pid; + lkp->lk_lockholder = td; lkp->lk_exclusivecount = 1; #if defined(DEBUG_LOCKS) lkp->lk_filename = file; @@ -491,22 +480,20 @@ lockinit(lkp, prio, wmesg, timo, flags) lkp->lk_prio = prio; lkp->lk_wmesg = wmesg; lkp->lk_timo = timo; - lkp->lk_lockholder = LK_NOPROC; + lkp->lk_lockholder = LK_NOTHREAD; } /* * Determine the status of a lock. */ int -lockstatus(lkp, p) - struct lock *lkp; - struct proc *p; +lockstatus(struct lock *lkp, struct thread *td) { int lock_type = 0; simple_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) lock_type = LK_EXCLUSIVE; else lock_type = LK_EXCLOTHER; @@ -539,13 +526,21 @@ void lockmgr_printinfo(lkp) struct lock *lkp; { + struct thread *td = lkp->lk_lockholder; + struct proc *p; + + if (td && td != LK_KERNTHREAD && td != LK_NOTHREAD) + p = td->td_proc; + else + p = NULL; if (lkp->lk_sharecount) printf(" lock type %s: SHARED (count %d)", lkp->lk_wmesg, lkp->lk_sharecount); else if (lkp->lk_flags & LK_HAVE_EXCL) - printf(" lock type %s: EXCL (count %d) by pid %d", - lkp->lk_wmesg, lkp->lk_exclusivecount, lkp->lk_lockholder); + printf(" lock type %s: EXCL (count %d) by td %p pid %d", + lkp->lk_wmesg, lkp->lk_exclusivecount, td, + p ? p->p_pid : -99); if (lkp->lk_waitcount > 0) printf(" with %d pending", lkp->lk_waitcount); } diff --git a/sys/kern/kern_memio.c b/sys/kern/kern_memio.c index 96da393458..9982055ff1 100644 --- a/sys/kern/kern_memio.c +++ b/sys/kern/kern_memio.c @@ -39,7 +39,7 @@ * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/i386/mem.c,v 1.79.2.9 2003/01/04 22:58:01 njl Exp $ - * $DragonFly: src/sys/kern/kern_memio.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/kern/kern_memio.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -135,7 +135,7 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td) return (EPERM); break; case 14: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (securelevel > 0) @@ -440,7 +440,6 @@ mem_range_AP_init(void) static int random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - struct proc *p = td->td_proc; static intrmask_t interrupt_allowed; intrmask_t interrupt_mask; int error, intr; @@ -471,7 +470,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) case FIONBIO: break; case MEM_SETIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -488,7 +487,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_CLEARIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -502,7 +501,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_RETURNIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); *(u_int16_t *)data = interrupt_allowed; diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 836c9e20a7..f8a9a3a8ad 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -38,7 +38,7 @@ * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 * $FreeBSD: src/sys/kern/kern_mib.c,v 1.29.2.4 2001/07/30 23:28:00 peter Exp $ - * $DragonFly: src/sys/kern/kern_mib.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_mib.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -148,7 +148,8 @@ char hostname[MAXHOSTNAMELEN]; static int sysctl_hostname(SYSCTL_HANDLER_ARGS) { - struct proc *p = req->p; + struct thread *td = req->td; + struct proc *p = td ? td->td_proc : NULL; int error; if (p && p->p_ucred->cr_prison) { diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 3a8f154c0c..468cc13679 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -29,7 +29,7 @@ * confusing and/or plain wrong in that context. * * $FreeBSD: src/sys/kern/kern_ntptime.c,v 1.32.2.2 2001/04/22 11:19:46 jhay Exp $ - * $DragonFly: src/sys/kern/kern_ntptime.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_ntptime.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ntp.h" @@ -273,6 +273,7 @@ struct ntp_adjtime_args { int ntp_adjtime(struct ntp_adjtime_args *uap) { + struct thread *td = curthread; struct timex ntv; /* temporary structure */ long freq; /* frequency ns/s) */ int modes; /* mode bits from structure */ @@ -294,7 +295,7 @@ ntp_adjtime(struct ntp_adjtime_args *uap) */ modes = ntv.modes; if (modes) - error = suser(); + error = suser(td); if (error) return (error); s = splclock(); diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index f2d596c4ef..9215e7c93e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -37,7 +37,7 @@ * * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_prot.c,v 1.53.2.9 2002/03/09 05:20:26 dd Exp $ - * $DragonFly: src/sys/kern/kern_prot.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_prot.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -408,7 +408,7 @@ setuid(struct setuid_args *uap) #ifdef POSIX_APPENDIX_B_4_2_2 /* Use BSD-compat clause from B.4.2.2 */ uid != cr->cr_uid && /* allow setuid(geteuid()) */ #endif - (error = suser_xxx(0, PRISON_ROOT))) + (error = suser_cred(cr, PRISON_ROOT))) return (error); #ifdef _POSIX_SAVED_IDS @@ -420,7 +420,7 @@ setuid(struct setuid_args *uap) #ifdef POSIX_APPENDIX_B_4_2_2 /* Use the clause from B.4.2.2 */ uid == cr->cr_uid || #endif - suser_xxx(0, PRISON_ROOT) == 0) /* we are using privs */ + suser_cred(cr, PRISON_ROOT) == 0) /* we are using privs */ #endif { /* @@ -475,7 +475,7 @@ seteuid(struct seteuid_args *uap) euid = uap->euid; if (euid != cr->cr_ruid && /* allow seteuid(getuid()) */ euid != cr->cr_svuid && /* allow seteuid(saved uid) */ - (error = suser_xxx(0, PRISON_ROOT))) + (error = suser_cred(cr, PRISON_ROOT))) return (error); /* * Everything's okay, do it. Copy credentials so other references do @@ -525,7 +525,7 @@ setgid(struct setgid_args *uap) #ifdef POSIX_APPENDIX_B_4_2_2 /* Use BSD-compat clause from B.4.2.2 */ gid != cr->cr_groups[0] && /* allow setgid(getegid()) */ #endif - (error = suser_xxx(0, PRISON_ROOT))) + (error = suser_cred(cr, PRISON_ROOT))) return (error); #ifdef _POSIX_SAVED_IDS @@ -537,7 +537,7 @@ setgid(struct setgid_args *uap) #ifdef POSIX_APPENDIX_B_4_2_2 /* use the clause from B.4.2.2 */ gid == cr->cr_groups[0] || #endif - suser_xxx(0, PRISON_ROOT) == 0) /* we are using privs */ + suser_cred(cr, PRISON_ROOT) == 0) /* we are using privs */ #endif { /* @@ -592,7 +592,7 @@ setegid(struct setegid_args *uap) egid = uap->egid; if (egid != cr->cr_rgid && /* allow setegid(getgid()) */ egid != cr->cr_svgid && /* allow setegid(saved gid) */ - (error = suser_xxx(0, PRISON_ROOT))) + (error = suser_cred(cr, PRISON_ROOT))) return (error); if (cr->cr_groups[0] != egid) { cr = p->p_ucred = crcopy(cr); @@ -621,7 +621,7 @@ setgroups(struct setgroups_args *uap) return(EPERM); cr = p->p_ucred; - if ((error = suser_xxx(0, PRISON_ROOT))) + if ((error = suser_cred(cr, PRISON_ROOT))) return (error); ngrp = uap->gidsetsize; if (ngrp > NGROUPS) @@ -673,7 +673,7 @@ setreuid(struct setreuid_args *uap) if (((ruid != (uid_t)-1 && ruid != cr->cr_ruid && ruid != cr->cr_svuid) || (euid != (uid_t)-1 && euid != cr->cr_uid && euid != cr->cr_ruid && euid != cr->cr_svuid)) && - (error = suser_xxx(0, PRISON_ROOT)) != 0) + (error = suser_cred(cr, PRISON_ROOT)) != 0) return (error); if (euid != (uid_t)-1 && cr->cr_uid != euid) { @@ -717,7 +717,7 @@ setregid(struct setregid_args *uap) if (((rgid != (gid_t)-1 && rgid != cr->cr_rgid && rgid != cr->cr_svgid) || (egid != (gid_t)-1 && egid != cr->cr_groups[0] && egid != cr->cr_rgid && egid != cr->cr_svgid)) && - (error = suser_xxx(0, PRISON_ROOT)) != 0) + (error = suser_cred(cr, PRISON_ROOT)) != 0) return (error); if (egid != (gid_t)-1 && cr->cr_groups[0] != egid) { @@ -770,7 +770,7 @@ setresuid(struct setresuid_args *uap) euid != cr->cr_uid) || (suid != (uid_t)-1 && suid != cr->cr_ruid && suid != cr->cr_svuid && suid != cr->cr_uid)) && - (error = suser_xxx(0, PRISON_ROOT)) != 0) + (error = suser_cred(cr, PRISON_ROOT)) != 0) return (error); if (euid != (uid_t)-1 && cr->cr_uid != euid) { change_euid(euid); @@ -819,7 +819,7 @@ setresgid(struct setresgid_args *uap) egid != cr->cr_groups[0]) || (sgid != (gid_t)-1 && sgid != cr->cr_rgid && sgid != cr->cr_svgid && sgid != cr->cr_groups[0])) && - (error = suser_xxx(0, PRISON_ROOT)) != 0) + (error = suser_cred(cr, PRISON_ROOT)) != 0) return (error); if (egid != (gid_t)-1 && cr->cr_groups[0] != egid) { @@ -936,49 +936,35 @@ groupmember(gid_t gid, struct ucred *cred) /* * Test whether the specified credentials imply "super-user" * privilege; if so, and we have accounting info, set the flag - * indicating use of super-powers. + * indicating use of super-powers. A kernel thread without a process + * context is assumed to have super user capabilities. In situations + * where the caller always expect a cred to exist, the cred should be + * passed separately and suser_cred()should be used instead of suser(). + * * Returns 0 or error. */ int -suser(void) +suser(struct thread *td) { - struct proc *p = curthread->td_proc; + struct proc *p = td->td_proc; if (p != NULL) { - return suser_xxx(p->p_ucred, 0); + return suser_cred(p->p_ucred, 0); } else { - printf("suser(): wasn't run from a thread with a process context: %p\n", curthread); - return (EPERM); + return (0); } } int -suser_xxx(struct ucred *cred, int flag) +suser_cred(struct ucred *cred, int flag) { - struct proc *p = curthread->td_proc; + KASSERT(cred != NULL, ("suser_cred: NULL cred!")); - /* - * Either a cred or a process is required to check for - * superuser permissions (API enforcement). - */ - if (cred == NULL) { - if (p == NULL) { - printf("suser_xxx(): THINK!\n"); - return (EPERM); - } - cred = p->p_ucred; - } if (cred->cr_uid != 0) return (EPERM); if (cred->cr_prison && !(flag & PRISON_ROOT)) return (EPERM); - /* - * YYY for accounting only, but suser_xxx can be called from a - * different process with the cred for the original process and - * this will not work as expected YYY - */ - if (p) - p->p_acflag |= ASU; + /* NOTE: accounting for suser access (p_acflag/ASU) removed */ return (0); } @@ -1000,7 +986,7 @@ p_trespass(struct ucred *cr1, struct ucred *cr2) return (0); if (cr1->cr_uid == cr2->cr_uid) return (0); - if (!suser_xxx(cr1, PRISON_ROOT)) + if (suser_cred(cr1, PRISON_ROOT) == 0) return (0); return (EPERM); } @@ -1022,10 +1008,11 @@ crget() /* * Claim another reference to a ucred structure */ -void +struct ucred * crhold(struct ucred *cr) { cr->cr_ref++; + return(cr); } /* @@ -1161,7 +1148,7 @@ setlogin(struct setlogin_args *uap) char logintmp[MAXLOGNAME]; KKASSERT(p != NULL); - if ((error = suser_xxx(0, PRISON_ROOT))) + if ((error = suser_cred(p->p_ucred, PRISON_ROOT))) return (error); error = copyinstr((caddr_t) uap->namebuf, (caddr_t) logintmp, sizeof(logintmp), (size_t *)0); diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 86e1c5a095..e9f271df3a 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -37,7 +37,7 @@ * * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_resource.c,v 1.55.2.5 2001/11/03 01:41:08 ps Exp $ - * $DragonFly: src/sys/kern/kern_resource.c,v 1.5 2003/06/23 23:36:11 dillon Exp $ + * $DragonFly: src/sys/kern/kern_resource.c,v 1.6 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -212,7 +212,7 @@ donice(struct proc *chgp, int n) n = PRIO_MAX; if (n < PRIO_MIN) n = PRIO_MIN; - if (n < chgp->p_nice && suser()) + if (n < chgp->p_nice && suser_cred(cr, 0)) return (EACCES); chgp->p_nice = n; (void)resetpriority(chgp); @@ -263,7 +263,7 @@ rtprio(register struct rtprio_args *uap) cr->cr_ruid != p->p_ucred->cr_uid) return (EPERM); /* disallow setting rtprio in most cases if not superuser */ - if (suser()) { + if (suser_cred(cr, 0)) { /* can't set someone else's */ if (uap->pid) return (EPERM); @@ -389,7 +389,7 @@ dosetrlimit(u_int which, struct rlimit *limp) if (limp->rlim_cur > alimp->rlim_max || limp->rlim_max > alimp->rlim_max) - if ((error = suser_xxx(0, PRISON_ROOT))) + if ((error = suser_cred(p->p_ucred, PRISON_ROOT))) return (error); if (limp->rlim_cur > limp->rlim_max) limp->rlim_cur = limp->rlim_max; diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 94bf976f90..a2c1ad78f9 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -37,7 +37,7 @@ * * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_shutdown.c,v 1.72.2.12 2002/02/21 19:15:10 dillon Exp $ - * $DragonFly: src/sys/kern/kern_shutdown.c,v 1.5 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_shutdown.c,v 1.6 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ddb.h" @@ -141,9 +141,10 @@ SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) int reboot(struct reboot_args *uap) { + struct thread *td = curthread; int error; - if ((error = suser())) + if ((error = suser(td))) return (error); boot(uap->opt); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e0e5aa8c46..e62eeb2665 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -37,21 +37,22 @@ * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 * $FreeBSD: src/sys/kern/kern_sig.c,v 1.72.2.17 2003/05/16 16:34:34 obrien Exp $ - * $DragonFly: src/sys/kern/kern_sig.c,v 1.4 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_sig.c,v 1.5 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" #include "opt_ktrace.h" #include +#include #include #include #include #include -#include #include #include #include +#include #include #include #include @@ -923,13 +924,13 @@ trapsignal(p, sig, code) register int sig; u_long code; { - register struct sigacts *ps = p->p_sigacts; + struct sigacts *ps = p->p_sigacts; if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) && !SIGISMEMBER(p->p_sigmask, sig)) { p->p_stats->p_ru.ru_nsignals++; #ifdef KTRACE - if (KTRPOINT(p, KTR_PSIG)) + if (KTRPOINT(p->p_thread, KTR_PSIG)) ktrpsig(p->p_tracep, sig, ps->ps_sigact[_SIG_IDX(sig)], &p->p_sigmask, code); #endif @@ -1363,7 +1364,7 @@ postsig(sig) SIGDELSET(p->p_siglist, sig); action = ps->ps_sigact[_SIG_IDX(sig)]; #ifdef KTRACE - if (KTRPOINT(p, KTR_PSIG)) + if (KTRPOINT(p->p_thread, KTR_PSIG)) ktrpsig(p->p_tracep, sig, action, p->p_flag & P_OLDMASK ? &p->p_oldsigmask : &p->p_sigmask, 0); #endif @@ -1563,11 +1564,11 @@ const char *name; uid_t uid; pid_t pid; { */ static int -coredump(p) - register struct proc *p; +coredump(struct proc *p) { - register struct vnode *vp; - register struct ucred *cred = p->p_ucred; + struct vnode *vp; + struct ucred *cred = p->p_ucred; + struct thread *td = p->p_thread; struct flock lf; struct nameidata nd; struct vattr vattr; @@ -1595,7 +1596,7 @@ coredump(p) 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); error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR); free(name, M_TEMP); if (error) @@ -1603,7 +1604,7 @@ coredump(p) 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; @@ -1614,18 +1615,18 @@ coredump(p) /* 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); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 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); p->p_acflag |= ACORE; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); error = p->p_sysent->sv_coredump ? p->p_sysent->sv_coredump(p, vp, limit) : @@ -1635,7 +1636,7 @@ out1: lf.l_type = F_UNLCK; VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); out2: - error1 = vn_close(vp, FWRITE, cred, p); + error1 = vn_close(vp, FWRITE, cred, td); if (error == 0) error = error1; return (error); @@ -1663,9 +1664,7 @@ nosys(struct nosys_args *args) * stored credentials rather than those of the current process. */ void -pgsigio(sigio, sig, checkctty) - struct sigio *sigio; - int sig, checkctty; +pgsigio(struct sigio *sigio, int sig, int checkctty) { if (sigio == NULL) return; diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index cab26382ca..219b085f37 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -37,7 +37,7 @@ * * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_subr.c,v 1.31.2.2 2002/04/21 08:09:37 bde Exp $ - * $DragonFly: src/sys/kern/kern_subr.c,v 1.4 2003/06/23 23:36:11 dillon Exp $ + * $DragonFly: src/sys/kern/kern_subr.c,v 1.5 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -67,7 +67,7 @@ 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) { @@ -137,7 +137,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) { diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index d42aeb030a..7a0a360602 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -37,7 +37,7 @@ * * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 * $FreeBSD: src/sys/kern/kern_synch.c,v 1.87.2.6 2002/10/13 07:29:53 kbyanc Exp $ - * $DragonFly: src/sys/kern/kern_synch.c,v 1.7 2003/06/23 23:36:11 dillon Exp $ + * $DragonFly: src/sys/kern/kern_synch.c,v 1.8 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ktrace.h" @@ -418,13 +418,14 @@ tsleep(ident, priority, wmesg, timo) int priority, timo; const char *wmesg; { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int s, sig, catch = priority & PCATCH; int id = LOOKUP(ident); struct callout_handle thandle; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 1, 0); #endif s = splhigh(); @@ -484,7 +485,7 @@ resume: p->p_flag &= ~P_TIMEOUT; if (sig == 0) { #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif return (EWOULDBLOCK); @@ -493,7 +494,7 @@ resume: untimeout(endtsleep, (void *)p, thandle); if (catch && (sig != 0 || (sig = CURSIG(p)))) { #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) @@ -501,7 +502,7 @@ resume: return (ERESTART); } #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif return (0); @@ -524,12 +525,13 @@ resume: int xsleep(struct xwait *w, int priority, const char *wmesg, int timo, int *gen) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int s, sig, catch = priority & PCATCH; struct callout_handle thandle; #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 1, 0); #endif s = splhigh(); @@ -555,7 +557,7 @@ xsleep(struct xwait *w, int priority, const char *wmesg, int timo, int *gen) *gen = w->gen; splx(s); #ifdef KTRACE - if (p && KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif return(0); @@ -604,7 +606,7 @@ resume: p->p_flag &= ~P_TIMEOUT; if (sig == 0) { #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif return (EWOULDBLOCK); @@ -613,7 +615,7 @@ resume: untimeout(endtsleep, (void *)p, thandle); if (catch && (sig != 0 || (sig = CURSIG(p)))) { #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) @@ -621,7 +623,7 @@ resume: return (ERESTART); } #ifdef KTRACE - if (KTRPOINT(p, KTR_CSW)) + if (KTRPOINT(td, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); #endif return (0); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index d96667f845..771ca2332c 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -38,7 +38,7 @@ * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 * $FreeBSD: src/sys/kern/kern_sysctl.c,v 1.92.2.9 2003/05/01 22:48:09 trhodes Exp $ - * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -474,7 +474,7 @@ sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS) { int error; - error = suser_xxx(req->p->p_ucred, 0); + error = suser(req->td); if (error) return error; sysctl_sysctl_debug_dump_node(&sysctl__children, 0); @@ -888,7 +888,7 @@ kernel_sysctl(int *name, u_int namelen, void *old, size_t *oldlenp, void *new, s bzero(&req, sizeof req); - req.p = curproc; + req.td = curthread; if (oldlenp) { req.oldlen = *oldlenp; @@ -1051,7 +1051,8 @@ sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int sysctl_root(SYSCTL_HANDLER_ARGS) { - struct proc *p = req->p; + struct thread *td = req->td; + struct proc *p = td ? td->td_proc : NULL; struct sysctl_oid *oid; int error, indx; @@ -1076,7 +1077,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) /* Most likely only root can write */ if (!(oid->oid_kind & CTLFLAG_ANYBODY) && p && - (error = suser_xxx(p->p_ucred, + (error = suser_cred(p->p_ucred, (oid->oid_kind & CTLFLAG_PRISON) ? PRISON_ROOT : 0))) return (error); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index aa73131653..7d761599d1 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -32,7 +32,7 @@ * * @(#)kern_time.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/kern/kern_time.c,v 1.68.2.1 2002/10/01 08:00:41 bde Exp $ - * $DragonFly: src/sys/kern/kern_time.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_time.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -167,11 +167,12 @@ struct clock_settime_args { int clock_settime(struct clock_settime_args *uap) { + struct thread *td = curthread; struct timeval atv; struct timespec ats; int error; - if ((error = suser()) != 0) + if ((error = suser(td)) != 0) return (error); if (SCARG(uap, clock_id) != CLOCK_REALTIME) return (EINVAL); @@ -319,11 +320,12 @@ struct settimeofday_args { int settimeofday(struct settimeofday_args *uap) { + struct thread *td = curthread; struct timeval atv; struct timezone atz; int error; - if ((error = suser())) + if ((error = suser(td))) return (error); /* Verify all parameters before changing time. */ if (uap->tv) { @@ -357,11 +359,12 @@ struct adjtime_args { int adjtime(struct adjtime_args *uap) { + struct thread *td = curthread; struct timeval atv; - register long ndelta, ntickdelta, odelta; + long ndelta, ntickdelta, odelta; int s, error; - if ((error = suser())) + if ((error = suser(td))) return (error); if ((error = copyin((caddr_t)uap->delta, (caddr_t)&atv, sizeof(struct timeval)))) diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 26a8a82fdd..b7cc456097 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -32,7 +32,7 @@ * * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93 * $FreeBSD: src/sys/kern/kern_xxx.c,v 1.31 1999/08/28 00:46:15 peter Exp $ - * $DragonFly: src/sys/kern/kern_xxx.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/kern_xxx.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -77,15 +77,17 @@ struct sethostname_args { int osethostname(struct sethostname_args *uap) { + struct thread *td = curthread; + struct proc *p = td->td_proc; int name[2]; int error; + KKASSERT(p); name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - if ((error = suser_xxx(0, PRISON_ROOT))) + if ((error = suser_cred(p->p_ucred, PRISON_ROOT))) return (error); - return (userland_sysctl(name, 2, 0, 0, 0, - uap->hostname, uap->len, 0)); + return (userland_sysctl(name, 2, 0, 0, 0, uap->hostname, uap->len, 0)); } #ifndef _SYS_SYSPROTO_H_ @@ -114,9 +116,10 @@ struct osethostid_args { int osethostid(struct osethostid_args *uap) { + struct thread *td = curthread; int error; - if ((error = suser())) + if ((error = suser(td))) return (error); hostid = uap->hostid; return (0); @@ -227,9 +230,10 @@ struct setdomainname_args { int setdomainname(struct setdomainname_args *uap) { + struct thread *td = curthread; int error, domainnamelen; - if ((error = suser())) + if ((error = suser(td))) return (error); if ((u_int)uap->len > sizeof (domainname) - 1) return EINVAL; diff --git a/sys/kern/link_aout.c b/sys/kern/link_aout.c index 26baa926c1..3d17201eff 100644 --- a/sys/kern/link_aout.c +++ b/sys/kern/link_aout.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/link_aout.c,v 1.26 1999/12/24 15:33:36 bde Exp $ - * $DragonFly: src/sys/kern/link_aout.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/link_aout.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #ifndef __alpha__ @@ -188,7 +188,8 @@ static int link_aout_load_file(const char* filename, linker_file_t* result) { struct nameidata nd; - struct proc* p = curproc; /* XXX */ + struct thread *td = curthread; + struct proc *p = td->td_proc; int error = 0; int resid; struct exec header; @@ -196,10 +197,12 @@ link_aout_load_file(const char* filename, linker_file_t* result) linker_file_t lf; char *pathname; + KKASSERT(p != NULL); + pathname = linker_search_path(filename); if (pathname == NULL) return ENOENT; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, pathname, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, pathname, td); error = vn_open(&nd, FREAD, 0); free(pathname, M_LINKER); if (error) @@ -210,7 +213,7 @@ link_aout_load_file(const char* filename, linker_file_t* result) * 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; @@ -230,7 +233,7 @@ link_aout_load_file(const char* filename, linker_file_t* result) */ 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 +270,8 @@ link_aout_load_file(const char* filename, linker_file_t* result) *result = lf; out: - 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 310d06e887..ae207129bb 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/link_elf.c,v 1.24 1999/12/24 15:33:36 bde Exp $ - * $DragonFly: src/sys/kern/link_elf.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/link_elf.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -392,7 +392,8 @@ static int link_elf_load_file(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; Elf_Ehdr *hdr; caddr_t firstpage; int nbytes, i; @@ -418,14 +419,14 @@ link_elf_load_file(const char* filename, linker_file_t* result) int symcnt; int strcnt; + KKASSERT(p != NULL); shdr = NULL; lf = NULL; - pathname = linker_search_path(filename); if (pathname == NULL) return ENOENT; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, pathname, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, pathname, td); error = vn_open(&nd, FREAD, 0); free(pathname, M_LINKER); if (error) @@ -442,7 +443,7 @@ link_elf_load_file(const char* filename, linker_file_t* result) } 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; @@ -567,7 +568,7 @@ link_elf_load_file(const char* filename, linker_file_t* result) 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) { #ifdef SPARSE_MAPPING vm_map_remove(kernel_map, (vm_offset_t) ef->address, @@ -635,7 +636,7 @@ link_elf_load_file(const char* filename, linker_file_t* result) bzero(shdr, nbytes); 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; @@ -660,12 +661,12 @@ link_elf_load_file(const char* filename, linker_file_t* result) } 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; @@ -687,8 +688,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/subr_prf.c b/sys/kern/subr_prf.c index 5a7eafd4ac..3af37ed1dc 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -37,7 +37,7 @@ * * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/subr_prf.c,v 1.61.2.5 2002/08/31 18:22:08 dwmalone Exp $ - * $DragonFly: src/sys/kern/subr_prf.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/subr_prf.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -133,11 +133,10 @@ uprintf(const char *fmt, ...) } tpr_t -tprintf_open(p) - register struct proc *p; +tprintf_open(struct proc *p) { - if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { + if ((p->p_flag & P_CONTROLT) && p->p_session->s_ttyvp) { SESSHOLD(p->p_session); return ((tpr_t) p->p_session); } @@ -145,10 +144,8 @@ tprintf_open(p) } void -tprintf_close(sess) - tpr_t sess; +tprintf_close(tpr_t sess) { - if (sess) SESSRELE((struct session *) sess); } diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 2881f7f286..6161a96c49 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -37,7 +37,7 @@ * * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/sys_generic.c,v 1.55.2.10 2001/03/17 10:39:32 peter Exp $ - * $DragonFly: src/sys/kern/sys_generic.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/sys_generic.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ktrace.h" @@ -65,6 +65,7 @@ #endif #include #include +#include #include @@ -108,14 +109,16 @@ struct read_args { int read(struct read_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) == NULL) return (EBADF); error = dofileread(fp, uap->fd, uap->buf, uap->nbyte, (off_t)-1, 0); - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -134,10 +137,12 @@ struct pread_args { int pread(struct pread_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); if ((fp = holdfp(p->p_fd, uap->fd, FREAD)) == NULL) return (EBADF); if (fp->f_type != DTYPE_VNODE) { @@ -146,7 +151,7 @@ pread(struct pread_args *uap) error = dofileread(fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); } - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -161,7 +166,8 @@ dofileread(fp, fd, buf, nbyte, offset, flags) size_t nbyte; off_t offset; { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct uio auio; struct iovec aiov; long cnt, error = 0; @@ -181,12 +187,12 @@ dofileread(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, KTR_GENIO)) { ktriov = aiov; ktruio = auio; didktr = 1; @@ -194,7 +200,7 @@ dofileread(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,7 +230,8 @@ struct readv_args { int readv(struct readv_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct filedesc *fdp = p->p_fd; struct uio auio; @@ -255,7 +262,7 @@ readv(struct readv_args *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; @@ -272,14 +279,14 @@ readv(struct readv_args *uap) /* * if tracing, save a copy of iovec */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td, 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; @@ -298,7 +305,7 @@ readv(struct readv_args *uap) #endif p->p_retval[0] = cnt; done: - fdrop(fp, p); + fdrop(fp, td); if (needfree) FREE(needfree, M_IOV); return (error); @@ -317,14 +324,17 @@ struct write_args { int write(struct write_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); + if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) == NULL) return (EBADF); error = dofilewrite(fp, uap->fd, uap->buf, uap->nbyte, (off_t)-1, 0); - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -343,10 +353,12 @@ struct pwrite_args { int pwrite(struct pwrite_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) == NULL) return (EBADF); if (fp->f_type != DTYPE_VNODE) { @@ -355,7 +367,7 @@ pwrite(struct pwrite_args *uap) error = dofilewrite(fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); } - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -368,7 +380,8 @@ dofilewrite( off_t offset, int flags ) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct uio auio; struct iovec aiov; long cnt, error = 0; @@ -388,12 +401,12 @@ dofilewrite( 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, KTR_GENIO)) { ktriov = aiov; ktruio = auio; didktr = 1; @@ -402,7 +415,7 @@ dofilewrite( 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; @@ -434,9 +447,10 @@ struct writev_args { int writev(struct writev_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp; struct uio auio; struct iovec *iov; struct iovec *needfree; @@ -448,6 +462,9 @@ writev(struct writev_args *uap) struct uio ktruio; #endif + KKASSERT(p); + fdp = p->p_fd; + if ((fp = holdfp(fdp, uap->fd, FWRITE)) == NULL) return (EBADF); /* note: can't use iovlen until iovcnt is validated */ @@ -468,7 +485,7 @@ writev(struct writev_args *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; @@ -485,7 +502,7 @@ writev(struct writev_args *uap) /* * if tracing, save a copy of iovec and uio */ - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td, KTR_GENIO)) { MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); ktruio = auio; @@ -494,7 +511,7 @@ writev(struct writev_args *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; @@ -515,7 +532,7 @@ writev(struct writev_args *uap) #endif p->p_retval[0] = cnt; done: - fdrop(fp, p); + fdrop(fp, td); if (needfree) FREE(needfree, M_IOV); return (error); @@ -535,7 +552,8 @@ struct ioctl_args { int ioctl(struct ioctl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct filedesc *fdp; u_long com; @@ -549,6 +567,7 @@ ioctl(struct ioctl_args *uap) long align; } ubuf; + KKASSERT(p); fdp = p->p_fd; if ((u_int)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) @@ -589,7 +608,7 @@ ioctl(struct ioctl_args *uap) if (error) { if (memp) free(memp, M_IOCTLOPS); - fdrop(fp, p); + fdrop(fp, td); return (error); } } else { @@ -612,7 +631,7 @@ ioctl(struct ioctl_args *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: @@ -620,11 +639,11 @@ ioctl(struct ioctl_args *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. @@ -635,7 +654,7 @@ ioctl(struct ioctl_args *uap) } if (memp) free(memp, M_IOCTLOPS); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -786,11 +805,9 @@ done: } static int -selscan(p, ibits, obits, nfd) - struct proc *p; - fd_mask **ibits, **obits; - int nfd; +selscan(struct proc *p, fd_mask **ibits, fd_mask **obits, int nfd) { + struct thread *td = p->p_thread; struct filedesc *fdp = p->p_fd; int msk, i, fd; fd_mask bits; @@ -811,7 +828,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++; @@ -920,12 +937,10 @@ out: } static int -pollscan(p, fds, nfd) - struct proc *p; - struct pollfd *fds; - u_int nfd; +pollscan(struct proc *p, struct pollfd *fds, u_int nfd) { - register struct filedesc *fdp = p->p_fd; + struct thread *td = p->p_thread; + struct filedesc *fdp = p->p_fd; int i; struct file *fp; int n = 0; @@ -947,7 +962,7 @@ 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++; } diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 5c1115e12d..25297ef0cf 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -17,7 +17,7 @@ * are met. * * $FreeBSD: src/sys/kern/sys_pipe.c,v 1.60.2.13 2002/08/05 15:05:15 des Exp $ - * $DragonFly: src/sys/kern/sys_pipe.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/sys_pipe.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -79,6 +79,8 @@ #include #include +#include + /* * Use this define if you want to disable *fancy* VM things. Expect an * approx 30% decrease in transfer rate. This could be useful for @@ -90,15 +92,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, @@ -170,12 +172,16 @@ static vm_zone_t pipe_zone; int pipe(struct pipe_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *rf, *wf; struct pipe *rpipe, *wpipe; int fd, error; + KKASSERT(p); + fdp = p->p_fd; + if (pipe_zone == NULL) pipe_zone = zinit("PIPE", sizeof(struct pipe), 0, 0, 4); @@ -212,9 +218,9 @@ pipe(struct pipe_args *uap) if (error) { if (fdp->fd_ofiles[p->p_retval[0]] == rf) { fdp->fd_ofiles[p->p_retval[0]] = NULL; - fdrop(rf, p); + fdrop(rf, td); } - fdrop(rf, p); + fdrop(rf, td); /* rpipe has been closed by fdrop(). */ pipeclose(wpipe); return (error); @@ -227,7 +233,7 @@ pipe(struct pipe_args *uap) rpipe->pipe_peer = wpipe; wpipe->pipe_peer = rpipe; - fdrop(rf, p); + fdrop(rf, td); return (0); } @@ -387,12 +393,8 @@ pipeselwakeup(cpipe) /* ARGSUSED */ static int -pipe_read(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; +pipe_read(struct file *fp, struct uio *uio, struct ucred *cred, + int flags, struct thread *td) { struct pipe *rpipe = (struct pipe *) fp->f_data; int error; @@ -749,12 +751,8 @@ error1: #endif static int -pipe_write(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; +pipe_write(struct file *fp, struct uio *uio, struct ucred *cred, + int flags, struct thread *td) { int error = 0; int orig_resid; @@ -1023,11 +1021,7 @@ 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) - struct file *fp; - u_long cmd; - caddr_t data; - struct proc *p; +pipe_ioctl(struct file *fp, u_long cmd, caddr_t data, struct thread *td) { struct pipe *mpipe = (struct pipe *)fp->f_data; @@ -1072,11 +1066,7 @@ pipe_ioctl(fp, cmd, data, p) } int -pipe_poll(fp, events, cred, p) - struct file *fp; - int events; - struct ucred *cred; - struct proc *p; +pipe_poll(struct file *fp, int events, struct ucred *cred, struct thread *td) { struct pipe *rpipe = (struct pipe *)fp->f_data; struct pipe *wpipe; @@ -1102,12 +1092,12 @@ pipe_poll(fp, events, cred, p) if (revents == 0) { if (events & (POLLIN | POLLRDNORM)) { - selrecord(p->p_thread, &rpipe->pipe_sel); + selrecord(td, &rpipe->pipe_sel); rpipe->pipe_state |= PIPE_SEL; } if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p->p_thread, &wpipe->pipe_sel); + selrecord(td, &wpipe->pipe_sel); wpipe->pipe_state |= PIPE_SEL; } } @@ -1116,10 +1106,7 @@ pipe_poll(fp, events, cred, p) } static int -pipe_stat(fp, ub, p) - struct file *fp; - struct stat *ub; - struct proc *p; +pipe_stat(struct file *fp, struct stat *ub, struct thread *td) { struct pipe *pipe = (struct pipe *)fp->f_data; @@ -1141,9 +1128,7 @@ pipe_stat(fp, ub, p) /* ARGSUSED */ static int -pipe_close(fp, p) - struct file *fp; - struct proc *p; +pipe_close(struct file *fp, struct thread *td) { struct pipe *cpipe = (struct pipe *)fp->f_data; @@ -1155,8 +1140,7 @@ pipe_close(fp, p) } static void -pipe_free_kmem(cpipe) - struct pipe *cpipe; +pipe_free_kmem(struct pipe *cpipe) { if (cpipe->pipe_buffer.buffer != NULL) { @@ -1186,8 +1170,7 @@ pipe_free_kmem(cpipe) * shutdown the pipe */ static void -pipeclose(cpipe) - struct pipe *cpipe; +pipeclose(struct pipe *cpipe) { struct pipe *ppipe; diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 7592debfe4..39c96af366 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $ - * $DragonFly: src/sys/kern/sys_process.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/sys_process.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -318,7 +318,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) /* not owned by you, has done setuid (unless you're root) */ if ((p->p_ucred->cr_ruid != curp->p_ucred->cr_ruid) || (p->p_flag & P_SUGID)) { - if ((error = suser()) != 0) + if ((error = suser(curp->p_thread)) != 0) return error; } @@ -471,7 +471,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) uio.uio_resid = sizeof(int); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = p; + uio.uio_td = p->p_thread; error = procfs_domem(curp, p, NULL, &uio); if (uio.uio_resid != 0) { /* @@ -499,7 +499,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) uio.uio_offset = (off_t)(uintptr_t)piod->piod_offs; uio.uio_resid = piod->piod_len; uio.uio_segflg = UIO_USERSPACE; - uio.uio_procp = p; + uio.uio_td = p->p_thread; switch (piod->piod_op) { case PIOD_READ_D: case PIOD_READ_I: @@ -541,7 +541,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) uio.uio_resid = sizeof(struct reg); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = curp->p_thread; return (procfs_doregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETREGS) || defined(PT_GETREGS) */ @@ -567,7 +567,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) uio.uio_resid = sizeof(struct fpreg); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = curp->p_thread; return (procfs_dofpregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETFPREGS) || defined(PT_GETFPREGS) */ @@ -593,7 +593,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data) uio.uio_resid = sizeof(struct dbreg); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = curp; + uio.uio_td = curp->p_thread; 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 4af6d7f721..3e6f86ee23 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -32,7 +32,7 @@ * * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/kern/sys_socket.c,v 1.28.2.2 2001/02/26 04:23:16 jlemon Exp $ - * $DragonFly: src/sys/kern/sys_socket.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/sys_socket.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -58,37 +58,33 @@ struct fileops socketops = { /* ARGSUSED */ int -soo_read(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; -{ +soo_read( + struct file *fp, + struct uio *uio, + struct ucred *cred, + int flags, + struct thread *td +) { struct socket *so = (struct socket *)fp->f_data; return so->so_proto->pr_usrreqs->pru_soreceive(so, 0, uio, 0, 0, 0); } /* ARGSUSED */ int -soo_write(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; -{ +soo_write( + struct file *fp, + struct uio *uio, + struct ucred *cred, + int flags, + struct thread *td +) { 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) - struct file *fp; - u_long cmd; - register caddr_t data; - struct proc *p; +soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct thread *td) { register struct socket *so = (struct socket *)fp->f_data; @@ -141,28 +137,21 @@ 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, p)); - return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, p)); + return (rtioctl(cmd, data, td)); + return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, td)); } int -soo_poll(fp, events, cred, p) - struct file *fp; - int events; - struct ucred *cred; - struct proc *p; +soo_poll(struct file *fp, int events, struct ucred *cred, 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) - struct file *fp; - struct stat *ub; - struct proc *p; +soo_stat(struct file *fp, struct stat *ub, struct thread *td) { struct socket *so = (struct socket *)fp->f_data; @@ -185,9 +174,7 @@ soo_stat(fp, ub, p) /* ARGSUSED */ int -soo_close(fp, p) - struct file *fp; - struct proc *p; +soo_close(struct file *fp, struct thread *td) { int error = 0; diff --git a/sys/kern/sysv_ipc.c b/sys/kern/sysv_ipc.c index 7abdd7e74a..95703dbc56 100644 --- a/sys/kern/sysv_ipc.c +++ b/sys/kern/sysv_ipc.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/kern/sysv_ipc.c,v 1.13.2.2 2000/07/01 14:33:49 bsd Exp $ */ -/* $DragonFly: src/sys/kern/sysv_ipc.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ */ +/* $DragonFly: src/sys/kern/sysv_ipc.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */ /* @@ -53,7 +53,7 @@ ipcperm(struct proc *p, struct ipc_perm *perm, int mode) /* Check for user match. */ if (cred->cr_uid != perm->cuid && cred->cr_uid != perm->uid) { if (mode & IPC_M) - return (suser() == 0 ? 0 : EPERM); + return (suser_cred(cred, 0) == 0 ? 0 : EPERM); /* Check for group match. */ mode >>= 3; if (!groupmember(perm->gid, cred) && @@ -64,7 +64,8 @@ ipcperm(struct proc *p, struct ipc_perm *perm, int mode) if (mode & IPC_M) return (0); - return ((mode & perm->mode) == mode || suser() == 0 ? 0 : EACCES); + return ((mode & perm->mode) == mode || + suser_cred(cred, 0) == 0 ? 0 : EACCES); } #endif /* defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG) */ diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index 591866da90..731c5c3983 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/kern/sysv_msg.c,v 1.23.2.5 2002/12/31 08:54:53 maxim Exp $ */ -/* $DragonFly: src/sys/kern/sysv_msg.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ */ +/* $DragonFly: src/sys/kern/sysv_msg.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* * Implementation of SVID messages @@ -248,7 +248,8 @@ struct msgctl_args { int msgctl(struct msgctl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int msqid = uap->msqid; int cmd = uap->cmd; struct msqid_ds *user_msqptr = uap->buf; @@ -329,7 +330,7 @@ msgctl(struct msgctl_args *uap) if ((eval = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0) return(eval); if (msqbuf.msg_qbytes > msqptr->msg_qbytes) { - eval = suser(); + eval = suser(td); if (eval) return(eval); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index b8bbd11aea..aecffaa50c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -37,7 +37,7 @@ * * @(#)tty.c 8.8 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/tty.c,v 1.129.2.5 2002/03/11 01:32:31 dd Exp $ - * $DragonFly: src/sys/kern/tty.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/tty.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /*- @@ -700,15 +700,14 @@ ttyoutput(c, tp) */ /* ARGSUSED */ int -ttioctl(tp, cmd, data, flag) - struct tty *tp; - u_long cmd; - int flag; - void *data; +ttioctl(struct tty *tp, u_long cmd, void *data, int flag) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int s, error; + KKASSERT(p); + /* If the ioctl involves modification, hang if in the background. */ switch (cmd) { case TIOCCBRK: @@ -813,7 +812,7 @@ ttioctl(tp, cmd, data, flag) ISSET(constty->t_state, TS_CONNECTED)) return (EBUSY); #ifndef UCONSOLE - if ((error = suser()) != 0) + if ((error = suser(td)) != 0) return (error); #endif constty = tp; @@ -985,9 +984,9 @@ ttioctl(tp, cmd, data, flag) splx(s); break; case TIOCSTI: /* simulate terminal input */ - if ((flag & FREAD) == 0 && suser()) + if ((flag & FREAD) == 0 && suser(td)) return (EPERM); - if (!isctty(p, tp) && suser()) + if (!isctty(p, tp) && suser(td)) return (EACCES); s = spltty(); (*linesw[tp->t_line].l_rint)(*(u_char *)data, tp); @@ -1035,7 +1034,7 @@ ttioctl(tp, cmd, data, flag) } break; case TIOCSDRAINWAIT: - error = suser(); + error = suser(td); if (error) return (error); tp->t_timeout = *(int *)data * hz; diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 04ff56fc08..f14741348a 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -37,7 +37,7 @@ * * from: @(#)cons.c 7.2 (Berkeley) 5/9/91 * $FreeBSD: src/sys/kern/tty_cons.c,v 1.81.2.4 2001/12/17 18:44:41 guido Exp $ - * $DragonFly: src/sys/kern/tty_cons.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/tty_cons.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ddb.h" @@ -388,7 +388,7 @@ cnioctl(dev, cmd, data, flag, td) * output from the "virtual" console. */ if (cmd == TIOCCONS && constty) { - error = suser_xxx(td->td_proc->p_ucred, 0); + error = suser(td); if (error) return (error); constty = NULL; diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 9bb351882a..142d90fbf0 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -32,7 +32,7 @@ * * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95 * $FreeBSD: src/sys/kern/tty_pty.c,v 1.74.2.4 2002/02/20 19:58:13 dillon Exp $ - * $DragonFly: src/sys/kern/tty_pty.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/tty_pty.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -204,7 +204,7 @@ ptsopen(dev_t dev, int flag, int devtype, struct thread *td) 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()) { + } else if (tp->t_state & TS_XCLUDE && suser(td)) { return (EBUSY); } else if (pti->pt_prison != p->p_ucred->cr_prison) { return (EBUSY); diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index 7074c144b8..0c435266dd 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -32,7 +32,7 @@ * * @(#)tty_tty.c 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/sys/kern/tty_tty.c,v 1.30 1999/09/25 18:24:24 phk Exp $ - * $DragonFly: src/sys/kern/tty_tty.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/tty_tty.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -77,20 +77,18 @@ struct cdevsw ctty_cdevsw = { /*ARGSUSED*/ static int -cttyopen(dev, flag, mode, td) - dev_t dev; - int flag, mode; - struct thread *td; +cttyopen(dev_t dev, int flag, int mode, struct thread *td) { + struct proc *p = td->td_proc; struct vnode *ttyvp; int error; - KKASSERT(td->td_proc != NULL); - ttyvp = cttyvp(td->td_proc); + KKASSERT(p); + ttyvp = cttyvp(p); if (ttyvp == NULL) return (ENXIO); - vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td->td_proc); + vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td); #ifdef PARANOID /* * Since group is tty and mode is 620 on most terminal lines @@ -101,11 +99,11 @@ cttyopen(dev, flag, mode, td) * to delete this test. (mckusick 5/93) */ error = VOP_ACCESS(ttyvp, - (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, p); + (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, td); if (!error) #endif /* PARANOID */ - error = VOP_OPEN(ttyvp, flag, NOCRED, td->td_proc); - VOP_UNLOCK(ttyvp, 0, td->td_proc); + error = VOP_OPEN(ttyvp, flag, NOCRED, td); + VOP_UNLOCK(ttyvp, 0, td); return (error); } @@ -116,15 +114,18 @@ 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; + struct proc *p = td->td_proc; + struct vnode *ttyvp; int error; + KKASSERT(p); + ttyvp = cttyvp(p); 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); } @@ -135,15 +136,18 @@ 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 proc *p = td->td_proc; + struct vnode *ttyvp; int error; + KKASSERT(p); + ttyvp = cttyvp(p); if (ttyvp == NULL) return (EIO); - 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); return (error); } @@ -157,38 +161,37 @@ cttyioctl(dev, cmd, addr, flag, td) struct thread *td; { struct vnode *ttyvp; + struct proc *p = td->td_proc; - KKASSERT(td->td_proc != NULL); - ttyvp = cttyvp(td->td_proc); + KKASSERT(p); + ttyvp = cttyvp(p); 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(td->td_proc)) { - td->td_proc->p_flag &= ~P_CONTROLT; + if (!SESS_LEADER(p)) { + p->p_flag &= ~P_CONTROLT; return (0); } else return (EINVAL); } - return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, td->td_proc)); + return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED, td)); } /*ARGSUSED*/ static int -cttypoll(dev, events, td) - dev_t dev; - int events; - struct thread *td; +cttypoll(dev_t dev, int events, struct thread *td) { struct vnode *ttyvp; + struct proc *p = td->td_proc; - KKASSERT(td->td_proc != NULL); - ttyvp = cttyvp(td->td_proc); + KKASSERT(p); + ttyvp = cttyvp(p); if (ttyvp == NULL) /* try operation to get EOF/failure */ return (seltrue(dev, events, td)); - return (VOP_POLL(ttyvp, events, td->td_proc->p_ucred, td->td_proc)); + return (VOP_POLL(ttyvp, events, p->p_ucred, td)); } static void ctty_drvinit __P((void *unused)); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 6d6e8cf021..ceef87f4c1 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -32,7 +32,7 @@ * * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 * $FreeBSD: src/sys/kern/uipc_socket.c,v 1.68.2.22 2002/12/15 09:24:23 maxim Exp $ - * $DragonFly: src/sys/kern/uipc_socket.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_socket.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_inet.h" @@ -122,16 +122,13 @@ soalloc(waitok) } int -socreate(dom, aso, type, proto, p) - int dom; - struct socket **aso; - register int type; - int proto; - struct proc *p; +socreate(int dom, struct socket **aso, int type, + int proto, struct thread *td) { - register struct protosw *prp; - register struct socket *so; - register int error; + struct proc *p = td->td_proc; + struct protosw *prp; + struct socket *so; + int error; if (proto) prp = pffindproto(dom, proto, type); @@ -160,7 +157,7 @@ socreate(dom, aso, type, proto, p) so->so_cred = p->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); @@ -171,22 +168,18 @@ socreate(dom, aso, type, proto, p) } int -sobind(so, nam, p) - struct socket *so; - struct sockaddr *nam; - struct proc *p; +sobind(struct socket *so, struct sockaddr *nam, 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); } void -sodealloc(so) - struct socket *so; +sodealloc(struct socket *so) { so->so_gencnt = ++so_gencnt; @@ -212,15 +205,12 @@ sodealloc(so) } int -solisten(so, backlog, p) - register struct socket *so; - int backlog; - struct proc *p; +solisten(struct socket *so, int backlog, 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); @@ -235,8 +225,7 @@ solisten(so, backlog, p) } void -sofree(so) - register struct socket *so; +sofree(struct socket *so) { struct socket *head = so->so_head; @@ -271,8 +260,7 @@ sofree(so) * Free socket when disconnect complete. */ int -soclose(so) - register struct socket *so; +soclose(struct socket *so) { int s = splnet(); /* conservative */ int error = 0; @@ -349,9 +337,7 @@ soabort(so) } int -soaccept(so, nam) - register struct socket *so; - struct sockaddr **nam; +soaccept(struct socket *so, struct sockaddr **nam) { int s = splnet(); int error; @@ -365,10 +351,7 @@ soaccept(so, nam) } int -soconnect(so, nam, p) - register struct socket *so; - struct sockaddr *nam; - struct proc *p; +soconnect(struct socket *so, struct sockaddr *nam, struct thread *td) { int s; int error; @@ -387,15 +370,13 @@ 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); } int -soconnect2(so1, so2) - register struct socket *so1; - struct socket *so2; +soconnect2(struct socket *so1, struct socket *so2) { int s = splnet(); int error; @@ -406,8 +387,7 @@ soconnect2(so1, so2) } int -sodisconnect(so) - register struct socket *so; +sodisconnect(struct socket *so) { int s = splnet(); int error; @@ -445,18 +425,13 @@ bad: * Data and control buffers are freed on return. */ int -sosend(so, addr, uio, top, control, flags, p) - register struct socket *so; - struct sockaddr *addr; - struct uio *uio; - struct mbuf *top; - struct mbuf *control; - int flags; - struct proc *p; +sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, + struct mbuf *top, struct mbuf *control, int flags, + struct thread *td) { struct mbuf **mp; - register struct mbuf *m; - register long space, len, resid; + struct mbuf *m; + long space, len, resid; int clen = 0, error, s, dontroute, mlen; int atomic = sosendallatonce(so) || top; @@ -482,8 +457,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_proc && td->td_proc->p_stats) + td->td_proc->p_stats->p_ru.ru_msgsnd++; if (control) clen = control->m_len; #define snderr(errno) { error = errno; splx(s); goto release; } @@ -620,7 +595,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; @@ -768,8 +743,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) + 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 +1078,7 @@ sooptcopyin(sopt, buf, len, minlen) if (valsize > len) sopt->sopt_valsize = valsize = len; - if (sopt->sopt_p != 0) + if (sopt->sopt_td != NULL) return (copyin(sopt->sopt_val, buf, valsize)); bcopy(sopt->sopt_val, buf, valsize); @@ -1281,7 +1256,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 != NULL) error = copyout(buf, sopt->sopt_val, valsize); else bcopy(buf, sopt->sopt_val, valsize); @@ -1395,11 +1370,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_WAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_DATA); if (m == 0) return ENOBUFS; if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_p ? M_WAIT : M_DONTWAIT); + MCLGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_free(m); return ENOBUFS; @@ -1413,13 +1388,13 @@ soopt_getm(struct sockopt *sopt, struct mbuf **mp) m_prev = m; while (sopt_size) { - MGET(m, sopt->sopt_p ? M_WAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_DATA); if (m == 0) { m_freem(*mp); return ENOBUFS; } if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_p ? M_WAIT : M_DONTWAIT); + MCLGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(*mp); return ENOBUFS; @@ -1444,7 +1419,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 *), @@ -1474,7 +1449,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, @@ -1509,7 +1484,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(); @@ -1528,12 +1503,12 @@ sopoll(struct socket *so, int events, struct ucred *cred, struct proc *p) if (revents == 0) { if (events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { - selrecord(p->p_thread, &so->so_rcv.sb_sel); + selrecord(td, &so->so_rcv.sb_sel); so->so_rcv.sb_flags |= SB_SEL; } if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p->p_thread, &so->so_snd.sb_sel); + selrecord(td, &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 8bffd320ee..85e16a28a3 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -32,7 +32,7 @@ * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/kern/uipc_socket2.c,v 1.55.2.17 2002/08/31 19:04:55 dwmalone Exp $ - * $DragonFly: src/sys/kern/uipc_socket2.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_socket2.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_param.h" @@ -171,19 +171,7 @@ soisdisconnected(so) * Connstatus may be 0, or SO_ISCONFIRMING, or SO_ISCONNECTED. */ struct socket * -sonewconn(head, connstatus) - register struct socket *head; - int connstatus; -{ - - return (sonewconn3(head, connstatus, NULL)); -} - -struct socket * -sonewconn3(head, connstatus, p) - register struct socket *head; - int connstatus; - struct proc *p; +sonewconn(struct socket *head, int connstatus) { register struct socket *so; @@ -201,8 +189,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; - crhold(so->so_cred); + so->so_cred = crhold(head->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)) { sodealloc(so); @@ -869,7 +856,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; } @@ -882,13 +869,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 bdc600e554..af9a74e188 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -35,7 +35,7 @@ * * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 * $FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.65.2.17 2003/04/04 17:11:16 tegge Exp $ - * $DragonFly: src/sys/kern/uipc_syscalls.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_syscalls.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_compat.h" @@ -70,6 +70,7 @@ #include #include #include +#include static void sf_buf_init(void *arg); SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) @@ -103,21 +104,25 @@ extern struct fileops socketops; int socket(struct socket_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct socket *so; struct file *fp; int fd, error; + KKASSERT(p); + fdp = p->p_fd; + error = falloc(p, &fp, &fd); if (error) return (error); 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; @@ -126,7 +131,7 @@ socket(struct socket_args *uap) fp->f_type = DTYPE_SOCKET; p->p_retval[0] = fd; } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -138,22 +143,24 @@ socket(struct socket_args *uap) int bind(struct bind_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct sockaddr *sa; int error; + KKASSERT(p); error = holdsock(p->p_fd, uap->s, &fp); if (error) return (error); error = getsockaddr(&sa, uap->name, uap->namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } - 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); return (error); } @@ -164,15 +171,17 @@ bind(struct bind_args *uap) int listen(struct listen_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); error = holdsock(p->p_fd, uap->s, &fp); if (error) return (error); - 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); return(error); } @@ -182,7 +191,8 @@ listen(struct listen_args *uap) static int accept1(struct accept_args *uap, int compat) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *lfp = NULL; struct file *nfp = NULL; @@ -277,9 +287,9 @@ accept1(struct accept_args *uap, int compat) nfp->f_type = DTYPE_SOCKET; /* Sync socket nonblocking/async state with file flags */ tmp = fflag & FNONBLOCK; - (void) fo_ioctl(nfp, FIONBIO, (caddr_t)&tmp, p); + (void) fo_ioctl(nfp, FIONBIO, (caddr_t)&tmp, td); tmp = fflag & FASYNC; - (void) fo_ioctl(nfp, FIOASYNC, (caddr_t)&tmp, p); + (void) fo_ioctl(nfp, FIOASYNC, (caddr_t)&tmp, td); sa = 0; error = soaccept(so, &sa); if (error) { @@ -328,7 +338,7 @@ noconnection: if (error) { if (fdp->fd_ofiles[fd] == nfp) { fdp->fd_ofiles[fd] = NULL; - fdrop(nfp, p); + fdrop(nfp, td); } } splx(s); @@ -338,8 +348,8 @@ noconnection: */ done: if (nfp != NULL) - fdrop(nfp, p); - fdrop(lfp, p); + fdrop(nfp, td); + fdrop(lfp, td); return (error); } @@ -365,9 +375,10 @@ oaccept(struct accept_args *uap) int connect(struct connect_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; - register struct socket *so; + struct socket *so; struct sockaddr *sa; int error, s; @@ -382,7 +393,7 @@ connect(struct connect_args *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)) { @@ -408,7 +419,7 @@ bad: if (error == ERESTART) error = EINTR; done: - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -418,16 +429,19 @@ done: int socketpair(struct socketpair_args *uap) { - struct proc *p = curproc; - struct filedesc *fdp = p->p_fd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct filedesc *fdp; struct file *fp1, *fp2; struct socket *so1, *so2; int fd, error, sv[2]; - error = socreate(uap->domain, &so1, uap->type, uap->protocol, p); + KKASSERT(p); + fdp = p->p_fd; + error = socreate(uap->domain, &so1, uap->type, uap->protocol, td); if (error) return (error); - 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); @@ -457,21 +471,21 @@ socketpair(struct socketpair_args *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); return (error); 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: @@ -480,12 +494,10 @@ free1: } static int -sendit(s, mp, flags) - int s; - struct msghdr *mp; - int flags; +sendit(int s, struct msghdr *mp, int flags) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct uio auio; register struct iovec *iov; @@ -506,20 +518,20 @@ sendit(s, mp, flags) 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 { @@ -558,7 +570,7 @@ sendit(s, mp, flags) control = 0; } #ifdef KTRACE - if (KTRPOINT(p, KTR_GENIO)) { + if (KTRPOINT(td, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -569,7 +581,7 @@ sendit(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)) @@ -590,7 +602,7 @@ sendit(s, mp, flags) } #endif bad: - fdrop(fp, p); + fdrop(fp, td); if (to) FREE(to, M_SONAME); return (error); @@ -711,12 +723,10 @@ done: } static int -recvit(s, mp, namelenp) - int s; - struct msghdr *mp; - caddr_t namelenp; +recvit(int s, struct msghdr *mp, caddr_t namelenp) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct uio auio; register struct iovec *iov; @@ -738,18 +748,18 @@ recvit(s, mp, namelenp) 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, KTR_GENIO)) { int iovlen = auio.uio_iovcnt * sizeof (struct iovec); MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); @@ -858,7 +868,7 @@ recvit(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) @@ -1018,15 +1028,17 @@ done: int shutdown(struct shutdown_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; + KKASSERT(p); error = holdsock(p->p_fd, uap->s, &fp); if (error) return (error); error = soshutdown((struct socket *)fp->f_data, uap->how); - fdrop(fp, p); + fdrop(fp, td); return(error); } @@ -1037,7 +1049,8 @@ shutdown(struct shutdown_args *uap) int setsockopt(struct setsockopt_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct sockopt sopt; int error; @@ -1056,9 +1069,9 @@ setsockopt(struct setsockopt_args *uap) 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); return(error); } @@ -1069,7 +1082,8 @@ setsockopt(struct setsockopt_args *uap) int getsockopt(struct getsockopt_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int valsize, error; struct file *fp; struct sockopt sopt; @@ -1081,11 +1095,11 @@ getsockopt(struct getsockopt_args *uap) error = copyin((caddr_t)uap->avalsize, (caddr_t)&valsize, sizeof (valsize)); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } if (valsize < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } } else { @@ -1097,7 +1111,7 @@ getsockopt(struct getsockopt_args *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) { @@ -1105,7 +1119,7 @@ getsockopt(struct getsockopt_args *uap) error = copyout((caddr_t)&valsize, (caddr_t)uap->avalsize, sizeof (valsize)); } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -1118,9 +1132,10 @@ getsockopt(struct getsockopt_args *uap) static int getsockname1(struct getsockname_args *uap, int compat) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; - register struct socket *so; + struct socket *so; struct sockaddr *sa; int len, error; @@ -1129,11 +1144,11 @@ getsockname1(struct getsockname_args *uap, int compat) return (error); error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } if (len < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } so = (struct socket *)fp->f_data; @@ -1159,7 +1174,7 @@ gotnothing: bad: if (sa) FREE(sa, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -1188,9 +1203,10 @@ ogetsockname(struct getsockname_args *uap) static int getpeername1(struct getpeername_args *uap, int compat) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; - register struct socket *so; + struct socket *so; struct sockaddr *sa; int len, error; @@ -1199,16 +1215,16 @@ getpeername1(struct getpeername_args *uap, int compat) return (error); so = (struct socket *)fp->f_data; if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) { - fdrop(fp, p); + fdrop(fp, td); return (ENOTCONN); } error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } if (len < 0) { - fdrop(fp, p); + fdrop(fp, td); return (EINVAL); } sa = 0; @@ -1233,7 +1249,7 @@ gotnothing: bad: if (sa) FREE(sa, M_SONAME); - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -1476,9 +1492,10 @@ osendfile(struct osendfile_args *uap) int do_sendfile(struct sendfile_args *uap, int compat) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp; struct vnode *vp; struct vm_object *obj; struct socket *so; @@ -1490,6 +1507,9 @@ do_sendfile(struct sendfile_args *uap, int compat) off_t off, xfsize, hdtr_size, sbytes = 0; int error = 0, s; + KKASSERT(p); + fdp = p->p_fd; + vp = NULL; hdtr_size = 0; /* @@ -1511,7 +1531,7 @@ do_sendfile(struct sendfile_args *uap, int compat) error = EINVAL; goto done; } - fdrop(fp, p); + fdrop(fp, td); error = holdsock(p->p_fd, uap->s, &fp); if (error) goto done; @@ -1651,11 +1671,12 @@ 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); - error = VOP_READ(vp, &auio, IO_VMIO | ((MAXBSIZE / bsize) << 16), - p->p_ucred); - VOP_UNLOCK(vp, 0, 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, td); vm_page_flag_clear(pg, PG_ZERO); vm_page_io_finish(pg); if (error) { @@ -1771,7 +1792,8 @@ 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); @@ -1805,6 +1827,6 @@ done: if (vp) vrele(vp); if (fp) - fdrop(fp, p); + fdrop(fp, td); return (error); } diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index d4c8394c0d..0e2860cf4a 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -32,7 +32,7 @@ * * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 * $FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.54.2.10 2003/03/04 17:28:09 nectar Exp $ - * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -41,11 +41,11 @@ #include #include #include /* XXX must be before */ +#include #include #include #include #include -#include #include #include #include @@ -55,6 +55,7 @@ #include #include #include +#include #include @@ -78,9 +79,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)); @@ -88,8 +89,8 @@ 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_listen __P((struct unpcb *, struct proc *)); +static int unp_internalize __P((struct mbuf *, struct thread *)); +static int unp_listen __P((struct unpcb *, struct thread *)); static int uipc_abort(struct socket *so) @@ -127,7 +128,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 +138,23 @@ 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, td); } 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); } static int @@ -266,7 +266,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); @@ -282,7 +282,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) { @@ -295,7 +295,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 { @@ -328,7 +328,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 { @@ -582,13 +582,11 @@ unp_detach(unp) } static int -unp_bind(unp, nam, p) - struct unpcb *unp; - struct sockaddr *nam; - struct proc *p; +unp_bind(struct unpcb *unp, struct sockaddr *nam, struct thread *td) { + struct proc *p = td->td_proc; struct sockaddr_un *soun = (struct sockaddr_un *)nam; - register struct vnode *vp; + struct vnode *vp; struct vattr vattr; int error, namelen; struct nameidata nd; @@ -601,8 +599,7 @@ unp_bind(unp, nam, p) return EINVAL; strncpy(buf, soun->sun_path, namelen); buf[namelen] = 0; /* null-terminate the string */ - NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT, UIO_SYSSPACE, - buf, p); + NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT, UIO_SYSSPACE, buf, td); /* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ error = namei(&nd); if (error) @@ -620,7 +617,7 @@ unp_bind(unp, nam, p) 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); + VOP_LEASE(nd.ni_dvp, td, p->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); @@ -630,31 +627,31 @@ unp_bind(unp, nam, p) 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); return (0); } static int -unp_connect(so, nam, p) - struct socket *so; - struct sockaddr *nam; - struct proc *p; +unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { - register struct sockaddr_un *soun = (struct sockaddr_un *)nam; - register struct vnode *vp; - register struct socket *so2, *so3; + struct proc *p = td->td_proc; + struct sockaddr_un *soun = (struct sockaddr_un *)nam; + struct vnode *vp; + struct socket *so2, *so3; struct unpcb *unp, *unp2, *unp3; int error, len; struct nameidata nd; char buf[SOCK_MAXADDRLEN]; + KKASSERT(p); + len = nam->sa_len - offsetof(struct sockaddr_un, sun_path); if (len <= 0) return EINVAL; 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); @@ -664,7 +661,7 @@ unp_connect(so, nam, p) error = ENOTSOCK; goto bad; } - error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p); + error = VOP_ACCESS(vp, VWRITE, p->p_ucred, td); if (error) goto bad; so2 = vp->v_socket; @@ -678,7 +675,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 = sonewconn(so2, 0)) == 0) { error = ECONNREFUSED; goto bad; } @@ -786,8 +783,14 @@ unp_abort(unp) #endif static int -prison_unpcb(struct proc *p, struct unpcb *unp) +prison_unpcb(struct thread *td, struct unpcb *unp) { + struct proc *p; + + if (td == NULL) + return (0); + if ((p = td->td_proc) == NULL) + return (0); if (!p->p_ucred->cr_prison) return (0); if (p->p_fd->fd_rdir == unp->unp_rvnode) @@ -842,7 +845,7 @@ unp_pcblist(SYSCTL_HANDLER_ARGS) for (unp = LIST_FIRST(head), i = 0; unp && i < n; unp = LIST_NEXT(unp, unp_link)) { - if (unp->unp_gencnt <= gencnt && !prison_unpcb(req->p, unp)) + if (unp->unp_gencnt <= gencnt && !prison_unpcb(req->td, unp)) unp_list[i++] = unp; } n = i; /* in case we lost some during malloc */ @@ -925,15 +928,14 @@ unp_drain() #endif int -unp_externalize(rights) - struct mbuf *rights; +unp_externalize(struct mbuf *rights) { struct proc *p = curproc; /* XXX */ - register int i; - register struct cmsghdr *cm = mtod(rights, struct cmsghdr *); - register int *fdp; - register struct file **rp; - register struct file *fp; + int i; + struct cmsghdr *cm = mtod(rights, struct cmsghdr *); + int *fdp; + struct file **rp; + struct file *fp; int newfds = (cm->cmsg_len - (CMSG_DATA(cm) - (u_char *)cm)) / sizeof (struct file *); int f; @@ -1015,19 +1017,20 @@ unp_init(void) #endif static int -unp_internalize(control, p) - struct mbuf *control; - struct proc *p; +unp_internalize(struct mbuf *control, struct thread *td) { - struct filedesc *fdescp = p->p_fd; - register struct cmsghdr *cm = mtod(control, struct cmsghdr *); - register struct file **rp; - register struct file *fp; - register int i, fd, *fdp; - register struct cmsgcred *cmcred; + struct proc *p = td->td_proc; + struct filedesc *fdescp; + struct cmsghdr *cm = mtod(control, struct cmsghdr *); + struct file **rp; + struct file *fp; + int i, fd, *fdp; + struct cmsgcred *cmcred; int oldfds; u_int newlen; + KKASSERT(p); + fdescp = p->p_fd; if ((cm->cmsg_type != SCM_RIGHTS && cm->cmsg_type != SCM_CREDS) || cm->cmsg_level != SOL_SOCKET || cm->cmsg_len != control->m_len) return (EINVAL); @@ -1282,26 +1285,24 @@ unp_gc() sorflush((struct socket *)(tfp->f_data)); } for (i = nunref, fpp = extra_ref; --i >= 0; ++fpp) - closef(*fpp, (struct proc *) NULL); + closef(*fpp, NULL); free((caddr_t)extra_ref, M_FILE); unp_gcing = 0; } void -unp_dispose(m) - struct mbuf *m; +unp_dispose(struct mbuf *m) { - if (m) unp_scan(m, unp_discard); } static int -unp_listen(unp, p) - struct unpcb *unp; - struct proc *p; +unp_listen(struct unpcb *unp, struct thread *td) { + struct proc *p = td->td_proc; + KKASSERT(p); cru2x(p->p_ucred, &unp->unp_peercred); unp->unp_flags |= UNP_HAVEPCCACHED; return (0); @@ -1309,13 +1310,13 @@ unp_listen(unp, p) static void unp_scan(m0, op) - register struct mbuf *m0; + struct mbuf *m0; void (*op) __P((struct file *)); { - register struct mbuf *m; - register struct file **rp; - register struct cmsghdr *cm; - register int i; + struct mbuf *m; + struct file **rp; + struct cmsghdr *cm; + int i; int qfds; while (m0) { @@ -1356,5 +1357,5 @@ unp_discard(fp) fp->f_msgcount--; unp_rights--; - (void) closef(fp, (struct proc *)NULL); + (void) closef(fp, NULL); } diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 96d6c60911..caa58b9294 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -35,7 +35,7 @@ * * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95 * $FreeBSD: src/sys/kern/vfs_cache.c,v 1.42.2.6 2001/10/05 20:07:03 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cache.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cache.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -44,10 +44,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -450,7 +450,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_td; u_long vpid; /* capability number of vnode */ *vpp = NULL; @@ -464,7 +464,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); @@ -484,17 +484,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; } } @@ -507,12 +507,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; diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index 9634d20c64..232f0ad293 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/vfs_conf.c,v 1.49.2.5 2003/01/07 11:56:53 joerg Exp $ - * $DragonFly: src/sys/kern/vfs_conf.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_conf.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -171,6 +171,7 @@ vfs_mountroot(void *junk) static int vfs_mountroot_try(char *mountfrom) { + struct thread *td = curthread; struct mount *mp; char *vfsname, *path; int error; @@ -216,7 +217,7 @@ vfs_mountroot_try(char *mountfrom) (devsw(rootdev)->d_flags & D_MEMDISK)) mp->mnt_flag &= ~MNT_RDONLY; - error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); + error = VFS_MOUNT(mp, NULL, NULL, NULL, td); done: if (vfsname != NULL) @@ -225,7 +226,7 @@ done: free(path, M_MOUNT); if (error != 0) { if (mp != NULL) { - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, td); free(mp, M_MOUNT); } printf("Root mount failed: %d\n", error); @@ -238,7 +239,7 @@ done: /* sanity check system clock against root filesystem timestamp */ inittodr(mp->mnt_time); - vfs_unbusy(mp, curproc); + vfs_unbusy(mp, td); } return(error); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index f9c22e82eb..d9a14d0bad 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -37,7 +37,7 @@ * * * $FreeBSD: src/sys/kern/vfs_default.c,v 1.28.2.7 2003/01/10 18:23:26 bde Exp $ - * $DragonFly: src/sys/kern/vfs_default.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_default.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -254,9 +254,9 @@ vop_stdlock(ap) } #ifndef DEBUG_LOCKS - return (lockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p)); + return (lockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_td)); #else - return (debuglockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p, + return (debuglockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_td, "vop_stdlock", ap->a_vp->filename, ap->a_vp->line)); #endif } @@ -266,7 +266,7 @@ vop_stdunlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct lock *l; @@ -277,15 +277,15 @@ vop_stdunlock(ap) return 0; } - return (lockmgr(l, ap->a_flags | LK_RELEASE, &ap->a_vp->v_interlock, - ap->a_p)); + return (lockmgr(l, ap->a_flags | LK_RELEASE, + &ap->a_vp->v_interlock, ap->a_td)); } int vop_stdislocked(ap) struct vop_islocked_args /* { struct vnode *a_vp; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct lock *l; @@ -293,7 +293,7 @@ vop_stdislocked(ap) if ((l = (struct lock *)ap->a_vp->v_data) == NULL) return 0; - return (lockstatus(l, ap->a_p)); + return (lockstatus(l, ap->a_td)); } /* @@ -330,11 +330,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)); } @@ -409,9 +409,9 @@ vop_sharedlock(ap) if (flags & LK_INTERLOCK) vnflags |= LK_INTERLOCK; #ifndef DEBUG_LOCKS - return (lockmgr(l, vnflags, &vp->v_interlock, ap->a_p)); + return (lockmgr(l, vnflags, &vp->v_interlock, ap->a_td)); #else - return (debuglockmgr(l, vnflags, &vp->v_interlock, ap->a_p, + return (debuglockmgr(l, vnflags, &vp->v_interlock, ap->a_td, "vop_sharedlock", vp->filename, vp->line)); #endif } @@ -510,14 +510,14 @@ vop_noislocked(ap) int vop_stdcreatevobject(ap) struct vop_createvobject_args /* { - struct vnode *vp; - struct ucred *cred; - struct proc *p; + struct vnode *a_vp; + struct ucred *a_cred; + struct proc *a_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; @@ -528,7 +528,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) { @@ -549,9 +549,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; } } @@ -623,129 +623,90 @@ vop_stdgetvobject(ap) * used to fill the vfs fucntion table to get reasonable default return values. */ int -vfs_stdmount (mp, path, data, ndp, p) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; +vfs_stdmount(struct mount *mp, char *path, caddr_t data, + struct nameidata *ndp, struct thread *td) { return (0); } int -vfs_stdunmount (mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; +vfs_stdunmount(struct mount *mp, int mntflags, struct thread *td) { return (0); } int -vfs_stdroot (mp, vpp) - struct mount *mp; - struct vnode **vpp; +vfs_stdroot(struct mount *mp, struct vnode **vpp) { return (EOPNOTSUPP); } int -vfs_stdstatfs (mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +vfs_stdstatfs(struct mount *mp, struct statfs *sbp, struct thread *td) { return (EOPNOTSUPP); } int -vfs_stdvptofh (vp, fhp) - struct vnode *vp; - struct fid *fhp; +vfs_stdvptofh(struct vnode *vp, struct fid *fhp) { return (EOPNOTSUPP); } int -vfs_stdstart (mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; +vfs_stdstart(struct mount *mp, int flags, struct thread *td) { return (0); } int -vfs_stdquotactl (mp, cmds, uid, arg, p) - struct mount *mp; - int cmds; - uid_t uid; - caddr_t arg; - struct proc *p; +vfs_stdquotactl(struct mount *mp, int cmds, uid_t uid, + caddr_t arg, struct thread *td) { return (EOPNOTSUPP); } int -vfs_stdsync (mp, waitfor, cred, p) - struct mount *mp; - int waitfor; - struct ucred *cred; - struct proc *p; +vfs_stdsync(struct mount *mp, int waitfor, + struct ucred *cred, struct thread *td) { return (0); } int -vfs_stdvget (mp, ino, vpp) - struct mount *mp; - ino_t ino; - struct vnode **vpp; +vfs_stdvget(struct mount *mp, ino_t ino, struct vnode **vpp) { return (EOPNOTSUPP); } int -vfs_stdfhtovp (mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; +vfs_stdfhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) { return (EOPNOTSUPP); } int -vfs_stdcheckexp (mp, nam, extflagsp, credanonp) - struct mount *mp; - struct sockaddr *nam; - int *extflagsp; - struct ucred **credanonp; +vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp, + struct ucred **credanonp) { return (EOPNOTSUPP); } int -vfs_stdinit (vfsp) - struct vfsconf *vfsp; +vfs_stdinit(struct vfsconf *vfsp) { return (0); } int -vfs_stduninit (vfsp) - struct vfsconf *vfsp; +vfs_stduninit(struct vfsconf *vfsp) { return(0); } int -vfs_stdextattrctl(mp, cmd, attrname, arg, p) - struct mount *mp; - int cmd; - const char *attrname; - caddr_t arg; - struct proc *p; +vfs_stdextattrctl(struct mount *mp, int cmd, const char *attrname, + caddr_t arg, struct thread *td) { return(EOPNOTSUPP); } diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 8b6e67a321..5a0eaee708 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -37,18 +37,18 @@ * * @(#)vfs_lookup.c 8.4 (Berkeley) 2/16/94 * $FreeBSD: src/sys/kern/vfs_lookup.c,v 1.38.2.3 2001/08/31 19:36:49 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_lookup.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_lookup.c,v 1.3 2003/06/25 03:55:57 dillon Exp $ */ #include "opt_ktrace.h" #include #include -#include #include #include #include #include +#include #ifdef KTRACE #include @@ -77,25 +77,27 @@ * } */ int -namei(ndp) - register struct nameidata *ndp; +namei(struct nameidata *ndp) { - register struct filedesc *fdp; /* pointer to file descriptor state */ - register char *cp; /* pointer into pathname argument */ - register struct vnode *dp; /* the directory we are searching */ + struct filedesc *fdp; /* pointer to file descriptor state */ + char *cp; /* pointer into pathname argument */ + struct vnode *dp; /* the directory we are searching */ struct iovec aiov; /* uio for reading symbolic links */ struct uio auio; int error, linklen; struct componentname *cnp = &ndp->ni_cnd; - struct proc *p = cnp->cn_proc; + struct proc *p; - ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_proc->p_ucred; - KASSERT(cnp->cn_cred && cnp->cn_proc, ("namei: bad cred/proc")); + KKASSERT(ndp->ni_cnd.cn_td != NULL); + p = cnp->cn_td->td_proc; + KKASSERT(p != NULL); + KASSERT(cnp->cn_cred, ("namei: bad cred/proc")); + KKASSERT(cnp->cn_cred == p->p_ucred); /* YYY */ 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 @@ -123,8 +125,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(cnp->cn_td, KTR_NAMEI)) + ktrnamei(cnp->cn_td->td_proc->p_tracep, cnp->cn_pnbuf); #endif /* @@ -170,13 +172,13 @@ namei(ndp) ((cnp->cn_flags & (NOOBJ|LOCKLEAF)) == LOCKLEAF)) vfs_object_create(ndp->ni_vp, - ndp->ni_cnd.cn_proc, + ndp->ni_cnd.cn_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, cnp->cn_td); if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { error = ELOOP; break; @@ -192,7 +194,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 = NULL; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -283,7 +285,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_td; /* * Setup: break out flag bits into variables. @@ -299,7 +301,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: /* @@ -379,7 +381,7 @@ dirloop: } ndp->ni_vp = dp; if (!(cnp->cn_flags & (LOCKPARENT | LOCKLEAF))) - VOP_UNLOCK(dp, 0, p); + VOP_UNLOCK(dp, 0, cnp->cn_td); /* XXX This should probably move to the top of function. */ if (cnp->cn_flags & SAVESTART) panic("lookup: SAVESTART"); @@ -419,7 +421,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); } } @@ -446,7 +448,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; } @@ -501,11 +503,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; @@ -574,13 +576,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) @@ -600,7 +602,7 @@ relookup(dvp, vpp, cnp) struct vnode *dvp, **vpp; struct componentname *cnp; { - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct vnode *dp = 0; /* the directory we are searching */ int docache; /* == 0 do not cache last component */ int wantparent; /* 1 => wantparent or lockparent flag */ @@ -622,7 +624,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: */ /* @@ -656,7 +658,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) @@ -717,15 +719,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, cnp->cn_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_subr.c b/sys/kern/vfs_subr.c index aa1d8fb7b0..8af1514a15 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -37,7 +37,7 @@ * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 * $FreeBSD: src/sys/kern/vfs_subr.c,v 1.249.2.30 2003/04/04 20:35:57 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_subr.c,v 1.5 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_subr.c,v 1.6 2003/06/25 03:55:57 dillon Exp $ */ /* @@ -58,8 +58,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -85,7 +85,7 @@ static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); 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)); static unsigned long numvnodes; static void vlruvp(struct vnode *vp); SYSCTL_INT(_debug, OID_AUTO, numvnodes, CTLFLAG_RD, &numvnodes, 0, ""); @@ -200,11 +200,8 @@ vntblinit() * unmounting. Interlock is not released on failure. */ int -vfs_busy(mp, flags, interlkp, p) - struct mount *mp; - int flags; - struct simplelock *interlkp; - struct proc *p; +vfs_busy(struct mount *mp, int flags, struct simplelock *interlkp, + struct thread *td) { int lkflags; @@ -230,7 +227,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); } @@ -239,12 +236,9 @@ vfs_busy(mp, flags, interlkp, p) * Free a busy filesystem. */ void -vfs_unbusy(mp, p) - struct mount *mp; - struct proc *p; +vfs_unbusy(struct mount *mp, struct thread *td) { - - lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, p); + lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); } /* @@ -254,12 +248,9 @@ vfs_unbusy(mp, p) * Devname is usually updated by mount(8) after booting. */ int -vfs_rootmountalloc(fstypename, devname, mpp) - char *fstypename; - char *devname; - struct mount **mpp; +vfs_rootmountalloc(char *fstypename, char *devname, struct mount **mpp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vfsconf *vfsp; struct mount *mp; @@ -273,7 +264,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); bzero((char *)mp, (u_long)sizeof(struct mount)); lockinit(&mp->mnt_lock, PVFS, "vfslock", VLKTIMEOUT, LK_NOPAUSE); - (void)vfs_busy(mp, LK_NOWAIT, 0, p); + (void)vfs_busy(mp, LK_NOWAIT, 0, td); TAILQ_INIT(&mp->mnt_nvnodelist); TAILQ_INIT(&mp->mnt_reservedvnlist); mp->mnt_nvnodelistsize = 0; @@ -500,7 +491,7 @@ vlrureclaim(struct mount *mp) ) { simple_unlock(&mntvnode_slock); if (VMIGHTFREE(vp)) { - vgonel(vp, curproc); + vgonel(vp, curthread); done++; } else { simple_unlock(&vp->v_interlock); @@ -545,14 +536,14 @@ vnlru_proc(void) done = 0; simple_lock(&mountlist_slock); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } done += vlrureclaim(mp); simple_lock(&mountlist_slock); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } simple_unlock(&mountlist_slock); if (done == 0) { @@ -586,7 +577,8 @@ getnewvnode(tag, mp, vops, vpp) struct vnode **vpp; { int s; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct vnode *vp = NULL; vm_object_t object; @@ -674,7 +666,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 { simple_unlock(&vp->v_interlock); } @@ -721,7 +713,7 @@ getnewvnode(tag, mp, vops, vpp) vp->v_data = 0; splx(s); - vfs_object_create(vp, p, p->p_ucred); + vfs_object_create(vp, td, p->p_ucred); return (0); } @@ -782,12 +774,8 @@ vwakeup(bp) * Called with the underlying object locked. */ int -vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) - register struct vnode *vp; - int flags; - struct ucred *cred; - struct proc *p; - int slpflag, slptimeo; +vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, + struct thread *td, int slpflag, int slptimeo) { register struct buf *bp; struct buf *nbp, *blist; @@ -807,7 +795,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 || @@ -907,14 +895,10 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) * sync activity. */ int -vtruncbuf(vp, cred, p, length, blksize) - register struct vnode *vp; - struct ucred *cred; - struct proc *p; - off_t length; - int blksize; +vtruncbuf(struct vnode *vp, struct ucred *cred, struct thread *td, + off_t length, int blksize) { - register struct buf *bp; + struct buf *bp; struct buf *nbp; int s, anyfreed; int trunclbn; @@ -1161,9 +1145,9 @@ sched_sync(void) while ((vp = LIST_FIRST(slp)) != NULL) { if (VOP_ISLOCKED(vp, NULL) == 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, p->p_ucred, MNT_LAZY, td); + VOP_UNLOCK(vp, 0, td); } s = splbio(); if (LIST_FIRST(slp) == vp) { @@ -1506,10 +1490,10 @@ addalias(nvp, dev) * been changed to a new file system type). */ int -vget(vp, flags, p) - register struct vnode *vp; +vget(vp, flags, td) + struct vnode *vp; int flags; - struct proc *p; + struct thread *td; { int error; @@ -1541,7 +1525,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 @@ -1577,10 +1561,9 @@ vref(struct vnode *vp) * If count drops to zero, call inactive routine and return to freelist. */ void -vrele(vp) - struct vnode *vp; +vrele(struct vnode *vp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ KASSERT(vp != NULL, ("vrele: null vp")); @@ -1603,8 +1586,8 @@ vrele(vp) * 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); if (VSHOULDFREE(vp)) vfree(vp); else @@ -1619,10 +1602,9 @@ vrele(vp) } void -vput(vp) - struct vnode *vp; +vput(struct vnode *vp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ KASSERT(vp != NULL, ("vput: null vp")); @@ -1630,7 +1612,7 @@ vput(vp) if (vp->v_usecount > 1) { vp->v_usecount--; - VOP_UNLOCK(vp, LK_INTERLOCK, p); + VOP_UNLOCK(vp, LK_INTERLOCK, td); return; } @@ -1642,7 +1624,7 @@ vput(vp) * so we just need to release the vnode mutex. */ simple_unlock(&vp->v_interlock); - VOP_INACTIVE(vp, p); + VOP_INACTIVE(vp, td); if (VSHOULDFREE(vp)) vfree(vp); else @@ -1720,7 +1702,8 @@ vflush(mp, rootrefs, flags) int rootrefs; int flags; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; struct vnode *vp, *nvp, *rootvp = NULL; struct vattr vattr; int busy = 0, error; @@ -1762,7 +1745,7 @@ loop: */ if ((flags & WRITECLOSE) && (vp->v_type == VNON || - (VOP_GETATTR(vp, &vattr, p->p_ucred, p) == 0 && + (VOP_GETATTR(vp, &vattr, p->p_ucred, td) == 0 && vattr.va_nlink > 0)) && (vp->v_writecount == 0 || vp->v_type != VREG)) { simple_unlock(&vp->v_interlock); @@ -1775,7 +1758,7 @@ loop: */ if (vp->v_usecount == 0) { simple_unlock(&mntvnode_slock); - vgonel(vp, p); + vgonel(vp, td); simple_lock(&mntvnode_slock); continue; } @@ -1788,9 +1771,9 @@ loop: if (flags & FORCECLOSE) { simple_unlock(&mntvnode_slock); if (vp->v_type != VBLK && 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); } @@ -1814,7 +1797,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 simple_unlock(&rootvp->v_interlock); @@ -1852,10 +1835,7 @@ vlruvp(struct vnode *vp) * Disassociate the underlying file system from a vnode. */ static void -vclean(vp, flags, p) - struct vnode *vp; - int flags; - struct proc *p; +vclean(struct vnode *vp, int flags, struct thread *td) { int active; @@ -1882,12 +1862,12 @@ 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. */ - vinvalbuf(vp, V_SAVE, NOCRED, p, 0, 0); + vinvalbuf(vp, V_SAVE, NOCRED, td, 0, 0); VOP_DESTROYVOBJECT(vp); @@ -1898,19 +1878,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) { @@ -1995,18 +1975,14 @@ vop_revoke(ap) * Release the passed interlock if the vnode will be recycled. */ int -vrecycle(vp, inter_lkp, p) - struct vnode *vp; - struct simplelock *inter_lkp; - struct proc *p; +vrecycle(struct vnode *vp, struct simplelock *inter_lkp, struct thread *td) { - simple_lock(&vp->v_interlock); if (vp->v_usecount == 0) { if (inter_lkp) { simple_unlock(inter_lkp); } - vgonel(vp, p); + vgonel(vp, td); return (1); } simple_unlock(&vp->v_interlock); @@ -2018,22 +1994,19 @@ vrecycle(vp, inter_lkp, p) * in preparation for reuse. */ void -vgone(vp) - register struct vnode *vp; +vgone(struct vnode *vp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ simple_lock(&vp->v_interlock); - vgonel(vp, p); + vgonel(vp, td); } /* * vgone, with the vp interlock held. */ void -vgonel(vp, p) - struct vnode *vp; - struct proc *p; +vgonel(struct vnode *vp, struct thread *td) { int s; @@ -2051,7 +2024,7 @@ vgonel(vp, p) /* * Clean out the filesystem specific data. */ - vclean(vp, DOCLOSE, p); + vclean(vp, DOCLOSE, td); simple_lock(&vp->v_interlock); /* @@ -2212,14 +2185,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"); simple_lock(&mountlist_slock); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -2229,7 +2202,7 @@ DB_SHOW_COMMAND(lockedvnodes, lockedvnodes) } simple_lock(&mountlist_slock); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } simple_unlock(&mountlist_slock); } @@ -2404,19 +2377,18 @@ void vfs_unmountall() { struct mount *mp; - struct proc *p; + struct thread *td = curthread; int error; - if (curproc != NULL) - p = curproc; - else - p = initproc; /* XXX XXX should this be proc0? */ + if (td->td_proc == NULL) + td = initproc->p_thread; /* XXX XXX use proc0 instead? */ + /* * 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 (", @@ -2695,6 +2667,7 @@ vfs_export_lookup(mp, nep, nam) void vfs_msync(struct mount *mp, int flags) { + struct thread *td = curthread; /* XXX */ struct vnode *vp, *nvp; struct vm_object *obj; int tries; @@ -2722,7 +2695,7 @@ loop: (flags == MNT_WAIT || VOP_ISLOCKED(vp, NULL) == 0)) { simple_unlock(&mntvnode_slock); if (!vget(vp, - LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) { + LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, td)) { if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, flags == MNT_WAIT ? OBJPC_SYNC : OBJPC_NOSYNC); } @@ -2748,12 +2721,9 @@ loop: * vp must be locked when vfs_object_create is called. */ int -vfs_object_create(vp, p, cred) - struct vnode *vp; - struct proc *p; - struct ucred *cred; +vfs_object_create(struct vnode *vp, struct thread *td, struct ucred *cred) { - return (VOP_CREATEVOBJECT(vp, cred, p)); + return (VOP_CREATEVOBJECT(vp, cred, td)); } void @@ -2802,10 +2772,7 @@ vbusy(vp) * to avoid race conditions.) */ int -vn_pollrecord(vp, p, events) - struct vnode *vp; - struct proc *p; - short events; +vn_pollrecord(struct vnode *vp, struct thread *td, int events) { simple_lock(&vp->v_pollinfo.vpi_lock); if (vp->v_pollinfo.vpi_revents & events) { @@ -2823,7 +2790,7 @@ vn_pollrecord(vp, p, events) return events; } vp->v_pollinfo.vpi_events |= events; - selrecord(p->p_thread, &vp->v_pollinfo.vpi_selinfo); + selrecord(td, &vp->v_pollinfo.vpi_selinfo); simple_unlock(&vp->v_pollinfo.vpi_lock); return 0; } @@ -2955,12 +2922,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; /* @@ -2979,17 +2946,17 @@ sync_fsync(ap) * not already on the sync list. */ simple_lock(&mountlist_slock); - if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_slock, p) != 0) { + if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_slock, td) != 0) { simple_unlock(&mountlist_slock); 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; - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); return (0); } @@ -3109,7 +3076,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_td); if (!(flags & NDF_NO_DVP_RELE) && (ndp->ni_cnd.cn_flags & (LOCKPARENT|WANTPARENT))) { vrele(ndp->ni_dvp); @@ -3117,7 +3084,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_td); 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 67a3550f27..25d91b6814 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -37,7 +37,7 @@ * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 * $FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.151.2.18 2003/04/04 20:35:58 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_syscalls.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_syscalls.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ /* For 4.3 integer FS ID compatibility */ @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ #include #include #include +#include #include #include @@ -71,7 +71,9 @@ #include #include -static int change_dir __P((struct nameidata *ndp, struct proc *p)); +#include + +static int change_dir __P((struct nameidata *ndp, struct thread *td)); static void checkdirs __P((struct vnode *olddp)); static int chroot_refuse_vdir_fds __P((struct filedesc *fdp)); static int getutimes __P((const struct timeval *, struct timespec *)); @@ -81,7 +83,7 @@ static int setfflags __P((struct vnode *, int)); static int setutimes __P((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 *, struct vnode **, struct file *)); SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -107,7 +109,8 @@ struct mount_args { int mount(struct mount_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct mount *mp; struct vfsconf *vfsp; @@ -119,26 +122,26 @@ mount(struct mount_args *uap) struct nameidata nd; char fstypename[MFSNAMELEN]; - if (usermount == 0 && (error = suser())) + if (usermount == 0 && (error = suser(td))) return (error); /* * Do not allow NFS export by non-root users. */ if (SCARG(uap, flags) & MNT_EXPORTED) { - error = suser(); + error = suser(td); if (error) return (error); } /* * Silently enforce MNT_NOSUID and MNT_NODEV for non-root users */ - if (suser_xxx(p->p_ucred, 0)) + if (suser(td)) SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV; /* * Get vnode to be covered */ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -165,11 +168,11 @@ mount(struct mount_args *uap) * permitted to update it. */ if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid && - (error = suser())) { + (error = suser(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); } @@ -177,7 +180,7 @@ mount(struct mount_args *uap) if ((vp->v_flag & VMOUNT) != 0 || vp->v_mountedhere != NULL) { simple_unlock(&vp->v_interlock); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); vput(vp); return (EBUSY); } @@ -185,20 +188,20 @@ mount(struct mount_args *uap) simple_unlock(&vp->v_interlock); mp->mnt_flag |= SCARG(uap, flags) & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE); - 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()))) { + (error = suser(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); } @@ -235,7 +238,7 @@ mount(struct mount_args *uap) linker_file_t lf; /* Only load modules for root (very important!) */ - if ((error = suser()) != 0) { + if ((error = suser(td)) != 0) { vput(vp); return error; } @@ -277,7 +280,7 @@ mount(struct mount_args *uap) TAILQ_INIT(&mp->mnt_reservedvnlist); mp->mnt_nvnodelistsize = 0; 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++; @@ -287,7 +290,7 @@ mount(struct mount_args *uap) mp->mnt_vnodecovered = vp; mp->mnt_stat.f_owner = p->p_ucred->cr_uid; mp->mnt_iosize_max = DFLTPHYS; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); update: /* * Set the mount level flags. @@ -309,7 +312,7 @@ update: * XXX The final recipients of VFS_MOUNT just overwrite the ndp they * get. No freeing of cn_pnbuf. */ - error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p); + error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, td); if (mp->mnt_flag & MNT_UPDATE) { if (mp->mnt_kern_flag & MNTK_WANTRDWR) mp->mnt_flag &= ~MNT_RDONLY; @@ -327,14 +330,14 @@ update: vrele(mp->mnt_syncer); mp->mnt_syncer = NULL; } - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); simple_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; simple_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. */ @@ -348,18 +351,18 @@ update: TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); checkdirs(vp); - 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 { simple_lock(&vp->v_interlock); vp->v_flag &= ~VMOUNT; simple_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); } @@ -372,8 +375,7 @@ update: * mounted. If so, replace them with the new mount point. */ static void -checkdirs(olddp) - struct vnode *olddp; +checkdirs(struct vnode *olddp) { struct filedesc *fdp; struct vnode *newdp; @@ -423,14 +425,16 @@ struct unmount_args { int unmount(struct unmount_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct mount *mp; int error; struct nameidata nd; + KKASSERT(p); 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; @@ -442,7 +446,7 @@ unmount(struct unmount_args *uap) * permitted to unmount this filesystem. */ if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) && - (error = suser())) { + (error = suser(td))) { vput(vp); return (error); } @@ -463,21 +467,21 @@ unmount(struct unmount_args *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) - register struct mount *mp; - int flags; - struct proc *p; +dounmount(struct mount *mp, int flags, struct thread *td) { struct vnode *coveredvp; int error; int async_flag; + struct proc *p = td->td_proc; + + KKASSERT(p); simple_lock(&mountlist_slock); if (mp->mnt_kern_flag & MNTK_UNMOUNT) { @@ -489,7 +493,7 @@ dounmount(mp, flags, p) if (flags & MNT_FORCE) mp->mnt_kern_flag |= MNTK_UNMOUNTF; error = lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK | - ((flags & MNT_FORCE) ? 0 : LK_NOWAIT), &mountlist_slock, p); + ((flags & MNT_FORCE) ? 0 : LK_NOWAIT), &mountlist_slock, td); if (error) { mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF); if (mp->mnt_kern_flag & MNTK_MWAIT) @@ -507,9 +511,9 @@ dounmount(mp, flags, p) if (mp->mnt_syncer != NULL) vrele(mp->mnt_syncer); if (((mp->mnt_flag & MNT_RDONLY) || - (error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0) || + (error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, td)) == 0) || (flags & MNT_FORCE)) - error = VFS_UNMOUNT(mp, flags, p); + error = VFS_UNMOUNT(mp, flags, td); simple_lock(&mountlist_slock); if (error) { if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL) @@ -517,7 +521,7 @@ dounmount(mp, flags, p) mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF); mp->mnt_flag |= async_flag; lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE, - &mountlist_slock, p); + &mountlist_slock, td); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup((caddr_t)mp); return (error); @@ -530,7 +534,7 @@ dounmount(mp, flags, p) mp->mnt_vfc->vfc_refcount--; if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) panic("unmount: dangling vnode"); - lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, p); + lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, td); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup((caddr_t)mp); free((caddr_t)mp, M_MOUNT); @@ -555,13 +559,14 @@ SYSCTL_INT(_debug, OID_AUTO, syncprt, CTLFLAG_RW, &syncprt, 0, ""); int sync(struct sync_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct mount *mp, *nmp; int asyncflag; simple_lock(&mountlist_slock); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -570,12 +575,12 @@ sync(struct sync_args *uap) mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); VFS_SYNC(mp, MNT_NOWAIT, - ((p != NULL) ? p->p_ucred : NOCRED), p); + ((p != NULL) ? p->p_ucred : NOCRED), td); mp->mnt_flag |= asyncflag; } simple_lock(&mountlist_slock); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } simple_unlock(&mountlist_slock); #if 0 @@ -606,21 +611,23 @@ SYSCTL_INT(_kern_prison, OID_AUTO, quotas, CTLFLAG_RW, &prison_quotas, 0, ""); int quotactl(struct quotactl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct mount *mp; int error; struct nameidata nd; + KKASSERT(p); if (p->p_ucred->cr_prison && !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); mp = nd.ni_vp->v_mount; NDFREE(&nd, NDF_ONLY_PNBUF); vrele(nd.ni_vp); return (VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid), - SCARG(uap, arg), p)); + SCARG(uap, arg), td)); } /* @@ -632,25 +639,27 @@ quotactl(struct quotactl_args *uap) int statfs(struct statfs_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct mount *mp; struct statfs *sp; int error; struct nameidata nd; struct statfs sb; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + KKASSERT(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)) { + if (suser(td)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -667,24 +676,26 @@ statfs(struct statfs_args *uap) int fstatfs(struct fstatfs_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; struct mount *mp; register struct statfs *sp; int error; struct statfs sb; + KKASSERT(p); if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; if (mp == NULL) return (EBADF); 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)) { + if (suser(td)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -701,7 +712,8 @@ fstatfs(struct fstatfs_args *uap) int getfsstat(struct getfsstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct mount *mp, *nmp; struct statfs *sp; caddr_t sfsp; @@ -712,7 +724,7 @@ getfsstat(struct getfsstat_args *uap) count = 0; simple_lock(&mountlist_slock); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, td)) { nmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -725,16 +737,16 @@ getfsstat(struct getfsstat_args *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))) { simple_lock(&mountlist_slock); 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); @@ -742,7 +754,7 @@ getfsstat(struct getfsstat_args *uap) count++; simple_lock(&mountlist_slock); nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } simple_unlock(&mountlist_slock); if (sfsp && count > maxcount) @@ -761,7 +773,8 @@ getfsstat(struct getfsstat_args *uap) int fchdir(struct fchdir_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct vnode *vp, *tdp; struct mount *mp; @@ -772,16 +785,16 @@ fchdir(struct fchdir_args *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, p->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); @@ -791,7 +804,7 @@ fchdir(struct fchdir_args *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); @@ -806,14 +819,15 @@ fchdir(struct fchdir_args *uap) int chdir(struct chdir_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->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); @@ -868,12 +882,14 @@ SYSCTL_INT(_kern, OID_AUTO, chroot_allow_open_directories, CTLFLAG_RW, int chroot(struct chroot_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; int error; struct nameidata nd; - error = suser_xxx(0, PRISON_ROOT); + KKASSERT(p); + error = suser_cred(p->p_ucred, PRISON_ROOT); if (error) return (error); if (chroot_allow_open_directories == 0 || @@ -882,8 +898,8 @@ chroot(struct chroot_args *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); @@ -899,7 +915,7 @@ chroot(struct chroot_args *uap) * Common routine for chroot and chdir. */ static int -change_dir(struct nameidata *ndp, struct proc *p) +change_dir(struct nameidata *ndp, struct thread *td) { struct vnode *vp; int error; @@ -911,11 +927,11 @@ change_dir(struct nameidata *ndp, struct proc *p) if (vp->v_type != VDIR) error = ENOTDIR; else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + error = VOP_ACCESS(vp, VEXEC, ndp->ni_cnd.cn_cred, td); if (error) vput(vp); else - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -928,7 +944,8 @@ change_dir(struct nameidata *ndp, struct proc *p) int open(struct open_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp; struct vnode *vp; @@ -947,7 +964,7 @@ open(struct open_args *uap) return (error); fp = nfp; cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); p->p_dupfd = -indx - 1; /* XXX check for fdopen */ /* * Bump the ref count to prevent another process from closing @@ -959,7 +976,7 @@ open(struct open_args *uap) /* * release our own reference */ - fdrop(fp, p); + fdrop(fp, td); /* * handle special fdopen() case. bleh. dupfdopen() is @@ -979,7 +996,7 @@ open(struct open_args *uap) */ if (fdp->fd_ofiles[indx] == fp) { fdp->fd_ofiles[indx] = NULL; - fdrop(fp, p); + fdrop(fp, td); } if (error == ERESTART) @@ -1001,9 +1018,9 @@ open(struct open_args *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); + VOP_UNLOCK(vp, 0, td); + vn_close(vp, flags & FMASK, fp->f_cred, td); + fdrop(fp, td); p->p_retval[0] = indx; return 0; } @@ -1023,7 +1040,7 @@ open(struct open_args *uap) type = F_FLOCK; if ((flags & 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) { /* * lock request failed. Normally close the descriptor @@ -1033,24 +1050,24 @@ open(struct open_args *uap) */ 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); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); fp->f_flag |= FHASLOCK; } /* assert that vn_open created a backing object if one is needed */ KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0, ("open: vmio vnode has no backing object after vn_open")); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); /* * release our private reference, leaving the one associated with the * descriptor table intact. */ - fdrop(fp, p); + fdrop(fp, td); p->p_retval[0] = indx; return (0); } @@ -1086,26 +1103,29 @@ ocreat(struct ocreat_args *uap) int mknod(struct mknod_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct vattr vattr; int error; int whiteout = 0; struct nameidata nd; + KKASSERT(p); + switch (SCARG(uap, mode) & S_IFMT) { case S_IFCHR: case S_IFBLK: - error = suser(); + error = suser(td); break; default: - error = suser_xxx(0, PRISON_ROOT); + error = suser_cred(p->p_ucred, PRISON_ROOT); break; } if (error) return (error); 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; @@ -1136,7 +1156,7 @@ mknod(struct mknod_args *uap) } } if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, p->p_ucred, LEASE_WRITE); if (whiteout) error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, CREATE); else { @@ -1170,13 +1190,14 @@ mknod(struct mknod_args *uap) int mkfifo(struct mkfifo_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vattr vattr; int error; struct nameidata nd; 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) { @@ -1191,7 +1212,7 @@ mkfifo(struct mkfifo_args *uap) 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); + VOP_LEASE(nd.ni_dvp, td, p->p_ucred, LEASE_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); if (error == 0) vput(nd.ni_vp); @@ -1209,13 +1230,14 @@ mkfifo(struct mkfifo_args *uap) int link(struct link_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct nameidata nd; 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); @@ -1223,7 +1245,7 @@ link(struct link_args *uap) if (vp->v_type == VDIR) error = EPERM; /* POSIX */ else { - NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p); + NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td); error = namei(&nd); if (!error) { if (nd.ni_vp != NULL) { @@ -1231,9 +1253,9 @@ link(struct link_args *uap) vrele(nd.ni_vp); error = EEXIST; } else { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, + VOP_LEASE(nd.ni_dvp, td, p->p_ucred, LEASE_WRITE); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1258,7 +1280,8 @@ link(struct link_args *uap) int symlink(struct symlink_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vattr vattr; char *path; int error; @@ -1268,7 +1291,7 @@ symlink(struct symlink_args *uap) if ((error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL)) != 0) goto out; 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) { @@ -1283,7 +1306,7 @@ symlink(struct symlink_args *uap) } VATTR_NULL(&vattr); vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask; - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, p->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) @@ -1305,13 +1328,14 @@ out: int undelete(struct undelete_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; struct nameidata nd; bwillwrite(); NDINIT(&nd, DELETE, LOCKPARENT|DOWHITEOUT, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); error = namei(&nd); if (error) return (error); @@ -1327,7 +1351,7 @@ undelete(struct undelete_args *uap) return (EEXIST); } - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, p->p_ucred, LEASE_WRITE); error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); @@ -1344,18 +1368,19 @@ undelete(struct undelete_args *uap) int unlink(struct unlink_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; int error; struct nameidata nd; 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; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (vp->v_type == VDIR) error = EPERM; /* POSIX */ @@ -1370,7 +1395,7 @@ unlink(struct unlink_args *uap) } if (!error) { - VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(nd.ni_dvp, td, p->p_ucred, LEASE_WRITE); error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1393,7 +1418,8 @@ unlink(struct unlink_args *uap) int lseek(struct lseek_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct ucred *cred = p->p_ucred; struct filedesc *fdp = p->p_fd; struct file *fp; @@ -1410,7 +1436,7 @@ lseek(struct lseek_args *uap) fp->f_offset += SCARG(uap, offset); break; case L_XTND: - error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p); + error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, td); if (error) return (error); fp->f_offset = SCARG(uap, offset) + vattr.va_size; @@ -1458,7 +1484,8 @@ olseek(struct olseek_args *uap) int access(struct access_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct ucred *cred, *tmpcred; struct vnode *vp; int error, flags; @@ -1475,7 +1502,7 @@ access(struct access_args *uap) tmpcred->cr_groups[0] = p->p_ucred->cr_rgid; p->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; @@ -1490,7 +1517,7 @@ access(struct access_args *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); @@ -1510,18 +1537,18 @@ out1: int ostat(struct ostat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat sb; struct ostat osb; int error; 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); @@ -1539,7 +1566,7 @@ ostat(struct ostat_args *uap) int olstat(struct olstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct vnode *vp; struct stat sb; struct ostat osb; @@ -1547,11 +1574,11 @@ olstat(struct olstat_args *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) @@ -1599,16 +1626,16 @@ cvtstat(st, ost) int stat(struct stat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat sb; int error; 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) @@ -1626,18 +1653,18 @@ stat(struct stat_args *uap) int lstat(struct lstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; int error; struct vnode *vp; struct stat sb; 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) @@ -1677,18 +1704,18 @@ cvtnstat(sb, nsb) int nstat(struct nstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat sb; struct nstat nsb; int error; 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); @@ -1706,7 +1733,7 @@ nstat(struct nstat_args *uap) int nlstat(struct nlstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; int error; struct vnode *vp; struct stat sb; @@ -1714,12 +1741,12 @@ nlstat(struct nlstat_args *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); @@ -1737,12 +1764,13 @@ nlstat(struct nlstat_args *uap) int pathconf(struct pathconf_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; 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); @@ -1760,7 +1788,8 @@ pathconf(struct pathconf_args *uap) int readlink(struct readlink_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct iovec aiov; struct uio auio; @@ -1768,7 +1797,7 @@ readlink(struct readlink_args *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); @@ -1783,7 +1812,7 @@ readlink(struct readlink_args *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); } @@ -1795,7 +1824,8 @@ readlink(struct readlink_args *uap) static int setfflags(struct vnode *vp, int flags) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; struct vattr vattr; @@ -1806,15 +1836,15 @@ setfflags(struct vnode *vp, int flags) * chown can't fail when done as root. */ if ((vp->v_type == VCHR || vp->v_type == VBLK) && - ((error = suser_xxx(p->p_ucred, PRISON_ROOT)) != 0)) + ((error = suser_cred(p->p_ucred, PRISON_ROOT)) != 0)) return (error); - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->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, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -1827,11 +1857,11 @@ setfflags(struct vnode *vp, int flags) int chflags(struct chflags_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; 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); @@ -1849,7 +1879,8 @@ chflags(struct chflags_args *uap) int fchflags(struct fchflags_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; @@ -1861,16 +1892,17 @@ fchflags(struct fchflags_args *uap) static int setfmode(struct vnode *vp, int mode) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; struct vattr vattr; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->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, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return error; } @@ -1883,11 +1915,11 @@ setfmode(struct vnode *vp, int mode) int chmod(struct chmod_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; 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); @@ -1905,11 +1937,11 @@ chmod(struct chmod_args *uap) int lchmod(struct lchmod_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; 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); @@ -1927,7 +1959,8 @@ lchmod(struct lchmod_args *uap) int fchmod(struct fchmod_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; @@ -1939,17 +1972,18 @@ fchmod(struct fchmod_args *uap) static int setfown(struct vnode *vp, uid_t uid, gid_t gid) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; struct vattr vattr; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->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, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return error; } @@ -1962,11 +1996,11 @@ setfown(struct vnode *vp, uid_t uid, gid_t gid) int chown(struct chown_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; 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); @@ -1984,11 +2018,11 @@ chown(struct chown_args *uap) int lchown(struct lchown_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; 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); @@ -2006,7 +2040,8 @@ lchown(struct lchown_args *uap) int fchown(struct fchown_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct file *fp; int error; @@ -2038,19 +2073,20 @@ getutimes(const struct timeval *usrtvp, struct timespec *tsp) static int setutimes(struct vnode *vp, const struct timespec *ts, int nullflag) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; struct vattr vattr; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->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, p->p_ucred, td); + VOP_UNLOCK(vp, 0, td); return error; } @@ -2063,7 +2099,7 @@ setutimes(struct vnode *vp, const struct timespec *ts, int nullflag) int utimes(struct utimes_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct timespec ts[2]; struct timeval *usrtvp; int error; @@ -2072,7 +2108,7 @@ utimes(struct utimes_args *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); @@ -2090,7 +2126,7 @@ utimes(struct utimes_args *uap) int lutimes(struct lutimes_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct timespec ts[2]; struct timeval *usrtvp; int error; @@ -2099,7 +2135,7 @@ lutimes(struct lutimes_args *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); @@ -2117,7 +2153,8 @@ lutimes(struct lutimes_args *uap) int futimes(struct futimes_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct timespec ts[2]; struct file *fp; struct timeval *usrtvp; @@ -2140,7 +2177,8 @@ futimes(struct futimes_args *uap) int truncate(struct truncate_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct vattr vattr; int error; @@ -2148,20 +2186,20 @@ truncate(struct truncate_args *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; 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, p->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, p->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, p->p_ucred, td); } vput(vp); return (error); @@ -2176,7 +2214,8 @@ truncate(struct truncate_args *uap) int ftruncate(struct ftruncate_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vattr vattr; struct vnode *vp; struct file *fp; @@ -2189,16 +2228,16 @@ ftruncate(struct ftruncate_args *uap) if ((fp->f_flag & FWRITE) == 0) return (EINVAL); vp = (struct vnode *)fp->f_data; - VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LEASE(vp, td, p->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); return (error); } @@ -2253,7 +2292,8 @@ oftruncate(struct oftruncate_args *uap) int fsync(struct fsync_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct file *fp; vm_object_t obj; @@ -2262,14 +2302,14 @@ fsync(struct fsync_args *uap) if ((error = getvnode(p->p_fd, 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 (VOP_GETVOBJECT(vp, &obj) == 0) vm_object_page_clean(obj, 0, 0, 0); - if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p)) == 0 && + if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td)) == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) && bioops.io_fsync) error = (*bioops.io_fsync)(vp); - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -2283,19 +2323,20 @@ fsync(struct fsync_args *uap) int rename(struct rename_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *tvp, *fvp, *tdvp; struct nameidata fromnd, tond; int error; 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; 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) { @@ -2328,12 +2369,12 @@ rename(struct rename_args *uap) error = -1; out: if (!error) { - VOP_LEASE(tdvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tdvp, td, p->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, p->p_ucred, LEASE_WRITE); } if (tvp) { - VOP_LEASE(tvp, p, p->p_ucred, LEASE_WRITE); + VOP_LEASE(tvp, td, p->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); @@ -2373,14 +2414,15 @@ out1: int mkdir(struct mkdir_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct vattr vattr; int error; struct nameidata nd; bwillwrite(); - NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p); + NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td); nd.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&nd)) != 0) return (error); @@ -2397,7 +2439,7 @@ mkdir(struct mkdir_args *uap) 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); + VOP_LEASE(nd.ni_dvp, td, p->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); @@ -2417,14 +2459,15 @@ mkdir(struct mkdir_args *uap) int rmdir(struct rmdir_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; int error; struct nameidata nd; 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; @@ -2445,8 +2488,8 @@ rmdir(struct rmdir_args *uap) if (vp->v_flag & VROOT) error = EBUSY; 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, p->p_ucred, LEASE_WRITE); + VOP_LEASE(vp, td, p->p_ucred, LEASE_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); } out: @@ -2471,7 +2514,8 @@ out: int ogetdirentries(struct ogetdirentries_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct file *fp; struct uio auio, kuio; @@ -2498,9 +2542,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) { @@ -2553,12 +2597,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) @@ -2590,7 +2634,8 @@ unionread: int getdirentries(struct getdirentries_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct file *fp; struct uio auio; @@ -2612,19 +2657,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) @@ -2674,7 +2719,8 @@ getdents(struct getdents_args *uap) int umask(struct umask_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp; fdp = p->p_fd; @@ -2693,13 +2739,14 @@ umask(struct umask_args *uap) int revoke(struct revoke_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct vnode *vp; struct vattr vattr; 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; @@ -2708,10 +2755,10 @@ revoke(struct revoke_args *uap) error = EINVAL; goto out; } - if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, td)) != 0) goto out; if (p->p_ucred->cr_uid != vattr.va_uid && - (error = suser_xxx(0, PRISON_ROOT))) + (error = suser_cred(p->p_ucred, PRISON_ROOT))) goto out; if (vcount(vp) > 1) VOP_REVOKE(vp, REVOKEALL); @@ -2744,7 +2791,7 @@ getvnode(struct filedesc *fdp, int fd, struct file **fpp) int getfh(struct getfh_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; fhandle_t fh; struct vnode *vp; @@ -2753,10 +2800,10 @@ getfh(struct getfh_args *uap) /* * Must be super user */ - error = suser(); + error = suser(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); @@ -2784,7 +2831,8 @@ getfh(struct getfh_args *uap) int fhopen(struct fhopen_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct mount *mp; struct vnode *vp; struct fhandle fhp; @@ -2800,7 +2848,7 @@ fhopen(struct fhopen_args *uap) /* * Must be super user */ - error = suser(); + error = suser(td); if (error) return (error); @@ -2851,28 +2899,28 @@ fhopen(struct fhopen_args *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_LEASE(vp, p, p->p_ucred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* XXX */ + VOP_UNLOCK(vp, 0, td); /* 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); 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) @@ -2909,7 +2957,7 @@ fhopen(struct fhopen_args *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) { /* * lock request failed. Normally close the descriptor @@ -2918,23 +2966,23 @@ fhopen(struct fhopen_args *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); + VOP_UNLOCK(vp, 0, td); + fdrop(fp, td); p->p_retval[0] = indx; return (0); @@ -2949,7 +2997,7 @@ bad: int fhstat(struct fhstat_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct stat sb; fhandle_t fh; struct mount *mp; @@ -2959,7 +3007,7 @@ fhstat(struct fhstat_args *uap) /* * Must be super user */ - error = suser(); + error = suser(td); if (error) return (error); @@ -2971,7 +3019,7 @@ fhstat(struct fhstat_args *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); @@ -2985,7 +3033,7 @@ fhstat(struct fhstat_args *uap) int fhstatfs(struct fhstatfs_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct statfs *sp; struct mount *mp; struct vnode *vp; @@ -2996,7 +3044,7 @@ fhstatfs(struct fhstatfs_args *uap) /* * Must be super user */ - if ((error = suser())) + if ((error = suser(td))) return (error); if ((error = copyin(SCARG(uap, u_fhp), &fh, sizeof(fhandle_t))) != 0) @@ -3009,10 +3057,10 @@ fhstatfs(struct fhstatfs_args *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)) { + if (suser(td)) { bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb)); sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; sp = &sb; @@ -3034,18 +3082,18 @@ fhstatfs(struct fhstatfs_args *uap) int extattrctl(struct extattrctl_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct nameidata nd; struct mount *mp; int 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); mp = nd.ni_vp->v_mount; NDFREE(&nd, 0); return (VFS_EXTATTRCTL(mp, SCARG(uap, cmd), SCARG(uap, attrname), - SCARG(uap, arg), p)); + SCARG(uap, arg), td)); } /* @@ -3057,7 +3105,8 @@ extattrctl(struct extattrctl_args *uap) int extattr_set_file(struct extattr_set_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct nameidata nd; struct uio auio; struct iovec *iov, *needfree = NULL, aiov[UIO_SMALLIOV]; @@ -3069,7 +3118,7 @@ extattr_set_file(struct extattr_set_file_args *uap) if (error) return (error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return(error); iovlen = uap->iovcnt * sizeof(struct iovec); @@ -3086,7 +3135,7 @@ extattr_set_file(struct extattr_set_file_args *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 = 0; if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) goto done; @@ -3100,7 +3149,7 @@ extattr_set_file(struct extattr_set_file_args *uap) iov++; } cnt = auio.uio_resid; - error = VOP_SETEXTATTR(nd.ni_vp, attrname, &auio, p->p_ucred, p); + error = VOP_SETEXTATTR(nd.ni_vp, attrname, &auio, p->p_ucred, td); cnt -= auio.uio_resid; p->p_retval[0] = cnt; done: @@ -3119,7 +3168,8 @@ done: int extattr_get_file(struct extattr_get_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct nameidata nd; struct uio auio; struct iovec *iov, *needfree, aiov[UIO_SMALLIOV]; @@ -3131,7 +3181,7 @@ extattr_get_file(struct extattr_get_file_args *uap) if (error) return (error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return (error); iovlen = uap->iovcnt * sizeof (struct iovec); @@ -3150,7 +3200,7 @@ extattr_get_file(struct extattr_get_file_args *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 = 0; if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen))) goto done; @@ -3164,7 +3214,7 @@ extattr_get_file(struct extattr_get_file_args *uap) iov++; } cnt = auio.uio_resid; - error = VOP_GETEXTATTR(nd.ni_vp, attrname, &auio, p->p_ucred, p); + error = VOP_GETEXTATTR(nd.ni_vp, attrname, &auio, p->p_ucred, td); cnt -= auio.uio_resid; p->p_retval[0] = cnt; done: @@ -3181,7 +3231,8 @@ done: int extattr_delete_file(struct extattr_delete_file_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct nameidata nd; char attrname[EXTATTR_MAXNAMELEN]; int error; @@ -3190,10 +3241,10 @@ extattr_delete_file(struct extattr_delete_file_args *uap) if (error) return(error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); + SCARG(uap, path), td); if ((error = namei(&nd)) != 0) return(error); - error = VOP_SETEXTATTR(nd.ni_vp, attrname, NULL, p->p_ucred, p); + error = VOP_SETEXTATTR(nd.ni_vp, attrname, NULL, p->p_ucred, td); NDFREE(&nd, 0); return(error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 55a19f1a1a..1b1f53ab22 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -37,7 +37,7 @@ * * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/vfs_vnops.c,v 1.87.2.13 2002/12/29 18:19:53 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_vnops.c,v 1.3 2003/06/23 17:55:42 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_vnops.c,v 1.4 2003/06/25 03:55:57 dillon Exp $ */ #include @@ -55,17 +55,17 @@ #include #include -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, @@ -85,12 +85,14 @@ vn_open(ndp, fmode, cmode) int fmode, cmode; { register struct vnode *vp; - register struct proc *p = ndp->ni_cnd.cn_proc; - register struct ucred *cred = p->p_ucred; + register struct thread *td = ndp->ni_cnd.cn_td; + register struct ucred *cred = ndp->ni_cnd.cn_cred; struct vattr vat; struct vattr *vap = &vat; int mode, error; + KKASSERT(cred == td->td_proc->p_ucred); + if (fmode & O_CREAT) { ndp->ni_cnd.cn_nameiop = CREATE; ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; @@ -106,7 +108,7 @@ vn_open(ndp, fmode, cmode) vap->va_mode = cmode; if (fmode & O_EXCL) vap->va_vaflags |= VA_EXCLUSIVE; - 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); if (error) { @@ -164,29 +166,29 @@ vn_open(ndp, fmode, cmode) 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 (fmode & O_TRUNC) { - VOP_UNLOCK(vp, 0, p); /* XXX */ - VOP_LEASE(vp, p, cred, LEASE_WRITE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* XXX */ + VOP_UNLOCK(vp, 0, td); /* XXX */ + VOP_LEASE(vp, td, cred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); /* XXX */ VATTR_NULL(vap); vap->va_size = 0; - error = VOP_SETATTR(vp, vap, cred, p); + error = VOP_SETATTR(vp, vap, cred, td); if (error) goto bad; } - error = VOP_OPEN(vp, fmode, cred, p); + error = VOP_OPEN(vp, fmode, cred, 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, cred)) != 0) + if ((error = vfs_object_create(vp, td, cred)) != 0) goto bad; } @@ -222,17 +224,13 @@ vn_writechk(vp) * Vnode close call */ int -vn_close(vp, flags, cred, p) - register struct vnode *vp; - int flags; - struct ucred *cred; - struct proc *p; +vn_close(struct vnode *vp, int flags, struct ucred *cred, 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); vrele(vp); return (error); } @@ -274,7 +272,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; @@ -284,14 +282,14 @@ 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; int error; if ((ioflg & IO_NODELOCKED) == 0) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = base; @@ -300,7 +298,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 { @@ -312,7 +310,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) if (auio.uio_resid && error == 0) error = EIO; if ((ioflg & IO_NODELOCKED) == 0) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (error); } @@ -325,7 +323,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p) * core'ing the same binary, or unrelated processes scanning the directory). */ 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; @@ -335,7 +333,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; @@ -345,7 +343,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; @@ -362,26 +360,25 @@ 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; @@ -391,7 +388,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); } @@ -399,18 +396,18 @@ 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; 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_procp %p is not p %p", + uio->uio_td, td)); vp = (struct vnode *)fp->f_data; if (vp->v_type == VREG) bwillwrite(); @@ -425,8 +422,8 @@ vn_write(fp, uio, cred, flags, p) if ((fp->f_flag & O_FSYNC) || (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS))) ioflag |= IO_SYNC; - 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); @@ -434,7 +431,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); return (error); } @@ -442,29 +439,25 @@ vn_write(fp, uio, cred, flags, p) * File table vnode stat routine. */ static int -vn_statfile(fp, sb, p) - struct file *fp; - struct stat *sb; - struct proc *p; +vn_statfile(struct file *fp, struct stat *sb, 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) - struct vnode *vp; - register struct stat *sb; - struct proc *p; +vn_stat(struct vnode *vp, struct stat *sb, struct thread *td) { + struct proc *p = td->td_proc; struct vattr vattr; - register struct vattr *vap; + struct vattr *vap; int error; u_short mode; + KKASSERT(p); vap = &vattr; - error = VOP_GETATTR(vp, vap, p->p_ucred, p); + error = VOP_GETATTR(vp, vap, p->p_ucred, td); if (error) return (error); @@ -545,7 +538,7 @@ vn_stat(vp, sb, p) } sb->st_flags = vap->va_flags; - if (suser_xxx(p->p_ucred, 0)) + if (suser(td)) sb->st_gen = 0; else sb->st_gen = vap->va_gen; @@ -563,22 +556,21 @@ vn_stat(vp, sb, p) * File table vnode ioctl routine. */ static int -vn_ioctl(fp, com, data, p) - struct file *fp; - u_long com; - caddr_t data; - struct proc *p; +vn_ioctl(struct file *fp, u_long com, caddr_t data, struct thread *td) { - register struct vnode *vp = ((struct vnode *)fp->f_data); + struct vnode *vp = ((struct vnode *)fp->f_data); + struct ucred *ucred; struct vattr vattr; int error; - switch (vp->v_type) { + KKASSERT(td->td_proc != NULL); + ucred = td->td_proc->p_ucred; + switch (vp->v_type) { case VREG: case VDIR: if (com == FIONREAD) { - error = VOP_GETATTR(vp, &vattr, p->p_ucred, p); + error = VOP_GETATTR(vp, &vattr, ucred, td); if (error) return (error); *(int *)data = vattr.va_size - fp->f_offset; @@ -587,7 +579,6 @@ vn_ioctl(fp, com, data, p) if (com == FIONBIO || com == FIOASYNC) /* XXX */ return (0); /* XXX */ /* fall into ... */ - default: #if 0 return (ENOTTY); @@ -601,18 +592,19 @@ 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, ucred, td); if (error == 0 && com == TIOCSCTTY) { + struct session *sess = td->td_proc->p_session; /* Do nothing if reassigning same control tty */ - if (p->p_session->s_ttyvp == vp) + if (sess->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 (sess->s_ttyvp) + vrele(sess->s_ttyvp); - p->p_session->s_ttyvp = vp; + sess->s_ttyvp = vp; VREF(vp); } return (error); @@ -623,14 +615,9 @@ vn_ioctl(fp, com, data, p) * File table vnode poll routine. */ static int -vn_poll(fp, events, cred, p) - struct file *fp; - int events; - struct ucred *cred; - struct proc *p; +vn_poll(struct file *fp, int events, struct ucred *cred, 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)); } /* @@ -639,16 +626,10 @@ vn_poll(fp, events, cred, p) */ int #ifndef DEBUG_LOCKS -vn_lock(vp, flags, p) +vn_lock(struct vnode *vp, int flags, struct thread *td) #else -debug_vn_lock(vp, flags, p, filename, line) -#endif - struct vnode *vp; - int flags; - struct proc *p; -#ifdef DEBUG_LOCKS - const char *filename; - int line; +debug_vn_lock(struct vnode *vp, int flags, struct thread *td, + const char *filename, int line) #endif { int error; @@ -672,7 +653,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); } @@ -685,14 +666,13 @@ debug_vn_lock(vp, flags, p, filename, line) * File table vnode close routine. */ static int -vn_closefile(fp, p) - struct file *fp; - struct proc *p; +vn_closefile(struct file *fp, struct thread *td) { + int err; fp->f_ops = &badfileops; - return (vn_close(((struct vnode *)fp->f_data), fp->f_flag, - fp->f_cred, p)); + err = vn_close(((struct vnode *)fp->f_data), fp->f_flag, fp->f_cred, td); + return(err); } static int diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 748f561e6e..8eefe6ee82 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -32,7 +32,7 @@ # # @(#)vnode_if.src 8.12 (Berkeley) 5/14/95 # $FreeBSD: src/sys/kern/vnode_if.src,v 1.29.2.3 2001/05/18 09:58:45 bp Exp $ -# $DragonFly: src/sys/kern/Attic/vnode_if.src,v 1.2 2003/06/17 04:28:42 dillon Exp $ +# $DragonFly: src/sys/kern/Attic/vnode_if.src,v 1.3 2003/06/25 03:55:57 dillon Exp $ # # @@ -60,7 +60,7 @@ # vop_islocked { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -127,7 +127,7 @@ vop_open { IN struct vnode *vp; IN int mode; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -137,7 +137,7 @@ vop_close { IN struct vnode *vp; IN int fflag; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -147,7 +147,7 @@ vop_access { IN struct vnode *vp; IN int mode; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -157,7 +157,7 @@ vop_getattr { IN struct vnode *vp; OUT struct vattr *vap; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -167,7 +167,7 @@ vop_setattr { IN struct vnode *vp; IN struct vattr *vap; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -195,7 +195,7 @@ vop_write { # vop_lease { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; IN struct ucred *cred; IN int flag; }; @@ -209,7 +209,7 @@ vop_ioctl { IN caddr_t data; IN int fflag; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -219,7 +219,7 @@ vop_poll { IN struct vnode *vp; IN int events; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -245,7 +245,7 @@ vop_mmap { IN struct vnode *vp; IN int fflags; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -255,7 +255,7 @@ vop_fsync { IN struct vnode *vp; IN struct ucred *cred; IN int waitfor; - IN struct proc *p; + IN struct thread *td; }; # @@ -352,7 +352,7 @@ vop_readlink { # vop_inactive { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -360,7 +360,7 @@ vop_inactive { # vop_reclaim { IN struct vnode *vp; - IN struct proc *p; + IN struct thread *td; }; # @@ -369,7 +369,7 @@ vop_reclaim { vop_lock { IN struct vnode *vp; IN int flags; - IN struct proc *p; + IN struct thread *td; }; # @@ -378,7 +378,7 @@ vop_lock { vop_unlock { IN struct vnode *vp; IN int flags; - IN struct proc *p; + IN struct thread *td; }; # @@ -502,7 +502,7 @@ vop_getacl { IN acl_type_t type; OUT struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -513,7 +513,7 @@ vop_setacl { IN acl_type_t type; IN struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -524,7 +524,7 @@ vop_aclcheck { IN acl_type_t type; IN struct acl *aclp; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -535,7 +535,7 @@ vop_getextattr { IN char *name; INOUT struct uio *uio; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -546,7 +546,7 @@ vop_setextattr { IN char *name; INOUT struct uio *uio; IN struct ucred *cred; - IN struct proc *p; + IN struct thread *td; }; # @@ -555,7 +555,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/net/gre/if_gre.c b/sys/net/gre/if_gre.c index 7fd559af15..d7dfef01e5 100644 --- a/sys/net/gre/if_gre.c +++ b/sys/net/gre/if_gre.c @@ -1,6 +1,6 @@ /* $NetBSD: if_gre.c,v 1.42 2002/08/14 00:23:27 itojun Exp $ */ /* $FreeBSD: src/sys/net/if_gre.c,v 1.9.2.3 2003/01/23 21:06:44 sam Exp $ */ -/* $DragonFly: src/sys/net/gre/if_gre.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ */ +/* $DragonFly: src/sys/net/gre/if_gre.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -433,7 +433,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct sockaddr *sa = NULL; int error; struct sockaddr_in sp, sm, dp, dm; - struct proc *p = curproc; + struct thread *td = curthread; error = 0; @@ -445,7 +445,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFDSTADDR: break; case SIOCSIFFLAGS: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if ((ifr->ifr_flags & IFF_LINK0) != 0) sc->g_proto = IPPROTO_GRE; @@ -453,7 +453,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) sc->g_proto = IPPROTO_MOBILE; goto recompute; case SIOCSIFMTU: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (ifr->ifr_mtu < 576) { error = EINVAL; @@ -466,7 +466,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCADDMULTI: case SIOCDELMULTI: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (ifr == 0) { error = EAFNOSUPPORT; @@ -483,7 +483,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } break; case GRESPROTO: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; sc->g_proto = ifr->ifr_flags; switch (sc->g_proto) { @@ -503,7 +503,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case GRESADDRS: case GRESADDRD: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; /* * set tunnel endpoints, compute a less specific route @@ -569,7 +569,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifr->ifr_addr = *sa; break; case SIOCSIFPHYADDR: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (aifr->ifra_addr.sin_family != AF_INET || aifr->ifra_dstaddr.sin_family != AF_INET) { @@ -585,7 +585,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) sc->g_dst = aifr->ifra_dstaddr.sin_addr; goto recompute; case SIOCSLIFPHYADDR: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (lifr->addr.ss_family != AF_INET || lifr->dstaddr.ss_family != AF_INET) { @@ -602,7 +602,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) (satosin((struct sockadrr *)&lifr->dstaddr))->sin_addr; goto recompute; case SIOCDIFPHYADDR: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; sc->g_src.s_addr = INADDR_ANY; sc->g_dst.s_addr = INADDR_ANY; diff --git a/sys/net/i4b/driver/i4b_ipr.c b/sys/net/i4b/driver/i4b_ipr.c index 70e0e2dc18..ecdd665952 100644 --- a/sys/net/i4b/driver/i4b_ipr.c +++ b/sys/net/i4b/driver/i4b_ipr.c @@ -28,7 +28,7 @@ * --------------------------------------------------------- * * $FreeBSD: src/sys/i4b/driver/i4b_ipr.c,v 1.8.2.3 2001/10/27 15:48:17 hm Exp $ - * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.2 2003/06/17 04:28:39 dillon Exp $ + * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.3 2003/06/25 03:55:55 dillon Exp $ * * last edit-date: [Fri Oct 26 19:32:38 2001] * @@ -617,13 +617,10 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) #ifdef IPR_VJ case IPRIOCSMAXCID: { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ #if defined(__FreeBSD_version) && __FreeBSD_version >= 400005 - if((error = suser(p)) != 0) -#else - if((error = suser(p->p_ucred, &p->p_acflag)) != 0) -#endif + if ((error = suser(td)) != 0) return (error); sl_compress_setup(sc->sc_compr, *(int *)data); } diff --git a/sys/net/if.c b/sys/net/if.c index 1605fa9c57..36f3484d99 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -32,7 +32,7 @@ * * @(#)if.c 8.3 (Berkeley) 1/4/94 * $FreeBSD: src/sys/net/if.c,v 1.85.2.23 2003/04/15 18:11:19 fjoe Exp $ - * $DragonFly: src/sys/net/if.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/if.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ #include "opt_compat.h" @@ -941,7 +941,7 @@ if_withname(sa) * Interface ioctls. */ int -ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) +ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) { struct ifnet *ifp; struct ifreq *ifr; @@ -961,7 +961,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) switch (cmd) { case SIOCIFCREATE: case SIOCIFDESTROY: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); return ((cmd == SIOCIFCREATE) ? if_clone_create(ifr->ifr_name, sizeof(ifr->ifr_name)) : @@ -999,7 +999,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) break; case SIOCSIFFLAGS: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); new_flags = (ifr->ifr_flags & 0xffff) | @@ -1033,7 +1033,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) break; case SIOCSIFCAP: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); if (ifr->ifr_reqcap & ~ifp->if_capabilities) @@ -1042,7 +1042,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) break; case SIOCSIFMETRIC: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); ifp->if_metric = ifr->ifr_metric; @@ -1050,7 +1050,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) break; case SIOCSIFPHYS: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return error; if (!ifp->if_ioctl) @@ -1064,7 +1064,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) { u_long oldmtu = ifp->if_mtu; - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); if (ifp->if_ioctl == NULL) @@ -1089,7 +1089,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) case SIOCADDMULTI: case SIOCDELMULTI: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); @@ -1119,7 +1119,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) case SIOCSLIFPHYADDR: case SIOCSIFMEDIA: case SIOCSIFGENERIC: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); if (ifp->if_ioctl == 0) @@ -1143,7 +1143,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) return ((*ifp->if_ioctl)(ifp, cmd, data)); case SIOCSIFLLADDR: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error) return (error); return if_setlladdr(ifp, @@ -1194,10 +1194,8 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) case OSIOCGIFNETMASK: cmd = SIOCGIFNETMASK; } - error = ((*so->so_proto->pr_usrreqs->pru_control)(so, - cmd, - data, - ifp, p)); + error = ((*so->so_proto->pr_usrreqs->pru_control) + (so, cmd, data, ifp, td)); switch (ocmd) { case OSIOCGIFADDR: @@ -1315,7 +1313,7 @@ ifconf(u_long cmd, caddr_t data) if (space <= sizeof(ifr)) break; sa = ifa->ifa_addr; - if (curproc->p_ucred->cr_prison && prison_if(curproc, sa)) + if (curproc->p_ucred->cr_prison && prison_if(curthread, sa)) continue; addrs++; #ifdef COMPAT_43 diff --git a/sys/net/if.h b/sys/net/if.h index 3a4c204770..d6114a6205 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -32,7 +32,7 @@ * * @(#)if.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/if.h,v 1.58.2.9 2002/08/30 14:23:38 sobomax Exp $ - * $DragonFly: src/sys/net/if.h,v 1.2 2003/06/17 04:28:47 dillon Exp $ + * $DragonFly: src/sys/net/if.h,v 1.3 2003/06/25 03:56:02 dillon Exp $ */ #ifndef _NET_IF_H_ @@ -337,9 +337,9 @@ __END_DECLS #endif #ifdef _KERNEL -struct proc; +struct thread; -int prison_if __P((struct proc *p, struct sockaddr *sa)); +int prison_if __P((struct thread *td, struct sockaddr *sa)); /* XXX - this should go away soon. */ #include diff --git a/sys/net/if_var.h b/sys/net/if_var.h index a451bcf345..6768438eb7 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -32,7 +32,7 @@ * * From: @(#)if.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.16 2003/04/15 18:11:19 fjoe Exp $ - * $DragonFly: src/sys/net/if_var.h,v 1.2 2003/06/17 04:28:48 dillon Exp $ + * $DragonFly: src/sys/net/if_var.h,v 1.3 2003/06/25 03:56:02 dillon Exp $ */ #ifndef _NET_IF_VAR_H_ @@ -398,7 +398,7 @@ int if_setlladdr(struct ifnet *, const u_char *, int); void if_unroute(struct ifnet *, int flag, int fam); void if_up(struct ifnet *); /*void ifinit(void);*/ /* declared in systm.h for main() */ -int ifioctl(struct socket *, u_long, caddr_t, struct proc *); +int ifioctl(struct socket *, u_long, caddr_t, struct thread *); int ifpromisc(struct ifnet *, int); struct ifnet *ifunit(const char *); struct ifnet *if_withname(struct sockaddr *); diff --git a/sys/net/ppp/if_ppp.c b/sys/net/ppp/if_ppp.c index d0472e3769..d529111e27 100644 --- a/sys/net/ppp/if_ppp.c +++ b/sys/net/ppp/if_ppp.c @@ -70,7 +70,7 @@ */ /* $FreeBSD: src/sys/net/if_ppp.c,v 1.67.2.4 2002/04/14 21:41:48 luigi Exp $ */ -/* $DragonFly: src/sys/net/ppp/if_ppp.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ */ +/* $DragonFly: src/sys/net/ppp/if_ppp.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ @@ -227,15 +227,14 @@ pppattach(dummy) * Allocate a ppp interface unit and initialize it. */ struct ppp_softc * -pppalloc(pid) - pid_t pid; +pppalloc(struct thread *td) { int nppp, i; struct ppp_softc *sc; for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) - if (sc->sc_xfer == pid) { - sc->sc_xfer = 0; + if (sc->sc_xfer == td) { + sc->sc_xfer = NULL; return sc; } for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) @@ -280,7 +279,7 @@ pppdealloc(sc) sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); getmicrotime(&sc->sc_if.if_lastchange); sc->sc_devp = NULL; - sc->sc_xfer = 0; + sc->sc_xfer = NULL; for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) @@ -332,12 +331,8 @@ pppdealloc(sc) * Ioctl routine for generic ppp devices. */ int -pppioctl(sc, cmd, data, flag, p) - struct ppp_softc *sc; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, + int flag, struct thread *td) { int s, error, flags, mru, npx; u_int nb; @@ -368,7 +363,7 @@ pppioctl(sc, cmd, data, flag, p) break; case PPPIOCSFLAGS: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); flags = *(int *)data & SC_MASK; s = splsoftnet(); @@ -382,7 +377,7 @@ pppioctl(sc, cmd, data, flag, p) break; case PPPIOCSMRU: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); mru = *(int *)data; if (mru >= PPP_MRU && mru <= PPP_MAXMRU) @@ -395,7 +390,7 @@ pppioctl(sc, cmd, data, flag, p) #ifdef VJC case PPPIOCSMAXCID: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); if (sc->sc_comp) { s = splsoftnet(); @@ -406,14 +401,14 @@ pppioctl(sc, cmd, data, flag, p) #endif case PPPIOCXFERUNIT: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); - sc->sc_xfer = p->p_pid; + sc->sc_xfer = td; break; #ifdef PPP_COMPRESS case PPPIOCSCOMPRESS: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); odp = (struct ppp_option_data *) data; nb = odp->length; @@ -483,7 +478,7 @@ pppioctl(sc, cmd, data, flag, p) if (cmd == PPPIOCGNPMODE) { npi->mode = sc->sc_npmode[npx]; } else { - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); if (npi->mode != sc->sc_npmode[npx]) { s = splsoftnet(); @@ -550,14 +545,14 @@ pppioctl(sc, cmd, data, flag, p) */ static int pppsioctl(ifp, cmd, data) - register struct ifnet *ifp; + struct ifnet *ifp; u_long cmd; caddr_t data; { - struct proc *p = curproc; /* XXX */ - register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; - register struct ifaddr *ifa = (struct ifaddr *)data; - register struct ifreq *ifr = (struct ifreq *)data; + struct thread *td = curthread; /* XXX */ + struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; + struct ifaddr *ifa = (struct ifaddr *)data; + struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; #ifdef PPP_COMPRESS struct ppp_comp_stats *pcp; @@ -604,7 +599,7 @@ pppsioctl(ifp, cmd, data) break; case SIOCSIFMTU: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; if (ifr->ifr_mtu > PPP_MAXMTU) error = EINVAL; diff --git a/sys/net/ppp/if_pppvar.h b/sys/net/ppp/if_pppvar.h index 120ceb61ca..bc0db35358 100644 --- a/sys/net/ppp/if_pppvar.h +++ b/sys/net/ppp/if_pppvar.h @@ -40,7 +40,7 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $FreeBSD: src/sys/net/if_pppvar.h,v 1.15 2000/01/29 16:56:23 peter Exp $ - * $DragonFly: src/sys/net/ppp/if_pppvar.h,v 1.2 2003/06/17 04:28:48 dillon Exp $ + * $DragonFly: src/sys/net/ppp/if_pppvar.h,v 1.3 2003/06/25 03:56:02 dillon Exp $ */ /* @@ -63,7 +63,7 @@ struct ppp_softc { void (*sc_relinq) __P((struct ppp_softc *)); /* relinquish ifunit */ void (*sc_setmtu) __P((struct ppp_softc *)); /* set mtu */ short sc_mru; /* max receive unit */ - pid_t sc_xfer; /* used in transferring unit */ + struct thread *sc_xfer; /* used in transferring unit */ /*hi*/ struct ifqueue sc_rawq; /* received packets */ /*net*/ struct ifqueue sc_inq; /* queue of input packets for daemon */ /*net*/ struct ifqueue sc_fastq; /* interactive output packet q */ @@ -101,10 +101,10 @@ struct ppp_softc { extern struct ppp_softc ppp_softc[]; -struct ppp_softc *pppalloc __P((pid_t pid)); +struct ppp_softc *pppalloc __P((struct thread *td)); 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/ppp_layer/ppp_tty.c b/sys/net/ppp_layer/ppp_tty.c index aef2054581..40b45d40d2 100644 --- a/sys/net/ppp_layer/ppp_tty.c +++ b/sys/net/ppp_layer/ppp_tty.c @@ -71,7 +71,7 @@ */ /* $FreeBSD: src/sys/net/ppp_tty.c,v 1.43.2.1 2002/02/13 00:43:11 dillon Exp $ */ -/* $DragonFly: src/sys/net/ppp_layer/ppp_tty.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ */ +/* $DragonFly: src/sys/net/ppp_layer/ppp_tty.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ #include "opt_ppp.h" /* XXX for ppp_defs.h */ @@ -195,11 +195,11 @@ pppasyncattach(dummy) static int pppopen(dev_t dev, struct tty *tp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct ppp_softc *sc; int error, s; - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); s = spltty(); @@ -212,7 +212,7 @@ pppopen(dev_t dev, struct tty *tp) } } - if ((sc = pppalloc(p->p_pid)) == NULL) { + if ((sc = pppalloc(td)) == NULL) { splx(s); return ENXIO; } @@ -455,18 +455,15 @@ static int ppptioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) { struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc; - struct proc *p = td->td_proc; int error, s; - KKASSERT(p != NULL); - if (sc == NULL || tp != (struct tty *) sc->sc_devp) return (ENOIOCTL); error = 0; switch (cmd) { case PPPIOCSASYNCMAP: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; sc->sc_asyncmap[0] = *(u_int *)data; break; @@ -476,7 +473,7 @@ ppptioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) break; case PPPIOCSRASYNCMAP: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; sc->sc_rasyncmap = *(u_int *)data; break; @@ -486,7 +483,7 @@ ppptioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) break; case PPPIOCSXASYNCMAP: - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) break; s = spltty(); bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap)); @@ -501,7 +498,7 @@ ppptioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *td) 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_usrreq.c b/sys/net/raw_usrreq.c index 2275d51d59..4c12348b7c 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -32,7 +32,7 @@ * * @(#)raw_usrreq.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/raw_usrreq.c,v 1.18 1999/08/28 00:48:28 peter Exp $ - * $DragonFly: src/sys/net/raw_usrreq.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/raw_usrreq.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ #include @@ -66,12 +66,12 @@ raw_init() void raw_input(m0, proto, src, dst) struct mbuf *m0; - register struct sockproto *proto; + struct sockproto *proto; struct sockaddr *src, *dst; { - register struct rawcb *rp; - register struct mbuf *m = m0; - register int sockets = 0; + struct rawcb *rp; + struct mbuf *m = m0; + int sockets = 0; struct socket *last; last = 0; @@ -152,26 +152,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_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(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; } @@ -227,7 +227,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.c b/sys/net/route.c index c551576ae0..cc79d009a3 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -32,7 +32,7 @@ * * @(#)route.c 8.3 (Berkeley) 1/9/95 * $FreeBSD: src/sys/net/route.c,v 1.59.2.10 2003/01/17 08:04:00 ru Exp $ - * $DragonFly: src/sys/net/route.c,v 1.2 2003/06/17 04:28:48 dillon Exp $ + * $DragonFly: src/sys/net/route.c,v 1.3 2003/06/25 03:56:02 dillon Exp $ */ #include "opt_inet.h" @@ -397,10 +397,7 @@ out: * Routing table ioctl interface. */ int -rtioctl(req, data, p) - u_long req; - caddr_t data; - struct proc *p; +rtioctl(u_long req, caddr_t data, struct thread *td) { #ifdef INET /* Multicast goop, grrr... */ diff --git a/sys/net/route.h b/sys/net/route.h index 974c6e6df0..80f692b76b 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -32,7 +32,7 @@ * * @(#)route.h 8.4 (Berkeley) 1/9/95 * $FreeBSD: src/sys/net/route.h,v 1.36.2.5 2002/02/01 11:48:01 ru Exp $ - * $DragonFly: src/sys/net/route.h,v 1.2 2003/06/17 04:28:48 dillon Exp $ + * $DragonFly: src/sys/net/route.h,v 1.3 2003/06/25 03:56:02 dillon Exp $ */ #ifndef _NET_ROUTE_H_ @@ -293,7 +293,7 @@ struct rtentry * rtalloc1 __P((struct sockaddr *, int, u_long)); void rtfree __P((struct rtentry *)); int rtinit __P((struct ifaddr *, int, int)); -int rtioctl __P((u_long, caddr_t, struct proc *)); +int rtioctl __P((u_long, caddr_t, struct thread *)); void rtredirect __P((struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct sockaddr *, struct rtentry **)); int rtrequest __P((int, struct sockaddr *, diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 5085367808..2ddb5f56ea 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -32,7 +32,7 @@ * * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 * $FreeBSD: src/sys/net/rtsock.c,v 1.44.2.11 2002/12/04 14:05:41 ru Exp $ - * $DragonFly: src/sys/net/rtsock.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/rtsock.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ @@ -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; @@ -152,21 +152,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; } @@ -230,11 +230,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; } @@ -331,7 +331,7 @@ route_output(m, so) * Verify that the caller has the appropriate privilege; RTM_GET * is the only operation the non-superuser is allowed. */ - if (rtm->rtm_type != RTM_GET && suser_xxx(so->so_cred, 0) != 0) + if (rtm->rtm_type != RTM_GET && suser_cred(so->so_cred, 0) != 0) senderr(EPERM); switch (rtm->rtm_type) { @@ -966,7 +966,7 @@ sysctl_iflist(af, w) while ((ifa = TAILQ_NEXT(ifa, ifa_link)) != 0) { if (af && af != ifa->ifa_addr->sa_family) continue; - if (curproc->p_ucred->cr_prison && prison_if(curproc, ifa->ifa_addr)) + if (curproc->p_ucred->cr_prison && prison_if(curthread, ifa->ifa_addr)) continue; ifaaddr = ifa->ifa_addr; netmask = ifa->ifa_netmask; diff --git a/sys/net/sl/if_sl.c b/sys/net/sl/if_sl.c index 7653499d19..7563ff58d8 100644 --- a/sys/net/sl/if_sl.c +++ b/sys/net/sl/if_sl.c @@ -32,7 +32,7 @@ * * @(#)if_sl.c 8.6 (Berkeley) 2/1/94 * $FreeBSD: src/sys/net/if_sl.c,v 1.84.2.2 2002/02/13 00:43:10 dillon Exp $ - * $DragonFly: src/sys/net/sl/if_sl.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/sl/if_sl.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ /* @@ -278,8 +278,9 @@ slopen(dev_t dev, struct tty *tp) struct sl_softc *sc; int nsl; int s, error; + struct thread *td = curthread; /* XXX */ - error = suser(); /* YYY uses curproc */ + error = suser(td); if (error) return (error); diff --git a/sys/net/tap/if_tap.c b/sys/net/tap/if_tap.c index e63a63d875..adef9a1089 100644 --- a/sys/net/tap/if_tap.c +++ b/sys/net/tap/if_tap.c @@ -32,7 +32,7 @@ /* * $FreeBSD: src/sys/net/if_tap.c,v 1.3.2.3 2002/04/14 21:41:48 luigi Exp $ - * $DragonFly: src/sys/net/tap/if_tap.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/tap/if_tap.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $ */ @@ -268,11 +268,10 @@ tapopen(dev_t dev, int flag, int mode, d_thread_t *td) { struct tap_softc *tp = NULL; int error; - struct proc *p = td->td_proc; KKASSERT(p != NULL); - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); tp = dev->si_drv1; @@ -286,7 +285,7 @@ tapopen(dev_t dev, int flag, int mode, d_thread_t *td) bcopy(tp->arpcom.ac_enaddr, tp->ether_addr, sizeof(tp->ether_addr)); - tp->tap_pid = p->p_pid; + tp->tap_td = td; tp->tap_flags |= TAP_OPEN; taprefcnt ++; @@ -356,7 +355,7 @@ tapclose(dev_t dev, int foo, int bar, d_thread_t *td) selwakeup(&tp->tap_rsel); tp->tap_flags &= ~TAP_OPEN; - tp->tap_pid = 0; + tp->tap_td = NULL; taprefcnt --; if (taprefcnt < 0) { @@ -430,10 +429,18 @@ tapifioctl(ifp, cmd, data) s = splimp(); ifs = (struct ifstat *)data; dummy = strlen(ifs->ascii); - if (tp->tap_pid != 0 && dummy < sizeof(ifs->ascii)) - snprintf(ifs->ascii + dummy, + if (tp->tap_td != NULL && dummy < sizeof(ifs->ascii)) { + if (tp->tap_td->td_proc) { + snprintf(ifs->ascii + dummy, sizeof(ifs->ascii) - dummy, - "\tOpened by PID %d\n", tp->tap_pid); + "\tOpened by pid %d\n", + (int)tp->tap_td->td_proc->p_pid); + } else { + snprintf(ifs->ascii + dummy, + sizeof(ifs->ascii) - dummy, + "\tOpened by td %p\n", tp->tap_td); + } + } splx(s); break; diff --git a/sys/net/tap/if_tapvar.h b/sys/net/tap/if_tapvar.h index 99b5487fce..f957baade6 100644 --- a/sys/net/tap/if_tapvar.h +++ b/sys/net/tap/if_tapvar.h @@ -35,7 +35,7 @@ /* * $FreeBSD: src/sys/net/if_tapvar.h,v 1.3.2.1 2000/07/27 13:57:05 nsayer Exp $ - * $DragonFly: src/sys/net/tap/if_tapvar.h,v 1.2 2003/06/17 04:28:48 dillon Exp $ + * $DragonFly: src/sys/net/tap/if_tapvar.h,v 1.3 2003/06/25 03:56:02 dillon Exp $ * $Id: if_tapvar.h,v 0.6 2000/07/11 02:16:08 max Exp $ */ @@ -57,7 +57,7 @@ struct tap_softc { u_int8_t ether_addr[ETHER_ADDR_LEN]; /* ether addr of the remote side */ - pid_t tap_pid; /* PID of process to open */ + struct thread *tap_td; /* thread of process to open */ struct sigio *tap_sigio; /* information for async I/O */ struct selinfo tap_rsel; /* read select */ }; diff --git a/sys/net/tun/if_tun.c b/sys/net/tun/if_tun.c index bd9c1dc782..d99c06d545 100644 --- a/sys/net/tun/if_tun.c +++ b/sys/net/tun/if_tun.c @@ -14,7 +14,7 @@ * operation though. * * $FreeBSD: src/sys/net/if_tun.c,v 1.74.2.8 2002/02/13 00:43:11 dillon Exp $ - * $DragonFly: src/sys/net/tun/if_tun.c,v 1.3 2003/06/23 17:55:45 dillon Exp $ + * $DragonFly: src/sys/net/tun/if_tun.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ */ #include "opt_inet.h" @@ -141,8 +141,7 @@ tunopen(dev_t dev, int flag, int mode, struct thread *td) register int error; KKASSERT(td->td_proc); - error = suser_xxx(td->td_proc->p_ucred, 0); - if (error) + if ((error = suser(td)) != NULL) return (error); tp = dev->si_drv1; diff --git a/sys/netgraph/ksocket/ng_ksocket.c b/sys/netgraph/ksocket/ng_ksocket.c index b45ef87d7b..6502273770 100644 --- a/sys/netgraph/ksocket/ng_ksocket.c +++ b/sys/netgraph/ksocket/ng_ksocket.c @@ -37,7 +37,7 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/netgraph/ng_ksocket.c,v 1.5.2.13 2003/04/28 20:41:09 archie Exp $ - * $DragonFly: src/sys/netgraph/ksocket/ng_ksocket.c,v 1.2 2003/06/17 04:28:50 dillon Exp $ + * $DragonFly: src/sys/netgraph/ksocket/ng_ksocket.c,v 1.3 2003/06/25 03:56:03 dillon Exp $ * $Whistle: ng_ksocket.c,v 1.1 1999/11/16 20:04:40 archie Exp $ */ @@ -561,7 +561,7 @@ ng_ksocket_constructor(node_p *nodep) 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; /* XXX broken */ const priv_p priv = node->private; struct ng_mesg *msg; char *s1, *s2, name[NG_HOOKLEN+1]; @@ -600,7 +600,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); @@ -643,7 +643,7 @@ static int ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, const char *raddr, struct ng_mesg **rptr) { - struct proc *p = curproc ? curproc : &proc0; /* XXX broken */ + struct thread *td = curthread; /* XXX broken */ const priv_p priv = node->private; struct socket *const so = priv->so; struct ng_mesg *resp = NULL; @@ -665,7 +665,7 @@ ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, ERROUT(ENXIO); /* Bind */ - error = sobind(so, sa, p); + error = sobind(so, sa, td); break; } case NGM_KSOCKET_LISTEN: @@ -677,7 +677,7 @@ ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, ERROUT(ENXIO); /* Listen */ - error = solisten(so, *((int32_t *)msg->data), p); + error = solisten(so, *((int32_t *)msg->data), td); break; } @@ -729,7 +729,7 @@ ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, /* 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); } @@ -807,7 +807,7 @@ ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, 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; @@ -841,7 +841,7 @@ ng_ksocket_rcvmsg(node_p node, struct ng_mesg *msg, 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; } @@ -883,7 +883,7 @@ done: static int ng_ksocket_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) { - struct proc *p = curproc ? curproc : &proc0; /* XXX broken */ + struct thread *td = curthread; /* XXX broken */ const node_p node = hook->node; const priv_p priv = node->private; struct socket *const so = priv->so; @@ -915,7 +915,7 @@ ng_ksocket_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) /* Send packet */ priv->flags |= KSF_SENDING; - error = (*so->so_proto->pr_usrreqs->pru_sosend)(so, sa, 0, m, 0, 0, p); + error = (*so->so_proto->pr_usrreqs->pru_sosend)(so, sa, 0, m, 0, 0, td); priv->flags &= ~KSF_SENDING; /* Clean up and exit */ @@ -1049,7 +1049,7 @@ ng_ksocket_incoming(struct socket *so, void *arg, int waitflag) } /* Read and forward available mbuf's */ - auio.uio_procp = NULL; + auio.uio_td = NULL; auio.uio_resid = 1000000000; flags = MSG_DONTWAIT; while (1) { diff --git a/sys/netgraph/socket/ng_socket.c b/sys/netgraph/socket/ng_socket.c index f985d7b8f9..9bebcf8133 100644 --- a/sys/netgraph/socket/ng_socket.c +++ b/sys/netgraph/socket/ng_socket.c @@ -37,7 +37,7 @@ * Author: Julian Elischer * * $FreeBSD: src/sys/netgraph/ng_socket.c,v 1.11.2.6 2002/07/02 22:17:18 archie Exp $ - * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.4 2003/06/25 03:56:03 dillon Exp $ * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $ */ @@ -110,7 +110,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 *td); */ static int ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp); static int ng_connect_cntl(struct sockaddr *nam, struct ngpcb *pcbp); @@ -157,11 +157,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_xxx(p->p_ucred, 0)) + if (suser(td)) return (EPERM); if (pcbp != NULL) return (EISCONN); @@ -181,7 +181,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; @@ -259,7 +259,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); @@ -269,7 +269,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) { struct ngpcb *const pcbp = sotongpcb(so); @@ -283,7 +283,7 @@ ngc_connect(struct socket *so, struct sockaddr *nam, struct proc *p) ***************************************************************/ 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); @@ -305,7 +305,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; @@ -372,7 +372,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); @@ -541,7 +541,7 @@ 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; const struct cmsghdr *cm = mtod(control, const struct cmsghdr *); diff --git a/sys/netgraph/tty/ng_tty.c b/sys/netgraph/tty/ng_tty.c index b6df184a7a..86522b391e 100644 --- a/sys/netgraph/tty/ng_tty.c +++ b/sys/netgraph/tty/ng_tty.c @@ -37,7 +37,7 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/netgraph/ng_tty.c,v 1.7.2.3 2002/02/13 00:43:12 dillon Exp $ - * $DragonFly: src/sys/netgraph/tty/ng_tty.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netgraph/tty/ng_tty.c,v 1.4 2003/06/25 03:56:03 dillon Exp $ * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $ */ @@ -191,13 +191,13 @@ static int ngt_ldisc; static int ngt_open(dev_t dev, struct tty *tp) { - struct proc *const p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ char name[sizeof(NG_TTY_NODE_TYPE) + 8]; sc_p sc; int s, error; /* Super-user only */ - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td))) return (error); s = splnet(); (void) spltty(); /* XXX is this necessary? */ diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 79ef4d1266..f4d7776f94 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -32,7 +32,7 @@ * * @(#)in.c 8.4 (Berkeley) 1/9/95 * $FreeBSD: src/sys/netinet/in.c,v 1.44.2.14 2002/11/08 00:45:50 suz Exp $ - * $DragonFly: src/sys/netinet/in.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/in.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_bootp.h" @@ -60,7 +60,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 *, @@ -186,16 +186,16 @@ 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 ifnet *ifp; + struct thread *td; { - register struct ifreq *ifr = (struct ifreq *)data; - register struct in_ifaddr *ia = 0, *iap; - register struct ifaddr *ifa; + struct ifreq *ifr = (struct ifreq *)data; + struct in_ifaddr *ia = 0, *iap; + struct ifaddr *ifa; struct in_addr dst; struct in_ifaddr *oia; struct in_aliasreq *ifra = (struct in_aliasreq *)data; @@ -207,13 +207,13 @@ in_control(so, cmd, data, ifp, p) switch (cmd) { case SIOCALIFADDR: case SIOCDLIFADDR: - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(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); } /* @@ -266,7 +266,7 @@ in_control(so, cmd, data, ifp, p) case SIOCSIFADDR: case SIOCSIFNETMASK: case SIOCSIFDSTADDR: - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return error; if (ifp == 0) @@ -305,7 +305,7 @@ in_control(so, cmd, data, ifp, p) break; case SIOCSIFBRDADDR: - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return error; /* FALLTHROUGH */ @@ -474,12 +474,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; @@ -541,7 +541,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: @@ -627,7 +627,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.h b/sys/netinet/in.h index fbaf0d0c49..74e554379c 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -32,7 +32,7 @@ * * @(#)in.h 8.3 (Berkeley) 1/3/94 * $FreeBSD: src/sys/netinet/in.h,v 1.48.2.9 2002/12/01 14:03:10 sobomax Exp $ - * $DragonFly: src/sys/netinet/in.h,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/in.h,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #ifndef _NETINET_IN_H_ @@ -472,14 +472,16 @@ struct ifnet; struct mbuf; /* forward declarations for Standard C */ #ifdef _KERNEL +struct thread; + int in_broadcast __P((struct in_addr, struct ifnet *)); int in_canforward __P((struct in_addr)); int in_cksum __P((struct mbuf *, int)); int in_localaddr __P((struct in_addr)); char *inet_ntoa __P((struct in_addr)); /* in libkern */ -int prison_ip __P((struct proc *p, int flag, u_int32_t *ip)); -void prison_remote_ip __P((struct proc *p, int flag, u_int32_t *ip)); +int prison_ip __P((struct thread *td, int flag, u_int32_t *ip)); +void prison_remote_ip __P((struct thread *td, int flag, u_int32_t *ip)); #define in_hosteq(s, t) ((s).s_addr == (t).s_addr) #define in_nullhost(x) ((x).s_addr == INADDR_ANY) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 4dfbdc1a3b..1395f60536 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -32,7 +32,7 @@ * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.59.2.26 2003/01/24 05:11:33 sam Exp $ - * $DragonFly: src/sys/netinet/in_pcb.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/in_pcb.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_ipsec.h" @@ -145,12 +145,9 @@ 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) - struct socket *so; - struct inpcbinfo *pcbinfo; - struct proc *p; +in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo, struct thread *td) { - register struct inpcb *inp; + struct inpcb *inp; #ifdef IPSEC int error; #endif @@ -184,12 +181,10 @@ in_pcballoc(so, pcbinfo, p) } int -in_pcbbind(inp, nam, p) - register struct inpcb *inp; - struct sockaddr *nam; - struct proc *p; +in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td) { - register struct socket *so = inp->inp_socket; + struct socket *so = inp->inp_socket; + struct proc *p = td->td_proc; unsigned short *lastport; struct sockaddr_in *sin; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; @@ -197,6 +192,8 @@ in_pcbbind(inp, nam, p) int wild = 0, reuseport = (so->so_options & SO_REUSEPORT); int error, prison = 0; + KKASSERT(p); + if (TAILQ_EMPTY(&in_ifaddrhead)) /* XXX broken! */ return (EADDRNOTAVAIL); if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY) @@ -216,7 +213,7 @@ in_pcbbind(inp, nam, p) return (EAFNOSUPPORT); #endif if (sin->sin_addr.s_addr != INADDR_ANY) - if (prison_ip(p, 0, &sin->sin_addr.s_addr)) + if (prison_ip(td, 0, &sin->sin_addr.s_addr)) return(EINVAL); lport = sin->sin_port; if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) { @@ -240,7 +237,7 @@ in_pcbbind(inp, nam, p) /* GROSS */ if (ntohs(lport) < IPPORT_RESERVED && p && - suser_xxx(p->p_ucred, PRISON_ROOT)) + suser_cred(p->p_ucred, PRISON_ROOT)) return (EACCES); if (p && p->p_ucred->cr_prison) prison = 1; @@ -268,7 +265,7 @@ in_pcbbind(inp, nam, p) } } if (prison && - prison_ip(p, 0, &sin->sin_addr.s_addr)) + prison_ip(td, 0, &sin->sin_addr.s_addr)) return (EADDRNOTAVAIL); t = in_pcblookup_local(pcbinfo, sin->sin_addr, lport, prison ? 0 : wild); @@ -292,7 +289,7 @@ in_pcbbind(inp, nam, p) int count; if (inp->inp_laddr.s_addr != INADDR_ANY) - if (prison_ip(p, 0, &inp->inp_laddr.s_addr )) { + if (prison_ip(td, 0, &inp->inp_laddr.s_addr )) { inp->inp_laddr.s_addr = INADDR_ANY; return (EINVAL); } @@ -303,7 +300,7 @@ in_pcbbind(inp, nam, p) last = ipport_hilastauto; lastport = &pcbinfo->lasthi; } else if (inp->inp_flags & INP_LOWPORT) { - if (p && (error = suser_xxx(p->p_ucred, PRISON_ROOT))) { + if (p && (error = suser_cred(p->p_ucred, PRISON_ROOT))) { inp->inp_laddr.s_addr = INADDR_ANY; return error; } @@ -359,7 +356,7 @@ in_pcbbind(inp, nam, p) } } inp->inp_lport = lport; - if (prison_ip(p, 0, &inp->inp_laddr.s_addr)) { + if (prison_ip(td, 0, &inp->inp_laddr.s_addr)) { inp->inp_laddr.s_addr = INADDR_ANY; inp->inp_lport = 0; return (EINVAL); @@ -502,22 +499,20 @@ in_pcbladdr(inp, nam, plocal_sin) * then pick one. */ int -in_pcbconnect(inp, nam, p) - register struct inpcb *inp; - struct sockaddr *nam; - struct proc *p; +in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct thread *td) { struct sockaddr_in *ifaddr; struct sockaddr_in *sin = (struct sockaddr_in *)nam; struct sockaddr_in sa; + struct ucred *cr = td->td_proc ? td->td_proc->p_ucred : NULL; int error; - if (inp->inp_laddr.s_addr == INADDR_ANY && p->p_ucred->cr_prison != NULL) { + if (inp->inp_laddr.s_addr == INADDR_ANY && cr && cr->cr_prison != NULL) { bzero(&sa, sizeof (sa)); - sa.sin_addr.s_addr = htonl(p->p_ucred->cr_prison->pr_ip); + sa.sin_addr.s_addr = htonl(cr->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); } @@ -534,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); } @@ -1036,11 +1031,17 @@ in_pcbremlists(inp) } int -prison_xinpcb(struct proc *p, struct inpcb *inp) +prison_xinpcb(struct thread *td, struct inpcb *inp) { - if (!p->p_ucred->cr_prison) + struct ucred *cr; + + if (td->td_proc == NULL) + return (0); + cr = td->td_proc->p_ucred; + if (cr->cr_prison == NULL) return (0); - if (ntohl(inp->inp_laddr.s_addr) == p->p_ucred->cr_prison->pr_ip) + if (ntohl(inp->inp_laddr.s_addr) == cr->cr_prison->pr_ip) return (0); return (1); } + diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index a05fc7780f..1b5e5e4494 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -32,7 +32,7 @@ * * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.7 2003/01/24 05:11:34 sam Exp $ - * $DragonFly: src/sys/netinet/in_pcb.h,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/in_pcb.h,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #ifndef _NETINET_IN_PCB_H_ @@ -314,9 +314,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 *)); @@ -335,7 +335,7 @@ void in_pcbrehash __P((struct inpcb *)); int in_setpeeraddr __P((struct socket *so, struct sockaddr **nam)); int in_setsockaddr __P((struct socket *so, struct sockaddr **nam)); void in_pcbremlists __P((struct inpcb *inp)); -int prison_xinpcb __P((struct proc *p, struct inpcb *inp)); +int prison_xinpcb __P((struct thread *p, struct inpcb *inp)); #endif /* _KERNEL */ #endif /* !_NETINET_IN_PCB_H_ */ diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index b5aaa6d824..950c49451e 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -32,7 +32,7 @@ * * @(#)in_var.h 8.2 (Berkeley) 1/9/95 * $FreeBSD: src/sys/netinet/in_var.h,v 1.33.2.3 2001/12/14 20:09:34 jlemon Exp $ - * $DragonFly: src/sys/netinet/in_var.h,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/in_var.h,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #ifndef _NETINET_IN_VAR_H_ @@ -227,7 +227,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 cae4dfb198..ad7c92fc97 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_divert.c,v 1.42.2.6 2003/01/23 21:06:45 sam Exp $ - * $DragonFly: src/sys/netinet/ip_divert.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/ip_divert.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_inet.h" @@ -336,7 +336,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; @@ -344,14 +344,14 @@ div_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("div_attach"); - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(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; @@ -393,7 +393,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; @@ -412,7 +412,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; @@ -427,7 +427,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) && @@ -486,7 +486,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS) s = splnet(); for (inp = LIST_FIRST(divcbinfo.listhead), i = 0; inp && i < n; inp = LIST_NEXT(inp, inp_list)) { - if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp))/*YYY*/ + if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->td, inp)) inp_list[i++] = inp; } splx(s); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index f617ea7c93..f453153671 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -32,7 +32,7 @@ * * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/netinet/ip_output.c,v 1.99.2.37 2003/04/15 06:44:45 silby Exp $ - * $DragonFly: src/sys/netinet/ip_output.c,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/ip_output.c,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #define _IP_VHL @@ -1347,7 +1347,7 @@ ip_ctloutput(so, sopt) error = EMSGSIZE; break; } - MGET(m, sopt->sopt_p ? M_WAIT : M_DONTWAIT, MT_HEADER); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_HEADER); if (m == 0) { error = ENOBUFS; break; @@ -1460,7 +1460,7 @@ ip_ctloutput(so, sopt) if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */ break; priv = (sopt->sopt_p != NULL && - suser(sopt->sopt_p) != 0) ? 0 : 1; + suser(sopt->sopt_p->p_thread) != 0) ? 0 : 1; req = mtod(m, caddr_t); len = m->m_len; optname = sopt->sopt_name; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 0d6b88d75e..acfb067aa6 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -32,7 +32,7 @@ * * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.64.2.15 2003/01/24 10:52:50 hsu Exp $ - * $DragonFly: src/sys/netinet/raw_ip.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/raw_ip.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_inet6.h" @@ -486,7 +486,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; @@ -494,14 +494,14 @@ rip_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("rip_attach"); - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(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; @@ -548,7 +548,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; @@ -566,7 +566,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; @@ -592,7 +592,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); u_long dst; diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 271365cbca..d60791625c 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -32,7 +32,7 @@ * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.73.2.31 2003/01/24 05:11:34 sam Exp $ - * $DragonFly: src/sys/netinet/tcp_subr.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/tcp_subr.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_compat.h" @@ -877,7 +877,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS) s = splnet(); for (inp = LIST_FIRST(tcbinfo.listhead), i = 0; inp && i < n; inp = LIST_NEXT(inp, inp_list)) { - if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp)) + if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->td, inp)) inp_list[i++] = inp; } splx(s); @@ -931,7 +931,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error, s; - error = suser_xxx(req->p->p_ucred, 0); + error = suser(req->td); if (error) return (error); error = SYSCTL_IN(req, addrs, sizeof(addrs)); @@ -961,7 +961,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error, s, mapped = 0; - error = suser_xxx(req->p->p_ucred, 0); + error = suser_cred(req->p->p_ucred, 0); if (error) return (error); error = SYSCTL_IN(req, addrs, sizeof(addrs)); diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 8baca20fb6..226871b729 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/tcp_syncache.c,v 1.5.2.14 2003/02/24 04:02:27 silby Exp $ - * $DragonFly: src/sys/netinet/tcp_syncache.c,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/tcp_syncache.c,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_inet6.h" @@ -664,7 +664,7 @@ syncache_socket(sc, lso) laddr = inp->inp_laddr; if (inp->inp_laddr.s_addr == INADDR_ANY) inp->inp_laddr = sc->sc_inc.inc_laddr; - 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 abort; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index ac9f5f4c8f..d99d77fae2 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -32,7 +32,7 @@ * * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.51.2.17 2002/10/11 11:46:44 ume Exp $ - * $DragonFly: src/sys/netinet/tcp_usrreq.c,v 1.2 2003/06/17 04:28:51 dillon Exp $ + * $DragonFly: src/sys/netinet/tcp_usrreq.c,v 1.3 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_ipsec.h" @@ -87,12 +87,12 @@ */ extern char *tcpstates[]; /* XXX ??? */ -static int tcp_attach __P((struct socket *, struct proc *)); +static int tcp_attach __P((struct socket *, struct thread *)); static int tcp_connect __P((struct tcpcb *, struct sockaddr *, - struct proc *)); + struct thread *)); #ifdef INET6 static int tcp6_connect __P((struct tcpcb *, struct sockaddr *, - struct proc *)); + struct thread *)); #endif /* INET6 */ static struct tcpcb * tcp_disconnect __P((struct tcpcb *)); @@ -115,7 +115,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; @@ -129,7 +129,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; @@ -188,7 +188,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; @@ -208,7 +208,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); @@ -217,7 +217,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; @@ -248,11 +248,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); @@ -263,7 +263,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; @@ -272,7 +272,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); @@ -280,7 +280,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; @@ -292,7 +292,7 @@ tcp6_usr_listen(struct socket *so, struct proc *p) inp->inp_vflag &= ~INP_IPV4; if ((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; @@ -308,7 +308,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; @@ -328,9 +328,9 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) goto out; } - prison_remote_ip(p, 0, &sinp->sin_addr.s_addr); + prison_remote_ip(td, 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); @@ -338,7 +338,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; @@ -369,7 +369,7 @@ 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; @@ -377,7 +377,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p) inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; inp->inp_inc.inc_isipv6 = 1; - 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); @@ -504,7 +504,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; @@ -557,10 +557,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; @@ -606,10 +606,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; @@ -700,10 +700,7 @@ struct pr_usrreqs tcp6_usrreqs = { * Initialize connection parameters and enter SYN-SENT state. */ static int -tcp_connect(tp, nam, p) - register struct tcpcb *tp; - struct sockaddr *nam; - struct proc *p; +tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; @@ -715,7 +712,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 +781,7 @@ tcp_connect(tp, nam, p) #ifdef INET6 static int -tcp6_connect(tp, nam, p) - register struct tcpcb *tp; - struct sockaddr *nam; - struct proc *p; +tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; @@ -799,7 +793,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; } @@ -1009,9 +1003,7 @@ 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) - struct socket *so; - struct proc *p; +tcp_attach(struct socket *so, struct thread *td) { register struct tcpcb *tp; struct inpcb *inp; @@ -1025,7 +1017,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 eb90a67320..77ae8d4d5d 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -32,7 +32,7 @@ * * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.64.2.18 2003/01/24 05:11:34 sam Exp $ - * $DragonFly: src/sys/netinet/udp_usrreq.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ + * $DragonFly: src/sys/netinet/udp_usrreq.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ #include "opt_ipsec.h" @@ -138,7 +138,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() @@ -602,7 +602,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS) s = splnet(); for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n; inp = LIST_NEXT(inp, inp_list)) { - if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp)) + if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->td, inp)) inp_list[i++] = inp; } splx(s); @@ -650,7 +650,7 @@ udp_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error, s; - error = suser_xxx(req->p->p_ucred, 0); + error = suser(req->td); if (error) return (error); error = SYSCTL_IN(req, addrs, sizeof(addrs)); @@ -673,15 +673,15 @@ SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW, 0, 0, udp_getcred, "S,ucred", "Get the ucred of a UDP connection"); static int -udp_output(inp, m, addr, control, p) - register struct inpcb *inp; +udp_output(inp, m, addr, control, td) + 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; + struct udpiphdr *ui; + int len = m->m_pkthdr.len; struct in_addr laddr; struct sockaddr_in *sin; int s = 0, error = 0; @@ -696,7 +696,7 @@ udp_output(inp, m, addr, control, p) if (addr) { sin = (struct sockaddr_in *)addr; - prison_remote_ip(p, 0, &sin->sin_addr.s_addr); + prison_remote_ip(td, 0, &sin->sin_addr.s_addr); laddr = inp->inp_laddr; if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; @@ -706,7 +706,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; @@ -806,7 +806,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; @@ -819,7 +819,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; @@ -831,7 +831,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; @@ -840,13 +840,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; @@ -859,12 +859,15 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) return EISCONN; error = 0; s = splnet(); - if (inp->inp_laddr.s_addr == INADDR_ANY && p->p_ucred->cr_prison != NULL) - error = in_pcbbind(inp, NULL, p); + if (inp->inp_laddr.s_addr == INADDR_ANY && + td->td_proc && + td->td_proc->p_ucred->cr_prison != NULL) { + error = in_pcbbind(inp, NULL, td); + } if (error == 0) { sin = (struct sockaddr_in *)nam; - prison_remote_ip(p, 0, &sin->sin_addr.s_addr); - error = in_pcbconnect(inp, nam, p); + prison_remote_ip(td, 0, &sin->sin_addr.s_addr); + error = in_pcbconnect(inp, nam, td); } splx(s); if (error == 0) @@ -909,7 +912,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; @@ -918,7 +921,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 42cc082cf3..b31e1ffccd 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/in6.c,v 1.7.2.9 2002/04/28 05:40:26 suz Exp $ */ -/* $DragonFly: src/sys/netinet6/in6.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/in6.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: in6.c,v 1.259 2002/01/21 11:37:50 keiichi Exp $ */ /* @@ -132,7 +132,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 *)); @@ -364,12 +364,8 @@ in6_len2mask(mask, len) #define ia62ifa(ia6) (&((ia6)->ia_ifa)) int -in6_control(so, cmd, data, ifp, p) - struct socket *so; - u_long cmd; - caddr_t data; - struct ifnet *ifp; - struct proc *p; +in6_control(struct socket *so, u_long cmd, caddr_t data, + struct ifnet *ifp, struct thread *td) { struct in6_ifreq *ifr = (struct in6_ifreq *)data; struct in6_ifaddr *ia = NULL; @@ -377,7 +373,7 @@ in6_control(so, cmd, data, ifp, p) int privileged; privileged = 0; - if (p == NULL || !suser_xxx(p->p_ucred, 0)) + if (suser(td) == 0) privileged++; switch (cmd) { @@ -1321,12 +1317,8 @@ in6_purgeif(ifp) * address encoding scheme. (see figure on page 8) */ static int -in6_lifaddr_ioctl(so, cmd, data, ifp, p) - struct socket *so; - u_long cmd; - caddr_t data; - struct ifnet *ifp; - struct proc *p; +in6_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, + struct ifnet *ifp, struct thread *td) { struct if_laddrreq *iflr = (struct if_laddrreq *)data; struct ifaddr *ifa; diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index e512618c5d..be912e8122 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/in6_pcb.c,v 1.10.2.9 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/in6_pcb.c,v 1.3 2003/06/23 17:55:46 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/in6_pcb.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: in6_pcb.c,v 1.31 2001/05/21 05:45:10 jinmei Exp $ */ /* @@ -123,10 +123,7 @@ struct in6_addr zeroin6_addr; int -in6_pcbbind(inp, nam, p) - register struct inpcb *inp; - struct sockaddr *nam; - struct proc *p; +in6_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td) { struct socket *so = inp->inp_socket; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; @@ -188,10 +185,11 @@ in6_pcbbind(inp, nam, p) } if (lport) { struct inpcb *t; + struct proc *p = td->td_proc; /* may be NULL */ /* GROSS */ if (ntohs(lport) < IPV6PORT_RESERVED && p && - suser_xxx(p->p_ucred, PRISON_ROOT)) + suser_cred(p->p_ucred, PRISON_ROOT)) return(EACCES); if (so->so_cred->cr_uid != 0 && !IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { @@ -249,7 +247,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 { @@ -276,12 +274,10 @@ in6_pcbbind(inp, nam, p) */ int -in6_pcbladdr(inp, nam, plocal_addr6) - register struct inpcb *inp; - struct sockaddr *nam; - struct in6_addr **plocal_addr6; +in6_pcbladdr(struct inpcb *inp, struct sockaddr *nam, + struct in6_addr **plocal_addr6) { - register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; struct ifnet *ifp = NULL; int error = 0; @@ -340,10 +336,7 @@ in6_pcbladdr(inp, nam, plocal_addr6) * then pick one. */ int -in6_pcbconnect(inp, nam, p) - register struct inpcb *inp; - struct sockaddr *nam; - struct proc *p; +in6_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct thread *td) { struct in6_addr *addr6; register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; @@ -365,7 +358,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_src.c b/sys/netinet6/in6_src.c index fdaecef08c..b75c4cdbd1 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/in6_src.c,v 1.1.2.3 2002/02/26 18:02:06 ume Exp $ */ -/* $DragonFly: src/sys/netinet6/in6_src.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/in6_src.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: in6_src.c,v 1.37 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -333,10 +333,7 @@ in6_selecthlim(in6p, ifp) * share this function by all *bsd*... */ int -in6_pcbsetport(laddr, inp, p) - struct in6_addr *laddr; - struct inpcb *inp; - struct proc *p; +in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct thread *td) { struct socket *so = inp->inp_socket; u_int16_t lport = 0, first, last, *lastport; @@ -354,7 +351,7 @@ in6_pcbsetport(laddr, inp, p) last = ipport_hilastauto; lastport = &pcbinfo->lasthi; } else if (inp->inp_flags & INP_LOWPORT) { - if (p && (error = suser_xxx(p->p_ucred, 0))) + if ((error = suser(td)) != 0) return error; first = ipport_lowfirstauto; /* 1023 */ last = ipport_lowlastauto; /* 600 */ diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 38950edae8..2d67536241 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/ip6_input.c,v 1.11.2.15 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/ip6_input.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/ip6_input.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $ */ /* @@ -1130,12 +1130,12 @@ ip6_savecontrol(in6p, mp, ip6, m) struct ip6_hdr *ip6; struct mbuf *m; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int privileged = 0; int rthdr_exist = 0; - if (p && !suser_xxx(p->p_ucred, 0)) + if (suser(td) == 0) privileged++; #ifdef SO_TIMESTAMP diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 4494d3e413..88ae9545d4 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/ip6_output.c,v 1.13.2.18 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/ip6_output.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/ip6_output.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: ip6_output.c,v 1.279 2002/01/26 06:12:30 jinmei Exp $ */ /* @@ -1308,29 +1308,29 @@ ip6_insertfraghdr(m0, m, hlen, frghdrp) * IP6 socket option processing. */ int -ip6_ctloutput(so, sopt) - struct socket *so; - struct sockopt *sopt; +ip6_ctloutput(struct socket *so, struct sockopt *sopt) { int privileged; struct inpcb *in6p = sotoinpcb(so); 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"); + /* NOT REACHED */ + td = NULL; } error = optval = 0; - privileged = (p == 0 || suser_xxx(p->p_ucred, 0)) ? 0 : 1; + privileged = (td == NULL || suser(td)) ? 0 : 1; if (level == IPPROTO_IPV6) { switch (op) { diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index cc957fc63a..286338fbf4 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet6/raw_ip6.c,v 1.7.2.7 2003/01/24 05:11:35 sam Exp $ - * $DragonFly: src/sys/netinet6/raw_ip6.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ + * $DragonFly: src/sys/netinet6/raw_ip6.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* @@ -554,7 +554,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; @@ -562,14 +562,14 @@ rip6_attach(struct socket *so, int proto, struct proc *p) inp = sotoinpcb(so); if (inp) panic("rip6_attach"); - if (p && (error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(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; @@ -622,7 +622,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; @@ -652,7 +652,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; @@ -697,7 +697,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 93b23b823e..d3ba6f45a1 100644 --- a/sys/netinet6/udp6_output.c +++ b/sys/netinet6/udp6_output.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/udp6_output.c,v 1.1.2.6 2003/01/23 21:06:47 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/udp6_output.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/udp6_output.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: udp6_output.c,v 1.31 2001/05/21 16:39:15 jinmei Exp $ */ /* @@ -121,12 +121,8 @@ #define udp6s_opackets udps_opackets int -udp6_output(in6p, m, addr6, control, p) - struct in6pcb *in6p; - struct mbuf *m; - struct mbuf *control; - struct sockaddr *addr6; - struct proc *p; +udp6_output(struct in6pcb *in6p, struct mbuf *m, struct sockaddr *addr6, + struct mbuf *control, struct thread *td) { u_int32_t ulen = m->m_pkthdr.len; u_int32_t plen = sizeof(struct udphdr) + ulen; @@ -141,9 +137,7 @@ udp6_output(in6p, m, addr6, control, p) int flags; struct sockaddr_in6 tmp; - priv = 0; - if (p && !suser_xxx(p->p_ucred, 0)) - priv = 1; + priv = !suser(td); /* 1 if privilaged, 0 if not */ if (control) { if ((error = ip6_setpktoptions(control, &opt, priv, 0)) != 0) goto release; @@ -215,7 +209,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 fa128b1147..3b95a7f98e 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/udp6_usrreq.c,v 1.6.2.13 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/udp6_usrreq.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ */ +/* $DragonFly: src/sys/netinet6/udp6_usrreq.c,v 1.4 2003/06/25 03:56:04 dillon Exp $ */ /* $KAME: udp6_usrreq.c,v 1.27 2001/05/21 05:45:10 jinmei Exp $ */ /* @@ -145,9 +145,7 @@ in6_mcmatch(in6p, ia6, ifp) } int -udp6_input(mp, offp, proto) - struct mbuf **mp; - int *offp, proto; +udp6_input(struct mbuf **mp, int *offp, int proto) { struct mbuf *m = *mp; register struct ip6_hdr *ip6; @@ -494,7 +492,7 @@ udp6_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error, s; - error = suser_xxx(req->p->p_ucred, 0); + error = suser(req->td); if (error) return (error); @@ -543,7 +541,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; @@ -558,7 +556,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; @@ -579,7 +577,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; @@ -604,20 +602,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; @@ -637,7 +635,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; @@ -650,7 +648,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_v6only) { /* should be non mapped addr */ @@ -707,7 +705,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; @@ -753,7 +751,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, } } - return udp6_output(inp, m, addr, control, p); + return udp6_output(inp, m, addr, control, td); bad: m_freem(m); diff --git a/sys/netproto/atalk/at_control.c b/sys/netproto/atalk/at_control.c index 9f54cb7e62..2e1389bdee 100644 --- a/sys/netproto/atalk/at_control.c +++ b/sys/netproto/atalk/at_control.c @@ -98,9 +98,8 @@ 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) ) { - return( EPERM ); - } + if (suser(td)) + return(EPERM); sat = satosat( &ifr->ifr_addr ); nr = (struct netrange *)sat->sat_zero; diff --git a/sys/netproto/atalk/ddp_usrreq.c b/sys/netproto/atalk/ddp_usrreq.c index 9fa9789385..da15521816 100644 --- a/sys/netproto/atalk/ddp_usrreq.c +++ b/sys/netproto/atalk/ddp_usrreq.c @@ -22,9 +22,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); @@ -35,7 +35,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; @@ -73,7 +73,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; @@ -90,7 +90,7 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p) } 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; @@ -151,7 +151,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; @@ -217,7 +217,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; @@ -252,7 +252,7 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p) return( EINVAL ); } if ( sat->sat_port < ATPORT_RESERVED && - suser(p) ) { + suser(td) ) { return( EACCES ); } } @@ -311,7 +311,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; diff --git a/sys/netproto/atm/atm_usrreq.c b/sys/netproto/atm/atm_usrreq.c index fadfd43f66..5db37dfe52 100644 --- a/sys/netproto/atm/atm_usrreq.c +++ b/sys/netproto/atm/atm_usrreq.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sys/netatm/atm_usrreq.c,v 1.6 1999/08/28 00:48:39 peter Exp $ - * @(#) $DragonFly: src/sys/netproto/atm/atm_usrreq.c,v 1.2 2003/06/17 04:28:49 dillon Exp $ + * @(#) $DragonFly: src/sys/netproto/atm/atm_usrreq.c,v 1.3 2003/06/25 03:56:03 dillon Exp $ */ /* @@ -40,9 +40,9 @@ /* * 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)); @@ -121,10 +121,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(); @@ -151,12 +151,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(); @@ -170,7 +170,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 (suser(td)) ATM_RETERR(EPERM); switch (acp->acr_opcode) { @@ -203,7 +203,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct atmaddreq *aap = (struct atmaddreq *)data; Atm_endpoint *epp; - if (p && (suser(p) != 0)) + if (suser(td)) ATM_RETERR(EPERM); switch (aap->aar_opcode) { @@ -253,7 +253,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct sigmgr *smp; Atm_endpoint *epp; - if (p && (suser(p) != 0)) + if (suser(td)) ATM_RETERR(EPERM); switch (adp->adr_opcode) { @@ -306,7 +306,7 @@ atm_dgram_control(so, cmd, data, ifp, p) struct sigmgr *smp; struct ifnet *ifp2; - if (p && (suser(p) != 0)) + if (suser(td)) ATM_RETERR(EPERM); switch (asp->asr_opcode) { diff --git a/sys/netproto/ipx/ipx.c b/sys/netproto/ipx/ipx.c index 8174a5732c..9a3c8a2f98 100644 --- a/sys/netproto/ipx/ipx.c +++ b/sys/netproto/ipx/ipx.c @@ -34,7 +34,7 @@ * @(#)ipx.c * * $FreeBSD: src/sys/netipx/ipx.c,v 1.17.2.3 2003/04/04 09:35:43 tjr Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include @@ -61,12 +61,8 @@ 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) - struct socket *so; - u_long cmd; - caddr_t data; - register struct ifnet *ifp; - struct proc *p; +ipx_control(struct socket *so, u_long cmd, caddr_t data, + struct ifnet *ifp, struct thread *td) { register struct ifreq *ifr = (struct ifreq *)data; register struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data; @@ -110,7 +106,7 @@ ipx_control(so, cmd, data, ifp, p) return (0); } - if (p && (error = suser(p)) != 0) + if ((error = suser(td)) != 0) return (error); switch (cmd) { diff --git a/sys/netproto/ipx/ipx_pcb.c b/sys/netproto/ipx/ipx_pcb.c index cfa5c2f74c..ccb9bbf622 100644 --- a/sys/netproto/ipx/ipx_pcb.c +++ b/sys/netproto/ipx/ipx_pcb.c @@ -34,7 +34,7 @@ * @(#)ipx_pcb.c * * $FreeBSD: src/sys/netipx/ipx_pcb.c,v 1.18.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_pcb.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx_pcb.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include @@ -55,10 +55,7 @@ static struct ipx_addr zeroipx_addr; int -ipx_pcballoc(so, head, p) - struct socket *so; - struct ipxpcb *head; - struct proc *p; +ipx_pcballoc(struct socket *so, struct ipxpcb *head, struct thread *td) { register struct ipxpcb *ipxp; @@ -74,12 +71,9 @@ ipx_pcballoc(so, head, p) } int -ipx_pcbbind(ipxp, nam, p) - register struct ipxpcb *ipxp; - struct sockaddr *nam; - struct proc *p; +ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) { - register struct sockaddr_ipx *sipx; + struct sockaddr_ipx *sipx; u_short lport = 0; if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr)) @@ -101,7 +95,7 @@ ipx_pcbbind(ipxp, nam, p) int error; if (aport < IPXPORT_RESERVED && - p != NULL && (error = suser(p)) != 0) + p != NULL && (error = suser(td)) != 0) return (error); if (ipx_pcblookup(&zeroipx_addr, lport, 0)) return (EADDRINUSE); @@ -127,15 +121,12 @@ noname: * then pick one. */ int -ipx_pcbconnect(ipxp, nam, p) - struct ipxpcb *ipxp; - struct sockaddr *nam; - struct proc *p; +ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) { struct ipx_ifaddr *ia; - register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; - register struct ipx_addr *dst; - register struct route *ro; + struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; + struct ipx_addr *dst; + struct route *ro; struct ifnet *ifp; ia = NULL; @@ -244,7 +235,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 */ @@ -278,9 +269,7 @@ ipx_pcbdetach(ipxp) } void -ipx_setsockaddr(ipxp, nam) - register struct ipxpcb *ipxp; - struct sockaddr **nam; +ipx_setsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam) { struct sockaddr_ipx *sipx, ssipx; diff --git a/sys/netproto/ipx/ipx_usrreq.c b/sys/netproto/ipx/ipx_usrreq.c index bf6e1879a5..45188f9721 100644 --- a/sys/netproto/ipx/ipx_usrreq.c +++ b/sys/netproto/ipx/ipx_usrreq.c @@ -34,7 +34,7 @@ * @(#)ipx_usrreq.c * * $FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.26.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include "opt_ipx.h" @@ -72,17 +72,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 = { @@ -434,10 +434,7 @@ ipx_usr_abort(so) } static int -ipx_attach(so, proto, p) - struct socket *so; - int proto; - struct proc *p; +ipx_attach(struct socket *so, int proto, struct thread *td) { int error; int s; @@ -446,7 +443,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); @@ -454,21 +451,15 @@ ipx_attach(so, proto, p) } static int -ipx_bind(so, nam, p) - struct socket *so; - struct sockaddr *nam; - struct proc *p; +ipx_bind(struct socket *so, struct sockaddr *nam, 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) - struct socket *so; - struct sockaddr *nam; - struct proc *p; +ipx_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int error; int s; @@ -477,7 +468,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); @@ -527,13 +518,8 @@ ipx_peeraddr(so, nam) } static int -ipx_send(so, flags, m, nam, control, p) - struct socket *so; - int flags; - struct mbuf *m; - struct sockaddr *nam; - struct mbuf *control; - struct proc *p; +ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, + struct mbuf *control, struct thread *td) { int error; struct ipxpcb *ipxp = sotoipxpcb(so); @@ -550,7 +536,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; @@ -595,19 +581,16 @@ ipx_sockaddr(so, nam) } static int -ripx_attach(so, proto, p) - struct socket *so; - int proto; - struct proc *p; +ripx_attach(struct socket *so, int proto, struct thread *td) { int error = 0; int s; struct ipxpcb *ipxp = sotoipxpcb(so); - if (p != NULL && (error = suser(p)) != 0) + if ((error = suser(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/netproto/ncp/ncp_conn.c b/sys/netproto/ncp/ncp_conn.c index 95ae8a3840..63931d1212 100644 --- a/sys/netproto/ncp/ncp_conn.c +++ b/sys/netproto/ncp/ncp_conn.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * $FreeBSD: src/sys/netncp/ncp_conn.c,v 1.3.2.5 2001/02/22 08:54:11 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_conn.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_conn.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ * * Connection tables */ @@ -59,7 +59,7 @@ static int ncp_next_handle = 1; static struct lock lhlock; static int ncp_sysctl_connstat(SYSCTL_HANDLER_ARGS); -static int ncp_conn_lock_any(struct ncp_conn *conn, struct proc *p, +static int ncp_conn_lock_any(struct ncp_conn *conn, struct thread *td, struct ucred *cred); extern struct linker_set sysctl_net_ncp; @@ -80,17 +80,20 @@ ncp_conn_init(void) { } int -ncp_conn_locklist(int flags, struct proc *p){ - return lockmgr(&listlock, flags | LK_CANRECURSE, 0, p); +ncp_conn_locklist(int flags, struct thread *td) +{ + return lockmgr(&listlock, flags | LK_CANRECURSE, 0, td); } void -ncp_conn_unlocklist(struct proc *p){ - lockmgr(&listlock, LK_RELEASE, 0, p); +ncp_conn_unlocklist(struct thread *td) +{ + lockmgr(&listlock, LK_RELEASE, 0, td); } int -ncp_conn_access(struct ncp_conn *conn, struct ucred *cred, mode_t mode) { +ncp_conn_access(struct ncp_conn *conn, struct ucred *cred, mode_t mode) +{ int error; if (cred == NOCRED || ncp_suser(cred) == 0 || @@ -104,52 +107,58 @@ ncp_conn_access(struct ncp_conn *conn, struct ucred *cred, mode_t mode) { } int -ncp_conn_lock_any(struct ncp_conn *conn, struct proc *p, struct ucred *cred) { +ncp_conn_lock_any(struct ncp_conn *conn, struct thread *td, struct ucred *cred) +{ int error; if (conn->nc_id == 0) return EACCES; - error = lockmgr(&conn->nc_lock, LK_EXCLUSIVE | LK_CANRECURSE, 0, p); + error = lockmgr(&conn->nc_lock, LK_EXCLUSIVE | LK_CANRECURSE, 0, td); if (error == ERESTART) return EINTR; - error = ncp_chkintr(conn, p); + error = ncp_chkintr(conn, td); if (error) { - lockmgr(&conn->nc_lock, LK_RELEASE, 0, p); + lockmgr(&conn->nc_lock, LK_RELEASE, 0, td); return error; } if (conn->nc_id == 0) { - lockmgr(&conn->nc_lock, LK_RELEASE, 0, p); + lockmgr(&conn->nc_lock, LK_RELEASE, 0, td); return EACCES; } - conn->procp = p; /* who currently operates */ + conn->td = td; /* who currently operates */ conn->ucred = cred; return 0; } int -ncp_conn_lock(struct ncp_conn *conn, struct proc *p, struct ucred *cred, int mode) { +ncp_conn_lock(struct ncp_conn *conn, struct thread *td, + struct ucred *cred, int mode) +{ int error; - error = ncp_conn_access(conn,cred,mode); - if (error) return error; - return ncp_conn_lock_any(conn, p, cred); + error = ncp_conn_access(conn, cred, mode); + if (error) + return error; + return ncp_conn_lock_any(conn, td, cred); } /* * Lock conn but unlock connlist */ static int -ncp_conn_lock2(struct ncp_conn *conn, struct proc *p, struct ucred *cred, int mode) { +ncp_conn_lock2(struct ncp_conn *conn, struct thread *td, + struct ucred *cred, int mode) +{ int error; - error = ncp_conn_access(conn,cred,mode); + error = ncp_conn_access(conn, cred, mode); if (error) { - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); return error; } conn->nc_lwant++; - ncp_conn_unlocklist(p); - error = ncp_conn_lock_any(conn,p,cred); + ncp_conn_unlocklist(td); + error = ncp_conn_lock_any(conn, td, cred); conn->nc_lwant--; if (conn->nc_lwant == 0) { wakeup(&conn->nc_lwant); @@ -158,17 +167,19 @@ ncp_conn_lock2(struct ncp_conn *conn, struct proc *p, struct ucred *cred, int mo } void -ncp_conn_unlock(struct ncp_conn *conn, struct proc *p) { +ncp_conn_unlock(struct ncp_conn *conn, struct thread *td) { /* * note, that LK_RELASE will do wakeup() instead of wakeup_one(). * this will do a little overhead */ - lockmgr(&conn->nc_lock, LK_RELEASE, 0, p); + lockmgr(&conn->nc_lock, LK_RELEASE, 0, td); } int -ncp_conn_assert_locked(struct ncp_conn *conn,char *checker, struct proc *p){ - if (conn->nc_lock.lk_flags & LK_HAVE_EXCL) return 0; +ncp_conn_assert_locked(struct ncp_conn *conn,char *checker, struct thread *td) +{ + if (conn->nc_lock.lk_flags & LK_HAVE_EXCL) + return 0; printf("%s: connection isn't locked!\n", checker); return EIO; } @@ -177,7 +188,7 @@ ncp_conn_assert_locked(struct ncp_conn *conn,char *checker, struct proc *p){ * create, fill with defaults and return in locked state */ int -ncp_conn_alloc(struct proc *p, struct ucred *cred, struct ncp_conn **conn) +ncp_conn_alloc(struct thread *td, struct ucred *cred, struct ncp_conn **conn) { int error; struct ncp_conn *ncp; @@ -191,11 +202,11 @@ ncp_conn_alloc(struct proc *p, struct ucred *cred, struct ncp_conn **conn) ncp->nc_owner = cred; ncp->seq = 0; ncp->connid = 0xFFFF; - ncp_conn_lock_any(ncp, p, ncp->nc_owner); + ncp_conn_lock_any(ncp, td, ncp->nc_owner); *conn = ncp; - ncp_conn_locklist(LK_EXCLUSIVE, p); + ncp_conn_locklist(LK_EXCLUSIVE, td); SLIST_INSERT_HEAD(&conn_list,ncp,nc_next); - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); return (error); } @@ -203,19 +214,20 @@ ncp_conn_alloc(struct proc *p, struct ucred *cred, struct ncp_conn **conn) * Remove the connection, on entry it must be locked */ int -ncp_conn_free(struct ncp_conn *ncp) { +ncp_conn_free(struct ncp_conn *ncp) +{ int error; struct ncp_conn *ncp1; if (ncp->nc_id == 0) { - printf("already!!!!\n"); + printf("already!!!!\n"); return EACCES; } if (ncp==NULL) { NCPFATAL("conn==NULL !\n"); return(EIO); } - error = ncp_conn_assert_locked(ncp, __FUNCTION__, ncp->procp); + error = ncp_conn_assert_locked(ncp, __FUNCTION__, ncp->td); if (error) return error; if (ncp->ref_cnt) { NCPFATAL("there are %d referenses left\n",ncp->ref_cnt); @@ -225,16 +237,16 @@ ncp_conn_free(struct ncp_conn *ncp) { * Mark conn as died and wait for other process */ ncp->nc_id = 0; - ncp_conn_unlock(ncp,ncp->procp); + ncp_conn_unlock(ncp, ncp->td); /* * if signal is raised - how I do react ? */ - lockmgr(&ncp->nc_lock, LK_DRAIN, 0, ncp->procp); + lockmgr(&ncp->nc_lock, LK_DRAIN, 0, ncp->td); while (ncp->nc_lwant) { printf("lwant = %d\n", ncp->nc_lwant); tsleep(&ncp->nc_lwant, PZERO,"ncpdr",2*hz); } - ncp_conn_locklist(LK_EXCLUSIVE, ncp->procp); + ncp_conn_locklist(LK_EXCLUSIVE, ncp->td); /* * It is possible, that other process destroy connection while we draining, * and free it. So, we must rescan list @@ -243,12 +255,12 @@ ncp_conn_free(struct ncp_conn *ncp) { if (ncp1 == ncp) break; } if (ncp1 == NULL) { - ncp_conn_unlocklist(ncp->procp); + ncp_conn_unlocklist(ncp->td); return 0; } SLIST_REMOVE(&conn_list, ncp, ncp_conn, nc_next); ncp_conn_cnt--; - ncp_conn_unlocklist(ncp->procp); + ncp_conn_unlocklist(ncp->td); if (ncp->li.user) free(ncp->li.user, M_NCPDATA); if (ncp->li.password) free(ncp->li.password, M_NCPDATA); crfree(ncp->nc_owner); @@ -260,18 +272,18 @@ ncp_conn_free(struct ncp_conn *ncp) { * Lookup connection by handle, return a locked conn descriptor */ int -ncp_conn_getbyref(int ref,struct proc *p,struct ucred *cred, int mode, struct ncp_conn **connpp){ +ncp_conn_getbyref(int ref,struct thread *td,struct ucred *cred, int mode, struct ncp_conn **connpp){ struct ncp_conn *ncp; int error=0; - ncp_conn_locklist(LK_SHARED, p); + ncp_conn_locklist(LK_SHARED, td); SLIST_FOREACH(ncp, &conn_list, nc_next) if (ncp->nc_id == ref) break; if (ncp == NULL) { - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); return(EBADF); } - error = ncp_conn_lock2(ncp, p, cred, mode); + error = ncp_conn_lock2(ncp, td, cred, mode); if (!error) *connpp = ncp; return (error); @@ -280,11 +292,11 @@ ncp_conn_getbyref(int ref,struct proc *p,struct ucred *cred, int mode, struct nc * find attached, but not logged in connection to specified server */ int -ncp_conn_getattached(struct ncp_conn_args *li,struct proc *p,struct ucred *cred,int mode, struct ncp_conn **connpp){ +ncp_conn_getattached(struct ncp_conn_args *li,struct thread *td,struct ucred *cred,int mode, struct ncp_conn **connpp){ struct ncp_conn *ncp, *ncp2=NULL; int error = 0; - ncp_conn_locklist(LK_SHARED, p); + ncp_conn_locklist(LK_SHARED, td); SLIST_FOREACH(ncp, &conn_list, nc_next) { if ((ncp->flags & NCPFL_LOGGED) != 0 || strcmp(ncp->li.server,li->server) != 0 || @@ -300,10 +312,10 @@ ncp_conn_getattached(struct ncp_conn_args *li,struct proc *p,struct ucred *cred, } if (ncp == NULL) ncp = ncp2; if (ncp == NULL) { - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); return(EBADF); } - error = ncp_conn_lock2(ncp,p,cred,mode); + error = ncp_conn_lock2(ncp,td,cred,mode); if (!error) *connpp=ncp; return (error); @@ -320,13 +332,15 @@ ncp_conn_getattached(struct ncp_conn_args *li,struct proc *p,struct ucred *cred, */ int -ncp_conn_getbyli(struct ncp_conn_args *li,struct proc *p,struct ucred *cred,int mode, struct ncp_conn **connpp){ +ncp_conn_getbyli(struct ncp_conn_args *li, struct thread *td, + struct ucred *cred, int mode, struct ncp_conn **connpp) +{ struct ncp_conn *ncp, *ncp2=NULL; int error=0, partial, haveserv; partial = (li == NULL || li->server[0] == 0 || li->user == NULL); haveserv = (li && li->server[0]); - ncp_conn_locklist(LK_SHARED, p); + ncp_conn_locklist(LK_SHARED, td); SLIST_FOREACH(ncp, &conn_list, nc_next) { if (partial) { if (cred->cr_uid == ncp->nc_owner->cr_uid) { @@ -356,10 +370,10 @@ ncp_conn_getbyli(struct ncp_conn_args *li,struct proc *p,struct ucred *cred,int } if (ncp == NULL) ncp = ncp2; if (ncp == NULL) { - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); return(EBADF); } - error = ncp_conn_lock2(ncp,p,cred,mode); + error = ncp_conn_lock2(ncp,td,cred,mode); if (!error) *connpp=ncp; return (error); @@ -376,12 +390,12 @@ ncp_conn_setprimary(struct ncp_conn *conn, int on){ if (conn->ucred->cr_uid != conn->nc_owner->cr_uid) return EACCES; - ncp_conn_locklist(LK_SHARED, conn->procp); + ncp_conn_locklist(LK_SHARED, conn->td); SLIST_FOREACH(ncp, &conn_list, nc_next) { if (conn->ucred->cr_uid == ncp->nc_owner->cr_uid) ncp->flags &= ~NCPFL_PRIMARY; } - ncp_conn_unlocklist(conn->procp); + ncp_conn_unlocklist(conn->td); if (on) conn->flags |= NCPFL_PRIMARY; return 0; @@ -391,39 +405,39 @@ ncp_conn_setprimary(struct ncp_conn *conn, int on){ * problem: how locks should be applied ? */ int -ncp_conn_gethandle(struct ncp_conn *conn, struct proc *p, struct ncp_handle **handle){ +ncp_conn_gethandle(struct ncp_conn *conn, struct thread *td, struct ncp_handle **handle){ struct ncp_handle *refp; - lockmgr(&lhlock, LK_EXCLUSIVE, 0, p); + lockmgr(&lhlock, LK_EXCLUSIVE, 0, td); SLIST_FOREACH(refp, &lhlist, nh_next) - if (refp->nh_conn == conn && p == refp->nh_proc) break; + if (refp->nh_conn == conn && td == refp->nh_td) break; if (refp) { conn->ref_cnt++; refp->nh_ref++; *handle = refp; - lockmgr(&lhlock, LK_RELEASE, 0, p); + lockmgr(&lhlock, LK_RELEASE, 0, td); return 0; } MALLOC(refp,struct ncp_handle *,sizeof(struct ncp_handle),M_NCPDATA, M_WAITOK | M_ZERO); SLIST_INSERT_HEAD(&lhlist,refp,nh_next); refp->nh_ref++; - refp->nh_proc = p; + refp->nh_td = td; refp->nh_conn = conn; refp->nh_id = ncp_next_handle++; *handle = refp; conn->ref_cnt++; - lockmgr(&lhlock, LK_RELEASE, 0, p); + lockmgr(&lhlock, LK_RELEASE, 0, td); return 0; } /* * release reference, if force - ignore refcount */ int -ncp_conn_puthandle(struct ncp_handle *handle, struct proc *p, int force) { +ncp_conn_puthandle(struct ncp_handle *handle, struct thread *td, int force) { struct ncp_handle *refp = handle; - lockmgr(&lhlock, LK_EXCLUSIVE, 0, p); + lockmgr(&lhlock, LK_EXCLUSIVE, 0, td); refp->nh_ref--; refp->nh_conn->ref_cnt--; if (force) { @@ -434,20 +448,20 @@ ncp_conn_puthandle(struct ncp_handle *handle, struct proc *p, int force) { SLIST_REMOVE(&lhlist, refp, ncp_handle, nh_next); FREE(refp, M_NCPDATA); } - lockmgr(&lhlock, LK_RELEASE, 0, p); + lockmgr(&lhlock, LK_RELEASE, 0, td); return 0; } /* * find a connHandle */ int -ncp_conn_findhandle(int connHandle, struct proc *p, struct ncp_handle **handle) { +ncp_conn_findhandle(int connHandle, struct thread *td, struct ncp_handle **handle) { struct ncp_handle *refp; - lockmgr(&lhlock, LK_SHARED, 0, p); + lockmgr(&lhlock, LK_SHARED, 0, td); SLIST_FOREACH(refp, &lhlist, nh_next) - if (refp->nh_proc == p && refp->nh_id == connHandle) break; - lockmgr(&lhlock, LK_RELEASE, 0, p); + if (refp->nh_td == td && refp->nh_id == connHandle) break; + lockmgr(&lhlock, LK_RELEASE, 0, td); if (refp == NULL) { return EBADF; } @@ -458,20 +472,20 @@ ncp_conn_findhandle(int connHandle, struct proc *p, struct ncp_handle **handle) * Clear handles associated with specified process */ int -ncp_conn_putprochandles(struct proc *p) { +ncp_conn_putprochandles(struct thread *td) { struct ncp_handle *hp, *nhp; int haveone = 0; - lockmgr(&lhlock, LK_EXCLUSIVE, 0, p); + lockmgr(&lhlock, LK_EXCLUSIVE, 0, td); for (hp = SLIST_FIRST(&lhlist); hp; hp = nhp) { nhp = SLIST_NEXT(hp, nh_next); - if (hp->nh_proc != p) continue; + if (hp->nh_td != td) continue; haveone = 1; hp->nh_conn->ref_cnt -= hp->nh_ref; SLIST_REMOVE(&lhlist, hp, ncp_handle, nh_next); FREE(hp, M_NCPDATA); } - lockmgr(&lhlock, LK_RELEASE, 0, p); + lockmgr(&lhlock, LK_RELEASE, 0, td); return haveone; } /* @@ -516,7 +530,7 @@ ncp_sysctl_connstat(SYSCTL_HANDLER_ARGS) { /* struct ucred *cred = req->p->p_ucred;*/ error = 0; - ncp_conn_locklist(LK_SHARED, req->p); + ncp_conn_locklist(LK_SHARED, req->td); error = SYSCTL_OUT(req, &ncp_conn_cnt, sizeof(ncp_conn_cnt)); SLIST_FOREACH(ncp, &conn_list, nc_next) { if (error) break; @@ -532,6 +546,6 @@ ncp_sysctl_connstat(SYSCTL_HANDLER_ARGS) { ncp->nc_lwant--; error = SYSCTL_OUT(req, &ncs, sizeof(ncs)); } - ncp_conn_unlocklist(req->p); + ncp_conn_unlocklist(req->td); return(error); } diff --git a/sys/netproto/ncp/ncp_conn.h b/sys/netproto/ncp/ncp_conn.h index 12a58223be..12d637104d 100644 --- a/sys/netproto/ncp/ncp_conn.h +++ b/sys/netproto/ncp/ncp_conn.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_conn.h,v 1.3 1999/12/29 04:46:15 peter Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_conn.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_conn.h,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #ifndef _NETNCP_NCP_CONN_H_ #define _NETNCP_NCP_CONN_H_ @@ -158,7 +158,7 @@ struct ncp_handle { SLIST_ENTRY(ncp_handle) nh_next; int nh_id; /* handle id */ struct ncp_conn*nh_conn; /* which conn we are refernce */ - struct proc * nh_proc; /* who owns the handle */ + struct thread * nh_td; /* who owns the handle */ int nh_ref; /* one process can asquire many handles, but we return the one */ }; @@ -180,7 +180,7 @@ struct ncp_conn { SLIST_HEAD(ncp_ref_hd,ncp_ref) ref_list;/* list of handles */ struct lock nc_lock; /* excl locks */ int nc_lwant; /* number of wanted locks */ - struct proc *procp; /* pid currently operates */ + struct thread *td; /* thread currently operates */ struct ucred *ucred; /* usr currently operates */ struct ncp_rq *nc_rq; /* current request */ /* Fields used to process ncp requests */ @@ -205,27 +205,27 @@ struct ncp_conn { #define ncp_conn_invalidate(conn) {conn->flags |= NCPFL_INVALID;} int ncp_conn_init(void); -int ncp_conn_alloc(struct proc *p,struct ucred *cred, struct ncp_conn **connid); +int ncp_conn_alloc(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); /*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); extern struct ncp_conn_head conn_list; diff --git a/sys/netproto/ncp/ncp_login.c b/sys/netproto/ncp/ncp_login.c index d22efb562c..33d7b4b2c6 100644 --- a/sys/netproto/ncp/ncp_login.c +++ b/sys/netproto/ncp/ncp_login.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_login.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_login.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_login.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include #include @@ -49,10 +49,10 @@ static int ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, unsigned char *key, unsigned char *passwd, - struct proc *p, struct ucred *cred); + struct thread *td, struct ucred *cred); static int ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, char *object_name, unsigned char *passwd, - struct proc *p, struct ucred *cred); + struct thread *td, struct ucred *cred); static int ncp_sign_start(struct ncp_conn *conn, char *logindata); static int ncp_get_encryption_key(struct ncp_conn *conn, char *target); @@ -89,7 +89,7 @@ ncp_get_encryption_key(struct ncp_conn *conn, char *target) { int error; DECLARE_RQ; - NCP_RQ_HEAD_S(23,23,conn->procp,conn->ucred); + NCP_RQ_HEAD_S(23, 23, conn->td, conn->ucred); checkbad(ncp_request(conn,rqp)); if (rqp->rpsize < 8) { NCPFATAL("rpsize=%d < 8\n", rqp->rpsize); @@ -103,7 +103,7 @@ ncp_get_encryption_key(struct ncp_conn *conn, char *target) { int ncp_login_object(struct ncp_conn *conn, unsigned char *username, int login_type, unsigned char *password, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { int error; unsigned char ncp_key[8]; @@ -111,19 +111,19 @@ ncp_login_object(struct ncp_conn *conn, unsigned char *username, if ((error = ncp_get_encryption_key(conn, ncp_key)) != 0) { printf("%s: Warning: use unencrypted login\n", __FUNCTION__); - return ncp_login_unencrypted(conn, login_type, username, password,p,cred); + return ncp_login_unencrypted(conn, login_type, username, password,td,cred); } - if ((error = ncp_get_bindery_object_id(conn, login_type, username, &user,p,cred)) != 0) { + if ((error = ncp_get_bindery_object_id(conn, login_type, username, &user,td,cred)) != 0) { return error; } - error = ncp_login_encrypted(conn, &user, ncp_key, password,p,cred); + error = ncp_login_encrypted(conn, &user, ncp_key, password,td,cred); return error; } int ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, unsigned char *key, unsigned char *passwd, - struct proc *p,struct ucred *cred) { + struct thread *td,struct ucred *cred) { u_int32_t tmpID = htonl(object->object_id); u_char buf[16 + 8]; u_char encrypted[8]; @@ -133,7 +133,7 @@ ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, nw_keyhash((u_char*)&tmpID, passwd, strlen(passwd), buf); nw_encrypt(key, buf, encrypted); - NCP_RQ_HEAD_S(23,24,p,cred); + NCP_RQ_HEAD_S(23,24,td,cred); ncp_rq_mem(rqp, encrypted, 8); ncp_rq_word_hl(rqp, object->object_type); ncp_rq_pstring(rqp, object->object_name); @@ -151,12 +151,12 @@ ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, int ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, char *object_name, unsigned char *passwd, - struct proc *p, struct ucred *cred) + struct thread *td, struct ucred *cred) { int error; DECLARE_RQ; - NCP_RQ_HEAD_S(23,20,conn->procp,conn->ucred); + NCP_RQ_HEAD_S(23, 20, conn->td, conn->ucred); ncp_rq_word_hl(rqp, object_type); ncp_rq_pstring(rqp, object_name); ncp_rq_pstring(rqp, passwd); @@ -171,7 +171,7 @@ ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, */ int ncp_login(struct ncp_conn *conn, char *user, int objtype, char *password, - struct proc *p, struct ucred *cred) { + struct thread *td, struct ucred *cred) { int error; if (ncp_suser(cred) != 0 && cred->cr_uid != conn->nc_owner->cr_uid) @@ -187,7 +187,7 @@ ncp_login(struct ncp_conn *conn, char *user, int objtype, char *password, ncp_str_upper(conn->li.user); if ((conn->li.opt & NCP_OPT_NOUPCASEPASS) == 0) ncp_str_upper(conn->li.password); - checkbad(ncp_login_object(conn, conn->li.user, objtype, conn->li.password,p,cred)); + checkbad(ncp_login_object(conn, conn->li.user, objtype, conn->li.password,td,cred)); conn->li.objtype = objtype; conn->flags |= NCPFL_LOGGED; return 0; diff --git a/sys/netproto/ncp/ncp_mod.c b/sys/netproto/ncp/ncp_mod.c index dcb131bac7..506e771c49 100644 --- a/sys/netproto/ncp/ncp_mod.c +++ b/sys/netproto/ncp/ncp_mod.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_mod.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_mod.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_mod.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include #include @@ -59,7 +59,7 @@ SYSCTL_INT(_net_ncp, OID_AUTO, sysent, CTLFLAG_RD, &ncp_sysent, 0, ""); SYSCTL_INT(_net_ncp, OID_AUTO, version, CTLFLAG_RD, &ncp_version, 0, ""); static int -ncp_conn_frag_rq(struct ncp_conn *conn, struct proc *p, struct ncp_conn_frag *nfp); +ncp_conn_frag_rq(struct ncp_conn *conn, struct thread *td, struct ncp_conn_frag *nfp); /* * Attach to NCP server @@ -70,26 +70,31 @@ struct sncp_connect_args { }; static int -__P(sncp_connect(struct proc *p, struct sncp_connect_args *uap)){ +sncp_connect(struct thread *td, struct sncp_connect_args *uap) +{ int connHandle = 0, error; struct ncp_conn *conn; struct ncp_handle *handle; struct ncp_conn_args li; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; checkbad(copyin(uap->li,&li,sizeof(li))); checkbad(copyout(&connHandle,uap->connHandle,sizeof(connHandle))); /* check before */ li.password = li.user = NULL; - error = ncp_conn_getattached(&li, p, p->p_ucred, NCPM_WRITE | NCPM_EXECUTE, &conn); + error = ncp_conn_getattached(&li, td, cred, NCPM_WRITE | NCPM_EXECUTE, &conn); if (error) { - error = ncp_connect(&li, p, p->p_ucred, &conn); + error = ncp_connect(&li, td, cred, &conn); } if (!error) { - error = ncp_conn_gethandle(conn, p, &handle); + error = ncp_conn_gethandle(conn, td, &handle); copyout(&handle->nh_id, uap->connHandle, sizeof(uap->connHandle)); - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); } bad: - p->p_retval[0]=error; + td->td_proc->p_retval[0]=error; return error; } @@ -99,26 +104,32 @@ struct sncp_request_args { struct ncp_buf *ncpbuf; }; -static int ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, +static int ncp_conn_handler(struct thread *td, struct sncp_request_args *uap, struct ncp_conn *conn, struct ncp_handle *handle); static int -__P(sncp_request(struct proc *p, struct sncp_request_args *uap)){ +sncp_request(struct thread *td, struct sncp_request_args *uap) +{ int error = 0, rqsize; struct ncp_conn *conn; struct ncp_handle *handle; + struct ucred *cred; + DECLARE_RQ; - error = ncp_conn_findhandle(uap->connHandle,p,&handle); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + + error = ncp_conn_findhandle(uap->connHandle,td,&handle); if (error) return error; conn = handle->nh_conn; if (uap->fn == NCP_CONN) - return ncp_conn_handler(p, uap, conn, handle); + return ncp_conn_handler(td, uap, conn, handle); error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int)); if (error) return(error); - error = ncp_conn_lock(conn,p,p->p_ucred,NCPM_EXECUTE); + error = ncp_conn_lock(conn,td,cred,NCPM_EXECUTE); if (error) return(error); - ncp_rq_head(rqp,NCP_REQUEST,uap->fn,p,p->p_ucred); + ncp_rq_head(rqp,NCP_REQUEST,uap->fn,td,cred); if (rqsize) error = ncp_rq_usermem(rqp,(caddr_t)uap->ncpbuf->packet, rqsize); if (!error) { @@ -131,12 +142,12 @@ __P(sncp_request(struct proc *p, struct sncp_request_args *uap)){ copyout(&rqp->rpsize, &uap->ncpbuf->rpsize, sizeof(rqp->rpsize)); } ncp_rq_done(rqp); - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); return error; } static int -ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, +ncp_conn_handler(struct thread *td, struct sncp_request_args *uap, struct ncp_conn *conn, struct ncp_handle *hp) { int error=0, rqsize, subfn; @@ -144,7 +155,9 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, char *pdata; - cred = p->p_ucred; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int)); if (error) return(error); error = 0; @@ -168,16 +181,16 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, auio.uio_resid = rwrq.nrw_cnt; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = (subfn == NCP_CONN_READ) ? UIO_READ : UIO_WRITE; - auio.uio_procp = p; - error = ncp_conn_lock(conn,p,cred,NCPM_EXECUTE); + auio.uio_td = td; + error = ncp_conn_lock(conn,td,cred,NCPM_EXECUTE); if (error) return(error); if (subfn == NCP_CONN_READ) error = ncp_read(conn, &rwrq.nrw_fh, &auio, cred); else error = ncp_write(conn, &rwrq.nrw_fh, &auio, cred); rwrq.nrw_cnt -= auio.uio_resid; - ncp_conn_unlock(conn,p); - p->p_retval[0] = rwrq.nrw_cnt; + ncp_conn_unlock(conn,td); + td->td_proc->p_retval[0] = rwrq.nrw_cnt; break; } /* case int_read/write */ case NCP_CONN_SETFLAGS: { @@ -188,7 +201,7 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, pdata += sizeof(mask); error = copyin(pdata,&flags,sizeof(flags)); if (error) return error; - error = ncp_conn_lock(conn,p,cred,NCPM_WRITE); + error = ncp_conn_lock(conn,td,cred,NCPM_WRITE); if (error) return error; if (mask & NCPFL_PERMANENT) { conn->flags &= ~NCPFL_PERMANENT; @@ -197,11 +210,11 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, if (mask & NCPFL_PRIMARY) { error = ncp_conn_setprimary(conn, flags & NCPFL_PRIMARY); if (error) { - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); break; } } - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); break; } case NCP_CONN_LOGIN: { @@ -209,48 +222,48 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, if (rqsize != sizeof(la)) return (EBADRPC); if ((error = copyin(pdata,&la,rqsize)) != 0) break; - error = ncp_conn_lock(conn, p, cred, NCPM_EXECUTE | NCPM_WRITE); + error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE | NCPM_WRITE); if (error) return error; - error = ncp_login(conn, la.username, la.objtype, la.password, p, p->p_ucred); - ncp_conn_unlock(conn, p); - p->p_retval[0] = error; + error = ncp_login(conn, la.username, la.objtype, la.password, td, cred); + ncp_conn_unlock(conn, td); + td->td_proc->p_retval[0] = error; break; } case NCP_CONN_GETINFO: { struct ncp_conn_stat ncs; int len = sizeof(ncs); - error = ncp_conn_lock(conn, p, p->p_ucred, NCPM_READ); + error = ncp_conn_lock(conn, td, cred, NCPM_READ); if (error) return error; ncp_conn_getinfo(conn, &ncs); copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); error = copyout(&ncs, &uap->ncpbuf->packet, len); - ncp_conn_unlock(conn, p); + ncp_conn_unlock(conn, td); break; } case NCP_CONN_GETUSER: { int len; - error = ncp_conn_lock(conn, p, p->p_ucred, NCPM_READ); + error = ncp_conn_lock(conn, td, cred, NCPM_READ); if (error) return error; len = (conn->li.user) ? strlen(conn->li.user) + 1 : 0; copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); if (len) { error = copyout(conn->li.user, &uap->ncpbuf->packet, len); } - ncp_conn_unlock(conn, p); + ncp_conn_unlock(conn, td); break; } case NCP_CONN_CONN2REF: { int len = sizeof(int); - error = ncp_conn_lock(conn, p, p->p_ucred, NCPM_READ); + error = ncp_conn_lock(conn, td, cred, NCPM_READ); if (error) return error; copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); if (len) { error = copyout(&conn->nc_id, &uap->ncpbuf->packet, len); } - ncp_conn_unlock(conn, p); + ncp_conn_unlock(conn, td); break; } case NCP_CONN_FRAG: { @@ -258,34 +271,34 @@ ncp_conn_handler(struct proc *p, struct sncp_request_args *uap, if (rqsize != sizeof(nf)) return (EBADRPC); if ((error = copyin(pdata, &nf, rqsize)) != 0) break; - error = ncp_conn_lock(conn, p, cred, NCPM_EXECUTE); + error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE); if (error) return error; - error = ncp_conn_frag_rq(conn, p, &nf); - ncp_conn_unlock(conn, p); + error = ncp_conn_frag_rq(conn, td, &nf); + ncp_conn_unlock(conn, td); copyout(&nf, &pdata, sizeof(nf)); - p->p_retval[0] = error; + td->td_proc->p_retval[0] = error; break; } case NCP_CONN_DUP: { struct ncp_handle *newhp; int len = sizeof(NWCONN_HANDLE); - error = ncp_conn_lock(conn, p, cred, NCPM_READ); + error = ncp_conn_lock(conn, td, cred, NCPM_READ); if (error) break; copyout(&len, &uap->ncpbuf->rpsize, len); - error = ncp_conn_gethandle(conn, p, &newhp); + error = ncp_conn_gethandle(conn, td, &newhp); if (!error) error = copyout(&newhp->nh_id, uap->ncpbuf->packet, len); - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); break; } case NCP_CONN_CONNCLOSE: { - error = ncp_conn_lock(conn, p, cred, NCPM_EXECUTE); + error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE); if (error) break; - ncp_conn_puthandle(hp, p, 0); + ncp_conn_puthandle(hp, td, 0); error = ncp_disconnect(conn); if (error) - ncp_conn_unlock(conn, p); + ncp_conn_unlock(conn, td); break; } default: @@ -300,12 +313,17 @@ struct sncp_conn_scan_args { }; static int -__P(sncp_conn_scan(struct proc *p, struct sncp_conn_scan_args *uap)){ +sncp_conn_scan(struct thread *td, struct sncp_conn_scan_args *uap) +{ int connHandle = 0, error; struct ncp_conn_args li, *lip; struct ncp_conn *conn; struct ncp_handle *hp; char *user = NULL, *password = NULL; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; if (uap->li) { if (copyin(uap->li,&li,sizeof(li))) return EFAULT; @@ -334,28 +352,32 @@ __P(sncp_conn_scan(struct proc *p, struct sncp_conn_scan_args *uap)){ lip->user = user; lip->password = password; } - error = ncp_conn_getbyli(lip,p,p->p_ucred,NCPM_EXECUTE,&conn); + error = ncp_conn_getbyli(lip,td,cred,NCPM_EXECUTE,&conn); if (!error) { /* already have this login */ - ncp_conn_gethandle(conn, p, &hp); + ncp_conn_gethandle(conn, td, &hp); connHandle = hp->nh_id; - ncp_conn_unlock(conn,p); + ncp_conn_unlock(conn,td); copyout(&connHandle,uap->connHandle,sizeof(connHandle)); } if (user) free(user, M_NCPDATA); if (password) free(password, M_NCPDATA); - p->p_retval[0] = error; + td->td_proc->p_retval[0] = error; return error; } int -ncp_conn_frag_rq(struct ncp_conn *conn, struct proc *p, struct ncp_conn_frag *nfp){ +ncp_conn_frag_rq(struct ncp_conn *conn, struct thread *td, struct ncp_conn_frag *nfp){ int error = 0, i, rpsize; u_int32_t fsize; NW_FRAGMENT *fp; + struct ucred *cred; DECLARE_RQ; - ncp_rq_head(rqp,NCP_REQUEST,nfp->fn,p,p->p_ucred); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + + ncp_rq_head(rqp,NCP_REQUEST,nfp->fn,td,cred); if (nfp->rqfcnt) { for(fp = nfp->rqf, i = 0; i < nfp->rqfcnt; i++, fp++) { checkbad(ncp_rq_usermem(rqp,(caddr_t)fp->fragAddress, fp->fragSize)); @@ -389,7 +411,7 @@ struct sncp_intfn_args { }; static int -sncp_intfn(struct proc *p, struct sncp_intfn_args *uap) +sncp_intfn(struct thread *td, struct sncp_intfn_args *uap) { return ENOSYS; } diff --git a/sys/netproto/ncp/ncp_ncp.c b/sys/netproto/ncp/ncp_ncp.c index 10cd609aa0..b1260ca257 100644 --- a/sys/netproto/ncp/ncp_ncp.c +++ b/sys/netproto/ncp/ncp_ncp.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_ncp.c,v 1.3 1999/10/29 10:21:07 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_ncp.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_ncp.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ * * Core of NCP protocol */ @@ -84,9 +84,10 @@ void m_dumpm(struct mbuf *m) { #endif /* NCP_DATA_DEBUG */ int -ncp_chkintr(struct ncp_conn *conn, struct proc *p) +ncp_chkintr(struct ncp_conn *conn, struct thread *td) { sigset_t tmpset; + struct proc *p = td->td_proc; if (p == NULL) return 0; @@ -101,7 +102,7 @@ ncp_chkintr(struct ncp_conn *conn, struct proc *p) /* * Process initial NCP handshake (attach) * NOTE: Since all functions below may change conn attributes, they - * should be called with LOCKED connection, also they use procp & ucred + * should be called with LOCKED connection, also they use td & ucred */ int ncp_ncp_connect(struct ncp_conn *conn) { @@ -111,7 +112,7 @@ ncp_ncp_connect(struct ncp_conn *conn) { conn->flags &= ~(NCPFL_INVALID | NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED); conn->seq = 0; - checkbad(ncp_rq_head(rqp,NCP_ALLOC_SLOT,0,conn->procp,conn->ucred)); + checkbad(ncp_rq_head(rqp,NCP_ALLOC_SLOT,0,conn->td,conn->ucred)); error=ncp_do_request(conn,rqp); if (!error) { rp = mtod(rqp->rp, struct ncp_rphdr*); @@ -147,7 +148,7 @@ ncp_ncp_disconnect(struct ncp_conn *conn) { #ifdef NCPBURST ncp_burst_disconnect(conn); #endif - error=ncp_rq_head(rqp,NCP_FREE_SLOT,0,conn->procp,conn->ucred); + error=ncp_rq_head(rqp,NCP_FREE_SLOT,0,conn->td,conn->ucred); ncprq = mtod(rqp->rq,struct ncp_rqhdr*); error=ncp_do_request(conn,rqp); ncp_rq_done(rqp); @@ -181,7 +182,7 @@ static int ncp_do_request(struct ncp_conn *conn, struct ncp_rq *rqp) { int error=EIO,len, dosend, plen = 0, gotpacket, s; struct socket *so; - struct proc *p = conn->procp; + struct thread *td = conn->td; struct ncp_rqhdr *rq; struct ncp_rphdr *rp=NULL; struct timeval tv; @@ -189,8 +190,8 @@ ncp_do_request(struct ncp_conn *conn, struct ncp_rq *rqp) { conn->nc_rq = rqp; rqp->conn = conn; - if (p == NULL) - p = curproc; /* XXX maybe procpage ? */ + if (td == NULL) + td = curthread; /* XXX maybe procpage ? */ if (!ncp_conn_valid(conn)) { printf("%s: conn not valid\n",__FUNCTION__); return (error); @@ -250,10 +251,10 @@ ncp_do_request(struct ncp_conn *conn, struct ncp_rq *rqp) { } tv.tv_sec = conn->li.timeout; tv.tv_usec = 0; - error = ncp_sock_rselect(so, p, &tv, POLLIN); + error = ncp_sock_rselect(so, td, &tv, POLLIN); if (error == EWOULDBLOCK ) /* timeout expired */ continue; - error = ncp_chkintr(conn, p); + error = ncp_chkintr(conn, td); if (error == EINTR) /* we dont restart */ break; if (error) break; @@ -374,7 +375,7 @@ ncp_restore_login(struct ncp_conn *conn) { error = ncp_reconnect(conn); if (error) break; if (conn->li.user) - error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->procp,conn->ucred); + error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->td,conn->ucred); if (error) break; conn->flags |= NCPFL_LOGGED; } while(0); @@ -390,7 +391,7 @@ ncp_request(struct ncp_conn *conn, struct ncp_rq *rqp) { int error, rcnt; /* struct ncp_rqhdr *rq = mtod(rqp->rq,struct ncp_rqhdr*);*/ - error = ncp_conn_lock(conn,rqp->p,rqp->cred,NCPM_EXECUTE); + error = ncp_conn_lock(conn,rqp->td,rqp->cred,NCPM_EXECUTE); if (error) return error; rcnt = NCP_RESTORE_COUNT; for(;;) { @@ -408,7 +409,7 @@ ncp_request(struct ncp_conn *conn, struct ncp_rq *rqp) { if (ncp_conn_valid(conn)) /* not just error ! */ break; } - ncp_conn_unlock(conn,rqp->p); + ncp_conn_unlock(conn,rqp->td); return error; } @@ -420,7 +421,7 @@ ncp_negotiate_buffersize(struct ncp_conn *conn, int size, int *target) { int error; DECLARE_RQ; - NCP_RQ_HEAD(0x21,conn->procp,conn->ucred); + NCP_RQ_HEAD(0x21,conn->td,conn->ucred); ncp_rq_word_hl(rqp, size); checkbad(ncp_request(conn,rqp)); *target = min(ncp_rp_word_hl(rqp), size); @@ -435,7 +436,7 @@ ncp_negotiate_size_and_options(struct ncp_conn *conn, int size, int options, int rs; DECLARE_RQ; - NCP_RQ_HEAD(0x61,conn->procp,conn->ucred); + NCP_RQ_HEAD(0x61,conn->td,conn->ucred); ncp_rq_word_hl(rqp, size); ncp_rq_byte(rqp, options); checkbad(ncp_request(conn, rqp)); @@ -534,7 +535,7 @@ ncp_reconnect(struct ncp_conn *conn) { * Server addr should be filled in. */ int -ncp_connect(struct ncp_conn_args *li, struct proc *p, struct ucred *cred, +ncp_connect(struct ncp_conn_args *li, struct thread *td, struct ucred *cred, struct ncp_conn **aconn) { struct ncp_conn *conn; @@ -559,7 +560,7 @@ ncp_connect(struct ncp_conn_args *li, struct proc *p, struct ucred *cred, owner = cred; crhold(owner); } - error = ncp_conn_alloc(p, owner, &conn); + error = ncp_conn_alloc(td, owner, &conn); if (error) return (error); if (error) { @@ -605,7 +606,7 @@ ncp_check_rq(struct ncp_conn *conn){ return; if (conn->flags & NCPFL_INTR) return; /* first, check for signals */ - if (ncp_chkintr(conn,conn->procp)) { + if (ncp_chkintr(conn,conn->td)) { conn->flags |= NCPFL_INTR; } return; diff --git a/sys/netproto/ncp/ncp_ncp.h b/sys/netproto/ncp/ncp_ncp.h index ef7838d1cb..998f3d92a3 100644 --- a/sys/netproto/ncp/ncp_ncp.h +++ b/sys/netproto/ncp/ncp_ncp.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_ncp.h,v 1.3 2000/01/14 19:54:38 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_ncp.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_ncp.h,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #ifndef _NETNCP_NCP_NCP_H_ #define _NETNCP_NCP_NCP_H_ @@ -110,15 +110,16 @@ struct ncp_conn; struct ncp_conn_args; struct ncp_rq; struct proc; +struct thread; struct ucred; int ncp_request(struct ncp_conn *conn,struct ncp_rq *rqp); int ncp_ncp_connect(struct ncp_conn *conn); int ncp_ncp_disconnect(struct ncp_conn *conn); int ncp_reconnect(struct ncp_conn *conn); -int ncp_connect(struct ncp_conn_args *li,struct proc *p, struct ucred *cred,struct ncp_conn **aconn); +int ncp_connect(struct ncp_conn_args *li,struct thread *td, struct ucred *cred,struct ncp_conn **aconn); int ncp_disconnect(struct ncp_conn *conn); int ncp_login(struct ncp_conn *conn, char *user, int objtype, char *password, - struct proc *p, struct ucred *cred); + struct thread *td, struct ucred *cred); #endif /* _NCP_NCP_H_ */ diff --git a/sys/netproto/ncp/ncp_rq.c b/sys/netproto/ncp/ncp_rq.c index 22f25af40c..4035da0648 100644 --- a/sys/netproto/ncp/ncp_rq.c +++ b/sys/netproto/ncp/ncp_rq.c @@ -32,7 +32,7 @@ * Routines to prepare request and fetch reply * * $FreeBSD: src/sys/netncp/ncp_rq.c,v 1.1.2.1 2001/05/21 16:27:20 ru Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_rq.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_rq.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include #include @@ -48,7 +48,7 @@ #include int -ncp_rq_head(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,struct proc *p, +ncp_rq_head(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,struct thread *td, struct ucred *cred) { struct mbuf *m; @@ -57,7 +57,7 @@ ncp_rq_head(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,struct proc *p, caddr_t pstart; bzero(rqp, sizeof(*rqp)); - rqp->p = p; + rqp->td = td; rqp->cred = cred; m = m_gethdr(M_WAIT, MT_DATA); if (m == NULL) diff --git a/sys/netproto/ncp/ncp_rq.h b/sys/netproto/ncp/ncp_rq.h index e4ba65a465..6f70d44cab 100644 --- a/sys/netproto/ncp/ncp_rq.h +++ b/sys/netproto/ncp/ncp_rq.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_rq.h,v 1.4 2000/01/14 19:54:38 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_rq.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_rq.h,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #ifndef _NETNCP_NCP_RQ_H_ #define _NETNCP_NCP_RQ_H_ @@ -98,7 +98,7 @@ struct ncp_rq { int rpsize; /* reply size minus ncp header */ int cc; /* completion code */ int cs; /* connection state */ - struct proc *p; /* proc that did rq */ + struct thread *td; /* thread that did rq */ struct ucred *cred; /* user that did rq */ int rexmit; }; @@ -106,16 +106,16 @@ struct ncp_rq { #define DECLARE_RQ struct ncp_rq rq;struct ncp_rq *rqp=&rq -int ncp_rq_head(struct ncp_rq *rqp,u_int32_t ptype, u_int8_t fn,struct proc *p, - struct ucred *cred); +int ncp_rq_head(struct ncp_rq *rqp,u_int32_t ptype, u_int8_t fn, + struct thread *td, struct ucred *cred); int ncp_rq_done(struct ncp_rq *rqp); /* common case for normal request */ -#define ncp_rq_init(rqp,fn,p,c) ncp_rq_head((rqp),NCP_REQUEST,(fn),(p),(c)) +#define ncp_rq_init(rqp,fn,td,c) ncp_rq_head((rqp),NCP_REQUEST,(fn),(td),(c)) #define ncp_rq_close(rqp) ncp_rq_done((rqp)) -#define NCP_RQ_HEAD(fn,p,c) ncp_rq_init(rqp,fn,p,c) -#define NCP_RQ_HEAD_S(fn,sfn,p,c) NCP_RQ_HEAD(fn,p,c);ncp_rq_word(rqp,0);ncp_rq_byte(rqp,(sfn)) +#define NCP_RQ_HEAD(fn,td,c) ncp_rq_init(rqp,fn,td,c) +#define NCP_RQ_HEAD_S(fn,sfn,td,c) do { NCP_RQ_HEAD(fn,td,c);ncp_rq_word(rqp,0);ncp_rq_byte(rqp,(sfn)); } while(0) #define NCP_RQ_EXIT bad: ncp_rq_close(rqp) #define NCP_RQ_EXIT_NB ncp_rq_close(rqp) #define ncp_rq_word ncp_rq_word_lh diff --git a/sys/netproto/ncp/ncp_sock.c b/sys/netproto/ncp/ncp_sock.c index fd83f9f646..48c2e72c80 100644 --- a/sys/netproto/ncp/ncp_sock.c +++ b/sys/netproto/ncp/ncp_sock.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_sock.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_sock.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_sock.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ * * Low level socket routines */ @@ -75,17 +75,17 @@ /*int ncp_poll(struct socket *so, int events);*/ /*static int ncp_getsockname(struct socket *so, caddr_t asa, int *alen);*/ -static int ncp_soconnect(struct socket *so,struct sockaddr *target, struct proc *p); +static int ncp_soconnect(struct socket *so,struct sockaddr *target, struct thread *p); /* This will need only if native IP used, or (unlikely) NCP will be * implemented on the socket level */ static int -ncp_soconnect(struct socket *so,struct sockaddr *target, struct proc *p) { +ncp_soconnect(struct socket *so,struct sockaddr *target, struct thread *td) { int error,s; - error = soconnect(so, (struct sockaddr*)target, p); + error = soconnect(so, (struct sockaddr*)target, td); if (error) return error; /* @@ -138,11 +138,11 @@ ncp_getsockname(struct socket *so, caddr_t asa, int *alen) { int ncp_sock_recv(struct socket *so, struct mbuf **mp, int *rlen) { struct uio auio; - struct proc *p=curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int error,flags,len; auio.uio_resid = len = 1000000; - auio.uio_procp = p; + auio.uio_td = td; flags = MSG_DONTWAIT; /* error = so->so_proto->pr_usrreqs->pru_soreceive(so, 0, &auio, @@ -164,7 +164,7 @@ int ncp_sock_recv(struct socket *so, struct mbuf **mp, int *rlen) int ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct sockaddr *to = 0; struct ncp_conn *conn = rqp->conn; struct mbuf *m; @@ -174,13 +174,13 @@ ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp) for(;;) { m = m_copym(top, 0, M_COPYALL, M_WAIT); /* NCPDDEBUG(m);*/ - error = so->so_proto->pr_usrreqs->pru_sosend(so, to, 0, m, 0, flags, p); + error = so->so_proto->pr_usrreqs->pru_sosend(so, to, 0, m, 0, flags, td); if (error == 0 || error == EINTR || error == ENETDOWN) break; if (rqp->rexmit == 0) break; rqp->rexmit--; tsleep(&sendwait, PWAIT, "ncprsn", conn->li.timeout * hz); - error = ncp_chkintr(conn, p); + error = ncp_chkintr(conn, td); if (error == EINTR) break; } if (error) { @@ -191,17 +191,21 @@ ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp) int ncp_poll(struct socket *so, int events){ - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct ucred *cred=NULL; - 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 -ncp_sock_rselect(struct socket *so,struct proc *p, struct timeval *tv, int events) +ncp_sock_rselect(struct socket *so, struct thread *td, + struct timeval *tv, int events) { struct timeval atv,rtv,ttv; + struct proc *p = td->td_proc; int s,timo,error=0; + KKASSERT(p); + if (tv) { atv=*tv; if (itimerfix(&atv)) { @@ -252,7 +256,7 @@ int ncp_sock_connect_ipx(struct ncp_conn *conn) { struct sockaddr_ipx sipx; struct ipxpcb *npcb; - struct proc *p = conn->procp; + struct thread *td = conn->td; int addrlen, error, count; sipx.sipx_port = htons(0); @@ -263,15 +267,15 @@ ncp_sock_connect_ipx(struct ncp_conn *conn) { goto bad; } conn->ncp_so = conn->wdg_so = NULL; - checkbad(socreate(AF_IPX, &conn->ncp_so, SOCK_DGRAM, 0, p)); + checkbad(socreate(AF_IPX, &conn->ncp_so, SOCK_DGRAM, 0, td)); if (conn->li.opt & NCP_OPT_WDOG) - checkbad(socreate(AF_IPX, &conn->wdg_so, SOCK_DGRAM,0,p)); + checkbad(socreate(AF_IPX, &conn->wdg_so, SOCK_DGRAM,0,td)); addrlen = sizeof(sipx); sipx.sipx_family = AF_IPX; ipx_setnullnet(sipx.sipx_addr); ipx_setnullhost(sipx.sipx_addr); sipx.sipx_len = addrlen; - error = sobind(conn->ncp_so, (struct sockaddr *)&sipx, p); + error = sobind(conn->ncp_so, (struct sockaddr *)&sipx, td); if (error == 0) { if ((conn->li.opt & NCP_OPT_WDOG) == 0) break; @@ -279,7 +283,7 @@ ncp_sock_connect_ipx(struct ncp_conn *conn) { sipx.sipx_port = htons(ntohs(sipx.sipx_port) + 1); ipx_setnullnet(sipx.sipx_addr); ipx_setnullhost(sipx.sipx_addr); - error = sobind(conn->wdg_so, (struct sockaddr *)&sipx, p); + error = sobind(conn->wdg_so, (struct sockaddr *)&sipx, td); } if (!error) break; if (error != EADDRINUSE) goto bad; @@ -292,7 +296,7 @@ ncp_sock_connect_ipx(struct ncp_conn *conn) { npcb->ipxp_dpt = IPXPROTO_NCP; /* IPXrouted must be running, i.e. route must be presented */ conn->li.ipxaddr.sipx_len = sizeof(struct sockaddr_ipx); - checkbad(ncp_soconnect(conn->ncp_so, &conn->li.saddr, p)); + checkbad(ncp_soconnect(conn->ncp_so, &conn->li.saddr, td)); if (conn->wdg_so) { sotoipxpcb(conn->wdg_so)->ipxp_laddr.x_net = npcb->ipxp_laddr.x_net; sotoipxpcb(conn->wdg_so)->ipxp_laddr.x_host= npcb->ipxp_laddr.x_host; @@ -302,11 +306,11 @@ ncp_sock_connect_ipx(struct ncp_conn *conn) { } #ifdef NCPBURST if (ncp_burst_enabled) { - checkbad(socreate(AF_IPX, &conn->bc_so, SOCK_DGRAM, 0, p)); + checkbad(socreate(AF_IPX, &conn->bc_so, SOCK_DGRAM, 0, td)); bzero(&sipx, sizeof(sipx)); sipx.sipx_len = sizeof(sipx); - checkbad(sobind(conn->bc_so, (struct sockaddr *)&sipx, p)); - checkbad(ncp_soconnect(conn->bc_so, &conn->li.saddr, p)); + checkbad(sobind(conn->bc_so, (struct sockaddr *)&sipx, td)); + checkbad(ncp_soconnect(conn->bc_so, &conn->li.saddr, td)); } #endif if (!error) { @@ -340,17 +344,17 @@ ncp_sock_checksum(struct ncp_conn *conn, int enable) { int ncp_sock_connect_in(struct ncp_conn *conn) { struct sockaddr_in sin; - struct proc *p=conn->procp; + struct thread *td = conn->td; int addrlen=sizeof(sin), error; conn->flags = 0; bzero(&sin,addrlen); conn->ncp_so = conn->wdg_so = NULL; - checkbad(socreate(AF_INET, &conn->ncp_so, SOCK_DGRAM, IPPROTO_UDP, p)); + checkbad(socreate(AF_INET, &conn->ncp_so, SOCK_DGRAM, IPPROTO_UDP, td)); sin.sin_family = AF_INET; sin.sin_len = addrlen; - checkbad(sobind(conn->ncp_so, (struct sockaddr *)&sin, p)); - checkbad(ncp_soconnect(conn->ncp_so,(struct sockaddr*)&conn->li.addr, p)); + checkbad(sobind(conn->ncp_so, (struct sockaddr *)&sin, td)); + checkbad(ncp_soconnect(conn->ncp_so,(struct sockaddr*)&conn->li.addr, td)); if (!error) conn->flags |= NCPFL_SOCONN; return error; @@ -405,7 +409,7 @@ ncp_watchdog(struct ncp_conn *conn) { while (conn->wdg_so) { /* not a loop */ so = conn->wdg_so; auio.uio_resid = len = 1000000; - auio.uio_procp = curproc; + auio.uio_td = curthread; flags = MSG_DONTWAIT; error = so->so_proto->pr_usrreqs->pru_soreceive(so, (struct sockaddr**)&sa, &auio, &m, (struct mbuf**)0, &flags); @@ -416,7 +420,7 @@ ncp_watchdog(struct ncp_conn *conn) { buf = mtod(m, char*); if (buf[1] != '?') break; buf[1] = 'Y'; - error = so->so_proto->pr_usrreqs->pru_sosend(so, (struct sockaddr*)sa, 0, m, 0, 0, curproc); + error = so->so_proto->pr_usrreqs->pru_sosend(so, (struct sockaddr*)sa, 0, m, 0, 0, curthread); NCPSDEBUG("send watch dog %d\n",error); break; } diff --git a/sys/netproto/ncp/ncp_sock.h b/sys/netproto/ncp/ncp_sock.h index 048deda81c..696f2edbe8 100644 --- a/sys/netproto/ncp/ncp_sock.h +++ b/sys/netproto/ncp/ncp_sock.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_sock.h,v 1.3 2000/01/14 19:54:39 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_sock.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_sock.h,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #ifndef _NETNCP_NCP_SOCK_H_ #define _NETNCP_NCP_SOCK_H_ @@ -39,6 +39,7 @@ struct ncp_conn; struct mbuf; struct ncp_rq; struct proc; +struct thread; struct socket; struct timeval; @@ -48,7 +49,7 @@ int ncp_sock_recv(struct socket *so, struct mbuf **mp, int *rlen); int ncp_sock_send(struct socket *so, struct mbuf *data, struct ncp_rq *rqp); int ncp_sock_disconnect(struct ncp_conn *conn); int ncp_poll(struct socket *so, int events); -int ncp_sock_rselect(struct socket *so,struct proc *p, struct timeval *tv,int events); +int ncp_sock_rselect(struct socket *so,struct thread *td, struct timeval *tv,int events); int ncp_sock_checksum(struct ncp_conn *conn, int enable); void ncp_check_rq(struct ncp_conn *conn); diff --git a/sys/netproto/ncp/ncp_subr.c b/sys/netproto/ncp/ncp_subr.c index c501968205..68bc5d0c99 100644 --- a/sys/netproto/ncp/ncp_subr.c +++ b/sys/netproto/ncp/ncp_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_subr.c,v 1.2.2.1 2001/02/22 08:54:11 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_subr.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_subr.c,v 1.3 2003/06/25 03:56:05 dillon Exp $ */ #include #include @@ -54,14 +54,15 @@ int ncp_debuglevel = 0; struct callout_handle ncp_timer_handle; -static void ncp_at_exit(struct proc *p); +static void ncp_at_exit(struct thread *td); static void ncp_timer(void *arg); /* * duplicate string from user space. It should be very-very slow. */ char * -ncp_str_dup(char *s) { +ncp_str_dup(char *s) +{ char *p, bt; int len = 0; @@ -77,26 +78,31 @@ ncp_str_dup(char *s) { void -ncp_at_exit(struct proc *p) { +ncp_at_exit(struct thread *td) +{ struct ncp_conn *ncp, *nncp; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; - if (ncp_conn_putprochandles(p) == 0) return; + if (ncp_conn_putprochandles(td) == 0) return; - ncp_conn_locklist(LK_EXCLUSIVE, p); + ncp_conn_locklist(LK_EXCLUSIVE, td); for (ncp = SLIST_FIRST(&conn_list); ncp; ncp = nncp) { nncp = SLIST_NEXT(ncp, nc_next); if (ncp->ref_cnt != 0) continue; - if (ncp_conn_lock(ncp, p, p->p_ucred,NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) + if (ncp_conn_lock(ncp, td, cred, NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) continue; if (ncp_disconnect(ncp) != 0) - ncp_conn_unlock(ncp,p); + ncp_conn_unlock(ncp, td); } - ncp_conn_unlocklist(p); - return; + ncp_conn_unlocklist(td); } int -ncp_init(void) { +ncp_init(void) +{ ncp_conn_init(); if (at_exit(ncp_at_exit)) { NCPFATAL("can't register at_exit handler\n"); @@ -107,24 +113,29 @@ ncp_init(void) { } void -ncp_done(void) { +ncp_done(void) +{ struct ncp_conn *ncp, *nncp; - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; untimeout(ncp_timer,NULL,ncp_timer_handle); rm_at_exit(ncp_at_exit); - ncp_conn_locklist(LK_EXCLUSIVE, p); + ncp_conn_locklist(LK_EXCLUSIVE, td); for (ncp = SLIST_FIRST(&conn_list); ncp; ncp = nncp) { nncp = SLIST_NEXT(ncp, nc_next); ncp->ref_cnt = 0; - if (ncp_conn_lock(ncp, p, p->p_ucred,NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) { + if (ncp_conn_lock(ncp, td, cred,NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) { NCPFATAL("Can't lock connection !\n"); continue; } if (ncp_disconnect(ncp) != 0) - ncp_conn_unlock(ncp,p); + ncp_conn_unlock(ncp, td); } - ncp_conn_unlocklist(p); + ncp_conn_unlocklist(td); } @@ -145,12 +156,12 @@ int ncp_get_bindery_object_id(struct ncp_conn *conn, u_int16_t object_type, char *object_name, struct ncp_bindery_object *target, - struct proc *p,struct ucred *cred) + struct thread *td,struct ucred *cred) { int error; DECLARE_RQ; - NCP_RQ_HEAD_S(23,53,p,cred); + NCP_RQ_HEAD_S(23,53,td,cred); ncp_rq_word_hl(rqp, object_type); ncp_rq_pstring(rqp, object_name); checkbad(ncp_request(conn,rqp)); @@ -182,7 +193,7 @@ ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cr if (!burstio) { len = min(4096 - (uiop->uio_offset % 4096), tsiz); len = min(len, conn->buffer_size); - NCP_RQ_HEAD(72,uiop->uio_procp,cred); + NCP_RQ_HEAD(72,uiop->uio_td,cred); ncp_rq_byte(rqp, 0); ncp_rq_mem(rqp, (caddr_t)file, 6); ncp_rq_dword(rqp, htonl(uiop->uio_offset)); @@ -224,7 +235,7 @@ ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *c printf("gotcha!\n"); } /* rq head */ - NCP_RQ_HEAD(73,uiop->uio_procp,cred); + NCP_RQ_HEAD(73,uiop->uio_td,cred); ncp_rq_byte(rqp, 0); ncp_rq_mem(rqp, (caddr_t)file, 6); ncp_rq_dword(rqp, htonl(uiop->uio_offset)); diff --git a/sys/netproto/ncp/ncp_subr.h b/sys/netproto/ncp/ncp_subr.h index bee2ed0b33..0c92f30887 100644 --- a/sys/netproto/ncp/ncp_subr.h +++ b/sys/netproto/ncp/ncp_subr.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netncp/ncp_subr.h,v 1.3 2000/01/14 19:54:39 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_subr.h,v 1.3 2003/06/23 17:55:47 dillon Exp $ + * $DragonFly: src/sys/netproto/ncp/ncp_subr.h,v 1.4 2003/06/25 03:56:05 dillon Exp $ */ #ifndef _NETNCP_NCP_SUBR_H_ #define _NETNCP_NCP_SUBR_H_ @@ -84,7 +84,7 @@ #define checkbad(fn) {error=(fn);if(error) goto bad;} -#define ncp_suser(cred) suser_xxx(cred, 0) +#define ncp_suser(cred) suser_cred(cred, 0) #define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid) @@ -107,11 +107,12 @@ struct ncp_open_info { extern int ncp_debuglevel; struct proc; +struct thread; struct ucred; int ncp_init(void); void ncp_done(void); -int ncp_chkintr(struct ncp_conn *conn, struct proc *p); +int ncp_chkintr(struct ncp_conn *conn, struct thread *td); char*ncp_str_dup(char *s); /* ncp_crypt.c */ @@ -123,10 +124,10 @@ void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate); int ncp_get_bindery_object_id(struct ncp_conn *conn, u_int16_t object_type, char *object_name, struct ncp_bindery_object *target, - struct proc *p,struct ucred *cred); + struct thread *td,struct ucred *cred); int ncp_login_object(struct ncp_conn *conn, unsigned char *username, int login_type, unsigned char *password, - struct proc *p,struct ucred *cred); + struct thread *td,struct ucred *cred); int ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred); int ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred); diff --git a/sys/netproto/smb/smb_conn.c b/sys/netproto/smb/smb_conn.c index 58cc9f94a9..89bbdc7e59 100644 --- a/sys/netproto/smb/smb_conn.c +++ b/sys/netproto/smb/smb_conn.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_conn.c,v 1.1.2.1 2001/05/22 08:32:33 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_conn.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_conn.c,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ /* @@ -64,9 +64,9 @@ SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW, NULL, "SMB protocol"); MALLOC_DEFINE(M_SMBCONN, "SMB conn", "SMB connection"); static void smb_co_init(struct smb_connobj *cp, int level, char *objname, - struct proc *p); + struct thread *td); static void smb_co_done(struct smb_connobj *cp); -static int smb_co_lockstatus(struct smb_connobj *cp, struct proc *p); +static int smb_co_lockstatus(struct smb_connobj *cp, struct thread *td); static int smb_vc_disconnect(struct smb_vc *vcp); static void smb_vc_free(struct smb_connobj *cp); @@ -83,8 +83,8 @@ int smb_sm_init(void) { - smb_co_init(&smb_vclist, SMBL_SM, "smbsm", curproc); - smb_co_unlock(&smb_vclist, 0, curproc); + smb_co_init(&smb_vclist, SMBL_SM, "smbsm", curthread); + smb_co_unlock(&smb_vclist, 0, curthread); return 0; } @@ -102,24 +102,22 @@ smb_sm_done(void) } static int -smb_sm_lockvclist(int flags, struct proc *p) +smb_sm_lockvclist(int flags, struct thread *td) { - - return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE, p); + return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE, td); } static void -smb_sm_unlockvclist(struct proc *p) +smb_sm_unlockvclist(struct thread *td) { - - smb_co_unlock(&smb_vclist, LK_RELEASE, p); + smb_co_unlock(&smb_vclist, LK_RELEASE, td); } static int smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_vc *vcp; int exact = 1; int error; @@ -127,7 +125,7 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, vcspec->shspec = shspec; error = ENOENT; SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) { - error = smb_vc_lock(vcp, LK_EXCLUSIVE, p); + error = smb_vc_lock(vcp, LK_EXCLUSIVE, td); if (error) continue; itry { @@ -159,14 +157,14 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, error = 0; break; } icatch(error) { - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); } ifinally { } iendtry; if (error == 0) break; } if (vcp) { - smb_vc_ref(vcp, p); + smb_vc_ref(vcp, td); *vcpp = vcp; } return error; @@ -176,19 +174,19 @@ int smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_vc *vcp; struct smb_share *ssp = NULL; int error; *vcpp = vcp = NULL; - error = smb_sm_lockvclist(LK_EXCLUSIVE, p); + error = smb_sm_lockvclist(LK_EXCLUSIVE, td); if (error) return error; error = smb_sm_lookupint(vcspec, shspec, scred, vcpp); if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) { - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); return error; } error = smb_sm_lookupint(vcspec, NULL, scred, &vcp); @@ -211,7 +209,7 @@ smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, else smb_share_put(ssp, scred); out: - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); if (error == 0) *vcpp = vcp; else if (vcp) @@ -223,14 +221,15 @@ out: * Common code for connection object */ static void -smb_co_init(struct smb_connobj *cp, int level, char *objname, struct proc *p) +smb_co_init(struct smb_connobj *cp, int level, char *objname, struct thread *td) { SLIST_INIT(&cp->co_children); smb_sl_init(&cp->co_interlock, objname); lockinit(&cp->co_lock, PZERO, objname, 0, 0); cp->co_level = level; cp->co_usecount = 1; - KASSERT(smb_co_lock(cp, LK_EXCLUSIVE, p) == 0, ("smb_co_init: lock failed")); + KASSERT(smb_co_lock(cp, LK_EXCLUSIVE, td) == 0, + ("smb_co_init: lock failed")); } static void @@ -249,7 +248,7 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) cp->co_gone(cp, scred); parent = cp->co_parent; if (parent) { - smb_co_lock(parent, LK_EXCLUSIVE, scred->scr_p); + smb_co_lock(parent, LK_EXCLUSIVE, scred->scr_td); SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next); smb_co_put(parent, scred); } @@ -258,7 +257,7 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_co_ref(struct smb_connobj *cp, struct proc *p) +smb_co_ref(struct smb_connobj *cp, struct thread *td) { SMB_CO_LOCK(cp); @@ -269,7 +268,7 @@ smb_co_ref(struct smb_connobj *cp, struct proc *p) void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; SMB_CO_LOCK(cp); if (cp->co_usecount > 1) { @@ -285,7 +284,7 @@ smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) cp->co_usecount--; cp->co_flags |= SMBO_GONE; - lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock, p); + lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock, td); smb_co_gone(cp, scred); } @@ -297,7 +296,7 @@ smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred) if ((flags & LK_INTERLOCK) == 0) SMB_CO_LOCK(cp); cp->co_usecount++; - error = smb_co_lock(cp, flags | LK_INTERLOCK, scred->scr_p); + error = smb_co_lock(cp, flags | LK_INTERLOCK, scred->scr_td); if (error) { SMB_CO_LOCK(cp); cp->co_usecount--; @@ -310,7 +309,7 @@ smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred) void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; int flags; flags = LK_RELEASE; @@ -324,48 +323,48 @@ smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) } else { SMBERROR("negative usecount"); } - lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock, p); + lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock, td); if ((cp->co_flags & SMBO_GONE) == 0) return; - lockmgr(&cp->co_lock, LK_DRAIN, NULL, p); + lockmgr(&cp->co_lock, LK_DRAIN, NULL, td); smb_co_gone(cp, scred); } int -smb_co_lockstatus(struct smb_connobj *cp, struct proc *p) +smb_co_lockstatus(struct smb_connobj *cp, struct thread *td) { - return lockstatus(&cp->co_lock, p); + return lockstatus(&cp->co_lock, td); } int -smb_co_lock(struct smb_connobj *cp, int flags, struct proc *p) +smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td) { if (cp->co_flags & SMBO_GONE) return EINVAL; if ((flags & LK_TYPE_MASK) == 0) flags |= LK_EXCLUSIVE; - if (smb_co_lockstatus(cp, p) == LK_EXCLUSIVE && + if (smb_co_lockstatus(cp, td) == LK_EXCLUSIVE && (flags & LK_CANRECURSE) == 0) { SMBERROR("recursive lock for object %d\n", cp->co_level); return 0; } - return lockmgr(&cp->co_lock, flags, &cp->co_interlock, p); + return lockmgr(&cp->co_lock, flags, &cp->co_interlock, td); } void -smb_co_unlock(struct smb_connobj *cp, int flags, struct proc *p) +smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td) { - (void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock, p); + (void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock, td); } static void smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child) { - KASSERT(smb_co_lockstatus(parent, curproc) == LK_EXCLUSIVE, ("smb_co_addchild: parent not locked")); - KASSERT(smb_co_lockstatus(child, curproc) == LK_EXCLUSIVE, ("smb_co_addchild: child not locked")); + KASSERT(smb_co_lockstatus(parent, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: parent not locked")); + KASSERT(smb_co_lockstatus(child, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: child not locked")); - smb_co_ref(parent, curproc); + smb_co_ref(parent, curthread); SLIST_INSERT_HEAD(&parent->co_children, child, co_next); child->co_parent = parent; } @@ -379,7 +378,7 @@ smb_vc_create(struct smb_vcspec *vcspec, struct smb_cred *scred, struct smb_vc **vcpp) { struct smb_vc *vcp; - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct ucred *cred = scred->scr_cred; uid_t uid = vcspec->owner; gid_t gid = vcspec->group; @@ -397,7 +396,7 @@ smb_vc_create(struct smb_vcspec *vcspec, return EPERM; vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK); - smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc", p); + smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc", td); vcp->obj.co_free = smb_vc_free; vcp->obj.co_gone = smb_vc_gone; vcp->vc_number = smb_vcnext++; @@ -491,9 +490,9 @@ smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_vc_ref(struct smb_vc *vcp, struct proc *p) +smb_vc_ref(struct smb_vc *vcp, struct thread *td) { - smb_co_ref(VCTOCP(vcp), p); + smb_co_ref(VCTOCP(vcp), td); } void @@ -515,15 +514,15 @@ smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred) } int -smb_vc_lock(struct smb_vc *vcp, int flags, struct proc *p) +smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td) { - return smb_co_lock(VCTOCP(vcp), flags, p); + return smb_co_lock(VCTOCP(vcp), flags, td); } void -smb_vc_unlock(struct smb_vc *vcp, int flags, struct proc *p) +smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td) { - smb_co_unlock(VCTOCP(vcp), flags, p); + smb_co_unlock(VCTOCP(vcp), flags, td); } int @@ -575,22 +574,22 @@ int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp, struct smb_cred *scred, struct smb_share **sspp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_share *ssp = NULL; int error; *sspp = NULL; dp->scred = scred; SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) { - error = smb_share_lock(ssp, LK_EXCLUSIVE, p); + error = smb_share_lock(ssp, LK_EXCLUSIVE, td); if (error) continue; if (smb_vc_cmpshare(ssp, dp) == 0) break; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); } if (ssp) { - smb_share_ref(ssp, p); + smb_share_ref(ssp, td); *sspp = ssp; error = 0; } else @@ -669,7 +668,7 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp) { struct smb_share *ssp; - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct ucred *cred = scred->scr_cred; uid_t realuid = cred->cr_uid; uid_t uid = shspec->owner; @@ -694,7 +693,7 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, if (gid == SMBM_ANY_GROUP) gid = cred->cr_groups[0]; ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK); - smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss", p); + smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss", td); ssp->obj.co_free = smb_share_free; ssp->obj.co_gone = smb_share_gone; smb_sl_init(&ssp->ss_stlock, "ssstlock"); @@ -732,9 +731,9 @@ smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_share_ref(struct smb_share *ssp, struct proc *p) +smb_share_ref(struct smb_share *ssp, struct thread *td) { - smb_co_ref(SSTOCP(ssp), p); + smb_co_ref(SSTOCP(ssp), td); } void @@ -756,15 +755,15 @@ smb_share_put(struct smb_share *ssp, struct smb_cred *scred) } int -smb_share_lock(struct smb_share *ssp, int flags, struct proc *p) +smb_share_lock(struct smb_share *ssp, int flags, struct thread *td) { - return smb_co_lock(SSTOCP(ssp), flags, p); + return smb_co_lock(SSTOCP(ssp), flags, td); } void -smb_share_unlock(struct smb_share *ssp, int flags, struct proc *p) +smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td) { - smb_co_unlock(SSTOCP(ssp), flags, p); + smb_co_unlock(SSTOCP(ssp), flags, td); } int @@ -828,7 +827,8 @@ smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip) static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) { - struct proc *p = req->p; + struct thread *td = req->td; + struct ucred *ucred; struct smb_cred scred; struct smb_vc *vcp; struct smb_share *ssp; @@ -836,33 +836,36 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) struct smb_share_info ssi; int error, itype; - smb_makescred(&scred, p, p->p_ucred); - error = smb_sm_lockvclist(LK_SHARED, p); + KKASSERT(td->td_proc); + ucred = td->td_proc->p_ucred; + + smb_makescred(&scred, td, ucred); + error = smb_sm_lockvclist(LK_SHARED, td); if (error) return error; SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) { - error = smb_vc_lock(vcp, LK_SHARED, p); + error = smb_vc_lock(vcp, LK_SHARED, td); if (error) continue; smb_vc_getinfo(vcp, &vci); error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info)); if (error) { - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); break; } SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) { - error = smb_share_lock(ssp, LK_SHARED, p); + error = smb_share_lock(ssp, LK_SHARED, td); if (error) { error = 0; continue; } smb_share_getinfo(ssp, &ssi); - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info)); if (error) break; } - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); if (error) break; } @@ -870,6 +873,6 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) itype = SMB_INFO_NONE; error = SYSCTL_OUT(req, &itype, sizeof(itype)); } - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); return error; } diff --git a/sys/netproto/smb/smb_conn.h b/sys/netproto/smb/smb_conn.h index f5ff1c8d73..d2feb77069 100644 --- a/sys/netproto/smb/smb_conn.h +++ b/sys/netproto/smb/smb_conn.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_conn.h,v 1.1.2.3 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_conn.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_conn.h,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ #ifndef _NETINET_IN_H_ #include @@ -357,12 +357,12 @@ int smb_sm_lookup(struct smb_vcspec *vcspec, /* * Connection object */ -void smb_co_ref(struct smb_connobj *cp, struct proc *p); +void smb_co_ref(struct smb_connobj *cp, struct thread *td); void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred); int smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred); void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred); -int smb_co_lock(struct smb_connobj *cp, int flags, struct proc *p); -void smb_co_unlock(struct smb_connobj *cp, int flags, struct proc *p); +int smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td); +void smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td); /* * session level functions @@ -373,10 +373,10 @@ int smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred); int smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode); int smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred); void smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred); -void smb_vc_ref(struct smb_vc *vcp, struct proc *p); +void smb_vc_ref(struct smb_vc *vcp, struct thread *td); void smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred); -int smb_vc_lock(struct smb_vc *vcp, int flags, struct proc *p); -void smb_vc_unlock(struct smb_vc *vcp, int flags, struct proc *p); +int smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td); +void smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td); int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp); const char * smb_vc_getpass(struct smb_vc *vcp); @@ -388,12 +388,12 @@ u_short smb_vc_nextmid(struct smb_vc *vcp); int smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp); int smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode); -void smb_share_ref(struct smb_share *ssp, struct proc *p); +void smb_share_ref(struct smb_share *ssp, struct thread *td); void smb_share_rele(struct smb_share *ssp, struct smb_cred *scred); int smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred); void smb_share_put(struct smb_share *ssp, struct smb_cred *scred); -int smb_share_lock(struct smb_share *ssp, int flags, struct proc *p); -void smb_share_unlock(struct smb_share *ssp, int flags, struct proc *p); +int smb_share_lock(struct smb_share *ssp, int flags, struct thread *td); +void smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td); void smb_share_invalidate(struct smb_share *ssp); int smb_share_valid(struct smb_share *ssp); const char * smb_share_getpass(struct smb_share *ssp); @@ -444,7 +444,7 @@ struct smbiod { struct smb_slock iod_rqlock; /* iod_rqlist, iod_muxwant */ struct smb_rqhead iod_rqlist; /* list of outstanding requests */ int iod_muxwant; - struct proc * iod_p; + struct thread * iod_td; struct smb_cred iod_scred; struct smb_slock iod_evlock; /* iod_evlist */ STAILQ_HEAD(,smbiod_event) iod_evlist; diff --git a/sys/netproto/smb/smb_dev.c b/sys/netproto/smb/smb_dev.c index beb40c42c4..b736103b70 100644 --- a/sys/netproto/smb/smb_dev.c +++ b/sys/netproto/smb/smb_dev.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_dev.c,v 1.2.2.1 2001/05/22 08:32:33 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_dev.c,v 1.3 2003/06/23 17:55:47 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_dev.c,v 1.4 2003/06/25 03:56:06 dillon Exp $ */ #include #include @@ -114,6 +114,7 @@ nsmb_dev_open(dev_t dev, int oflags, int devtype, d_thread_t *td) KKASSERT(p != NULL); cred = p->p_ucred; + sdp = SMB_GETDEV(dev); if (sdp && (sdp->sd_flags & NSMBFL_OPEN)) return EBUSY; @@ -144,7 +145,6 @@ nsmb_dev_open(dev_t dev, int oflags, int devtype, d_thread_t *td) static int nsmb_dev_close(dev_t dev, int flag, int fmt, d_thread_t *td) { - struct proc *p = td->td_proc; struct smb_dev *sdp; struct smb_vc *vcp; struct smb_share *ssp; @@ -157,7 +157,7 @@ nsmb_dev_close(dev_t dev, int flag, int fmt, d_thread_t *td) splx(s); return EBADF; } - smb_makescred(&scred, p, NULL); + smb_makescred(&scred, td, NULL); ssp = sdp->sd_share; if (ssp != NULL) smb_share_rele(ssp, &scred); @@ -179,7 +179,6 @@ nsmb_dev_close(dev_t dev, int flag, int fmt, d_thread_t *td) static int nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) { - struct proc *p = td->td_proc; struct smb_dev *sdp; struct smb_vc *vcp; struct smb_share *ssp; @@ -190,7 +189,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) if ((sdp->sd_flags & NSMBFL_OPEN) == 0) return EBADF; - smb_makescred(&scred, p, NULL); + smb_makescred(&scred, td, NULL); switch (cmd) { case SMBIOC_OPENSESSION: if (sdp->sd_vc) @@ -200,7 +199,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) if (error) break; sdp->sd_vc = vcp; - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); sdp->sd_level = SMBL_VC; break; case SMBIOC_OPENSHARE: @@ -213,7 +212,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) if (error) break; sdp->sd_share = ssp; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); sdp->sd_level = SMBL_SHARE; break; case SMBIOC_REQUEST: @@ -242,7 +241,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) break; if (on && (vcp->obj.co_flags & SMBV_PERMANENT) == 0) { vcp->obj.co_flags |= SMBV_PERMANENT; - smb_vc_ref(vcp, p); + smb_vc_ref(vcp, td); } else if (!on && (vcp->obj.co_flags & SMBV_PERMANENT)) { vcp->obj.co_flags &= ~SMBV_PERMANENT; smb_vc_rele(vcp, &scred); @@ -260,7 +259,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) break; if (on && (ssp->obj.co_flags & SMBS_PERMANENT) == 0) { ssp->obj.co_flags |= SMBS_PERMANENT; - smb_share_ref(ssp, p); + smb_share_ref(ssp, td); } else if (!on && (ssp->obj.co_flags & SMBS_PERMANENT)) { ssp->obj.co_flags &= ~SMBS_PERMANENT; smb_share_rele(ssp, &scred); @@ -283,12 +282,12 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) break; if (vcp) { sdp->sd_vc = vcp; - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); sdp->sd_level = SMBL_VC; } if (ssp) { sdp->sd_share = ssp; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); sdp->sd_level = SMBL_SHARE; } break; @@ -307,7 +306,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td) auio.uio_resid = rwrq->ioc_cnt; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = (cmd == SMBIOC_READ) ? UIO_READ : UIO_WRITE; - auio.uio_procp = p; + auio.uio_td = td; if (cmd == SMBIOC_READ) error = smb_read(ssp, rwrq->ioc_fh, &auio, &scred); else @@ -403,8 +402,12 @@ smb_dev2share(int fd, int mode, struct smb_cred *scred, dev_t dev; int error; - if ((fp = nsmb_getfp(scred->scr_p->p_fd, fd, FREAD | FWRITE)) == NULL) + KKASSERT(scred->scr_td->td_proc); + + if ((fp = nsmb_getfp(scred->scr_td->td_proc->p_fd, + fd, FREAD | FWRITE)) == NULL) { return EBADF; + } vp = (struct vnode*)fp->f_data; if (vp == NULL) return EBADF; diff --git a/sys/netproto/smb/smb_iod.c b/sys/netproto/smb/smb_iod.c index 5190e8b6c1..9176fd79db 100644 --- a/sys/netproto/smb/smb_iod.c +++ b/sys/netproto/smb/smb_iod.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_iod.c,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_iod.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_iod.c,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ #include @@ -104,12 +104,12 @@ static void smb_iod_closetran(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; if (vcp->vc_tdata == NULL) return; - SMB_TRAN_DISCONNECT(vcp, p); - SMB_TRAN_DONE(vcp, p); + SMB_TRAN_DISCONNECT(vcp, td); + SMB_TRAN_DONE(vcp, td); vcp->vc_tdata = NULL; } @@ -125,7 +125,7 @@ static int smb_iod_connect(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; int error; SMBIODEBUG("%d\n", iod->iod_state); @@ -141,13 +141,13 @@ smb_iod_connect(struct smbiod *iod) vcp->vc_genid++; error = 0; itry { - ithrow(SMB_TRAN_CREATE(vcp, p)); + ithrow(SMB_TRAN_CREATE(vcp, td)); SMBIODEBUG("tcreate\n"); if (vcp->vc_laddr) { - ithrow(SMB_TRAN_BIND(vcp, vcp->vc_laddr, p)); + ithrow(SMB_TRAN_BIND(vcp, vcp->vc_laddr, td)); } SMBIODEBUG("tbind\n"); - ithrow(SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, p)); + ithrow(SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, td)); SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags); iod->iod_state = SMBIOD_ST_TRANACTIVE; SMBIODEBUG("tconnect\n"); @@ -209,7 +209,7 @@ smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp) static int smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) { - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; struct smb_vc *vcp = iod->iod_vc; struct smb_share *ssp = rqp->sr_share; struct mbuf *m; @@ -249,7 +249,7 @@ smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) SMBSDEBUG("M:%04x, P:%04x, U:%04x, T:%04x\n", rqp->sr_mid, 0, 0, 0); m_dumpm(rqp->sr_rq.mb_top); m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAIT); - error = rqp->sr_lerror = m ? SMB_TRAN_SEND(vcp, m, p) : ENOBUFS; + error = rqp->sr_lerror = m ? SMB_TRAN_SEND(vcp, m, td) : ENOBUFS; if (error == 0) { getnanotime(&rqp->sr_timesent); iod->iod_lastrqsent = rqp->sr_timesent; @@ -278,7 +278,7 @@ static int smb_iod_recvall(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; struct smb_rq *rqp; struct mbuf *m; u_char *hp; @@ -295,7 +295,7 @@ smb_iod_recvall(struct smbiod *iod) } for (;;) { m = NULL; - error = SMB_TRAN_RECV(vcp, &m, p); + error = SMB_TRAN_RECV(vcp, &m, td); if (error == EWOULDBLOCK) break; if (SMB_TRAN_FATAL(vcp, error)) { @@ -356,7 +356,7 @@ smb_iod_recvall(struct smbiod *iod) */ SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { - if (smb_proc_intr(rqp->sr_cred->scr_p)) { + if (smb_proc_intr(rqp->sr_cred->scr_td)) { smb_iod_rqprocessed(rqp, EINTR); } } @@ -400,7 +400,7 @@ smb_iod_addrq(struct smb_rq *rqp) int error; SMBIODEBUG("\n"); - if (rqp->sr_cred->scr_p == iod->iod_p) { + if (rqp->sr_cred->scr_td == iod->iod_td) { rqp->sr_flags |= SMBR_INTERNAL; SMB_IOD_RQLOCK(iod); TAILQ_INSERT_HEAD(&iod->iod_rqlist, rqp, sr_link); @@ -640,7 +640,7 @@ smb_iod_thread(void *arg) { struct smbiod *iod = arg; - smb_makescred(&iod->iod_scred, iod->iod_p, NULL); + smb_makescred(&iod->iod_scred, iod->iod_td, NULL); while ((iod->iod_flags & SMBIOD_SHUTDOWN) == 0) { smb_iod_main(iod); SMBIODEBUG("going to sleep for %d ticks\n", iod->iod_sleeptimo); @@ -655,6 +655,7 @@ int smb_iod_create(struct smb_vc *vcp) { struct smbiod *iod; + struct proc *newp = NULL; int error; iod = smb_zmalloc(sizeof(*iod), M_SMBIOD, M_WAITOK); @@ -669,13 +670,14 @@ smb_iod_create(struct smb_vc *vcp) TAILQ_INIT(&iod->iod_rqlist); smb_sl_init(&iod->iod_evlock, "90evl"); STAILQ_INIT(&iod->iod_evlist); - error = kthread_create_compat(smb_iod_thread, iod, &iod->iod_p, + error = kthread_create_compat(smb_iod_thread, iod, &newp, RFNOWAIT, "smbiod%d", iod->iod_id); if (error) { SMBERROR("can't start smbiod: %d", error); free(iod, M_SMBIOD); return error; } + iod->iod_td = newp->p_thread; return 0; } diff --git a/sys/netproto/smb/smb_rq.c b/sys/netproto/smb/smb_rq.c index ebc0715196..66444a490d 100644 --- a/sys/netproto/smb/smb_rq.c +++ b/sys/netproto/smb/smb_rq.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_rq.c,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ #include #include @@ -181,7 +181,7 @@ smb_rq_enqueue(struct smb_rq *rqp) if (ssp->ss_flags & SMBS_RECONNECTING) { msleep(&ssp->ss_vcgenid, SMBS_ST_LOCKPTR(ssp), PWAIT | PDROP, "90trcn", hz); - if (smb_proc_intr(rqp->sr_cred->scr_p)) + if (smb_proc_intr(rqp->sr_cred->scr_td)) return EINTR; continue; } @@ -245,11 +245,11 @@ smb_rq_bend(struct smb_rq *rqp) int smb_rq_intr(struct smb_rq *rqp) { - struct proc *p = rqp->sr_cred->scr_p; + struct thread *td = rqp->sr_cred->scr_td; if (rqp->sr_flags & SMBR_INTR) return EINTR; - return smb_proc_intr(p); + return smb_proc_intr(td); } int diff --git a/sys/netproto/smb/smb_smb.c b/sys/netproto/smb/smb_smb.c index b31ca764fe..9b23073e5a 100644 --- a/sys/netproto/smb/smb_smb.c +++ b/sys/netproto/smb/smb_smb.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_smb.c,v 1.1.2.3 2002/12/14 14:44:19 fjoe Exp $ - * $DragonFly: src/sys/netproto/smb/smb_smb.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_smb.c,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ /* * various SMB requests. Most of the routines merely packs data into mbufs. @@ -75,7 +75,7 @@ static struct smb_dialect smb_dialects[] = { static int smb_smb_nomux(struct smb_vc *vcp, struct smb_cred *scred, const char *name) { - if (scred->scr_p == vcp->vc_iod->iod_p) + if (scred->scr_td == vcp->vc_iod->iod_td) return 0; SMBERROR("wrong function called(%s)\n", name); return EINVAL; diff --git a/sys/netproto/smb/smb_subr.c b/sys/netproto/smb/smb_subr.c index 58b7cb0a4f..a420ef6e31 100644 --- a/sys/netproto/smb/smb_subr.c +++ b/sys/netproto/smb/smb_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.c,v 1.1.2.2 2001/09/03 08:55:11 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.4 2003/06/23 17:55:47 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.5 2003/06/25 03:56:06 dillon Exp $ */ #include #include @@ -63,23 +63,23 @@ MALLOC_DEFINE(M_SMBTEMP, "SMBTEMP", "Temp netsmb data"); smb_unichar smb_unieol = 0; void -smb_makescred(struct smb_cred *scred, struct proc *p, struct ucred *cred) +smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred) { - if (p) { - scred->scr_p = p; - scred->scr_cred = cred ? cred : p->p_ucred; + scred->scr_td = td; + if (td && td->td_proc) { + scred->scr_cred = cred ? cred : td->td_proc->p_ucred; } else { - scred->scr_p = NULL; scred->scr_cred = cred ? cred : NULL; } } int -smb_proc_intr(struct proc *p) +smb_proc_intr(struct thread *td) { sigset_t tmpset; + struct proc *p; - if (p == NULL) + if ((p = td->td_proc) == NULL) return 0; tmpset = p->p_siglist; SIGSETNAND(tmpset, p->p_sigmask); diff --git a/sys/netproto/smb/smb_subr.h b/sys/netproto/smb/smb_subr.h index 30d135898c..115c3a0447 100644 --- a/sys/netproto/smb/smb_subr.h +++ b/sys/netproto/smb/smb_subr.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.h,v 1.1.2.1 2001/05/22 08:32:34 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.h,v 1.3 2003/06/23 17:55:47 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.h,v 1.4 2003/06/25 03:56:06 dillon Exp $ */ #ifndef _NETSMB_SMB_SUBR_H_ #define _NETSMB_SMB_SUBR_H_ @@ -75,7 +75,7 @@ void m_dumpm(struct mbuf *m); SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ SIGISMEMBER(set, SIGQUIT)) -#define smb_suser(cred) suser_xxx(cred, 0) +#define smb_suser(cred) suser_cred(cred, 0) #include @@ -131,7 +131,7 @@ typedef smb_unichar *smb_uniptr; * Crediantials of user/process being processing in the connection procedures */ struct smb_cred { - struct proc * scr_p; + struct thread * scr_td; struct ucred * scr_cred; }; @@ -139,13 +139,14 @@ extern smb_unichar smb_unieol; struct mbchain; struct proc; +struct thread; struct simplelock; struct smb_vc; struct smb_rq; -void smb_makescred(struct smb_cred *scred, struct proc *p, struct ucred *cred); -int smb_proc_intr(struct proc *); +void smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred); +int smb_proc_intr(struct thread *td); char *smb_strdup(const char *s); void *smb_memdup(const void *umem, int len); char *smb_strdupin(char *s, int maxlen); diff --git a/sys/netproto/smb/smb_tran.h b/sys/netproto/smb/smb_tran.h index fe2c28c4cf..0597d4cacf 100644 --- a/sys/netproto/smb/smb_tran.h +++ b/sys/netproto/smb/smb_tran.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_tran.h,v 1.1.2.1 2001/05/22 08:32:34 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_tran.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_tran.h,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ #ifndef _NETSMB_SMB_TRAN_H_ @@ -55,20 +55,20 @@ struct smb_tran_ops; struct smb_tran_desc { sa_family_t tr_type; - int (*tr_create)(struct smb_vc *vcp, struct proc *p); - int (*tr_done)(struct smb_vc *vcp, struct proc *p); - int (*tr_bind)(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p); - int (*tr_connect)(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p); - int (*tr_disconnect)(struct smb_vc *vcp, struct proc *p); - int (*tr_send)(struct smb_vc *vcp, struct mbuf *m0, struct proc *p); - int (*tr_recv)(struct smb_vc *vcp, struct mbuf **mpp, struct proc *p); + int (*tr_create)(struct smb_vc *vcp, struct thread *td); + int (*tr_done)(struct smb_vc *vcp, struct thread *td); + int (*tr_bind)(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td); + int (*tr_connect)(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td); + int (*tr_disconnect)(struct smb_vc *vcp, struct thread *td); + int (*tr_send)(struct smb_vc *vcp, struct mbuf *m0, struct thread *td); + int (*tr_recv)(struct smb_vc *vcp, struct mbuf **mpp, struct thread *td); void (*tr_timo)(struct smb_vc *vcp); void (*tr_intr)(struct smb_vc *vcp); int (*tr_getparam)(struct smb_vc *vcp, int param, void *data); int (*tr_setparam)(struct smb_vc *vcp, int param, void *data); int (*tr_fatal)(struct smb_vc *vcp, int error); #ifdef notyet - int (*tr_poll)(struct smb_vc *vcp, struct proc *p); + int (*tr_poll)(struct smb_vc *vcp, struct thread *td); int (*tr_cmpaddr)(void *addr1, void *addr2); #endif LIST_ENTRY(smb_tran_desc) tr_link; diff --git a/sys/netproto/smb/smb_trantcp.c b/sys/netproto/smb/smb_trantcp.c index 845104580b..306a4bfad3 100644 --- a/sys/netproto/smb/smb_trantcp.c +++ b/sys/netproto/smb/smb_trantcp.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_trantcp.c,v 1.3.2.1 2001/05/22 08:32:34 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_trantcp.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_trantcp.c,v 1.3 2003/06/25 03:56:06 dillon Exp $ */ #include #include @@ -71,11 +71,11 @@ SYSCTL_INT(_net_smb, OID_AUTO, tcpsndbuf, CTLFLAG_RW, &smb_tcpsndbuf, 0, ""); SYSCTL_INT(_net_smb, OID_AUTO, tcprcvbuf, CTLFLAG_RW, &smb_tcprcvbuf, 0, ""); #define nb_sosend(so,m,flags,p) (so)->so_proto->pr_usrreqs->pru_sosend( \ - so, NULL, 0, m, 0, flags, p) + so, NULL, 0, m, 0, flags, td) static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, - u_int8_t *rpcodep, struct proc *p); -static int smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p); + u_int8_t *rpcodep, struct thread *td); +static int smb_nbst_disconnect(struct smb_vc *vcp, struct thread *td); static int nb_setsockopt_int(struct socket *so, int level, int name, int val) @@ -91,15 +91,16 @@ nb_setsockopt_int(struct socket *so, int level, int name, int val) } static __inline int -nb_poll(struct nbpcb *nbp, int events, struct proc *p) +nb_poll(struct nbpcb *nbp, int events, struct thread *td) { return nbp->nbp_tso->so_proto->pr_usrreqs->pru_sopoll(nbp->nbp_tso, - events, NULL, p); + events, NULL, td); } static int -nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) +nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct thread *td) { + struct proc *p = td->td_proc; struct timeval atv, rtv, ttv; int s, timo, error; @@ -113,9 +114,10 @@ nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) timevaladd(&atv, &rtv); } timo = 0; + KKASSERT(p); retry: p->p_flag |= P_SELECT; - error = nb_poll(nbp, events, p); + error = nb_poll(nbp, events, td); if (error) { error = 0; goto done; @@ -144,7 +146,7 @@ done: } static int -nb_intr(struct nbpcb *nbp, struct proc *p) +nb_intr(struct nbpcb *nbp, struct thread *td) { return 0; } @@ -191,12 +193,12 @@ nb_put_name(struct mbchain *mbp, struct sockaddr_nb *snb) } static int -nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) +nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct thread *td) { struct socket *so; int error, s; - error = socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP, p); + error = socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP, td); if (error) return error; nbp->nbp_tso = so; @@ -212,14 +214,14 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) nb_setsockopt_int(so, IPPROTO_TCP, TCP_NODELAY, 1); so->so_rcv.sb_flags &= ~SB_NOINTR; so->so_snd.sb_flags &= ~SB_NOINTR; - error = soconnect(so, (struct sockaddr*)to, p); + error = soconnect(so, (struct sockaddr*)to, td); if (error) goto bad; s = splnet(); while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { tsleep(&so->so_timeo, PSOCK, "nbcon", 2 * hz); if ((so->so_state & SS_ISCONNECTING) && so->so_error == 0 && - (error = nb_intr(nbp, p)) != 0) { + (error = nb_intr(nbp, td)) != 0) { so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -234,12 +236,12 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) splx(s); return 0; bad: - smb_nbst_disconnect(nbp->nbp_vc, p); + smb_nbst_disconnect(nbp->nbp_vc, td); return error; } static int -nbssn_rq_request(struct nbpcb *nbp, struct proc *p) +nbssn_rq_request(struct nbpcb *nbp, struct thread *td) { struct mbchain mb, *mbp = &mb; struct mdchain md, *mdp = &md; @@ -257,7 +259,7 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) nb_put_name(mbp, nbp->nbp_paddr); nb_put_name(mbp, nbp->nbp_laddr); nb_sethdr(mbp->mb_top, NB_SSN_REQUEST, mb_fixhdr(mbp) - 4); - error = nb_sosend(nbp->nbp_tso, mbp->mb_top, 0, p); + error = nb_sosend(nbp->nbp_tso, mbp->mb_top, 0, td); if (!error) { nbp->nbp_state = NBST_RQSENT; } @@ -266,14 +268,14 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) if (error) return error; TIMESPEC_TO_TIMEVAL(&tv, &nbp->nbp_timo); - error = nbssn_rselect(nbp, &tv, POLLIN, p); + error = nbssn_rselect(nbp, &tv, POLLIN, td); if (error == EWOULDBLOCK) { /* Timeout */ NBDEBUG("initial request timeout\n"); return ETIMEDOUT; } if (error) /* restart or interrupt */ return error; - error = nbssn_recv(nbp, &m0, &rplen, &rpcode, p); + error = nbssn_recv(nbp, &m0, &rplen, &rpcode, td); if (error) { NBDEBUG("recv() error %d\n", error); return error; @@ -302,12 +304,12 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) md_get_uint16(mdp, &port); sin.sin_port = port; nbp->nbp_state = NBST_RETARGET; - smb_nbst_disconnect(nbp->nbp_vc, p); - error = nb_connect_in(nbp, &sin, p); + smb_nbst_disconnect(nbp->nbp_vc, td); + error = nb_connect_in(nbp, &sin, td); if (!error) - error = nbssn_rq_request(nbp, p); + error = nbssn_rq_request(nbp, td); if (error) { - smb_nbst_disconnect(nbp->nbp_vc, p); + smb_nbst_disconnect(nbp->nbp_vc, td); break; } } while(0); @@ -318,7 +320,7 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) static int nbssn_recvhdr(struct nbpcb *nbp, int *lenp, - u_int8_t *rpcodep, int flags, struct proc *p) + u_int8_t *rpcodep, int flags, struct thread *td) { struct socket *so = nbp->nbp_tso; struct uio auio; @@ -334,7 +336,7 @@ nbssn_recvhdr(struct nbpcb *nbp, int *lenp, auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(len); - auio.uio_procp = p; + auio.uio_td = td; error = so->so_proto->pr_usrreqs->pru_soreceive (so, (struct sockaddr **)NULL, &auio, (struct mbuf **)NULL, (struct mbuf **)NULL, &flags); @@ -357,7 +359,7 @@ nbssn_recvhdr(struct nbpcb *nbp, int *lenp, static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, - u_int8_t *rpcodep, struct proc *p) + u_int8_t *rpcodep, struct thread *td) { struct socket *so = nbp->nbp_tso; struct uio auio; @@ -373,7 +375,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, *mpp = NULL; for(;;) { m = NULL; - error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, p); + error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, td); if (so->so_state & (SS_ISDISCONNECTING | SS_ISDISCONNECTED | SS_CANTRCVMORE)) { nbp->nbp_state = NBST_CLOSED; @@ -388,7 +390,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, continue; bzero(&auio, sizeof(auio)); auio.uio_resid = len; - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = MSG_WAITALL; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -428,7 +430,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, * SMB transport interface */ static int -smb_nbst_create(struct smb_vc *vcp, struct proc *p) +smb_nbst_create(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp; @@ -444,13 +446,13 @@ smb_nbst_create(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_done(struct smb_vc *vcp, struct proc *p) +smb_nbst_done(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; if (nbp == NULL) return ENOTCONN; - smb_nbst_disconnect(vcp, p); + smb_nbst_disconnect(vcp, td); if (nbp->nbp_laddr) free(nbp->nbp_laddr, M_SONAME); if (nbp->nbp_paddr) @@ -460,7 +462,7 @@ smb_nbst_done(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) +smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct sockaddr_nb *snb; @@ -493,7 +495,7 @@ smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) } static int -smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) +smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct sockaddr_in sin; @@ -519,7 +521,7 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) nbp->nbp_paddr = snb; sin = snb->snb_addrin; getnanotime(&ts1); - error = nb_connect_in(nbp, &sin, p); + error = nb_connect_in(nbp, &sin, td); if (error) return error; getnanotime(&ts2); @@ -530,14 +532,14 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) timespecadd(&nbp->nbp_timo, &ts2); timespecadd(&nbp->nbp_timo, &ts2); timespecadd(&nbp->nbp_timo, &ts2); /* * 4 */ - error = nbssn_rq_request(nbp, p); + error = nbssn_rq_request(nbp, td); if (error) - smb_nbst_disconnect(vcp, p); + smb_nbst_disconnect(vcp, td); return error; } static int -smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p) +smb_nbst_disconnect(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct socket *so; @@ -557,7 +559,7 @@ smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct proc *p) +smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; int error; @@ -570,7 +572,7 @@ smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct proc *p) if (m0 == NULL) return ENOBUFS; nb_sethdr(m0, NB_SSN_MESSAGE, m_fixhdr(m0) - 4); - error = nb_sosend(nbp->nbp_tso, m0, 0, p); + error = nb_sosend(nbp->nbp_tso, m0, 0, td); return error; abort: if (m0) @@ -580,14 +582,14 @@ abort: static int -smb_nbst_recv(struct smb_vc *vcp, struct mbuf **mpp, struct proc *p) +smb_nbst_recv(struct smb_vc *vcp, struct mbuf **mpp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; u_int8_t rpcode; int error, rplen; nbp->nbp_flags |= NBF_RECVLOCK; - error = nbssn_recv(nbp, mpp, &rplen, &rpcode, p); + error = nbssn_recv(nbp, mpp, &rplen, &rpcode, td); nbp->nbp_flags &= ~NBF_RECVLOCK; return error; } diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index badac03684..f319a36aa3 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ -/* $DragonFly: src/sys/opencrypto/cryptodev.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ */ +/* $DragonFly: src/sys/opencrypto/cryptodev.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ /* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */ /* @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include @@ -80,12 +82,12 @@ struct fcrypt { }; static int cryptof_rw(struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *); -static int cryptof_ioctl(struct file *, u_long, caddr_t, struct proc *); -static int cryptof_poll(struct file *, int, struct ucred *, struct proc *); + struct ucred *cred, int flags, struct thread *); +static int cryptof_ioctl(struct file *, u_long, caddr_t, struct thread *); +static int cryptof_poll(struct file *, int, struct ucred *, struct thread *); static int cryptof_kqfilter(struct file *, struct knote *); -static int cryptof_stat(struct file *, struct stat *, struct proc *); -static int cryptof_close(struct file *, struct proc *); +static int cryptof_stat(struct file *, struct stat *, struct thread *); +static int cryptof_close(struct file *, struct thread *); static struct fileops cryptofops = { cryptof_rw, @@ -106,7 +108,7 @@ static struct csession *csecreate(struct fcrypt *, u_int64_t, caddr_t, static int csefree(struct csession *); static int cryptodev_op(struct csession *, struct crypt_op *, - struct proc *p); + struct thread *td); static int cryptodev_key(struct crypt_kop *); static int @@ -115,7 +117,7 @@ cryptof_rw( struct uio *uio, struct ucred *active_cred, int flags, - struct proc *p) + struct thread *td) { return (EIO); @@ -127,7 +129,7 @@ cryptof_ioctl( struct file *fp, u_long cmd, caddr_t data, - struct proc *p) + struct thread *td) { struct cryptoini cria, crie; struct fcrypt *fcr = (struct fcrypt *)fp->f_data; @@ -285,7 +287,7 @@ bail: cse = csefind(fcr, cop->ses); if (cse == NULL) return (EINVAL); - error = cryptodev_op(cse, cop, p); + error = cryptodev_op(cse, cop, td); break; case CIOCKEY: error = cryptodev_key((struct crypt_kop *)data); @@ -306,7 +308,7 @@ static int cryptodev_op( struct csession *cse, struct crypt_op *cop, - struct proc *p) + struct thread *td) { struct cryptop *crp = NULL; struct cryptodesc *crde = NULL, *crda = NULL; @@ -323,7 +325,7 @@ cryptodev_op( cse->uio.uio_resid = 0; cse->uio.uio_segflg = UIO_SYSSPACE; cse->uio.uio_rw = UIO_WRITE; - cse->uio.uio_procp = p; + cse->uio.uio_td = td; cse->uio.uio_iov = cse->iovec; bzero(&cse->iovec, sizeof(cse->iovec)); cse->uio.uio_iov[0].iov_len = cop->len; @@ -572,7 +574,7 @@ cryptof_poll( struct file *fp, int events, struct ucred *active_cred, - struct proc *p) + struct thread *td) { return (0); @@ -591,7 +593,7 @@ static int cryptof_stat( struct file *fp, struct stat *sb, - struct proc *p) + struct thread *td) { return (EOPNOTSUPP); @@ -599,7 +601,7 @@ cryptof_stat( /* ARGSUSED */ static int -cryptof_close(struct file *fp, struct proc *p) +cryptof_close(struct file *fp, struct thread *td) { struct fcrypt *fcr = (struct fcrypt *)fp->f_data; struct csession *cse; @@ -685,7 +687,7 @@ csefree(struct csession *cse) } static int -cryptoopen(dev_t dev, int oflags, int devtype, struct proc *p) +cryptoopen(dev_t dev, int oflags, int devtype, struct thread *td) { if (crypto_usercrypto == 0) return (ENXIO); @@ -705,7 +707,7 @@ cryptowrite(dev_t dev, struct uio *uio, int ioflag) } static int -cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct file *f; struct fcrypt *fcr; @@ -717,7 +719,8 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) TAILQ_INIT(&fcr->csessions); fcr->sesn = 0; - error = falloc(p, &f, &fd); + KKASSERT(td->td_proc); + error = falloc(td->td_proc, &f, &fd); if (error) { FREE(fcr, M_XDATA); @@ -729,7 +732,7 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) f->f_ops = &cryptofops; f->f_data = (caddr_t) fcr; *(u_int32_t *)data = fd; - fdrop(f, p); + fdrop(f, td); break; default: error = EINVAL; diff --git a/sys/platform/pc32/gnu/isa/dgb.c b/sys/platform/pc32/gnu/isa/dgb.c index 3c084fb120..6e3ec0ed9b 100644 --- a/sys/platform/pc32/gnu/isa/dgb.c +++ b/sys/platform/pc32/gnu/isa/dgb.c @@ -1,6 +1,6 @@ /*- * dgb.c $FreeBSD: src/sys/gnu/i386/isa/dgb.c,v 1.56.2.1 2001/02/26 04:23:09 jlemon Exp $ - * dgb.c $DragonFly: src/sys/platform/pc32/gnu/isa/dgb.c,v 1.2 2003/06/17 04:28:34 dillon Exp $ + * dgb.c $DragonFly: src/sys/platform/pc32/gnu/isa/dgb.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ * * Digiboard driver. * @@ -924,11 +924,7 @@ load_fep: /* ARGSUSED */ static int -dgbopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +dgbopen(dev_t dev, int flag, int mode, struct thread *td) { struct dgb_softc *sc; struct tty *tp; @@ -1013,8 +1009,7 @@ open_top: goto open_top; } } - if (tp->t_state & TS_XCLUDE && - suser(p)) { + if (tp->t_state & TS_XCLUDE && suser(td)) { error = EBUSY; goto out; } @@ -1104,17 +1099,13 @@ out: /*ARGSUSED*/ static int -dgbclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; +dgbclose(dev_t dev, int flag, int mode, struct thread *td) { - int mynor; - struct tty *tp; + struct tty *tp; int unit, pnum; struct dgb_softc *sc; struct dgb_p *port; + int mynor; int s; int i; @@ -1464,12 +1455,7 @@ dgbpoll(unit_c) } static int -dgbioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +dgbioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct dgb_softc *sc; int unit, pnum; @@ -1512,7 +1498,7 @@ dgbioctl(dev, cmd, data, flag, p) } switch (cmd) { case TIOCSETA: - error = suser(p); + error = suser(td); if (error != 0) return (error); *ct = *(struct termios *)data; @@ -1734,7 +1720,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); if (error != 0) { splx(s); return (error); diff --git a/sys/platform/pc32/i386/busdma_machdep.c b/sys/platform/pc32/i386/busdma_machdep.c index ad6c1a3228..16fa8ad6e9 100644 --- a/sys/platform/pc32/i386/busdma_machdep.c +++ b/sys/platform/pc32/i386/busdma_machdep.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.16.2.2 2003/01/23 00:55:27 scottl Exp $ - * $DragonFly: src/sys/platform/pc32/i386/busdma_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/busdma_machdep.c,v 1.3 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -499,7 +499,7 @@ static int _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t segs[], void *buf, bus_size_t buflen, - struct proc *p, + struct thread *td, int flags, vm_offset_t *lastaddrp, int *segp, @@ -511,8 +511,8 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, int seg; pmap_t pmap; - if (p != NULL) - pmap = vmspace_pmap(p->p_vmspace); + if (td->td_proc != NULL) + pmap = vmspace_pmap(td->td_proc->p_vmspace); else pmap = NULL; @@ -647,7 +647,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, int nsegs, error, first, i; bus_size_t resid; struct iovec *iov; - struct proc *p = NULL; + struct thread *td = NULL; KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, ("bus_dmamap_load_uio: No support for bounce pages!")); @@ -656,8 +656,8 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, iov = uio->uio_iov; if (uio->uio_segflg == UIO_USERSPACE) { - p = uio->uio_procp; - KASSERT(p != NULL, + td = uio->uio_td; + KASSERT(td != NULL && td->td_proc != NULL, ("bus_dmamap_load_uio: USERSPACE but no proc")); } @@ -676,7 +676,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_buffer(dmat, dm_segments, addr, minlen, - p, flags, &lastaddr, &nsegs, first); + td, flags, &lastaddr, &nsegs, first); first = 0; resid -= minlen; diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 18922042e9..b69c5d6984 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.11 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.12 2003/06/25 03:55:53 dillon Exp $ */ #include "apm.h" @@ -2433,7 +2433,7 @@ set_dbregs(p, dbregs) * from within kernel mode? */ - if (suser_xxx(p->p_ucred, 0) != 0) { + if (suser_cred(p->p_ucred, 0) != 0) { if (dbregs->dr7 & 0x3) { /* dr0 is enabled */ if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) diff --git a/sys/platform/pc32/i386/mem.c b/sys/platform/pc32/i386/mem.c index 755311440c..9c518cca08 100644 --- a/sys/platform/pc32/i386/mem.c +++ b/sys/platform/pc32/i386/mem.c @@ -39,7 +39,7 @@ * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/i386/mem.c,v 1.79.2.9 2003/01/04 22:58:01 njl Exp $ - * $DragonFly: src/sys/platform/pc32/i386/Attic/mem.c,v 1.3 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/Attic/mem.c,v 1.4 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -135,7 +135,7 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td) return (EPERM); break; case 14: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (securelevel > 0) @@ -440,7 +440,6 @@ mem_range_AP_init(void) static int random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - struct proc *p = td->td_proc; static intrmask_t interrupt_allowed; intrmask_t interrupt_mask; int error, intr; @@ -471,7 +470,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) case FIONBIO: break; case MEM_SETIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -488,7 +487,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_CLEARIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); if (intr < 0 || intr >= 16) @@ -502,7 +501,7 @@ random_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) enable_intr(); break; case MEM_RETURNIRQ: - error = suser_xxx(p->p_ucred, 0); + error = suser(td); if (error != 0) return (error); *(u_int16_t *)data = interrupt_allowed; diff --git a/sys/platform/pc32/i386/sys_machdep.c b/sys/platform/pc32/i386/sys_machdep.c index 21088fc56a..bf3db2374f 100644 --- a/sys/platform/pc32/i386/sys_machdep.c +++ b/sys/platform/pc32/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.4 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ * */ @@ -163,9 +163,7 @@ i386_extend_pcb(struct proc *p) } static int -i386_set_ioperm(p, args) - struct proc *p; - char *args; +i386_set_ioperm(struct proc *p, char *args) { int i, error; struct i386_ioperm_args ua; @@ -174,7 +172,7 @@ i386_set_ioperm(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0) return (error); - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser_cred(p->p_ucred, 0)) != 0) return (error); if (securelevel > 0) return (EPERM); diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index 0438b7ef55..bdb65a81ca 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.7 2003/06/23 23:36:05 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.8 2003/06/25 03:55:53 dillon Exp $ */ /* @@ -1071,10 +1071,11 @@ void syscall2(frame) struct trapframe frame; { + struct thread *td = curthread; + struct proc *p = td->td_proc; caddr_t params; int i; struct sysent *callp; - struct proc *p = curproc; register_t orig_tf_eflags; u_quad_t sticks; int error; @@ -1150,7 +1151,7 @@ syscall2(frame) get_mplock(); have_mplock = 1; #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) + if (KTRPOINT(td, KTR_SYSCALL)) ktrsyscall(p->p_tracep, code, narg, args); #endif goto bad; @@ -1167,7 +1168,7 @@ syscall2(frame) } #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) { + if (KTRPOINT(td, KTR_SYSCALL)) { if (have_mplock == 0) { get_mplock(); have_mplock = 1; @@ -1239,7 +1240,7 @@ bad: have_mplock = userret(p, &frame, sticks, have_mplock); #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) { + if (KTRPOINT(td, KTR_SYSRET)) { if (have_mplock == 0) { get_mplock(); have_mplock = 1; @@ -1278,7 +1279,7 @@ fork_return(p, frame) userret(p, &frame, 0, 1); #ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) + if (KTRPOINT(p->p_thread, KTR_SYSRET)) ktrsysret(p->p_tracep, SYS_fork, 0, 0); #endif } diff --git a/sys/platform/pc32/i386/vm86.c b/sys/platform/pc32/i386/vm86.c index 8a6564d72f..423da40241 100644 --- a/sys/platform/pc32/i386/vm86.c +++ b/sys/platform/pc32/i386/vm86.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86.c,v 1.31.2.2 2001/10/05 06:18:55 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm86.c,v 1.4 2003/06/23 17:55:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm86.c,v 1.5 2003/06/25 03:55:53 dillon Exp $ */ #include @@ -645,9 +645,7 @@ vm86_getptr(vmc, kva, sel, off) } int -vm86_sysarch(p, args) - struct proc *p; - char *args; +vm86_sysarch(struct proc *p, char *args) { int error = 0; struct i386_vm86_args ua; @@ -705,7 +703,7 @@ vm86_sysarch(p, args) case VM86_INTCALL: { struct vm86_intcall_args sa; - if ((error = suser_xxx(p->p_ucred, 0))) + if ((error = suser_cred(p->p_ucred, 0))) return (error); if ((error = copyin(ua.sub_args, &sa, sizeof(sa)))) return (error); diff --git a/sys/platform/pc32/i386/vm_machdep.c b/sys/platform/pc32/i386/vm_machdep.c index 5a244de17f..4f077410fa 100644 --- a/sys/platform/pc32/i386/vm_machdep.c +++ b/sys/platform/pc32/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.9 2003/06/22 04:30:39 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.10 2003/06/25 03:55:53 dillon Exp $ */ #include "npx.h" @@ -308,14 +308,13 @@ 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; - struct vnode *vp; - struct ucred *cred; +cpu_coredump(struct thread *td, struct vnode *vp, struct ucred *cred) { + struct proc *p = td->td_proc; int error; caddr_t tempuser; + KKASSERT(p); tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK); if (!tempuser) return EINVAL; @@ -328,7 +327,7 @@ cpu_coredump(p, vp, cred) bcopy(p->p_thread->td_pcb, tempuser + ((char *)p->p_thread->td_pcb - (char *)p->p_addr), sizeof(struct pcb)); error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td); free(tempuser, M_TEMP); diff --git a/sys/sys/buf2.h b/sys/sys/buf2.h index 87fd84cd30..267828695e 100644 --- a/sys/sys/buf2.h +++ b/sys/sys/buf2.h @@ -37,7 +37,7 @@ * * @(#)buf.h 8.9 (Berkeley) 3/30/95 * $FreeBSD: src/sys/sys/buf.h,v 1.88.2.10 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/sys/buf2.h,v 1.1 2003/06/19 01:55:07 dillon Exp $ + * $DragonFly: src/sys/sys/buf2.h,v 1.2 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_BUF2_H_ @@ -67,7 +67,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; not necessary */ - ret = lockmgr(&(bp)->b_lock, locktype, &buftimelock, curproc); + ret = lockmgr(&(bp)->b_lock, locktype, &buftimelock, curthread); splx(s); return ret; } @@ -86,7 +86,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; } @@ -101,7 +101,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); } @@ -121,11 +121,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 != NULL && bp->b_lock.lk_lockholder == p->p_pid) - p->p_locks--; - bp->b_lock.lk_lockholder = LK_KERNPROC; + if (bp->b_lock.lk_lockholder == td) + td->td_locks--; + bp->b_lock.lk_lockholder = LK_KERNTHREAD; } /* * Find out the number of references to a lock. diff --git a/sys/sys/event.h b/sys/sys/event.h index 0698e4be03..65cd1ff1e6 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/event.h,v 1.5.2.6 2003/02/09 15:28:13 nectar Exp $ - * $DragonFly: src/sys/sys/event.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/event.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_EVENT_H_ @@ -164,12 +164,13 @@ struct knote { }; struct proc; +struct thread; extern void knote(struct klist *list, long hint); -extern void knote_remove(struct proc *p, struct klist *list); +extern void knote_remove(struct thread *td, struct klist *list); extern void knote_fdclose(struct proc *p, int fd); extern int kqueue_register(struct kqueue *kq, - struct kevent *kev, struct proc *p); + struct kevent *kev, struct thread *td); #else /* !_KERNEL */ diff --git a/sys/sys/file.h b/sys/sys/file.h index 9f0188f677..72749ef983 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -32,7 +32,7 @@ * * @(#)file.h 8.3 (Berkeley) 1/9/95 * $FreeBSD: src/sys/sys/file.h,v 1.22.2.7 2002/11/21 23:39:24 sam Exp $ - * $DragonFly: src/sys/sys/file.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/file.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_FILE_H_ @@ -48,6 +48,7 @@ struct stat; struct proc; +struct thread; struct uio; struct knote; @@ -70,20 +71,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 @@ -102,6 +103,8 @@ struct file { MALLOC_DECLARE(M_FILE); #endif +extern int fdrop __P((struct file *fp, struct thread *td)); + LIST_HEAD(filelist, file); extern struct filelist filehead; /* head of list of open files */ extern struct fileops vnops; @@ -110,124 +113,6 @@ extern int maxfiles; /* kernel limit on number of open files */ 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)); - -static __inline void -fhold(fp) - struct file *fp; -{ - - fp->f_count++; -} - -static __inline int fo_read __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); -static __inline int fo_write __P((struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct proc *p)); -static __inline int fo_ioctl __P((struct file *fp, u_long com, caddr_t data, - struct proc *p)); -static __inline int fo_poll __P((struct file *fp, int events, - struct ucred *cred, struct proc *p)); -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)); -static __inline int fo_kqfilter __P((struct file *fp, struct knote *kn)); - -static __inline int -fo_read(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; -{ - int error; - - fhold(fp); - error = (*fp->f_ops->fo_read)(fp, uio, cred, flags, p); - fdrop(fp, p); - return (error); -} - -static __inline int -fo_write(fp, uio, cred, flags, p) - struct file *fp; - struct uio *uio; - struct ucred *cred; - struct proc *p; - int flags; -{ - int error; - - fhold(fp); - error = (*fp->f_ops->fo_write)(fp, uio, cred, flags, p); - fdrop(fp, p); - return (error); -} - -static __inline int -fo_ioctl(fp, com, data, p) - struct file *fp; - u_long com; - caddr_t data; - struct proc *p; -{ - int error; - - fhold(fp); - error = (*fp->f_ops->fo_ioctl)(fp, com, data, p); - fdrop(fp, p); - return (error); -} - -static __inline int -fo_poll(fp, events, cred, p) - struct file *fp; - int events; - struct ucred *cred; - struct proc *p; -{ - int error; - - fhold(fp); - error = (*fp->f_ops->fo_poll)(fp, events, cred, p); - fdrop(fp, p); - return (error); -} - -static __inline int -fo_stat(fp, sb, p) - struct file *fp; - struct stat *sb; - struct proc *p; -{ - int error; - - fhold(fp); - error = (*fp->f_ops->fo_stat)(fp, sb, p); - fdrop(fp, p); - return (error); -} - -static __inline int -fo_close(fp, p) - struct file *fp; - struct proc *p; -{ - - return ((*fp->f_ops->fo_close)(fp, p)); -} - -static __inline int -fo_kqfilter(fp, kn) - struct file *fp; - struct knote *kn; -{ - - return ((*fp->f_ops->fo_kqfilter)(fp, kn)); -} - #endif /* _KERNEL */ #endif /* !SYS_FILE_H */ diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 3ab7d83e36..b3db9cd9c3 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -32,7 +32,7 @@ * * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/filedesc.h,v 1.19.2.5 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/filedesc.h,v 1.3 2003/06/23 17:55:50 dillon Exp $ + * $DragonFly: src/sys/sys/filedesc.h,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_FILEDESC_H_ @@ -150,6 +150,10 @@ struct sigio { SLIST_HEAD(sigiolst, sigio); #ifdef _KERNEL + +struct thread; +struct proc; + /* * Kernel global variables and routines. */ @@ -162,10 +166,10 @@ struct filedesc *fdinit __P((struct proc *p)); struct filedesc *fdshare __P((struct proc *p)); struct filedesc *fdcopy __P((struct proc *p)); void fdfree __P((struct proc *p)); -int closef __P((struct file *fp,struct proc *p)); +int closef __P((struct file *fp, struct thread *td)); void fdcloseexec __P((struct proc *p)); int fdcheckstd __P((struct proc *p)); -struct file *holdfp __P((struct filedesc* fdp, int fd, int flag)); +struct file *holdfp __P((struct filedesc *fdp, int fd, int flag)); int getvnode __P((struct filedesc *fdp, int fd, struct file **fpp)); int fdissequential __P((struct file *)); void fdsequential __P((struct file *, int)); diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 40b5c77dd2..e363865ee6 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -32,7 +32,7 @@ * * @(#)ktrace.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/ktrace.h,v 1.19.2.3 2001/01/06 09:58:23 alfred Exp $ - * $DragonFly: src/sys/sys/ktrace.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/ktrace.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_KTRACE_H_ @@ -65,8 +65,8 @@ struct ktr_header { /* * Test for kernel trace point (MP SAFE) */ -#define KTRPOINT(p, type) \ - (((p)->p_traceflag & ((1<<(type))|KTRFAC_ACTIVE)) == (1<<(type))) +#define KTRPOINT(td, type) \ + ((td->td_proc) && (((td)->td_proc->p_traceflag & ((1<<(type))|KTRFAC_ACTIVE)) == (1<<(type)))) /* * ktrace record types diff --git a/sys/sys/lock.h b/sys/sys/lock.h index bb86855919..3bfdda9731 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -36,7 +36,7 @@ * * @(#)lock.h 8.12 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/lock.h,v 1.17.2.3 2001/12/25 01:44:44 dillon Exp $ - * $DragonFly: src/sys/sys/lock.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/lock.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _LOCK_H_ @@ -50,6 +50,8 @@ * upgrading from shared to exclusive, and sleeping until the lock * can be gained. The simple locks are defined in . */ +struct thread; + struct lock { struct simplelock lk_interlock; /* lock on remaining fields */ u_int lk_flags; /* see below */ @@ -59,7 +61,7 @@ struct lock { short lk_prio; /* priority at which to sleep */ char *lk_wmesg; /* resource sleeping (for tsleep) */ int lk_timo; /* maximum sleep time (for tsleep) */ - pid_t lk_lockholder; /* pid of exclusive lock holder */ + struct thread *lk_lockholder; /* thread of excl lock holder */ #ifdef DEBUG_LOCKS const char *lk_filename; const char *lk_lockername; @@ -171,8 +173,8 @@ struct lock { /* * Indicator that no process holds exclusive lock */ -#define LK_KERNPROC ((pid_t) -2) -#define LK_NOPROC ((pid_t) -1) +#define LK_KERNTHREAD ((struct thread *)-2) +#define LK_NOTHREAD ((struct thread *)-1) void dumplockinfo(struct lock *lkp); struct proc; @@ -181,19 +183,19 @@ void lockinit __P((struct lock *, int prio, char *wmesg, int timo, int flags)); #ifdef DEBUG_LOCKS int debuglockmgr __P((struct lock *, u_int flags, - struct simplelock *, struct proc *p, + struct simplelock *, struct thread *p, const char *, const char *, int)); -#define lockmgr(lockp, flags, slockp, proc) \ - debuglockmgr((lockp), (flags), (slockp), (proc), \ +#define lockmgr(lockp, flags, slockp, td) \ + debuglockmgr((lockp), (flags), (slockp), (td), \ "lockmgr", __FILE__, __LINE__) #else int lockmgr __P((struct lock *, u_int flags, - struct simplelock *, struct proc *p)); + struct simplelock *, struct thread *td)); #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 *)); #ifdef SIMPLELOCK_DEBUG diff --git a/sys/sys/mount.h b/sys/sys/mount.h index f3690c91cd..ba3a97c1ac 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -32,7 +32,7 @@ * * @(#)mount.h 8.21 (Berkeley) 5/20/95 * $FreeBSD: src/sys/sys/mount.h,v 1.89.2.7 2003/04/04 20:35:57 tegge Exp $ - * $DragonFly: src/sys/sys/mount.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/mount.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_MOUNT_H_ @@ -51,6 +51,8 @@ #include #endif +struct thread; + typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ /* @@ -328,18 +330,18 @@ struct mbuf; 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, @@ -351,7 +353,7 @@ struct vfsops { int (*vfs_uninit) __P((struct vfsconf *)); int (*vfs_extattrctl) __P((struct mount *mp, int cmd, const char *attrname, caddr_t arg, - struct proc *p)); + struct thread *td)); }; #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ @@ -414,13 +416,13 @@ extern char *mountrootfsname; /* * exported vnode operations */ -int dounmount __P((struct mount *, int, struct proc *)); +int dounmount __P((struct mount *, int, struct thread *)); 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 simplelock *, struct proc *)); +int vfs_busy __P((struct mount *, int, struct simplelock *, struct thread *)); int vfs_export /* process mount export info */ __P((struct mount *, struct netexport *, struct export_args *)); struct netcred *vfs_export_lookup /* lookup host in fs export list */ @@ -432,7 +434,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 *)); void vfs_unmountall __P((void)); int vfs_register __P((struct vfsconf *)); int vfs_unregister __P((struct vfsconf *)); @@ -446,15 +448,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 *p)); +int vfs_stdstart __P((struct mount *mp, int flags, struct thread *p)); +int vfs_stdunmount __P((struct mount *mp, int mntflags, struct thread *p)); 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 *p)); +int vfs_stdstatfs __P((struct mount *mp, struct statfs *sbp, struct thread *p)); int vfs_stdsync __P((struct mount *mp, int waitfor, struct ucred *cred, - struct proc *p)); + struct thread *p)); 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, @@ -463,7 +465,7 @@ int vfs_stdvptofh __P((struct vnode *vp, struct fid *fhp)); int vfs_stdinit __P((struct vfsconf *)); int vfs_stduninit __P((struct vfsconf *)); int vfs_stdextattrctl __P((struct mount *mp, int cmd, const char *attrname, - caddr_t arg, struct proc *p)); + caddr_t arg, struct thread *p)); #else /* !_KERNEL */ diff --git a/sys/sys/namei.h b/sys/sys/namei.h index f584b1b4db..5eb8e992ab 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -32,7 +32,7 @@ * * @(#)namei.h 8.5 (Berkeley) 1/9/95 * $FreeBSD: src/sys/sys/namei.h,v 1.29.2.2 2001/09/30 21:12:54 luigi Exp $ - * $DragonFly: src/sys/sys/namei.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/namei.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_NAMEI_H_ @@ -47,7 +47,7 @@ struct componentname { */ u_long cn_nameiop; /* namei operation */ u_long cn_flags; /* flags to namei */ - struct proc *cn_proc; /* process requesting lookup */ + struct thread *cn_td; /* process requesting lookup */ struct ucred *cn_cred; /* credentials */ /* * Shared between lookup and commit routines. @@ -149,28 +149,23 @@ struct nameidata { * 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 -#if defined(__STDC__) || defined(__cplusplus) NDINIT(struct nameidata *ndp, u_long op, u_long flags, enum uio_seg segflg, const char *namep, - struct proc *p) -#else -NDINIT(ndp, op, flags, segflg, namep, p) - struct nameidata *ndp; - u_long op, flags; - enum uio_seg segflg; - const char *namep; - struct proc *p; -#endif -{ + struct thread *td +) { + struct proc *p = td->td_proc; + + KKASSERT(p != NULL); 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_td = td; + ndp->ni_cnd.cn_cred = p->p_ucred; } #define NDF_NO_DVP_RELE 0x00000001 diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 51ba452cbf..7157e9b308 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.14 2003/06/23 23:36:14 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.15 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_PROC_H_ @@ -250,7 +250,7 @@ struct proc { #define P_INMEM 0x00004 /* Loaded into memory. */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00020 /* Has started profiling. */ -#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ +#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */ #define P_SINTR 0x00080 /* Sleep is interruptible. */ #define P_SUGID 0x00100 /* Had set id privileges since last exec. */ #define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */ @@ -406,9 +406,9 @@ void schedclock __P((struct proc *)); void setrunnable __P((struct proc *)); void setrunqueue __P((struct proc *)); void sleepinit __P((void)); -int suser __P((void)); +int suser __P((struct thread *td)); int suser_proc __P((struct proc *p)); -int suser_xxx __P((struct ucred *cred, int flag)); +int suser_cred __P((struct ucred *cred, int flag)); void remrunqueue __P((struct proc *)); void cpu_heavy_switch __P((struct thread *)); void cpu_lwkt_switch __P((struct thread *)); @@ -422,7 +422,7 @@ int fork1 __P((struct proc *, int, struct proc **)); void start_forked_proc __P((struct proc *, struct proc *)); 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 *)); void setsugid __P((void)); void faultin __P((struct proc *p)); diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 6cfce3ff66..16ba2b095c 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -32,7 +32,7 @@ * * @(#)protosw.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/protosw.h,v 1.28.2.2 2001/07/03 11:02:01 ume Exp $ - * $DragonFly: src/sys/sys/protosw.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/protosw.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_PROTOSW_H_ @@ -40,7 +40,7 @@ /* Forward declare these structures referenced from prototypes below. */ struct mbuf; -struct proc; +struct thread; struct sockaddr; struct socket; struct sockopt; @@ -184,17 +184,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)); @@ -202,7 +202,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 @@ -222,22 +222,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/socketvar.h b/sys/sys/socketvar.h index 65110b82ef..8e7ce42139 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -32,7 +32,7 @@ * * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 * $FreeBSD: src/sys/sys/socketvar.h,v 1.46.2.9 2002/08/14 22:23:10 dg Exp $ - * $DragonFly: src/sys/sys/socketvar.h,v 1.2 2003/06/17 04:28:58 dillon Exp $ + * $DragonFly: src/sys/sys/socketvar.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _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 { @@ -312,15 +312,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)); /* @@ -357,14 +357,14 @@ void sf_buf_ref(caddr_t addr, u_int size); 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)); @@ -374,11 +374,8 @@ 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)); -struct socket * - sonewconn __P((struct socket *head, int connstatus)); -struct socket * - sonewconn3 __P((struct socket *head, int connstatus, struct proc *p)); +int solisten __P((struct socket *so, int backlog, struct thread *td)); +struct socket *sonewconn __P((struct socket *head, int connstatus)); 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)); @@ -389,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)); @@ -397,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/sysctl.h b/sys/sys/sysctl.h index c5f19746ca..8d5d81243e 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -35,7 +35,7 @@ * * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/sysctl.h,v 1.81.2.10 2003/05/01 22:48:09 trhodes Exp $ - * $DragonFly: src/sys/sys/sysctl.h,v 1.3 2003/06/23 17:55:50 dillon Exp $ + * $DragonFly: src/sys/sys/sysctl.h,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_SYSCTL_H_ @@ -105,7 +105,7 @@ struct ctlname { * so that we can use the interface from the kernel or from user-space. */ struct sysctl_req { - struct proc *p; + struct thread *td; int lock; void *oldptr; size_t oldlen; diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 656ca943b7..91aba55fa5 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -37,7 +37,7 @@ * * @(#)systm.h 8.7 (Berkeley) 3/29/95 * $FreeBSD: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $ - * $DragonFly: src/sys/sys/systm.h,v 1.5 2003/06/23 17:55:50 dillon Exp $ + * $DragonFly: src/sys/sys/systm.h,v 1.6 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_SYSTM_H_ @@ -313,7 +313,7 @@ extern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */ */ /* Exit callout list declarations. */ -typedef void (*exitlist_fn) __P((struct proc *procp)); +typedef void (*exitlist_fn) __P((struct thread *td)); int at_exit __P((exitlist_fn function)); int rm_at_exit __P((exitlist_fn function)); diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 0171e1e09a..54c39a1c5b 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -4,7 +4,7 @@ * Implements the architecture independant portion of the LWKT * subsystem. * - * $DragonFly: src/sys/sys/thread.h,v 1.8 2003/06/23 23:36:14 dillon Exp $ + * $DragonFly: src/sys/sys/thread.h,v 1.9 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_THREAD_H_ @@ -135,6 +135,7 @@ struct thread { u_int64_t td_uticks; /* Statclock hits in user mode (uS) */ u_int64_t td_sticks; /* Statclock hits in system mode (uS) */ u_int64_t td_iticks; /* Statclock hits processing intr (uS) */ + int td_locks; /* lockmgr lock debugging YYY */ struct mi_thread td_mach; }; @@ -148,6 +149,7 @@ struct thread { */ #define TDF_RUNNING 0x0001 /* currently running */ #define TDF_RUNQ 0x0002 /* on run queue */ +#define TDF_DEADLKTREAT 0x1000 /* special lockmgr deadlock treatment */ /* * Thread priorities. Typically only one thread from any given diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index 5fd333045e..4f74469835 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -32,7 +32,7 @@ * * @(#)ucred.h 8.4 (Berkeley) 1/9/95 * $FreeBSD: src/sys/sys/ucred.h,v 1.14.2.5 2002/03/09 05:20:25 dd Exp $ - * $DragonFly: src/sys/sys/ucred.h,v 1.3 2003/06/23 17:55:50 dillon Exp $ + * $DragonFly: src/sys/sys/ucred.h,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_UCRED_H_ @@ -44,7 +44,7 @@ struct prison; * Credentials. * * Please do not inspect cr_uid directly to determine superuserness. - * Only the suser()/suser_xxx() function should be used for this. + * Only the suser()/suser_cred() function should be used for this. */ struct ucred { u_int cr_ref; /* reference count */ @@ -88,7 +88,7 @@ struct ucred *crcopy __P((struct ucred *cr)); struct ucred *crdup __P((struct ucred *cr)); void crfree __P((struct ucred *cr)); struct ucred *crget __P((void)); -void crhold __P((struct ucred *cr)); +struct ucred *crhold __P((struct ucred *cr)); void cru2x __P((struct ucred *cr, struct xucred *xcr)); int groupmember __P((gid_t gid, struct ucred *cred)); #endif /* _KERNEL */ diff --git a/sys/sys/uio.h b/sys/sys/uio.h index b48581ef31..cc565c6e1c 100644 --- a/sys/sys/uio.h +++ b/sys/sys/uio.h @@ -32,7 +32,7 @@ * * @(#)uio.h 8.5 (Berkeley) 2/22/94 * $FreeBSD: src/sys/sys/uio.h,v 1.11.2.1 2001/09/28 16:58:35 dillon Exp $ - * $DragonFly: src/sys/sys/uio.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/sys/uio.h,v 1.3 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_UIO_H_ @@ -59,6 +59,10 @@ enum uio_seg { #ifdef _KERNEL +/* + * uio_td is primarily used for USERSPACE transfers, but some devices + * like ttys may also use it to get at the process. + */ struct uio { struct iovec *uio_iov; int uio_iovcnt; @@ -66,7 +70,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/vnode.h b/sys/sys/vnode.h index 4a50111452..5d5f979874 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -32,7 +32,7 @@ * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 * $FreeBSD: src/sys/sys/vnode.h,v 1.111.2.19 2002/12/29 18:19:53 dillon Exp $ - * $DragonFly: src/sys/sys/vnode.h,v 1.3 2003/06/24 02:12:00 dillon Exp $ + * $DragonFly: src/sys/sys/vnode.h,v 1.4 2003/06/25 03:56:10 dillon Exp $ */ #ifndef _SYS_VNODE_H_ @@ -459,7 +459,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); \ @@ -471,7 +471,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) @@ -481,7 +481,7 @@ do { \ struct vnode *_vp = (vp); \ \ if (_vp && IS_LOCKING_VFS(_vp) && \ - VOP_ISLOCKED(_vp, curproc) != LK_EXCLOTHER) \ + VOP_ISLOCKED(_vp, curthread) != LK_EXCLOTHER) \ panic("%s: %p is not exclusive locked by another proc", \ str, _vp); \ } while (0) @@ -545,6 +545,7 @@ struct mount; struct nameidata; struct ostat; struct proc; +struct thread; struct stat; struct nstat; struct ucred; @@ -581,41 +582,40 @@ 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 simplelock *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)); 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 *td, const char *filename, int line)); #define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__) #endif int vn_open __P((struct nameidata *ndp, int fmode, 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 *td, 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)); dev_t vn_todev __P((struct vnode *vp)); 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 *)); int vn_writechk __P((struct vnode *vp)); diff --git a/sys/vfs/coda/coda_namecache.c b/sys/vfs/coda/coda_namecache.c index d392e5b520..11ece22b01 100644 --- a/sys/vfs/coda/coda_namecache.c +++ b/sys/vfs/coda/coda_namecache.c @@ -28,7 +28,7 @@ * * @(#) src/sys/coda/coda_namecache.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_namecache.c,v 1.10 1999/08/28 00:40:53 peter Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_namecache.c,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_namecache.c,v 1.3 2003/06/25 03:55:44 dillon Exp $ * */ @@ -277,7 +277,7 @@ coda_nc_enter(dcp, name, namelen, cred, cp) */ vref(CTOV(cp)); vref(CTOV(dcp)); - crhold(cred); + cred = crhold(cred); cncp->dcp = dcp; cncp->cp = cp; cncp->namelen = namelen; diff --git a/sys/vfs/coda/coda_venus.c b/sys/vfs/coda/coda_venus.c index 5c91022848..0927810039 100644 --- a/sys/vfs/coda/coda_venus.c +++ b/sys/vfs/coda/coda_venus.c @@ -28,7 +28,7 @@ * * @(#) src/sys/cfs/coda_venus.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_venus.c,v 1.9 1999/08/28 00:40:56 peter Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_venus.c,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_venus.c,v 1.3 2003/06/25 03:55:44 dillon Exp $ * */ @@ -92,7 +92,8 @@ ((char*)inp + (int)inp->struc)[len++] = 0; \ Isize += len -#define INIT_IN(in, op, ident, p) \ +#define INIT_IN(in, op, ident, td) \ + do { struct proc *p = (td)->td_proc; \ (in)->opcode = (op); \ (in)->pid = p ? p->p_pid : -1; \ (in)->pgid = p ? p->p_pgid : -1; \ @@ -105,6 +106,7 @@ (in)->cred.cr_uid = -1; \ (in)->cred.cr_groupid = -1; \ } \ + } while(0) #define CNV_OFLAG(to, from) \ do { \ @@ -164,14 +166,14 @@ int coda_kernel_version = CODA_KERNEL_VERSION; int venus_root(void *mdp, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid) { DECL_NO_IN(coda_root); /* sets Isize & Osize */ ALLOC_NO_IN(coda_root); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(inp, CODA_ROOT, cred, p); + INIT_IN(inp, CODA_ROOT, cred, td); error = coda_call(mdp, Isize, &Osize, (char *)inp); if (!error) @@ -183,7 +185,7 @@ venus_root(void *mdp, int venus_open(void *mdp, ViceFid *fid, int flag, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ dev_t *dev, ino_t *inode) { int cflag; @@ -191,7 +193,7 @@ venus_open(void *mdp, ViceFid *fid, int flag, ALLOC(coda_open); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_OPEN, cred, p); + INIT_IN(&inp->ih, CODA_OPEN, cred, td); inp->VFid = *fid; CNV_OFLAG(cflag, flag); inp->flags = cflag; @@ -209,13 +211,13 @@ venus_open(void *mdp, ViceFid *fid, int flag, int venus_close(void *mdp, ViceFid *fid, int flag, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { int cflag; DECL_NO_OUT(coda_close); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_close); /* sets inp & outp */ - INIT_IN(&inp->ih, CODA_CLOSE, cred, p); + INIT_IN(&inp->ih, CODA_CLOSE, cred, td); inp->VFid = *fid; CNV_OFLAG(cflag, flag); inp->flags = cflag; @@ -247,7 +249,7 @@ venus_write(void) int venus_ioctl(void *mdp, ViceFid *fid, int com, int flag, caddr_t data, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL(coda_ioctl); /* sets Isize & Osize */ struct PioctlData *iap = (struct PioctlData *)data; @@ -256,7 +258,7 @@ venus_ioctl(void *mdp, ViceFid *fid, coda_ioctl_size = VC_MAXMSGSIZE; ALLOC(coda_ioctl); /* sets inp & outp */ - INIT_IN(&inp->ih, CODA_IOCTL, cred, p); + INIT_IN(&inp->ih, CODA_IOCTL, cred, td); inp->VFid = *fid; /* command was mutated by increasing its size field to reflect the @@ -297,14 +299,14 @@ venus_ioctl(void *mdp, ViceFid *fid, int venus_getattr(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ struct vattr *vap) { DECL(coda_getattr); /* sets Isize & Osize */ ALLOC(coda_getattr); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_GETATTR, cred, p); + INIT_IN(&inp->ih, CODA_GETATTR, cred, td); inp->VFid = *fid; error = coda_call(mdp, Isize, &Osize, (char *)inp); @@ -318,13 +320,13 @@ venus_getattr(void *mdp, ViceFid *fid, int venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_setattr); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_setattr); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_SETATTR, cred, p); + INIT_IN(&inp->ih, CODA_SETATTR, cred, td); inp->VFid = *fid; CNV_V2VV_ATTR(&inp->attr, vap); @@ -336,13 +338,13 @@ venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap, int venus_access(void *mdp, ViceFid *fid, int mode, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_access); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_access); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_ACCESS, cred, p); + INIT_IN(&inp->ih, CODA_ACCESS, cred, td); inp->VFid = *fid; /* NOTE: * NetBSD and Venus internals use the "data" in the low 3 bits. @@ -358,7 +360,7 @@ venus_access(void *mdp, ViceFid *fid, int mode, int venus_readlink(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ char **str, int *len) { DECL(coda_readlink); /* sets Isize & Osize */ @@ -366,7 +368,7 @@ venus_readlink(void *mdp, ViceFid *fid, ALLOC(coda_readlink); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_READLINK, cred, p); + INIT_IN(&inp->ih, CODA_READLINK, cred, td); inp->VFid = *fid; Osize += CODA_MAXPATHLEN; @@ -383,13 +385,13 @@ venus_readlink(void *mdp, ViceFid *fid, int venus_fsync(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_fsync); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_fsync); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_FSYNC, cred, p); + INIT_IN(&inp->ih, CODA_FSYNC, cred, td); inp->VFid = *fid; error = coda_call(mdp, Isize, &Osize, (char *)inp); @@ -401,7 +403,7 @@ venus_fsync(void *mdp, ViceFid *fid, int venus_lookup(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, int *vtype) { DECL(coda_lookup); /* sets Isize & Osize */ @@ -409,7 +411,7 @@ venus_lookup(void *mdp, ViceFid *fid, ALLOC(coda_lookup); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_LOOKUP, cred, p); + INIT_IN(&inp->ih, CODA_LOOKUP, cred, td); inp->VFid = *fid; /* NOTE: @@ -438,7 +440,7 @@ venus_lookup(void *mdp, ViceFid *fid, int venus_create(void *mdp, ViceFid *fid, const char *nm, int len, int exclusive, int mode, struct vattr *va, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, struct vattr *attr) { DECL(coda_create); /* sets Isize & Osize */ @@ -446,7 +448,7 @@ venus_create(void *mdp, ViceFid *fid, ALLOC(coda_create); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_CREATE, cred, p); + INIT_IN(&inp->ih, CODA_CREATE, cred, td); inp->VFid = *fid; inp->excl = exclusive ? C_O_EXCL : 0; inp->mode = mode; @@ -468,14 +470,14 @@ venus_create(void *mdp, ViceFid *fid, int venus_remove(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_remove); /* sets Isize & Osize */ coda_remove_size += len + 1; ALLOC_NO_OUT(coda_remove); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_REMOVE, cred, p); + INIT_IN(&inp->ih, CODA_REMOVE, cred, td); inp->VFid = *fid; inp->name = Isize; @@ -490,14 +492,14 @@ venus_remove(void *mdp, ViceFid *fid, int venus_link(void *mdp, ViceFid *fid, ViceFid *tfid, const char *nm, int len, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_link); /* sets Isize & Osize */ coda_link_size += len + 1; ALLOC_NO_OUT(coda_link); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_LINK, cred, p); + INIT_IN(&inp->ih, CODA_LINK, cred, td); inp->sourceFid = *fid; inp->destFid = *tfid; @@ -513,14 +515,14 @@ venus_link(void *mdp, ViceFid *fid, ViceFid *tfid, int venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid, const char *nm, int len, const char *tnm, int tlen, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_rename); /* sets Isize & Osize */ coda_rename_size += len + 1 + tlen + 1; ALLOC_NO_OUT(coda_rename); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_RENAME, cred, p); + INIT_IN(&inp->ih, CODA_RENAME, cred, td); inp->sourceFid = *fid; inp->destFid = *tfid; @@ -539,7 +541,7 @@ venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid, int venus_mkdir(void *mdp, ViceFid *fid, const char *nm, int len, struct vattr *va, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, struct vattr *ova) { DECL(coda_mkdir); /* sets Isize & Osize */ @@ -547,7 +549,7 @@ venus_mkdir(void *mdp, ViceFid *fid, ALLOC(coda_mkdir); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_MKDIR, cred, p); + INIT_IN(&inp->ih, CODA_MKDIR, cred, td); inp->VFid = *fid; CNV_V2VV_ATTR(&inp->attr, va); @@ -567,14 +569,14 @@ venus_mkdir(void *mdp, ViceFid *fid, int venus_rmdir(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_rmdir); /* sets Isize & Osize */ coda_rmdir_size += len + 1; ALLOC_NO_OUT(coda_rmdir); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_RMDIR, cred, p); + INIT_IN(&inp->ih, CODA_RMDIR, cred, td); inp->VFid = *fid; inp->name = Isize; @@ -589,14 +591,14 @@ venus_rmdir(void *mdp, ViceFid *fid, int venus_symlink(void *mdp, ViceFid *fid, const char *lnm, int llen, const char *nm, int len, struct vattr *va, - struct ucred *cred, struct proc *p) + struct ucred *cred, struct thread *td) { DECL_NO_OUT(coda_symlink); /* sets Isize & Osize */ coda_symlink_size += llen + 1 + len + 1; ALLOC_NO_OUT(coda_symlink); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_SYMLINK, cred, p); + INIT_IN(&inp->ih, CODA_SYMLINK, cred, td); inp->VFid = *fid; CNV_V2VV_ATTR(&inp->attr, va); @@ -615,7 +617,7 @@ venus_symlink(void *mdp, ViceFid *fid, int venus_readdir(void *mdp, ViceFid *fid, int count, int offset, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ char *buffer, int *len) { DECL(coda_readdir); /* sets Isize & Osize */ @@ -623,7 +625,7 @@ venus_readdir(void *mdp, ViceFid *fid, ALLOC(coda_readdir); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_READDIR, cred, p); + INIT_IN(&inp->ih, CODA_READDIR, cred, td); inp->VFid = *fid; inp->count = count; inp->offset = offset; @@ -641,14 +643,14 @@ venus_readdir(void *mdp, ViceFid *fid, int venus_fhtovp(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, int *vtype) { DECL(coda_vget); /* sets Isize & Osize */ ALLOC(coda_vget); /* sets inp & outp */ /* Send the open to Venus. */ - INIT_IN(&inp->ih, CODA_VGET, cred, p); + INIT_IN(&inp->ih, CODA_VGET, cred, td); inp->VFid = *fid; error = coda_call(mdp, Isize, &Osize, (char *)inp); diff --git a/sys/vfs/coda/coda_venus.h b/sys/vfs/coda/coda_venus.h index e802c88f16..a406533f7d 100644 --- a/sys/vfs/coda/coda_venus.h +++ b/sys/vfs/coda/coda_venus.h @@ -28,23 +28,23 @@ * * @(#) src/sys/coda/coda_venus.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_venus.h,v 1.4 1999/08/28 00:40:56 peter Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_venus.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_venus.h,v 1.3 2003/06/25 03:55:44 dillon Exp $ * */ int venus_root(void *mdp, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid); int venus_open(void *mdp, ViceFid *fid, int flag, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ dev_t *dev, ino_t *inode); int venus_close(void *mdp, ViceFid *fid, int flag, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); void venus_read(void); @@ -55,80 +55,80 @@ venus_write(void); int venus_ioctl(void *mdp, ViceFid *fid, int com, int flag, caddr_t data, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_getattr(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ struct vattr *vap); int venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_access(void *mdp, ViceFid *fid, int mode, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_readlink(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ char **str, int *len); int venus_fsync(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_lookup(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, int *vtype); int venus_create(void *mdp, ViceFid *fid, const char *nm, int len, int exclusive, int mode, struct vattr *va, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, struct vattr *attr); int venus_remove(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_link(void *mdp, ViceFid *fid, ViceFid *tfid, const char *nm, int len, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid, const char *nm, int len, const char *tnm, int tlen, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_mkdir(void *mdp, ViceFid *fid, const char *nm, int len, struct vattr *va, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, struct vattr *ova); int venus_rmdir(void *mdp, ViceFid *fid, const char *nm, int len, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_symlink(void *mdp, ViceFid *fid, const char *lnm, int llen, const char *nm, int len, struct vattr *va, - struct ucred *cred, struct proc *p); + struct ucred *cred, struct thread *td); int venus_readdir(void *mdp, ViceFid *fid, int count, int offset, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ char *buffer, int *len); int venus_fhtovp(void *mdp, ViceFid *fid, - struct ucred *cred, struct proc *p, + struct ucred *cred, struct thread *td, /*out*/ ViceFid *VFid, int *vtype); diff --git a/sys/vfs/coda/coda_vfsops.c b/sys/vfs/coda/coda_vfsops.c index 8c46281f20..b07dc52766 100644 --- a/sys/vfs/coda/coda_vfsops.c +++ b/sys/vfs/coda/coda_vfsops.c @@ -28,7 +28,7 @@ * * @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_vfsops.c,v 1.24.2.1 2001/07/26 20:36:45 iedowse Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_vfsops.c,v 1.3 2003/06/23 17:55:26 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_vfsops.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ * */ @@ -109,12 +109,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; @@ -137,7 +137,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; @@ -235,10 +235,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; @@ -294,9 +294,13 @@ 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 ucred *cred; ViceFid VFid; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + ENTRY; MARK_ENTRY(CODA_ROOT_STATS); result = NULL; @@ -310,16 +314,16 @@ 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); } } - error = venus_root(vftomi(vfsp), p->p_ucred, p, &VFid); + error = venus_root(vftomi(vfsp), cred, td, &VFid); if (!error) { /* @@ -333,9 +337,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); @@ -353,9 +357,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); @@ -376,10 +380,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); */ @@ -414,11 +418,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); @@ -443,10 +447,14 @@ 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 ucred *cred; ViceFid VFid; int vtype; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + ENTRY; MARK_ENTRY(CODA_VGET_STATS); @@ -458,7 +466,7 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) return(0); } - error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_ucred, p, &VFid, &vtype); + error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, cred, td, &VFid, &vtype); if (error) { CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));) diff --git a/sys/vfs/coda/coda_vfsops.h b/sys/vfs/coda/coda_vfsops.h index d40496578d..5ebd092867 100644 --- a/sys/vfs/coda/coda_vfsops.h +++ b/sys/vfs/coda/coda_vfsops.h @@ -28,7 +28,7 @@ * * @(#) src/sys/cfs/coda_vfsops.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_vfsops.h,v 1.4 1999/08/28 00:40:57 peter Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_vfsops.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_vfsops.h,v 1.3 2003/06/25 03:55:44 dillon Exp $ * */ @@ -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/vfs/coda/coda_vnops.c b/sys/vfs/coda/coda_vnops.c index 50e68bc4da..e0933e0854 100644 --- a/sys/vfs/coda/coda_vnops.c +++ b/sys/vfs/coda/coda_vnops.c @@ -28,7 +28,7 @@ * * @(#) src/sys/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_vnops.c,v 1.22.2.1 2001/06/29 16:26:22 shafeeq Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_vnops.c,v 1.3 2003/06/24 02:11:53 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_vnops.c,v 1.4 2003/06/25 03:55:44 dillon Exp $ * */ @@ -233,7 +233,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; @@ -254,7 +254,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, &dev, &inode); if (error) return (error); if (!error) { @@ -270,7 +270,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); @@ -295,14 +295,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); @@ -325,7 +325,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; @@ -346,7 +346,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 { @@ -356,7 +356,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); } @@ -366,7 +366,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); vrele(CTOV(cp)); CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); ) @@ -381,7 +381,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 @@ -392,17 +392,17 @@ 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!!! */ @@ -449,20 +449,20 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p) * We get the vnode back locked in both Mach and * NetBSD. Needs unlocked */ - VOP_UNLOCK(cfvp, 0, p); + VOP_UNLOCK(cfvp, 0, td); } 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); @@ -490,7 +490,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); } } @@ -504,7 +504,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. */ @@ -524,7 +524,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; @@ -549,7 +549,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; @@ -578,7 +578,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); if (error) MARK_INT_FAIL(CODA_IOCTL_STATS); @@ -609,7 +609,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; @@ -638,7 +638,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, vap); if (!error) { CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n", @@ -676,7 +676,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; @@ -691,7 +691,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); if (!error) cp->c_flags &= ~C_VATTR; @@ -716,7 +716,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; @@ -745,7 +745,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); return(error); } @@ -760,7 +760,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; @@ -784,7 +784,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, &str, &len); if (!error) { uiop->uio_rw = UIO_READ; @@ -811,7 +811,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; @@ -834,7 +834,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. @@ -860,7 +860,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); CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); ); return(error); @@ -877,7 +877,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 = curthread; /* upcall decl */ /* locals */ @@ -917,7 +917,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) { @@ -927,7 +927,7 @@ coda_inactive(v) panic("coda_inactive: cp->ovp != NULL"); } #endif - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); vgone(vp); } @@ -959,7 +959,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_td; /* locals */ struct cnode *cp; const char *nm = cnp->cn_nameptr; @@ -1002,7 +1002,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, &VFid, &vtype); if (error) { MARK_INT_FAIL(CODA_LOOKUP_STATS); @@ -1073,7 +1073,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; } /* @@ -1081,7 +1081,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"); } @@ -1090,7 +1090,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"); } @@ -1119,7 +1119,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_td; /* locals */ int error; struct cnode *cp; @@ -1140,7 +1140,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, &VFid, &attr); if (!error) { @@ -1179,7 +1179,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"); } @@ -1203,7 +1203,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_td; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1246,7 +1246,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); CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); ) @@ -1265,7 +1265,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_td; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1295,7 +1295,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); /* Invalidate the parent's attr cache, the modification time has changed */ VTOC(tdvp)->c_flags &= ~C_VATTR; @@ -1319,7 +1319,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_td; /* true args */ int error; const char *fnm = fcnp->cn_nameptr; @@ -1332,8 +1332,7 @@ coda_rename(v) /* Hmmm. The vnodes are already looked up. Perhaps they are locked? This could be Bad. XXX */ #ifdef OLD_DIAGNOSTIC - if ((fcnp->cn_cred != tcnp->cn_cred) - || (fcnp->cn_proc != tcnp->cn_proc)) + if ((fcnp->cn_cred != tcnp->cn_cred) || (fcnp->cn_td != tcnp->cn_td)) { panic("coda_rename: component names don't agree"); } @@ -1376,7 +1375,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); exit: CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));) @@ -1413,7 +1412,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_td; /* locals */ int error; const char *nm = cnp->cn_nameptr; @@ -1437,7 +1436,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, &VFid, &ova); if (!error) { if (coda_find(&VFid) != NULL) @@ -1482,7 +1481,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_td; /* true args */ int error; const char *nm = cnp->cn_nameptr; @@ -1514,7 +1513,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); CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); ) @@ -1533,7 +1532,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_td; struct vnode **vpp = ap->a_vpp; /* locals */ int error; @@ -1576,7 +1575,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); /* Invalidate the parent's attr cache, the modification time has changed */ tdcp->c_flags &= ~C_VATTR; @@ -1605,7 +1604,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; @@ -1630,14 +1629,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); @@ -1659,7 +1658,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); } } @@ -1772,7 +1771,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 */ @@ -1784,9 +1783,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 } @@ -1799,7 +1798,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 */ @@ -1809,7 +1808,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 @@ -1821,7 +1820,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/vfs/coda/coda_vnops.h b/sys/vfs/coda/coda_vnops.h index 5c95ec71e5..7ac90244b4 100644 --- a/sys/vfs/coda/coda_vnops.h +++ b/sys/vfs/coda/coda_vnops.h @@ -28,7 +28,7 @@ * * @(#) src/sys/coda/coda_vnops.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $ * $FreeBSD: src/sys/coda/coda_vnops.h,v 1.6 1999/08/28 00:40:58 peter Exp $ - * $DragonFly: src/sys/vfs/coda/Attic/coda_vnops.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ + * $DragonFly: src/sys/vfs/coda/Attic/coda_vnops.h,v 1.3 2003/06/25 03:55:44 dillon Exp $ * */ @@ -84,7 +84,7 @@ int coda_fbsd_putpages __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 *p); 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/vfs/fdesc/fdesc.h b/sys/vfs/fdesc/fdesc.h index 527d201fa3..cda33dc9e3 100644 --- a/sys/vfs/fdesc/fdesc.h +++ b/sys/vfs/fdesc/fdesc.h @@ -36,7 +36,7 @@ * @(#)fdesc.h 8.5 (Berkeley) 1/21/94 * * $FreeBSD: src/sys/miscfs/fdesc/fdesc.h,v 1.8.2.1 2001/10/22 22:49:26 chris Exp $ - * $DragonFly: src/sys/vfs/fdesc/fdesc.h,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/fdesc/fdesc.h,v 1.3 2003/06/25 03:55:58 dillon Exp $ */ #ifdef _KERNEL @@ -66,5 +66,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/vfs/fdesc/fdesc_vfsops.c b/sys/vfs/fdesc/fdesc_vfsops.c index 15f4a9c3c4..a1ad65a812 100644 --- a/sys/vfs/fdesc/fdesc_vfsops.c +++ b/sys/vfs/fdesc/fdesc_vfsops.c @@ -36,7 +36,7 @@ * @(#)fdesc_vfsops.c 8.4 (Berkeley) 1/21/94 * * $FreeBSD: src/sys/miscfs/fdesc/fdesc_vfsops.c,v 1.22.2.3 2002/08/23 17:42:39 njl Exp $ - * $DragonFly: src/sys/vfs/fdesc/fdesc_vfsops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/fdesc/fdesc_vfsops.c,v 1.3 2003/06/25 03:55:58 dillon Exp $ */ /* @@ -60,22 +60,18 @@ 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) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; +fdesc_mount(struct mount *mp, char *path, caddr_t data, + struct nameidata *ndp, struct thread *td) { int error = 0; struct fdescmount *fmp; @@ -91,7 +87,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); @@ -109,15 +105,12 @@ fdesc_mount(mp, path, data, ndp, p) bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); 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) - struct mount *mp; - int mntflags; - struct proc *p; +fdesc_unmount(struct mount *mp, int mntflags, struct thread *td) { int error; int flags = 0; @@ -146,11 +139,9 @@ fdesc_unmount(mp, mntflags, p) } int -fdesc_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; +fdesc_root(struct mount *mp, struct vnode **vpp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; /* @@ -158,23 +149,23 @@ 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) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +fdesc_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { + struct proc *p = td->td_proc; struct filedesc *fdp; int lim; int i; int last; int freefd; + KKASSERT(p); + /* * Compute number of free file descriptors. * [ Strange results will ensue if the open file diff --git a/sys/vfs/fdesc/fdesc_vnops.c b/sys/vfs/fdesc/fdesc_vnops.c index bac9d4a500..959d1ef62c 100644 --- a/sys/vfs/fdesc/fdesc_vnops.c +++ b/sys/vfs/fdesc/fdesc_vnops.c @@ -36,7 +36,7 @@ * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 * * $FreeBSD: src/sys/miscfs/fdesc/fdesc_vnops.c,v 1.47.2.1 2001/10/22 22:49:26 chris Exp $ - * $DragonFly: src/sys/vfs/fdesc/fdesc_vnops.c,v 1.3 2003/06/23 17:55:43 dillon Exp $ + * $DragonFly: src/sys/vfs/fdesc/fdesc_vnops.c,v 1.4 2003/06/25 03:55:58 dillon Exp $ */ /* @@ -53,11 +53,12 @@ #include #include /* Must come after sys/malloc.h */ #include -#include #include +#include #include #include #include +#include #include @@ -96,12 +97,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; @@ -111,7 +112,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); @@ -171,27 +172,30 @@ fdesc_lookup(ap) struct componentname * a_cnp; } */ *ap; { + struct componentname *cnp = ap->a_cnp; + struct thread *td = cnp->cn_td; + struct proc *p = td->td_proc; struct vnode **vpp = ap->a_vpp; struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; char *pname = cnp->cn_nameptr; - struct proc *p = cnp->cn_proc; int nlen = cnp->cn_namelen; - int nfiles = p->p_fd->fd_nfiles; + int nfiles; u_int fd; int error; struct vnode *fvp; + KKASSERT(p); + nfiles = p->p_fd->fd_nfiles; if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) { error = EROFS; 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); } @@ -219,16 +223,16 @@ fdesc_lookup(ap) 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); } @@ -239,10 +243,13 @@ 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; + struct proc *p = ap->a_td->td_proc; + + KKASSERT(p); if (VTOFDESC(vp)->fd_type == Froot) return (0); @@ -255,7 +262,7 @@ fdesc_open(ap) * Other callers of vn_open or VOP_OPEN will simply report the * error. */ - ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ + p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */ return (ENODEV); } @@ -265,17 +272,20 @@ 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 proc *p = ap->a_td->td_proc; struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - struct filedesc *fdp = ap->a_p->p_fd; + struct filedesc *fdp; struct file *fp; struct stat stb; u_int fd; int error = 0; + KKASSERT(p); + fdp = p->p_fd; switch (VTOFDESC(vp)->fd_type) { case Froot: VATTR_NULL(vap); @@ -305,7 +315,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); @@ -361,9 +371,10 @@ 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 proc *p = ap->a_td->td_proc; struct vattr *vap = ap->a_vap; struct file *fp; unsigned fd; @@ -376,11 +387,12 @@ fdesc_setattr(ap) return (EACCES); fd = VTOFDESC(ap->a_vp)->fd_fd; + KKASSERT(p); /* * Allow setattr where there is an underlying vnode. */ - error = getvnode(ap->a_p->p_fd, fd, &fp); + error = getvnode(p->p_fd, fd, &fp); if (error) { /* * getvnode() returns EINVAL if the file descriptor is not @@ -432,7 +444,8 @@ fdesc_readdir(ap) uio->uio_resid < UIO_MX) return (EINVAL); i = (u_int)off / UIO_MX; - fdp = uio->uio_procp->p_fd; + KKASSERT(uio->uio_td->td_proc); + fdp = uio->uio_td->td_proc->p_fd; error = 0; fcnt = i - 2; /* The first two nodes are `.' and `..' */ @@ -482,17 +495,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->p_thread); + 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; @@ -501,7 +514,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/vfs/fifofs/fifo_vnops.c b/sys/vfs/fifofs/fifo_vnops.c index ce13d5415b..e8a89050a2 100644 --- a/sys/vfs/fifofs/fifo_vnops.c +++ b/sys/vfs/fifofs/fifo_vnops.c @@ -32,7 +32,7 @@ * * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 * $FreeBSD: src/sys/miscfs/fifofs/fifo_vnops.c,v 1.45.2.4 2003/04/22 10:11:24 bde Exp $ - * $DragonFly: src/sys/vfs/fifofs/fifo_vnops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/fifofs/fifo_vnops.c,v 1.3 2003/06/25 03:55:59 dillon Exp $ */ #include @@ -165,26 +165,25 @@ 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 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); @@ -226,10 +225,10 @@ fifo_open(ap) } if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) { if (fip->fi_writers == 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, ap->a_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, ap->a_td); if (error) goto bad; /* @@ -247,10 +246,10 @@ fifo_open(ap) } } else { if (fip->fi_readers == 0) { - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, ap->a_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, ap->a_td); if (error) goto bad; /* @@ -263,7 +262,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, ap->a_td); return (error); } @@ -282,7 +281,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 @@ -294,10 +293,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); @@ -317,7 +316,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 @@ -326,10 +325,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); @@ -347,7 +346,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; @@ -357,13 +356,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); } @@ -460,7 +459,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; @@ -470,13 +469,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); } @@ -485,11 +484,10 @@ static int fifo_inactive(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); } @@ -529,7 +527,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/vfs/gnu/ext2fs/ext2_vnops.c b/sys/vfs/gnu/ext2fs/ext2_vnops.c index 2bdff22f88..6aa5ce7530 100644 --- a/sys/vfs/gnu/ext2fs/ext2_vnops.c +++ b/sys/vfs/gnu/ext2fs/ext2_vnops.c @@ -44,7 +44,7 @@ * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 * @(#)ext2_vnops.c 8.7 (Berkeley) 2/3/94 * $FreeBSD: src/sys/gnu/ext2fs/ext2_vnops.c,v 1.51.2.2 2003/01/02 17:26:18 bde Exp $ - * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_vnops.c,v 1.2 2003/06/17 04:28:34 dillon Exp $ + * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_vnops.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ */ #include "opt_quota.h" @@ -1112,7 +1112,7 @@ ext2_makeinode(mode, dvp, vpp, cnp) tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */ ip->i_nlink = 1; if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) && - suser_xxx(cnp->cn_cred, 0, PRISON_ROOT)) + suser_cred(cnp->cn_cred, PRISON_ROOT)) ip->i_mode &= ~ISGID; if (cnp->cn_flags & ISWHITEOUT) diff --git a/sys/vfs/hpfs/hpfs_vnops.c b/sys/vfs/hpfs/hpfs_vnops.c index 735d090ba4..b293ab84ac 100644 --- a/sys/vfs/hpfs/hpfs_vnops.c +++ b/sys/vfs/hpfs/hpfs_vnops.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/hpfs/hpfs_vnops.c,v 1.2.2.2 2002/01/15 18:35:09 semenu Exp $ - * $DragonFly: src/sys/vfs/hpfs/hpfs_vnops.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/vfs/hpfs/hpfs_vnops.c,v 1.3 2003/06/25 03:55:51 dillon Exp $ */ #include @@ -520,14 +520,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)); @@ -566,7 +566,7 @@ 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_cred(cred, PRISON_ROOT)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || (error = VOP_ACCESS(vp, VWRITE, cred, p)))) return (error); diff --git a/sys/vfs/isofs/cd9660/cd9660_lookup.c b/sys/vfs/isofs/cd9660/cd9660_lookup.c index 762ddacde5..2ec2cd940a 100644 --- a/sys/vfs/isofs/cd9660/cd9660_lookup.c +++ b/sys/vfs/isofs/cd9660/cd9660_lookup.c @@ -39,11 +39,12 @@ * * @(#)cd9660_lookup.c 8.2 (Berkeley) 1/23/94 * $FreeBSD: src/sys/isofs/cd9660/cd9660_lookup.c,v 1.23.2.2 2001/11/04 06:19:47 dillon Exp $ - * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_lookup.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_lookup.c,v 1.3 2003/06/25 03:55:56 dillon Exp $ */ #include #include +#include #include #include #include @@ -120,7 +121,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_td; bp = NULL; *vpp = NULL; @@ -351,16 +352,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 +381,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/vfs/isofs/cd9660/cd9660_node.c b/sys/vfs/isofs/cd9660/cd9660_node.c index eed895865f..6e3c0f2eb0 100644 --- a/sys/vfs/isofs/cd9660/cd9660_node.c +++ b/sys/vfs/isofs/cd9660/cd9660_node.c @@ -37,7 +37,7 @@ * * @(#)cd9660_node.c 8.2 (Berkeley) 1/23/94 * $FreeBSD: src/sys/isofs/cd9660/cd9660_node.c,v 1.29.2.1 2000/07/08 14:35:56 bp Exp $ - * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_node.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_node.c,v 1.3 2003/06/25 03:55:56 dillon Exp $ */ #include @@ -99,7 +99,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; @@ -110,7 +110,7 @@ loop: vp = ITOV(ip); simple_lock(&vp->v_interlock); simple_unlock(&cd9660_ihash_slock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -123,10 +123,9 @@ loop: * Insert the inode into the hash table, and return it locked. */ void -cd9660_ihashins(ip) - struct iso_node *ip; +cd9660_ihashins(struct iso_node *ip) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct iso_node **ipp, *iq; simple_lock(&cd9660_ihash_slock); @@ -138,7 +137,7 @@ cd9660_ihashins(ip) *ipp = ip; simple_unlock(&cd9660_ihash_slock); - lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, p); + lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, td); } /* @@ -169,11 +168,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; @@ -181,13 +180,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, (struct simplelock *)0, p); + vrecycle(vp, (struct simplelock *)0, td); return error; } diff --git a/sys/vfs/isofs/cd9660/cd9660_vfsops.c b/sys/vfs/isofs/cd9660/cd9660_vfsops.c index 4849457ac2..ec1e1ae2eb 100644 --- a/sys/vfs/isofs/cd9660/cd9660_vfsops.c +++ b/sys/vfs/isofs/cd9660/cd9660_vfsops.c @@ -37,13 +37,13 @@ * * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95 * $FreeBSD: src/sys/isofs/cd9660/cd9660_vfsops.c,v 1.74.2.7 2002/04/08 09:39:29 bde Exp $ - * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_vfsops.c,v 1.3 2003/06/23 17:55:41 dillon Exp $ + * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_vfsops.c,v 1.4 2003/06/25 03:55:56 dillon Exp $ */ #include #include -#include #include +#include #include #include #include @@ -66,10 +66,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_checkexp __P((struct mount *, struct sockaddr *, @@ -100,9 +100,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 @@ -110,9 +110,7 @@ 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) - dev_t dev; - struct proc *p; +iso_get_ssector(dev_t dev, struct thread *td) { struct ioc_toc_header h; struct ioc_read_toc_single_entry t; @@ -125,13 +123,13 @@ iso_get_ssector(dev, p) if (ioctlp == NULL) return 0; - if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p->p_thread) != 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->p_thread) != 0) + if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, td) != 0) return 0; if ((t.entry.control & 4) != 0) /* found a data track */ @@ -144,12 +142,10 @@ 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) - struct mount *mp; - struct proc *p; +iso_mountroot(struct mount *mp, struct thread *td) { struct iso_args args; int error; @@ -160,23 +156,23 @@ iso_mountroot(mp, p) } args.flags = ISOFSMNT_ROOT; - vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_OPEN(rootvp, FREAD, FSCRED, p); - VOP_UNLOCK(rootvp, 0, p); + vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(rootvp, FREAD, FSCRED, td); + VOP_UNLOCK(rootvp, 0, td); if (error) return (error); - args.ssector = iso_get_ssector(rootdev, p); + args.ssector = iso_get_ssector(rootdev, td); - (void)VOP_CLOSE(rootvp, FREAD, NOCRED, p); + (void)VOP_CLOSE(rootvp, FREAD, NOCRED, 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); } @@ -186,12 +182,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; @@ -201,7 +197,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,6 +205,8 @@ cd9660_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EROFS); + KKASSERT(td->td_proc); + /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -222,7 +220,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); @@ -238,18 +236,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(); + error = suser(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 */ @@ -266,7 +264,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; } @@ -274,12 +272,12 @@ cd9660_mount(mp, path, data, ndp, p) * Common code for mount and mountroot */ static int -iso_mountfs(devvp, mp, p, argp) - register struct vnode *devvp; - struct mount *mp; - struct proc *p; - struct iso_args *argp; -{ +iso_mountfs( + struct vnode *devvp, + struct mount *mp, + struct thread *td, + struct iso_args *argp +) { register struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; struct buf *pribp = NULL, *supbp = NULL; @@ -300,6 +298,7 @@ iso_mountfs(devvp, mp, p, argp) if (!(mp->mnt_flag & MNT_RDONLY)) return EROFS; + KKASSERT(td->td_proc); /* * Disallow multiple mounts of the same device. * Disallow mounting of a device that is currently in use @@ -310,12 +309,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; if (devvp->v_rdev->si_iosize_max != 0) @@ -530,7 +529,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; @@ -542,10 +541,7 @@ out: * unmount system call */ static int -cd9660_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; +cd9660_unmount(struct mount *mp, int mntflags, struct thread *td) { register struct iso_mnt *isomp; int error, flags = 0; @@ -563,7 +559,7 @@ cd9660_unmount(mp, mntflags, p) isomp = VFSTOISOFS(mp); isomp->im_devvp->v_specmountpoint = 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; @@ -596,12 +592,9 @@ cd9660_root(mp, vpp) * Get file system statistics. */ int -cd9660_statfs(mp, sbp, p) - struct mount *mp; - register struct statfs *sbp; - struct proc *p; +cd9660_statfs(struct mount *mp, register struct statfs *sbp, struct thread *td) { - register struct iso_mnt *isomp; + struct iso_mnt *isomp; isomp = VFSTOISOFS(mp); diff --git a/sys/vfs/isofs/cd9660/cd9660_vnops.c b/sys/vfs/isofs/cd9660/cd9660_vnops.c index 908fe5574d..c62b67f21d 100644 --- a/sys/vfs/isofs/cd9660/cd9660_vnops.c +++ b/sys/vfs/isofs/cd9660/cd9660_vnops.c @@ -37,11 +37,12 @@ * * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95 * $FreeBSD: src/sys/isofs/cd9660/cd9660_vnops.c,v 1.62 1999/12/15 23:01:51 eivind Exp $ - * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_vnops.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_vnops.c,v 1.3 2003/06/25 03:55:56 dillon Exp $ */ #include #include +#include #include #include #include @@ -203,7 +204,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; { @@ -238,7 +239,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; diff --git a/sys/vfs/mfs/mfs_extern.h b/sys/vfs/mfs/mfs_extern.h index 5ec80b903c..48b951d928 100644 --- a/sys/vfs/mfs/mfs_extern.h +++ b/sys/vfs/mfs/mfs_extern.h @@ -32,7 +32,7 @@ * * @(#)mfs_extern.h 8.4 (Berkeley) 3/30/95 * $FreeBSD: src/sys/ufs/mfs/mfs_extern.h,v 1.15 1999/08/28 00:52:24 peter Exp $ - * $DragonFly: src/sys/vfs/mfs/mfs_extern.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/mfs/mfs_extern.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _UFS_MFS_MFS_EXTERN_H_ @@ -41,12 +41,12 @@ struct buf; struct mfsnode; struct mount; -struct proc; +struct thread; struct vnode; void mfs_doio __P((struct buf *bp, struct mfsnode *mfsnode)); u_char *mfs_getimage __P((void)); -int mfs_mountfs __P((struct vnode *, struct mount *, struct proc *)); +int mfs_mountfs __P((struct vnode *, struct mount *, struct thread *)); int mfs_mountroot __P((void)); #endif /* !_UFS_MFS_MFS_EXTERN_H_ */ diff --git a/sys/vfs/mfs/mfs_vfsops.c b/sys/vfs/mfs/mfs_vfsops.c index a906984407..f921694650 100644 --- a/sys/vfs/mfs/mfs_vfsops.c +++ b/sys/vfs/mfs/mfs_vfsops.c @@ -32,7 +32,7 @@ * * @(#)mfs_vfsops.c 8.11 (Berkeley) 6/19/95 * $FreeBSD: src/sys/ufs/mfs/mfs_vfsops.c,v 1.81.2.3 2001/07/04 17:35:21 tegge Exp $ - * $DragonFly: src/sys/vfs/mfs/mfs_vfsops.c,v 1.3 2003/06/19 01:55:08 dillon Exp $ + * $DragonFly: src/sys/vfs/mfs/mfs_vfsops.c,v 1.4 2003/06/25 03:56:12 dillon Exp $ */ @@ -72,10 +72,10 @@ extern vop_t **mfs_vnodeop_p; static int mfs_mount __P((struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, - struct proc *p)); -static int mfs_start __P((struct mount *mp, int flags, struct proc *p)); + struct thread *td)); +static int mfs_start __P((struct mount *mp, int flags, struct thread *td)); static int mfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); + struct thread *td)); static int mfs_init __P((struct vfsconf *)); static struct cdevsw mfs_cdevsw = { @@ -157,12 +157,12 @@ VFS_SET(mfs_vfsops, mfs, 0); */ /* ARGSUSED */ static int -mfs_mount(mp, path, data, ndp, p) +mfs_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 mfs_args args; @@ -213,7 +213,7 @@ mfs_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - err = ffs_flushfiles(mp, flags, p); + err = ffs_flushfiles(mp, flags, td); if (err) goto error_1; } @@ -254,7 +254,7 @@ mfs_mount(mp, path, data, ndp, p) mfsp->mfs_baseoff = args.base; mfsp->mfs_size = args.size; mfsp->mfs_vnode = devvp; - mfsp->mfs_pid = p->p_pid; + mfsp->mfs_td = td; mfsp->mfs_active = 1; bufq_init(&mfsp->buf_queue); @@ -278,7 +278,7 @@ mfs_mount(mp, path, data, ndp, p) &size); /* real size*/ bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - if ((err = ffs_mountfs(devvp, mp, p, M_MFSNODE)) != 0) { + if ((err = ffs_mountfs(devvp, mp, td, M_MFSNODE)) != 0) { mfsp->mfs_active = 0; goto error_2; } @@ -289,7 +289,7 @@ mfs_mount(mp, path, data, ndp, p) * * 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; @@ -317,10 +317,7 @@ static int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */ */ /* ARGSUSED */ static int -mfs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; +mfs_start(struct mount *mp, int flags, struct thread *td) { register struct vnode *vp = VFSTOUFS(mp)->um_devvp; register struct mfsnode *mfsp = VTOMFS(vp); @@ -364,10 +361,11 @@ mfs_start(mp, flags, p) */ if (gotsig) { gotsig = 0; - if (dounmount(mp, 0, p) != 0) { - sig = CURSIG(p); + if (dounmount(mp, 0, td) != 0) { + KKASSERT(td->td_proc); + sig = CURSIG(td->td_proc); if (sig) - SIGDELSET(p->p_siglist, sig); + SIGDELSET(td->td_proc->p_siglist, sig); } } else if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0)) @@ -380,14 +378,11 @@ mfs_start(mp, flags, p) * Get file system statistics. */ static int -mfs_statfs(mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +mfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { int error; - error = ffs_statfs(mp, sbp, p); + error = ffs_statfs(mp, sbp, td); sbp->f_type = mp->mnt_vfc->vfc_typenum; return (error); } diff --git a/sys/vfs/mfs/mfs_vnops.c b/sys/vfs/mfs/mfs_vnops.c index 56ed0218ce..aa28d32de5 100644 --- a/sys/vfs/mfs/mfs_vnops.c +++ b/sys/vfs/mfs/mfs_vnops.c @@ -32,7 +32,7 @@ * * @(#)mfs_vnops.c 8.11 (Berkeley) 5/22/95 * $FreeBSD: src/sys/ufs/mfs/mfs_vnops.c,v 1.47.2.1 2001/05/22 02:06:43 bp Exp $ - * $DragonFly: src/sys/vfs/mfs/mfs_vnops.c,v 1.4 2003/06/23 17:55:51 dillon Exp $ + * $DragonFly: src/sys/vfs/mfs/mfs_vnops.c,v 1.5 2003/06/25 03:56:12 dillon Exp $ */ #include @@ -107,7 +107,7 @@ mfs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -175,7 +175,7 @@ mfs_strategy(ap) register struct buf *bp = ap->a_bp; register struct mfsnode *mfsp; struct vnode *vp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int s; if (!vfinddev(bp->b_dev, VBLK, &vp) || vp->v_usecount == 0) @@ -189,7 +189,7 @@ mfs_strategy(ap) s = splbio(); - if (mfsp->mfs_pid == 0) { + if (mfsp->mfs_td == NULL) { /* * mini-root. Note: B_FREEBUF not supported at the moment, * I'm not sure what kind of dataspace b_data is in. @@ -204,7 +204,7 @@ mfs_strategy(ap) else bcopy(bp->b_data, base, bp->b_bcount); biodone(bp); - } else if (mfsp->mfs_pid == p->p_pid) { + } else if (mfsp->mfs_td == td) { /* * VOP to self */ @@ -318,7 +318,7 @@ mfs_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; @@ -339,7 +339,7 @@ mfs_close(ap) * we must invalidate any in core blocks, so that * we can, free up its vnode. */ - if ((error = vinvalbuf(vp, 1, ap->a_cred, ap->a_p, 0, 0)) != 0) + if ((error = vinvalbuf(vp, 1, ap->a_cred, ap->a_td, 0, 0)) != 0) return (error); /* * There should be no way to have any more uses of this @@ -365,7 +365,7 @@ static int mfs_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; @@ -374,7 +374,7 @@ mfs_inactive(ap) if (bufq_first(&mfsp->buf_queue) != NULL) panic("mfs_inactive: not inactive (next buffer %p)", bufq_first(&mfsp->buf_queue)); - VOP_UNLOCK(vp, 0, ap->a_p); + VOP_UNLOCK(vp, 0, ap->a_td); return (0); } @@ -405,8 +405,8 @@ mfs_print(ap) { register struct mfsnode *mfsp = VTOMFS(ap->a_vp); - printf("tag VT_MFS, pid %ld, base %p, size %ld\n", - (long)mfsp->mfs_pid, (void *)mfsp->mfs_baseoff, mfsp->mfs_size); + printf("tag VT_MFS, td %p, base %p, size %ld\n", + mfsp->mfs_td, (void *)mfsp->mfs_baseoff, mfsp->mfs_size); return (0); } diff --git a/sys/vfs/mfs/mfsnode.h b/sys/vfs/mfs/mfsnode.h index 3767a73655..6799e366ca 100644 --- a/sys/vfs/mfs/mfsnode.h +++ b/sys/vfs/mfs/mfsnode.h @@ -32,7 +32,7 @@ * * @(#)mfsnode.h 8.3 (Berkeley) 5/19/95 * $FreeBSD: src/sys/ufs/mfs/mfsnode.h,v 1.12.2.2 2001/07/04 17:35:21 tegge Exp $ - * $DragonFly: src/sys/vfs/mfs/mfsnode.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/mfs/mfsnode.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _UFS_MFS_MFSNODE_H_ @@ -46,8 +46,8 @@ struct mfsnode { struct vnode *mfs_vnode; /* vnode associated with this mfsnode */ caddr_t mfs_baseoff; /* base of file system in memory */ long mfs_size; /* size of memory file system */ - pid_t mfs_pid; /* supporting process pid */ - struct buf_queue_head buf_queue; /* list of I/O requests */ + struct thread *mfs_td; /* supporting thread */ + struct buf_queue_head buf_queue; /* list of I/O requests */ int mfs_active; long mfs_spare[1]; }; diff --git a/sys/vfs/msdosfs/denode.h b/sys/vfs/msdosfs/denode.h index 6742714cc3..983416eb40 100644 --- a/sys/vfs/msdosfs/denode.h +++ b/sys/vfs/msdosfs/denode.h @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/msdosfs/denode.h,v 1.20 1999/12/29 04:54:52 peter Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/denode.h,v 1.2 2003/06/17 04:28:47 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/msdosfs/denode.h,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* $NetBSD: denode.h,v 1.25 1997/11/17 15:36:28 ws Exp $ */ /*- @@ -282,6 +282,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/vfs/msdosfs/msdosfs_denode.c b/sys/vfs/msdosfs/msdosfs_denode.c index dd20909182..1685015629 100644 --- a/sys/vfs/msdosfs/msdosfs_denode.c +++ b/sys/vfs/msdosfs/msdosfs_denode.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/msdosfs/msdosfs_denode.c,v 1.47.2.3 2002/08/22 16:20:15 trhodes Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_denode.c,v 1.2 2003/06/17 04:28:47 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_denode.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */ /*- @@ -126,7 +126,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; @@ -140,7 +140,7 @@ loop: vp = DETOV(dep); simple_lock(&vp->v_interlock); simple_unlock(&dehash_slock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (dep); } @@ -203,6 +203,7 @@ deget(pmp, dirclust, diroffset, depp) u_long diroffset; /* index of entry within the cluster */ struct denode **depp; /* returns the addr of the gotten denode */ { + struct thread *td = curthread; /* XXX */ int error; dev_t dev = pmp->pm_dev; struct mount *mntp = pmp->pm_mountp; @@ -210,7 +211,6 @@ deget(pmp, dirclust, diroffset, depp) struct denode *ldep; struct vnode *nvp; struct buf *bp; - struct proc *p = curproc; /* 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 (lockmgr(&ldep->de_lock, LK_EXCLUSIVE, (struct simplelock *)0, p)) + if (lockmgr(&ldep->de_lock, LK_EXCLUSIVE, (struct simplelock *)0, td)) panic("deget: unexpected lock failure"); /* @@ -425,12 +425,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; @@ -531,7 +531,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); @@ -681,12 +681,11 @@ 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; int error = 0; #ifdef MSDOSFS_DEBUG @@ -712,14 +711,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, ap->a_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, ap->a_td); /* * If we are done with the denode, reclaim it * so that it can be reused immediately. @@ -729,6 +728,6 @@ out: dep->de_Name[0]); #endif if (dep->de_Name[0] == SLOT_DELETED) - vrecycle(vp, (struct simplelock *)0, p); + vrecycle(vp, (struct simplelock *)0, ap->a_td); return (error); } diff --git a/sys/vfs/msdosfs/msdosfs_lookup.c b/sys/vfs/msdosfs/msdosfs_lookup.c index 2d037dca29..31869ae516 100644 --- a/sys/vfs/msdosfs/msdosfs_lookup.c +++ b/sys/vfs/msdosfs/msdosfs_lookup.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/msdosfs/msdosfs_lookup.c,v 1.30.2.1 2000/11/03 15:55:39 bp Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_lookup.c,v 1.2 2003/06/17 04:28:47 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_lookup.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */ /*- @@ -51,9 +51,10 @@ #include #include -#include #include #include +#include +#include #include #include @@ -110,7 +111,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_td; int unlen; int wincnt = 1; @@ -340,7 +341,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_td); if (error) return (error); /* @@ -365,7 +366,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 +439,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_td); if (error) return (error); @@ -456,7 +457,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 +474,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_td); if (error) return (error); @@ -489,7 +490,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 +517,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 +541,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/vfs/msdosfs/msdosfs_vfsops.c b/sys/vfs/msdosfs/msdosfs_vfsops.c index 2dfe352dc1..71d161ee46 100644 --- a/sys/vfs/msdosfs/msdosfs_vfsops.c +++ b/sys/vfs/msdosfs/msdosfs_vfsops.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/msdosfs/msdosfs_vfsops.c,v 1.60.2.6 2002/09/12 21:33:38 trhodes Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vfsops.c,v 1.2 2003/06/17 04:28:47 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vfsops.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ /*- @@ -52,8 +52,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -88,19 +88,19 @@ 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_checkexp __P((struct mount *, struct sockaddr *, int *, struct ucred **)); 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 @@ -161,7 +161,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; @@ -224,12 +224,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 */ @@ -238,6 +238,9 @@ msdosfs_mount(mp, path, data, ndp, p) size_t size; int error, flags; mode_t accessmode; + struct proc *p = td->td_proc; + + KKASSERT(p); error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args)); if (error) @@ -269,14 +272,14 @@ msdosfs_mount(mp, path, data, ndp, p) */ if (p->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); + p->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; } @@ -299,7 +302,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); @@ -318,16 +321,16 @@ msdosfs_mount(mp, path, data, ndp, p) 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, p->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 @@ -344,7 +347,7 @@ 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; } @@ -353,7 +356,7 @@ msdosfs_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) 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 @@ -361,10 +364,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; @@ -381,6 +384,9 @@ mountmsdosfs(devvp, mp, p, argp) u_int8_t SecPerClust; u_long clusters; int ronly, error; + struct proc *p = td->td_proc; + + KKASSERT(p); /* * Disallow multiple mounts of the same device. @@ -393,16 +399,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, p->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); @@ -422,7 +428,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; @@ -739,7 +745,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); @@ -753,10 +759,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; @@ -793,7 +799,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); @@ -822,10 +828,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; @@ -847,11 +853,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; @@ -893,17 +899,17 @@ loop: continue; } simple_unlock(&mntvnode_slock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { simple_lock(&mntvnode_slock); 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); simple_lock(&mntvnode_slock); } @@ -913,11 +919,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/vfs/msdosfs/msdosfs_vnops.c b/sys/vfs/msdosfs/msdosfs_vnops.c index be1601e82c..58d2a7ba38 100644 --- a/sys/vfs/msdosfs/msdosfs_vnops.c +++ b/sys/vfs/msdosfs/msdosfs_vnops.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/msdosfs/msdosfs_vnops.c,v 1.95.2.4 2003/06/13 15:05:47 trhodes Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vnops.c,v 1.4 2003/06/23 17:55:45 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vnops.c,v 1.5 2003/06/25 03:56:01 dillon Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- @@ -51,12 +51,12 @@ #include #include -#include #include /* defines plimit structure in proc struct */ #include #include #include #include +#include #include #include #include @@ -227,7 +227,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; @@ -249,7 +249,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; @@ -327,7 +327,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); @@ -393,7 +393,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; @@ -405,7 +405,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 /* @@ -430,7 +430,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, PRISON_ROOT))) + (error = suser_cred(cred, PRISON_ROOT))) return (error); /* * We are very inconsistent about handling unsupported @@ -471,7 +471,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, PRISON_ROOT))) + (error = suser_cred(cred, PRISON_ROOT))) return error; if (uid != pmp->pm_uid || gid != pmp->pm_gid) return EINVAL; @@ -495,7 +495,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; } @@ -503,9 +503,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, PRISON_ROOT)) && + (error = suser_cred(cred, 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 && @@ -532,7 +532,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, PRISON_ROOT))) + (error = suser_cred(cred, PRISON_ROOT))) return (error); if (vp->v_type != VDIR) { /* We ignore the read and execute bits. */ @@ -662,12 +662,13 @@ 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); struct msdosfsmount *pmp = dep->de_pmp; struct ucred *cred = ap->a_cred; + struct proc *p = td->td_proc; #ifdef MSDOSFS_DEBUG printf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n", @@ -854,7 +855,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; @@ -997,7 +998,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_td; struct denode *ip, *xp, *dp, *zp; u_char toname[11], oldname[11]; u_long from_diroffset, to_diroffset; @@ -1047,7 +1048,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); @@ -1068,7 +1069,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; } @@ -1098,8 +1099,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_td); + VOP_UNLOCK(fvp, 0, td); if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) newparent = 1; if (doingdirectory && newparent) { @@ -1168,7 +1169,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) { @@ -1179,7 +1180,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; } @@ -1199,9 +1200,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); @@ -1223,8 +1224,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++; @@ -1233,8 +1234,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) { @@ -1243,8 +1244,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) @@ -1254,7 +1255,7 @@ abortit: } reinsert(ip); if (newparent) - VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fdvp, 0, td); } /* @@ -1273,7 +1274,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; @@ -1283,12 +1284,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); @@ -1448,11 +1449,11 @@ msdosfs_rmdir(ap) struct componentname *a_cnp; } */ *ap; { - register struct vnode *vp = ap->a_vp; - 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 vnode *vp = ap->a_vp; + struct vnode *dvp = ap->a_dvp; + struct componentname *cnp = ap->a_cnp; + struct denode *ip, *dp; + struct thread *td = cnp->cn_td; int error; ip = VTODE(vp); @@ -1487,14 +1488,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/vfs/nfs/krpc.h b/sys/vfs/nfs/krpc.h index 0bef5aa737..786ff2003e 100644 --- a/sys/vfs/nfs/krpc.h +++ b/sys/vfs/nfs/krpc.h @@ -1,20 +1,21 @@ /* $NetBSD: krpc.h,v 1.4 1995/12/19 23:07:11 cgd Exp $ */ /* $FreeBSD: src/sys/nfs/krpc.h,v 1.6 1999/08/28 00:49:55 peter Exp $ */ -/* $DragonFly: src/sys/vfs/nfs/krpc.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ */ +/* $DragonFly: src/sys/vfs/nfs/krpc.h,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #include 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/vfs/nfs/nfs.h b/sys/vfs/nfs/nfs.h index 5a47971d2d..4f0d105fe5 100644 --- a/sys/vfs/nfs/nfs.h +++ b/sys/vfs/nfs/nfs.h @@ -35,7 +35,7 @@ * * @(#)nfs.h 8.4 (Berkeley) 5/1/95 * $FreeBSD: src/sys/nfs/nfs.h,v 1.53.2.5 2002/02/20 01:35:34 iedowse Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs.h,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #ifndef _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; /* Thread 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; /* thread ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ }; @@ -592,18 +592,18 @@ 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 *td)); 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_sigintr __P((struct nfsmount *, struct nfsreq *, struct thread *)); int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *, @@ -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)); @@ -653,21 +653,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)); @@ -675,55 +675,55 @@ 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)); -int nfs_meta_setsize __P((struct vnode *vp, struct ucred *cred, struct proc *p, u_quad_t nsize)); +int nfs_meta_setsize __P((struct vnode *vp, struct ucred *cred, struct thread *td, u_quad_t nsize)); #endif /* _KERNEL */ diff --git a/sys/vfs/nfs/nfs_bio.c b/sys/vfs/nfs/nfs_bio.c index 7fde3d4db9..a25fdc87fc 100644 --- a/sys/vfs/nfs/nfs_bio.c +++ b/sys/vfs/nfs/nfs_bio.c @@ -35,7 +35,7 @@ * * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nfs_bio.c,v 1.83.2.4 2002/12/29 18:19:53 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.3 2003/06/19 01:55:07 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.4 2003/06/25 03:56:07 dillon Exp $ */ @@ -66,7 +66,7 @@ #include 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; @@ -85,20 +85,22 @@ nfs_getpages(ap) vm_ooffset_t a_offset; } */ *ap; { + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; /* XXX */ int i, error, nextoff, size, toff, count, npages; struct uio uio; struct iovec iov; vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; struct ucred *cred; struct nfsmount *nmp; vm_page_t *pages; + KKASSERT(p); + vp = ap->a_vp; - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + cred = p->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -110,7 +112,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); @@ -151,7 +153,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); @@ -245,6 +247,7 @@ nfs_putpages(ap) vm_ooffset_t a_offset; } */ *ap; { + struct thread *td = curthread; struct uio uio; struct iovec iov; vm_offset_t kva; @@ -253,16 +256,16 @@ nfs_putpages(ap) off_t offset; int *rtvals; struct vnode *vp; - struct proc *p; struct ucred *cred; struct nfsmount *nmp; struct nfsnode *np; vm_page_t *pages; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + vp = ap->a_vp; np = VTONFS(vp); - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ nmp = VFSTONFS(vp->v_mount); pages = ap->a_m; count = ap->a_count; @@ -272,7 +275,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++) { rtvals[i] = VM_PAGER_AGAIN; @@ -305,7 +308,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; @@ -333,17 +336,13 @@ nfs_putpages(ap) * Vnode op for read using bio */ int -nfs_bioread(vp, uio, ioflag, cred) - register struct vnode *vp; - register struct uio *uio; - int ioflag; - struct ucred *cred; +nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) { - register struct nfsnode *np = VTONFS(vp); - register int biosize, i; + struct nfsnode *np = VTONFS(vp); + 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; @@ -358,11 +357,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); @@ -391,23 +390,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; @@ -422,7 +421,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); @@ -431,14 +430,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); } @@ -470,13 +469,13 @@ 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_READ | B_ASYNC); vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); brelse(rabp); @@ -509,7 +508,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 */ @@ -522,10 +521,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); @@ -537,7 +536,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); return (error); @@ -558,13 +557,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_flags |= B_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { bp->b_flags |= B_ERROR; brelse(bp); @@ -582,20 +581,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_flags |= B_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 @@ -610,13 +609,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_flags |= B_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. @@ -654,12 +653,12 @@ 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_READ | B_ASYNC); vfs_busy_pages(rabp, 0); - if (nfs_asyncio(rabp, cred, p)) { + if (nfs_asyncio(rabp, cred, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); brelse(rabp); @@ -729,7 +728,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; @@ -756,7 +755,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 @@ -765,7 +764,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); } @@ -778,7 +777,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; @@ -807,7 +806,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 */ @@ -825,11 +824,11 @@ restart: * Maybe this should be above the vnode op call, but so long as * file servers have no limits, i don't think it matters */ - if (p && uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - psignal(p, SIGXFSZ); + if (td->td_proc && uio->uio_offset + uio->uio_resid > + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + psignal(td->td_proc, SIGXFSZ); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (EFBIG); } @@ -842,13 +841,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; @@ -879,7 +878,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; @@ -905,7 +904,7 @@ again: else 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; np->n_flag |= NMODIFIED; @@ -945,7 +944,7 @@ again: if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags |= B_READ; vfs_busy_pages(bp, 0); - error = nfs_doio(bp, cred, p); + error = nfs_doio(bp, cred, td); if (error) { brelse(bp); break; @@ -1013,7 +1012,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); @@ -1022,7 +1021,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; @@ -1080,7 +1079,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; } @@ -1094,7 +1093,7 @@ again: } while (uio->uio_resid > 0 && n > 0); if (haverslock) - nfs_rsunlock(np, p); + nfs_rsunlock(np, td); return (error); } @@ -1115,11 +1114,7 @@ again: * its EOF. */ static struct buf * -nfs_getcacheblk(vp, bn, size, p) - struct vnode *vp; - daddr_t bn; - int size; - struct proc *p; +nfs_getcacheblk(struct vnode *vp, daddr_t bn, int size, struct thread *td) { register struct buf *bp; struct mount *mp; @@ -1131,7 +1126,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)) return ((struct buf *)0); bp = getblk(vp, bn, size, 0, 2 * hz); } @@ -1153,12 +1148,8 @@ nfs_getcacheblk(vp, bn, size, p) * doing the flush, just wait for completion. */ int -nfs_vinvalbuf(vp, flags, cred, p, intrflg) - struct vnode *vp; - int flags; - struct ucred *cred; - struct proc *p; - int intrflg; +nfs_vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, + struct thread *td, int intrflg) { register struct nfsnode *np = VTONFS(vp); struct nfsmount *nmp = VFSTONFS(vp->v_mount); @@ -1184,7 +1175,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)) return (EINTR); } @@ -1192,9 +1183,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)) { np->n_flag &= ~NFLUSHINPROG; if (np->n_flag & NFLUSHWANT) { np->n_flag &= ~NFLUSHWANT; @@ -1202,7 +1193,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) { @@ -1221,10 +1212,7 @@ nfs_vinvalbuf(vp, flags, cred, p, intrflg) * is eventually dequeued by the async daemon, nfs_doio() *will*. */ int -nfs_asyncio(bp, cred, procp) - register struct buf *bp; - struct ucred *cred; - struct proc *procp; +nfs_asyncio(struct buf *bp, struct ucred *cred, struct thread *td) { struct nfsmount *nmp; int i; @@ -1269,7 +1257,7 @@ again: NFS_DPF(ASYNCIO, ("nfs_asyncio: waking iod %d for mount %p\n", i, nmp)); - nfs_iodwant[i] = (struct proc *)0; + nfs_iodwant[i] = NULL; nfs_iodmount[i] = nmp; nmp->nm_bufqiods++; wakeup((caddr_t)&nfs_iodwant[i]); @@ -1306,7 +1294,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)) return (EINTR); if (slpflag == PCATCH) { slpflag = 0; @@ -1354,12 +1342,11 @@ again: /* * Do an I/O operation to/from a cache block. This may be called * synchronously or from an nfsiod. + * + * NOTE! TD MIGHT BE NULL */ int -nfs_doio(bp, cr, p) - struct buf *bp; - struct ucred *cr; - struct proc *p; +nfs_doio(struct buf *bp, struct ucred *cr, struct thread *td) { struct uio *uiop; struct vnode *vp; @@ -1376,7 +1363,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 B_ERROR and B_INVAL state prior to initiating the I/O. We @@ -1443,15 +1430,15 @@ nfs_doio(bp, cr, p) uiop->uio_resid = 0; } } - if (p && (vp->v_flag & VTEXT) && + if (td && td->td_proc && (vp->v_flag & VTEXT) && (((nmp->nm_flag & NFSMNT_NQNFS) && NQNFS_CKINVALID(vp, np, ND_READ) && np->n_lrev != np->n_brev) || (!(nmp->nm_flag & NFSMNT_NQNFS) && np->n_mtime != np->n_vattr.va_mtime.tv_sec))) { uprintf("Process killed due to text file modification\n"); - psignal(p, SIGKILL); - PHOLD(p); + psignal(td->td_proc, SIGKILL); + PHOLD(td->td_proc); } break; case VLNK: @@ -1496,7 +1483,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; @@ -1618,7 +1605,7 @@ nfs_doio(bp, cr, p) */ int -nfs_meta_setsize(struct vnode *vp, struct ucred *cred, struct proc *p, u_quad_t nsize) +nfs_meta_setsize(struct vnode *vp, struct ucred *cred, struct thread *td, u_quad_t nsize) { struct nfsnode *np = VTONFS(vp); u_quad_t tsize = np->n_size; @@ -1637,10 +1624,10 @@ nfs_meta_setsize(struct vnode *vp, struct ucred *cred, struct proc *p, u_quad_t * truncation point. We may have a B_DELWRI and/or B_CACHE * buffer that now needs to be truncated. */ - error = vtruncbuf(vp, cred, p, nsize, biosize); + error = vtruncbuf(vp, cred, td, nsize, biosize); lbn = nsize / biosize; bufsize = nsize & (biosize - 1); - bp = nfs_getcacheblk(vp, lbn, bufsize, p); + bp = nfs_getcacheblk(vp, lbn, bufsize, td); if (bp->b_dirtyoff > bp->b_bcount) bp->b_dirtyoff = bp->b_bcount; if (bp->b_dirtyend > bp->b_bcount) diff --git a/sys/vfs/nfs/nfs_node.c b/sys/vfs/nfs/nfs_node.c index e8cf5ed255..625dacab2c 100644 --- a/sys/vfs/nfs/nfs_node.c +++ b/sys/vfs/nfs/nfs_node.c @@ -35,7 +35,7 @@ * * @(#)nfs_node.c 8.6 (Berkeley) 5/22/95 * $FreeBSD: src/sys/nfs/nfs_node.c,v 1.36.2.3 2002/01/05 22:25:04 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_node.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_node.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ @@ -83,16 +83,12 @@ nfs_nhinit() static int nfs_node_hash_lock; int -nfs_nget(mntp, fhp, fhsize, npp) - struct mount *mntp; - register nfsfh_t *fhp; - int fhsize; - struct nfsnode **npp; +nfs_nget(struct mount *mntp, nfsfh_t *fhp, 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; + struct vnode *vp; struct vnode *nvp; int error; int rsflags; @@ -116,7 +112,7 @@ loop: bcmp((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize)) continue; vp = NFSTOV(np); - if (vget(vp, LK_EXCLUSIVE|LK_SLEEPFAIL, p)) + if (vget(vp, LK_EXCLUSIVE|LK_SLEEPFAIL, td)) goto loop; *npp = np; return(0); @@ -186,7 +182,7 @@ loop: /* * Lock the new nfsnode. */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); return (0); } @@ -195,12 +191,11 @@ 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 nfsnode *np; + struct sillyrename *sp; np = VTONFS(ap->a_vp); if (prtactive && ap->a_vp->v_usecount != 0) @@ -219,11 +214,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, ap->a_td, 1); + else if (vget(ap->a_vp, 0, ap->a_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, ap->a_td, 1); vrele(ap->a_vp); } /* @@ -236,7 +231,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); } @@ -377,7 +372,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/vfs/nfs/nfs_nqlease.c b/sys/vfs/nfs/nfs_nqlease.c index 864aacde82..e4330effd5 100644 --- a/sys/vfs/nfs/nfs_nqlease.c +++ b/sys/vfs/nfs/nfs_nqlease.c @@ -35,7 +35,7 @@ * * @(#)nfs_nqlease.c 8.9 (Berkeley) 5/20/95 * $FreeBSD: src/sys/nfs/nfs_nqlease.c,v 1.50 2000/02/13 03:32:05 peter Exp $ - * $DragonFly: src/sys/vfs/nfs/Attic/nfs_nqlease.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/Attic/nfs_nqlease.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ @@ -170,12 +170,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; @@ -194,7 +194,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; @@ -337,25 +337,22 @@ doreply: * OS needs. */ void -nqnfs_lease_check(vp, p, cred, flag) - struct vnode *vp; - struct proc *p; - struct ucred *cred; - int flag; +nqnfs_lease_check(struct vnode *vp, struct thread *td, + struct ucred *cred, int flag) { u_int32_t duration = 0; int cache; 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; @@ -365,7 +362,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); } @@ -721,11 +718,8 @@ nqnfs_serverd() * do the real work. */ int -nqnfsrv_getlease(nfsd, slp, procp, mrq) - struct nfsrv_descript *nfsd; - struct nfssvc_sock *slp; - struct proc *procp; - struct mbuf **mrq; +nqnfsrv_getlease(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, + struct thread *td, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct sockaddr *nam = nfsd->nd_nam; @@ -762,9 +756,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); @@ -781,11 +775,8 @@ nqnfsrv_getlease(nfsd, slp, procp, mrq) * client. Find the entry and expire it. */ int -nqnfsrv_vacated(nfsd, slp, procp, mrq) - struct nfsrv_descript *nfsd; - struct nfssvc_sock *slp; - struct proc *procp; - struct mbuf **mrq; +nqnfsrv_vacated(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, + struct thread *td, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct sockaddr *nam = nfsd->nd_nam; @@ -859,16 +850,13 @@ nfsmout: * Client get lease rpc function. */ int -nqnfs_getlease(vp, rwflag, cred, p) - register struct vnode *vp; - int rwflag; - struct ucred *cred; - struct proc *p; +nqnfs_getlease(struct vnode *vp, int rwflag, + struct ucred *cred, struct thread *td) { - register u_int32_t *tl; - register caddr_t cp; - register int32_t t1, t2; - register struct nfsnode *np; + u_int32_t *tl; + caddr_t cp; + int32_t t1, t2; + struct nfsnode *np; struct nfsmount *nmp = VFSTONFS(vp->v_mount); caddr_t bpos, dpos, cp2; time_t reqtime; @@ -885,7 +873,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++); @@ -1016,15 +1004,15 @@ nqnfs_callback(nmp, mrep, md, dpos) * the list asynchronously. */ int -nqnfs_clientd(nmp, cred, ncd, flag, argp, p) - register struct nfsmount *nmp; +nqnfs_clientd(nmp, cred, ncd, flag, argp, td) + 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 nfsnode *np; struct vnode *vp; struct nfsreq myrep; struct nfsuid *nuidp, *nnuidp; @@ -1076,7 +1064,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 = NULL; (void) nfs_reply(&myrep); } @@ -1089,7 +1077,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) { CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer); @@ -1100,12 +1088,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; } } @@ -1117,10 +1105,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; @@ -1152,7 +1140,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); } } @@ -1178,10 +1166,9 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p) * Called from the settimeofday() syscall. */ void -nqnfs_lease_updatetime(deltat) - register int deltat; +nqnfs_lease_updatetime(int deltat) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct nqlease *lp; struct nfsnode *np; struct mount *mp, *nxtmp; @@ -1202,7 +1189,7 @@ nqnfs_lease_updatetime(deltat) */ simple_lock(&mountlist_slock); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nxtmp) { - if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) { + if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, td)) { nxtmp = TAILQ_NEXT(mp, mnt_list); continue; } @@ -1218,7 +1205,7 @@ nqnfs_lease_updatetime(deltat) } simple_lock(&mountlist_slock); nxtmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp, p); + vfs_unbusy(mp, td); } simple_unlock(&mountlist_slock); } diff --git a/sys/vfs/nfs/nfs_serv.c b/sys/vfs/nfs/nfs_serv.c index 0e6fbe41fc..5fe53d5467 100644 --- a/sys/vfs/nfs/nfs_serv.c +++ b/sys/vfs/nfs/nfs_serv.c @@ -35,7 +35,7 @@ * * @(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 * $FreeBSD: src/sys/nfs/nfs_serv.c,v 1.93.2.6 2002/12/29 18:19:53 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_serv.c,v 1.4 2003/06/23 17:55:48 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_serv.c,v 1.5 2003/06/25 03:56:07 dillon Exp $ */ /* @@ -148,7 +148,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 *)); @@ -171,11 +171,8 @@ ndclear(struct nameidata *nd) * nfs v3 access service */ int -nfsrv3_access(nfsd, slp, procp, mrq) - struct nfsrv_descript *nfsd; - struct nfssvc_sock *slp; - struct proc *procp; - struct mbuf **mrq; +nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, + struct thread *td, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct sockaddr *nam = nfsd->nd_nam; @@ -184,8 +181,8 @@ nfsrv3_access(nfsd, slp, procp, mrq) struct vnode *vp = NULL; nfsfh_t nfh; fhandle_t *fhp; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, getret; char *cp2; @@ -211,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 | @@ -219,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); @@ -245,24 +242,24 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct nfs_fattr *fp; + struct nfs_fattr *fp; struct vattr va; - register struct vattr *vap = &va; + struct vattr *vap = &va; struct vnode *vp = NULL; nfsfh_t nfh; fhandle_t *fhp; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache; char *cp2; @@ -280,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)); @@ -302,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; @@ -313,14 +310,14 @@ nfsrv_setattr(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, preat; - register struct vattr *vap = &va; - register struct nfsv2_sattr *sp; - register struct nfs_fattr *fp; + struct vattr *vap = &va; + struct nfsv2_sattr *sp; + struct nfs_fattr *fp; struct vnode *vp = NULL; nfsfh_t nfh; fhandle_t *fhp; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, preat_ret = 1, postat_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0; @@ -390,7 +387,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)) @@ -419,11 +416,12 @@ 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: @@ -450,24 +448,24 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct nfs_fattr *fp; + struct nfs_fattr *fp; struct nameidata nd, ind, *ndp = &nd; struct vnode *vp, *dirp = NULL; nfsfh_t nfh; fhandle_t *fhp; - register caddr_t cp; - register u_int32_t *tl; - register int32_t t1; + caddr_t cp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, cache, len, dirattr_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag; @@ -489,7 +487,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 @@ -500,7 +498,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -532,7 +530,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; @@ -574,7 +572,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, - procp); + td); vrele(dirp); dirp = NULL; } @@ -612,7 +610,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; @@ -646,10 +644,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; @@ -657,10 +655,10 @@ nfsrv_readlink(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN]; - register struct iovec *ivp = iv; - register struct mbuf *mp; - register u_int32_t *tl; - register int32_t t1; + struct iovec *ivp = iv; + struct mbuf *mp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, i, tlen, len, getret; int v3 = (nfsd->nd_flag & ND_NFSV3); @@ -708,7 +706,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 = NULL; error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE); if (error) { @@ -727,7 +725,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); @@ -759,23 +757,23 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct iovec *iv; + struct iovec *iv; struct iovec *iv2; - register struct mbuf *m; - register struct nfs_fattr *fp; - register u_int32_t *tl; - register int32_t t1; - register int i; + struct mbuf *m; + struct nfs_fattr *fp; + u_int32_t *tl; + int32_t t1; + int i; caddr_t bpos; int error = 0, rdonly, cache, cnt, len, left, siz, tlen, getret; int v3 = (nfsd->nd_flag & ND_NFSV3), reqlen; @@ -828,10 +826,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) { @@ -970,7 +968,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); @@ -1010,25 +1008,25 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct iovec *ivp; - register int i, cnt; - register struct mbuf *mp; - register struct nfs_fattr *fp; + struct iovec *ivp; + int i, cnt; + struct mbuf *mp; + struct nfs_fattr *fp; struct iovec *iv; struct vattr va, forat; - register struct vattr *vap = &va; - register u_int32_t *tl; - register int32_t t1; + struct vattr *vap = &va; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, len, forat_ret = 1; int ioflags, aftat_ret = 1, retlen, zeroing, adjust; @@ -1113,7 +1111,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; @@ -1122,7 +1120,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); @@ -1164,13 +1162,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 = NULL; 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) @@ -1219,23 +1217,23 @@ 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; - register struct mbuf *mp; - register struct nfsrv_descript *wp, *nfsd, *owp, *swp; - register struct nfs_fattr *fp; - register int i; + struct iovec *ivp; + struct mbuf *mp; + struct nfsrv_descript *wp, *nfsd, *owp, *swp; + struct nfs_fattr *fp; + int i; struct iovec *iov; struct nfsrvw_delayhash *wpp; struct ucred *cred; struct vattr va, forat; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos, dpos; int error = 0, rdonly, cache, len, forat_ret = 1; int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; @@ -1399,7 +1397,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; @@ -1411,7 +1409,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) @@ -1422,7 +1420,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 = NULL; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; if (uiop->uio_resid > 0) { @@ -1454,7 +1452,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; } @@ -1546,12 +1544,10 @@ loop1: * NB: Must be called at splsoftclock(). */ static void -nfsrvw_coalesce(owp, nfsd) - register struct nfsrv_descript *owp; - register struct nfsrv_descript *nfsd; +nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) { - register int overlap; - register struct mbuf *mp; + int overlap; + struct mbuf *mp; struct nfsrv_descript *p; NFS_DPF(WG, ("C%03x-%03x", @@ -1595,23 +1591,23 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct nfs_fattr *fp; + struct nfs_fattr *fp; struct vattr va, dirfor, diraft; - register struct vattr *vap = &va; - register struct nfsv2_sattr *sp; - register u_int32_t *tl; + struct vattr *vap = &va; + struct nfsv2_sattr *sp; + u_int32_t *tl; struct nameidata nd; - register int32_t t1; + int32_t t1; caddr_t bpos; int error = 0, rdev, cache, len, tsize, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0; @@ -1648,11 +1644,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; @@ -1745,7 +1741,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 ( @@ -1760,7 +1756,7 @@ nfsrv_create(nfsd, slp, procp, mrq) if (vap->va_type == VCHR && rdev == 0xffffffff) vap->va_type = VFIFO; if (vap->va_type != VFIFO && - (error = suser_xxx(cred, 0))) { + (error = suser_cred(cred, 0))) { goto nfsmreply0; } vap->va_rdev = rdev; @@ -1788,7 +1784,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_td = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -1809,14 +1805,13 @@ 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); + error = VOP_SETATTR(nd.ni_vp, vap, cred, td); } } } @@ -1826,13 +1821,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; } @@ -1879,10 +1874,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; @@ -1890,10 +1885,10 @@ nfsrv_mknod(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; - register struct vattr *vap = &va; - register u_int32_t *tl; + struct vattr *vap = &va; + u_int32_t *tl; struct nameidata nd; - register int32_t t1; + int32_t t1; caddr_t bpos; int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; u_int32_t major, minor; @@ -1923,9 +1918,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); @@ -1965,7 +1960,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq) if (error) NDFREE(&nd, NDF_ONLY_PNBUF); } else { - if (vtyp != VFIFO && (error = suser_xxx(cred, 0))) + if (vtyp != VFIFO && (error = suser_cred(cred, 0))) goto out; nqsrv_getl(nd.ni_dvp, ND_WRITE); @@ -1983,10 +1978,11 @@ nfsrv_mknod(nfsd, slp, procp, mrq) vput(nd.ni_dvp); nd.ni_dvp = NULL; + KKASSERT(td->td_proc); 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_td = td; + nd.ni_cnd.cn_cred = td->td_proc->p_ucred; error = lookup(&nd); nd.ni_dvp = NULL; @@ -2019,14 +2015,14 @@ 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); } if (vp) { 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; @@ -2059,10 +2055,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; @@ -2070,8 +2066,8 @@ nfsrv_remove(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nameidata nd; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); @@ -2094,11 +2090,10 @@ 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); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); } else { vrele(dirp); dirp = NULL; @@ -2125,7 +2120,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; } @@ -2151,18 +2146,18 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, cache, len, len2, fdirfor_ret = 1, fdiraft_ret = 1; int tdirfor_ret = 1, tdiraft_ret = 1; @@ -2203,11 +2198,10 @@ 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); + fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, td); } else { vrele(fdirp); fdirp = NULL; @@ -2228,11 +2222,10 @@ 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); + tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, td); } else { vrele(tdirp); tdirp = NULL; @@ -2325,9 +2318,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); @@ -2374,10 +2367,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; @@ -2385,8 +2378,8 @@ nfsrv_link(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nameidata nd; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, len, dirfor_ret = 1, diraft_ret = 1; int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3); @@ -2425,11 +2418,10 @@ 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); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); } else { vrele(dirp); dirp = NULL; @@ -2457,9 +2449,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); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { nfsm_srvpostop_attr(getret, &at); @@ -2489,10 +2481,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; @@ -2501,9 +2493,9 @@ nfsrv_symlink(nfsd, slp, procp, mrq) struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nameidata nd; - register struct vattr *vap = &va; - register u_int32_t *tl; - register int32_t t1; + struct vattr *vap = &va; + u_int32_t *tl; + int32_t t1; struct nfsv2_sattr *sp; char *bpos, *pathcp = (char *)0, *cp2; struct uio io; @@ -2526,11 +2518,10 @@ 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); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); } else { vrele(dirp); dirp = NULL; @@ -2552,7 +2543,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 = NULL; nfsm_mtouio(&io, len2); if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -2595,7 +2586,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_td = td; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); @@ -2606,8 +2597,7 @@ nfsrv_symlink(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); vput(nd.ni_vp); nd.ni_vp = NULL; } @@ -2623,7 +2613,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; } @@ -2666,10 +2656,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; @@ -2677,12 +2667,12 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; - register struct vattr *vap = &va; - register struct nfs_fattr *fp; + struct vattr *vap = &va; + struct nfs_fattr *fp; struct nameidata nd; - register caddr_t cp; - register u_int32_t *tl; - register int32_t t1; + caddr_t cp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); @@ -2705,11 +2695,10 @@ 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); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); } else { vrele(dirp); dirp = NULL; @@ -2761,11 +2750,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) { @@ -2804,18 +2793,18 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); @@ -2838,11 +2827,10 @@ 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); + dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, td); } else { vrele(dirp); dirp = NULL; @@ -2884,7 +2872,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); @@ -2947,22 +2935,22 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register char *bp, *be; - register struct mbuf *mp; - register struct dirent *dp; - register caddr_t cp; - register u_int32_t *tl; - register int32_t t1; + char *bp, *be; + struct mbuf *mp; + struct dirent *dp; + caddr_t cp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; struct mbuf *mb, *mb2, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; @@ -3021,7 +3009,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. @@ -3031,7 +3019,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; @@ -3040,7 +3028,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 @@ -3055,9 +3043,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 = NULL; 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; @@ -3067,11 +3055,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; @@ -3242,22 +3230,22 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register char *bp, *be; - register struct mbuf *mp; - register struct dirent *dp; - register caddr_t cp; - register u_int32_t *tl; - register int32_t t1; + char *bp, *be; + struct mbuf *mp; + struct dirent *dp; + caddr_t cp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; struct mbuf *mb, *mb2, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; @@ -3305,7 +3293,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. @@ -3315,7 +3303,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); @@ -3325,7 +3313,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; @@ -3336,17 +3324,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 = NULL; 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) @@ -3463,7 +3451,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; @@ -3581,10 +3569,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; @@ -3595,8 +3583,8 @@ nfsrv_commit(nfsd, slp, procp, mrq) struct vnode *vp = NULL; nfsfh_t nfh; fhandle_t *fhp; - register u_int32_t *tl; - register int32_t t1; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt, cache; char *cp2; @@ -3626,7 +3614,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) { /* @@ -3636,7 +3624,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 @@ -3694,7 +3682,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; nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF); @@ -3718,20 +3706,20 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register struct statfs *sf; - register struct nfs_statfs *sfp; - register u_int32_t *tl; - register int32_t t1; + struct statfs *sf; + struct nfs_statfs *sfp; + u_int32_t *tl; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, getret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); @@ -3759,8 +3747,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)); @@ -3805,19 +3793,19 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register u_int32_t *tl; - register struct nfsv3_fsinfo *sip; - register int32_t t1; + u_int32_t *tl; + struct nfsv3_fsinfo *sip; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, getret = 1, pref; char *cp2; @@ -3845,10 +3833,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); @@ -3887,19 +3875,19 @@ 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; struct sockaddr *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; - register u_int32_t *tl; - register struct nfsv3_pathconf *pc; - register int32_t t1; + u_int32_t *tl; + struct nfsv3_pathconf *pc; + int32_t t1; caddr_t bpos; int error = 0, rdonly, cache, getret = 1; register_t linkmax, namemax, chownres, notrunc; @@ -3932,7 +3920,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); @@ -3966,10 +3954,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; @@ -3991,10 +3979,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; @@ -4031,13 +4019,8 @@ 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) - register struct vnode *vp; - int flags; - register struct ucred *cred; - int rdonly; - struct proc *p; - int override; +nfsrv_access(struct vnode *vp, int flags, struct ucred *cred, + int rdonly, struct thread *td, int override) { struct vattr vattr; int error; @@ -4067,10 +4050,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/vfs/nfs/nfs_socket.c b/sys/vfs/nfs/nfs_socket.c index dc9ca0969c..81aee3f9f3 100644 --- a/sys/vfs/nfs/nfs_socket.c +++ b/sys/vfs/nfs/nfs_socket.c @@ -35,7 +35,7 @@ * * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nfs_socket.c,v 1.60.2.6 2003/03/26 01:44:46 alfred Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_socket.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_socket.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ /* @@ -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, @@ -198,21 +198,19 @@ int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd, * We do not free the sockaddr if error. */ int -nfs_connect(nmp, rep) - register struct nfsmount *nmp; - struct nfsreq *rep; +nfs_connect(struct nfsmount *nmp, struct nfsreq *rep) { - register struct socket *so; + struct socket *so; int s, error, rcvreserve, sndreserve; 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 +231,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 +241,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 +251,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 +267,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 +282,7 @@ 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)) != 0){ so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -483,8 +481,8 @@ nfs_send(so, nam, top, rep) else flags = 0; - error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0, - flags, curproc /*XXX*/); + error = so->so_proto->pr_usrreqs->pru_sosend + (so, sendnam, 0, top, 0, flags, curthread /*XXX*/); /* * ENOBUFS for dgram sockets is transient and non fatal. * No need to log, and no need to break a soft mount. @@ -529,10 +527,7 @@ nfs_send(so, nam, top, rep) * we have read any of it, even if the system call has been interrupted. */ static int -nfs_receive(rep, aname, mp) - register struct nfsreq *rep; - struct sockaddr **aname; - struct mbuf **mp; +nfs_receive(struct nfsreq *rep, struct sockaddr **aname, struct mbuf **mp) { register struct socket *so; struct uio auio; @@ -542,7 +537,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() @@ -609,7 +604,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 @@ -677,7 +672,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 @@ -723,7 +718,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 @@ -933,11 +928,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; @@ -970,7 +965,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; @@ -1101,7 +1096,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; @@ -1395,14 +1390,14 @@ 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)) { nfs_softterm(rep); continue; } @@ -1424,7 +1419,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; @@ -1456,11 +1451,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; @@ -1568,12 +1563,10 @@ nfs_softterm(rep) * This is used for NFSMNT_INT mounts. */ int -nfs_sigintr(nmp, rep, p) - struct nfsmount *nmp; - struct nfsreq *rep; - register struct proc *p; +nfs_sigintr(struct nfsmount *nmp, struct nfsreq *rep, struct thread *td) { sigset_t tmpset; + struct proc *p; if (rep && (rep->r_flags & R_SOFTTERM)) return (EINTR); @@ -1582,7 +1575,8 @@ nfs_sigintr(nmp, rep, p) return (EINTR); if (!(nmp->nm_flag & NFSMNT_INT)) return (0); - if (p == NULL) + KKASSERT(td); + if ((p = td->td_proc) == NULL) return (0); tmpset = p->p_siglist; @@ -1601,18 +1595,17 @@ nfs_sigintr(nmp, rep, p) * in progress when a reconnect is necessary. */ int -nfs_sndlock(rep) - struct nfsreq *rep; +nfs_sndlock(struct nfsreq *rep) { - register int *statep = &rep->r_nmp->nm_state; - struct proc *p; + int *statep = &rep->r_nmp->nm_state; + struct thread *td; int slpflag = 0, slptimeo = 0; - p = rep->r_procp; + td = rep->r_td; if (rep->r_nmp->nm_flag & NFSMNT_INT) slpflag = PCATCH; while (*statep & NFSSTA_SNDLOCK) { - if (nfs_sigintr(rep->r_nmp, rep, p)) + if (nfs_sigintr(rep->r_nmp, rep, td)) return (EINTR); *statep |= NFSSTA_WANTSND; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), @@ -1659,7 +1652,7 @@ 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)) return (EINTR); *statep |= NFSSTA_WANTRCV; (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk", @@ -2005,14 +1998,12 @@ nfsmout: #endif static int -nfs_msg(p, server, msg) - struct proc *p; - char *server, *msg; +nfs_msg(struct thread *td, char *server, char *msg) { tpr_t tpr; - if (p) - tpr = tprintf_open(p); + if (td->td_proc) + tpr = tprintf_open(td->td_proc); else tpr = NULL; tprintf(tpr, "nfs server %s: %s\n", server, msg); @@ -2050,7 +2041,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/vfs/nfs/nfs_subs.c b/sys/vfs/nfs/nfs_subs.c index 62eb7577c5..1926754b32 100644 --- a/sys/vfs/nfs/nfs_subs.c +++ b/sys/vfs/nfs/nfs_subs.c @@ -35,7 +35,7 @@ * * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95 * $FreeBSD: src/sys/nfs/nfs_subs.c,v 1.90.2.2 2001/10/25 19:18:53 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_subs.c,v 1.3 2003/06/19 01:55:07 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_subs.c,v 1.4 2003/06/25 03:56:07 dillon Exp $ */ /* @@ -1128,7 +1128,7 @@ nfs_init(vfsp) nfs_ticks = 1; /* Ensure async daemons disabled */ for (i = 0; i < NFS_MAXASYNCDAEMON; i++) { - nfs_iodwant[i] = (struct proc *)0; + nfs_iodwant[i] = NULL; nfs_iodmount[i] = (struct nfsmount *)0; } nfs_nhinit(); /* Init the nfsnode table */ @@ -1466,7 +1466,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; @@ -1475,7 +1475,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; @@ -1615,7 +1615,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_td = td; VREF(dp); ndp->ni_startdir = dp; @@ -1651,7 +1651,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; @@ -1672,7 +1672,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 = NULL; auio.uio_resid = MAXPATHLEN; error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); if (error) { @@ -1926,7 +1926,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; @@ -1990,7 +1990,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); } @@ -2188,14 +2188,14 @@ nfsrv_errmap(nd, err) } int -nfsrv_object_create(vp) - struct vnode *vp; +nfsrv_object_create(struct vnode *vp) { + struct thread *td = curthread; + struct proc *p = td->td_proc; 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, td, p ? p->p_ucred : NULL)); } /* diff --git a/sys/vfs/nfs/nfs_syscalls.c b/sys/vfs/nfs/nfs_syscalls.c index aca18bacae..bfa95e0103 100644 --- a/sys/vfs/nfs/nfs_syscalls.c +++ b/sys/vfs/nfs/nfs_syscalls.c @@ -35,7 +35,7 @@ * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nfs_syscalls.c,v 1.58.2.1 2000/11/26 02:30:06 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_syscalls.c,v 1.3 2003/06/23 17:55:48 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_syscalls.c,v 1.4 2003/06/25 03:56:07 dillon Exp $ */ #include @@ -76,7 +76,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; @@ -90,7 +90,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 @@ -108,8 +108,8 @@ 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, ""); @@ -146,20 +146,21 @@ nfssvc(struct nfssvc_args *uap) struct nfsmount *nmp; #endif /* NFS_NOSERVER */ int error; - struct proc *p = curproc; + struct thread *td = curthread; /* * Must be super user */ - error = suser(); + error = suser(td); if(error) return (error); + KKASSERT(td->td_proc); /* for ucred and p_fd */ while (nfssvc_sockhead_flag & SLP_INIT) { nfssvc_sockhead_flag |= SLP_WANTINIT; (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; @@ -169,7 +170,7 @@ nfssvc(struct nfssvc_args *uap) if (error) return (error); NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - ncd.ncd_dirp, p); + ncd.ncd_dirp, td); error = namei(&nd); if (error) return (error); @@ -184,13 +185,13 @@ nfssvc(struct nfssvc_args *uap) (uap->flag & NFSSVC_GOTAUTH) == 0) return (0); 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) return (error); - error = holdsock(p->p_fd, nfsdarg.sock, &fp); + error = holdsock(td->td_proc->p_fd, nfsdarg.sock, &fp); if (error) return (error); /* @@ -202,12 +203,12 @@ nfssvc(struct nfssvc_args *uap) error = getsockaddr(&nam, nfsdarg.name, nfsdarg.namelen); if (error) { - fdrop(fp, p); + fdrop(fp, td); return (error); } } - 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) @@ -299,7 +300,7 @@ nfssvc(struct nfssvc_args *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) @@ -312,14 +313,11 @@ nfssvc(struct nfssvc_args *uap) * Adds a socket to the list for servicing by nfsds. */ static int -nfssvc_addsock(fp, mynam, p) - struct file *fp; - struct sockaddr *mynam; - struct proc *p; +nfssvc_addsock(struct file *fp, struct sockaddr *mynam, struct thread *td) { - register int siz; - register struct nfssvc_sock *slp; - register struct socket *so; + int siz; + struct nfssvc_sock *slp; + struct socket *so; int error, s; so = (struct socket *)fp->f_data; @@ -409,13 +407,10 @@ nfssvc_addsock(fp, mynam, p) * until it is killed by a signal. */ static int -nfssvc_nfsd(nsd, argp, p) - struct nfsd_srvargs *nsd; - caddr_t argp; - struct proc *p; +nfssvc_nfsd(struct nfsd_srvargs *nsd, caddr_t argp, struct thread *td) { - register int siz; - register struct nfssvc_sock *slp; + int siz; + struct nfssvc_sock *slp; struct nfsd *nfsd = nsd->nsd_nfsd; struct nfsrv_descript *nd = NULL; struct mbuf *m, *mreq; @@ -432,7 +427,7 @@ nfssvc_nfsd(nsd, argp, p) malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK); bzero((caddr_t)nfsd, sizeof (struct nfsd)); s = splnet(); - nfsd->nfsd_procp = p; + nfsd->nfsd_td = td; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); nfs_numnfsd++; } else @@ -593,10 +588,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) { @@ -728,7 +723,7 @@ nfsrv_zapsock(slp) so->so_upcall = NULL; so->so_upcallarg = NULL; soshutdown(so, 2); - closef(fp, (struct proc *)0); + closef(fp, NULL); if (slp->ns_nam) FREE(slp->ns_nam, M_SONAME); m_freem(slp->ns_raw); @@ -908,8 +903,7 @@ 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(struct thread *td) { register struct buf *bp; register int i, myiod; @@ -938,7 +932,7 @@ nfssvc_iod(p) && error == 0) { if (nmp) nmp->nm_bufqiods--; - nfs_iodwant[myiod] = p; + nfs_iodwant[myiod] = td; nfs_iodmount[myiod] = NULL; error = tsleep((caddr_t)&nfs_iodwant[myiod], PWAIT | PCATCH, "nfsidl", 0); @@ -961,9 +955,9 @@ nfssvc_iod(p) wakeup(&nmp->nm_bufq); } if (bp->b_flags & B_READ) - (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_rcred, NULL); else - (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); + (void) nfs_doio(bp, bp->b_wcred, NULL); /* * If there are more than one iod on this mount, then defect * so that the iods can be shared out fairly between the mounts @@ -1002,7 +996,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); if (error) { nmp->nm_state &= ~NFSSTA_WANTAUTH; return (error); @@ -1022,7 +1016,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); } if (nmp->nm_state & NFSSTA_AUTHERR) { nmp->nm_state &= ~NFSSTA_AUTHERR; diff --git a/sys/vfs/nfs/nfs_vfsops.c b/sys/vfs/nfs/nfs_vfsops.c index 59ccfb0512..72788480dd 100644 --- a/sys/vfs/nfs/nfs_vfsops.c +++ b/sys/vfs/nfs/nfs_vfsops.c @@ -35,7 +35,7 @@ * * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95 * $FreeBSD: src/sys/nfs/nfs_vfsops.c,v 1.91.2.7 2003/01/27 20:04:08 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_vfsops.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_vfsops.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #include "opt_bootp.h" @@ -104,14 +104,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 *td)); static int nfs_unmount __P(( struct mount *mp, int mntflags, - struct proc *p)); + struct thread *td)); 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 *td)); static int nfs_sync __P(( struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); + struct ucred *cred, struct thread *td)); /* * nfs vfs operations. @@ -164,7 +164,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, @@ -244,10 +244,7 @@ nfs_convert_diskless() * nfs statfs call */ int -nfs_statfs(mp, sbp, p) - struct mount *mp; - register struct statfs *sbp; - struct proc *p; +nfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { register struct vnode *vp; register struct nfs_statfs *sfp; @@ -272,11 +269,11 @@ nfs_statfs(mp, sbp, p) cred = crget(); cred->cr_ngroups = 1; if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) - (void)nfs_fsinfo(nmp, vp, cred, p); + (void)nfs_fsinfo(nmp, vp, cred, td); nfsstats.rpccnt[NFSPROC_FSSTAT]++; nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3)); nfsm_fhtom(vp, v3); - nfsm_request(vp, NFSPROC_FSSTAT, p, cred); + nfsm_request(vp, NFSPROC_FSSTAT, td, cred); if (v3) nfsm_postop_attr(vp, retattr); if (error) { @@ -322,11 +319,8 @@ nfs_statfs(mp, sbp, p) * nfs version 3 fsinfo rpc call */ int -nfs_fsinfo(nmp, vp, cred, p) - register struct nfsmount *nmp; - register struct vnode *vp; - struct ucred *cred; - struct proc *p; +nfs_fsinfo(struct nfsmount *nmp, struct vnode *vp, + struct ucred *cred, struct thread *td) { register struct nfsv3_fsinfo *fsp; register caddr_t cp; @@ -340,7 +334,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); @@ -401,7 +395,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]; @@ -440,7 +434,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); @@ -456,12 +450,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); @@ -495,7 +489,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); @@ -521,9 +515,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 ; @@ -535,13 +529,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 @@ -561,15 +555,9 @@ nfs_mountroot(mp) * Internal version of mount system call for diskless setup. */ static int -nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp) - char *path; - char *which; - int mountflag; - struct sockaddr_in *sin; - struct nfs_args *args; - struct proc *p; - struct vnode **vpp; - struct mount **mpp; +nfs_mountdiskless(char *path, char *which, int mountflag, + struct sockaddr_in *sin, struct nfs_args *args, struct thread *td, + struct vnode **vpp, struct mount **mpp) { struct mount *mp; struct sockaddr *nam; @@ -592,7 +580,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); if (didalloc) free(mp, M_MOUNT); FREE(nam, M_SONAME); @@ -762,12 +750,8 @@ nfs_decode_args(nmp, argp) */ /* ARGSUSED */ static int -nfs_mount(mp, path, data, ndp, p) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; +nfs_mount(struct mount *mp, char *path, caddr_t data, + struct nameidata *ndp, struct thread *td) { int error; struct nfs_args args; @@ -854,12 +838,8 @@ nfs_mount(mp, path, data, ndp, p) * Common code for mount and mountroot */ static int -mountnfs(argp, mp, nam, pth, hst, vpp) - register struct nfs_args *argp; - register struct mount *mp; - struct sockaddr *nam; - char *pth, *hst; - struct vnode **vpp; +mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, + char *pth, char *hst, struct vnode **vpp) { register struct nfsmount *nmp; struct nfsnode *np; @@ -958,12 +938,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, curproc->p_ucred, curthread); /* * Lose the lock but keep the ref. */ - VOP_UNLOCK(*vpp, 0, curproc); + VOP_UNLOCK(*vpp, 0, curthread); return (0); bad: @@ -977,10 +957,7 @@ bad: * unmount system call */ static int -nfs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; +nfs_unmount(struct mount *mp, int mntflags, struct thread *td) { register struct nfsmount *nmp; int error, flags = 0; @@ -1061,13 +1038,9 @@ extern int syncprt; */ /* ARGSUSED */ static int -nfs_sync(mp, waitfor, cred, p) - struct mount *mp; - int waitfor; - struct ucred *cred; - struct proc *p; +nfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td) { - register struct vnode *vp; + struct vnode *vp; int error, allerror = 0; /* @@ -1086,9 +1059,9 @@ loop: if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY) continue; - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) 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/vfs/nfs/nfs_vnops.c b/sys/vfs/nfs/nfs_vnops.c index cafbc346de..0bac6450eb 100644 --- a/sys/vfs/nfs/nfs_vnops.c +++ b/sys/vfs/nfs/nfs_vnops.c @@ -35,7 +35,7 @@ * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 * $FreeBSD: src/sys/nfs/nfs_vnops.c,v 1.150.2.5 2001/12/20 19:56:28 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.3 2003/06/19 01:55:07 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.4 2003/06/25 03:56:07 dillon Exp $ */ @@ -105,8 +105,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 *)); @@ -128,7 +128,7 @@ static int nfs_readdir __P((struct vop_readdir_args *)); static int nfs_bmap __P((struct vop_bmap_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 *)); @@ -233,11 +233,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)); @@ -249,7 +249,7 @@ extern u_int32_t nfs_true, nfs_false; extern u_int32_t nfs_xdrneg1; extern struct nfsstats nfsstats; extern nfstype nfsv3_type[9]; -struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON]; +struct thread *nfs_iodwant[NFS_MAXASYNCDAEMON]; struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; int nfs_numasync = 0; #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) @@ -275,10 +275,8 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, | NFSV3ACCESS_EXTEND | NFSV3ACCESS_EXECUTE \ | NFSV3ACCESS_DELETE | NFSV3ACCESS_LOOKUP) static int -nfs3_access_otw(struct vnode *vp, - int wmode, - struct proc *p, - struct ucred *cred) +nfs3_access_otw(struct vnode *vp, int wmode, + struct thread *td, struct ucred *cred) { const int v3 = 1; u_int32_t *tl; @@ -296,7 +294,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); @@ -321,7 +319,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; @@ -392,7 +390,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; @@ -425,7 +423,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); @@ -459,7 +457,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; @@ -481,14 +479,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; } @@ -496,24 +494,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; } @@ -562,7 +560,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; @@ -587,10 +585,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; } @@ -611,7 +609,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; @@ -637,7 +635,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); } @@ -645,7 +643,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); } @@ -663,7 +661,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; @@ -723,15 +721,15 @@ nfs_setattr(ap) tsize = np->n_size; error = nfs_meta_setsize(vp, ap->a_cred, - ap->a_p, vap->va_size); + ap->a_td, vap->va_size); 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) { np->n_size = tsize; vnode_pager_setsize(vp, np->n_size); @@ -744,9 +742,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); @@ -758,11 +756,8 @@ nfs_setattr(ap) * Do an nfs setattr rpc. */ static int -nfs_setattrrpc(vp, vap, cred, procp) - register struct vnode *vp; - register struct vattr *vap; - struct ucred *cred; - struct proc *procp; +nfs_setattrrpc(struct vnode *vp, struct vattr *vap, + struct ucred *cred, struct thread *td) { register struct nfsv2_sattr *sp; register caddr_t cp; @@ -798,7 +793,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 @@ -837,7 +832,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_td; *vpp = NULLVP; if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) && @@ -853,7 +848,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); } @@ -868,18 +863,18 @@ nfs_lookup(ap) VREF(newvp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); - error = vget(newvp, LK_EXCLUSIVE, p); + VOP_UNLOCK(dvp, 0, td); + 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); } 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); } 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 && @@ -891,9 +886,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) return (error); @@ -907,7 +902,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_td, cnp->cn_cred); if (error) { nfsm_postop_attr(dvp, attrflag); m_freem(mrep); @@ -938,20 +933,20 @@ nfs_lookup(ap) m_freem(mrep); 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); + 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))) { vput(newvp); return (error); } @@ -965,7 +960,7 @@ nfs_lookup(ap) return (error); } if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); newvp = NFSTOV(np); } if (v3) { @@ -990,7 +985,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); if (dvp->v_mount->mnt_flag & MNT_RDONLY) error = EROFS; else @@ -1061,7 +1056,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 +1112,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) { @@ -1197,7 +1192,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); @@ -1290,7 +1285,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_td)) != 0) { return (error); } nfsstats.rpccnt[NFSPROC_MKNOD]++; @@ -1316,7 +1311,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_td, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1325,7 +1320,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_td, &np); if (!error) newvp = NFSTOV(np); } @@ -1398,7 +1393,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_td)) != 0) { return (error); } if (vap->va_vaflags & VA_EXCLUSIVE) @@ -1434,7 +1429,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_td, cnp->cn_cred); if (!error) { nfsm_mtofh(dvp, newvp, v3, gotvp); if (!gotvp) { @@ -1443,7 +1438,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_td, &np); if (!error) newvp = NFSTOV(np); } @@ -1471,7 +1466,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_td); } if (!error) { if (cnp->cn_flags & MAKEENTRY) @@ -1520,7 +1515,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_td) == 0 && vattr.va_nlink > 1)) { /* * Purge the name cache so that the chance of a lookup for @@ -1534,11 +1529,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_td, 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_td); /* * Kludge City: If the first reply to the remove rpc is lost.. * the reply to the retransmitted request will be ENOENT @@ -1557,24 +1552,23 @@ nfs_remove(ap) * nfs file remove rpc called from nfs_inactive */ int -nfs_removeit(sp) - register struct sillyrename *sp; +nfs_removeit(struct sillyrename *sp) { - return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, sp->s_cred, - (struct proc *)0)); + return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, + sp->s_cred, NULL)); } /* * Nfs remove rpc, called from nfs_remove() and nfs_removeit(). */ static int -nfs_removerpc(dvp, name, namelen, cred, proc) - register struct vnode *dvp; +nfs_removerpc(dvp, name, namelen, cred, td) + 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; @@ -1589,7 +1583,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; @@ -1642,9 +1636,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_td); if (tvp) - VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc); + VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_td); /* * If the tvp exists and is in use, sillyrename it before doing the @@ -1659,7 +1653,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_td); if (fvp->v_type == VDIR) { if (tvp != NULL && tvp->v_type == VDIR) @@ -1694,22 +1688,22 @@ 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_td)); } /* * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit(). */ static int -nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) - register struct vnode *fdvp; +nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, td) + struct vnode *fdvp; const char *fnameptr; int fnamelen; register struct vnode *tdvp; const char *tnameptr; int tnamelen; struct ucred *cred; - struct proc *proc; + struct thread *td; { register u_int32_t *tl; register caddr_t cp; @@ -1727,7 +1721,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); @@ -1773,7 +1767,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_td); v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; @@ -1782,7 +1776,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_td, cnp->cn_cred); if (v3) { nfsm_postop_attr(vp, attrflag); nfsm_wcc_data(tdvp, wccflag); @@ -1854,7 +1848,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_td, cnp->cn_cred); if (v3) { if (error == 0) nfsm_mtofh(dvp, newvp, v3, gotvp); @@ -1884,7 +1878,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_td, &np); if (!error) newvp = NFSTOV(np); } @@ -1929,7 +1923,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_td)) != 0) { return (error); } len = cnp->cn_namelen; @@ -1949,7 +1943,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_td, cnp->cn_cred); if (!error) nfsm_mtofh(dvp, newvp, v3, gotvp); if (v3) @@ -1968,7 +1962,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_td, &np); if (!error) { newvp = NFSTOV(np); if (newvp->v_type != VDIR) @@ -2012,7 +2006,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_td, cnp->cn_cred); if (v3) nfsm_wcc_data(dvp, wccflag); nfsm_reqdone; @@ -2058,7 +2052,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); @@ -2138,7 +2132,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) { @@ -2328,7 +2322,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); @@ -2512,7 +2506,6 @@ nfs_sillyrename(dvp, vp, cnp) register struct sillyrename *sp; struct nfsnode *np; int error; - short pid; cache_purge(dvp); np = VTONFS(vp); @@ -2527,12 +2520,11 @@ nfs_sillyrename(dvp, vp, cnp) VREF(dvp); /* Fudge together a funny name */ - pid = cnp->cn_proc->p_pid; - sp->s_namlen = sprintf(sp->s_name, ".nfsA%04x4.4", pid); + sp->s_namlen = sprintf(sp->s_name, ".nfsA%08x4.4", (int)cnp->cn_td); /* 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_td, (struct nfsnode **)0) == 0) { sp->s_name[4]++; if (sp->s_name[4] > 'z') { error = EINVAL; @@ -2543,7 +2535,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_td, &np); np->n_sillyrename = sp; return (0); bad: @@ -2562,12 +2554,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; @@ -2586,7 +2578,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) { @@ -2642,12 +2634,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; @@ -2666,7 +2658,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); @@ -2726,7 +2718,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)); @@ -2736,9 +2728,9 @@ nfs_strategy(ap) panic("nfs physio"); if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; + td = NULL; else - p = curproc; /* XXX */ + td = curthread; /* XXX */ if (bp->b_flags & B_READ) cr = bp->b_rcred; @@ -2751,8 +2743,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); } @@ -2768,7 +2760,7 @@ nfs_mmap(ap) struct vnode *a_vp; int a_fflags; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -2786,11 +2778,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)); } /* @@ -2799,11 +2791,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); @@ -2932,7 +2924,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++) { @@ -2943,7 +2935,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; } } @@ -3002,7 +2994,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)) { error = EINTR; goto done; } @@ -3038,7 +3030,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)) { error = EINTR; goto done; } @@ -3117,7 +3109,7 @@ nfs_bwrite(ap) struct vnode *a_bp; } */ *ap; { - return (nfs_writebp(ap->a_bp, 1, curproc)); + return (nfs_writebp(ap->a_bp, 1, curthread)); } /* @@ -3126,10 +3118,10 @@ nfs_bwrite(ap) * 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; @@ -3198,7 +3190,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; @@ -3232,7 +3224,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); /* @@ -3309,7 +3301,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; @@ -3325,7 +3317,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)); @@ -3386,7 +3378,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; @@ -3408,7 +3400,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/vfs/nfs/nfsnode.h b/sys/vfs/nfs/nfsnode.h index 6212d50703..e7cb7d8ada 100644 --- a/sys/vfs/nfs/nfsnode.h +++ b/sys/vfs/nfs/nfsnode.h @@ -35,7 +35,7 @@ * * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95 * $FreeBSD: src/sys/nfs/nfsnode.h,v 1.32.2.1 2001/06/26 04:20:11 bp Exp $ - * $DragonFly: src/sys/vfs/nfs/nfsnode.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfsnode.h,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ @@ -156,7 +156,7 @@ struct nfsnode { * Queue head for nfsiod's */ extern TAILQ_HEAD(nfs_bufq, buf) nfs_bufq; -extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON]; +extern struct thread *nfs_iodwant[NFS_MAXASYNCDAEMON]; extern struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; #if defined(_KERNEL) @@ -173,16 +173,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/vfs/nfs/nqnfs.h b/sys/vfs/nfs/nqnfs.h index 1906872b81..6f3586a2f6 100644 --- a/sys/vfs/nfs/nqnfs.h +++ b/sys/vfs/nfs/nqnfs.h @@ -35,7 +35,7 @@ * * @(#)nqnfs.h 8.3 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nqnfs.h,v 1.22 2000/02/13 03:32:07 peter Exp $ - * $DragonFly: src/sys/vfs/nfs/Attic/nqnfs.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/Attic/nqnfs.h,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ @@ -147,7 +147,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. @@ -190,20 +190,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/vfs/ntfs/ntfs_compr.c b/sys/vfs/ntfs/ntfs_compr.c index 70f41cc832..72510f669e 100644 --- a/sys/vfs/ntfs/ntfs_compr.c +++ b/sys/vfs/ntfs/ntfs_compr.c @@ -26,13 +26,13 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_compr.c,v 1.7 1999/12/03 20:37:38 semenu Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_compr.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_compr.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #include #include -#include #include +#include #include #include #include diff --git a/sys/vfs/ntfs/ntfs_subr.c b/sys/vfs/ntfs/ntfs_subr.c index 9b394f6b54..459edbd51d 100644 --- a/sys/vfs/ntfs/ntfs_subr.c +++ b/sys/vfs/ntfs/ntfs_subr.c @@ -26,14 +26,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_subr.c,v 1.7.2.4 2001/10/12 22:08:49 semenu Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_subr.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_subr.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #include #include #include -#include #include +#include #include #include #include @@ -228,7 +228,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); @@ -959,7 +959,7 @@ ntfs_ntlookupfile( error = ntfs_vgetex(ntmp->ntm_mountp, iep->ie_number, attrtype, attrname, LK_EXCLUSIVE, VG_DONTLOADIN | VG_DONTVALIDFN, - curproc, &nvp); + curthread, &nvp); /* free the buffer returned by ntfs_ntlookupattr() */ if (attrname) { diff --git a/sys/vfs/ntfs/ntfs_vfsops.c b/sys/vfs/ntfs/ntfs_vfsops.c index 5113a0ba9f..0d652149fa 100644 --- a/sys/vfs/ntfs/ntfs_vfsops.c +++ b/sys/vfs/ntfs/ntfs_vfsops.c @@ -26,15 +26,15 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_vfsops.c,v 1.20.2.5 2001/12/25 01:44:45 dillon Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_vfsops.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_vfsops.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #include #include -#include #include #include +#include #include #include #include @@ -77,38 +77,38 @@ 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 *)); static int ntfs_checkexp __P((struct mount *, struct sockaddr *, int *, struct ucred **)); #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 @@ -149,14 +149,14 @@ ntfs_checkexp(mp, nam, exflagsp, credanonp) #if defined(__NetBSD__) /*ARGSUSED*/ static int -ntfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) +ntfs_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 thread *td; { return (EINVAL); } @@ -166,7 +166,7 @@ ntfs_mountroot() { struct mount *mp; extern struct vnode *rootvp; - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ int error; struct ntfs_args args; @@ -189,7 +189,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); @@ -200,7 +200,7 @@ ntfs_mountroot() simple_lock(&mountlist_slock); CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); simple_unlock(&mountlist_slock); - (void)ntfs_statfs(mp, &mp->mnt_stat, p); + (void)ntfs_statfs(mp, &mp->mnt_stat, td); vfs_unbusy(mp); return (0); } @@ -236,8 +236,8 @@ ntfs_mount ( void *data, #endif struct nameidata *ndp, - struct proc *p ) -{ + struct thread *td +) { size_t size; int err = 0; struct vnode *devvp; @@ -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; } @@ -312,7 +312,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,17 +420,21 @@ 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; dev_t dev = devvp->v_rdev; int error, ronly, ncount, i; struct vnode *vp; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; /* * Disallow multiple mounts of the same device. @@ -449,19 +453,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, cred, 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, cred, 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); @@ -625,11 +629,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); @@ -640,7 +644,7 @@ static int ntfs_start ( struct mount *mp, int flags, - struct proc *p ) + struct thread *td) { return (0); } @@ -650,7 +654,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; @@ -690,17 +694,17 @@ ntfs_unmount( if (ntmp->ntm_devvp->v_type != VBAD) ntmp->ntm_devvp->v_specmountpoint = 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); @@ -745,7 +749,7 @@ ntfs_quotactl ( int cmds, uid_t uid, caddr_t arg, - struct proc *p) + struct thread *td) { printf("\nntfs_quotactl():\n"); return EOPNOTSUPP; @@ -788,7 +792,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; @@ -832,7 +836,7 @@ ntfs_sync ( struct mount *mp, int waitfor, struct ucred *cred, - struct proc *p) + struct thread *td) { /*dprintf(("ntfs_sync():\n"));*/ return (0); @@ -889,7 +893,7 @@ ntfs_vgetex( char *attrname, u_long lkflags, u_long flags, - struct proc *p, + struct thread *td, struct vnode **vpp) { int error; @@ -954,7 +958,7 @@ ntfs_vgetex( } if (FTOV(fp)) { - VGET(FTOV(fp), lkflags, p); + VGET(FTOV(fp), lkflags, td); *vpp = FTOV(fp); ntfs_ntput(ip); return (0); @@ -981,7 +985,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); @@ -1000,7 +1004,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/vfs/ntfs/ntfs_vfsops.h b/sys/vfs/ntfs/ntfs_vfsops.h index 143a0d5379..c9d78a671e 100644 --- a/sys/vfs/ntfs/ntfs_vfsops.h +++ b/sys/vfs/ntfs/ntfs_vfsops.h @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_vfsops.h,v 1.6 2000/01/14 19:54:41 bde Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_vfsops.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_vfsops.h,v 1.3 2003/06/25 03:56:07 dillon Exp $ */ #define VG_DONTLOADIN 0x0001 /* Tells ntfs_vgetex to do not call */ /* ntfs_loadntnode() on ntnode, even if */ @@ -38,8 +38,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/vfs/ntfs/ntfs_vnops.c b/sys/vfs/ntfs/ntfs_vnops.c index bde9496929..3e54a0fb6b 100644 --- a/sys/vfs/ntfs/ntfs_vnops.c +++ b/sys/vfs/ntfs/ntfs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_vnops.c,v 1.9.2.4 2002/08/06 19:35:18 semenu Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_vnops.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_vnops.c,v 1.3 2003/06/25 03:56:07 dillon Exp $ * */ @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -228,7 +229,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; @@ -282,7 +283,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 @@ -460,7 +461,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; @@ -546,7 +547,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 @@ -575,7 +576,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 @@ -749,7 +750,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_td); if(error) return (error); @@ -788,7 +789,7 @@ ntfs_lookup(ap) if(error) return (error); - VOP__UNLOCK(dvp,0,cnp->cn_proc); + VOP__UNLOCK(dvp,0,cnp->cn_td); cnp->cn_flags |= PDIRUNLOCK; dprintf(("ntfs_lookup: parentdir: %d\n", @@ -797,13 +798,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_td)==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_td); if (error) { vput( *(ap->a_vpp) ); return (error); @@ -821,7 +822,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_td); } if (cnp->cn_flags & MAKEENTRY) @@ -843,7 +844,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/vfs/nullfs/null_subr.c b/sys/vfs/nullfs/null_subr.c index 9b7dfbd57b..72c1c0015b 100644 --- a/sys/vfs/nullfs/null_subr.c +++ b/sys/vfs/nullfs/null_subr.c @@ -36,7 +36,7 @@ * @(#)null_subr.c 8.7 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/miscfs/nullfs/null_subr.c,v 1.21.2.4 2001/06/26 04:20:09 bp Exp $ - * $DragonFly: src/sys/vfs/nullfs/Attic/null_subr.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/nullfs/Attic/null_subr.c,v 1.3 2003/06/25 03:55:59 dillon Exp $ */ #include @@ -108,7 +108,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; @@ -121,25 +121,25 @@ 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; } - 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; } @@ -156,7 +156,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; @@ -206,16 +206,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/vfs/nullfs/null_vfsops.c b/sys/vfs/nullfs/null_vfsops.c index 9d74486e9e..69c7965710 100644 --- a/sys/vfs/nullfs/null_vfsops.c +++ b/sys/vfs/nullfs/null_vfsops.c @@ -37,7 +37,7 @@ * * @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92 * $FreeBSD: src/sys/miscfs/nullfs/null_vfsops.c,v 1.35.2.3 2001/07/26 20:37:11 iedowse Exp $ - * $DragonFly: src/sys/vfs/nullfs/null_vfsops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/nullfs/null_vfsops.c,v 1.3 2003/06/25 03:55:59 dillon Exp $ */ /* @@ -62,31 +62,31 @@ 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, - const char *attrname, caddr_t arg, struct proc *p); + const char *attrname, caddr_t arg, 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; @@ -119,20 +119,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); @@ -171,7 +171,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 */ @@ -198,7 +198,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); @@ -210,23 +210,17 @@ nullfs_mount(mp, path, data, ndp, p) * when that filesystem was mounted. */ static int -nullfs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; +nullfs_start(struct mount *mp, int flags, 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) - struct mount *mp; - int mntflags; - struct proc *p; +nullfs_unmount(struct mount *mp, int mntflags, struct thread *td) { void *mntdata; int error; @@ -252,11 +246,9 @@ nullfs_unmount(mp, mntflags, p) } static int -nullfs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; +nullfs_root(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, @@ -276,27 +268,24 @@ 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) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +nullfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { int error; struct statfs mstat; @@ -307,7 +296,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); @@ -330,11 +319,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. @@ -383,15 +372,15 @@ nullfs_vptofh(vp, fhp) } static int -nullfs_extattrctl(mp, cmd, attrname, arg, p) +nullfs_extattrctl(mp, cmd, attrname, arg, td) struct mount *mp; int cmd; const char *attrname; caddr_t arg; - struct proc *p; + struct thread *td; { return VFS_EXTATTRCTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, attrname, - arg, p); + arg, td); } diff --git a/sys/vfs/nullfs/null_vnops.c b/sys/vfs/nullfs/null_vnops.c index f1e6cf7bdd..472aaf4883 100644 --- a/sys/vfs/nullfs/null_vnops.c +++ b/sys/vfs/nullfs/null_vnops.c @@ -38,7 +38,7 @@ * Ancestors: * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92 * $FreeBSD: src/sys/miscfs/nullfs/null_vnops.c,v 1.38.2.6 2002/07/31 00:32:28 semenu Exp $ - * $DragonFly: src/sys/vfs/nullfs/null_vnops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/nullfs/null_vnops.c,v 1.3 2003/06/25 03:55:59 dillon Exp $ * ...and... * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project * @@ -181,6 +181,7 @@ #include #include #include +#include #include #include #include @@ -362,7 +363,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_td; int flags = cnp->cn_flags; struct vnode *vp, *ldvp, *lvp; int error; @@ -387,7 +388,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; @@ -412,7 +413,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; @@ -458,7 +459,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; @@ -479,7 +480,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; @@ -514,7 +515,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; @@ -575,12 +576,11 @@ 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 null_node *np = VTONULL(vp); struct vnode *lvp; int error; @@ -593,7 +593,7 @@ null_lock(ap) return 0; } error = lockmgr(&np->null_lock, flags & ~LK_THISLAYER, - &vp->v_interlock, p); + &vp->v_interlock, ap->a_td); return (error); } @@ -610,9 +610,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, ap->a_td)); } - return(lockmgr(vp->v_vnlock, flags, &vp->v_interlock, p)); + return(lockmgr(vp->v_vnlock, flags, &vp->v_interlock, ap->a_td)); } /* * To prevent race conditions involving doing a lookup @@ -624,21 +624,21 @@ null_lock(ap) */ lvp = NULLVPTOLOWERVP(vp); if (lvp == NULL) - return (lockmgr(&np->null_lock, flags, &vp->v_interlock, p)); + return (lockmgr(&np->null_lock, flags, &vp->v_interlock, ap->a_td)); if (flags & LK_INTERLOCK) { VI_UNLOCK(vp); 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, ap->a_td); } else - error = VOP_LOCK(lvp, flags, p); + error = VOP_LOCK(lvp, flags, ap->a_td); if (error) return (error); - error = lockmgr(&np->null_lock, flags, &vp->v_interlock, p); + error = lockmgr(&np->null_lock, flags, &vp->v_interlock, ap->a_td); if (error) - VOP_UNLOCK(lvp, 0, p); + VOP_UNLOCK(lvp, 0, ap->a_td); return (error); } @@ -652,12 +652,11 @@ 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 null_node *np = VTONULL(vp); struct vnode *lvp; @@ -666,36 +665,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, ap->a_td)); } lvp = NULLVPTOLOWERVP(vp); if (lvp == NULL) - return (lockmgr(&np->null_lock, flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&np->null_lock, flags | LK_RELEASE, &vp->v_interlock, ap->a_td)); if ((flags & LK_THISLAYER) == 0) { if (flags & LK_INTERLOCK) { VI_UNLOCK(vp); flags &= ~LK_INTERLOCK; } - VOP_UNLOCK(lvp, flags, p); + VOP_UNLOCK(lvp, flags, ap->a_td); } else flags &= ~LK_THISLAYER; ap->a_flags = flags; - return (lockmgr(&np->null_lock, flags | LK_RELEASE, &vp->v_interlock, p)); + return (lockmgr(&np->null_lock, flags | LK_RELEASE, &vp->v_interlock, ap->a_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; if (vp->v_vnlock != NULL) - return (lockstatus(vp->v_vnlock, p)); - return (lockstatus(&VTONULL(vp)->null_lock, p)); + return (lockstatus(vp->v_vnlock, ap->a_td)); + return (lockstatus(&VTONULL(vp)->null_lock, ap->a_td)); } @@ -708,23 +706,22 @@ 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 null_node *xp = VTONULL(vp); struct vnode *lowervp = xp->null_lowervp; - lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, p); + lockmgr(&null_hashlock, LK_EXCLUSIVE, NULL, ap->a_td); LIST_REMOVE(xp, null_hash); - lockmgr(&null_hashlock, LK_RELEASE, NULL, p); + lockmgr(&null_hashlock, LK_RELEASE, NULL, ap->a_td); xp->null_lowervp = NULLVP; if (vp->v_vnlock != NULL) { vp->v_vnlock = &xp->null_lock; /* we no longer share the lock */ } else - VOP_UNLOCK(vp, LK_THISLAYER, p); + VOP_UNLOCK(vp, LK_THISLAYER, ap->a_td); vput(lowervp); /* @@ -744,7 +741,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; @@ -793,7 +790,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/vfs/nwfs/nwfs.h b/sys/vfs/nwfs/nwfs.h index c71249003e..dca764e1bb 100644 --- a/sys/vfs/nwfs/nwfs.h +++ b/sys/vfs/nwfs/nwfs.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs.h,v 1.3 1999/12/29 04:54:56 peter Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs.h,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #ifndef _NWFS_H_ @@ -76,9 +76,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/vfs/nwfs/nwfs_io.c b/sys/vfs/nwfs/nwfs_io.c index 5d59b56fee..26acd249d5 100644 --- a/sys/vfs/nwfs/nwfs_io.c +++ b/sys/vfs/nwfs/nwfs_io.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_io.c,v 1.6.2.1 2000/10/25 02:11:10 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_io.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_io.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ * */ #include @@ -93,7 +93,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 ); @@ -115,7 +115,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; @@ -159,7 +159,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; @@ -171,7 +171,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; @@ -179,14 +179,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; } @@ -204,7 +204,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; @@ -216,11 +216,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) { @@ -229,15 +229,16 @@ 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) { - psignal(p, SIGXFSZ); + if (td->td_proc && uiop->uio_offset + uiop->uio_resid > + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + psignal(td->td_proc, SIGXFSZ); return (EFBIG); } error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cred); @@ -255,10 +256,7 @@ nwfs_writevnode(vp, uiop, cred, ioflag) * Do an I/O operation to/from a cache block. */ int -nwfs_doio(bp, cr, p) - struct buf *bp; - struct ucred *cr; - struct proc *p; +nwfs_doio(struct buf *bp, struct ucred *cr, struct thread *td) { struct uio *uiop; struct vnode *vp; @@ -275,7 +273,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_flags & B_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; @@ -399,15 +397,16 @@ nwfs_getpages(ap) vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; + struct thread *td = curthread; /* XXX */ struct ucred *cred; struct nwmount *nmp; struct nwnode *np; vm_page_t *pages; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + vp = ap->a_vp; - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ np = VTONW(vp); nmp = VFSTONWFS(vp->v_mount); pages = ap->a_m; @@ -431,7 +430,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); @@ -510,17 +509,17 @@ nwfs_putpages(ap) } */ *ap; { int error; + struct thread *td = curthread; /* XXX */ struct vnode *vp = ap->a_vp; - struct proc *p; struct ucred *cred; #ifndef NWFS_RWCACHE - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ - VOP_OPEN(vp, FWRITE, cred, p); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; /* XXX */ + VOP_OPEN(vp, FWRITE, cred, td); error = vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count, ap->a_sync, ap->a_rtvals); - VOP_CLOSE(vp, FWRITE, cred, p); + VOP_CLOSE(vp, FWRITE, cred, td); return error; #else struct uio uio; @@ -533,9 +532,10 @@ nwfs_putpages(ap) struct nwnode *np; vm_page_t *pages; - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ -/* VOP_OPEN(vp, FWRITE, cred, p);*/ + KKASSERT(td->td_proc); + 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; @@ -559,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); @@ -584,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); @@ -608,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); 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; @@ -623,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/vfs/nwfs/nwfs_ioctl.c b/sys/vfs/nwfs/nwfs_ioctl.c index 67b67da66a..1216af51f7 100644 --- a/sys/vfs/nwfs/nwfs_ioctl.c +++ b/sys/vfs/nwfs/nwfs_ioctl.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_ioctl.c,v 1.2.2.1 2001/02/22 09:14:12 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_ioctl.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_ioctl.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #include #include @@ -52,13 +52,13 @@ nwfs_ioctl(ap) struct vnode *a_vp; u_long a_command; caddr_t a_data; - int fflag; - struct ucred *cred; - struct proc *p; + int a_fflag; + struct ucred *a_cred; + struct thread *a_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); @@ -70,23 +70,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/vfs/nwfs/nwfs_node.c b/sys/vfs/nwfs/nwfs_node.c index 9d23c6b927..33ee21030d 100644 --- a/sys/vfs/nwfs/nwfs_node.c +++ b/sys/vfs/nwfs/nwfs_node.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_node.c,v 1.3.2.8 2001/12/25 01:44:45 dillon Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_node.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_node.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #include #include @@ -137,7 +137,7 @@ nwfs_hashlookup(struct nwmount *nmp, ncpfid fid, struct nwnode **npp) int nwfs_allocvp(struct mount *mp, ncpfid fid, 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); @@ -145,18 +145,18 @@ nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp) 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); simple_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; *vpp = vp; return(0); } - lockmgr(&nwhashlock, LK_RELEASE, NULL, p); + lockmgr(&nwhashlock, LK_RELEASE, NULL, td); /* * Do the MALLOC before the getnewvnode since doing so afterward @@ -173,7 +173,7 @@ rescan: vp->v_data = np; np->n_vnode = vp; np->n_mount = nmp; - 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. @@ -191,20 +191,20 @@ rescan: lockinit(&np->n_lock, PINOD, "nwnode", VLKTIMEOUT, LK_CANRECURSE); 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); return 0; } 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; } @@ -215,26 +215,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_refparent) { np->n_refparent = 0; - 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; @@ -251,22 +251,25 @@ 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; struct vnode *vp = ap->a_vp; struct nwnode *np = VTONW(vp); int error; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + 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/vfs/nwfs/nwfs_node.h b/sys/vfs/nwfs/nwfs_node.h index 5b9c2034b7..72fe5f8d7c 100644 --- a/sys/vfs/nwfs/nwfs_node.h +++ b/sys/vfs/nwfs/nwfs_node.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_node.h,v 1.3.2.2 2000/10/25 02:28:42 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_node.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_node.h,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #ifndef _NWFS_NODE_H_ #define _NWFS_NODE_H_ @@ -88,7 +88,7 @@ struct uio; void nwfs_hash_init(void); void nwfs_hash_free(void); int nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp); -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/vfs/nwfs/nwfs_subr.c b/sys/vfs/nwfs/nwfs_subr.c index c59ee256ff..6da1340702 100644 --- a/sys/vfs/nwfs/nwfs_subr.c +++ b/sys/vfs/nwfs/nwfs_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_subr.c,v 1.2.2.2 2000/10/25 02:11:10 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #include #include @@ -77,7 +77,7 @@ ncp_update_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); @@ -88,7 +88,7 @@ ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred) DECLARE_RQ; NCPNDEBUG("vol=%d,dir=%d\n", volnum, dirent); - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 2); /* subfunction */ ncp_rq_byte(rqp, nmp->name_space); ncp_rq_byte(rqp, 0); /* reserved */ @@ -103,13 +103,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); int error; DECLARE_RQ; - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 3); /* subfunction */ ncp_rq_byte(rqp, nmp->name_space); ncp_rq_byte(rqp, 0); /* data stream */ @@ -134,7 +134,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); int error; @@ -146,7 +146,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; - NCP_RQ_HEAD(87, p, cred); + NCP_RQ_HEAD(87, td, cred); ncp_rq_byte(rqp, 6); /* subfunction */ ncp_rq_byte(rqp, ns); ncp_rq_byte(rqp, ns); /* DestNameSpace */ @@ -168,7 +168,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); @@ -185,10 +185,10 @@ ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, if (len == 1 && name[0] == '.') { if (strcmp(dnp->n_name, NWFS_ROOTVOL) == 0) { 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] == '.') { @@ -196,7 +196,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; } @@ -216,7 +216,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 if ((create_attributes & aDIR) != 0) { search_attribs |= SA_SUBDIR_FILES; } - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 1);/* subfunction */ ncp_rq_byte(rqp, nmp->name_space); ncp_rq_byte(rqp, open_create_mode); @@ -261,11 +261,11 @@ 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) { int error; DECLARE_RQ; - NCP_RQ_HEAD(66,p,cred); + NCP_RQ_HEAD(66,td,cred); ncp_rq_byte(rqp, 0); ncp_rq_mem(rqp, (caddr_t)fh, 6); error = ncp_request(conn,rqp); @@ -275,13 +275,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) { int error; struct ncp_conn *conn=NWFSTOCONN(nmp); DECLARE_RQ; - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 8); /* subfunction */ ncp_rq_byte(rqp, nmp->name_space); ncp_rq_byte(rqp, 0); /* reserved */ @@ -297,12 +297,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) { DECLARE_RQ; int error; - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 4); ncp_rq_byte(rqp, ns); ncp_rq_byte(rqp, 1); @@ -328,7 +328,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); u_int8_t volnum = nmp->n_volume; @@ -337,7 +337,7 @@ ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, int error; DECLARE_RQ; - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 7); /* subfunction */ ncp_rq_byte(rqp, nmp->name_space); ncp_rq_byte(rqp, 0); /* reserved */ @@ -351,11 +351,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); @@ -366,10 +366,11 @@ ncp_setattr(vp, vap, cred, procp) DECLARE_RQ; 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); + error = ncp_open_create_file_or_subdir( + nmp, vp, 0, NULL, OC_MODE_OPEN, 0, + AR_WRITE | AR_READ, &nwn,td,cred); if (error) return error; - NCP_RQ_HEAD(73,procp,cred); + NCP_RQ_HEAD(73,td,cred); ncp_rq_byte(rqp, 0); ncp_rq_mem(rqp, (caddr_t)&nwn.fh, 6); ncp_rq_dword(rqp, htonl(vap->va_size)); @@ -377,7 +378,7 @@ ncp_setattr(vp, vap, cred, procp) checkbad(ncp_request(conn,rqp)); np->n_vattr.va_size = np->n_size = vap->va_size; NCP_RQ_EXIT; - ncp_close_file(conn, &nwn.fh, procp, cred); + ncp_close_file(conn, &nwn.fh, td, cred); if (error) return error; } info_mask = 0; @@ -392,7 +393,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); } @@ -400,11 +401,11 @@ 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) { int error,len; DECLARE_RQ; - NCP_RQ_HEAD_S(22,44,p,cred); + NCP_RQ_HEAD_S(22,44,td,cred); ncp_rq_byte(rqp,n); checkbad(ncp_request(conn,rqp)); target->total_blocks = ncp_rp_dword_lh(rqp); @@ -428,13 +429,13 @@ 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) { int error; u_int8_t ns; u_int16_t nscnt; DECLARE_RQ; - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 24); /* Subfunction: Get Loaded Name Spaces */ ncp_rq_word(rqp, 0); ncp_rq_byte(rqp, volume); @@ -452,13 +453,13 @@ 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) { int error; DECLARE_RQ; NCPNDEBUG("looking up vol %s\n", volname); - NCP_RQ_HEAD(87,p,cred); + NCP_RQ_HEAD(87,td,cred); ncp_rq_byte(rqp, 22); /* Subfunction: Generate dir handle */ ncp_rq_byte(rqp, 0); /* src name space */ ncp_rq_byte(rqp, 0); /* dst name space, always zero */ diff --git a/sys/vfs/nwfs/nwfs_subr.h b/sys/vfs/nwfs/nwfs_subr.h index d1944a0849..1721b76298 100644 --- a/sys/vfs/nwfs/nwfs_subr.h +++ b/sys/vfs/nwfs/nwfs_subr.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_subr.h,v 1.2.2.1 2000/04/17 08:34:20 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.h,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #ifndef _NWFS_SUBR_H_ #define _NWFS_SUBR_H_ @@ -48,47 +48,48 @@ 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 *); 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/vfs/nwfs/nwfs_vfsops.c b/sys/vfs/nwfs/nwfs_vfsops.c index 85ce7be0ed..cbd214a30f 100644 --- a/sys/vfs/nwfs/nwfs_vfsops.c +++ b/sys/vfs/nwfs/nwfs_vfsops.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_vfsops.c,v 1.6.2.6 2001/10/25 19:18:54 dillon Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_vfsops.c,v 1.3 2003/06/23 17:55:48 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_vfsops.c,v 1.4 2003/06/25 03:56:08 dillon Exp $ */ #include "opt_ncp.h" #ifndef NCP @@ -68,13 +68,13 @@ SYSCTL_INT(_vfs_nwfs, OID_AUTO, version, CTLFLAG_RD, &nwfs_version, 0, ""); SYSCTL_INT(_vfs_nwfs, OID_AUTO, debuglevel, CTLFLAG_RW, &nwfs_debuglevel, 0, ""); 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); @@ -141,7 +141,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 */ size_t size; @@ -151,6 +151,10 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, struct ncp_handle *handle = NULL; struct vnode *vp; char *pc,*pe; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; if (data == NULL) { nwfs_printf("missing data argument\n"); @@ -167,7 +171,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,cred,NCPM_EXECUTE,&conn); if (error) { nwfs_printf("invalid connection refernce %d\n",args.connRef); return (error); @@ -177,7 +181,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 +224,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,11 +237,15 @@ 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; int error, flags; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; NCPVODEBUG("nwfs_unmount: flags=%04x\n",mntflags); flags = 0; @@ -249,9 +257,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,cred,NCPM_WRITE | NCPM_EXECUTE) == 0) { if(ncp_disconnect(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,25 +277,28 @@ 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; /* XXX */ + struct ucred *cred; int error, nsf, opt; u_char vol; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + nmp = VFSTONWFS(mp); 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) /* XXX */ ; 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 +324,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 +332,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 +340,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 +356,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 +371,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 +385,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); @@ -419,18 +430,22 @@ 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; struct nwnode *np = nmp->n_root; struct ncp_volume_info vi; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; 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,cred); if (error) return error; secsize = 512; /* XXX how to get real value ??? */ sbp->f_spare2=0; /* placeholder */ @@ -465,11 +480,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; int error, allerror = 0; @@ -489,9 +504,9 @@ loop: if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY) continue; - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) 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/vfs/nwfs/nwfs_vnops.c b/sys/vfs/nwfs/nwfs_vnops.c index 4331b135dd..432f71e1d7 100644 --- a/sys/vfs/nwfs/nwfs_vnops.c +++ b/sys/vfs/nwfs/nwfs_vnops.c @@ -30,14 +30,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_vnops.c,v 1.6.2.3 2001/03/14 11:26:59 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_vnops.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_vnops.c,v 1.3 2003/06/25 03:56:08 dillon Exp $ */ #include #include -#include #include #include #include +#include #include #include #include @@ -134,7 +134,7 @@ nwfs_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; @@ -172,7 +172,7 @@ nwfs_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; @@ -190,17 +190,17 @@ nwfs_open(ap) } 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; } @@ -213,13 +213,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++; @@ -237,14 +237,14 @@ nwfs_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 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,td=%p,c=%d\n",np->n_name,ap->a_td,np->opened); if (vp->v_type == VDIR) return 0; /* nothing to do now */ error = 0; @@ -254,7 +254,7 @@ nwfs_close(ap) return 0; } simple_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); simple_lock(&vp->v_interlock); if (np->opened == 0) { simple_unlock(&vp->v_interlock); @@ -263,7 +263,7 @@ nwfs_close(ap) if (--np->opened == 0) { simple_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 simple_unlock(&vp->v_interlock); np->n_atime = 0; @@ -279,7 +279,7 @@ nwfs_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; @@ -297,10 +297,10 @@ nwfs_getattr(ap) 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); @@ -321,7 +321,7 @@ nwfs_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; @@ -359,13 +359,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); } @@ -445,7 +445,7 @@ 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_td))) { return (error); } fmode = AR_READ | AR_WRITE; @@ -454,9 +454,9 @@ nwfs_create(ap) 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_td, 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_td,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); @@ -498,7 +498,7 @@ nwfs_remove(ap) } else { 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_td,cnp->cn_cred); if (error == 0) np->n_flag |= NSHOULDFREE; else if (error == 0x899c) @@ -545,7 +545,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_td, tcnp->cn_cred); if (error == 0x899c) error = EACCES; if (error) goto out; @@ -560,7 +560,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_td,tcnp->cn_cred); if (error == 0x8992) error = EEXIST; @@ -658,7 +658,7 @@ 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_td))) { return (error); } if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) { @@ -666,7 +666,7 @@ nwfs_mkdir(ap) } 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) { + &no, cnp->cn_td, cnp->cn_cred) != 0) { error = EACCES; } else { error = 0; @@ -707,7 +707,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_td,cnp->cn_cred); if (error == 0) np->n_flag |= NSHOULDFREE; else if (error == NWE_DIR_NOT_EMPTY) @@ -755,10 +755,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); } @@ -810,16 +810,14 @@ static int nwfs_strategy (ap) { struct buf *bp=ap->a_bp; struct ucred *cr; - struct proc *p; int error = 0; + struct thread *td = NULL; NCPVNDEBUG("\n"); if (bp->b_flags & B_PHYS) panic("nwfs physio"); - if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; - else - p = curproc; /* XXX */ + if ((bp->b_flags & B_ASYNC) == 0) + td = curthread; /* YYY dunno if this is legal */ if (bp->b_flags & B_READ) cr = bp->b_rcred; else @@ -830,7 +828,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); } @@ -919,7 +917,7 @@ 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_td; char _name[cnp->cn_namelen+1]; bcopy(cnp->cn_nameptr,_name,cnp->cn_namelen); _name[cnp->cn_namelen]=0; @@ -937,7 +935,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); @@ -966,18 +964,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; @@ -988,9 +986,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); @@ -1005,7 +1003,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; } @@ -1013,12 +1011,12 @@ 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; @@ -1033,7 +1031,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; @@ -1042,7 +1040,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_td); if (error) return (error); if (NWCMPF(&dnp->n_fid, &fid)) { /* we found ourselfs */ VREF(dvp); @@ -1053,11 +1051,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_td); if (error) return (error); if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR; error = nwfs_nget(mp, fid, fap, dvp, &vp); @@ -1065,18 +1063,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); } @@ -1090,7 +1088,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/vfs/portal/portal_vfsops.c b/sys/vfs/portal/portal_vfsops.c index cfbf6f2a18..00a05f75a9 100644 --- a/sys/vfs/portal/portal_vfsops.c +++ b/sys/vfs/portal/portal_vfsops.c @@ -36,7 +36,7 @@ * @(#)portal_vfsops.c 8.11 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/miscfs/portal/portal_vfsops.c,v 1.26.2.2 2001/07/26 20:37:16 iedowse Exp $ - * $DragonFly: src/sys/vfs/portal/portal_vfsops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/portal/portal_vfsops.c,v 1.3 2003/06/25 03:55:59 dillon Exp $ */ /* @@ -61,23 +61,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; @@ -98,12 +98,13 @@ portal_mount(mp, path, data, ndp, p) if (error) return (error); - error = holdsock(p->p_fd, args.pa_socket, &fp); + KKASSERT(td->td_proc); + 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); } @@ -117,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); } @@ -145,16 +146,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; @@ -187,7 +188,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 */ @@ -201,7 +202,7 @@ portal_root(mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; /* @@ -209,16 +210,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/vfs/portal/portal_vnops.c b/sys/vfs/portal/portal_vnops.c index e99c01add3..4e11c5193d 100644 --- a/sys/vfs/portal/portal_vnops.c +++ b/sys/vfs/portal/portal_vnops.c @@ -36,7 +36,7 @@ * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * * $FreeBSD: src/sys/miscfs/portal/portal_vnops.c,v 1.38 1999/12/21 06:29:00 chris Exp $ - * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.3 2003/06/23 17:55:43 dillon Exp $ + * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.4 2003/06/25 03:56:00 dillon Exp $ */ /* @@ -67,7 +67,7 @@ static int portal_fileid = PORTAL_ROOTFILEID+1; static int portal_badop __P((void)); -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_inactive __P((struct vop_inactive_args *ap)); @@ -79,8 +79,8 @@ 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; @@ -207,12 +207,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; @@ -240,7 +240,8 @@ 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) + KKASSERT(td->td_proc); + if (td->td_proc->p_dupfd >= 0) return (ENODEV); pt = VTOPORTAL(vp); @@ -249,7 +250,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; @@ -318,12 +319,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; @@ -395,7 +396,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++; } } @@ -404,9 +405,10 @@ 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]; + KKASSERT(td->td_proc); + 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; } @@ -416,7 +418,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_proc->p_dupfd = fd; error = ENXIO; bad:; @@ -440,7 +442,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; @@ -485,7 +487,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; { @@ -531,11 +533,11 @@ static int portal_inactive(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); } diff --git a/sys/vfs/procfs/procfs.h b/sys/vfs/procfs/procfs.h index 632642c61e..5d520f943b 100644 --- a/sys/vfs/procfs/procfs.h +++ b/sys/vfs/procfs/procfs.h @@ -38,7 +38,7 @@ * * From: * $FreeBSD: src/sys/miscfs/procfs/procfs.h,v 1.32.2.3 2002/01/22 17:22:59 nectar Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs.h,v 1.3 2003/06/23 17:55:44 dillon Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs.h,v 1.4 2003/06/25 03:56:00 dillon Exp $ */ /* @@ -99,7 +99,7 @@ struct pfsnode { ((p1)->p_ucred->cr_ruid == (p2)->p_ucred->cr_ruid) && \ ((p1)->p_ucred->cr_svuid == (p2)->p_ucred->cr_ruid) && \ ((p2)->p_flag & (P_SUGID|P_INEXEC)) == 0) || \ - (suser_xxx((p1)->p_ucred, PRISON_ROOT) == 0)) + (suser_cred((p1)->p_ucred, PRISON_ROOT) == 0)) /* * Convert between pfsnode vnode @@ -123,7 +123,7 @@ struct dbreg; #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) -void procfs_exit __P((struct proc *)); +void procfs_exit __P((struct thread *)); int procfs_freevp __P((struct vnode *)); int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); struct vnode *procfs_findtextvp __P((struct proc *)); diff --git a/sys/vfs/procfs/procfs_subr.c b/sys/vfs/procfs/procfs_subr.c index 913c2d8b4f..8dd33be1a5 100644 --- a/sys/vfs/procfs/procfs_subr.c +++ b/sys/vfs/procfs/procfs_subr.c @@ -37,7 +37,7 @@ * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/miscfs/procfs/procfs_subr.c,v 1.26.2.3 2002/02/18 21:28:04 des Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs_subr.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs_subr.c,v 1.3 2003/06/25 03:56:00 dillon Exp $ */ #include @@ -86,7 +86,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; @@ -98,7 +98,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); @@ -239,16 +239,21 @@ procfs_freevp(vp) } int -procfs_rw(ap) - struct vop_read_args *ap; +procfs_rw(struct vop_read_args *ap) { struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; - struct proc *curp = uio->uio_procp; + struct thread *curtd = uio->uio_td; + struct proc *curp; struct pfsnode *pfs = VTOPFS(vp); struct proc *p; int rtval; + if (curtd == NULL) + return (EINVAL); + if ((curp = curtd->td_proc) == NULL) /* XXX */ + return (EINVAL); + p = PFIND(pfs->pfs_pid); if (p == NULL) return (EINVAL); @@ -377,10 +382,13 @@ vfs_findname(nm, buf, buflen) } void -procfs_exit(struct proc *p) +procfs_exit(struct thread *td) { struct pfsnode *pfs; - pid_t pid = p->p_pid; + pid_t pid; + + KKASSERT(td->td_proc); + pid = td->td_proc->p_pid; /* * The reason for this loop is not obvious -- basicly, diff --git a/sys/vfs/procfs/procfs_vfsops.c b/sys/vfs/procfs/procfs_vfsops.c index 993cd0a123..a1e8a9c04d 100644 --- a/sys/vfs/procfs/procfs_vfsops.c +++ b/sys/vfs/procfs/procfs_vfsops.c @@ -37,7 +37,7 @@ * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95 * * $FreeBSD: src/sys/miscfs/procfs/procfs_vfsops.c,v 1.32.2.1 2001/10/15 20:42:01 des Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs_vfsops.c,v 1.2 2003/06/17 04:28:42 dillon Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs_vfsops.c,v 1.3 2003/06/25 03:56:00 dillon Exp $ */ /* @@ -53,11 +53,11 @@ #include 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. @@ -66,12 +66,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; @@ -94,7 +94,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); } @@ -103,10 +103,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; @@ -137,10 +137,7 @@ procfs_root(mp, vpp) * Get file system statistics. */ static int -procfs_statfs(mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +procfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { sbp->f_bsize = PAGE_SIZE; sbp->f_iosize = PAGE_SIZE; diff --git a/sys/vfs/procfs/procfs_vnops.c b/sys/vfs/procfs/procfs_vnops.c index f7079f9763..22a09bd14f 100644 --- a/sys/vfs/procfs/procfs_vnops.c +++ b/sys/vfs/procfs/procfs_vnops.c @@ -37,7 +37,7 @@ * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * * $FreeBSD: src/sys/miscfs/procfs/procfs_vnops.c,v 1.76.2.7 2002/01/22 17:22:59 nectar Exp $ - * $DragonFly: src/sys/vfs/procfs/procfs_vnops.c,v 1.3 2003/06/23 17:55:44 dillon Exp $ + * $DragonFly: src/sys/vfs/procfs/procfs_vnops.c,v 1.4 2003/06/25 03:56:00 dillon Exp $ */ /* @@ -130,7 +130,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); @@ -148,7 +148,8 @@ procfs_open(ap) ((pfs->pfs_flags & O_EXCL) && (ap->a_mode & FWRITE))) return (EBUSY); - p1 = ap->a_p; + p1 = ap->a_td->td_proc; + KKASSERT(p1); /* Can't trace a process that's currently exec'ing. */ if ((p2->p_flag & P_INEXEC) != 0) return EAGAIN; @@ -180,7 +181,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); @@ -231,17 +232,19 @@ procfs_ioctl(ap) struct vop_ioctl_args *ap; { struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct proc *procp, *p; + struct proc *procp; + struct proc *p; int error; int signo; struct procfs_status *psp; unsigned char flags; - p = ap->a_p; procp = pfind(pfs->pfs_pid); - if (procp == NULL) { + if (procp == NULL) return ENOTTY; - } + p = ap->a_td->td_proc; + if (p == NULL) + return EINVAL; /* Can't trace a process that's currently exec'ing. */ if ((procp->p_flag & P_INEXEC) != 0) @@ -263,7 +266,7 @@ procfs_ioctl(ap) */ #define NFLAGS (PF_ISUGID) flags = (unsigned char)*(unsigned int*)ap->a_data; - if (flags & NFLAGS && (error = suser_xxx(ap->a_cred, 0))) + if (flags & NFLAGS && (error = suser_cred(ap->a_cred, 0))) return error; procp->p_pfsflags = flags; break; @@ -355,11 +358,12 @@ static int procfs_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; + struct thread *a_td; } */ *ap; { struct vnode *vp = ap->a_vp; - VOP_UNLOCK(vp, 0, ap->a_p); + VOP_UNLOCK(vp, 0, ap->a_td); return (0); } @@ -424,7 +428,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); @@ -595,7 +599,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; { @@ -633,7 +637,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 vattr *vap; @@ -648,7 +652,7 @@ procfs_access(ap) return (0); vap = &vattr; - error = VOP_GETATTR(ap->a_vp, vap, ap->a_cred, ap->a_p); + error = VOP_GETATTR(ap->a_vp, vap, ap->a_cred, ap->a_td); if (error) return (error); diff --git a/sys/vfs/smbfs/smbfs.h b/sys/vfs/smbfs/smbfs.h index 474d59a0d7..57756d685f 100644 --- a/sys/vfs/smbfs/smbfs.h +++ b/sys/vfs/smbfs/smbfs.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs.h,v 1.2.2.2 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs.h,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs.h,v 1.3 2003/06/25 03:55:52 dillon Exp $ */ #ifndef _SMBFS_SMBFS_H_ #define _SMBFS_SMBFS_H_ @@ -101,9 +101,9 @@ struct smbmount { #define VTOSMBFS(vp) (VFSTOSMBFS(VTOVFS(vp))) int smbfs_ioctl(struct vop_ioctl_args *ap); -int smbfs_doio(struct buf *bp, struct ucred *cr, struct proc *p); +int smbfs_doio(struct buf *bp, struct ucred *cr, struct thread *td); int smbfs_vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, - struct proc *p, int intrflg); + struct thread *td, int intrflg); #endif /* KERNEL */ #endif /* _SMBFS_SMBFS_H_ */ diff --git a/sys/vfs/smbfs/smbfs_io.c b/sys/vfs/smbfs/smbfs_io.c index 2aa234b450..58e7626478 100644 --- a/sys/vfs/smbfs/smbfs_io.c +++ b/sys/vfs/smbfs/smbfs_io.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_io.c,v 1.3.2.3 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_io.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_io.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ * */ #include @@ -93,7 +93,7 @@ smbfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) np = VTOSMB(vp); SMBVDEBUG("dirname='%s'\n", np->n_name); - smb_makescred(&scred, uio->uio_procp, cred); + smb_makescred(&scred, uio->uio_td, cred); offset = uio->uio_offset / DE_SIZE; /* offset in the directory */ limit = uio->uio_resid / DE_SIZE; if (uio->uio_resid < DE_SIZE || uio->uio_offset < 0) @@ -180,9 +180,9 @@ smbfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) int smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) { + struct thread *td; struct smbmount *smp = VFSTOSMBFS(vp->v_mount); struct smbnode *np = VTOSMB(vp); - struct proc *p; struct vattr vattr; struct smb_cred scred; int error, lks; @@ -203,36 +203,36 @@ smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) return EINVAL; /* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize) return EFBIG;*/ - p = uiop->uio_procp; + td = uiop->uio_td; if (vp->v_type == VDIR) { - lks = LK_EXCLUSIVE;/*lockstatus(&vp->v_lock, p);*/ + lks = LK_EXCLUSIVE;/*lockstatus(&vp->v_lock, td);*/ if (lks == LK_SHARED) - vn_lock(vp, LK_UPGRADE | LK_RETRY, p); + vn_lock(vp, LK_UPGRADE | LK_RETRY, td); error = smbfs_readvdir(vp, uiop, cred); if (lks == LK_SHARED) - vn_lock(vp, LK_DOWNGRADE | LK_RETRY, p); + vn_lock(vp, LK_DOWNGRADE | LK_RETRY, td); return error; } /* biosize = SSTOCN(smp->sm_share)->sc_txmax;*/ if (np->n_flag & NMODIFIED) { smbfs_attr_cacheremove(vp); - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return error; np->n_mtime.tv_sec = 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.tv_sec != vattr.va_mtime.tv_sec) { - error = smbfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = smbfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return error; np->n_mtime.tv_sec = vattr.va_mtime.tv_sec; } } - smb_makescred(&scred, p, cred); + smb_makescred(&scred, td, cred); return smb_read(smp->sm_share, np->n_fid, uiop, &scred); } @@ -240,10 +240,10 @@ int smbfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag) { + struct thread *td; struct smbmount *smp = VTOSMBFS(vp); struct smbnode *np = VTOSMB(vp); struct smb_cred scred; - struct proc *p; int error = 0; if (vp->v_type != VREG) { @@ -255,11 +255,11 @@ smbfs_writevnode(struct vnode *vp, struct uio *uiop, return EINVAL; /* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize) return (EFBIG);*/ - p = uiop->uio_procp; + td = uiop->uio_td; if (ioflag & (IO_APPEND | IO_SYNC)) { if (np->n_flag & NMODIFIED) { smbfs_attr_cacheremove(vp); - error = smbfs_vinvalbuf(vp, V_SAVE, cred, p, 1); + error = smbfs_vinvalbuf(vp, V_SAVE, cred, td, 1); if (error) return error; } @@ -269,7 +269,7 @@ smbfs_writevnode(struct vnode *vp, struct uio *uiop, * File size can be changed by another client */ smbfs_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; @@ -277,11 +277,13 @@ smbfs_writevnode(struct vnode *vp, struct uio *uiop, } if (uiop->uio_resid == 0) return 0; - if (p && uiop->uio_offset + uiop->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - psignal(p, SIGXFSZ); + if (td->td_proc && + uiop->uio_offset + uiop->uio_resid > + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + psignal(td->td_proc, SIGXFSZ); return EFBIG; } - smb_makescred(&scred, p, cred); + smb_makescred(&scred, td, cred); error = smb_write(smp->sm_share, np->n_fid, uiop, &scred); SMBVDEBUG("after: ofs=%d,resid=%d\n",(int)uiop->uio_offset, uiop->uio_resid); if (!error) { @@ -297,7 +299,7 @@ smbfs_writevnode(struct vnode *vp, struct uio *uiop, * Do an I/O operation to/from a cache block. */ int -smbfs_doio(struct buf *bp, struct ucred *cr, struct proc *p) +smbfs_doio(struct buf *bp, struct ucred *cr, struct thread *td) { struct vnode *vp = bp->b_vp; struct smbmount *smp = VFSTOSMBFS(vp->v_mount); @@ -310,9 +312,9 @@ smbfs_doio(struct buf *bp, struct ucred *cr, struct proc *p) uiop->uio_iov = &io; uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_procp = p; + uiop->uio_td = td; - smb_makescred(&scred, p, cr); + smb_makescred(&scred, td, cr); if (bp->b_flags & B_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; @@ -422,16 +424,17 @@ smbfs_getpages(ap) vm_offset_t kva; struct buf *bp; struct vnode *vp; - struct proc *p; + struct thread *td = curthread; /* XXX */ struct ucred *cred; struct smbmount *smp; struct smbnode *np; struct smb_cred scred; vm_page_t *pages; + KKASSERT(td->td_proc); + vp = ap->a_vp; - p = curproc; /* XXX */ - cred = curproc->p_ucred; /* XXX */ + cred = td->td_proc->p_ucred; np = VTOSMB(vp); smp = VFSTOSMBFS(vp->v_mount); pages = ap->a_m; @@ -441,7 +444,7 @@ smbfs_getpages(ap) printf("smbfs_getpages: called with non-merged cache vnode??\n"); return VM_PAGER_ERROR; } - smb_makescred(&scred, p, cred); + smb_makescred(&scred, td, cred); bp = getpbuf(&smbfs_pbuf_freecnt); npages = btoc(count); @@ -456,7 +459,7 @@ smbfs_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 = smb_read(smp->sm_share, np->n_fid, &uio, &scred); pmap_qremove(kva, npages); @@ -536,16 +539,16 @@ smbfs_putpages(ap) { int error; struct vnode *vp = ap->a_vp; - struct proc *p; + struct thread *td = curthread; /* XXX */ struct ucred *cred; #ifdef SMBFS_RWGENERIC - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ - VOP_OPEN(vp, FWRITE, cred, p); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + VOP_OPEN(vp, FWRITE, cred, td); error = vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count, ap->a_sync, ap->a_rtvals); - VOP_CLOSE(vp, FWRITE, cred, p); + VOP_CLOSE(vp, FWRITE, cred, td); return error; #else struct uio uio; @@ -559,9 +562,9 @@ smbfs_putpages(ap) struct smb_cred scred; vm_page_t *pages; - p = curproc; /* XXX */ - cred = p->p_ucred; /* XXX */ -/* VOP_OPEN(vp, FWRITE, cred, p);*/ + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; +/* VOP_OPEN(vp, FWRITE, cred, td);*/ np = VTOSMB(vp); smp = VFSTOSMBFS(vp->v_mount); pages = ap->a_m; @@ -585,12 +588,12 @@ smbfs_putpages(ap) uio.uio_resid = count; uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_WRITE; - uio.uio_procp = p; + uio.uio_td = td; SMBVDEBUG("ofs=%d,resid=%d\n",(int)uio.uio_offset, uio.uio_resid); - smb_makescred(&scred, p, cred); + smb_makescred(&scred, td, cred); error = smb_write(smp->sm_share, np->n_fid, &uio, &scred); -/* VOP_CLOSE(vp, FWRITE, cred, p);*/ +/* VOP_CLOSE(vp, FWRITE, cred, td);*/ SMBVDEBUG("paged write done: %d\n", error); pmap_qremove(kva, npages); @@ -612,11 +615,11 @@ smbfs_putpages(ap) * doing the flush, just wait for completion. */ int -smbfs_vinvalbuf(vp, flags, cred, p, intrflg) +smbfs_vinvalbuf(vp, flags, cred, td, intrflg) struct vnode *vp; int flags; struct ucred *cred; - struct proc *p; + struct thread *td; int intrflg; { struct smbnode *np = VTOSMB(vp); @@ -634,12 +637,12 @@ smbfs_vinvalbuf(vp, flags, cred, p, intrflg) while (np->n_flag & NFLUSHINPROG) { np->n_flag |= NFLUSHWANT; error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "smfsvinv", slptimeo); - error = smb_proc_intr(p); + error = smb_proc_intr(td); 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; @@ -649,7 +652,7 @@ smbfs_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/vfs/smbfs/smbfs_node.c b/sys/vfs/smbfs/smbfs_node.c index 999afd1c26..e4dca72e9b 100644 --- a/sys/vfs/smbfs/smbfs_node.c +++ b/sys/vfs/smbfs/smbfs_node.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_node.c,v 1.2.2.3 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_node.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_node.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ */ #include #include @@ -56,8 +56,8 @@ #include #define SMBFS_NOHASH(smp, hval) (&(smp)->sm_hash[(hval) & (smp)->sm_hashlen]) -#define smbfs_hash_lock(smp, p) lockmgr(&smp->sm_hashlock, LK_EXCLUSIVE, NULL, p) -#define smbfs_hash_unlock(smp, p) lockmgr(&smp->sm_hashlock, LK_RELEASE, NULL, p) +#define smbfs_hash_lock(smp, td) lockmgr(&smp->sm_hashlock, LK_EXCLUSIVE, NULL, td) +#define smbfs_hash_unlock(smp, td) lockmgr(&smp->sm_hashlock, LK_RELEASE, NULL, td) extern vop_t **smbfs_vnodeop_p; @@ -164,7 +164,7 @@ static int smbfs_node_alloc(struct mount *mp, struct vnode *dvp, const char *name, int nmlen, struct smbfattr *fap, struct vnode **vpp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct smbmount *smp = VFSTOSMBFS(mp); struct smbnode_hashhead *nhpp; struct smbnode *np, *np2, *dnp; @@ -181,7 +181,7 @@ smbfs_node_alloc(struct mount *mp, struct vnode *dvp, if (dvp == NULL) return EINVAL; vp = VTOSMB(VTOSMB(dvp)->n_parent)->n_vnode; - error = vget(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (error == 0) *vpp = vp; return error; @@ -196,7 +196,7 @@ smbfs_node_alloc(struct mount *mp, struct vnode *dvp, } hashval = smbfs_hash(name, nmlen); retry: - smbfs_hash_lock(smp, p); + smbfs_hash_lock(smp, td); loop: nhpp = SMBFS_NOHASH(smp, hashval); LIST_FOREACH(np, nhpp, n_hash) { @@ -205,13 +205,13 @@ loop: np->n_nmlen != nmlen || bcmp(name, np->n_name, nmlen) != 0) continue; VI_LOCK(vp); - smbfs_hash_unlock(smp, p); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) != 0) + smbfs_hash_unlock(smp, td); + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td) != 0) goto retry; *vpp = vp; return 0; } - smbfs_hash_unlock(smp, p); + smbfs_hash_unlock(smp, td); /* * If we don't have node attributes, then it is an explicit lookup * for an existing vnode. @@ -244,9 +244,9 @@ loop: SMBERROR("new vnode '%s' born without parent ?\n", np->n_name); lockinit(&np->n_lock, PINOD, "smbnode", VLKTIMEOUT, LK_CANRECURSE); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); - smbfs_hash_lock(smp, p); + smbfs_hash_lock(smp, td); LIST_FOREACH(np2, nhpp, n_hash) { if (np2->n_parent != dvp || np2->n_nmlen != nmlen || bcmp(name, np2->n_name, nmlen) != 0) @@ -257,7 +257,7 @@ loop: goto loop; } LIST_INSERT_HEAD(nhpp, np, n_hash); - smbfs_hash_unlock(smp, p); + smbfs_hash_unlock(smp, td); *vpp = vp; return 0; } @@ -288,18 +288,18 @@ int smbfs_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; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct vnode *dvp; struct smbnode *np = VTOSMB(vp); struct smbmount *smp = VTOSMBFS(vp); SMBVDEBUG("%s,%d\n", np->n_name, vp->v_usecount); - smbfs_hash_lock(smp, p); + smbfs_hash_lock(smp, td); dvp = (np->n_parent && (np->n_flag & NREFPARENT)) ? np->n_parent : NULL; @@ -312,7 +312,7 @@ smbfs_reclaim(ap) smp->sm_root = NULL; } vp->v_data = NULL; - smbfs_hash_unlock(smp, p); + smbfs_hash_unlock(smp, td); if (np->n_name) smbfs_name_free(np->n_name); FREE(np, M_SMBNODE); @@ -338,25 +338,28 @@ int smbfs_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; struct vnode *vp = ap->a_vp; struct smbnode *np = VTOSMB(vp); struct smb_cred scred; int error; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + SMBVDEBUG("%s: %d\n", VTOSMB(vp)->n_name, vp->v_usecount); if (np->n_opencount) { - error = smbfs_vinvalbuf(vp, V_SAVE, cred, p, 1); - smb_makescred(&scred, p, cred); + error = smbfs_vinvalbuf(vp, V_SAVE, cred, td, 1); + smb_makescred(&scred, td, cred); error = smbfs_smb_close(np->n_mount->sm_share, np->n_fid, &np->n_mtime, &scred); np->n_opencount = 0; } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (0); } /* diff --git a/sys/vfs/smbfs/smbfs_vfsops.c b/sys/vfs/smbfs/smbfs_vfsops.c index c85502a61a..2b4598a38e 100644 --- a/sys/vfs/smbfs/smbfs_vfsops.c +++ b/sys/vfs/smbfs/smbfs_vfsops.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_vfsops.c,v 1.2.2.5 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_vfsops.c,v 1.2 2003/06/17 04:28:33 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_vfsops.c,v 1.3 2003/06/25 03:55:52 dillon Exp $ */ #include "opt_netsmb.h" #ifndef NETSMB @@ -80,13 +80,13 @@ static MALLOC_DEFINE(M_SMBFSHASH, "SMBFS hash", "SMBFS hash table"); static int smbfs_mount(struct mount *, char *, caddr_t, - struct nameidata *, struct proc *); -static int smbfs_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *); + struct nameidata *, struct thread *); +static int smbfs_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *); static int smbfs_root(struct mount *, struct vnode **); -static int smbfs_start(struct mount *, int, struct proc *); -static int smbfs_statfs(struct mount *, struct statfs *, struct proc *); -static int smbfs_sync(struct mount *, int, struct ucred *, struct proc *); -static int smbfs_unmount(struct mount *, int, struct proc *); +static int smbfs_start(struct mount *, int, struct thread *); +static int smbfs_statfs(struct mount *, struct statfs *, struct thread *); +static int smbfs_sync(struct mount *, int, struct ucred *, struct thread *); +static int smbfs_unmount(struct mount *, int, struct thread *); static int smbfs_init(struct vfsconf *vfsp); static int smbfs_uninit(struct vfsconf *vfsp); @@ -132,7 +132,7 @@ int smbfs_pbuf_freecnt = -1; /* start out unlimited */ static int smbfs_mount(struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p) + struct nameidata *ndp, struct thread *td) { struct smbfs_args args; /* will hold data from mount request */ struct smbmount *smp = NULL; @@ -140,10 +140,14 @@ smbfs_mount(struct mount *mp, char *path, caddr_t data, struct smb_share *ssp = NULL; struct vnode *vp; struct smb_cred scred; + struct ucred *cred; size_t size; int error; char *pc, *pe; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + if (data == NULL) { printf("missing data argument\n"); return EINVAL; @@ -160,14 +164,14 @@ smbfs_mount(struct mount *mp, char *path, caddr_t data, SMBFS_VERSION, args.version); return EINVAL; } - smb_makescred(&scred, p, p->p_ucred); + smb_makescred(&scred, td, cred); error = smb_dev2share(args.dev, SMBM_EXEC, &scred, &ssp); if (error) { printf("invalid device handle %d (%d)\n", args.dev, error); return error; } vcp = SSTOVC(ssp); - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); mp->mnt_stat.f_iosize = SSTOVC(ssp)->vc_txmax; #ifdef SMBFS_USEZONE @@ -220,7 +224,7 @@ smbfs_mount(struct mount *mp, char *path, caddr_t data, error = smbfs_root(mp, &vp); if (error) goto bad; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); SMBVDEBUG("root.v_usecount = %d\n", vp->v_usecount); #ifdef DIAGNOSTICS @@ -245,12 +249,16 @@ bad: /* Unmount the filesystem described by mp. */ static int -smbfs_unmount(struct mount *mp, int mntflags, struct proc *p) +smbfs_unmount(struct mount *mp, int mntflags, struct thread *td) { struct smbmount *smp = VFSTOSMBFS(mp); struct smb_cred scred; + struct ucred *cred; int error, flags; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + SMBVDEBUG("smbfs_unmount: flags=%04x\n", mntflags); flags = 0; if (mntflags & MNT_FORCE) @@ -270,7 +278,7 @@ smbfs_unmount(struct mount *mp, int mntflags, struct proc *p) } while (error == EBUSY && smp->sm_didrele != 0); if (error) return error; - smb_makescred(&scred, p, p->p_ucred); + smb_makescred(&scred, td, cred); smb_share_put(smp->sm_share, &scred); mp->mnt_data = (qaddr_t)0; @@ -292,24 +300,27 @@ smbfs_unmount(struct mount *mp, int mntflags, struct proc *p) static int smbfs_root(struct mount *mp, struct vnode **vpp) { + struct thread *td = curthread; /* XXX */ struct smbmount *smp = VFSTOSMBFS(mp); struct vnode *vp; struct smbnode *np; struct smbfattr fattr; - struct proc *p = curproc; - struct ucred *cred = p->p_ucred; + struct ucred *cred; struct smb_cred scred; int error; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + if (smp == NULL) { SMBERROR("smp == NULL (bug in umount)\n"); return EINVAL; } if (smp->sm_root) { *vpp = SMBTOV(smp->sm_root); - return vget(*vpp, LK_EXCLUSIVE | LK_RETRY, p); + return vget(*vpp, LK_EXCLUSIVE | LK_RETRY, td); } - smb_makescred(&scred, p, cred); + smb_makescred(&scred, td, cred); error = smbfs_smb_lookup(NULL, NULL, 0, &fattr, &scred); if (error) return error; @@ -328,10 +339,10 @@ smbfs_root(struct mount *mp, struct vnode **vpp) */ /* ARGSUSED */ static int -smbfs_start(mp, flags, p) +smbfs_start(mp, flags, td) struct mount *mp; int flags; - struct proc *p; + struct thread *td; { SMBVDEBUG("flags=%04x\n", flags); return 0; @@ -342,12 +353,12 @@ smbfs_start(mp, flags, p) */ /* ARGSUSED */ static int -smbfs_quotactl(mp, cmd, uid, arg, p) +smbfs_quotactl(mp, cmd, uid, arg, td) struct mount *mp; int cmd; uid_t uid; caddr_t arg; - struct proc *p; + struct thread *td; { SMBVDEBUG("return EOPNOTSUPP\n"); return EOPNOTSUPP; @@ -380,20 +391,24 @@ smbfs_uninit(struct vfsconf *vfsp) * smbfs_statfs call */ int -smbfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) +smbfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { struct smbmount *smp = VFSTOSMBFS(mp); struct smbnode *np = smp->sm_root; struct smb_share *ssp = smp->sm_share; struct smb_cred scred; + struct ucred *cred; int error = 0; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + if (np == NULL) return EINVAL; sbp->f_iosize = SSTOVC(ssp)->vc_txmax; /* optimal transfer block size */ sbp->f_spare2 = 0; /* placeholder */ - smb_makescred(&scred, p, p->p_ucred); + smb_makescred(&scred, td, cred); if (SMB_DIALECT(SSTOVC(ssp)) >= SMB_DIALECT_LANMAN2_0) error = smbfs_smb_statfs2(ssp, sbp, &scred); @@ -418,11 +433,11 @@ smbfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) */ /* ARGSUSED */ static int -smbfs_sync(mp, waitfor, cred, p) +smbfs_sync(mp, waitfor, cred, td) struct mount *mp; int waitfor; struct ucred *cred; - struct proc *p; + struct thread *td; { struct vnode *vp; int error, allerror = 0; @@ -442,9 +457,9 @@ loop: if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY) continue; - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) 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/vfs/smbfs/smbfs_vnops.c b/sys/vfs/smbfs/smbfs_vnops.c index af4ad48aad..4c4f1cc7cc 100644 --- a/sys/vfs/smbfs/smbfs_vnops.c +++ b/sys/vfs/smbfs/smbfs_vnops.c @@ -30,13 +30,13 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_vnops.c,v 1.2.2.8 2003/04/04 08:57:23 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_vnops.c,v 1.3 2003/06/23 17:55:37 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_vnops.c,v 1.4 2003/06/25 03:55:52 dillon Exp $ */ #include #include -#include #include #include +#include #include #include #include @@ -136,7 +136,7 @@ smbfs_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; @@ -172,7 +172,7 @@ smbfs_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; @@ -192,19 +192,19 @@ smbfs_open(ap) return 0; } if (np->n_flag & NMODIFIED) { - if ((error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1)) == EINTR) + if ((error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1)) == EINTR) return error; smbfs_attr_cacheremove(vp); - 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.tv_sec = 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.tv_sec != vattr.va_mtime.tv_sec) { - error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1); + error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1); if (error == EINTR) return error; np->n_mtime.tv_sec = vattr.va_mtime.tv_sec; @@ -217,7 +217,7 @@ smbfs_open(ap) accmode = SMB_AM_OPENREAD; if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) accmode = SMB_AM_OPENRW; - smb_makescred(&scred, ap->a_p, ap->a_cred); + smb_makescred(&scred, ap->a_td, ap->a_cred); error = smbfs_smb_open(np, accmode, &scred); if (error) { if (mode & FWRITE) @@ -237,14 +237,14 @@ smbfs_closel(struct vop_close_args *ap) { struct vnode *vp = ap->a_vp; struct smbnode *np = VTOSMB(vp); - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct smb_cred scred; struct vattr vattr; int error; SMBVDEBUG("name=%s, pid=%d, c=%d\n",np->n_name, p->p_pid, np->n_opencount); - smb_makescred(&scred, p, ap->a_cred); + smb_makescred(&scred, td, ap->a_cred); if (np->n_opencount == 0) { if (vp->v_type != VDIR) @@ -261,10 +261,10 @@ smbfs_closel(struct vop_close_args *ap) } error = 0; } else { - error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, p, 1); + error = smbfs_vinvalbuf(vp, V_SAVE, ap->a_cred, td, 1); if (np->n_opencount) return error; - VOP_GETATTR(vp, &vattr, ap->a_cred, p); + VOP_GETATTR(vp, &vattr, ap->a_cred, td); error = smbfs_smb_close(np->n_mount->sm_share, np->n_fid, &np->n_mtime, &scred); } @@ -283,22 +283,22 @@ smbfs_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; int error, dolock; VI_LOCK(vp); dolock = (vp->v_flag & VXLOCK) == 0; if (dolock) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td); else VI_UNLOCK(vp); error = smbfs_closel(ap); if (dolock) - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return error; } @@ -311,7 +311,7 @@ smbfs_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; @@ -327,7 +327,7 @@ smbfs_getattr(ap) if (!error) return 0; SMBVDEBUG("not in the cache\n"); - smb_makescred(&scred, ap->a_p, ap->a_cred); + smb_makescred(&scred, ap->a_td, ap->a_cred); oldsize = np->n_size; error = smbfs_smb_lookup(np, NULL, 0, &fattr, &scred); if (error) { @@ -347,7 +347,7 @@ smbfs_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; @@ -371,7 +371,7 @@ smbfs_setattr(ap) vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) && isreadonly) return EROFS; - smb_makescred(&scred, ap->a_p, ap->a_cred); + smb_makescred(&scred, ap->a_td, ap->a_cred); if (vap->va_size != VNOVAL) { switch (vp->v_type) { case VDIR: @@ -409,9 +409,9 @@ smbfs_setattr(ap) atime = &vap->va_atime; if (mtime != atime) { if (ap->a_cred->cr_uid != VTOSMBFS(vp)->sm_args.uid && - (error = suser_xxx(ap->a_cred, PRISON_ROOT)) && + (error = suser_cred(ap->a_cred, PRISON_ROOT)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, ap->a_p)))) + (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, ap->a_td)))) return (error); #if 0 if (mtime == NULL) @@ -425,13 +425,13 @@ smbfs_setattr(ap) */ if (np->n_opencount == 0) { if (vcp->vc_flags & SMBV_WIN95) { - error = VOP_OPEN(vp, FWRITE, ap->a_cred, ap->a_p); + error = VOP_OPEN(vp, FWRITE, ap->a_cred, ap->a_td); if (!error) { /* error = smbfs_smb_setfattrNT(np, 0, mtime, atime, &scred); - VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);*/ + VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td);*/ if (mtime) np->n_mtime = *mtime; - VOP_CLOSE(vp, FWRITE, ap->a_cred, ap->a_p); + VOP_CLOSE(vp, FWRITE, ap->a_cred, ap->a_td); } } else if ((vcp->vc_sopt.sv_caps & SMB_CAP_NT_SMBS)) { error = smbfs_smb_setptime2(np, mtime, atime, 0, &scred); @@ -461,7 +461,7 @@ smbfs_setattr(ap) * required attributes. */ smbfs_attr_cacheremove(vp); /* 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.tv_sec = vap->va_mtime.tv_sec; return error; } @@ -537,9 +537,9 @@ smbfs_create(ap) *vpp = NULL; if (vap->va_type != VREG) 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_td))) return error; - smb_makescred(&scred, cnp->cn_proc, cnp->cn_cred); + smb_makescred(&scred, cnp->cn_td, cnp->cn_cred); error = smbfs_smb_create(dnp, name, nmlen, &scred); if (error) @@ -574,7 +574,7 @@ smbfs_remove(ap) if (vp->v_type == VDIR || np->n_opencount || vp->v_usecount != 1) return EPERM; - smb_makescred(&scred, cnp->cn_proc, cnp->cn_cred); + smb_makescred(&scred, cnp->cn_td, cnp->cn_cred); error = smbfs_smb_delete(np, &scred); cache_purge(vp); return error; @@ -624,7 +624,7 @@ smbfs_rename(ap) error = EINVAL; goto out; } - smb_makescred(&scred, tcnp->cn_proc, tcnp->cn_cred); + smb_makescred(&scred, tcnp->cn_td, tcnp->cn_cred); /* * It seems that Samba doesn't implement SMB_COM_MOVE call... */ @@ -733,12 +733,12 @@ smbfs_mkdir(ap) int len = cnp->cn_namelen; int error; - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc))) { + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_td))) { return error; } if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) return EEXIST; - smb_makescred(&scred, cnp->cn_proc, cnp->cn_cred); + smb_makescred(&scred, cnp->cn_td, cnp->cn_cred); error = smbfs_smb_mkdir(dnp, name, len, &scred); if (error) return error; @@ -775,7 +775,7 @@ smbfs_rmdir(ap) if (dvp == vp) return EINVAL; - smb_makescred(&scred, cnp->cn_proc, cnp->cn_cred); + smb_makescred(&scred, cnp->cn_td, cnp->cn_cred); error = smbfs_smb_rmdir(np, &scred); dnp->n_flag |= NMODIFIED; smbfs_attr_cacheremove(dvp); @@ -819,13 +819,13 @@ static int smbfs_fsync(ap) struct vop_fsync_args /* { struct vnodeop_desc *a_desc; - struct vnode * a_vp; - struct ucred * a_cred; + struct vnode *a_vp; + struct ucred *a_cred; int a_waitfor; - struct proc * a_p; + struct thread *a_td; } */ *ap; { -/* return (smb_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1));*/ +/* return (smb_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1));*/ return (0); } @@ -887,23 +887,21 @@ smbfs_strategy (ap) { struct buf *bp=ap->a_bp; struct ucred *cr; - struct proc *p; + struct thread *td = NULL; int error = 0; SMBVDEBUG("\n"); if (bp->b_flags & B_PHYS) panic("smbfs physio"); - if (bp->b_flags & B_ASYNC) - p = (struct proc *)0; - else - p = curproc; /* XXX */ + if ((bp->b_flags & B_ASYNC) == 0) + td = curthread; /* XXX */ if (bp->b_flags & B_READ) cr = bp->b_rcred; else cr = bp->b_wcred; if ((bp->b_flags & B_ASYNC) == 0 ) - error = smbfs_doio(bp, cr, p); + error = smbfs_doio(bp, cr, td); return error; } @@ -953,12 +951,12 @@ smbfs_getextattr(struct vop_getextattr_args *ap) IN char *a_name; INOUT struct uio *a_uio; IN struct ucred *a_cred; - IN struct proc *a_p; + IN struct thread *a_td; }; */ { struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; + struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; struct uio *uio = ap->a_uio; const char *name = ap->a_name; @@ -967,10 +965,10 @@ smbfs_getextattr(struct vop_getextattr_args *ap) char buf[10]; int i, attr, error; - error = VOP_ACCESS(vp, VREAD, cred, p); + error = VOP_ACCESS(vp, VREAD, cred, td); if (error) return error; - error = VOP_GETATTR(vp, &vattr, cred, p); + error = VOP_GETATTR(vp, &vattr, cred, td); if (error) return error; if (strcmp(name, "dosattr") == 0) { @@ -1005,7 +1003,7 @@ smbfs_advlock(ap) struct flock *fl = ap->a_fl; caddr_t id = (caddr_t)1 /* ap->a_id */; /* int flags = ap->a_flags;*/ - struct proc *p = curproc; + struct thread *td = curthread; /* XXX */ struct smb_cred scred; off_t start, end, size; int error, lkop; @@ -1040,7 +1038,7 @@ smbfs_advlock(ap) if (end < start) return EINVAL; } - smb_makescred(&scred, p, p ? p->p_ucred : NULL); + smb_makescred(&scred, td, td->td_proc ? td->td_proc->p_ucred : NULL); switch (ap->a_op) { case F_SETLK: switch (fl->l_type) { @@ -1127,7 +1125,7 @@ smbfs_lookup(ap) } */ *ap; { struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct vnode *dvp = ap->a_dvp; struct vnode **vpp = ap->a_vpp; struct vnode *vp; @@ -1165,7 +1163,7 @@ smbfs_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)) != 0) + if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) return error; lockparent = flags & LOCKPARENT; wantparent = flags & (LOCKPARENT|WANTPARENT); @@ -1193,24 +1191,24 @@ smbfs_lookup(ap) error = 0; SMBVDEBUG("cached '.'\n"); } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); /* unlock parent */ + VOP_UNLOCK(dvp, 0, td); /* unlock parent */ cnp->cn_flags |= PDIRUNLOCK; - error = vget(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (!error && lockparent && 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(vp, LK_EXCLUSIVE, p); + error = vget(vp, LK_EXCLUSIVE, td); if (!lockparent || error || !islastcn) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } 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 == VTOSMB(vp)->n_ctime*/) { if (nameiop != LOOKUP && islastcn) cnp->cn_flags |= SAVENAME; @@ -1221,9 +1219,9 @@ smbfs_lookup(ap) } 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) { cnp->cn_flags |= PDIRUNLOCK; @@ -1236,7 +1234,7 @@ smbfs_lookup(ap) */ error = 0; *vpp = NULLVP; - smb_makescred(&scred, p, cnp->cn_cred); + smb_makescred(&scred, td, cnp->cn_cred); fap = &fattr; if (flags & ISDOTDOT) { error = smbfs_smb_lookup(VTOSMB(dnp->n_parent), NULL, 0, fap, @@ -1255,12 +1253,12 @@ smbfs_lookup(ap) * Handle RENAME or CREATE case... */ if ((nameiop == CREATE || nameiop == RENAME) && wantparent && islastcn) { - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, p); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td); if (error) return error; cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (EJUSTRETURN); @@ -1273,7 +1271,7 @@ smbfs_lookup(ap) * handle DELETE case ... */ if (nameiop == DELETE && islastcn) { /* delete last component */ - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, p); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td); if (error) return error; if (isdot) { @@ -1287,13 +1285,13 @@ smbfs_lookup(ap) *vpp = vp; cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return 0; } if (nameiop == RENAME && islastcn && wantparent) { - error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, p); + error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td); if (error) return error; if (isdot) @@ -1304,20 +1302,20 @@ smbfs_lookup(ap) *vpp = vp; 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 = smbfs_nget(mp, dvp, name, nmlen, 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); if (error) { cnp->cn_flags |= PDIRUNLOCK; vput(vp); @@ -1335,7 +1333,7 @@ smbfs_lookup(ap) *vpp = vp; SMBVDEBUG("lookup: getnewvp!\n"); if (!lockparent || !islastcn) { - VOP_UNLOCK(dvp, 0, p); + VOP_UNLOCK(dvp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } } diff --git a/sys/vfs/specfs/spec_vnops.c b/sys/vfs/specfs/spec_vnops.c index 9ad1550524..9a7da712fe 100644 --- a/sys/vfs/specfs/spec_vnops.c +++ b/sys/vfs/specfs/spec_vnops.c @@ -32,7 +32,7 @@ * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 * $FreeBSD: src/sys/miscfs/specfs/spec_vnops.c,v 1.131.2.4 2001/02/26 04:23:20 jlemon Exp $ - * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.4 2003/06/23 17:55:44 dillon Exp $ + * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.5 2003/06/25 03:56:00 dillon Exp $ */ #include @@ -134,10 +134,9 @@ 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 vnode *vp = ap->a_vp; dev_t dev = vp->v_rdev; int error; @@ -192,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->p_thread); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_UNLOCK(vp, 0, ap->a_td); + error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, ap->a_td); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td); if (error) return (error); @@ -239,7 +238,7 @@ spec_read(ap) } */ *ap; { struct vnode *vp; - struct proc *p; + struct thread *td; struct uio *uio; dev_t dev; int error; @@ -247,14 +246,14 @@ spec_read(ap) vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; - p = uio->uio_procp; + td = uio->uio_td; if (uio->uio_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); return (error); } @@ -272,7 +271,7 @@ spec_write(ap) } */ *ap; { struct vnode *vp; - struct proc *p; + struct thread *td; struct uio *uio; dev_t dev; int error; @@ -280,11 +279,11 @@ spec_write(ap) vp = ap->a_vp; dev = vp->v_rdev; uio = ap->a_uio; - p = uio->uio_procp; + td = uio->uio_td; - 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); return (error); } @@ -300,14 +299,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->p_thread)); + ap->a_data, ap->a_fflag, ap->a_td)); } /* ARGSUSED */ @@ -317,13 +316,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->p_thread); + return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_td); } /* ARGSUSED */ @@ -352,7 +351,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; @@ -428,11 +427,11 @@ static int spec_inactive(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); } @@ -462,12 +461,12 @@ spec_strategy(ap) vp = ap->a_vp; if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) { if ((bp->b_flags & B_READ) == 0) { - if (bp->b_lock.lk_lockholder == LK_KERNPROC) + if (bp->b_lock.lk_lockholder == LK_KERNTHREAD) mp->mnt_stat.f_asyncwrites++; else mp->mnt_stat.f_syncwrites++; } else { - if (bp->b_lock.lk_lockholder == LK_KERNPROC) + if (bp->b_lock.lk_lockholder == LK_KERNTHREAD) mp->mnt_stat.f_asyncreads++; else mp->mnt_stat.f_syncreads++; @@ -554,11 +553,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 proc *p = ap->a_td->td_proc; struct vnode *vp = ap->a_vp; - struct proc *p = ap->a_p; dev_t dev = vp->v_rdev; /* @@ -591,7 +590,7 @@ spec_close(ap) } else if (vcount(vp) > 1) { return (0); } - return (devsw(dev)->d_close(dev, ap->a_fflag, S_IFCHR, p->p_thread)); + return (devsw(dev)->d_close(dev, ap->a_fflag, S_IFCHR, ap->a_td)); } /* diff --git a/sys/vfs/ufs/ffs_balloc.c b/sys/vfs/ufs/ffs_balloc.c index 580b89b269..2ec5875699 100644 --- a/sys/vfs/ufs/ffs_balloc.c +++ b/sys/vfs/ufs/ffs_balloc.c @@ -32,7 +32,7 @@ * * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95 * $FreeBSD: src/sys/ufs/ffs/ffs_balloc.c,v 1.26.2.1 2002/10/10 19:48:20 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_balloc.c,v 1.3 2003/06/19 01:55:08 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_balloc.c,v 1.4 2003/06/25 03:56:11 dillon Exp $ */ #include @@ -80,7 +80,7 @@ ffs_balloc(ap) 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 = ap->a_vp; ip = VTOI(vp); @@ -363,7 +363,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; @@ -400,6 +400,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/vfs/ufs/ffs_extern.h b/sys/vfs/ufs/ffs_extern.h index a03764c3ab..fa6b593610 100644 --- a/sys/vfs/ufs/ffs_extern.h +++ b/sys/vfs/ufs/ffs_extern.h @@ -32,7 +32,7 @@ * * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 * $FreeBSD: src/sys/ufs/ffs/ffs_extern.h,v 1.30 2000/01/09 22:40:02 mckusick Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_extern.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_extern.h,v 1.3 2003/06/25 03:56:11 dillon Exp $ */ #ifndef _UFS_FFS_EXTERN_H @@ -60,6 +60,7 @@ struct inode; struct malloc_type; struct mount; struct proc; +struct thread; struct sockaddr; struct statfs; struct ucred; @@ -78,22 +79,22 @@ ufs_daddr_t ffs_blkpref __P((struct inode *, ufs_daddr_t, int, ufs_daddr_t *)); int ffs_bmap __P((struct vop_bmap_args *)); void ffs_clrblock __P((struct fs *, u_char *, ufs_daddr_t)); 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 vnode *, 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_reallocblks __P((struct vop_reallocblks_args *)); int ffs_realloccg __P((struct inode *, ufs_daddr_t, ufs_daddr_t, int, int, struct ucred *, struct buf **)); void ffs_setblock __P((struct fs *, u_char *, ufs_daddr_t)); -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 **)); @@ -111,7 +112,7 @@ 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_flushfiles __P((struct mount *, int, struct proc *)); +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/vfs/ufs/ffs_inode.c b/sys/vfs/ufs/ffs_inode.c index d6bd320cf0..4a4aa21f31 100644 --- a/sys/vfs/ufs/ffs_inode.c +++ b/sys/vfs/ufs/ffs_inode.c @@ -32,7 +32,7 @@ * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 * $FreeBSD: src/sys/ufs/ffs/ffs_inode.c,v 1.56.2.5 2002/02/05 18:35:03 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.3 2003/06/25 03:56:11 dillon Exp $ */ #include "opt_quota.h" @@ -129,12 +129,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; @@ -190,14 +190,14 @@ 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); } else { #ifdef QUOTA (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)); } @@ -257,7 +257,7 @@ ffs_truncate(vp, length, flags, cred, p) */ if (DOINGSOFTDEP(ovp) && lbn < NDADDR && fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize && - (error = VOP_FSYNC(ovp, cred, MNT_WAIT, p)) != 0) { + (error = VOP_FSYNC(ovp, cred, MNT_WAIT, td)) != 0) { return (error); } oip->i_size = length; @@ -312,7 +312,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/vfs/ufs/ffs_rawread.c b/sys/vfs/ufs/ffs_rawread.c index 28f53d4454..5819976d29 100644 --- a/sys/vfs/ufs/ffs_rawread.c +++ b/sys/vfs/ufs/ffs_rawread.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ufs/ffs/ffs_rawread.c,v 1.3.2.2 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.3 2003/06/25 03:56:11 dillon Exp $ */ #include @@ -411,8 +411,8 @@ ffs_rawread(struct vnode *vp, uio->uio_iovcnt == 1 && uio->uio_segflg == UIO_USERSPACE && uio->uio_resid == uio->uio_iov->iov_len && - (((uio->uio_procp != NULL) ? uio->uio_procp : curproc)->p_flag & - P_DEADLKTREAT) == 0) { + (((uio->uio_td != NULL) ? uio->uio_td : curthread)->td_flags & + TDF_DEADLKTREAT) == 0) { int secsize; /* Media sector size */ off_t filebytes; /* Bytes left of file */ int blockbytes; /* Bytes left of file in full blocks */ diff --git a/sys/vfs/ufs/ffs_softdep.c b/sys/vfs/ufs/ffs_softdep.c index dc90cdab61..e4ac01a8ed 100644 --- a/sys/vfs/ufs/ffs_softdep.c +++ b/sys/vfs/ufs/ffs_softdep.c @@ -37,7 +37,7 @@ * * from: @(#)ffs_softdep.c 9.59 (McKusick) 6/21/00 * $FreeBSD: src/sys/ufs/ffs/ffs_softdep.c,v 1.57.2.11 2002/02/05 18:46:53 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_softdep.c,v 1.3 2003/06/19 01:55:08 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_softdep.c,v 1.4 2003/06/25 03:56:11 dillon Exp $ */ /* @@ -135,7 +135,6 @@ static struct malloc_type *memtype[] = { */ #define TYPENAME(type) \ ((unsigned)(type) < D_LAST ? memtype[type]->ks_shortdesc : "???") -#define CURPROC curproc /* * End system adaptaion definitions. */ @@ -146,8 +145,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)); @@ -237,10 +236,12 @@ static struct lockit { #define FREE_LOCK(lk) splx((lk)->lkt_spl) #else /* DEBUG */ +#define NOHOLDER ((struct thread *)-1) +#define SPECIAL_FLAG ((struct thread *)-2) 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 *)); @@ -254,18 +255,18 @@ static void acquire_lock(lk) struct lockit *lk; { - pid_t holder; + thread_t 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++; } @@ -274,9 +275,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); } @@ -288,7 +289,7 @@ softdep_panic(msg) char *msg; { - if (lk.lkt_held != -1) + if (lk.lkt_held != NOHOLDER) FREE_LOCK(&lk); panic(msg); } @@ -317,14 +318,14 @@ interlocked_sleep(lk, op, ident, flags, wmesg, timo) const char *wmesg; int timo; { - pid_t holder; + thread_t holder; int s, retval; s = lk->lkt_spl; # ifdef DEBUG - if (lk->lkt_held == -1) + if (lk->lkt_held == NOHOLDER) panic("interlocked_sleep: lock not held"); - lk->lkt_held = -1; + lk->lkt_held = NOHOLDER; # endif /* DEBUG */ switch (op) { case SLEEP: @@ -337,15 +338,15 @@ interlocked_sleep(lk, op, ident, flags, wmesg, timo) panic("interlocked_sleep: unknown operation"); } # ifdef DEBUG - 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("interlocked_sleep: locking against self"); else - panic("interlocked_sleep: lock held by %d", holder); + panic("interlocked_sleep: lock held by %p", holder); } - lk->lkt_held = CURPROC->p_pid; + lk->lkt_held = curthread; lockcnt++; # endif /* DEBUG */ lk->lkt_spl = s; @@ -357,7 +358,7 @@ interlocked_sleep(lk, op, ident, flags, wmesg, timo) */ struct sema { int value; - pid_t holder; + thread_t holder; char *name; int prio; int timo; @@ -373,7 +374,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; @@ -397,7 +398,7 @@ sema_get(semap, interlock) } return (0); } - semap->holder = CURPROC->p_pid; + semap->holder = curthread; if (interlock != NULL) FREE_LOCK(interlock); return (1); @@ -408,8 +409,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"); } @@ -417,7 +418,7 @@ sema_release(semap) semap->value = 0; wakeup(semap); } - semap->holder = -1; + semap->holder = NOHOLDER; } /* @@ -450,7 +451,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); @@ -465,7 +466,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); @@ -482,12 +483,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"); } @@ -507,7 +508,7 @@ static int tickdelay = 2; /* number of ticks to pause during slowdown */ static int *stat_countp; /* statistic to count in proc_waiting timeout */ static int proc_waiting; /* tracks whether we have a timeout posted */ 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 */ @@ -556,7 +557,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"); } @@ -582,7 +583,7 @@ static int softdep_process_worklist(matchmnt) struct mount *matchmnt; { - struct proc *p = CURPROC; + thread_t td = curthread; int matchcnt, loopcount; long starttime; @@ -590,7 +591,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; /* @@ -609,12 +610,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); } @@ -636,12 +637,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); } @@ -699,7 +700,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) { @@ -776,14 +777,15 @@ softdep_move_dependencies(oldbp, newbp) * Purge the work list of all items associated with a particular mount point. */ int -softdep_flushfiles(oldmnt, flags, p) - struct mount *oldmnt; - int flags; - struct proc *p; +softdep_flushfiles(struct mount *oldmnt, int flags, struct thread *td) { struct vnode *devvp; + struct ucred *cred; int error, loopcnt; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + /* * Await our turn to clear out the queue, then serialize access. */ @@ -794,7 +796,7 @@ softdep_flushfiles(oldmnt, flags, p) } softdep_worklist_busy = -1; - if ((error = ffs_flushfiles(oldmnt, flags, p)) != 0) { + if ((error = ffs_flushfiles(oldmnt, flags, td)) != 0) { softdep_worklist_busy = 0; if (softdep_worklist_req) wakeup(&softdep_worklist_req); @@ -814,7 +816,7 @@ 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 we still found nothing to do, we are really done. @@ -822,9 +824,9 @@ softdep_flushfiles(oldmnt, flags, p) if (softdep_process_worklist(oldmnt) == 0) break; } - 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, cred, MNT_WAIT, td); + VOP_UNLOCK(devvp, 0, td); if (error) break; } @@ -899,7 +901,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; @@ -968,7 +970,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; @@ -1242,7 +1244,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) @@ -1412,7 +1414,7 @@ allocdirect_merge(adphead, newadp, oldadp) struct freefrag *freefrag; #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 || @@ -1963,7 +1965,7 @@ free_allocdirect(adphead, adp, delay) { #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) @@ -2252,7 +2254,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) @@ -2453,7 +2455,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); @@ -2794,13 +2796,16 @@ static void handle_workitem_remove(dirrem) struct dirrem *dirrem; { - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct ucred *cred; struct inodedep *inodedep; struct vnode *vp; struct inode *ip; ino_t oldinum; int error; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; if ((error = VFS_VGET(dirrem->dm_mnt, dirrem->dm_oldinum, &vp)) != 0) { softdep_error("handle_workitem_remove: vget", error); return; @@ -2843,7 +2848,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,cred, td)) != 0) softdep_error("handle_workitem_remove: truncate", error); /* * Rename a directory to a new parent. Since, we are both deleting @@ -3226,9 +3231,9 @@ softdep_disk_write_complete(bp) struct bmsafemap *bmsafemap; #ifdef DEBUG - if (lk.lkt_held != -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) { @@ -3294,7 +3299,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); @@ -3305,7 +3310,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"); } } @@ -3316,7 +3321,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 */ @@ -3330,9 +3335,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 } @@ -3352,7 +3357,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"); } /* @@ -3390,7 +3395,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 */ @@ -3422,7 +3427,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; @@ -3456,7 +3461,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; @@ -3487,12 +3492,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, @@ -3501,7 +3506,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, @@ -3519,7 +3524,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) { @@ -3559,7 +3564,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; @@ -3580,7 +3585,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 */ @@ -3588,7 +3593,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); @@ -3638,7 +3643,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; @@ -3675,7 +3680,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; @@ -3700,7 +3705,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 *) @@ -3918,11 +3923,14 @@ softdep_fsync(vp) struct inode *ip; struct buf *bp; struct fs *fs; - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct proc *p = td->td_proc; int error, flushparent; ino_t parentino; ufs_lbn_t lbn; + KKASSERT(p); + ip = VTOI(vp); fs = ip->i_fs; ACQUIRE_LOCK(&lk); @@ -3980,9 +3988,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); if (flushparent) { @@ -4316,7 +4324,7 @@ loop: if (vn_isdisk(vp, NULL) && vp->v_specmountpoint && !VOP_ISLOCKED(vp, NULL) && (error = VFS_SYNC(vp->v_specmountpoint, MNT_WAIT, ap->a_cred, - ap->a_p)) != 0) + ap->a_td)) != 0) return (error); return (0); } @@ -4420,7 +4428,8 @@ flush_pagedep_deps(pvp, mp, diraddhdp) struct mount *mp; struct diraddhd *diraddhdp; { - struct proc *p = CURPROC; /* XXX */ + struct thread *td = curthread; /* XXX */ + struct ucred *cr; struct inodedep *inodedep; struct ufsmount *ump; struct diradd *dap; @@ -4429,6 +4438,9 @@ flush_pagedep_deps(pvp, mp, diraddhdp) struct buf *bp; ino_t inum; + KKASSERT(td->td_proc); + cr = td->td_proc->p_ucred; + ump = VFSTOUFS(mp); while ((dap = LIST_FIRST(diraddhdp)) != NULL) { /* @@ -4467,8 +4479,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, cr, MNT_NOWAIT, td)) || + (error=VOP_FSYNC(vp, cr, MNT_NOWAIT, td))) { vput(vp); break; } @@ -4570,12 +4582,12 @@ request_cleanup(resource, islocked) int resource; int islocked; { - struct proc *p = CURPROC; + struct thread *td = curthread; /* XXX */ /* * 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. @@ -4663,8 +4675,7 @@ pause_timer(arg) * reduce the number of dirrem, freefile, and freeblks dependency structures. */ static void -clear_remove(p) - struct proc *p; +clear_remove(struct thread *td) { struct pagedep_hashhead *pagedephd; struct pagedep *pagedep; @@ -4673,6 +4684,10 @@ clear_remove(p) struct vnode *vp; int error, cnt; ino_t ino; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; ACQUIRE_LOCK(&lk); for (cnt = 0; cnt < pagedep_hash; cnt++) { @@ -4689,7 +4704,7 @@ clear_remove(p) softdep_error("clear_remove: vget", error); return; } - if ((error = VOP_FSYNC(vp, p->p_ucred, MNT_NOWAIT, p))) + if ((error = VOP_FSYNC(vp, cred, MNT_NOWAIT, td))) softdep_error("clear_remove: fsync", error); drain_output(vp, 0); vput(vp); @@ -4704,9 +4719,9 @@ clear_remove(p) * the number of inodedep dependency structures. */ static void -clear_inodedeps(p) - struct proc *p; +clear_inodedeps(struct thread *td) { + struct ucred *cred; struct inodedep_hashhead *inodedephd; struct inodedep *inodedep; static int next = 0; @@ -4716,6 +4731,9 @@ clear_inodedeps(p) int error, cnt; ino_t firstino, lastino, ino; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + ACQUIRE_LOCK(&lk); /* * Pick a random inode dependency to be cleared. @@ -4759,10 +4777,10 @@ clear_inodedeps(p) return; } if (ino == lastino) { - if ((error = VOP_FSYNC(vp, p->p_ucred, MNT_WAIT, p))) + if ((error = VOP_FSYNC(vp, cred, 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, cred, MNT_NOWAIT, td))) softdep_error("clear_inodedeps: fsync2", error); drain_output(vp, 0); } diff --git a/sys/vfs/ufs/ffs_vfsops.c b/sys/vfs/ufs/ffs_vfsops.c index 9c63b76db1..47a30225df 100644 --- a/sys/vfs/ufs/ffs_vfsops.c +++ b/sys/vfs/ufs/ffs_vfsops.c @@ -32,15 +32,15 @@ * * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95 * $FreeBSD: src/sys/ufs/ffs/ffs_vfsops.c,v 1.117.2.10 2002/06/23 22:34:52 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_vfsops.c,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_vfsops.c,v 1.3 2003/06/25 03:56:11 dillon Exp $ */ #include "opt_quota.h" #include #include -#include #include +#include #include #include #include @@ -65,10 +65,10 @@ static MALLOC_DEFINE(M_FFSNODE, "FFS node", "FFS vnode private part"); static int ffs_sbupdate __P((struct ufsmount *, int)); -static int ffs_reload __P((struct mount *,struct ucred *,struct proc *)); +static int ffs_reload __P((struct mount *,struct ucred *,struct thread *)); static int ffs_oldfscompat __P((struct fs *)); static int ffs_mount __P((struct mount *, char *, caddr_t, - struct nameidata *, struct proc *)); + struct nameidata *, struct thread *)); static int ffs_init __P((struct vfsconf *)); static struct vfsops ufs_vfsops = { @@ -128,12 +128,12 @@ VFS_SET(ufs_vfsops, ufs, 0); * namei() if it is a genuine NULL from the user. */ static 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; int err = 0; @@ -144,6 +144,10 @@ ffs_mount( mp, path, data, ndp, p) register struct fs *fs; int error, flags, ronly = 0; mode_t accessmode; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; /* * Use NULL path to flag a root mount @@ -160,7 +164,7 @@ ffs_mount( mp, path, data, ndp, p) return (err); } - if( ( err = ffs_mountfs(rootvp, mp, p, M_FFSNODE)) != 0) { + if( ( err = ffs_mountfs(rootvp, mp, td, M_FFSNODE)) != 0) { /* fs specific cleanup (if any)*/ goto error_1; } @@ -194,7 +198,7 @@ ffs_mount( mp, path, data, ndp, p) /* * Flush any dirty data. */ - VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p); + VFS_SYNC(mp, MNT_WAIT, cred, td); /* * Check for and optionally get rid of files open * for writing. @@ -203,14 +207,14 @@ ffs_mount( mp, path, data, ndp, p) if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; if (mp->mnt_flag & MNT_SOFTDEP) { - err = softdep_flushfiles(mp, flags, p); + err = softdep_flushfiles(mp, flags, td); } else { - err = ffs_flushfiles(mp, flags, p); + err = ffs_flushfiles(mp, flags, td); } ronly = 1; } if (!err && (mp->mnt_flag & MNT_RELOAD)) - err = ffs_reload(mp, ndp->ni_cnd.cn_cred, p); + err = ffs_reload(mp, ndp->ni_cnd.cn_cred, td); if (err) { goto error_1; } @@ -219,14 +223,14 @@ ffs_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) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); + if (cred->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); + cred, td)) != 0) { + VOP_UNLOCK(devvp, 0, td); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } fs->fs_flags &= ~FS_UNCLEAN; @@ -247,7 +251,7 @@ ffs_mount( mp, path, data, ndp, p) /* check to see if we need to start softdep */ if (fs->fs_flags & FS_DOSOFTDEP) { - err = softdep_mount(devvp, mp, fs, p->p_ucred); + err = softdep_mount(devvp, mp, fs, cred); if (err) goto error_1; } @@ -279,7 +283,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); err = namei(ndp); if (err) { /* can't get devvp!*/ @@ -296,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 (cred->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, cred, td)) != 0) { vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, p); + VOP_UNLOCK(devvp, 0, td); } if (mp->mnt_flag & MNT_UPDATE) { @@ -363,7 +367,7 @@ ffs_mount( mp, path, data, ndp, p) &size); /* real size*/ bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - err = ffs_mountfs(devvp, mp, p, M_FFSNODE); + err = ffs_mountfs(devvp, mp, td, M_FFSNODE); } if (err) { goto error_2; @@ -376,7 +380,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; @@ -416,12 +420,9 @@ success: * 6) re-read inode data for all active vnodes. */ static int -ffs_reload(mp, cred, p) - register struct mount *mp; - struct ucred *cred; - struct proc *p; +ffs_reload(struct mount *mp, struct ucred *cred, struct thread *td) { - register struct vnode *vp, *nvp, *devvp; + struct vnode *vp, *nvp, *devvp; struct inode *ip; void *space; struct buf *bp; @@ -431,15 +432,17 @@ ffs_reload(mp, cred, p) int i, blks, size, error; int32_t *lp; + KKASSERT(td->td_proc && td->td_proc->p_ucred == cred); + if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EINVAL); /* * 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"); @@ -450,16 +453,16 @@ ffs_reload(mp, cred, p) * block device. See ffs_mountmfs() for more details. */ if (devvp->v_tag != VT_MFS && 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, cred); simple_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; @@ -529,17 +532,17 @@ loop: /* * Step 4: invalidate all inactive vnodes. */ - if (vrecycle(vp, &mntvnode_slock, p)) + if (vrecycle(vp, &mntvnode_slock, td)) goto loop; /* * Step 5: invalidate all cached file data. */ simple_lock(&vp->v_interlock); simple_unlock(&mntvnode_slock); - 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. @@ -567,10 +570,10 @@ loop: * 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; @@ -587,7 +590,7 @@ ffs_mountfs(devvp, mp, p, malloctype) int ncount; dev = devvp->v_rdev; - cred = p ? p->p_ucred : NOCRED; + cred = td->td_proc ? td->td_proc->p_ucred : NOCRED; /* XXX */ /* * Disallow multiple mounts of the same device. * Disallow mounting of a device that is currently in use @@ -601,9 +604,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); @@ -614,16 +617,16 @@ ffs_mountfs(devvp, mp, p, malloctype) * increases the opportunity for metadata caching. */ if (devvp->v_tag != VT_MFS && 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, cred); simple_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 != 0) @@ -631,7 +634,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; @@ -779,7 +782,7 @@ out: devvp->v_specmountpoint = 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); @@ -824,10 +827,7 @@ ffs_oldfscompat(fs) * unmount system call */ int -ffs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; +ffs_unmount(struct mount *mp, int mntflags, struct thread *td) { register struct ufsmount *ump; register struct fs *fs; @@ -838,10 +838,10 @@ ffs_unmount(mp, mntflags, p) flags |= FORCECLOSE; } 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); } ump = VFSTOUFS(mp); @@ -856,9 +856,9 @@ ffs_unmount(mp, mntflags, p) } ump->um_devvp->v_specmountpoint = 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); @@ -874,13 +874,14 @@ ffs_unmount(mp, mntflags, p) * Flush out all the files in a filesystem. */ int -ffs_flushfiles(mp, flags, p) - register struct mount *mp; - int flags; - struct proc *p; +ffs_flushfiles(struct mount *mp, int flags, struct thread *td) { - register struct ufsmount *ump; + struct ufsmount *ump; int error; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; ump = VFSTOUFS(mp); #ifdef QUOTA @@ -908,9 +909,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, cred, MNT_WAIT, td); + VOP_UNLOCK(ump->um_devvp, 0, td); return (error); } @@ -918,10 +919,7 @@ ffs_flushfiles(mp, flags, p) * Get file system statistics. */ int -ffs_statfs(mp, sbp, p) - struct mount *mp; - register struct statfs *sbp; - struct proc *p; +ffs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { register struct ufsmount *ump; register struct fs *fs; @@ -956,11 +954,7 @@ ffs_statfs(mp, sbp, p) * Note: we are always called with the filesystem marked `MPBUSY'. */ int -ffs_sync(mp, waitfor, cred, p) - struct mount *mp; - int waitfor; - struct ucred *cred; - struct proc *p; +ffs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td) { struct vnode *nvp, *vp; struct inode *ip; @@ -1001,15 +995,15 @@ loop: } if (vp->v_type != VCHR) { simple_unlock(&mntvnode_slock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT, td); if (error) { simple_lock(&mntvnode_slock); if (error == ENOENT) goto loop; } else { - 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); simple_lock(&mntvnode_slock); } @@ -1037,10 +1031,10 @@ loop: if (waitfor != MNT_LAZY) { if (ump->um_mountp->mnt_flag & MNT_SOFTDEP) waitfor = MNT_NOWAIT; - 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); } #ifdef QUOTA qsync(mp); diff --git a/sys/vfs/ufs/quota.h b/sys/vfs/ufs/quota.h index 15b754377f..17406c3ffa 100644 --- a/sys/vfs/ufs/quota.h +++ b/sys/vfs/ufs/quota.h @@ -35,7 +35,7 @@ * * @(#)quota.h 8.3 (Berkeley) 8/19/94 * $FreeBSD: src/sys/ufs/ufs/quota.h,v 1.15.2.1 2003/02/27 12:04:13 das Exp $ - * $DragonFly: src/sys/vfs/ufs/quota.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/quota.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _UFS_UFS_QUOTA_H_ @@ -175,6 +175,7 @@ struct dquot { struct inode; struct mount; struct proc; +struct thread; struct ucred; struct vnode; @@ -185,11 +186,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 *, struct mount *, int)); +int quotaon __P((struct thread *, 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 *)); #else /* !_KERNEL */ diff --git a/sys/vfs/ufs/ufs_extern.h b/sys/vfs/ufs/ufs_extern.h index 3469b2fb3f..9d2a5ac492 100644 --- a/sys/vfs/ufs/ufs_extern.h +++ b/sys/vfs/ufs/ufs_extern.h @@ -32,7 +32,7 @@ * * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 * $FreeBSD: src/sys/ufs/ufs/ufs_extern.h,v 1.27.2.1 2000/12/28 11:01:46 ps Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_extern.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_extern.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _UFS_UFS_EXTERN_H_ @@ -89,7 +89,7 @@ void ufs_itimes __P((struct vnode *vp)); int ufs_lookup __P((struct vop_cachedlookup_args *)); int ufs_reclaim __P((struct vop_reclaim_args *)); 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/vfs/ufs/ufs_ihash.c b/sys/vfs/ufs/ufs_ihash.c index 07b4b22496..f3b70e4ee1 100644 --- a/sys/vfs/ufs/ufs_ihash.c +++ b/sys/vfs/ufs/ufs_ihash.c @@ -32,7 +32,7 @@ * * @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95 * $FreeBSD: src/sys/ufs/ufs/ufs_ihash.c,v 1.20 1999/08/28 00:52:29 peter Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_ihash.c,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_ihash.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #include @@ -96,11 +96,9 @@ ufs_ihashlookup(dev, inum) * to it. If it is in core, but locked, wait for it. */ struct vnode * -ufs_ihashget(dev, inum) - dev_t dev; - ino_t inum; +ufs_ihashget(dev_t dev, ino_t inum) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct inode *ip; struct vnode *vp; @@ -111,7 +109,7 @@ loop: vp = ITOV(ip); simple_lock(&vp->v_interlock); simple_unlock(&ufs_ihash_slock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) goto loop; return (vp); } @@ -124,14 +122,13 @@ loop: * Insert the inode into the hash table, and return it locked. */ void -ufs_ihashins(ip) - struct inode *ip; +ufs_ihashins(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_lock, LK_EXCLUSIVE, (struct simplelock *)0, p); + lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, td); simple_lock(&ufs_ihash_slock); ipp = INOHASH(ip->i_dev, ip->i_number); diff --git a/sys/vfs/ufs/ufs_inode.c b/sys/vfs/ufs/ufs_inode.c index e65ece4da7..98abc0d779 100644 --- a/sys/vfs/ufs/ufs_inode.c +++ b/sys/vfs/ufs/ufs_inode.c @@ -37,7 +37,7 @@ * * @(#)ufs_inode.c 8.9 (Berkeley) 5/14/95 * $FreeBSD: src/sys/ufs/ufs/ufs_inode.c,v 1.25.2.3 2002/07/05 22:42:31 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_inode.c,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_inode.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #include "opt_quota.h" @@ -66,12 +66,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) @@ -87,7 +87,7 @@ ufs_inactive(ap) if (!getinoquota(ip)) (void)chkiq(ip, -1, NOCRED, FORCE); #endif - error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, p); + error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, td); ip->i_rdev = 0; mode = ip->i_mode; ip->i_mode = 0; @@ -97,13 +97,13 @@ ufs_inactive(ap) if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) UFS_UPDATE(vp, 0); 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, (struct simplelock *)0, p); + vrecycle(vp, (struct simplelock *)0, td); return (error); } @@ -114,7 +114,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/vfs/ufs/ufs_lookup.c b/sys/vfs/ufs/ufs_lookup.c index f76020ad8a..d9b8be8a23 100644 --- a/sys/vfs/ufs/ufs_lookup.c +++ b/sys/vfs/ufs/ufs_lookup.c @@ -37,7 +37,7 @@ * * @(#)ufs_lookup.c 8.15 (Berkeley) 6/16/95 * $FreeBSD: src/sys/ufs/ufs/ufs_lookup.c,v 1.33.2.7 2001/09/22 19:22:13 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_lookup.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_lookup.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #include "opt_ufs.h" @@ -45,9 +45,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -154,7 +154,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_td; bp = NULL; slotoffset = -1; @@ -398,7 +398,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_td); if (error) return (error); /* @@ -443,7 +443,7 @@ notfound: */ cnp->cn_flags |= SAVENAME; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (EJUSTRETURN); @@ -488,7 +488,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_td); if (error) return (error); /* @@ -507,10 +507,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) @@ -530,7 +530,7 @@ found: } *vpp = tdp; if (!lockparent) { - VOP_UNLOCK(vdp, 0, p); + VOP_UNLOCK(vdp, 0, td); cnp->cn_flags |= PDIRUNLOCK; } return (0); @@ -543,7 +543,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_td)) != 0) return (error); /* * Careful about locking second inode. @@ -552,10 +552,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) @@ -563,7 +563,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); @@ -590,15 +590,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); } @@ -613,7 +613,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; @@ -737,8 +737,8 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) struct componentname *cnp; struct buf *newdirbp; { - struct ucred *cr; - struct proc *p; + struct ucred *cred; + struct thread *td = curthread; /* XXX */ int newentrysize; struct inode *dp; struct buf *bp; @@ -747,8 +747,8 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) int error, ret, blkoff, loc, spacefree, flags; char *dirbuf; - p = curproc; /* XXX */ - cr = p->p_ucred; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; dp = VTOI(dvp); newentrysize = DIRSIZ(OFSFMT(dvp), dirp); @@ -766,7 +766,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) if (!DOINGSOFTDEP(dvp) && !DOINGASYNC(dvp)) flags |= B_SYNC; if ((error = VOP_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ, - cr, flags, &bp)) != 0) { + cred, flags, &bp)) != 0) { if (DOINGSOFTDEP(dvp) && newdirbp != NULL) bdwrite(newdirbp); return (error); @@ -945,14 +945,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, cred, td); if (tvp != NULL) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, td); } return (error); } @@ -1120,7 +1120,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, NULL); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. @@ -1191,7 +1191,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, NULL); if (error != 0) break; # if (BYTE_ORDER == LITTLE_ENDIAN) diff --git a/sys/vfs/ufs/ufs_quota.c b/sys/vfs/ufs/ufs_quota.c index dd5771c40a..5cf86ee674 100644 --- a/sys/vfs/ufs/ufs_quota.c +++ b/sys/vfs/ufs/ufs_quota.c @@ -35,16 +35,16 @@ * * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 * $FreeBSD: src/sys/ufs/ufs/ufs_quota.c,v 1.27.2.3 2002/01/15 10:33:32 phk Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_quota.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_quota.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #include #include #include -#include #include #include #include +#include #include #include #include @@ -384,8 +384,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; @@ -396,21 +396,25 @@ quotaon(p, mp, type, fname) struct dquot *dq; int error; struct nameidata nd; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; vpp = &ump->um_quotas[type]; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td); error = vn_open(&nd, FREAD|FWRITE, 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, cred, 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; @@ -419,8 +423,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(cred); + ump->um_cred[type] = cred; ump->um_btime[type] = MAX_DQ_TIME; ump->um_itime[type] = MAX_IQ_TIME; if (dqget(NULLVP, 0, ump, type, &dq) == 0) { @@ -440,7 +444,7 @@ again: nextvp = TAILQ_NEXT(vp, v_nmntvnodes); if (vp->v_type == VNON || vp->v_writecount == 0) continue; - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) goto again; error = getinoquota(VTOI(vp)); if (error) { @@ -453,7 +457,7 @@ again: } ump->um_qflags[type] &= ~QTF_OPENING; if (error) - quotaoff(p, mp, type); + quotaoff(td, mp, type); return (error); } @@ -461,18 +465,19 @@ again: * Q_QUOTAOFF - turn off disk quotas for a filesystem. */ int -quotaoff(p, mp, type) - struct proc *p; - struct mount *mp; - register int type; +quotaoff(struct thread *td, struct mount *mp, int type) { struct vnode *vp; struct vnode *qvp, *nextvp; struct ufsmount *ump = VFSTOUFS(mp); struct dquot *dq; struct inode *ip; + struct ucred *cred; int error; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + if ((qvp = ump->um_quotas[type]) == NULLVP) return (0); ump->um_qflags[type] |= QTF_CLOSING; @@ -485,7 +490,7 @@ again: nextvp = TAILQ_NEXT(vp, v_nmntvnodes); if (vp->v_type == VNON) continue; - if (vget(vp, LK_EXCLUSIVE, p)) + if (vget(vp, LK_EXCLUSIVE, td)) goto again; ip = VTOI(vp); dq = ip->i_dquot[type]; @@ -497,7 +502,7 @@ again: } dqflush(qvp); qvp->v_flag &= ~VSYSTEM; - error = vn_close(qvp, FREAD|FWRITE, p->p_ucred, p); + error = vn_close(qvp, FREAD|FWRITE, cred, td); ump->um_quotas[type] = NULLVP; crfree(ump->um_cred[type]); ump->um_cred[type] = NOCRED; @@ -644,11 +649,10 @@ setuse(mp, id, type, addr) * Q_SYNC - sync quota files to disk. */ int -qsync(mp) - struct mount *mp; +qsync(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; @@ -676,7 +680,7 @@ again: continue; simple_lock(&vp->v_interlock); simple_unlock(&mntvnode_slock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); + error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { simple_lock(&mntvnode_slock); if (error == ENOENT) @@ -735,7 +739,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; @@ -792,7 +796,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; @@ -807,12 +811,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 = NULL; 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; @@ -882,11 +886,9 @@ dqrele(vp, dq) * Update the disk quota in the quota file. */ static int -dqsync(vp, dq) - struct vnode *vp; - struct dquot *dq; +dqsync(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; @@ -899,13 +901,13 @@ dqsync(vp, dq) if ((dqvp = dq->dq_ump->um_quotas[dq->dq_type]) == NULLVP) panic("dqsync: file"); 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); } } @@ -918,7 +920,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 = NULL; error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]); if (auio.uio_resid && error == 0) error = EIO; @@ -926,7 +928,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/vfs/ufs/ufs_readwrite.c b/sys/vfs/ufs/ufs_readwrite.c index f6eb91598b..bd34547ceb 100644 --- a/sys/vfs/ufs/ufs_readwrite.c +++ b/sys/vfs/ufs/ufs_readwrite.c @@ -32,7 +32,7 @@ * * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 * $FreeBSD: src/sys/ufs/ufs/ufs_readwrite.c,v 1.65.2.14 2003/04/04 22:21:29 tegge Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_readwrite.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_readwrite.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #define BLKSIZE(a, b, c) blksize(a, b, c) @@ -411,12 +411,12 @@ WRITE(ap) register struct inode *ip; register FS *fs; struct buf *bp; - struct proc *p; ufs_daddr_t lbn; off_t osize; int seqcount; int blkoffset, error, extended, flags, ioflag, resid, size, xfersize; vm_object_t object; + struct thread *td; extended = 0; seqcount = ap->a_ioflag >> 16; @@ -467,11 +467,11 @@ 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->td_proc && uio->uio_offset + uio->uio_resid > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - psignal(p, SIGXFSZ); + td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { + psignal(td->td_proc, SIGXFSZ); if (object) vm_object_vndeallocate(object); return (EFBIG); @@ -595,7 +595,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/vfs/ufs/ufs_vfsops.c b/sys/vfs/ufs/ufs_vfsops.c index abd917eb2b..cc2139720d 100644 --- a/sys/vfs/ufs/ufs_vfsops.c +++ b/sys/vfs/ufs/ufs_vfsops.c @@ -37,7 +37,7 @@ * * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 * $FreeBSD: src/sys/ufs/ufs/ufs_vfsops.c,v 1.17.2.3 2001/10/14 19:08:16 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #include "opt_quota.h" @@ -61,12 +61,8 @@ MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure"); */ /* ARGSUSED */ int -ufs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; +ufs_start(struct mount *mp, int flags, struct thread *td) { - return (0); } @@ -92,48 +88,52 @@ 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); #else + struct proc *p = td->td_proc; int cmd, type, error; + if (p == NULL) + return (EOPNOTSUPP); + if (uid == -1) - uid = p->p_cred->p_ruid; + uid = p->p_ucred->cr_ruid; cmd = cmds >> SUBCMDSHIFT; switch (cmd) { case Q_SYNC: break; case Q_GETQUOTA: - if (uid == p->p_cred->p_ruid) + if (uid == p->p_ucred->cr_ruid) break; /* fall through */ default: - if ((error = suser_xxx(0, p, PRISON_ROOT)) != 0) + if ((error = suser_cred(p->p_ucred, 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: @@ -156,7 +156,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/vfs/ufs/ufs_vnops.c b/sys/vfs/ufs/ufs_vnops.c index 97807ad25f..dd84297253 100644 --- a/sys/vfs/ufs/ufs_vnops.c +++ b/sys/vfs/ufs/ufs_vnops.c @@ -37,7 +37,7 @@ * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 * $FreeBSD: src/sys/ufs/ufs/ufs_vnops.c,v 1.131.2.8 2003/01/02 17:26:19 bde Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_vnops.c,v 1.3 2003/06/23 17:55:51 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_vnops.c,v 1.4 2003/06/25 03:56:12 dillon Exp $ */ #include "opt_quota.h" @@ -46,12 +46,12 @@ #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -79,8 +79,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 *)); @@ -264,7 +264,7 @@ ufs_open(ap) struct vnode *a_vp; int a_mode; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -289,7 +289,7 @@ ufs_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; @@ -307,7 +307,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; @@ -392,7 +392,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; @@ -436,14 +436,13 @@ 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; int error; /* @@ -459,7 +458,7 @@ ufs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != ip->i_uid && - (error = suser_xxx(cred, PRISON_ROOT))) + (error = suser_cred(cred, PRISON_ROOT))) return (error); if ((cred->cr_uid == 0) && (cred->cr_prison == NULL)) { if ((ip->i_flags @@ -487,7 +486,7 @@ ufs_setattr(ap) if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if ((error = ufs_chown(vp, vap->va_uid, vap->va_gid, cred, p)) != 0) + if ((error = ufs_chown(vp, vap->va_uid, vap->va_gid, cred, ap->a_td)) != 0) return (error); } if (vap->va_size != VNOVAL) { @@ -507,7 +506,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, ap->a_td)) != 0) return (error); } ip = VTOI(vp); @@ -515,9 +514,9 @@ ufs_setattr(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != ip->i_uid && - (error = suser_xxx(cred, PRISON_ROOT)) && + (error = suser_cred(cred, PRISON_ROOT)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(vp, VWRITE, cred, p)))) + (error = VOP_ACCESS(vp, VWRITE, cred, ap->a_td)))) return (error); if (vap->va_atime.tv_sec != VNOVAL) ip->i_flag |= IN_ACCESS; @@ -540,7 +539,7 @@ ufs_setattr(ap) if (vap->va_mode != (mode_t)VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - error = ufs_chmod(vp, (int)vap->va_mode, cred, p); + error = ufs_chmod(vp, (int)vap->va_mode, cred, ap->a_td); } VN_KNOTE(vp, NOTE_ATTRIB); return (error); @@ -551,17 +550,13 @@ ufs_setattr(ap) * Inode must be locked before calling. */ static int -ufs_chmod(vp, mode, cred, p) - register struct vnode *vp; - register int mode; - register struct ucred *cred; - struct proc *p; +ufs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct thread *td) { register struct inode *ip = VTOI(vp); int error; if (cred->cr_uid != ip->i_uid) { - error = suser_xxx(cred, PRISON_ROOT); + error = suser_cred(cred, PRISON_ROOT); if (error) return (error); } @@ -582,12 +577,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; @@ -609,7 +604,7 @@ ufs_chown(vp, uid, gid, cred, p) */ if ((cred->cr_uid != ip->i_uid || uid != ip->i_uid || (gid != ip->i_gid && !groupmember((gid_t)gid, cred))) && - (error = suser_xxx(cred, PRISON_ROOT))) + (error = suser_cred(cred, PRISON_ROOT))) return (error); ogid = ip->i_gid; ouid = ip->i_uid; @@ -693,7 +688,7 @@ ufs_mmap(ap) struct vnode *a_vp; int a_fflags; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { @@ -740,7 +735,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_td; struct inode *ip; struct direct newdir; int error; @@ -753,7 +748,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); @@ -785,7 +780,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); @@ -888,7 +883,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_td; struct inode *ip, *xp, *dp; struct direct newdir; int doingdirectory = 0, oldparent = 0, newparent = 0; @@ -933,18 +928,18 @@ abortit: goto abortit; } - 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; } @@ -955,7 +950,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; } @@ -988,7 +983,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; } @@ -1002,8 +997,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_td); + VOP_UNLOCK(fvp, 0, td); if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { @@ -1146,7 +1141,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_td)) != 0) goto bad; } VN_KNOTE(tdvp, NOTE_WRITE); @@ -1221,7 +1216,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; @@ -1522,7 +1517,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_td); } cache_purge(vp); #ifdef UFS_DIRHASH @@ -1566,8 +1561,8 @@ ufs_symlink(ap) ip->i_flag |= IN_CHANGE | IN_UPDATE; } 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); + UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, + (int *)0, NULL); if (error) vput(vp); return (error); @@ -1843,7 +1838,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; @@ -1917,7 +1912,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; @@ -2135,7 +2130,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) if (DOINGSOFTDEP(tvp)) softdep_change_linkcnt(ip); if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) && - suser_xxx(cnp->cn_cred, 0)) { + suser_cred(cnp->cn_cred, 0)) { ip->i_mode &= ~ISGID; } diff --git a/sys/vfs/ufs/ufsmount.h b/sys/vfs/ufs/ufsmount.h index 23b8d40e52..67ba717054 100644 --- a/sys/vfs/ufs/ufsmount.h +++ b/sys/vfs/ufs/ufsmount.h @@ -32,7 +32,7 @@ * * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 * $FreeBSD: src/sys/ufs/ufs/ufsmount.h,v 1.17 1999/12/29 04:55:06 peter Exp $ - * $DragonFly: src/sys/vfs/ufs/ufsmount.h,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufsmount.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _UFS_UFS_UFSMOUNT_H_ @@ -98,7 +98,7 @@ struct ufsmount { struct malloc_type *um_malloctype; /* The inodes malloctype */ int um_i_effnlink_valid; /* i_effnlink valid? */ 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/vfs/umapfs/umap_subr.c b/sys/vfs/umapfs/umap_subr.c index 889e586363..bc9172504c 100644 --- a/sys/vfs/umapfs/umap_subr.c +++ b/sys/vfs/umapfs/umap_subr.c @@ -36,7 +36,7 @@ * @(#)umap_subr.c 8.9 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/miscfs/umapfs/umap_subr.c,v 1.19 1999/09/04 11:51:41 bde Exp $ - * $DragonFly: src/sys/vfs/umapfs/Attic/umap_subr.c,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/umapfs/Attic/umap_subr.c,v 1.3 2003/06/25 03:56:00 dillon Exp $ */ #include @@ -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/vfs/umapfs/umap_vfsops.c b/sys/vfs/umapfs/umap_vfsops.c index 97e362fb34..e9ad0fb0f0 100644 --- a/sys/vfs/umapfs/umap_vfsops.c +++ b/sys/vfs/umapfs/umap_vfsops.c @@ -36,7 +36,7 @@ * @(#)umap_vfsops.c 8.8 (Berkeley) 5/14/95 * * $FreeBSD: src/sys/miscfs/umapfs/umap_vfsops.c,v 1.31.2.2 2001/09/11 09:49:53 kris Exp $ - * $DragonFly: src/sys/vfs/umapfs/Attic/umap_vfsops.c,v 1.3 2003/06/23 17:55:44 dillon Exp $ + * $DragonFly: src/sys/vfs/umapfs/Attic/umap_vfsops.c,v 1.4 2003/06/25 03:56:01 dillon Exp $ */ /* @@ -62,34 +62,30 @@ 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, const char *attrname, caddr_t arg, - struct proc *p)); + struct thread *td)); /* * Mount umap layer */ static int -umapfs_mount(mp, path, data, ndp, p) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; +umapfs_mount(struct mount *mp, char *path, caddr_t data, + struct nameidata *ndp, struct thread *td) { struct umap_args args; struct vnode *lowerrootvp, *vp; @@ -104,7 +100,7 @@ umapfs_mount(mp, path, data, ndp, p) /* * Only for root */ - if ((error = suser_xxx(p->p_ucred, 0)) != 0) + if ((error = suser(td)) != 0) return (error); #ifdef DEBUG @@ -116,7 +112,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));*/ } /* @@ -130,7 +126,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); @@ -208,7 +204,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 */ @@ -235,7 +231,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); @@ -249,10 +245,7 @@ umapfs_mount(mp, path, data, ndp, p) * when that filesystem was mounted. */ static int -umapfs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; +umapfs_start(struct mount *mp, int flags, struct thread *td) { return (0); /* return (VFS_START(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, flags, p)); */ @@ -262,10 +255,7 @@ umapfs_start(mp, flags, p) * Free reference to umap layer */ static int -umapfs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; +umapfs_unmount(struct mount *mp, int mntflags, struct thread *td) { int error; int flags = 0; @@ -301,11 +291,9 @@ umapfs_unmount(mp, mntflags, p) } static int -umapfs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; +umapfs_root(struct mount *mp, struct vnode **vpp) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode *vp; #ifdef DEBUG @@ -319,27 +307,20 @@ 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) - struct mount *mp; - int cmd; - uid_t uid; - caddr_t arg; - struct proc *p; +umapfs_quotactl(struct mount *mp, int cmd, uid_t uid, + caddr_t arg, 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) - struct mount *mp; - struct statfs *sbp; - struct proc *p; +umapfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) { int error; struct statfs mstat; @@ -352,7 +333,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); @@ -375,11 +356,7 @@ umapfs_statfs(mp, sbp, p) } static int -umapfs_sync(mp, waitfor, cred, p) - struct mount *mp; - int waitfor; - struct ucred *cred; - struct proc *p; +umapfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td) { /* * XXX - Assumes no data cached at umap layer. @@ -388,31 +365,22 @@ umapfs_sync(mp, waitfor, cred, p) } static int -umapfs_vget(mp, ino, vpp) - struct mount *mp; - ino_t ino; - struct vnode **vpp; +umapfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) { return (VFS_VGET(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, ino, vpp)); } static int -umapfs_fhtovp(mp, fidp, vpp) - struct mount *mp; - struct fid *fidp; - struct vnode **vpp; +umapfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp) { return (VFS_FHTOVP(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, fidp, vpp)); } static int -umapfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct sockaddr *nam; - int *exflagsp; - struct ucred **credanonp; +umapfs_checkexp(struct mount *mp, struct sockaddr *nam, int *exflagsp, + struct ucred **credanonp) { return (VFS_CHECKEXP(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, nam, @@ -420,23 +388,17 @@ umapfs_checkexp(mp, nam, exflagsp, credanonp) } static int -umapfs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; +umapfs_vptofh(struct vnode *vp, struct fid *fhp) { return (VFS_VPTOFH(UMAPVPTOLOWERVP(vp), fhp)); } static int -umapfs_extattrctl(mp, cmd, attrname, arg, p) - struct mount *mp; - int cmd; - const char *attrname; - caddr_t arg; - struct proc *p; +umapfs_extattrctl(struct mount *mp, int cmd, const char *attrname, + caddr_t arg, struct thread *td) { return (VFS_EXTATTRCTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, attrname, - arg, p)); + arg, td)); } diff --git a/sys/vfs/umapfs/umap_vnops.c b/sys/vfs/umapfs/umap_vnops.c index c917dff14d..d70f657dc9 100644 --- a/sys/vfs/umapfs/umap_vnops.c +++ b/sys/vfs/umapfs/umap_vnops.c @@ -35,7 +35,7 @@ * * @(#)umap_vnops.c 8.6 (Berkeley) 5/22/95 * $FreeBSD: src/sys/miscfs/umapfs/umap_vnops.c,v 1.30 1999/08/30 07:08:04 bde Exp $ - * $DragonFly: src/sys/vfs/umapfs/Attic/umap_vnops.c,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/umapfs/Attic/umap_vnops.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -283,7 +284,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 +360,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 +381,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 +393,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 +406,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/vfs/union/union.h b/sys/vfs/union/union.h index 22136829eb..57afe49bc4 100644 --- a/sys/vfs/union/union.h +++ b/sys/vfs/union/union.h @@ -36,7 +36,7 @@ * * @(#)union.h 8.9 (Berkeley) 12/10/94 * $FreeBSD: src/sys/miscfs/union/union.h,v 1.17 1999/12/29 04:54:48 peter Exp $ - * $DragonFly: src/sys/vfs/union/union.h,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/union/union.h,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ struct union_args { @@ -120,23 +120,23 @@ 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 void union_vm_coherency __P((struct vnode *, struct uio *, int)); -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/vfs/union/union_subr.c b/sys/vfs/union/union_subr.c index ac728a1adb..89cfe8c339 100644 --- a/sys/vfs/union/union_subr.c +++ b/sys/vfs/union/union_subr.c @@ -36,13 +36,14 @@ * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 * $FreeBSD: src/sys/miscfs/union/union_subr.c,v 1.43.2.2 2001/12/25 01:44:45 dillon Exp $ - * $DragonFly: src/sys/vfs/union/union_subr.c,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/union/union_subr.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ #include #include #include #include +#include #include #include #include @@ -57,8 +58,6 @@ #include /* for vm cache coherency */ #include -#include - extern int union_init __P((void)); /* must be power of two, otherwise change UNION_HASH() */ @@ -86,11 +85,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() @@ -345,7 +344,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_td : curthread; /* XXX */ int hash = 0; int vflag; int try; @@ -405,7 +404,7 @@ loop: un->un_uppervp == NULLVP) && (UNIONTOV(un)->v_mount == mp)) { if (vget(UNIONTOV(un), 0, - cnp ? cnp->cn_proc : NULL)) { + cnp ? cnp->cn_td : NULL)) { union_list_unlock(hash); goto loop; } @@ -445,21 +444,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. @@ -568,7 +567,7 @@ loop: bzero(un, sizeof(*un)); lockinit(&un->un_lock, PVFS, "unlock", VLKTIMEOUT, 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; @@ -650,11 +649,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; @@ -671,12 +670,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); @@ -737,11 +736,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 vnode *lvp, *uvp; @@ -750,13 +749,13 @@ 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); - error = union_vn_create(&uvp, un, p); + error = union_vn_create(&uvp, un, td); if (error) return (error); @@ -768,23 +767,23 @@ 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); 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 @@ -798,12 +797,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; } @@ -851,7 +850,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_td = cnp->cn_td; if (um->um_op == UNMNT_ABOVE) cn->cn_cred = cnp->cn_cred; else @@ -860,7 +859,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_td); /* * Pass dvp unlocked and referenced on call to relookup(). @@ -869,7 +868,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_td); return(error); } @@ -905,7 +904,7 @@ union_mkshadow(um, dvp, cnp, vpp) { int error; struct vattr va; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct componentname cn; error = union_relookup(um, dvp, vpp, cnp, &cn, @@ -939,7 +938,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) { @@ -967,9 +966,13 @@ union_mkwhiteout(um, dvp, cnp, path) char *path; { int error; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct vnode *wvp; struct componentname cn; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; error = union_relookup(um, dvp, &wvp, cnp, &cn, path, strlen(path)); if (error) @@ -988,7 +991,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, cred, LEASE_WRITE); error = VOP_WHITEOUT(dvp, &cn, CREATE); if (cn.cn_flags & HASBUF) { @@ -1013,20 +1016,24 @@ 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; 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; struct componentname cn; + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + cmode = UN_FILEMODE & ~td->td_proc->p_fd->fd_cmask; + *vpp = NULLVP; /* @@ -1043,8 +1050,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_td = td; + cn.cn_cred = cred; cn.cn_nameptr = cn.cn_pnbuf; cn.cn_consume = 0; @@ -1088,7 +1095,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); @@ -1098,9 +1105,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); @@ -1111,16 +1118,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 @@ -1132,10 +1139,9 @@ union_vn_close(vp, fmode, cred, p) */ void -union_removed_upper(un) - struct union_node *un; +union_removed_upper(struct union_node *un) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ struct vnode **vpp; /* @@ -1164,17 +1170,14 @@ union_removed_upper(un) * during a remove/rmdir operation. */ int -union_dowhiteout(un, cred, p) - struct union_node *un; - struct ucred *cred; - struct proc *p; +union_dowhiteout(struct union_node *un, struct ucred *cred, 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); @@ -1210,9 +1213,7 @@ union_dircache_r(vp, vppp, cntp) } struct vnode * -union_dircache(vp, p) - struct vnode *vp; - struct proc *p; +union_dircache(struct vnode *vp, struct thread *td) { int cnt; struct vnode *nvp; @@ -1221,7 +1222,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; @@ -1247,7 +1248,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); @@ -1260,7 +1261,7 @@ union_dircache(vp, p) un->un_dircache = dircache; out: - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); return (nvp); } @@ -1302,14 +1303,14 @@ union_vm_coherency(struct vnode *vp, struct uio *uio, int cleanfls) * 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; @@ -1317,7 +1318,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; @@ -1325,17 +1326,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/vfs/union/union_vfsops.c b/sys/vfs/union/union_vfsops.c index 963939c324..579a808cca 100644 --- a/sys/vfs/union/union_vfsops.c +++ b/sys/vfs/union/union_vfsops.c @@ -36,7 +36,7 @@ * * @(#)union_vfsops.c 8.20 (Berkeley) 5/20/95 * $FreeBSD: src/sys/miscfs/union/union_vfsops.c,v 1.39.2.2 2001/10/25 19:18:53 dillon Exp $ - * $DragonFly: src/sys/vfs/union/union_vfsops.c,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/union/union_vfsops.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ /* @@ -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; @@ -89,6 +89,8 @@ union_mount(mp, path, data, ndp, p) UDEBUG(("union_mount(mp = %p)\n", (void *)mp)); + KKASSERT(td->td_proc); + /* * Disable clustered write, otherwise system becomes unstable. */ @@ -127,21 +129,20 @@ 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 /* * Obtain upper vnode by calling namei() on the path. The * upperrootvp will be turned referenced but not locked. */ - NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT, - UIO_USERSPACE, args.target, p); + NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT, 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; @@ -225,9 +226,8 @@ union_mount(mp, path, data, ndp, p) goto bad; } - um->um_cred = p->p_ucred; - crhold(um->um_cred); - um->um_cmode = UN_DIRMODE &~ p->p_fd->fd_cmask; + um->um_cred = crhold(td->td_proc->p_ucred); + um->um_cmode = UN_DIRMODE & ~td->td_proc->p_fd->fd_cmask; /* * Depending on what you think the MNT_LOCAL flag might mean, @@ -280,7 +280,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)); @@ -308,10 +308,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; @@ -401,10 +401,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); @@ -417,7 +417,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); } @@ -436,7 +436,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/vfs/union/union_vnops.c b/sys/vfs/union/union_vnops.c index 0ec44926af..bb89cd76b2 100644 --- a/sys/vfs/union/union_vnops.c +++ b/sys/vfs/union/union_vnops.c @@ -36,7 +36,7 @@ * * @(#)union_vnops.c 8.32 (Berkeley) 6/23/95 * $FreeBSD: src/sys/miscfs/union/union_vnops.c,v 1.72 1999/12/15 23:02:14 eivind Exp $ - * $DragonFly: src/sys/vfs/union/union_vnops.c,v 1.2 2003/06/17 04:28:43 dillon Exp $ + * $DragonFly: src/sys/vfs/union/union_vnops.c,v 1.3 2003/06/25 03:56:01 dillon Exp $ */ #include @@ -110,13 +110,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); @@ -124,29 +124,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); } @@ -179,7 +179,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) struct componentname *cnp; { int error; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct vnode *dvp = *pdvp; struct vnode *tdvp; struct mount *mp; @@ -202,7 +202,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); } } @@ -233,7 +233,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 @@ -253,7 +253,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) @@ -262,10 +262,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; @@ -292,7 +292,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_td; int lockparent = cnp->cn_flags & LOCKPARENT; struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount); struct ucred *saved_cred = NULL; @@ -330,7 +330,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. @@ -404,7 +404,7 @@ union_lookup(ap) int terror; terror = VOP_GETATTR(upperdvp, &va, - cnp->cn_cred, cnp->cn_proc); + cnp->cn_cred, cnp->cn_td); if (terror == 0 && (va.va_flags & OPAQUE)) iswhiteout = 1; } @@ -447,7 +447,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); @@ -471,7 +471,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; } } @@ -534,11 +534,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); @@ -601,7 +601,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); } } @@ -638,24 +638,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_td; 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); } @@ -673,9 +673,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_td)) != NULLVP) { error = VOP_WHITEOUT(un->un_uppervp, cnp, ap->a_flags); - union_unlock_upper(uppervp, cnp->cn_proc); + union_unlock_upper(uppervp, cnp->cn_td); } return(error); } @@ -701,9 +701,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_td)) != 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_td); } return (error); } @@ -724,14 +724,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; @@ -743,7 +743,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, @@ -752,12 +752,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; } } @@ -767,13 +767,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); } /* @@ -781,7 +781,7 @@ union_open(ap) */ if (tvpisupper) { if (tvp) - union_unlock_upper(tvp, p); + union_unlock_upper(tvp, td); } else { vput(tvp); } @@ -801,7 +801,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); @@ -834,11 +834,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; @@ -857,15 +857,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; /* @@ -886,7 +886,7 @@ union_access(ap) error = VCALL(vp, VOFFSET(vop_access), ap); } } - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, 0, td); } return(error); } @@ -913,7 +913,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; @@ -934,7 +934,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? */ @@ -951,7 +951,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? */ @@ -969,11 +969,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; @@ -996,7 +996,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); } @@ -1006,12 +1006,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); } @@ -1054,18 +1054,18 @@ 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!")); if (ap->a_vp->v_flag & VOBJBUF) union_vm_coherency(ap->a_vp, ap->a_uio, 0); error = VOP_READ(uvp, ap->a_uio, ap->a_ioflag, ap->a_cred); - union_unlock_other(uvp, p); + union_unlock_other(uvp, td); /* * XXX @@ -1098,11 +1098,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"); /* @@ -1138,7 +1138,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); } @@ -1146,7 +1146,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; @@ -1165,7 +1165,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); @@ -1180,7 +1180,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); @@ -1194,7 +1194,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; @@ -1213,7 +1213,7 @@ union_mmap(ap) struct vnode *a_vp; int a_fflags; struct ucred *a_cred; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct vnode *ovp = OTHERVP(ap->a_vp); @@ -1228,17 +1228,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); @@ -1262,16 +1262,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_td; 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 @@ -1279,13 +1279,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); } @@ -1306,7 +1306,7 @@ union_link(ap) } */ *ap; { struct componentname *cnp = ap->a_cnp; - struct proc *p = cnp->cn_proc; + struct thread *td = cnp->cn_td; struct union_node *dun = VTOUNION(ap->a_tdvp); struct vnode *vp; struct vnode *tdvp; @@ -1318,24 +1318,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; } @@ -1350,18 +1350,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); } @@ -1418,9 +1418,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_td); + error = union_copyup(un, 1, ap->a_fcnp->cn_cred, ap->a_fcnp->cn_td); + VOP_UNLOCK(un->un_vnode, 0, ap->a_fcnp->cn_td); if (error) goto bad; break; @@ -1436,12 +1436,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_td); 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_td); 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_td); if (error) goto bad; break; @@ -1485,7 +1485,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_td); vput(ap->a_tdvp); } @@ -1500,7 +1500,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_td); vput(ap->a_tvp); /* note: tvp may be NULL */ } @@ -1541,18 +1541,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_td; 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); @@ -1573,25 +1573,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_td; 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); } @@ -1614,14 +1614,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_td; 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); } @@ -1645,14 +1645,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); } @@ -1668,15 +1668,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); } @@ -1691,11 +1691,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; @@ -1722,11 +1722,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); @@ -1751,7 +1751,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 @@ -1769,12 +1769,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); } @@ -1796,7 +1796,7 @@ union_unlock(ap) struct vop_unlock_args /* { struct vnode *a_vp; int a_flags; - struct proc *a_p; + struct thread *a_td; } */ *ap; { struct union_node *un = VTOUNION(ap->a_vp); @@ -1815,7 +1815,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); @@ -1873,16 +1873,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/vm/vm_extern.h b/sys/vm/vm_extern.h index 03d38280eb..44b1174e1d 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -32,7 +32,7 @@ * * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94 * $FreeBSD: src/sys/vm/vm_extern.h,v 1.46.2.3 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_extern.h,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_extern.h,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ #ifndef _VM_EXTERN_H_ @@ -73,7 +73,7 @@ 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)); +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)); diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 4181223638..2497c4755f 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -67,7 +67,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_fault.c,v 1.108.2.8 2002/02/26 05:49:27 silby Exp $ - * $DragonFly: src/sys/vm/vm_fault.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_fault.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ /* @@ -648,7 +648,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 1179a4c673..1c5b597748 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -60,7 +60,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_glue.c,v 1.94.2.4 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_glue.c,v 1.5 2003/06/22 04:30:43 dillon Exp $ + * $DragonFly: src/sys/vm/vm_glue.c,v 1.6 2003/06/25 03:56:12 dillon Exp $ */ #include "opt_vm.h" @@ -491,7 +491,7 @@ retry: */ if (lockmgr(&vm->vm_map.lock, LK_EXCLUSIVE | LK_NOWAIT, - (void *)0, curproc)) { + (void *)0, curthread)) { vmspace_free(vm); continue; } diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 82d97e3bfb..8e01abfb4f 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_map.c,v 1.187.2.19 2003/05/27 00:47:02 alc Exp $ - * $DragonFly: src/sys/vm/vm_map.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_map.c,v 1.3 2003/06/25 03:56:12 dillon Exp $ */ /* @@ -1994,14 +1994,14 @@ vm_map_clean(map, start, end, syncio, invalidate) 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, OFF_TO_IDX(offset), OFF_TO_IDX(offset + size + PAGE_MASK), flags); - VOP_UNLOCK(object->handle, 0, curproc); + VOP_UNLOCK(object->handle, 0, curthread); vm_object_deallocate(object); } if (object && invalidate && diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index cac3b89ab9..536674e17e 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_map.h,v 1.54.2.5 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_map.h,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_map.h,v 1.3 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -216,7 +216,7 @@ struct vmspace { #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) @@ -226,7 +226,7 @@ struct vmspace { #define vm_map_lock(map) \ do { \ printf ("locking map LK_EXCLUSIVE: 0x%x\n", map); \ - if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \ + if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curthread) != 0) { \ panic("vm_map_lock: failed to get lock"); \ } \ (map)->timestamp++; \ @@ -234,7 +234,7 @@ struct vmspace { #else #define vm_map_lock(map) \ do { \ - if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \ + if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curthread) != 0) { \ panic("vm_map_lock: failed to get lock"); \ } \ (map)->timestamp++; \ @@ -243,7 +243,7 @@ struct vmspace { #else #define vm_map_lock(map) \ do { \ - lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc); \ + lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curthread); \ (map)->timestamp++; \ } while(0) #endif /* DIAGNOSTIC */ @@ -252,50 +252,50 @@ struct vmspace { #define vm_map_unlock(map) \ do { \ printf ("locking map LK_RELEASE: 0x%x\n", map); \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \ + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curthread); \ } while (0) #define vm_map_lock_read(map) \ do { \ printf ("locking map LK_SHARED: 0x%x\n", map); \ - lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc); \ + lockmgr(&(map)->lock, LK_SHARED, (void *)0, curthread); \ } while (0) #define vm_map_unlock_read(map) \ do { \ printf ("locking map LK_RELEASE: 0x%x\n", map); \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc); \ + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curthread); \ } while (0) #else #define vm_map_unlock(map) \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc) + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curthread) #define vm_map_lock_read(map) \ - lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc) + lockmgr(&(map)->lock, LK_SHARED, (void *)0, curthread) #define vm_map_unlock_read(map) \ - lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc) + lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curthread) #endif 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; #if defined(MAP_LOCK_DIAGNOSTIC) printf("locking map LK_EXCLUPGRADE: 0x%x\n", map); #endif - error = lockmgr(&map->lock, LK_EXCLUPGRADE, (void *)0, p); + error = lockmgr(&map->lock, LK_EXCLUPGRADE, (void *)0, td); if (error == 0) map->timestamp++; return error; } -#define vm_map_lock_upgrade(map) _vm_map_lock_upgrade(map, curproc) +#define vm_map_lock_upgrade(map) _vm_map_lock_upgrade(map, curthread) #if defined(MAP_LOCK_DIAGNOSTIC) #define vm_map_lock_downgrade(map) \ do { \ printf ("locking map LK_DOWNGRADE: 0x%x\n", map); \ - lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc); \ + lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curthread); \ } while (0) #else #define vm_map_lock_downgrade(map) \ - lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curproc) + lockmgr(&(map)->lock, LK_DOWNGRADE, (void *)0, curthread) #endif #define vm_map_set_recursive(map) \ diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 6a33ecab6e..6d41ad1e21 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -39,7 +39,7 @@ * * @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94 * $FreeBSD: src/sys/vm/vm_mmap.c,v 1.108.2.6 2002/07/02 20:06:19 dillon Exp $ - * $DragonFly: src/sys/vm/vm_mmap.c,v 1.3 2003/06/23 17:55:51 dillon Exp $ + * $DragonFly: src/sys/vm/vm_mmap.c,v 1.4 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -78,6 +78,8 @@ #include #include +#include + #ifndef _SYS_SYSPROTO_H_ struct sbrk_args { int incr; @@ -166,7 +168,8 @@ ogetpagesize(struct getpagesize_args *uap) int mmap(struct mmap_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; struct file *fp = NULL; struct vnode *vp; @@ -180,6 +183,8 @@ mmap(struct mmap_args *uap) struct vmspace *vms = p->p_vmspace; vm_object_t obj; + KKASSERT(p); + addr = (vm_offset_t) uap->addr; size = uap->len; prot = uap->prot & VM_PROT_ALL; @@ -315,7 +320,7 @@ mmap(struct mmap_args *uap) if (securelevel >= 1) disablexworkaround = 1; else - disablexworkaround = suser_xxx(p->p_ucred, 0); + disablexworkaround = suser(td); if (vp->v_type == VCHR && disablexworkaround && (flags & (MAP_PRIVATE|MAP_COPY))) { error = EINVAL; @@ -352,8 +357,7 @@ mmap(struct mmap_args *uap) if ((fp->f_flag & FWRITE) != 0) { struct vattr va; if ((error = - VOP_GETATTR(vp, &va, - p->p_ucred, p))) { + VOP_GETATTR(vp, &va, p->p_ucred, td))) { goto done; } if ((va.va_flags & @@ -391,7 +395,7 @@ mmap(struct mmap_args *uap) p->p_retval[0] = (register_t) (addr + pageoff); done: if (fp) - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -894,7 +898,7 @@ mlock(struct mlock_args *uap) p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur) return (ENOMEM); #else - error = suser_xxx(p->p_ucred, 0); + error = suser_cred(p->p_ucred, 0); if (error) return (error); #endif @@ -927,10 +931,11 @@ munlockall(struct munlockall_args *uap) int munlock(struct munlock_args *uap) { + struct thread *td = curthread; + struct proc *p = td->td_proc; vm_offset_t addr; vm_size_t size, pageoff; int error; - struct proc *p = curproc; addr = (vm_offset_t) uap->addr; size = uap->len; @@ -945,7 +950,7 @@ munlock(struct munlock_args *uap) return (EINVAL); #ifndef pmap_wired_count - error = suser(); + error = suser(td); if (error) return (error); #endif @@ -972,7 +977,10 @@ 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; /* XXX */ + struct proc *p = td->td_proc; + + KKASSERT(p); if (size == 0) return (0); @@ -1024,7 +1032,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, p->p_ucred, td); if (error) return (error); objsize = round_page(vat.va_size); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index ae48e95bcd..03a1090ab4 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_object.c,v 1.171.2.8 2003/05/26 19:17:56 alc Exp $ - * $DragonFly: src/sys/vm/vm_object.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_object.c,v 1.3 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -264,7 +264,7 @@ vm_object_reference(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_page.c b/sys/vm/vm_page.c index f9fcdac732..6a147f78b6 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -35,7 +35,7 @@ * * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91 * $FreeBSD: src/sys/vm/vm_page.c,v 1.147.2.18 2002/03/10 05:03:19 alc Exp $ - * $DragonFly: src/sys/vm/vm_page.c,v 1.4 2003/06/22 17:39:48 dillon Exp $ + * $DragonFly: src/sys/vm/vm_page.c,v 1.5 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -1761,9 +1761,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) { @@ -1788,9 +1788,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_pageout.c b/sys/vm/vm_pageout.c index 7b473263d6..8652bc2b35 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -66,7 +66,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_pageout.c,v 1.151.2.15 2002/12/29 18:21:04 dillon Exp $ - * $DragonFly: src/sys/vm/vm_pageout.c,v 1.3 2003/06/22 17:39:48 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pageout.c,v 1.4 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -545,7 +545,7 @@ vm_pageout_map_deactivate_pages(map, desired) vm_object_t obj, bigobj; int nothingwired; - if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curproc)) { + if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curthread)) { return; } @@ -867,7 +867,7 @@ rescan0: if (object->type == OBJT_VNODE) { vp = object->handle; - if (vget(vp, LK_EXCLUSIVE|LK_NOOBJ|LK_TIMELOCK, curproc)) { + if (vget(vp, LK_EXCLUSIVE|LK_NOOBJ|LK_TIMELOCK, curthread)) { ++pageout_lock_miss; if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 04f6c11b10..003eae2812 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -32,7 +32,7 @@ * * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 * $FreeBSD: src/sys/vm/vm_swap.c,v 1.96.2.2 2001/10/14 18:46:47 iedowse Exp $ - * $DragonFly: src/sys/vm/vm_swap.c,v 1.3 2003/06/23 17:55:51 dillon Exp $ + * $DragonFly: src/sys/vm/vm_swap.c,v 1.4 2003/06/25 03:56:13 dillon Exp $ */ #include "opt_swap.h" @@ -181,17 +181,21 @@ VNODEOP_SET(swapdev_vnodeop_opv_desc); int swapon(struct swapon_args *uap) { - struct proc *p = curproc; + struct thread *td = curthread; struct vattr attr; register struct vnode *vp; struct nameidata nd; int error; + struct ucred *cred; - error = suser_xxx(p->p_ucred, 0); + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; + + error = suser(td); if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->name, p); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->name, td); error = namei(&nd); if (error) return (error); @@ -200,14 +204,14 @@ swapon(struct swapon_args *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, cred, 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) @@ -228,11 +232,7 @@ swapon(struct swapon_args *uap) * XXX locking when multiple swapon's run in parallel */ int -swaponvp(p, vp, dev, nblks) - struct proc *p; - struct vnode *vp; - dev_t dev; - u_long nblks; +swaponvp(struct thread *td, struct vnode *vp, dev_t dev, u_long nblks) { int index; register struct swdevt *sp; @@ -241,6 +241,10 @@ swaponvp(p, vp, dev, nblks) swblk_t dvbase; int error; u_long aligned_nblks; + struct ucred *cred; + + KKASSERT(td->td_proc); + cred = td->td_proc->p_ucred; if (!swapdev_vp) { error = getnewvnode(VT_NON, NULL, swapdev_vnodeop_p, @@ -260,19 +264,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, cred, 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, cred, td); return (ENXIO); } if (nblks == 0) { - (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p); + (void) VOP_CLOSE(vp, FREAD | FWRITE, cred, td); return (ENXIO); } @@ -283,7 +287,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, cred, td); return (ENXIO); } /* diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 7f029ea960..1b59cb6967 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -39,7 +39,7 @@ * * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91 * $FreeBSD: src/sys/vm/vnode_pager.c,v 1.116.2.7 2002/12/31 09:34:51 dillon Exp $ - * $DragonFly: src/sys/vm/vnode_pager.c,v 1.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vnode_pager.c,v 1.3 2003/06/25 03:56:13 dillon Exp $ */ /* @@ -549,7 +549,7 @@ 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(object->handle, &auio, 0, curproc->p_ucred); if (!error) { @@ -1031,7 +1031,7 @@ 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; + auio.uio_td = NULL; error = VOP_WRITE(vp, &auio, ioflags, curproc->p_ucred); cnt.v_vnodeout++; cnt.v_vnodepgsout += ncount; @@ -1050,10 +1050,9 @@ vnode_pager_generic_putpages(vp, m, bytecount, flags, rtvals) } struct vnode * -vnode_pager_lock(object) - vm_object_t object; +vnode_pager_lock(vm_object_t object) { - struct proc *p = curproc; /* XXX */ + struct thread *td = curthread; /* XXX */ for (; object != NULL; object = object->backing_object) { if (object->type != OBJT_VNODE) @@ -1062,9 +1061,11 @@ vnode_pager_lock(object) return NULL; while (vget(object->handle, - LK_NOPAUSE | LK_SHARED | LK_RETRY | LK_CANRECURSE, p)) { - if ((object->flags & OBJ_DEAD) || (object->type != OBJT_VNODE)) + 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"); } return object->handle; -- 2.41.0