Index: head/sys/alpha/osf1/imgact_osf1.c =================================================================== --- head/sys/alpha/osf1/imgact_osf1.c (revision 83700) +++ head/sys/alpha/osf1/imgact_osf1.c (revision 83701) @@ -1,260 +1,261 @@ /* * Copyright (c) 1998-1999 Andrew Gallatin * All rights reserved. * * Based heavily on imgact_linux.c which is * Copyright (c) 1994-1996 Søren Schmidt. * Which in turn is based heavily on /sys/kern/imgact_aout.c which is: * Copyright (c) 1993, David Greenman * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern struct sysentvec osf1_sysvec; #ifdef DEBUG #define DPRINTF(a) printf a; #else #define DPRINTF(a) #endif static int exec_osf1_imgact(struct image_params *imgp) { int error; int path_not_saved; size_t bytes; const struct ecoff_exechdr *execp; const struct ecoff_aouthdr *eap; struct vmspace *vmspace; vm_offset_t baddr; vm_offset_t bsize; vm_offset_t bss_start; vm_offset_t daddr; vm_offset_t dend; vm_offset_t dsize; vm_offset_t raw_dend; vm_offset_t taddr; vm_offset_t tend; vm_offset_t tsize; struct nameidata *ndp; Osf_Auxargs *osf_auxargs; GIANT_REQUIRED; execp = (const struct ecoff_exechdr*)imgp->image_header; eap = &execp->a; ndp = NULL; /* check to make sure we have an alpha ecoff executable */ if (ECOFF_BADMAG(execp)) return -1; /* verfify it an OSF/1 exectutable */ if (eap->magic != ECOFF_ZMAGIC) { printf("unknown ecoff magic %x\n", eap->magic); return ENOEXEC; } osf_auxargs = malloc(sizeof(Osf_Auxargs), M_TEMP, M_WAITOK | M_ZERO); imgp->auxargs = osf_auxargs; osf_auxargs->executable = osf_auxargs->exec_path; path_not_saved = copyinstr(imgp->fname, osf_auxargs->executable, PATH_MAX, &bytes); if (execp->f.f_flags & DYNAMIC_FLAG) { if (path_not_saved) { uprintf("path to dynamic exectutable not found\n"); free(imgp->auxargs, M_TEMP); return(path_not_saved); } /* * Unmap the executable & attempt to slide in * /sbin/loader in its place. */ if (imgp->firstpage) exec_unmap_first_page(imgp); /* * Replicate what execve does, and map the first * page of the loader. */ ndp = (struct nameidata *)malloc(sizeof(struct nameidata), M_TEMP, M_WAITOK); NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, - "/compat/osf1/sbin/loader", imgp->proc); + "/compat/osf1/sbin/loader", &imgp->proc->p_thread); error = namei(ndp); if (error) { uprintf("imgact_osf1: can't read /compat/osf1/sbin/loader\n"); free(imgp->auxargs, M_TEMP); return(error); } if (imgp->vp) { vrele(imgp->vp); /* leaking in the nameizone ??? XXX */ } imgp->vp = ndp->ni_vp; error = exec_map_first_page(imgp); - VOP_UNLOCK(imgp->vp, 0, imgp->proc); + VOP_UNLOCK(imgp->vp, 0, &imgp->proc->p_thread); osf_auxargs->loader = "/compat/osf1/sbin/loader"; } execp = (const struct ecoff_exechdr*)imgp->image_header; eap = &execp->a; taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start); tend = round_page(eap->text_start + eap->tsize); tsize = tend - taddr; daddr = ECOFF_SEGMENT_ALIGN(execp, eap->data_start); dend = round_page(eap->data_start + eap->dsize); dsize = dend - daddr; bss_start = ECOFF_SEGMENT_ALIGN(execp, eap->bss_start); bsize = eap->bsize; imgp->entry_addr = eap->entry; /* copy in arguments and/or environment from old process */ error = exec_extract_strings(imgp); if (error) goto bail; /* * Destroy old process VM and create a new one (with a new stack). */ exec_new_vmspace(imgp); /* * The vm space can now be changed. */ vmspace = imgp->proc->p_vmspace; imgp->interpreted = 0; imgp->proc->p_sysent = &osf1_sysvec; if ((eap->tsize != 0 || eap->dsize != 0) && imgp->vp->v_writecount != 0) { #ifdef DIAGNOSTIC if (imgp->vp->v_flag & VTEXT) panic("exec: a VTEXT vnode has writecount != 0\n"); #endif return ETXTBSY; } imgp->vp->v_flag |= VTEXT; /* set up text segment */ if ((error = vm_mmap(&vmspace->vm_map, &taddr, tsize, VM_PROT_READ|VM_PROT_EXECUTE, VM_PROT_ALL, MAP_FIXED|MAP_COPY, (caddr_t)imgp->vp, ECOFF_TXTOFF(execp)))) { DPRINTF(("%s(%d): error = %d\n", __FILE__, __LINE__, error)); return error; } /* .. data .. */ if ((error = vm_mmap(&vmspace->vm_map, &daddr, dsize, VM_PROT_READ|VM_PROT_EXECUTE|VM_PROT_WRITE, VM_PROT_ALL, MAP_FIXED|MAP_COPY, (caddr_t)imgp->vp, ECOFF_DATOFF(execp)))) { DPRINTF(("%s(%d): error = %d\n", __FILE__, __LINE__, error)); goto bail; } /* .. bss .. */ if (round_page(bsize)) { baddr = bss_start; if ((error = vm_map_find(&vmspace->vm_map, NULL, (vm_offset_t) 0, &baddr, round_page(bsize), FALSE, VM_PROT_ALL, VM_PROT_ALL, FALSE))) { DPRINTF(("%s(%d): error = %d\n", __FILE__, __LINE__, error)); goto bail; } } raw_dend = (eap->data_start + eap->dsize); if (dend > raw_dend) { caddr_t zeros; zeros = malloc(dend-raw_dend,M_TEMP,M_WAITOK|M_ZERO); if ((error = copyout(zeros, (caddr_t)raw_dend, dend-raw_dend))) { uprintf("Can't zero start of bss, error %d\n",error); free(zeros,M_TEMP); goto bail; } free(zeros,M_TEMP); } vmspace->vm_tsize = btoc(round_page(tsize)); vmspace->vm_dsize = btoc((round_page(dsize) + round_page(bsize))); vmspace->vm_taddr = (caddr_t)taddr; vmspace->vm_daddr = (caddr_t)daddr; return(0); bail: free(imgp->auxargs, M_TEMP); if (ndp) { - VOP_CLOSE(ndp->ni_vp, FREAD, imgp->proc->p_ucred, imgp->proc); + VOP_CLOSE(ndp->ni_vp, FREAD, imgp->proc->p_ucred, + &imgp->proc->p_thread); vrele(ndp->ni_vp); } return(error); } /* * Tell kern_execve.c about it, with a little help from the linker. */ struct execsw osf1_execsw = { exec_osf1_imgact, "OSF/1 ECOFF" }; EXEC_SET(osf1_ecoff, osf1_execsw); Index: head/sys/alpha/osf1/osf1_mount.c =================================================================== --- head/sys/alpha/osf1/osf1_mount.c (revision 83700) +++ head/sys/alpha/osf1/osf1_mount.c (revision 83701) @@ -1,383 +1,383 @@ /* $NetBSD: osf1_mount.c,v 1.7 1998/05/20 16:34:29 chs Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Chris G. Demetriou * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ /* * Additional Copyright (c) 1999 by Andrew Gallatin * $FreeBSD$ */ #include "opt_nfs.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void bsd2osf_statfs __P((struct statfs *, struct osf1_statfs *)); int osf1_mount_mfs __P((struct thread *, struct osf1_mount_args *, struct mount_args *)); int osf1_mount_nfs __P((struct thread *, struct osf1_mount_args *, struct mount_args *)); #ifdef notanymore static const char *fsnames[OSF1_MOUNT_MAXTYPE+2] = INITMOUNTNAMES; #endif void bsd2osf_statfs(bsfs, osfs) struct statfs *bsfs; struct osf1_statfs *osfs; { #ifdef notanymore bzero(osfs, sizeof (struct osf1_statfs)); if (!strncmp(fsnames[MOUNT_UFS], bsfs->f_fstypename, MFSNAMELEN)) osfs->f_type = OSF1_MOUNT_UFS; else if (!strncmp(fsnames[MOUNT_NFS], bsfs->f_fstypename, MFSNAMELEN)) osfs->f_type = OSF1_MOUNT_NFS; else if (!strncmp(fsnames[MOUNT_MFS], bsfs->f_fstypename, MFSNAMELEN)) osfs->f_type = OSF1_MOUNT_MFS; else /* uh oh... XXX = PC, CDFS, PROCFS, etc. */ osfs->f_type = OSF1_MOUNT_ADDON; osfs->f_flags = bsfs->f_flags; /* XXX translate */ osfs->f_fsize = bsfs->f_bsize; osfs->f_bsize = bsfs->f_iosize; osfs->f_blocks = bsfs->f_blocks; osfs->f_bfree = bsfs->f_bfree; osfs->f_bavail = bsfs->f_bavail; osfs->f_files = bsfs->f_files; osfs->f_ffree = bsfs->f_ffree; bcopy(&bsfs->f_fsid, &osfs->f_fsid, max(sizeof bsfs->f_fsid, sizeof osfs->f_fsid)); /* osfs->f_spare zeroed above */ bcopy(bsfs->f_mntonname, osfs->f_mntonname, max(sizeof bsfs->f_mntonname, sizeof osfs->f_mntonname)); bcopy(bsfs->f_mntfromname, osfs->f_mntfromname, max(sizeof bsfs->f_mntfromname, sizeof osfs->f_mntfromname)); /* XXX osfs->f_xxx should be filled in... */ #endif } int osf1_statfs(td, uap) struct thread *td; struct osf1_statfs_args *uap; { int error; struct mount *mp; struct statfs *sp; struct osf1_statfs osfs; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td); if ((error = namei(&nd))) return (error); mp = nd.ni_vp->v_mount; sp = &mp->mnt_stat; vrele(nd.ni_vp); if ((error = VFS_STATFS(mp, sp, td))) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; bsd2osf_statfs(sp, &osfs); return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, SCARG(uap, len))); } int osf1_fstatfs(td, uap) struct thread *td; struct osf1_fstatfs_args *uap; { int error; struct file *fp; struct mount *mp; struct statfs *sp; struct osf1_statfs osfs; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp))) + if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp))) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; - if ((error = VFS_STATFS(mp, sp, p))) + if ((error = VFS_STATFS(mp, sp, td))) return (error); sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; bsd2osf_statfs(sp, &osfs); return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, SCARG(uap, len))); } int -osf1_getfsstat(p, uap) - struct proc *p; +osf1_getfsstat(td, uap) + struct thread *td; register struct osf1_getfsstat_args *uap; { long count, error, maxcount; caddr_t osf_sfsp; struct mount *mp, *nmp; struct statfs *sp; struct osf1_statfs osfs; if (SCARG(uap, flags) & ~OSF1_GETFSSTAT_FLAGS) return (EINVAL); maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs); osf_sfsp = (caddr_t)SCARG(uap, buf); for (count = 0, mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { nmp = TAILQ_NEXT(mp, mnt_list); if (osf_sfsp && count < maxcount) { sp = &mp->mnt_stat; /* * If OSF1_MNT_NOWAIT is specified, do not refresh the * fsstat cache. OSF1_MNT_WAIT overrides * OSF1_MNT_NOWAIT. */ if (((SCARG(uap, flags) & OSF1_MNT_NOWAIT) == 0 || (SCARG(uap, flags) & OSF1_MNT_WAIT)) && - (error = VFS_STATFS(mp, sp, p))) + (error = VFS_STATFS(mp, sp, td))) continue; sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; bsd2osf_statfs(sp, &osfs); if ((error = copyout(&osfs, osf_sfsp, sizeof (struct osf1_statfs)))) return (error); osf_sfsp += sizeof (struct osf1_statfs); } count++; } if (osf_sfsp && count > maxcount) td->td_retval[0] = maxcount; else td->td_retval[0] = count; return (0); } int -osf1_unmount(p, uap) - struct proc *p; +osf1_unmount(td, uap) + struct thread *td; struct osf1_unmount_args *uap; { struct unmount_args a; SCARG(&a, path) = SCARG(uap, path); if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS) return (EINVAL); SCARG(&a, flags) = 0; if ((SCARG(uap, flags) & OSF1_MNT_FORCE) && (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0) SCARG(&a, flags) |= MNT_FORCE; - return unmount(p, &a); + return unmount(td, &a); } int -osf1_mount(p, uap) - struct proc *p; +osf1_mount(td, uap) + struct thread *td; struct osf1_mount_args *uap; { int error; struct mount_args a; SCARG(&a, path) = SCARG(uap, path); if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS) return (EINVAL); SCARG(&a, flags) = SCARG(uap, flags); /* XXX - xlate */ switch (SCARG(uap, type)) { case OSF1_MOUNT_UFS: /* XXX */ return (EINVAL); break; case OSF1_MOUNT_NFS: /* XXX */ - if ((error = osf1_mount_nfs(p, uap, &a))) + if ((error = osf1_mount_nfs(td, uap, &a))) return error; break; case OSF1_MOUNT_MFS: /* XXX */ #ifdef notyet - if ((error = osf1_mount_mfs(p, uap, &a))) + if ((error = osf1_mount_mfs(td, uap, &a))) return error; #endif return EINVAL; break; case OSF1_MOUNT_CDFS: /* XXX */ return (EINVAL); break; case OSF1_MOUNT_PROCFS: /* XXX */ return (EINVAL); break; case OSF1_MOUNT_NONE: case OSF1_MOUNT_PC: case OSF1_MOUNT_S5FS: case OSF1_MOUNT_DFS: case OSF1_MOUNT_EFS: case OSF1_MOUNT_MSFS: case OSF1_MOUNT_FFM: case OSF1_MOUNT_FDFS: case OSF1_MOUNT_ADDON: default: return (EINVAL); } - return mount(p, &a); + return mount(td, &a); } int -osf1_mount_mfs(p, osf_argp, bsd_argp) - struct proc *p; +osf1_mount_mfs(td, osf_argp, bsd_argp) + struct thread *td; struct osf1_mount_args *osf_argp; struct mount_args *bsd_argp; { #ifdef notyet int error, len; caddr_t sg; static const char mfs_name[] = "mfs"; struct osf1_mfs_args osf_ma; struct mfs_args bsd_ma; sg = stackgap_init(); if ((error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma))) return error; bzero(&bsd_ma, sizeof bsd_ma); bsd_ma.fspec = osf_ma.name; /* XXX export args */ bsd_ma.base = osf_ma.base; bsd_ma.size = osf_ma.size; SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_ma); if ((error = copyout(&bsd_ma, SCARG(bsd_argp, data), sizeof bsd_ma))) return error; len = strlen(mfs_name) + 1; SCARG(bsd_argp, type) = stackgap_alloc(&sg, len); if ((error = copyout(mfs_name, (void *)SCARG(bsd_argp, type), len))) return error; #endif return 0; } int -osf1_mount_nfs(p, osf_argp, bsd_argp) - struct proc *p; +osf1_mount_nfs(td, osf_argp, bsd_argp) + struct thread *td; struct osf1_mount_args *osf_argp; struct mount_args *bsd_argp; { int error, len; caddr_t sg; static const char nfs_name[] = "nfs"; struct osf1_nfs_args osf_na; struct nfs_args bsd_na; sg = stackgap_init(); if ((error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na))) return error; bzero(&bsd_na, sizeof bsd_na); bsd_na.addr = (struct sockaddr *)osf_na.addr; bsd_na.addrlen = sizeof (struct sockaddr_in); bsd_na.sotype = SOCK_DGRAM; bsd_na.proto = 0; bsd_na.fh = osf_na.fh; if (osf_na.flags & ~OSF1_NFSMNT_FLAGS) return EINVAL; if (osf_na.flags & OSF1_NFSMNT_SOFT) bsd_na.flags |= NFSMNT_SOFT; if (osf_na.flags & OSF1_NFSMNT_WSIZE) { bsd_na.wsize = osf_na.wsize; bsd_na.flags |= NFSMNT_WSIZE; } if (osf_na.flags & OSF1_NFSMNT_RSIZE) { bsd_na.rsize = osf_na.rsize; bsd_na.flags |= NFSMNT_RSIZE; } if (osf_na.flags & OSF1_NFSMNT_TIMEO) { bsd_na.timeo = osf_na.timeo; bsd_na.flags |= NFSMNT_TIMEO; } if (osf_na.flags & OSF1_NFSMNT_RETRANS) { bsd_na.retrans = osf_na.retrans; bsd_na.flags |= NFSMNT_RETRANS; } if (osf_na.flags & OSF1_NFSMNT_HOSTNAME) bsd_na.hostname = osf_na.hostname; if (osf_na.flags & OSF1_NFSMNT_INT) bsd_na.flags |= NFSMNT_INT; if (osf_na.flags & OSF1_NFSMNT_NOCONN) bsd_na.flags |= NFSMNT_NOCONN; SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_na); if ((error = copyout(&bsd_na, SCARG(bsd_argp, data), sizeof bsd_na))) return error; len = strlen(nfs_name) + 1; SCARG(bsd_argp, type) = stackgap_alloc(&sg, len); if ((error = copyout(nfs_name, (void *)SCARG(bsd_argp, type), len))) return error; return 0; }