Plan 9 from Bell Labs’s /usr/web/sources/contrib/nemo/octopus/port/ofs/ofsnotify.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


# Notify the system about a new terminal mounted through ofs.
# This is octopus-specific and might not be of help for a std inferno system.

implement Ofsnotify;

include "sys.m";
	sys: Sys;
	pctl, sprint, fprint: import sys;
include "error.m";
	err: Error;
	checkload, stderr, error: import err;
include "registries.m";
	regs: Registries;
	Service, Registered, Attributes, Registry: import regs;

include "ofsnotify.m";

what: string;
sname: string;
pidreg: ref Registered;

init(w: string)
{
	sys = load Sys Sys->PATH;
	err = load Error Error->PATH;
	err->init();
	regs = checkload(load Registries Registries->PATH, Registries->PATH);
	regs->init();
	what =  "/devs/" + w;
	sname = w;
}

arrived()
{
	reg := Registry.new(nil);
	if (reg == nil){
		fprint(stderr, "ofs: reg: %r");
		return;
	}
	pid := pctl(0, nil);
	a:= Attributes.new(nil);
	a.set("name", "ofs");
	a.set("sys", sname);
	a.set("pid", sprint("%d", pid));
	name := sprint("%s!ofs", sname);
	(r, e) := reg.register(name, a, 0);
	if (e != nil){
		fprint(stderr, "ofs: reg: %r");
		return;
	}
	pidreg = r;
}

gone()
{
	pidreg = nil;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].