? a.out ? ktrace.out ? o Index: kern_core.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_core.c,v retrieving revision 1.18 diff -u -u -r1.18 kern_core.c --- kern_core.c 29 Apr 2011 22:57:54 -0000 1.18 +++ kern_core.c 22 Sep 2011 23:48:28 -0000 @@ -102,7 +102,7 @@ struct coredump_iostate io; struct plimit *lim; int error, error1; - char *name; + char *name, *lastslash; name = PNBUF_GET(); @@ -133,24 +133,6 @@ cred = p->p_cred; /* - * The core dump will go in the current working directory. Make - * sure that the directory is still there and that the mount flags - * allow us to write core dumps there. - * - * XXX: this is partially bogus, it should be checking the directory - * into which the file is actually written - which probably needs - * a flag on namei() - */ - vp = p->p_cwdi->cwdi_cdir; - if (vp->v_mount == NULL || - (vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0) { - error = EPERM; - mutex_exit(p->p_lock); - mutex_exit(proc_lock); - goto done; - } - - /* * Make sure the process has not set-id, to prevent data leaks, * unless it was specifically requested to allow set-id coredumps. */ @@ -173,10 +155,50 @@ error = coredump_buildname(p, name, pattern, MAXPATHLEN); mutex_exit(&lim->pl_lock); + /* + * On a simple filename, see if the filesystem allow us to write + * core dumps there. + */ + lastslash = strrchr(name, '/'); + if (!lastslash) { + vp = p->p_cwdi->cwdi_cdir; + if (vp->v_mount == NULL || + (vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0) + error = EPERM; + } + mutex_exit(p->p_lock); mutex_exit(proc_lock); - if (error) { + if (error) goto done; + + /* + * On a complex filename, see if the filesystem allow us to write + * core dumps there. + */ + if (lastslash) { + char c[2]; + + if (lastslash - name >= MAXPATHLEN - 2) { + error = EPERM; + goto done; + } + + c[0] = lastslash[1]; + c[1] = lastslash[2]; + lastslash[1] = '.'; + lastslash[2] = '\0'; + error = namei_simple_kernel(name, NSM_NOFOLLOW_NOEMULROOT, &vp); + if (error) + goto done; + if (vp->v_mount == NULL || + (vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0) + error = EPERM; + vrele(vp); + if (error) + goto done; + lastslash[1] = c[0]; + lastslash[2] = c[1]; } pb = pathbuf_create(name); Index: kern_exec.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_exec.c,v retrieving revision 1.329 diff -u -u -r1.329 kern_exec.c --- kern_exec.c 16 Sep 2011 21:02:28 -0000 1.329 +++ kern_exec.c 22 Sep 2011 23:48:29 -0000 @@ -955,7 +955,7 @@ */ if (pathstring[0] == '/') (void)strlcpy(pack.ep_path = dp, pathstring, MAXPATHLEN); -#ifdef notyet +#ifndef notyet /* * Although this works most of the time [since the entry was just * entered in the cache] we don't use it because it theoretically @@ -967,7 +967,7 @@ pack.ep_path = dp; #endif else { -#ifdef notyet +#ifndef notyet printf("Cannot get path for pid %d [%s] (error %d)", (int)p->p_pid, p->p_comm, error); #endif Index: subr_autoconf.c =================================================================== RCS file: /cvsroot/src/sys/kern/subr_autoconf.c,v retrieving revision 1.220 diff -u -u -r1.220 subr_autoconf.c --- subr_autoconf.c 31 Aug 2011 18:31:02 -0000 1.220 +++ subr_autoconf.c 22 Sep 2011 23:48:30 -0000 @@ -1332,7 +1332,7 @@ dev = kmem_zalloc(sizeof(*dev), KM_SLEEP); } else { dev = dev_private; -#ifdef DIAGNOSTIC +#if 1 printf("%s has not been converted to device_t\n", cd->cd_name); #endif } Index: tty.c =================================================================== RCS file: /cvsroot/src/sys/kern/tty.c,v retrieving revision 1.246 diff -u -u -r1.246 tty.c --- tty.c 26 Jul 2011 13:14:18 -0000 1.246 +++ tty.c 22 Sep 2011 23:48:32 -0000 @@ -91,6 +91,7 @@ #include #include #include +#include static int ttnread(struct tty *); static void ttyblock(struct tty *); @@ -207,12 +208,47 @@ static kauth_listener_t tty_listener; -static struct sysctllog *kern_tkstat_sysctllog; +#define TTY_MINQSIZE 0x00400 +#define TTY_MAXQSIZE 0x10000 +int tty_qsize = TTY_MINQSIZE; + +static int +tty_set_qsize(int *qsize, int newsize) +{ + newsize = 1 << ilog2(newsize); /* Make it a power of two */ + + if (newsize < TTY_MINQSIZE || newsize > TTY_MAXQSIZE) + return EINVAL; + + *qsize = newsize; + return 0; +} + +static int +sysctl_kern_tty_qsize(SYSCTLFN_ARGS) +{ + int newsize; + int error; + struct sysctlnode node; + node = *rnode; + node.sysctl_data = &newsize; + + newsize = tty_qsize; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + + + return tty_set_qsize(&tty_qsize, newsize); +} static void -sysctl_kern_tkstat_setup(void) +sysctl_kern_tty_setup(void) { + const struct sysctlnode *rnode, *cnode; + struct sysctllog *kern_tkstat_sysctllog, *kern_tty_sysctllog; + kern_tkstat_sysctllog = NULL; sysctl_createv(&kern_tkstat_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "kern", NULL, @@ -250,6 +286,19 @@ SYSCTL_DESCR("Number of raw tty input characters"), NULL, 0, &tk_rawcc, 0, CTL_KERN, KERN_TKSTAT, KERN_TKSTAT_RAWCC, CTL_EOL); + + kern_tty_sysctllog = NULL; + sysctl_createv(&kern_tty_sysctllog, 0, NULL, &rnode, + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "tty", NULL, + NULL, 0, NULL, 0, + CTL_KERN, CTL_CREATE, CTL_EOL); + sysctl_createv(&kern_tty_sysctllog, 0, &rnode, &cnode, + CTLFLAG_PERMANENT | CTLFLAG_READWRITE, + CTLTYPE_INT, "qsize", + SYSCTL_DESCR("TTY input and output queue size"), + sysctl_kern_tty_qsize, 0, &tty_qsize, 0, + CTL_CREATE, CTL_EOL); } int @@ -974,6 +1023,9 @@ case TIOCGWINSZ: /* get window size */ *(struct winsize *)data = tp->t_winsize; break; + case TIOCGQSIZE: + *(int *)data = tp->t_qsize; + break; case FIOGETOWN: mutex_enter(proc_lock); if (tp->t_session != NULL && !isctty(p, tp)) { @@ -1262,6 +1314,21 @@ } mutex_spin_exit(&tty_lock); break; + case TIOCSQSIZE: + mutex_spin_enter(&tty_lock); + if ((error = tty_set_qsize(&s, *(int *)data)) == 0 && + s != tp->t_qsize) { + tp->t_qsize = s; + clfree(&tp->t_rawq); + clfree(&tp->t_canq); + clfree(&tp->t_outq); + clalloc(&tp->t_rawq, tp->t_qsize, 1); + clalloc(&tp->t_canq, tp->t_qsize, 1); + clalloc(&tp->t_outq, tp->t_qsize, 0); + } + mutex_spin_exit(&tty_lock); + return error; + default: /* We may have to load the compat module for this. */ for (;;) { @@ -2694,15 +2761,15 @@ tp = kmem_zalloc(sizeof(*tp), KM_SLEEP); callout_init(&tp->t_rstrt_ch, 0); callout_setfunc(&tp->t_rstrt_ch, ttrstrt, tp); - /* XXX: default to 1024 chars for now */ - clalloc(&tp->t_rawq, 1024, 1); + tp->t_qsize = tty_qsize; + clalloc(&tp->t_rawq, tp->t_qsize, 1); cv_init(&tp->t_rawcv, "ttyraw"); cv_init(&tp->t_rawcvf, "ttyrawf"); - clalloc(&tp->t_canq, 1024, 1); + clalloc(&tp->t_canq, tp->t_qsize, 1); cv_init(&tp->t_cancv, "ttycan"); cv_init(&tp->t_cancvf, "ttycanf"); /* output queue doesn't need quoting */ - clalloc(&tp->t_outq, 1024, 0); + clalloc(&tp->t_outq, tp->t_qsize, 0); cv_init(&tp->t_outcv, "ttyout"); cv_init(&tp->t_outcvf, "ttyoutf"); /* Set default line discipline. */ @@ -2817,7 +2884,7 @@ tty_listener = kauth_listen_scope(KAUTH_SCOPE_DEVICE, tty_listener_cb, NULL); - sysctl_kern_tkstat_setup(); + sysctl_kern_tty_setup(); } /* Index: vfs_mount.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_mount.c,v retrieving revision 1.9 diff -u -u -r1.9 vfs_mount.c --- vfs_mount.c 1 Sep 2011 12:29:41 -0000 1.9 +++ vfs_mount.c 22 Sep 2011 23:48:32 -0000 @@ -89,6 +89,8 @@ #include #include +#include + #include #include #include @@ -1016,6 +1018,14 @@ return; } +#if defined(_KERNEL) && !defined(_RUMPKERNEL) + /* + * We need to turn off swap first before we unmount + * /dev, because otherwise the spec_vnodes are bad. + */ + uvm_swap_shutdown(l); +#endif + /* Unmount file systems. */ vfs_unmountall(l); }