From 96ff5968030ed5c0a4dd2ded3c4e903bcb131e89 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 5 Aug 2004 22:28:58 +0000 Subject: [PATCH] Bucket fastbuf's have to be seekable, since shep-reap seeks on them (although the seek will be inside the buffer [and thence optimized out by bseek()] under all reasonable circumstances [it was triggered by a bug in buck2obj]). --- lib/bucket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/bucket.c b/lib/bucket.c index f81f03e8..57fb83f4 100644 --- a/lib/bucket.c +++ b/lib/bucket.c @@ -183,6 +183,16 @@ obuck_fb_refill(struct fastbuf *f) return datasize; } +static void +obuck_fb_seek(struct fastbuf *f, sh_off_t pos, int whence) +{ + ASSERT(whence == SEEK_SET || whence == SEEK_END); + if (whence == SEEK_END) + pos += FB_BUCKET(f)->bucket_size; + ASSERT(pos >= 0 && pos <= FB_BUCKET(f)->bucket_size); + f->pos = pos; +} + static void obuck_fb_spout(struct fastbuf *f) { @@ -316,7 +326,7 @@ obuck_fetch(void) b->pos = 0; b->refill = obuck_fb_refill; b->spout = NULL; - b->seek = NULL; + b->seek = obuck_fb_seek; b->close = obuck_fb_close; b->config = NULL; b->can_overwrite_buffer = 2; -- 2.39.2