svn commit: r205470 - stable/6/sys/fs/fdescfs
Jung-uk Kim
jkim at FreeBSD.org
Mon Mar 22 20:52:53 UTC 2010
Author: jkim
Date: Mon Mar 22 20:52:52 2010
New Revision: 205470
URL: http://svn.freebsd.org/changeset/base/205470
Log:
MFC: r205223
Fix a long standing regression of readdir(3) in fdescfs(5) introduced
in r1.48. We were stopping at the first null pointer when multiple file
descriptors were opened and one in the middle was closed. This restores
traditional behaviour of fdescfs.
Modified:
stable/6/sys/fs/fdescfs/fdesc_vnops.c
Directory Properties:
stable/6/sys/ (props changed)
stable/6/sys/contrib/pf/ (props changed)
stable/6/sys/dev/cxgb/ (props changed)
Modified: stable/6/sys/fs/fdescfs/fdesc_vnops.c
==============================================================================
--- stable/6/sys/fs/fdescfs/fdesc_vnops.c Mon Mar 22 20:41:44 2010 (r205469)
+++ stable/6/sys/fs/fdescfs/fdesc_vnops.c Mon Mar 22 20:52:52 2010 (r205470)
@@ -440,11 +440,10 @@ fdesc_readdir(ap)
FILEDESC_LOCK_FAST(fdp);
while (i < fdp->fd_nfiles + 2 && uio->uio_resid >= UIO_MX) {
+ bzero((caddr_t)dp, UIO_MX);
switch (i) {
case 0: /* `.' */
case 1: /* `..' */
- bzero((caddr_t)dp, UIO_MX);
-
dp->d_fileno = i + FD_ROOT;
dp->d_namlen = i + 1;
dp->d_reclen = UIO_MX;
@@ -453,26 +452,24 @@ fdesc_readdir(ap)
dp->d_type = DT_DIR;
break;
default:
- if (fdp->fd_ofiles[fcnt] == NULL) {
- FILEDESC_UNLOCK_FAST(fdp);
- goto done;
- }
-
- bzero((caddr_t) dp, UIO_MX);
+ if (fdp->fd_ofiles[fcnt] == NULL)
+ break;
dp->d_namlen = sprintf(dp->d_name, "%d", fcnt);
dp->d_reclen = UIO_MX;
dp->d_type = DT_UNKNOWN;
dp->d_fileno = i + FD_DESC;
break;
}
- /*
- * And ship to userland
- */
- FILEDESC_UNLOCK_FAST(fdp);
- error = uiomove(dp, UIO_MX, uio);
- if (error)
- goto done;
- FILEDESC_LOCK_FAST(fdp);
+ if (dp->d_namlen != 0) {
+ /*
+ * And ship to userland
+ */
+ FILEDESC_UNLOCK_FAST(fdp);
+ error = uiomove(dp, UIO_MX, uio);
+ if (error)
+ goto done;
+ FILEDESC_LOCK_FAST(fdp);
+ }
i++;
fcnt++;
}
More information about the svn-src-stable-6
mailing list