diff options
author | delphij <delphij@FreeBSD.org> | 2007-08-16 11:00:07 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-08-16 11:00:07 +0000 |
commit | e83de305a6e6423afe873de281186f0d4e9ee0c5 (patch) | |
tree | aa014884c3b0b35871143c76d3c200dbd4116540 /sys | |
parent | 3fef07aaecd5fb8a817cb560b8e9b1c48f19c050 (diff) | |
download | FreeBSD-src-e83de305a6e6423afe873de281186f0d4e9ee0c5.zip FreeBSD-src-e83de305a6e6423afe873de281186f0d4e9ee0c5.tar.gz |
MFp4: rework tmpfs_readdir() logic in terms of correctness.
Approved by: re (tmpfs blanket)
Tested with: fstest, fsx
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/tmpfs/tmpfs_vnops.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 1d38ed9..711c0a6 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1219,22 +1219,25 @@ tmpfs_readdir(struct vop_readdir_args *v) startoff = uio->uio_offset; - switch (startoff) { - case TMPFS_DIRCOOKIE_DOT: + if (uio->uio_offset == TMPFS_DIRCOOKIE_DOT) { error = tmpfs_dir_getdotdent(node, uio); - if (error == 0) - cnt++; - break; - case TMPFS_DIRCOOKIE_DOTDOT: + if (error != 0) + goto outok; + cnt++; + } + + if (uio->uio_offset == TMPFS_DIRCOOKIE_DOTDOT) { error = tmpfs_dir_getdotdotdent(node, uio); - if (error == 0) - cnt++; - break; - default: - error = tmpfs_dir_getdents(node, uio, &cnt); - MPASS(error >= -1); + if (error != 0) + goto outok; + cnt++; } + error = tmpfs_dir_getdents(node, uio, &cnt); + +outok: + MPASS(error >= -1); + if (error == -1) error = 0; |