M port/devcons.c => port/devcons.c +9 -13
@@ 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*
M port/sysfile.c => port/sysfile.c +6 -0
@@ 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;