ref: 219d341ef88f0e36804bc12a9aa555c07c8e2498
parent: 164e81c696b9d564aac7661687cbf35ea7cabd15
author: 9ferno <[email protected]>
date: Tue Aug 31 16:08:42 EDT 2021
added halt to kfs64
--- a/appl/cmd/disk/kfs64.b
+++ b/appl/cmd/disk/kfs64.b
@@ -543,12 +543,13 @@
if(pid)
pids = pid :: pids;
}
- spawn consinit(c);
+ cmdchan := chan of int;
+ spawn consinit(c, cmdchan);
pid := <- c;
if(pid)
pids = pid :: pids;
- spawn kfs(sys->fildes(0));
+ spawn kfs(sys->fildes(0), cmdchan);
}
error(s: string)
@@ -672,7 +673,7 @@
rc: chan of (array of byte, string);
};
-consinit(c: chan of int)
+consinit(c: chan of int, cmdchan: chan of int)
{
kattach(FID1);
userinit();
@@ -763,6 +764,9 @@
"allowoff" or "disallow" =>
wstatallow = writeallow = 0;
wc <-= (len data, nil);
+ "halt" =>
+ cmdchan <-= 0;
+ wc <-= (len data, nil);
* =>
wc <-= (0, "unknown kfs request");
continue;
@@ -804,26 +808,53 @@
#
# normal kfs service
#
-kfs(rfd: ref Sys->FD)
+kfs(rfd: ref Sys->FD, cmdchan: chan of int)
{
cp := Chan.new(rfd);
- while((t := Tmsg.read(rfd, cp.msize)) != nil){
- if(debug)
- sys->print("<- %s\n", t.text());
- r := apply(cp, t);
- pick m := r {
- Error =>
- r.tag = t.tag;
+ tmsgchan := chan of ref Tmsg;
+ msizechan := chan of int;
+ spawn tmsgreader(rfd, tmsgchan, msizechan);
+ msizechan <- = cp.msize;
+ loop: for(;;)
+ alt
+ {
+ <- cmdchan => break loop;
+ t := <- tmsgchan =>
+ {
+ if(t == nil)
+ break loop;
+ else{
+ if(debug)
+ sys->print("<- %s\n", t.text());
+ r := apply(cp, t);
+ pick m := r {
+ Error =>
+ r.tag = t.tag;
+ }
+ if(debug)
+ sys->print("-> %s\n", r.text());
+ rbuf := r.pack();
+ if(rbuf == nil)
+ panic("Rmsg.pack");
+ if(sys->write(rfd, rbuf, len rbuf) != len rbuf)
+ panic("mount write");
+ }
+ msizechan <- = cp.msize;
}
- if(debug)
- sys->print("-> %s\n", r.text());
- rbuf := r.pack();
- if(rbuf == nil)
- panic("Rmsg.pack");
- if(sys->write(rfd, rbuf, len rbuf) != len rbuf)
- panic("mount write");
}
shutdown();
+}
+tmsgreader(rfd: ref Sys->FD, tmsgchan: chan of ref Tmsg, msizechan: chan of int)
+{
+ msize := <- msizechan;
+ while((t := Tmsg.read(rfd, msize)) != nil){
+ if(debug)
+ sys->print("<- %s\n", t.text());
+ tmsgchan <- = t;
+ msize = <- msizechan;
+ t = nil;
+ }
+ tmsgchan <- = t;
}
apply(cp: ref Chan, t: ref Tmsg): ref Rmsg