UnixSysCalls.mesa
Copyright Ó 1988, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Christian Jacobi, January 24, 1991 5:30 pm PST
Demers, November 9, 1988 5:41:50 pm PST
Carl Hauser, February 16, 1989 1:46:38 pm PST
Michael Plass, August 13, 1991 12:57 pm PDT
Unix(tm) system calls for PCedar.
Commented-out names are unimplemented for good reason, and not to be used, except: "????" means we should implement some version of this eventually.
DIRECTORY
UnixTypes USING [AccModTimes, AddressFamily, CHARPtr, FD, FileFlags, FileTimesPtr, GetResult, GID, GIDs, GIDsPtr, INTPtr, IOVec, IOVecPtr, IPCCtlCmd, MMapFlags, Mode, MsgFlags, MSyncFlags, PGRP, PID, PollFD, Protections, ProtocolFamily, RawVM, RES, RSFlags, RUsage, SDHow, SharedMemoryIdentifier, SharedMemoryKey, ShmAtFlags, ShmGetFlags, ShmIdDs, shmNoFlags, Signal, SockAddr, SockAddrPtr, SocketType, Stat, StatFS, StatFSPtr, StatPtr, StrBuf, StrBufPtr, TimeVal, TimeValPtr, TimeZone, TimeZonePtr, UID, Whence, Who];
UnixSysCalls: CEDAR DEFINITIONS
~ { OPEN UnixTypes;
Accept: UNSAFE PROC [s: FD, addr: SockAddrPtr, addrLen: INTPtr] RETURNS [FD];
Access: PROC [path: CHARPtr, mode: Mode] RETURNS [RES];
Acct
AdjTime
Audit
AuditOn
AuditSvc
Bind: PROC [s: FD, name: SockAddrPtr, nameLen: INT] RETURNS [RES];
Brk
SBrk
ChDir
ChMod: PROC [path: CHARPtr, mode: Mode] RETURNS [RES];
FChMod: PROC [fd: FD, mode: Mode] RETURNS [RES];
Chown
FChown
Chroot
Close: PROC [fd: FD] RETURNS [RES];
Connect: PROC [s: FD, name: SockAddrPtr, nameLen: INT] RETURNS [RES];
Creat
Dup
Dup2 ????
ExecVE
Exit
FCntl: PROC [fd: FD, cmd: INT, arg: INT] RETURNS [RES];
FCntl4: PROC [fd: FD, cmd: INT, arg: INT, doInIOP: BOOL] RETURNS [RES];
Caller controls whether fcntl is done in vp or iop. The Unix-style entry FCntl always does the fcntl call in the vp, which in some cases is inappropriate.
FLock
Fork
but see UnixSysCallExtensions.Spawn
FSync: PROC [fd: FD] RETURNS [RES];
GetAUID
SetAUID
GetDEnts: UNSAFE PROC [fd: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
GetDirentries
GetDomainName: UNSAFE PROC [name: CHARPtr, nameLen: INT] RETURNS [RES];
GetDTableSize: PROC RETURNS [INT];
GetGID: PROC RETURNS [GID];
GetEGID: PROC RETURNS [GID];
GetGroups: UNSAFE PROC [gidSetLen: INT, gidSet: GIDsPtr] RETURNS [nGroups: INT];
SetGroups
GetHostID: PROC RETURNS [INT];
GetHostName: UNSAFE PROC [name: CHARPtr, nameLen: INT] RETURNS [RES];
SetHostName
GetITimer
SetITimer
GetMsg: UNSAFE PROC [fd: FD, ctlPtr, dataPtr: StrBufPtr, flags: POINTER TO RSFlags] RETURNS [GetResult];
GetPageSize: PROC RETURNS [INT];
GetPeerName: UNSAFE PROC [s: FD, name: SockAddrPtr, nameLen: INTPtr] RETURNS [RES];
GetPID: PROC RETURNS [INT];
GetPPID: PROC RETURNS [INT];
GetPriority
SetPriority
GetRLimit
SetRLimit
GetRUsage: UNSAFE PROC [who: Who, rusage: POINTER TO RUsage] RETURNS [RES];
GetSockName: UNSAFE PROC [s: FD, name: SockAddrPtr, nameLen: INTPtr] RETURNS [RES];
GetSockOpt: UNSAFE PROC [s: FD, level: INT, optName: INT, optVal: CHARPtr, optLen: INTPtr] RETURNS [RES];
SetSockOpt: PROC [s: FD, level: INT, optName: INT, optVal: CHARPtr, optLen: INT] RETURNS [RES];
GetTimeOfDay: UNSAFE PROC [tp: TimeValPtr, tzp: TimeZonePtr] RETURNS [RES];
SetTimeOfDay
GetUID: PROC RETURNS[UID];
GetEUID: PROC RETURNS[UID];
IOCtl: UNSAFE PROC [d: FD, request: INT, argp: CHARPtr] RETURNS [RES];
... only a subset of the full Unix capability. See impl.
IOCtl4: UNSAFE PROC [d: FD, request: INT, argp: CHARPtr, doInIOP: BOOL] RETURNS [RES];
Caller controls whether ioctl is done in vp or iop.
The Unix-style entry IOCtl always does the ioctl call in the vp, which in some cases is inappropriate.
Kill: PROC [pid: PID, sig: Signal] RETURNS [RES];
KillPG: PROC [pgrp: PGRP, sig: Signal] RETURNS [RES];
Link: PROC [name1, name2: CHARPtr] RETURNS [RES];
Listen: PROC [s: FD, backlog: INT] RETURNS [RES];
LSeek: PROC [d: FD, offset: INT, whence: Whence] RETURNS [INT];
MInCore: UNSAFE PROC [addr: CHARPtr, len: INT, vec: CHARPtr] RETURNS [RES];
MkDir: PROC [path: CHARPtr, mode: Mode] RETURNS [RES];
MkNod: PROC [path: CHARPtr, mode: Mode, dev: INT] RETURNS [RES];
MMap: UNSAFE PROC [addr: RawVM, nbytes: CARD, prot: Protections, flags: MMapFlags, d: FD, offset: CARD] RETURNS [RES];
Restrictions: MUST HAVE flags.shared AND flags.fixed
addr must be page-aligned and must lie beyond heap segment limit.
Use UnixSysCallExtensions.VMReserve to reserve suitable VM
MUnmap: UNSAFE PROC [addr: RawVM, nbytes: CARD] RETURNS [RES];
addr must be page-aligned.
munmapped region must lie beyond heap segment limit AND MUST BE MAPPED.
Return 0 on success.
Panic on failure. DANGER!
Mount
MProtect: UNSAFE PROC [addr: RawVM, nbytes: CARD, prot: Protections] RETURNS [RES];
Use only in address ranges obtained with UnixSysCallExtensions.VMReserve.
MSync: UNSAFE PROC [addr: RawVM, nbytes: CARD, flags: MSyncFlags] RETURNS [RES];
MsgCtl
MsgGet
MsgOp
NFSSvc
AsyncDaemon
Open: PROC [path: CHARPtr, flags: FileFlags, mode: Mode] RETURNS [FD];
Pipe
Poll: UNSAFE PROC [fds: POINTER TO PollFD, nfds: CARD, timeout: INT] RETURNS [selected: INT];
Restricted form of the Unix Poll system call. The restrictions are:
nfds must be 1
the file descriptor specified in fds[0] must be valid (not -1)
Profil: UNSAFE PROC[buf: CHARPtr, bufSize: INT, offset: INT, scale: INT] RETURNS [RES];
PTrace
PutMsg: PROC [fd: FD, ctlPtr, dataPtr: StrBufPtr, flags: RSFlags] RETURNS [RES];
QuotaCtl
Read: UNSAFE PROC [d: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
ReadV: UNSAFE PROC [d: FD, iov: IOVecPtr, iovCnt: INT] RETURNS [INT];
ReadLink: UNSAFE PROC [path: CHARPtr, buf: CHARPtr, bufSize: INT] RETURNS [INT];
Reboot
Recv: UNSAFE PROC [fd: FD, buf: CHARPtr, len: INT, flags: MsgFlags] RETURNS [INT];
RecvFrom: UNSAFE PROC [fd: FD, buf: CHARPtr, len: INT, flags: MsgFlags, from: SockAddrPtr, fromLen: INTPtr] RETURNS [INT];
RecvMsg
Rename: PROC [from, to: CHARPtr] RETURNS [RES];
RmDir: PROC [path: CHARPtr] RETURNS [RES];
Select
SemCtl
SemGet
SemOp
Send: PROC [s: FD, msg: CHARPtr, len: INT, flags: MsgFlags] RETURNS [INT];
SendTo: PROC [s: FD, msg: CHARPtr, len: INT, flags: MsgFlags, to: SockAddrPtr, toLen: INT] RETURNS [INT];
SendMsg
SetPGRP
GetPGrp: PROC [pid: PID] RETURNS [PGRP];
SetREGID
SetREUID
SetUserAudit
ShmGet: PROC [key: SharedMemoryKey, size: INT, shmflg: ShmGetFlags] RETURNS [shmId: SharedMemoryIdentifier];
Returns shared memory identifier or errorSharedMemoryIdentifier.
Heavy clients of this should use the termination cleanup aids in UnixSysCallExtensions to clean up on termination of the world.
ShmCtl: PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf: POINTER TO ShmIdDs] RETURNS [RES];
Shared memory control operations.
ShmAt: UNSAFE PROC [id: SharedMemoryIdentifier, addr: RawVM, flags: ShmAtFlags ¬ shmNoFlags] RETURNS [INT];
Attaches shared memory segment.
Returns address of memory segment or -1 on failure.
WARNING:
You should explicitly allocate the memory with UnixSysCallExtensions.VMReserve.
A 0 addr would confuse the garbage collector.
ShmDt: UNSAFE PROC [addr: RawVM] RETURNS [RES];
Unmaps shared memory segment at addr from calling processes address space.
But segment and contents are retained.
Shutdown: PROC [s: FD, how: SDHow] RETURNS [RES];
SigBlock
SigPause
SigSetMask
SigStack
SigVec
Socket: PROC [af: AddressFamily, type: SocketType, protocol: ProtocolFamily] RETURNS [FD];
SocketPair ????
Stat: UNSAFE PROC [path: CHARPtr, buf: StatPtr] RETURNS [RES];
LStat: UNSAFE PROC [path: CHARPtr, buf: StatPtr] RETURNS [RES];
FStat: UNSAFE PROC [fd: FD, buf: StatPtr] RETURNS [RES];
StatFS: UNSAFE PROC [path: CHARPtr, buf: StatFSPtr] RETURNS [RES];
FStatFS: UNSAFE PROC [fd: FD, buf: StatFSPtr] RETURNS [RES];
Swapon
SymLink: PROC [name1, name2: CHARPtr] RETURNS [RES];
Sync: PROC RETURNS [RES];
Syscall
Truncate: PROC [path: CHARPtr, length: CARD] RETURNS [RES];
FTruncate: PROC [fd: FD, length: CARD] RETURNS [RES];
UMask
UName
Unlink: PROC [path: CHARPtr] RETURNS [RES];
Unmount
UTimes: PROC [file: CHARPtr, tvp: FileTimesPtr] RETURNS [RES];
VAdvise
VFork
VHangup
Wait
Wait3
Wait4
Write: PROC [d: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
WriteV: PROC [d: FD, iov: IOVecPtr, iovCnt: INT] RETURNS [INT];
}.
CHauser, February 16, 1989: Removed Dup, added GetSockOpt and SetSockOpt, tracking changes in PCR; changed FileTimesPtr type to be pointer to named record type instead of anonymous array type.
CHauser, February 22, 1989: added Poll, GetMsg, PutMsg
Michael Plass, August 6, 1991 5:27:57 pm PDT: Cedar10.0; brought up-to-date with UIO.h
Michael Plass, August 12, 1991 5:17:16 pm PDT: Now gets all type names from UnixTypes instead of a whole fleet of little interfaces; some types needed to be renamed to disambiguate: UnixFile.Flags => FileFlags, UnixStrOpts.Flags => RSFlags