From owner-p4-projects@FreeBSD.ORG Sun Oct 16 13:17:31 2005 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 7EFE316A423; Sun, 16 Oct 2005 13:17:30 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 19D1016A41F for ; Sun, 16 Oct 2005 13:17:30 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F43C43D67 for ; Sun, 16 Oct 2005 13:17:26 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j9GDHPcZ062278 for ; Sun, 16 Oct 2005 13:17:25 GMT (envelope-from soc-chenk@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9GDHPJp062275 for perforce@freebsd.org; Sun, 16 Oct 2005 13:17:25 GMT (envelope-from soc-chenk@freebsd.org) Date: Sun, 16 Oct 2005 13:17:25 GMT Message-Id: <200510161317.j9GDHPJp062275@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-chenk@freebsd.org using -f From: soc-chenk To: Perforce Change Reviews Cc: Subject: PERFORCE change 85366 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: Sun, 16 Oct 2005 13:17:32 -0000 http://perforce.freebsd.org/chv.cgi?CH=85366 Change 85366 by soc-chenk@soc-chenk_leavemealone on 2005/10/16 13:16:25 fix filehandle leak of readdir Submitted by: soc-chenk Affected files ... .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#19 edit Differences ... ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#19 (text+ko) ==== @@ -3601,9 +3601,9 @@ struct thread *td = curthread; int err = 0; struct fuse_iov cookediov; + struct fuse_filehandle *fufh; #if DIRECTIO_FOR_DIRS struct filedesc *fdp = td->td_proc->p_fd; - struct fuse_filehandle *fufh; struct file **fpp; struct file *fp = NULL; int found = -1; @@ -3653,6 +3653,12 @@ fufh = fp->f_data; #endif +#if ! DIRECTIO_FOR_DIRS + if ( ! (fufh = get_filehandle(vp, td, cred, FREAD))) { + DEBUG2G("fetching filehandle failed\n"); + return (EIO); + } +#endif /* * In "most cases" this will do and won't have to resize the buffer * (that is, if the daemon has a "tight" view of the dir entries, @@ -3662,20 +3668,18 @@ * (See fuse_dir_buffeater). */ fuse_iov_init(&cookediov, DIRCOOKEDSIZE); -#if DIRECTIO_FOR_DIRS - err = fuse_read_directbackend(vp, fufh, uio, cred, td, FUSE_READDIR, - fuse_dir_buffeater, &cookediov); -#else /* * We tried hard to use bio, but offsety readdir can't be handled * properly that way -- the offset field of fuse_dirents can't be * mapped to an offset of a bio buffer */ - err = fuse_read_directbackend(vp, get_filehandle(vp, td, cred, FREAD), - uio, cred, td, FUSE_READDIR, + err = fuse_read_directbackend(vp, fufh, uio, cred, td, FUSE_READDIR, fuse_dir_buffeater, &cookediov); + fuse_iov_teardown(&cookediov); +#if ! DIRECTIO_FOR_DIRS + fufh->useco--; #endif - fuse_iov_teardown(&cookediov); + return (err); }