summaryrefslogtreecommitdiff
path: root/sys/tmpfs
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-09-22 03:34:32 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-09-22 03:34:32 +0000
commit80824bb7e90babe540bc2ecf300a787259214e88 (patch)
tree2689abc931d350b0117a6fbb8699ee92cb610cbb /sys/tmpfs
parent6cc6d7c6023cf6989560a0f16f8efdc23f911cab (diff)
The readdir vop should set uio_offset to the cookie of the entry
after the last entry that fit, but I had it setting it to the cookier of the entry after that, so it would skip one entry for each block required. Remove the no-longer-needed cnt/cntp variable while we're touching things. prodding and testing by espie@
Diffstat (limited to 'sys/tmpfs')
-rw-r--r--sys/tmpfs/tmpfs.h4
-rw-r--r--sys/tmpfs/tmpfs_subr.c24
-rw-r--r--sys/tmpfs/tmpfs_vnops.c8
3 files changed, 17 insertions, 19 deletions
diff --git a/sys/tmpfs/tmpfs.h b/sys/tmpfs/tmpfs.h
index 0699e9dbda4..6f8736795e7 100644
--- a/sys/tmpfs/tmpfs.h
+++ b/sys/tmpfs/tmpfs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs.h,v 1.3 2013/06/04 09:11:40 espie Exp $ */
+/* $OpenBSD: tmpfs.h,v 1.4 2013/09/22 03:34:31 guenther Exp $ */
/* $NetBSD: tmpfs.h,v 1.45 2011/09/27 01:10:43 christos Exp $ */
/*
@@ -285,7 +285,7 @@ tmpfs_dirent_t *tmpfs_dir_cached(tmpfs_node_t *);
int tmpfs_dir_getdotdent(tmpfs_node_t *, struct uio *);
int tmpfs_dir_getdotdotdent(tmpfs_node_t *, struct uio *);
tmpfs_dirent_t *tmpfs_dir_lookupbycookie(tmpfs_node_t *, off_t);
-int tmpfs_dir_getdents(tmpfs_node_t *, struct uio *, off_t *);
+int tmpfs_dir_getdents(tmpfs_node_t *, struct uio *);
int tmpfs_reg_resize(struct vnode *, off_t);
int tmpfs_truncate(struct vnode *, off_t);
diff --git a/sys/tmpfs/tmpfs_subr.c b/sys/tmpfs/tmpfs_subr.c
index 7c83b81caef..2955dead36c 100644
--- a/sys/tmpfs/tmpfs_subr.c
+++ b/sys/tmpfs/tmpfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_subr.c,v 1.3 2013/09/01 17:02:56 guenther Exp $ */
+/* $OpenBSD: tmpfs_subr.c,v 1.4 2013/09/22 03:34:31 guenther Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $ */
/*
@@ -738,11 +738,11 @@ tmpfs_dir_lookupbycookie(tmpfs_node_t *node, off_t cookie)
* => The read starts at uio->uio_offset.
*/
int
-tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio, off_t *cntp)
+tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio)
{
- tmpfs_dirent_t *de;
+ tmpfs_dirent_t *de, *next_de;
struct dirent *dentp;
- off_t cookie;
+ off_t cookie, next_cookie;
int error;
KASSERT(VOP_ISLOCKED(node->tn_vnode));
@@ -813,12 +813,12 @@ tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio, off_t *cntp)
dentp->d_name[de->td_namelen] = '\0';
dentp->d_reclen = DIRENT_SIZE(dentp);
- de = TAILQ_NEXT(de, td_entries);
- if (de == NULL)
- cookie = TMPFS_DIRCOOKIE_EOF;
+ next_de = TAILQ_NEXT(de, td_entries);
+ if (next_de == NULL)
+ next_cookie = TMPFS_DIRCOOKIE_EOF;
else
- cookie = tmpfs_dircookie(de);
- dentp->d_off = cookie;
+ next_cookie = tmpfs_dircookie(next_de);
+ dentp->d_off = next_cookie;
/* Stop reading if the directory entry we are treating is
* bigger than the amount of data that can be returned. */
@@ -832,8 +832,10 @@ tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio, off_t *cntp)
* advance pointers.
*/
error = uiomove(dentp, dentp->d_reclen, uio);
-
- (*cntp)++;
+ if (error == 0) {
+ de = next_de;
+ cookie = next_cookie;
+ }
} while (error == 0 && uio->uio_resid > 0 && de != NULL);
/* Update the offset and cache. */
diff --git a/sys/tmpfs/tmpfs_vnops.c b/sys/tmpfs/tmpfs_vnops.c
index b8cb5efff38..892e9cd645a 100644
--- a/sys/tmpfs/tmpfs_vnops.c
+++ b/sys/tmpfs/tmpfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_vnops.c,v 1.7 2013/09/01 17:02:56 guenther Exp $ */
+/* $OpenBSD: tmpfs_vnops.c,v 1.8 2013/09/22 03:34:31 guenther Exp $ */
/* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */
/*
@@ -963,7 +963,6 @@ tmpfs_readdir(void *v)
struct vnode *vp = ap->a_vp;
struct uio *uio = ap->a_uio;
int *eofflag = ap->a_eofflag;
- off_t cnt;
tmpfs_node_t *node;
int error;
@@ -974,7 +973,6 @@ tmpfs_readdir(void *v)
return ENOTDIR;
}
node = VP_TO_TMPFS_DIR(vp);
- cnt = 0;
if (node->tn_links == 0) {
error = 0;
goto out;
@@ -987,7 +985,6 @@ tmpfs_readdir(void *v)
error = 0;
goto out;
}
- cnt++;
}
if (uio->uio_offset == TMPFS_DIRCOOKIE_DOTDOT) {
error = tmpfs_dir_getdotdotdent(node, uio);
@@ -996,9 +993,8 @@ tmpfs_readdir(void *v)
error = 0;
goto out;
}
- cnt++;
}
- error = tmpfs_dir_getdents(node, uio, &cnt);
+ error = tmpfs_dir_getdents(node, uio);
if (error == -1) {
error = 0;
}