<<>> <> <> <> <> <> <> DIRECTORY Basics USING [RawChars]; UnixTypes: CEDAR DEFINITIONS ~ { < and from whole cloth.>> bitsPerUnitMustBeEight: CARD[8..8] ~ BITS[UNIT]; CHARPtr: TYPE ~ POINTER TO Basics.RawChars ¬ NIL; <> INTPtr: TYPE ~ POINTER TO INT; Flag: TYPE ~ MACHINE DEPENDENT {false(0), true(1)}; UID: TYPE ~ INT16; GID: TYPE ~ INT16; PIDPtr: TYPE ~ POINTER TO PID; PID: TYPE ~ INT; PGRPPtr: TYPE ~ POINTER TO PGRP; PGRP: TYPE ~ INT; Time: TYPE ~ INT32; Dev: TYPE ~ INT16; Offset: TYPE ~ INT32; INum: TYPE ~ CARD32; RES: TYPE ~ SysCallResult; SysCallResult: TYPE ~ MACHINE DEPENDENT { success(0), failure(CARD32.LAST) }; RawVM: TYPE ~ POINTER; GIDsPtr: TYPE ~ POINTER TO GIDs; GIDs: TYPE ~ RECORD [ gids: PACKED SEQUENCE COMPUTED CARD OF GID ]; < and its included header files.>> FD: TYPE ~ FileDescriptor; FileDescriptor: TYPE ~ MACHINE DEPENDENT { pseudostdin(0), pseudostdout(1), pseudostderr(2), stdtrc(LOOPHOLE[-4]), stdout(LOOPHOLE[-3]), stdin(LOOPHOLE[-2]), error(CARD32.LAST) }; FileFlags: TYPE ~ MACHINE DEPENDENT RECORD [ fill0: [0..3777777B] ¬ 0, excl: Flag ¬ false, -- error if already created trunc: Flag ¬ false, -- truncate to zero length creat: Flag ¬ false, -- create if nonexistant [sic] fill1: [0..3] ¬ 0, async: Flag ¬ false, -- signal pgrp when data ready fill2: [0..3] ¬ 0, append: Flag ¬ false, -- append on each write ndelay: Flag ¬ false, -- non-blocking reads access: MACHINE DEPENDENT {RDONLY(0), WRONLY(1), RDWR(2), (3)} ]; <> LockOp: TYPE ~ MACHINE DEPENDENT RECORD [ fill: [0..0fffffffH] ¬ 0, un: Flag ¬ false, -- unlock nb: Flag ¬ false, -- don't block when locking ex: Flag ¬ false, -- exclusive lock sh: Flag ¬ false -- shared lock ]; <> Whence: TYPE ~ MACHINE DEPENDENT { set(0), -- absolute offset incr(1), -- relative to current offset xtnd(2), -- relative to end of file (CARD32.LAST) }; <> <.>> Protections: TYPE ~ MACHINE DEPENDENT RECORD [ fill: PACKED ARRAY [0..BITS[WORD]-4) OF BOOL ¬ ALL[FALSE], user: BOOL ¬ FALSE, -- kernel only exec: BOOL ¬ FALSE, write: BOOL ¬ FALSE, read: BOOL ¬ FALSE ]; MMapFlags: TYPE ~ MACHINE DEPENDENT RECORD [ fill: PACKED ARRAY [0..BITS[WORD]-8) OF BOOL ¬ ALL[FALSE], inherit: BOOL ¬ FALSE, noreserve: BOOL ¬ FALSE, rename: BOOL ¬ FALSE, fixed: BOOL ¬ TRUE, pad: PACKED ARRAY [0..1) OF BOOL ¬ ALL[FALSE], private: BOOL ¬ FALSE, shared: BOOL ¬ TRUE ]; MSyncFlags: TYPE ~ MACHINE DEPENDENT RECORD [ fill: PACKED ARRAY [0..BITS[WORD]-2) OF BOOL ¬ ALL[FALSE], invalidate: BOOL ¬ FALSE, -- Invalidate mappings async: BOOL ¬ FALSE -- Return immediately ]; <<>> <.>> PollFD: TYPE ~ WORD16 MACHINE DEPENDENT RECORD [ fd(0): FileDescriptor, events(2): PollEvents, revents(3): PollEvents ]; PollEvents: TYPE ~ WORD16 MACHINE DEPENDENT RECORD [ spare (0: 0..9): PACKED ARRAY[0..10) OF Flag ¬ ALL[false], <> nval (0: 10..10): Flag ¬ false, -- invalid pollfd entry hup (0: 11..11): Flag ¬ false, -- fd has been hung up on err (0: 12..12): Flag ¬ false, -- fd has error condition <> out (0: 13..13): Flag ¬ false, -- fd is writeable (won't block) pri (0: 14..14): Flag ¬ false, -- priority info at fd in (0:15..15): Flag ¬ false -- fd is readable ]; < and >> IpcPerm: TYPE = MACHINE DEPENDENT RECORD [--common IPC access structure uid: UID, -- (owner's) user id gid: GID, -- (owner's) group id cuid: UID, -- creator's user id cgid: GID, -- creator's group id mode: CARD16, -- access modes; r/w permission; (set op sets only low 9 bits) seq: CARD16, -- slot usage sequence number key: CARD -- key ]; ShmIdDs: TYPE = MACHINE DEPENDENT RECORD [ <<--shared memory descriptor structure>> ipcPerm: IpcPerm, -- operation permission struct segsz: INT, -- size of segment in bytes lpid: UID, -- process ID of last shmop cpid: UID, -- process ID of creator nAttch: CARD16, -- number of current attaches unused1: CARD16, -- depending on C compiler's padding algorithm ! aTime: Time, -- last shmat time dTime: Time, -- last shmdt time cTime: Time, -- last change time amp: POINTER -- segment anon¬map pointer ]; SharedMemoryIdentifier: TYPE = RECORD [val: CARD]; errorSharedMemoryIdentifier: SharedMemoryIdentifier = [CARD.LAST]; SharedMemoryKey: TYPE = RECORD [val: CARD]; ipcPRIVATE: SharedMemoryKey = [0]; --private key to create new SharedMemoryIdentifier ShmGetFlags: TYPE = RECORD [val: CARD]; <<--low order 9 bits for permission stuff>> ipcALLOC: ShmGetFlags = [0100000B]; -- entry currently allocated ipcCREAT: ShmGetFlags = [0001000B]; -- create entry if key doesn't exist ipcEXCL: ShmGetFlags = [0002000B]; -- fail if key exists allPerms: ShmGetFlags = [0000777B]; -- (not in found ipc.h) IPCCtlCmd: TYPE = RECORD [val: CARD]; ipcRMID: IPCCtlCmd = [0]; -- remove identifier ipcSET: IPCCtlCmd = [1]; -- set options ipcSTAT: IPCCtlCmd = [2]; -- get options ShmAtFlags: TYPE = RECORD [CARD]; shmNoFlags: ShmAtFlags = [000000]; shmRDOnly: ShmAtFlags = [010000]; -- attach read-only (else read-write) shmRnd: ShmAtFlags = [020000]; -- round attach address to SHMBA <>> Signal: TYPE ~ MACHINE DEPENDENT { SIGHUP(1), -- hangup SIGINT(2), -- interrupt SIGQUIT(3), -- quit SIGILL(4), -- illegal instruction (not reset when caught) SIGTRAP(5), -- trace trap (not reset when caught) SIGABRT(6), -- used by abort SIGEMT(7), -- EMT instruction SIGFPE(8), -- floating point exception SIGKILL(9), -- kill (cannot be caught or ignored) SIGBUS(10), -- bus error SIGSEGV(11), -- segmentation violation SIGSYS(12), -- bad argument to system call SIGPIPE(13), -- write on a pipe with no one to read it SIGALRM(14), -- alarm clock SIGTERM(15), -- software termination signal from kill SIGURG(16), -- urgent condition on IO channel SIGSTOP(17), -- sendable stop signal not from tty SIGTSTP(18), -- stop signal from tty SIGCONT(19), -- continue a stopped process SIGCHLD(20), -- to parent on child stop or exit SIGTTIN(21), -- to readers pgrp upon background tty read SIGTTOU(22), -- like TTIN for output if (tp->t¬local<OSTOP) SIGIO(23), -- input/output possible signal SIGXCPU(24), -- exceeded CPU time limit SIGXFSZ(25), -- exceeded file size limit SIGVTALRM(26), -- virtual time alarm SIGPROF(27), -- profiling time alarm SIGWINCH(28), -- window changed SIGLOST(29), -- resource lost (eg, record-lock lost) SIGUSR1(30), -- user defined signal 1 SIGUSR2(31) -- user defined signal 2 }; <> SocketType: TYPE ~ MACHINE DEPENDENT { stream(1), -- stream socket dgram(2), -- datagram socket raw(3), -- raw-protocol interface rdm(4), -- reliably-delivered message seqPacket(5), -- sequenced packet stream (CARD16.LAST) }; AddressFamily: TYPE ~ MACHINE DEPENDENT { unspec(0), -- unspecified unix(1), -- local to host (pipes, portals) inet(2), -- internetwork: UDP, TCP, etc. impLink(3), -- arpanet imp addresses pup(4), -- pup protocols: e.g. BSP chaos(5), -- mit CHAOS protocols ns(6), -- XEROX NS protocols nbs(7), -- nbs protocols ecma(8), -- european computer manufacturers datakit(9), -- datakit protocols ccitt(10), -- CCITT protocols, X.25 etc. sna(11), -- IBM SNA decNet(12), -- DECnet dli(13), -- Direct data link interface lat(14), -- LAT hyLink(15), -- NSC Hyperchannel appleTalk(16), -- Apple Talk nit(17), -- Network Interface Tap ieee802(18), -- IEEE 802.2, also ISO 8802 osi(19), -- umbrella for all families used by OSI (e.g. protosw lookup) x25(20), -- CCITT X.25 in particular osinet(21), -- AFI = 47, IDI = 4 gosip(22), -- U.S. Government OSI (CARD16.LAST) }; SockAddrPtr: TYPE ~ POINTER TO SockAddr; SockAddr: TYPE ~ WORD16 MACHINE DEPENDENT RECORD [ family(0): AddressFamily, data(1): PACKED ARRAY[0..14) OF CHAR -- up to 14 bytes of direct address ]; ProtocolFamily: TYPE ~ MACHINE DEPENDENT { -- same as address families for now unspec(0), -- unspecified unix(1), -- local to host (pipes, portals) inet(2), -- internetwork: UDP, TCP, etc. impLink(3), -- arpanet imp addresses pup(4), -- pup protocols: e.g. BSP chaos(5), -- mit CHAOS protocols ns(6), -- XEROX NS protocols nbs(7), -- nbs protocols ecma(8), -- european computer manufacturers datakit(9), -- datakit protocols ccitt(10), -- CCITT protocols, X.25 etc. sna(11), -- IBM SNA decNet(12), -- DECnet dli(13), -- Direct data link interface lat(14), -- LAT hyLink(15), -- NSC Hyperchannel appleTalk(16), -- Apple Talk nit(17), -- Network Interface Tap ieee802(18), -- IEEE 802.2, also ISO 8802 osi(19), -- umbrella for all families used by OSI (e.g. protosw lookup) x25(20), -- CCITT X.25 in particular osinet(21), -- AFI = 47, IDI = 4 gosip(22), -- U.S. Government OSI (CARD16.LAST) }; MsgFlags: TYPE ~ MACHINE DEPENDENT RECORD [ spare: [0..01fffffffH] ¬ 0, dontRoute: Flag ¬ false, -- send without using routing tables peek: Flag ¬ false, -- peek at incoming message oob: Flag ¬ false -- process out-of-band data ]; SDHow: TYPE ~ MACHINE DEPENDENT { noRecv(0), -- disable receives on the socket noSend(1), -- disable sends on the socket noSendOrRecv(2) -- disable both sends and receives }; <.>> Fmt: TYPE ~ MACHINE DEPENDENT { fifo(01B), -- fifo special chr(02B), -- character special dir(04B), -- directory blk(06B), -- block special reg(10B), -- regular file lnk(12B), -- symbolic link sock(14B), -- socket (17B) }; <<>> Permission: TYPE ~ MACHINE DEPENDENT RECORD [ read: Flag, write: Flag, exec: Flag ]; Mode: TYPE ~ MACHINE DEPENDENT RECORD [ fmt: Fmt ¬ LOOPHOLE[0], -- type of file suid: Flag ¬ false, -- set user id on execution sgid: Flag ¬ false, -- set group id on execution svtx: Flag ¬ false, -- save swapped text even after use owner: Permission ¬ [false, false, false], group: Permission ¬ [false, false, false], others: Permission ¬ [false, false, false] ]; StatPtr: TYPE ~ POINTER TO Stat; Stat: TYPE ~ MACHINE DEPENDENT RECORD [ dev: Dev, -- device inode resides on pad0: INT16, ino: INum, -- this inode's number mode: Mode, -- protection nlink: INT16, -- number of hard links to the file uid: UID, -- user ID of owner gid: GID, -- group ID of owner rdev: Dev, -- the device type, for inode that is device pad1: INT16, size: CARD32, -- total size of file, in bytes atime: Time, -- file last access time spare1: INT32, mtime: Time, -- file last modify time spare2: INT32, ctime: Time, -- file last status change time spare3: INT32, blksize: CARD32, -- optimal blocksize for file system i/o ops blocks: CARD32, -- actual number of blocks allocated spare4: ARRAY [0..2) OF INT32 ]; <> <> StrBufPtr: TYPE ~ POINTER TO StrBuf; StrBuf: TYPE ~ MACHINE DEPENDENT RECORD [ maxLen: INT, len: INT, buf: CHARPtr ]; RSFlags: TYPE = MACHINE DEPENDENT { none(0), hiPri(1), (CARD32.LAST) }; GetResult: TYPE = MACHINE DEPENDENT { success(0), moreCtl(1), moreData(2), moreCtlAndData(3), failure(CARD32.LAST) }; <> Who: TYPE ~ INT; children: Who = -1; self: Who = 0; RUsage: TYPE ~ RECORD [ utime: TimeVal, -- user time used stime: TimeVal, -- system time used maxrss: INT, -- max resident set size ixrss: INT, -- integral shared memory size idrss: INT, -- integral unshared data isrss: INT, -- integral unshared stack minflt: INT, -- page reclaims majflt: INT, -- page faults nswap: INT, -- swaps inblock: INT, -- block input operations oublock: INT, -- block output operations msgsnd: INT, -- messages sent msgrcv: INT, -- messages received nsignals: INT, -- signals received nvcsw: INT, -- voluntary context switches nivcsw: INT -- involuntary ]; <.>> TimeZonePtr: TYPE ~ POINTER TO TimeZone; TimeZone: TYPE = MACHINE DEPENDENT RECORD [ minutesWest: INT, dstTime: INT -- non-zero == dst applies at this location ]; TimeValPtr: TYPE ~ POINTER TO TimeVal; TimeVal: TYPE = MACHINE DEPENDENT RECORD [ sec: CARD, -- seconds since Jan 1, 1970 usec: CARD -- plus this many microseconds ]; FileTimesPtr: TYPE ~ POINTER TO AccModTimes; AccModTimes: TYPE ~ MACHINE DEPENDENT RECORD [ accessTime: TimeVal, modTime: TimeVal ]; <> IOVecPtr: TYPE ~ POINTER TO IOVec; IOVec: TYPE ~ MACHINE DEPENDENT RECORD [ base: CHARPtr, len: INT ]; <.>> FileSystemID: TYPE ~ MACHINE DEPENDENT RECORD [ val: ARRAY [0..2) OF CARD32 ]; StatFSPtr: TYPE ~ POINTER TO StatFS; StatFS: TYPE ~ MACHINE DEPENDENT RECORD [ type: CARD32, -- type of info, zero for now bsize: CARD32, -- fundamental file system block size blocks: CARD32, -- total blocks in file system bfree: CARD32, -- free blocks in file system bavail: CARD32, -- free blocks available to non-superuser files: CARD32, -- total file nodes in file system ffree: CARD32, -- free file nodes in file system fsid: FileSystemID, -- file system id spare: ARRAY [0..7) OF CARD32 ]; }. < FileFlags, UnixStrOpts.Flags => RSFlags>>