From 24420ab9eb9124dd2ac032beacd84e4a2f6ddf56 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 30 Apr 2017 01:51:07 +0200 Subject: kernel: fix rewinding in directories with pread() offset reading directories with pread() offset has to work the same way as read(), otherwise exportfs breaks rewinding in directories. --- sys/src/9/port/sysfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/src/9/port/sysfile.c b/sys/src/9/port/sysfile.c index 4a36951c9..ed8e5c7ad 100644 --- a/sys/src/9/port/sysfile.c +++ b/sys/src/9/port/sysfile.c @@ -655,7 +655,7 @@ read(int fd, uchar *p, long n, vlong *offp) error(Enegoff); if(off == 0){ /* rewind to the beginning of the directory */ - if(offp == nil){ + if(offp == nil || (c->qid.type & QTDIR)){ c->offset = 0; c->devoffset = 0; } @@ -677,7 +677,7 @@ read(int fd, uchar *p, long n, vlong *offp) }else nnn = nn = devtab[c->type]->read(c, p, n, off); - if((c->qid.type & QTDIR) || offp == nil){ + if(offp == nil || (c->qid.type & QTDIR)){ lock(c); c->devoffset += nn; c->offset += nnn; -- cgit v1.2.3