From owner-p4-projects@FreeBSD.ORG Mon Apr 16 17:49:05 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7352B16A40D; Mon, 16 Apr 2007 17:49:05 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3C36A16A40A for ; Mon, 16 Apr 2007 17:49:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 2B50113C46A for ; Mon, 16 Apr 2007 17:49:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3GHn5iH038445 for ; Mon, 16 Apr 2007 17:49:05 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3GHn4XI038442 for perforce@freebsd.org; Mon, 16 Apr 2007 17:49:04 GMT (envelope-from jhb@freebsd.org) Date: Mon, 16 Apr 2007 17:49:04 GMT Message-Id: <200704161749.l3GHn4XI038442@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 118253 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2007 17:49:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=118253 Change 118253 by jhb@jhb_mutex on 2007/04/16 17:48:17 Use kern_open() to open "/dev/null" in fdcheckstd(). Affected files ... .. //depot/projects/smpng/sys/kern/kern_descrip.c#105 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_descrip.c#105 (text+ko) ==== @@ -1813,11 +1813,9 @@ int fdcheckstd(struct thread *td) { - struct nameidata nd; struct filedesc *fdp; - struct file *fp; - register_t retval; - int fd, i, error, flags, devnull; + register_t retval, save; + int i, error, devnull; fdp = td->td_proc->p_fd; if (fdp == NULL) @@ -1829,48 +1827,14 @@ if (fdp->fd_ofiles[i] != NULL) continue; if (devnull < 0) { - int vfslocked; - error = falloc(td, &fp, &fd); - if (error != 0) - break; - /* Note extra ref on `fp' held for us by falloc(). */ - KASSERT(fd == i, ("oof, we didn't get our fd")); - NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, - "/dev/null", td); - flags = FREAD | FWRITE; - error = vn_open(&nd, &flags, 0, fd); - if (error != 0) { - /* - * Someone may have closed the entry in the - * file descriptor table, so check it hasn't - * changed before dropping the reference - * count. - */ - FILEDESC_XLOCK(fdp); - KASSERT(fdp->fd_ofiles[fd] == fp, - ("table not shared, how did it change?")); - fdp->fd_ofiles[fd] = NULL; - fdunused(fdp, fd); - FILEDESC_XUNLOCK(fdp); - fdrop(fp, td); - fdrop(fp, td); + save = td->td_retval[0]; + error = kern_open(td, "/dev/null", UIO_SYSSPACE, + O_RDWR, 0); + devnull = td->td_retval[0]; + KASSERT(devnull == i, ("oof, we didn't get our fd")); + td->td_retval[0] = save; + if (error) break; - } - vfslocked = NDHASGIANT(&nd); - NDFREE(&nd, NDF_ONLY_PNBUF); - FILE_LOCK(fp); - fp->f_flag = flags; - fp->f_vnode = nd.ni_vp; - if (fp->f_data == NULL) - fp->f_data = nd.ni_vp; - fp->f_type = DTYPE_VNODE; - if (fp->f_ops == &badfileops) - fp->f_ops = &vnops; - FILE_UNLOCK(fp); - VOP_UNLOCK(nd.ni_vp, 0, td); - VFS_UNLOCK_GIANT(vfslocked); - devnull = fd; - fdrop(fp, td); } else { error = do_dup(td, DUP_FIXED, devnull, i, &retval); if (error != 0)