DIRECTORY Basics USING [Comparison], BasicTime USING [GMT], Arpa USING [Address], ArpaUDP USING [Port], FSBackdoor USING [ErrorCode, Version], FSRemoteFileBackdoor USING [DeleteProc, DoIOProc, EnumerateForInfoProc, EnumerateForNamesProc, GetInfoProc, GetServerProc, RenameProc, RetrieveProc, ServerHandle, StoreProc, SweepProc, ValidateProc], Rope USING [ROPE], SunNFS USING [DirOpRes, FHandle, Stat, TimeVal], SunRPC USING [Handle], SunRPCAuth USING [Conversation] ; SunNFSFSRemoteFile: CEDAR DEFINITIONS ~ { ROPE: TYPE ~ Rope.ROPE; ServerHandle: TYPE ~ FSRemoteFileBackdoor.ServerHandle; Version: TYPE ~ FSBackdoor.Version; ServerData: TYPE ~ REF ServerDataObject; ServerDataObject: TYPE ~ RECORD [ ttl: CARD, downMsg: ROPE, -- non-NIL => down hostName: ROPE, address: Arpa.Address, port: ArpaUDP.Port, h: SunRPC.Handle, c: SunRPCAuth.Conversation, remoteDirs: RemoteDirHandle, mountPort: ArpaUDP.Port, cachedHandles: REF ]; ObtainRPCHandleAndConversation: PROC [sH: ServerHandle] RETURNS [h: SunRPC.Handle, c: SunRPCAuth.Conversation]; ReleaseRPCHandleAndConversation: PROC [sH: ServerHandle, h: SunRPC.Handle, c: SunRPCAuth.Conversation]; SunNFSGetServer: FSRemoteFileBackdoor.GetServerProc; SunNFSSweep: FSRemoteFileBackdoor.SweepProc; SunNFSValidate: FSRemoteFileBackdoor.ValidateProc; SunNFSDelete: FSRemoteFileBackdoor.DeleteProc; SunNFSEnumerateForInfo: FSRemoteFileBackdoor.EnumerateForInfoProc; SunNFSEnumerateForNames: FSRemoteFileBackdoor.EnumerateForNamesProc; SunNFSGetInfo: FSRemoteFileBackdoor.GetInfoProc; SunNFSRename: FSRemoteFileBackdoor.RenameProc; SunNFSRetrieve: FSRemoteFileBackdoor.RetrieveProc; SunNFSStore: FSRemoteFileBackdoor.StoreProc; SunNFSDoIO: FSRemoteFileBackdoor.DoIOProc; RemoteDirHandle: TYPE ~ REF RemoteDirObject; RemoteDirObject: TYPE ~ RECORD [ parent, child, sibling: RemoteDirHandle, nameComponent: ROPE, -- u/l case exactly as on server fHandle: SunNFS.FHandle, createMode: CARD, -- default mode for files created in this directory createModeTTL: CARDINAL, content: DirEntries, contentMTime: SunNFS.TimeVal, contentTTL: CARDINAL, contentLocked: BOOL _ FALSE, contentAvailable: CONDITION, useCount: CARDINAL, ttl: CARDINAL ]; DirEntries: TYPE ~ REF DirEntriesObject; DirEntriesObject: TYPE ~ RECORD [ next: DirEntries _ NIL, count: CARDINAL _ 0, entries: SEQUENCE maxCount: CARDINAL OF ROPE ]; GetRemoteDirRoot: PROC [sH: ServerHandle] RETURNS [dH: RemoteDirHandle]; GetRemoteDirChild: PROC [sH: ServerHandle, dH: RemoteDirHandle, childName: ROPE, create: BOOL] RETURNS [dHChild: RemoteDirHandle, created: BOOL]; CreateSubdirectory: PROC [sH: ServerHandle, dH: RemoteDirHandle, name: ROPE, desiredMode: CARD] RETURNS [fH: SunNFS.FHandle]; InsertRemoteDirChild: PROC [dH: RemoteDirHandle, childName: ROPE, fHandle: SunNFS.FHandle] RETURNS [dHChild: RemoteDirHandle]; PinRemoteDirPath: PROC [dH: RemoteDirHandle]; UnPinRemoteDir: PROC [dH: RemoteDirHandle] RETURNS [dHParent: RemoteDirHandle]; UnPinRemoteDirPath: PROC [dH: RemoteDirHandle]; SweepRemoteDirCache: PROC [root: RemoteDirHandle, seconds: CARD]; GetCreateMode: PROC [sH: ServerHandle, dH: RemoteDirHandle, forDirectory: BOOL _ FALSE] RETURNS [createMode: CARD]; EachDirEntryProc: TYPE ~ PROC [entryName: ROPE] RETURNS [continue: BOOL _ TRUE]; EnumerateDirectory: PROC [sH: ServerHandle, dH: RemoteDirHandle, eachDirEntry: EachDirEntryProc, staleOK: BOOL _ FALSE]; FollowDirPath: PROC [sH: ServerHandle, nR: NameReader, case: BOOL, create: BOOL] RETURNS [dH: RemoteDirHandle]; LookupThruSymLinks: PROC [sH: ServerHandle, dH: RemoteDirHandle, name: ROPE] RETURNS [SunNFS.DirOpRes]; caseFileNamePrefix: READONLY ROPE; caseFileNamePrefixLen: READONLY INT; CreateCaseFile: PROC [sH: ServerHandle, dH: RemoteDirHandle, base: ROPE]; CollectCaseFile: PROC [sH: ServerHandle, dH: RemoteDirHandle, base: ROPE]; VersionInfo: TYPE ~ { missing, bang, bangNumber, bangStar, bangH, bangL }; versionPartLeftBracket: READONLY ROPE; versionPartLeftBracketLen: READONLY INT; versionPartRightBracket: READONLY CHAR; versionPartRightBracketLen: READONLY INT; DecodeVersionFromNFSName: PROC [name: ROPE, checkCase: BOOL _ FALSE] RETURNS [nameWithoutVersion: ROPE, version: Version, caseOK: BOOL]; EncodeVersionInNFSName: PROC [name: ROPE, version: Version] RETURNS [nameWithVersion: ROPE]; NameReader: TYPE ~ REF NameReaderObject; NameReaderObject: TYPE ~ RECORD [ text: REF READONLY TEXT, index: CARDINAL ]; ReadDirComponent: PROC [nR: NameReader, case: BOOL] RETURNS [component: ROPE]; ReadBaseComponent: PROC [nR: NameReader, case: BOOL, stripVersion: BOOL _ FALSE] RETURNS [base: ROPE, vI: VersionInfo, version: Version, isPattern: BOOL, patternHead: ROPE]; CreateNameReader: PROC [r: ROPE] RETURNS [nR: NameReader]; ResetNameReader: PROC [nR: NameReader, position: INTEGER]; NameWriter: TYPE ~ REF NameWriterObject; NameWriterObject: TYPE ~ RECORD [ text: REF TEXT ]; CreateNameWriter: PROC RETURNS [nW: NameWriter]; WriteDirComponent: PROC [nW: NameWriter, component: ROPE]; WriteBaseComponent: PROC [nW: NameWriter, component: ROPE]; RetractComponent: PROC [nW: NameWriter]; RetractAndReturnComponent: PROC [nW: NameWriter] RETURNS [r: ROPE]; RopeFromNameWriter: PROC [nW: NameWriter] RETURNS [ROPE]; GMTFromSunTime: PROC [sunTime: SunNFS.TimeVal] RETURNS [gmt: BasicTime.GMT]; SunTimeFromGMT: PROC [gmt: BasicTime.GMT] RETURNS [sunTime: SunNFS.TimeVal]; CompareSunTimes: PROC [t1, t2: SunNFS.TimeVal] RETURNS [Basics.Comparison]; ReportRPCError: PROC [code: ATOM, sH: ServerHandle _ NIL, name, msg: ROPE _ NIL]; ReportAuthError: PROC [code: ATOM, sH: ServerHandle _ NIL, msg: ROPE _ NIL]; ReportNFSError: PROC [status: SunNFS.Stat, sH: ServerHandle _ NIL, name, msg: ROPE _ NIL]; ReportFSError: PROC [code: FSBackdoor.ErrorCode, sH: ServerHandle _ NIL, name, msg: ROPE _ NIL]; }... ŽSunNFSFSRemoteFile.mesa Copyright ำ 1987 by Xerox Corporation. All rights reserved. Demers, November 3, 1987 3:28:23 pm PST Copied Types Server Cache FS view ... Unix(tm) view ... Obtain SunRPC handle and Unix-flavor credentials for the current logged-in Cedar user (UserCredentials) Server Procs Directories Return "pinned" RemoteDirHandle for root of file system associated with server. Return "pinned" RemoteDirHandle for named child of given (pinned) directory. If create is TRUE, create the subdirectory if necessary. This is CASE-SENSITIVE! Create a subdirectory with the given (case-sensitive) name. Insert directory cache entry for given file. Caller must be sure that "fHandle" does in fact denote the named directory. Return "pinned" RemoteDirHandle. Lock ("pin") the given cached remote directory and all its ancestors. Cached directories are reference counted. For each "pin" operation there must be a corresponding "release" operation. See ReleaseRemoteDir / ReleaseRemoteDirPath, below. Release ("unpin") the given cached remote directory. The parent and other ancestors remain "pinned". Release ("unpin") the path leading to the given cached remote directory. The client may not hold any pinned descendants of dH. Called occasionally by the Sweep proc registered with FSRemoteFileBackdoor. Get the (nfs) mode to give to (regular or subdirectory) files created in the directory denoted by dH. Enumerate the directory, applying eachDirEntry to each entry. Note the name passed to eachDirEntry is in SERVER format, not FS format. Directory contents may be cached; if "staleOK" is FALSE, always contact the server to verify that the cache is up-to-date. Return a (pinned) RemoteDirHandle for the longest prefix of directory names in nR, leaving nR ready for ReadBaseComponent[nR]. If case is TRUE then this is case-sensitive; otherwise name components are presented to the server in LOWER case. The client is responsible for calling ReleaseRemoteDirPath[dH]. ! FS.Error[...] Lookup through symbolic links Like SunNFSClient.Lookup, but recursively follows symbolic links. This is CASE-SENSITIVE! Case of file names This is slightly bogus. A race between programs concurrently creating a new file version and deleting the "last" version may cause the case information to disappear. Fortunately, nobody relies on the case information for anything important. Create a case file for file base. The base should have no version part. If there are (appear to be) no more versions of the base file, delete any case file. The base should have no version part. File Name Readers / Writers Parsing If no version part, or version part can't be parsed, returns version=FSBackdoor.noVersion. The checkCase option checks to see that the name is all lower-case. Like FSName.BangVersionFile, but uses the NFS encoding of versions in file names. Name Readers The returned component is NIL if all the directory information has already been read. In particular, if the name reader contains "<>foo!17", the first call of ReadDirComponent will return NIL and leave things ready for ReadBaseComponent. If case is FALSE then the returned component is all LOWER CASE. The result "isPattern" is TRUE iff the base component contains a '* before the version part; in this case, "patternHead" goes up to (but does not include) the first '* in the pattern. If case is FALSE then the returned base and pattern head are all LOWER CASE. The base contains whatever version info was specified in the nR source, unless "stripVersion" is TRUE. The position is a number of pathname components. A negative position is relative to the current name reader position; a nonnegative position is absolute. Name Writers Create an empty name writer. WriteDirComponent appends ">" if the writer is currently empty, then appends component. WriteBaseComponent appends ">" unconditionally, then appends component. The idea is that if you start with an empty name writer, then do zero or more WriteDirComponent calls followed by a WriteBaseComponent call, then Rope.Cat["[server]<", RopeFromNameWriter[nW]] will be a valid name. "Back up" the last component written to the writer. Time Conversion Error Reporting These procs raise appropriate FS.Error[...]s. ส,˜codešœ™K™