XNSViewImpl.mesa
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Bill Jackson (bj), February 19, 1990 0:11 am PST
DIRECTORY
CrRPC USING [Handle],
IO USING [STREAM],
PFS USING [FileType, Mutability, nullUniqueID, tUnspecified, UniqueID],
PFSClass USING [AttachProc, CloseProc, CopyProc, DeleteProc, EnumerateClientPropertiesProc, EnumerateForInfoProc, EnumerateForNamesProc, FileInfoProc, FileManipulationProcs, FileManipulationProcsObject, FSHandle, FSObject, GetClientPropertyProc, GetHandleProc, GetInfoProc, LookupNameProc, MaintenanceProcs, MaintenanceProcsObject, OpenFile, OpenProc, ReadProc, Register, RenameProc, RetrieveProc, SetAttributesProc, SetByteCountAndUniqueIDProc, SetClientPropertyProc, StoreProc, SweepProc, ValidateProc, WriteProc],
PFSNames USING [PATH],
PFSBackdoor USING [ProduceError],
Rope USING [ROPE];
XNSViewImpl: CEDAR MONITOR LOCKS tr USING tr: Transport
IMPORTS PFSClass ~ {
ROPE: TYPE ~ Rope.ROPE;
Transport Management
Transport: TYPE ~ REF TransportBody;
TransportBody: TYPE ~ MONITORED RECORD [
crH: CrRPC.Handle,
mnt: REF
];
TransportProc: TYPE ~ PROC [tr: Transport];
CallProtected: PROC [mnt: REF, inner: TransportProc] ~ {
crH: CrRPC.Handle ~ NIL;
link: Transport ~ NEW[TransportBody];
UnderLock: ENTRY TransportProc ~ {
ENABLE UNWIND => { NULL };
inner[tr];
};
link.crH ← crH;
link.mnt ← mnt;
UnderLock[link];
};
XNS Virtual File System(s)
xnsFlavor: ATOM ~ $XNS;
VFS: TYPE ~ REF VFSInstance;
VFSInstance: TYPE ~ RECORD [
fs: ROPE,
flavorSpecified: BOOL
];
GetHandle: PFSClass.GetHandleProc ~ {
instance: VFS ~ NEW[VFSInstance ← [fs: fs, flavorSpecified: flavorSpecified] ];
downMsg ← NIL;
h ← NEW[PFSClass.FSObject ← vfs^];
Attempt to Attach new vfs[h]
h.data ← instance;
};
vfs: PFSClass.FSHandle ~ NEW [PFSClass.FSObject ← [
flavor: xnsFlavor,
name: NIL, -- filled in upon instantiation
maintenanceProcs: mo,
procs: fmo,
data: NIL -- filled in upon instantiation
]];
Maintenance Object
mo: PFSClass.MaintenanceProcs ~
NEW [PFSClass.MaintenanceProcsObject ← [
sweep: Sweep,
validate: Validate
]];
Maintenance Operations
Sweep: PFSClass.SweepProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
NULL;
};
Validate: PFSClass.ValidateProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
obsolete ← FALSE; downMsg ← NIL;
IF ( FALSE ) THEN { obsolete ← TRUE; downMsg ← NIL };
IF ( FALSE ) THEN { obsolete ← FALSE; downMsg ← "downMsg" };
};
File Manipulation Object
fmo: PFSClass.FileManipulationProcs ~
NEW[PFSClass.FileManipulationProcsObject ← [
delete: Delete,
enumerateForInfo: EnumerateForInfo,
enumerateForNames: EnumerateForNames,
fileInfo: FileInfo,
lookupName: Lookup,
rename: Rename,
copy: Copy,
setAttributes: SetAttributes,
setByteCountAndUniqueID: SetByteCountAndUniqueID,
setClientProperty: SetClientProperty,
getClientProperty: GetClientProperty,
enumerateClientProperties: EnumerateClientProperties,
read: Read,
write: Write,
open: Open,
close: Close,
store: Store,
retrieve: Retrieve,
attach: Attach,
getInfo: GetInfo
]];
File Manipulation Procs
XNSDelete: PROC ~ {
<<
fileH: FilingP10V5.Handle; withKids: BOOL;
[fileH: fileH, withKids: withKids] ← FindFile[mnt, crH, file, wantedUniqueID, $delete];
IF ( withKids ) THEN {
ENABLE UNWIND => {
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Close[h: crH, file: fileH, session: mnt.session^];
};
xx: ROPE ~ IO.PutFR["Directory %g has children", IO.rope[file] ];
PFSBackdoor.ProduceError[accessDenied, xx]
};
{
delete: BOOLIF ( proc = NIL ) THEN TRUE ELSE proc[fullName, uniqueID];
IF ( delete ) THEN {
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Delete[h: crH, file: fileH, session: mnt.session^];
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Close[h: crH, file: fileH, session: mnt.session^];
};
};
mnt.active ← FALSE; ReturnConnection[crH];
>>
};
Delete: PFSClass.DeleteProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
DeleteInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullName: PFSNames.PATHNIL;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
continue: BOOLIF ( proc = NIL ) THEN TRUE ELSE proc[fullName, uniqueID];
};
CallProtected[mnt, DeleteInner];
};
XNSEnumerateForInfo: PROC ~ {
<<
P: PROC [file: ROPE, bytes: INT, created: BasicTime.GMT, fileType: FileType, version: Version, fID: FileID, isDir: BOOL, withKids: BOOL, pathName: REF TEXT] RETURNS [continue: BOOL] = {
continue ← proc[file, bytes, created, fileType];
};
InnerEnumerate[h, pattern, FALSE, P, $enumerate];
>>
};
EnumerateForInfo: PFSClass.EnumerateForInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateForInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName: PFSNames.PATHNIL;
attachedTo: PFSNames.PATHNIL;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
bytes: INT ← 0;
mutability: PFS.Mutability ← immutable;
fileType: PFS.FileType ← PFS.tUnspecified;
continue: BOOLIF ( proc = NIL ) THEN TRUE ELSE
proc[fullFName, attachedTo, uniqueID, bytes, mutability, fileType];
};
CallProtected[mnt, EnumerateForInfoInner];
};
EnumerateForNames: PFSClass.EnumerateForNamesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateForNamesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
name: PFSNames.PATH;
continue: BOOLIF ( proc = NIL ) THEN TRUE ELSE proc[name];
};
CallProtected[mnt, EnumerateForNamesInner];
};
FileInfo: PFSClass.FileInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
FileInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
version ← [none];
attachedTo ← NIL;
bytes ← 0;
uniqueID ← PFS.nullUniqueID;
mutability ← immutable;
fileType ← PFS.tUnspecified;
};
CallProtected[mnt, FileInfoInner];
};
Lookup: PFSClass.LookupNameProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
path: PFSNames.PATH;
LookupInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
path ← NIL;
};
CallProtected[mnt, LookupInner];
RETURN[path];
};
Rename: PFSClass.RenameProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
RenameInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
done ← TRUE;
};
CallProtected[mnt, RenameInner];
};
Copy: PFSClass.CopyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
CopyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
done ← TRUE;
};
CallProtected[mnt, CopyInner];
};
SetAttributes: PFSClass.SetAttributesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetAttributesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetAttributesInner];
};
SetByteCountAndUniqueID: PFSClass.SetByteCountAndUniqueIDProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetByteCountAndUniqueIDInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetByteCountAndUniqueIDInner];
};
SetClientProperty: PFSClass.SetClientPropertyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetClientPropertyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetClientPropertyInner];
};
GetClientProperty: PFSClass.GetClientPropertyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
GetClientPropertyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
propertyValue ← NIL;
};
CallProtected[mnt, GetClientPropertyInner];
};
EnumerateClientProperties: PFSClass.EnumerateClientPropertiesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateClientPropertiesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
propertyName: ROPE; propertyValue: ROPE;
continue: BOOLIF ( proc = NIL ) THEN TRUE ELSE proc[propertyName, propertyValue];
};
CallProtected[mnt, EnumerateClientPropertiesInner];
};
Open: PFSClass.OpenProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
of: PFSClass.OpenFile;
OpenInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
of ← NIL;
};
CallProtected[mnt, OpenInner];
RETURN[of];
};
Read: PFSClass.ReadProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
ReadInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
bytesRead ← 0;
};
CallProtected[mnt, ReadInner];
};
Write: PFSClass.WriteProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
WriteInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
bytesWritten ← 0;
};
CallProtected[mnt, WriteInner];
};
Close: PFSClass.CloseProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
CloseInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, CloseInner];
};
Store: PFSClass.StoreProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
StoreInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullName: PFSNames.PATHNIL;
continue: BOOLIF ( proc = NIL ) THEN TRUE ELSE proc[fullName];
};
CallProtected[mnt, StoreInner];
};
Retrieve: PFSClass.RetrieveProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
RetrieveInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName: PFSNames.PATHNIL;
bytes: INT ← 0;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
s: IO.STREAMIF ( proc = NIL ) THEN NIL ELSE proc[fullFName, bytes, uniqueID];
IF ( s = NIL ) THEN ERROR;
};
CallProtected[mnt, RetrieveInner];
};
Attach: PFSClass.AttachProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
AttachInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
toFName ← NIL;
};
CallProtected[mnt, AttachInner];
};
GetInfo: PFSClass.GetInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
GetInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName ← NIL;
attachedTo ← NIL;
uniqueID ← PFS.nullUniqueID;
bytes ← 0;
mutability ← immutable;
fileType ← PFS.tUnspecified;
};
CallProtected[mnt, GetInfoInner];
};
Init: PROC ~ {
PFSClass.Register[xnsFlavor, GetHandle];
};
Init[];
}.