From c1279231353571a21ae697b320c9f564a65cde6a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 11 Nov 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-11-11 --- port/devcons.c | 22 +++++++++------------- port/sysfile.c | 6 ++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/port/devcons.c b/port/devcons.c index a53778d77dad191bbfd911a645c82b18f0976d1f..88a71ec71c7ca12b78da0fb13975cd18d7bb8885 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -13,9 +13,9 @@ void (*serialputs)(char*, int) = nil; Queue* kbdq; /* unprocessed console input */ Queue* lineq; /* processed console input */ -Queue* serialoq; /* serial console output */ -Queue* kprintoq; /* console output, for /dev/kprint */ -Lock kprintinuse; /* test and set whether /dev/kprint is open */ +Queue* serialoq; /* serial console output */ +Queue* kprintoq; /* console output, for /dev/kprint */ +Lock kprintinuse; /* test and set whether /dev/kprint is open */ static struct { @@ -35,7 +35,11 @@ static struct char *iw; char *ir; char *ie; -} kbd; +} kbd = { + .iw = kbd.istage, + .ir = kbd.istage, + .ie = kbd.istage + sizeof(kbd.istage), +}; char *sysname; vlong fasthz; @@ -492,14 +496,6 @@ kbdputcclock(void) } } -static void -kbdputcinit(void) -{ - kbd.ir = kbd.iw = kbd.istage; - kbd.ie = kbd.istage + sizeof(kbd.istage); - addclock0link(kbdputcclock); -} - enum{ Qdir, Qbintime, @@ -589,7 +585,7 @@ consinit(void) { todinit(); randominit(); - kbdputcinit(); + addclock0link(kbdputcclock); } static Chan* diff --git a/port/sysfile.c b/port/sysfile.c index fc7463fc31df9ac6cc01123424d3292c7c92880a..4bb23ca9da7603752ce386f826a8a15c36116414 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -530,6 +530,8 @@ sseek(ulong *arg) off = o.v; if((c->qid.type & QTDIR) && off != 0) error(Eisdir); + if(off < 0) + error(Enegoff); c->offset = off; break; @@ -538,6 +540,8 @@ sseek(ulong *arg) error(Eisdir); lock(c); /* lock for read/write update */ off = o.v + c->offset; + if(off < 0) + error(Enegoff); c->offset = off; unlock(c); break; @@ -549,6 +553,8 @@ sseek(ulong *arg) if(convM2D(buf, n, &dir, nil) == 0) error("internal error: stat error in seek"); off = dir.length + o.v; + if(off < 0) + error(Enegoff); c->offset = off; break;