All contributions in this site reflect the authors' opinions and they are not necessarily endorsed by, or reflect the beliefs of, anarchyinthetubes, as neither do most of the opinions in other sites.

cat-v (mirror)

Sys - System Interface

Sysmodule
{
        PATH:   con     "$Sys";
        SELF:   con     "$self";

        # Details on exception
        #
        Exceptionadt
        {
                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
        #
        Qidadt
        {
                path:   int;
                spath:  int;
                vers:   int;
                qtype:  int;
        };

        # Return from stat and directory read
        #
        Diradt
        {
                name:   string;
                uid:    string;
                gid:    string;
                qid:    Qid;
                mode:   int;
                atime:  int;
                mtime:  int;
                lengthint;
                hlength:int;
                dtype:  int;
                dev:    int;
        };

        # File descriptor
        #
        FDprotected adt
        {
                fd:     int;
        };

        # Network connection returned by dial
        #
        Connectionadt
        {
                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 bytestring);
        Rwritetype chan of (intstring);
        Tread:  type chan of (intintintRread);
        Twritetype chan of (intarray of byteintRwrite);
        FileIOadt
        {
                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(addrstring): (intConnection);
        aprint:         fn(sstring, *): array of byte;
        bind:           fn(sonstringflagsint): int;
        chdir:          fn(pathstring): int;
        create:         fn(sstringmodepermint): ref FD;
        dial:           fn(addrlocalstring): (intConnection);
        dirread:        fn(fdref FDdirarray of Dir): int;
        dup:            fn(oldnewint): int;
        export:         fn(cref FDflagint): int;
        fd2path:        fn(fdref FD): string;
        fildes:         fn(fdint): ref FD;
        file2chan:      fn(dirfilestring): ref FileIO;
        fileop:         fn(fdref FDreqarray of byte): array of byte;
        fprint:         fn(fdref FDsstring, *): int;
        fstat:          fn(fdref FD): (intDir);
        fwstat:         fn(fdref FDdDir): int;
        listen:         fn(cConnection): (intConnection);
        millisec:       fn(): int;
        mount:          fn(fdref FDonstringflagsintspecstring): int;
        open:           fn(sstringmodeint): ref FD;
        pctl:           fn(flagsintmovefdlist of int): int;
        pipe:           fn(fdsarray of ref FD): int;
        pread:          fn(fdref FDbufarray of bytenintoffbig): int;
        print:          fn(sstring, *): int;
        pwrite:         fn(fdref FDbufarray of bytenintoffbig): int;
        raise:          fn(sstring);
        raisev:         fn(sstringvref any);
        rescue:         fn(sstringeref Exception): int;
        rescued:        fn(flagintsstring): int;
        read:           fn(fdref FDbufarray of bytenint): int;
        readn:          fn(fdref FDbufarray of bytenint): int;
        remove:         fn(sstring): int;
        seek:           fn(fdref FDoffbigstartint): big;
        sleep:          fn(msint): int;
        sprint:         fn(sstring, *): string;
        stat:           fn(sstring): (intDir);
        stream:         fn(srcdstref FDbufsizint): int;
        unmount:        fn(s1strings2string): int;
        write:          fn(fdref FDbufarray of bytenint): int;
        wstat:          fn(sstringdDir): int;
};
original page
cat.4l77.com