PERFORCE change 85366 for review
soc-chenk
soc-chenk at FreeBSD.org
Sun Oct 16 06:17:32 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=85366
Change 85366 by soc-chenk at 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);
}
More information about the p4-projects
mailing list