From 1b8fb837529e67dfc11b6fb55d32bb74b6cd13b1 Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 5 Nov 2013 09:36:05 +0000 Subject: 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 . ok guenther@ deraadt@ --- lib/libc/gen/telldir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3-59-g8ed1b