29c29
< * $FreeBSD: head/sys/kern/imgact_elf.c 50477 1999-08-28 01:08:13Z peter $
---
> * $FreeBSD: head/sys/kern/imgact_elf.c 50717 1999-09-01 00:29:56Z julian $
686c686
< elf_coredump(p)
---
> elf_coredump(p, vp, limit)
688d687
< {
689a689,690
> off_t limit;
> {
691,694c692
< struct nameidata nd;
< struct vattr vattr;
< int error, error1;
< char *name; /* name of corefile */
---
> int error = 0;
699,703d696
< STOPEVENT(p, S_CORE, 0);
<
< if (sugid_coredump == 0 && p->p_flag & P_SUGID)
< return (EFAULT);
<
719c712
< if (hdrsize + seginfo.size >= p->p_rlimit[RLIMIT_CORE].rlim_cur)
---
> if (hdrsize + seginfo.size >= limit)
721,730d713
< name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
< if (name == NULL)
< return (EFAULT); /* XXX -- not the best error */
<
< NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
< error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
< free(name, M_TEMP);
< if (error)
< return (error);
< vp = nd.ni_vp;
732,744d714
< /* 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) {
< error = EFAULT;
< goto out;
< }
< VATTR_NULL(&vattr);
< vattr.va_size = 0;
< VOP_LEASE(vp, p, cred, LEASE_WRITE);
< VOP_SETATTR(vp, &vattr, cred, p);
< p->p_acflag |= ACORE;
<
<
751,752c721
< error = EINVAL;
< goto out;
---
> return EINVAL;
775,781c744,745
<
< out:
< VOP_UNLOCK(vp, 0, p);
< error1 = vn_close(vp, FWRITE, cred, p);
< if (error == 0)
< error = error1;
< return (error);
---
>
> return error;
< * $FreeBSD: head/sys/kern/imgact_elf.c 50477 1999-08-28 01:08:13Z peter $
---
> * $FreeBSD: head/sys/kern/imgact_elf.c 50717 1999-09-01 00:29:56Z julian $
686c686
< elf_coredump(p)
---
> elf_coredump(p, vp, limit)
688d687
< {
689a689,690
> off_t limit;
> {
691,694c692
< struct nameidata nd;
< struct vattr vattr;
< int error, error1;
< char *name; /* name of corefile */
---
> int error = 0;
699,703d696
< STOPEVENT(p, S_CORE, 0);
<
< if (sugid_coredump == 0 && p->p_flag & P_SUGID)
< return (EFAULT);
<
719c712
< if (hdrsize + seginfo.size >= p->p_rlimit[RLIMIT_CORE].rlim_cur)
---
> if (hdrsize + seginfo.size >= limit)
721,730d713
< name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
< if (name == NULL)
< return (EFAULT); /* XXX -- not the best error */
<
< NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
< error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
< free(name, M_TEMP);
< if (error)
< return (error);
< vp = nd.ni_vp;
732,744d714
< /* 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) {
< error = EFAULT;
< goto out;
< }
< VATTR_NULL(&vattr);
< vattr.va_size = 0;
< VOP_LEASE(vp, p, cred, LEASE_WRITE);
< VOP_SETATTR(vp, &vattr, cred, p);
< p->p_acflag |= ACORE;
<
<
751,752c721
< error = EINVAL;
< goto out;
---
> return EINVAL;
775,781c744,745
<
< out:
< VOP_UNLOCK(vp, 0, p);
< error1 = vn_close(vp, FWRITE, cred, p);
< if (error == 0)
< error = error1;
< return (error);
---
>
> return error;