cat-v (mirror)
Sys - System Interface
Sys: module
{
PATH: con "$Sys";
SELF: con "$self";
# Details on exception
#
Exception: adt
{
name: string;
mod: string;
value: ref any;
pc: int;
};
# Parameters to exception handlers
#
HANDLER,
EXCEPTION,
ACTIVE,
RAISE,
EXIT,
ONCE: con iota;
# Unique file identifier for file objects
#
Qid: adt
{
path: int;
spath: int;
vers: int;
qtype: int;
};
# Return from stat and directory read
#
Dir: adt
{
name: string;
uid: string;
gid: string;
qid: Qid;
mode: int;
atime: int;
mtime: int;
length: int;
hlength:int;
dtype: int;
dev: int;
};
# File descriptor
#
FD: protected adt
{
fd: int;
};
# Network connection returned by dial
#
Connection: adt
{
dfd: ref FD;
cfd: ref FD;
dir: string;
};
# File IO structures returned from file2chan
# read: (offset, bytes, fid, chan)
# write: (offset, data, fid, chan)
#
Rread: type chan of (array of byte, string);
Rwrite: type chan of (int, string);
Tread: type chan of (int, int, int, Rread);
Twrite: type chan of (int, array of byte, int, Rwrite);
FileIO: adt
{
read: Tread;
write: Twrite;
};
# Maximum read which will be completed atomically;
# also the optimum block size
#
ATOMICIO: con 8192;
# Legacy name length
#
NAMELEN: con 28;
SEEKSTART: con 0;
SEEKRELA: con 1;
SEEKEND: con 2;
ERRLEN: con 64;
WAITLEN: con ERRLEN;
OREAD: con 0;
OWRITE: con 1;
ORDWR: con 2;
OTRUNC: con 16;
ORCLOSE: con 64;
CHDIR: con int 16r80000000;
# bits in Qid.qtype
#
QTDIR: con 16r80; # type bit for directories
QTAPPEND: con 16r40; # type bit for append only files
QTEXCL: con 16r20; # type bit for exclusive use files
QTMOUNT: con 16r10; # type bit for mounted channel
QTAUTH: con 16r08; # type bit for authentication file
QTTMP: con 16r04; # type bit for not-backed-up file
QTFILE: con 16r00; # plain file
# bits in Dir.mode
#
DMDIR: con 16r80000000; # mode bit for directories
DMAPPEND: con 16r40000000; # mode bit for append only files
DMEXCL: con 16r20000000; # mode bit for exclusive use files
DMMOUNT: con 16r10000000; # mode bit for mounted channel
DMAUTH: con 16r08000000; # mode bit for authentication file
DMTMP: con 16r04000000; # mode bit for non-backed-up files
DMREAD: con 16r4; # mode bit for read permission
DMWRITE: con 16r2; # mode bit for write permission
DMEXEC: con 16r1; # mode bit for execute permission
# flags for mount/bind
#
MREPL: con 0;
MBEFORE: con 1;
MAFTER: con 2;
MCREATE: con 4;
# flags for pctl
#
NEWFD,
FORKFD,
NEWNS,
FORKNS,
NEWPGRP,
NODEVS,
NEWDATA,
NODATA: con 1 << iota;
# flags for export
#
EXPWAIT: con 0;
EXPASYNC: con 1;
UTFmax: con 3;
UTFerror: con 16r80;
announce: fn(addr: string): (int, Connection);
aprint: fn(s: string, *): array of byte;
bind: fn(s, on: string, flags: int): int;
chdir: fn(path: string): int;
create: fn(s: string, mode, perm: int): ref FD;
dial: fn(addr, local: string): (int, Connection);
dirread: fn(fd: ref FD, dir: array of Dir): int;
dup: fn(old, new: int): int;
export: fn(c: ref FD, flag: int): int;
fd2path: fn(fd: ref FD): string;
fildes: fn(fd: int): ref FD;
file2chan: fn(dir, file: string): ref FileIO;
fileop: fn(fd: ref FD, req: array of byte): array of byte;
fprint: fn(fd: ref FD, s: string, *): int;
fstat: fn(fd: ref FD): (int, Dir);
fwstat: fn(fd: ref FD, d: Dir): int;
listen: fn(c: Connection): (int, Connection);
millisec: fn(): int;
mount: fn(fd: ref FD, on: string, flags: int, spec: string): int;
open: fn(s: string, mode: int): ref FD;
pctl: fn(flags: int, movefd: list of int): int;
pipe: fn(fds: array of ref FD): int;
pread: fn(fd: ref FD, buf: array of byte, n: int, off: big): int;
print: fn(s: string, *): int;
pwrite: fn(fd: ref FD, buf: array of byte, n: int, off: big): int;
raise: fn(s: string);
raisev: fn(s: string, v: ref any);
rescue: fn(s: string, e: ref Exception): int;
rescued: fn(flag: int, s: string): int;
read: fn(fd: ref FD, buf: array of byte, n: int): int;
readn: fn(fd: ref FD, buf: array of byte, n: int): int;
remove: fn(s: string): int;
seek: fn(fd: ref FD, off: big, start: int): big;
sleep: fn(ms: int): int;
sprint: fn(s: string, *): string;
stat: fn(s: string): (int, Dir);
stream: fn(src, dst: ref FD, bufsiz: int): int;
unmount: fn(s1: string, s2: string): int;
write: fn(fd: ref FD, buf: array of byte, n: int): int;
wstat: fn(s: string, d: Dir): int;
};
{
PATH: con "$Sys";
SELF: con "$self";
# Details on exception
#
Exception: adt
{
name: string;
mod: string;
value: ref any;
pc: int;
};
# Parameters to exception handlers
#
HANDLER,
EXCEPTION,
ACTIVE,
RAISE,
EXIT,
ONCE: con iota;
# Unique file identifier for file objects
#
Qid: adt
{
path: int;
spath: int;
vers: int;
qtype: int;
};
# Return from stat and directory read
#
Dir: adt
{
name: string;
uid: string;
gid: string;
qid: Qid;
mode: int;
atime: int;
mtime: int;
length: int;
hlength:int;
dtype: int;
dev: int;
};
# File descriptor
#
FD: protected adt
{
fd: int;
};
# Network connection returned by dial
#
Connection: adt
{
dfd: ref FD;
cfd: ref FD;
dir: string;
};
# File IO structures returned from file2chan
# read: (offset, bytes, fid, chan)
# write: (offset, data, fid, chan)
#
Rread: type chan of (array of byte, string);
Rwrite: type chan of (int, string);
Tread: type chan of (int, int, int, Rread);
Twrite: type chan of (int, array of byte, int, Rwrite);
FileIO: adt
{
read: Tread;
write: Twrite;
};
# Maximum read which will be completed atomically;
# also the optimum block size
#
ATOMICIO: con 8192;
# Legacy name length
#
NAMELEN: con 28;
SEEKSTART: con 0;
SEEKRELA: con 1;
SEEKEND: con 2;
ERRLEN: con 64;
WAITLEN: con ERRLEN;
OREAD: con 0;
OWRITE: con 1;
ORDWR: con 2;
OTRUNC: con 16;
ORCLOSE: con 64;
CHDIR: con int 16r80000000;
# bits in Qid.qtype
#
QTDIR: con 16r80; # type bit for directories
QTAPPEND: con 16r40; # type bit for append only files
QTEXCL: con 16r20; # type bit for exclusive use files
QTMOUNT: con 16r10; # type bit for mounted channel
QTAUTH: con 16r08; # type bit for authentication file
QTTMP: con 16r04; # type bit for not-backed-up file
QTFILE: con 16r00; # plain file
# bits in Dir.mode
#
DMDIR: con 16r80000000; # mode bit for directories
DMAPPEND: con 16r40000000; # mode bit for append only files
DMEXCL: con 16r20000000; # mode bit for exclusive use files
DMMOUNT: con 16r10000000; # mode bit for mounted channel
DMAUTH: con 16r08000000; # mode bit for authentication file
DMTMP: con 16r04000000; # mode bit for non-backed-up files
DMREAD: con 16r4; # mode bit for read permission
DMWRITE: con 16r2; # mode bit for write permission
DMEXEC: con 16r1; # mode bit for execute permission
# flags for mount/bind
#
MREPL: con 0;
MBEFORE: con 1;
MAFTER: con 2;
MCREATE: con 4;
# flags for pctl
#
NEWFD,
FORKFD,
NEWNS,
FORKNS,
NEWPGRP,
NODEVS,
NEWDATA,
NODATA: con 1 << iota;
# flags for export
#
EXPWAIT: con 0;
EXPASYNC: con 1;
UTFmax: con 3;
UTFerror: con 16r80;
announce: fn(addr: string): (int, Connection);
aprint: fn(s: string, *): array of byte;
bind: fn(s, on: string, flags: int): int;
chdir: fn(path: string): int;
create: fn(s: string, mode, perm: int): ref FD;
dial: fn(addr, local: string): (int, Connection);
dirread: fn(fd: ref FD, dir: array of Dir): int;
dup: fn(old, new: int): int;
export: fn(c: ref FD, flag: int): int;
fd2path: fn(fd: ref FD): string;
fildes: fn(fd: int): ref FD;
file2chan: fn(dir, file: string): ref FileIO;
fileop: fn(fd: ref FD, req: array of byte): array of byte;
fprint: fn(fd: ref FD, s: string, *): int;
fstat: fn(fd: ref FD): (int, Dir);
fwstat: fn(fd: ref FD, d: Dir): int;
listen: fn(c: Connection): (int, Connection);
millisec: fn(): int;
mount: fn(fd: ref FD, on: string, flags: int, spec: string): int;
open: fn(s: string, mode: int): ref FD;
pctl: fn(flags: int, movefd: list of int): int;
pipe: fn(fds: array of ref FD): int;
pread: fn(fd: ref FD, buf: array of byte, n: int, off: big): int;
print: fn(s: string, *): int;
pwrite: fn(fd: ref FD, buf: array of byte, n: int, off: big): int;
raise: fn(s: string);
raisev: fn(s: string, v: ref any);
rescue: fn(s: string, e: ref Exception): int;
rescued: fn(flag: int, s: string): int;
read: fn(fd: ref FD, buf: array of byte, n: int): int;
readn: fn(fd: ref FD, buf: array of byte, n: int): int;
remove: fn(s: string): int;
seek: fn(fd: ref FD, off: big, start: int): big;
sleep: fn(ms: int): int;
sprint: fn(s: string, *): string;
stat: fn(s: string): (int, Dir);
stream: fn(src, dst: ref FD, bufsiz: int): int;
unmount: fn(s1: string, s2: string): int;
write: fn(fd: ref FD, buf: array of byte, n: int): int;
wstat: fn(s: string, d: Dir): int;
};