summaryrefslogtreecommitdiff
path: root/appl/lib/memfs.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/lib/memfs.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/lib/memfs.b')
-rw-r--r--appl/lib/memfs.b46
1 files changed, 46 insertions, 0 deletions
diff --git a/appl/lib/memfs.b b/appl/lib/memfs.b
new file mode 100644
index 00000000..4ffc7b65
--- /dev/null
+++ b/appl/lib/memfs.b
@@ -0,0 +1,46 @@
+# To be removed...
+# functionality has been moved to appl/cmd/memfs.b
+# some progs still refer to lib/memfs so it remains for the time being
+
+implement MemFS;
+
+include "sys.m";
+ sys: Sys;
+include "draw.m";
+include "memfs.m";
+
+Cmd: module {
+ PATH: con "/dis/memfs.dis";
+ init: fn(ctxt: ref Draw->Context, argv: list of string);
+};
+
+cmd: Cmd;
+
+init(): string
+{
+ sys = load Sys Sys->PATH;
+ cmd = load Cmd Cmd->PATH;
+ if (cmd == nil)
+ return sys->sprint("lib/memfs cannot load %s: %r\n", Cmd->PATH);
+ return nil;
+}
+
+newfs(maxsz: int): ref Sys->FD
+{
+ p := array [2] of ref Sys->FD;
+ if (sys->pipe(p) == -1)
+ return nil;
+ sync := chan of int;
+ spawn run(p[1].fd, maxsz, sync);
+ <- sync;
+ return p[0];
+}
+
+run(fd: int, sz: int, sync: chan of int)
+{
+ sys->pctl(Sys->FORKFD, nil);
+ sys->dup(fd, 0);
+ sys->pctl(Sys->NEWFD, 0::1::2::nil);
+ sync <-= 1;
+ cmd->init(nil, Cmd->PATH :: "-s" :: "-m" :: string sz :: nil);
+}