From ae76db6206afa100bdbee39669a69dbc77601f5f Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 26 Mar 1996 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1996-03-26 --- port/cache.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/port/cache.c b/port/cache.c index 35c164aff1dc051b340fa91e97ac1b16afb39a39..f9b5f20e0db38125c67378823edad80c9d686308 100644 --- a/port/cache.c +++ b/port/cache.c @@ -498,7 +498,7 @@ cupdate(Chan *c, uchar *buf, int len, ulong offset) void cwrite(Chan* c, uchar *buf, int len, ulong offset) { - int o; + int o, n; Mntcache *m; ulong eblock, ee; Extent *p, *f, *e, *tail; @@ -526,6 +526,26 @@ cwrite(Chan* c, uchar *buf, int len, ulong offset) p = f; } + if(f != 0) { + o = offset - f->start; + if(o >= 0) { + n = f->len - o; + if(n > len) + n = len; + if(n > 0) { + if(cpgmove(f, buf, o, n)) { + buf += n; + len -= n; + offset += n; + } + if(len == 0) { + qunlock(m); + return; + } + } + } + } + if(p != 0) { ee = p->start+p->len; if(ee > offset) {