summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2013-11-05 09:36:05 +0000
committerschwarze <schwarze@openbsd.org>2013-11-05 09:36:05 +0000
commit1b8fb837529e67dfc11b6fb55d32bb74b6cd13b1 (patch)
tree51bd41dbd0d03fd1daaae25aa7c5dc2cbbe615fc
parentFix RAID levels 0, 4, 5, and 6 with partitions larger than 2TB. (diff)
downloadwireguard-openbsd-1b8fb837529e67dfc11b6fb55d32bb74b6cd13b1.tar.xz
wireguard-openbsd-1b8fb837529e67dfc11b6fb55d32bb74b6cd13b1.zip
Make sure seekdir(3) works even when dirp->dd_buf still contains some
pending entries: At the time of the lseek(2), also invalidate the buffer in order to force getdents(2) during the next readdir(3). Because this throws away buffered data that could still be used in some cases, this is not particularly efficient, but at least it works; i will suggest optimizations soon. Bug found when investigating perl-5.18.1/t/op/threads-dirh.t that was reported broken by Andrew Fresh <andrew at afresh1 dot com>. ok guenther@ deraadt@
-rw-r--r--lib/libc/gen/telldir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index af3513a78b4..4791fab008c 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: telldir.c,v 1.15 2013/08/16 05:27:39 guenther Exp $ */
+/* $OpenBSD: telldir.c,v 1.16 2013/11/05 09:36:05 schwarze Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -67,5 +67,6 @@ telldir(DIR *dirp)
void
__seekdir(DIR *dirp, long loc)
{
+ dirp->dd_loc = 0;
dirp->dd_curpos = lseek(dirp->dd_fd, loc, SEEK_SET);
}