summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cef7aa7)
SCCS-vsn: sys/miscfs/specfs/spec_vnops.c 7.29
SCCS-vsn: sys/kern/subr_log.c 7.10
SCCS-vsn: sys/kern/subr_prf.c 7.19
SCCS-vsn: sys/kern/subr_rmap.c 7.5
SCCS-vsn: sys/kern/sys_process.c 7.14
SCCS-vsn: sys/kern/uipc_mbuf.c 7.18
SCCS-vsn: sys/kern/sysv_shm.c 7.10
SCCS-vsn: sys/kern/vfs_syscalls.c 7.60
SCCS-vsn: sys/kern/kern_exit.c 7.29
SCCS-vsn: sys/kern/kern_proc.c 7.13
SCCS-vsn: sys/kern/kern_sig.c 7.25
SCCS-vsn: sys/kern/kern_synch.c 7.13
SCCS-vsn: sys/kern/tty.c 7.37
SCCS-vsn: sys/kern/vfs_vnops.c 7.25
14 files changed:
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_exit.c 7.28 (Berkeley) %G%
+ * @(#)kern_exit.c 7.29 (Berkeley) %G%
#include "proc.h"
#include "buf.h"
#include "wait.h"
#include "proc.h"
#include "buf.h"
#include "wait.h"
#include "file.h"
#include "vnode.h"
#include "syslog.h"
#include "file.h"
#include "vnode.h"
#include "syslog.h"
#include "machine/psl.h"
#endif
#include "machine/psl.h"
#endif
+#include "../vm/vm_param.h"
+#include "../vm/vm_map.h"
+#include "../vm/vm_kern.h"
+
/*
* Exit system call: pass back caller's arg
*/
/*
* Exit system call: pass back caller's arg
*/
for (i = 0; i < NSIG; i++)
u.u_signal[i] = SIG_IGN;
untimeout(realitexpire, (caddr_t)p);
for (i = 0; i < NSIG; i++)
u.u_signal[i] = SIG_IGN;
untimeout(realitexpire, (caddr_t)p);
+#ifdef SYSVSHM
+ if (p->p_shm)
+ shmexit(p);
+#endif
+ vm_map_deallocate(p->p_map);
+ p->p_map = VM_MAP_NULL;
- * Release virtual memory. If we resulted from
- * a vfork(), instead give the resources back to
- * the parent.
+ * XXX preserve synchronization semantics of vfork
- if ((p->p_flag & SVFORK) == 0) {
-#ifdef MAPMEM
- if (u.u_mmap)
- (void) mmexit(p);
-#endif
- vrelvm();
- } else {
+ if (p->p_flag & SVFORK) {
p->p_flag &= ~SVFORK;
wakeup((caddr_t)p);
while ((p->p_flag & SVFDONE) == 0)
p->p_flag &= ~SVFORK;
wakeup((caddr_t)p);
while ((p->p_flag & SVFDONE) == 0)
if (p->p_tracep)
vrele(p->p_tracep);
#endif
if (p->p_tracep)
vrele(p->p_tracep);
#endif
- /*
- * Freeing the user structure and kernel stack
- * for the current process: have to run a bit longer
- * using the pages which are about to be freed...
- * vrelu will block memory allocation by raising ipl.
- */
- vrelu(p, 0);
- vrelpt(p);
+ splimp();
+ /* I don't think this will cause a sleep/realloc anywhere... */
+ kmem_free(kernel_map, (vm_offset_t)p->p_addr,
+ round_page(ctob(UPAGES)));
if (*p->p_prev = p->p_nxt) /* off allproc queue */
p->p_nxt->p_prev = p->p_prev;
if (p->p_nxt = zombproc) /* onto zombproc */
p->p_nxt->p_prev = &p->p_nxt;
p->p_prev = &zombproc;
zombproc = p;
if (*p->p_prev = p->p_nxt) /* off allproc queue */
p->p_nxt->p_prev = p->p_prev;
if (p->p_nxt = zombproc) /* onto zombproc */
p->p_nxt->p_prev = &p->p_nxt;
p->p_prev = &zombproc;
zombproc = p;
p->p_stat = SZOMB;
noproc = 1;
for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash)
p->p_stat = SZOMB;
noproc = 1;
for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash)
- if (p->p_pid == 1) {
- if (p->p_dsize == 0) {
- printf("Can't exec init (errno %d)\n", WEXITSTATUS(rv));
- for (;;)
- ;
- } else
- panic("init died");
- }
+ if (p->p_pid == 1)
+ panic("init died");
p->p_xstat = rv;
*p->p_ru = u.u_ru;
i = splclock();
p->p_xstat = rv;
*p->p_ru = u.u_ru;
i = splclock();
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_proc.c 7.12 (Berkeley) %G%
+ * @(#)kern_proc.c 7.13 (Berkeley) %G%
#include "seg.h"
#include "acct.h"
#include "wait.h"
#include "seg.h"
#include "acct.h"
#include "wait.h"
-#include "vm.h"
-#include "text.h"
#include "file.h"
#include "../ufs/quota.h"
#include "uio.h"
#include "file.h"
#include "../ufs/quota.h"
#include "uio.h"
#include "tty.h"
#include "machine/reg.h"
#include "tty.h"
#include "machine/reg.h"
-#include "machine/pte.h"
#include "machine/psl.h"
/*
#include "machine/psl.h"
/*
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_sig.c 7.24 (Berkeley) %G%
+ * @(#)kern_sig.c 7.25 (Berkeley) %G%
#include "timeb.h"
#include "times.h"
#include "buf.h"
#include "timeb.h"
#include "times.h"
#include "buf.h"
#include "acct.h"
#include "uio.h"
#include "file.h"
#include "acct.h"
#include "uio.h"
#include "file.h"
#include "ktrace.h"
#include "machine/reg.h"
#include "ktrace.h"
#include "machine/reg.h"
-#include "machine/pte.h"
#include "machine/psl.h"
#include "machine/mtpr.h"
#include "machine/psl.h"
#include "machine/mtpr.h"
+#include "../vm/vm_param.h"
#define ttystopsigmask (sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU))
#define stopsigmask (sigmask(SIGSTOP)|ttystopsigmask)
#define ttystopsigmask (sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU))
#define stopsigmask (sigmask(SIGSTOP)|ttystopsigmask)
* and don't clear any pending SIGCONT.
*/
if (p->p_pgrp->pg_jobc == 0 && action == SIG_DFL)
* and don't clear any pending SIGCONT.
*/
if (p->p_pgrp->pg_jobc == 0 && action == SIG_DFL)
/* FALLTHROUGH */
case SIGSTOP:
/* FALLTHROUGH */
case SIGSTOP:
if (ctob(UPAGES + u.u_dsize + u.u_ssize) >=
u.u_rlimit[RLIMIT_CORE].rlim_cur)
return (EFAULT);
if (ctob(UPAGES + u.u_dsize + u.u_ssize) >=
u.u_rlimit[RLIMIT_CORE].rlim_cur)
return (EFAULT);
- if (p->p_textp) {
- VOP_LOCK(p->p_textp->x_vptr);
- error = VOP_ACCESS(p->p_textp->x_vptr, VREAD, u.u_cred);
- VOP_UNLOCK(p->p_textp->x_vptr);
- if (error)
- return (EFAULT);
- }
ndp->ni_segflg = UIO_SYSSPACE;
ndp->ni_dirp = "core";
if (error = vn_open(ndp, FCREAT|FWRITE, 0644))
ndp->ni_segflg = UIO_SYSSPACE;
ndp->ni_dirp = "core";
if (error = vn_open(ndp, FCREAT|FWRITE, 0644))
vput(vp);
return (EFAULT);
}
vput(vp);
return (EFAULT);
}
-#ifdef MAPMEM
- if (error = mmcore(p)) {
- vput(vp);
- return (error);
- }
-#endif
VATTR_NULL(&vattr);
vattr.va_size = 0;
VOP_SETATTR(vp, &vattr, u.u_cred);
VATTR_NULL(&vattr);
vattr.va_size = 0;
VOP_SETATTR(vp, &vattr, u.u_cred);
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&u, ctob(UPAGES), (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
if (error == 0)
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&u, ctob(UPAGES), (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
if (error == 0)
- error = vn_rdwr(UIO_WRITE, vp,
- (caddr_t)ctob(dptov(p, 0)),
+ error = vn_rdwr(UIO_WRITE, vp, u.u_daddr,
(int)ctob(u.u_dsize), (off_t)ctob(UPAGES), UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
if (error == 0)
error = vn_rdwr(UIO_WRITE, vp,
(int)ctob(u.u_dsize), (off_t)ctob(UPAGES), UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
if (error == 0)
error = vn_rdwr(UIO_WRITE, vp,
- (caddr_t)ctob(sptov(p, u.u_ssize - 1)),
- (int)ctob(u.u_ssize),
+ trunc_page(USRSTACK - ctob(u.u_ssize)),
+ round_page(ctob(u.u_ssize)),
(off_t)ctob(UPAGES) + ctob(u.u_dsize), UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
vput(vp);
(off_t)ctob(UPAGES) + ctob(u.u_dsize), UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, ndp->ni_cred, (int *)0);
vput(vp);
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)kern_synch.c 7.12 (Berkeley) %G%
+ * @(#)kern_synch.c 7.13 (Berkeley) %G%
-#include "machine/pte.h"
-#include "machine/psl.h"
-#include "machine/mtpr.h"
-
#include "param.h"
#include "systm.h"
#include "user.h"
#include "proc.h"
#include "param.h"
#include "systm.h"
#include "user.h"
#include "proc.h"
#include "kernel.h"
#include "buf.h"
#include "kernel.h"
#include "buf.h"
+#include "machine/psl.h"
+#include "machine/mtpr.h"
+
/*
* Force switch among equal priority processes every 100ms.
*/
/*
* Force switch among equal priority processes every 100ms.
*/
p = (pp->p_cpu & 0377)/4;
p += PUSER + 2 * pp->p_nice;
p = (pp->p_cpu & 0377)/4;
p += PUSER + 2 * pp->p_nice;
- if (pp->p_rssize > pp->p_maxrss && freemem < desfree)
- p += 2*4; /* effectively, nice(4) */
if (p > 127)
p = 127;
if (p < curpri) {
if (p > 127)
p = 127;
if (p < curpri) {
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- * @(#)subr_log.c 7.9 (Berkeley) %G%
+ * %sccs.include.redist.c%
+ *
+ * @(#)subr_log.c 7.10 (Berkeley) %G%
logopen(dev)
dev_t dev;
{
logopen(dev)
dev_t dev;
{
+ register struct msgbuf *mbp = msgbufp;
if (log_open)
return (EBUSY);
if (log_open)
return (EBUSY);
* called by autoconf, msg_magic should be initialized by the time
* we get here.
*/
* called by autoconf, msg_magic should be initialized by the time
* we get here.
*/
- if (msgbuf.msg_magic != MSG_MAGIC) {
+ if (mbp->msg_magic != MSG_MAGIC) {
- msgbuf.msg_magic = MSG_MAGIC;
- msgbuf.msg_bufx = msgbuf.msg_bufr = 0;
+ mbp->msg_magic = MSG_MAGIC;
+ mbp->msg_bufx = mbp->msg_bufr = 0;
for (i=0; i < MSG_BSIZE; i++)
for (i=0; i < MSG_BSIZE; i++)
- msgbuf.msg_bufc[i] = 0;
struct uio *uio;
int flag;
{
struct uio *uio;
int flag;
{
+ register struct msgbuf *mbp = msgbufp;
register long l;
register int s;
int error = 0;
s = splhigh();
register long l;
register int s;
int error = 0;
s = splhigh();
- while (msgbuf.msg_bufr == msgbuf.msg_bufx) {
+ while (mbp->msg_bufr == mbp->msg_bufx) {
if (flag & IO_NDELAY) {
splx(s);
return (EWOULDBLOCK);
}
logsoftc.sc_state |= LOG_RDWAIT;
if (flag & IO_NDELAY) {
splx(s);
return (EWOULDBLOCK);
}
logsoftc.sc_state |= LOG_RDWAIT;
- if (error = tsleep((caddr_t)&msgbuf, LOG_RDPRI | PCATCH,
+ if (error = tsleep((caddr_t)mbp, LOG_RDPRI | PCATCH,
"klog", 0)) {
splx(s);
return (error);
"klog", 0)) {
splx(s);
return (error);
logsoftc.sc_state &= ~LOG_RDWAIT;
while (uio->uio_resid > 0) {
logsoftc.sc_state &= ~LOG_RDWAIT;
while (uio->uio_resid > 0) {
- l = msgbuf.msg_bufx - msgbuf.msg_bufr;
+ l = mbp->msg_bufx - mbp->msg_bufr;
- l = MSG_BSIZE - msgbuf.msg_bufr;
+ l = MSG_BSIZE - mbp->msg_bufr;
l = MIN(l, uio->uio_resid);
if (l == 0)
break;
l = MIN(l, uio->uio_resid);
if (l == 0)
break;
- error = uiomove((caddr_t)&msgbuf.msg_bufc[msgbuf.msg_bufr],
+ error = uiomove((caddr_t)&mbp->msg_bufc[mbp->msg_bufr],
(int)l, uio);
if (error)
break;
(int)l, uio);
if (error)
break;
- msgbuf.msg_bufr += l;
- if (msgbuf.msg_bufr < 0 || msgbuf.msg_bufr >= MSG_BSIZE)
- msgbuf.msg_bufr = 0;
+ mbp->msg_bufr += l;
+ if (mbp->msg_bufr < 0 || mbp->msg_bufr >= MSG_BSIZE)
+ mbp->msg_bufr = 0;
switch (rw) {
case FREAD:
switch (rw) {
case FREAD:
- if (msgbuf.msg_bufr != msgbuf.msg_bufx) {
+ if (msgbufp->msg_bufr != msgbufp->msg_bufx) {
psignal(p, SIGIO);
}
if (logsoftc.sc_state & LOG_RDWAIT) {
psignal(p, SIGIO);
}
if (logsoftc.sc_state & LOG_RDWAIT) {
- wakeup((caddr_t)&msgbuf);
+ wakeup((caddr_t)msgbufp);
logsoftc.sc_state &= ~LOG_RDWAIT;
}
}
logsoftc.sc_state &= ~LOG_RDWAIT;
}
}
/* return number of characters immediately available */
case FIONREAD:
s = splhigh();
/* return number of characters immediately available */
case FIONREAD:
s = splhigh();
- l = msgbuf.msg_bufx - msgbuf.msg_bufr;
+ l = msgbufp->msg_bufx - msgbufp->msg_bufr;
splx(s);
if (l < 0)
l += MSG_BSIZE;
splx(s);
if (l < 0)
l += MSG_BSIZE;
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)subr_prf.c 7.18 (Berkeley) %G%
+ * @(#)subr_prf.c 7.19 (Berkeley) %G%
#include "buf.h"
#include "conf.h"
#include "reboot.h"
#include "buf.h"
#include "conf.h"
#include "reboot.h"
#include "msgbuf.h"
#include "user.h"
#include "proc.h"
#include "msgbuf.h"
#include "user.h"
#include "proc.h"
register int c;
struct tty *ttyp;
{
register int c;
struct tty *ttyp;
{
+ register struct msgbuf *mbp = msgbufp;
extern int msgbufmapped;
if (panicstr)
extern int msgbufmapped;
if (panicstr)
constty = 0;
if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177 &&
msgbufmapped) {
constty = 0;
if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177 &&
msgbufmapped) {
- if (msgbuf.msg_magic != MSG_MAGIC) {
+ if (mbp->msg_magic != MSG_MAGIC) {
- msgbuf.msg_magic = MSG_MAGIC;
- msgbuf.msg_bufx = msgbuf.msg_bufr = 0;
+ mbp->msg_magic = MSG_MAGIC;
+ mbp->msg_bufx = mbp->msg_bufr = 0;
for (i=0; i < MSG_BSIZE; i++)
for (i=0; i < MSG_BSIZE; i++)
- msgbuf.msg_bufc[i] = 0;
- msgbuf.msg_bufc[msgbuf.msg_bufx++] = c;
- if (msgbuf.msg_bufx < 0 || msgbuf.msg_bufx >= MSG_BSIZE)
- msgbuf.msg_bufx = 0;
+ mbp->msg_bufc[mbp->msg_bufx++] = c;
+ if (mbp->msg_bufx < 0 || mbp->msg_bufx >= MSG_BSIZE)
+ mbp->msg_bufx = 0;
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)subr_rmap.c 7.4 (Berkeley) %G%
+ * @(#)subr_rmap.c 7.5 (Berkeley) %G%
#include "map.h"
#include "user.h"
#include "proc.h"
#include "map.h"
#include "user.h"
#include "proc.h"
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)sys_process.c 7.13 (Berkeley) %G%
+ * @(#)sys_process.c 7.14 (Berkeley) %G%
#include "user.h"
#include "proc.h"
#include "vnode.h"
#include "user.h"
#include "proc.h"
#include "vnode.h"
#include "seg.h"
#include "buf.h"
#include "ptrace.h"
#include "machine/reg.h"
#include "machine/psl.h"
#include "seg.h"
#include "buf.h"
#include "ptrace.h"
#include "machine/reg.h"
#include "machine/psl.h"
-#include "machine/pte.h"
+#include "../vm/vm_page.h"
+#include "../vm/vm_prot.h"
/*
* Priority for tracing
/*
* Priority for tracing
register struct proc *p;
{
register int i, *poff;
register struct proc *p;
{
register int i, *poff;
- register struct text *xp;
- struct vattr vattr;
if (ipc.ip_lock != p->p_pid)
return (0);
if (ipc.ip_lock != p->p_pid)
return (0);
break;
case PT_WRITE_I: /* write the child's text space */
break;
case PT_WRITE_I: /* write the child's text space */
- /*
- * If text, must assure exclusive use
- */
- if (xp = p->p_textp) {
- if (xp->x_count != 1 ||
- VOP_GETATTR(xp->x_vptr, &vattr, u.u_cred) ||
- (vattr.va_mode & VSVTX))
- goto error;
- xp->x_flag |= XTRC;
- }
- i = -1;
if ((i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data)) < 0) {
if ((i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data)) < 0) {
- if (!chgprot((caddr_t)ipc.ip_addr, RW) &&
- !chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RW))
+ vm_offset_t sa, ea;
+ int rv;
+
+ sa = trunc_page((vm_offset_t)ipc.ip_addr);
+ ea = round_page((vm_offset_t)ipc.ip_addr+sizeof(int)-1);
+ rv = vm_map_protect(p->p_map, sa, ea,
+ VM_PROT_DEFAULT, FALSE);
+ if (rv == KERN_SUCCESS) {
i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
- (void) chgprot((caddr_t)ipc.ip_addr, RO);
- (void) chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RO);
+ (void) vm_map_protect(p->p_map, sa, ea,
+ VM_PROT_READ|VM_PROT_EXECUTE, FALSE);
+ }
-#if defined(tahoe)
- /* make sure the old value is not in cache */
- ckeyrelease(p->p_ckey);
- p->p_ckey = getcodekey();
-#endif
- if (xp) {
- xp->x_flag |= XWRIT;
-#if defined(tahoe)
- xp->x_ckey = p->p_ckey;
-#endif
- }
break;
case PT_WRITE_D: /* write the child's data space */
break;
case PT_WRITE_D: /* write the child's data space */
*
* from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
*
*
* from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
*
- * @(#)sysv_shm.c 7.9 (Berkeley) %G%
+ * @(#)sysv_shm.c 7.10 (Berkeley) %G%
-#include "machine/pte.h"
-
#include "param.h"
#include "systm.h"
#include "user.h"
#include "kernel.h"
#include "proc.h"
#include "param.h"
#include "systm.h"
#include "user.h"
#include "kernel.h"
#include "proc.h"
+#include "mman.h"
+#include "../vm/vm_param.h"
+#include "../vm/vm_map.h"
+#include "../vm/vm_kern.h"
+#include "../vm/vm_inherit.h"
+#include "../vm/vm_pager.h"
#ifdef HPUXCOMPAT
#include "../hpux/hpux.h"
#ifdef HPUXCOMPAT
#include "../hpux/hpux.h"
int (*shmcalls[])() = { shmat, shmctl, shmdt, shmget };
int shmtot = 0;
int (*shmcalls[])() = { shmat, shmctl, shmdt, shmget };
int shmtot = 0;
-int shmfork(), shmexit();
-struct mapmemops shmops = { shmfork, (int (*)())0, shmexit, shmexit };
+/*
+ * Per process internal structure for managing segments.
+ * Each process using shm will have an array of ``shmseg'' of these.
+ */
+struct shmdesc {
+ vm_offset_t shmd_uva;
+ int shmd_id;
+};
+
+/*
+ * Per segment internal structure (shm_handle).
+ */
+struct shmhandle {
+ vm_offset_t shmh_kva;
+ caddr_t shmh_id;
+};
+
+vm_map_t shm_map; /* address space for shared memory segments */
shminit()
{
register int i;
shminit()
{
register int i;
+ vm_offset_t whocares1, whocares2;
+ shm_map = kmem_suballoc(kernel_map, &whocares1, &whocares2,
+ shminfo.shmall * NBPG, FALSE);
if (shminfo.shmmni > SHMMMNI)
shminfo.shmmni = SHMMMNI;
for (i = 0; i < shminfo.shmmni; i++) {
if (shminfo.shmmni > SHMMMNI)
shminfo.shmmni = SHMMMNI;
for (i = 0; i < shminfo.shmmni; i++) {
register struct ucred *cred = u.u_cred;
register int i;
int error, size, rval = 0;
register struct ucred *cred = u.u_cred;
register int i;
int error, size, rval = 0;
+ register struct shmhandle *shmh;
/* look up the specified shm_id */
if (uap->key != IPC_PRIVATE) {
/* look up the specified shm_id */
if (uap->key != IPC_PRIVATE) {
*/
shp->shm_perm.mode = SHM_ALLOC | SHM_DEST;
shp->shm_perm.key = uap->key;
*/
shp->shm_perm.mode = SHM_ALLOC | SHM_DEST;
shp->shm_perm.key = uap->key;
- kva = (caddr_t) malloc((u_long)ctob(size), M_SHM, M_WAITOK);
- if (kva == NULL) {
+ shmh = (struct shmhandle *)
+ malloc(sizeof(struct shmhandle), M_SHM, M_WAITOK);
+ shmh->shmh_kva = 0;
+ shmh->shmh_id = (caddr_t)(0xc0000000|rval); /* XXX */
+ error = vm_mmap(shm_map, &shmh->shmh_kva, ctob(size),
+ VM_PROT_ALL, MAP_ANON, shmh->shmh_id, 0);
+ if (error) {
+ free((caddr_t)shmh, M_SHM);
- if (!claligned(kva))
- panic("shmget: non-aligned memory");
- bzero(kva, (u_int)ctob(size));
+ shp->shm_handle = (void *) shmh;
shmtot += size;
shp->shm_perm.cuid = shp->shm_perm.uid = cred->cr_uid;
shp->shm_perm.cgid = shp->shm_perm.gid = cred->cr_gid;
shp->shm_perm.mode = SHM_ALLOC | (uap->shmflg&0777);
shmtot += size;
shp->shm_perm.cuid = shp->shm_perm.uid = cred->cr_uid;
shp->shm_perm.cgid = shp->shm_perm.gid = cred->cr_gid;
shp->shm_perm.mode = SHM_ALLOC | (uap->shmflg&0777);
- shp->shm_handle = (void *) kvtopte(kva);
shp->shm_segsz = uap->size;
shp->shm_cpid = p->p_pid;
shp->shm_lpid = shp->shm_nattch = 0;
shp->shm_segsz = uap->size;
shp->shm_cpid = p->p_pid;
shp->shm_lpid = shp->shm_nattch = 0;
{
register struct shmid_ds *shp;
register int size;
{
register struct shmid_ds *shp;
register int size;
- int error, prot, shmmapin();
+ int error;
+ int flags;
+ vm_prot_t prot;
+ struct shmdesc *shmd;
+ /*
+ * Allocate descriptors now (before validity check)
+ * in case malloc() blocks.
+ */
+ shmd = (struct shmdesc *)p->p_shm;
+ size = shminfo.shmseg * sizeof(struct shmdesc);
+ if (shmd == NULL) {
+ shmd = (struct shmdesc *)malloc(size, M_SHM, M_WAITOK);
+ bzero((caddr_t)shmd, size);
+ p->p_shm = (caddr_t)shmd;
+ }
if (error = shmvalid(uap->shmid))
return (error);
shp = &shmsegs[uap->shmid % SHMMMNI];
if (error = shmvalid(uap->shmid))
return (error);
shp = &shmsegs[uap->shmid % SHMMMNI];
/*
* Make sure user doesn't use more than their fair share
*/
/*
* Make sure user doesn't use more than their fair share
*/
- size = 0;
- for (mp = u.u_mmap; mp; mp = mp->mm_next)
- if (mp->mm_ops == &shmops)
- size++;
+ for (size = 0; size < shminfo.shmseg; size++) {
+ if (shmd->shmd_uva == 0)
+ break;
+ shmd++;
+ }
if (size >= shminfo.shmseg)
return (EMFILE);
if (size >= shminfo.shmseg)
return (EMFILE);
- /*
- * Allocate a mapped memory region descriptor and
- * attempt to expand the user page table to allow for region
- */
- prot = (uap->shmflg & SHM_RDONLY) ? MM_RO : MM_RW;
-#if defined(hp300)
- prot |= MM_CI;
-#endif
size = ctob(clrnd(btoc(shp->shm_segsz)));
size = ctob(clrnd(btoc(shp->shm_segsz)));
- error = mmalloc(p, uap->shmid, &uva, (segsz_t)size, prot, &shmops, &mp);
+ prot = VM_PROT_READ;
+ if ((uap->shmflg & SHM_RDONLY) == 0)
+ prot |= VM_PROT_WRITE;
+ flags = MAP_ANON|MAP_SHARED;
+ if (uva)
+ flags |= MAP_FIXED;
+ else
+ uva = (caddr_t)0x1000000; /* XXX */
+ error = vm_mmap(p->p_map, &uva, (vm_size_t)size, prot, flags,
+ ((struct shmhandle *)shp->shm_handle)->shmh_id, 0);
- return (error);
- if (error = mmmapin(p, mp, shmmapin)) {
- (void) mmfree(p, mp);
- return (error);
- }
+ return(error);
+ shmd->shmd_uva = (vm_offset_t)uva;
+ shmd->shmd_id = uap->shmid;
/*
* Fill in the remaining fields
*/
/*
* Fill in the remaining fields
*/
- register struct mapmem *mp;
+ register struct shmdesc *shmd;
+ register int i;
- for (mp = u.u_mmap; mp; mp = mp->mm_next)
- if (mp->mm_ops == &shmops && mp->mm_uva == uap->shmaddr)
+ shmd = (struct shmdesc *)p->p_shm;
+ for (i = 0; i < shminfo.shmseg; i++, shmd++)
+ if (shmd->shmd_uva &&
+ shmd->shmd_uva == (vm_offset_t)uap->shmaddr)
- if (mp == MMNIL)
- return (EINVAL);
- shmsegs[mp->mm_id % SHMMMNI].shm_lpid = p->p_pid;
- return (shmufree(p, mp));
+ if (i == shminfo.shmseg)
+ return(EINVAL);
+ shmufree(p, shmd);
+ shmsegs[shmd->shmd_id % SHMMMNI].shm_lpid = p->p_pid;
-shmmapin(mp, off)
- struct mapmem *mp;
+shmfork(rip, rpp, isvfork)
+ struct proc *rip, *rpp;
+ int isvfork;
- register struct shmid_ds *shp;
-
- shp = &shmsegs[mp->mm_id % SHMMMNI];
- if (off >= ctob(clrnd(btoc(shp->shm_segsz))))
- return(-1);
- return(((struct pte *)shp->shm_handle)[btop(off)].pg_pfnum);
-}
+ register struct shmdesc *shmd;
+ register int size;
-/*
- * Increment attach count on fork
- */
-/* ARGSUSED */
-shmfork(mp, ischild)
- register struct mapmem *mp;
-{
- if (!ischild)
- shmsegs[mp->mm_id % SHMMMNI].shm_nattch++;
+ /*
+ * Copy parents descriptive information
+ */
+ size = shminfo.shmseg * sizeof(struct shmdesc);
+ shmd = (struct shmdesc *)malloc(size, M_SHM, M_WAITOK);
+ bcopy((caddr_t)rip->p_shm, (caddr_t)shmd, size);
+ rpp->p_shm = (caddr_t)shmd;
+ /*
+ * Increment reference counts
+ */
+ for (size = 0; size < shminfo.shmseg; size++, shmd++)
+ if (shmd->shmd_uva)
+ shmsegs[shmd->shmd_id % SHMMMNI].shm_nattch++;
-/*
- * Detach from shared memory segment on exit (or exec)
- */
-shmexit(mp)
- struct mapmem *mp;
+shmexit(p)
+ struct proc *p;
- struct proc *p = u.u_procp; /* XXX */
+ register struct shmdesc *shmd;
+ register int i;
- return (shmufree(p, mp));
+ shmd = (struct shmdesc *)p->p_shm;
+ for (i = 0; i < shminfo.shmseg; i++, shmd++)
+ if (shmd->shmd_uva)
+ shmufree(p, shmd);
+ free((caddr_t)p->p_shm, M_SHM);
+ p->p_shm = NULL;
/*
* Free user resources associated with a shared memory segment
*/
/*
* Free user resources associated with a shared memory segment
*/
{
register struct shmid_ds *shp;
{
register struct shmid_ds *shp;
- shp = &shmsegs[mp->mm_id % SHMMMNI];
- mmmapout(p, mp);
- error = mmfree(p, mp);
+ shp = &shmsegs[shmd->shmd_id % SHMMMNI];
+ (void) vm_deallocate(p->p_map, shmd->shmd_uva,
+ ctob(clrnd(btoc(shp->shm_segsz))));
+ shmd->shmd_id = 0;
+ shmd->shmd_uva = 0;
shp->shm_dtime = time.tv_sec;
if (--shp->shm_nattch <= 0 && (shp->shm_perm.mode & SHM_DEST))
shmfree(shp);
shp->shm_dtime = time.tv_sec;
if (--shp->shm_nattch <= 0 && (shp->shm_perm.mode & SHM_DEST))
shmfree(shp);
if (shp->shm_handle == NULL)
panic("shmfree");
if (shp->shm_handle == NULL)
panic("shmfree");
- kva = (caddr_t) ptetokv(shp->shm_handle);
- free(kva, M_SHM);
+ /*
+ * Lose our lingering object reference by deallocating space
+ * in kernel. Pager will also be deallocated as a side-effect.
+ */
+ vm_deallocate(shm_map,
+ ((struct shmhandle *)shp->shm_handle)->shmh_kva,
+ clrnd(btoc(shp->shm_segsz)));
+ free((caddr_t)shp->shm_handle, M_SHM);
shp->shm_handle = NULL;
shmtot -= clrnd(btoc(shp->shm_segsz));
shp->shm_perm.mode = 0;
shp->shm_handle = NULL;
shmtot -= clrnd(btoc(shp->shm_segsz));
shp->shm_perm.mode = 0;
return (0);
return (EACCES);
}
return (0);
return (EACCES);
}
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)tty.c 7.36 (Berkeley) %G%
+ * @(#)tty.c 7.37 (Berkeley) %G%
tputchar('.', tp);
ttyoutint(x%100, 10, 2, tp);
#endif
tputchar('.', tp);
ttyoutint(x%100, 10, 2, tp);
#endif
- ttyprintf(tp, "%% %dk\n", pgtok(pick->p_ssize + pick->p_dsize));
+ ttyprintf(tp, "%% %dk\n", pgtok(pick->p_rssize));
}
tp->t_rocount = 0; /* so pending input will be retyped if BS */
}
}
tp->t_rocount = 0; /* so pending input will be retyped if BS */
}
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)uipc_mbuf.c 7.17 (Berkeley) %G%
+ * @(#)uipc_mbuf.c 7.18 (Berkeley) %G%
#include "map.h"
#define MBTYPES
#include "mbuf.h"
#include "map.h"
#define MBTYPES
#include "mbuf.h"
#include "kernel.h"
#include "syslog.h"
#include "domain.h"
#include "protosw.h"
#include "kernel.h"
#include "syslog.h"
#include "domain.h"
#include "protosw.h"
-#include "machine/pte.h"
+#include "../vm/vm_param.h"
+#include "../vm/vm_map.h"
+
+extern vm_map_t mb_map;
+struct mbuf *mbutl;
+char *mclrefcnt;
#define NCL_INIT (4096/CLBYTES)
#else
#define NCL_INIT 1
#define NCL_INIT (4096/CLBYTES)
#else
#define NCL_INIT 1
static int logged;
npg = ncl * CLSIZE;
static int logged;
npg = ncl * CLSIZE;
- mbx = rmalloc(mbmap, (long)npg);
- if (mbx == 0) {
+ p = (caddr_t)kmem_malloc(mb_map, ctob(npg), canwait);
+ if (p == NULL) {
if (logged == 0) {
logged++;
if (logged == 0) {
logged++;
- log(LOG_ERR, "mbuf map full\n");
+ log(LOG_ERR, "mb_map full\n");
- p = cltom(mbx * NBPG / MCLBYTES);
- if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0) {
- rmfree(mbmap, (long)npg, (long)mbx);
- return (0);
- }
- vmaccess(&Mbmap[mbx], p, npg);
ncl = ncl * CLBYTES / MCLBYTES;
for (i = 0; i < ncl; i++) {
((union mcluster *)p)->mcl_next = mclfree;
ncl = ncl * CLBYTES / MCLBYTES;
for (i = 0; i < ncl; i++) {
((union mcluster *)p)->mcl_next = mclfree;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)vfs_syscalls.c 7.59 (Berkeley) %G%
+ * @(#)vfs_syscalls.c 7.60 (Berkeley) %G%
if (error = vfs_lock(mp))
return (error);
if (error = vfs_lock(mp))
return (error);
- xumount(mp); /* remove unused sticky files from text table */
+ vnode_pager_umount(mp); /* release cached vnodes */
cache_purgevfs(mp); /* remove cache entries for this file sys */
if ((error = VFS_SYNC(mp, MNT_WAIT)) == 0 || (flags & MNT_FORCE))
error = VFS_UNMOUNT(mp, flags);
cache_purgevfs(mp); /* remove cache entries for this file sys */
if ((error = VFS_SYNC(mp, MNT_WAIT)) == 0 || (flags & MNT_FORCE))
error = VFS_UNMOUNT(mp, flags);
error = EBUSY;
goto out;
}
error = EBUSY;
goto out;
}
- if (vp->v_flag & VTEXT)
- xrele(vp); /* try once to free text */
+ (void) vnode_pager_uncache(vp);
out:
if (!error) {
error = VOP_REMOVE(ndp);
out:
if (!error) {
error = VOP_REMOVE(ndp);
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)vfs_vnops.c 7.24 (Berkeley) %G%
+ * @(#)vfs_vnops.c 7.25 (Berkeley) %G%
* the vnode, try to free it up once. If
* we fail, we can't allow writing.
*/
* the vnode, try to free it up once. If
* we fail, we can't allow writing.
*/
- if (vp->v_flag & VTEXT)
- xrele(vp);
- if (vp->v_flag & VTEXT)
+ if ((vp->v_flag & VTEXT) && !vnode_pager_uncache(vp))
return (ETXTBSY);
return (0);
}
return (ETXTBSY);
return (0);
}
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)spec_vnops.c 7.28 (Berkeley) %G%
+ * @(#)spec_vnops.c 7.29 (Berkeley) %G%
daddr_t bn;
int bsize, blkmask;
struct partinfo dpart;
daddr_t bn;
int bsize, blkmask;
struct partinfo dpart;
- register int n, on, i;
- int count, error = 0;
+ register int n, on;
+ int error = 0;
extern int mem_no;
if (uio->uio_rw != UIO_WRITE)
extern int mem_no;
if (uio->uio_rw != UIO_WRITE)
bn = (uio->uio_offset / DEV_BSIZE) &~ blkmask;
on = uio->uio_offset % bsize;
n = MIN((unsigned)(bsize - on), uio->uio_resid);
bn = (uio->uio_offset / DEV_BSIZE) &~ blkmask;
on = uio->uio_offset % bsize;
n = MIN((unsigned)(bsize - on), uio->uio_resid);
- count = howmany(bsize, CLBYTES);
- for (i = 0; i < count; i++)
- munhash(vp, bn + i * (CLBYTES / DEV_BSIZE));
if (n == bsize)
bp = getblk(vp, bn, bsize);
else
if (n == bsize)
bp = getblk(vp, bn, bsize);
else