UnixRemoteFile.mesa
Copyright Ó 1985, 1986 by Xerox Corporation. All rights reserved.
Last Edited by:
Demers, November 10, 1987 6:01:54 pm PST
DIRECTORY
BasicTime USING [GMT],
IO USING [STREAM],
RemoteFile USING [ServerHandle],
Rope USING [ROPE],
SunNFS USING [FType]
;
UnixRemoteFile: CEDAR DEFINITIONS
~ {
Types
FileDescriptor: TYPE ~ REF;
FType: TYPE ~ SunNFS.FType -- { non(0), reg(1), dir(2), blk(3), chr(4), lnk(5) } -- ;
GMT: TYPE ~ BasicTime.GMT;
Mode: TYPE ~ CARD32 -- rwxrwxrwx, suid, sgid -- ;
ROPE: TYPE ~ Rope.ROPE;
ServerHandle: TYPE ~ RemoteFile.ServerHandle;
STREAM: TYPE ~ IO.STREAM;
Parameters
viewUnix: READONLY ATOM;
Handles
A handle identifies a server.
UnixServerHandle: TYPE ~ REF UnixServerObject;
UnixServerObject: TYPE ~ RECORD [
sH: ServerHandle,
procs: UnixServerProcs
];
UnixServerProcs: TYPE ~ REF UnixServerProcsObject;
UnixServerProcsObject: TYPE ~ RECORD [
setUser: SetUserProc,
open: OpenProc,
close: CloseProc,
create: CreateProc,
delete: DeleteProc,
mkDir: MkDirProc,
rmDir: RmDirProc,
link: LinkProc,
symLink: LinkProc,
rename: RenameProc,
enumerate: EnumerateProc,
getInfo: GetInfoProc,
setInfo: SetInfoProc,
read: ReadProc,
write: WriteProc
];
CreateHandle: PROC [serverName: ROPE] RETURNS [h: UnixServerHandle];
Create a handle to talk to the named server.
DestroyHandle: PROC [h: UnixServerHandle];
Destroy a handle.
Operations
SetUser: PROC [h: UnixServerHandle, name: ROPE, password: ROPE] ~ INLINE { h.procs.setUser[h.sH, name, password] };
Set user name and password associated with the server handle. NIL means name/password of logged-in Cedar user.
Raises Error[$badCredentials] if password is incorrect.
SetUserProc: TYPE ~ PROC [sH: ServerHandle, name, password: ROPE];
Open: PROC [h: UnixServerHandle, path: ROPE] RETURNS [fD: FileDescriptor] ~ INLINE { RETURN [h.procs.open[h.sH, path]] };
Open an existing file.
OpenProc: TYPE ~ PROC [sH: ServerHandle, path: ROPE] RETURNS [fD: FileDescriptor];
Close: PROC [h: UnixServerHandle, fD: FileDescriptor] ~ INLINE { h.procs.close[h.sH, fD] };
Close the designated file.
CloseProc: TYPE ~ PROC [sH: ServerHandle, fD: FileDescriptor];
Create: PROC [h: UnixServerHandle, path: ROPE, mode: Mode] RETURNS [fD: FileDescriptor] ~ INLINE { RETURN [h.procs.create[h.sH, path, mode]] };
Create an empty file of the given name, smashing any existing one. The mode is the protection mode assigned to the new file.
CreateProc: TYPE ~ PROC [sH: ServerHandle, path: ROPE, mode: Mode] RETURNS [fD: FileDescriptor];
Delete: PROC [h: UnixServerHandle, path: ROPE] ~ INLINE { h.procs.delete[h.sH, path] };
Delete the named file.
DeleteProc: TYPE ~ PROC [sH: ServerHandle, path: ROPE];
MkDir: PROC [h: UnixServerHandle, path: ROPE, mode: Mode] ~ INLINE { h.procs.mkDir[h.sH, path, mode] };
Create a directory.
MkDirProc: TYPE ~ PROC [sH: ServerHandle, path: ROPE, mode: Mode];
RmDir: PROC [h: UnixServerHandle, path: ROPE] ~ INLINE { h.procs.rmDir[h.sH, path] };
Remove an empty directory.
RmDirProc: TYPE ~ PROC [sH: ServerHandle, path: ROPE];
Link: PROC [h: UnixServerHandle, toPath, asPath: ROPE] ~ INLINE { h.procs.link[h.sH, toPath, asPath] };
Create a hard link to file toPath under the name asPath. Since the link is hard, toPath must designate an existing file on the same file system volume as asPath.
LinkProc: TYPE ~ PROC [sH: ServerHandle, toPath, asPath: ROPE];
SymLink: PROC [h: UnixServerHandle, toPath, asPath: ROPE] ~ INLINE { h.procs.symLink[h.sH, toPath, asPath] };
Create a Symbolic link to file toPath under the name asPath. No check to see whether the file exists.
SymLinkProc: TYPE ~ PROC [sH: ServerHandle, toPath, asPath: ROPE];
Rename: PROC [h: UnixServerHandle, fromPath, toPath: ROPE] ~ INLINE { h.procs.rename[h.sH, fromPath, toPath] };
Rename atomically. The fromPath and toPath must be on the same file system volume.
RenameProc: TYPE ~ PROC [sH: ServerHandle, fromPath, toPath: ROPE];
EachNameProc: TYPE ~ PROC [name: ROPE] RETURNS [continue: BOOLTRUE];
Enumerate: PROC [h: UnixServerHandle, dirPath: ROPE, pattern: ROPE, eachName: EachNameProc] ~ INLINE { h.procs.enumerate[h.sH, dirPath, pattern, eachName] };
Enumerate files in directory designated by dirPath with names matching pattern.
EnumerateProc: TYPE ~ PROC [sH: ServerHandle, dirPath: ROPE, pattern: ROPE, eachName: EachNameProc];
GetInfo: PROC [h: UnixServerHandle, fD: FileDescriptor]
RETURNS [type: FType, size: CARD, mode: Mode, mTime: GMT] ~ INLINE {
[type, size, mode, mTime] ← h.procs.getInfo[h.sH, fD] };
Lookup information on given file.
GetInfoProc: TYPE ~ PROC [sH: ServerHandle, fD: FileDescriptor]
RETURNS [type: FType, size: CARD, mode: Mode, mTime: GMT];
SetInfo: PROC [h: UnixServerHandle, fD: FileDescriptor, mode: Mode, mTime: GMT] ~ INLINE { h.procs.setInfo[h.sH, fD, mode, mTime] };
Set (selected) information about given file. If mode is CARDINAL.LAST it will not be changed. If mTime is BasicTime.nullGMT it will not be changed.
SetInfoProc: TYPE ~ PROC [sH: ServerHandle, fD: FileDescriptor, mode: Mode, mTime: GMT];
Read: PROC [h: UnixServerHandle, fD: FileDescriptor, offset, count: CARD, bOffset: CARD, block: REF TEXT] RETURNS [bytesRead: CARD] ~ INLINE { bytesRead ← h.procs.read[h.sH, fD, offset, count, bOffset, block] };
Read specified bytes of file into block. Return number of bytes read, update block.length.
ReadProc: TYPE ~ PROC [sH: ServerHandle, fD: FileDescriptor, offset, count: CARD, bOffset: CARD, block: REF TEXT] RETURNS [bytesRead: CARD];
Write: PROC [h: UnixServerHandle, fD: FileDescriptor, offset, count: CARD, bOffset: CARD, block: REF TEXT] RETURNS [bytesWritten: CARD] ~ INLINE { bytesWritten ← h.procs.write[h.sH, fD, offset, count, bOffset, block] };
Write specified bytes of file from block. Return number of bytes written.
WriteProc: TYPE ~ PROC [sH: ServerHandle, fD: FileDescriptor, offset, count: CARD, bOffset: CARD, block: REF TEXT] RETURNS [bytesWritten: CARD];
Creature Comforts
OpenReadStream: PROC [h: UnixServerHandle, path: ROPE] RETURNS [str: STREAM];
Open an input stream for reading from the named file.
RetrieveFile: PROC [h: UnixServerHandle, path: ROPE, into: STREAM];
Retrieve the named file into the given stream.
OpenWriteStream: PROC [h: UnixServerHandle, path: ROPE, mode: Mode] RETURNS [str: STREAM];
Open an output stream for writing to the named file.
StoreFile: PROC [h: UnixServerHandle, path: ROPE, mode: Mode, from: STREAM];
Store the named file from the given stream.
Error
Error: ERROR [code: ATOM, msg: ROPE];
File Server
$viewNotImplemented -- server doesn't export Unix view
$pathNameSyntax -- syntax error in pathname
$perm -- caller is not owner
$noent -- no such file or directory
$io -- I/O error
$nxio -- no such device or address
$acces -- access permission denied
$exist -- file already exists
$nodev -- no such device
$notdir -- argument not a directory and should be
$isdir -- argument is a directory and shouldn't be
$fbig -- file would grow too big
$nospc -- no space left on device
$rofs -- file system is readonly
$nametoolong -- file name too long
$notempty -- attempt to remove a nonemtpy directory
$dquot -- disk quota exceeded
$stale -- fhandle argument no longer valid
RPC
$wrongRPCVersion
$wrongProgram
$wrongProgramVersion
$wrongProc
Authentication
$badCredentials
$wrongCredentials
$badVerifier
$wrongVerifier
$badReplyVerifier
$wrongReplyVerifier
$weakCredentials
Network problems
$timeout
$unknownServer
$unreachable
Generic bad thing
$protocol
}...