// IFSFiles.decl -- declarations for IFS file structures
//		This is an extension to AltoFileSys.d
// Copyright Xerox Corporation 1979, 1981, 1982

// Last modified May 11, 1982  10:09 AM by Taft

get "AltoFileSys.d"

// The first few structures parallel the ones in the standard
// Alto file system, but assign meaning to some previously unused
// bits and fields which are marked with "*".

//----------------------------------------------------------------------------
structure ISN:		// IFS serial number
//----------------------------------------------------------------------------
[
word1 word =
   [
   directory bit	// file is a directory (SysDir or IFS.dir)
   random bit		// not used in IFS
   nolog bit		// not used in IFS
   archived bit		//*file is archived
   part1 bit 12
   ]
word2 word = part2 word
]

//----------------------------------------------------------------------------
structure IDA:		// IFS virtual disk address
//----------------------------------------------------------------------------
[
blank byte
unit byte		//*logical unit number
page word		// virtual page number on unit
]

//----------------------------------------------------------------------------
structure IFP:		// IFS file pointer
//----------------------------------------------------------------------------
[
serialNumber @ISN
version word		// not used, always 1
da word 2 = @IDA	// virtual disk address
]

// structures unique to the IFS

manifest
[
maxPathNameChars = 99	// max length of pathname in chars
lenPathName = (maxPathNameChars+2) rshift 1
maxDirNameChars = 39	// max length of directory or user name
nGroups = 62		// number of protection groups
]

//----------------------------------------------------------------------------
structure DirName:	// directory name string
//----------------------------------------------------------------------------
[
length byte
char↑1,maxDirNameChars byte
]
manifest lenDirName = size DirName/16

//----------------------------------------------------------------------------
structure Protection:	// protection descriptor
//----------------------------------------------------------------------------
[
group↑0,nGroups-1 bit	// group access or membership
owner bit		// owner access
world bit		// world access
]
manifest lenProtection = size Protection/16

//----------------------------------------------------------------------------
structure FileProt:	// file protection
//----------------------------------------------------------------------------
[
readProt @Protection	// read protection
writeProt @Protection	// write protection
appendProt @Protection	// append protection
]
manifest lenFileProt = size FileProt/16

//----------------------------------------------------------------------------
structure InhProps:	// file properties inherited from old versions
//----------------------------------------------------------------------------
[
fileProt word lenFileProt = @FileProt
]
manifest lenInhProps = size InhProps/16

//----------------------------------------------------------------------------
structure ILDFlags:	// IFS leader page flags
//----------------------------------------------------------------------------
[
undeletable bit		// file is undeletable even by wheels
noBackup bit		// file should not be backed up
damaged bit		// file is damaged (set by IFSScavenger)
blank bit 13
]

//----------------------------------------------------------------------------
structure ILD:	// IFS leader page
//----------------------------------------------------------------------------
[
@LD			// first 256 words is standard leader page
pathName word lenPathName  // complete IFS pathname
inhProps word lenInhProps = @InhProps
author @DirName		// user name of last writer
backedUp @TIME		// date and time of last backup
type word		// ftText, ftBinary, ftUnspecified
byteSize word
flags word = @ILDFlags
checksum word		// software checksum over data; 0 => none;
			// is Pup checksum +1.
]

compileif (size ILD/16) gr 512 then
   [ Barf("ILD too large") ] // Leaf uses other 512 words for file map

manifest
[
// file types
ftUnspecified = 0
ftText = 1
ftBinary = 2
]

//----------------------------------------------------------------------------
structure DR:		// IFS directory record
//----------------------------------------------------------------------------
[
header word =
   [
   type bit 6		// entry type
   length bit 10	// entry length in words
   ]
fp @IFP			// file pointer
pathName @STRING	// complete IFS pathname
// DIF entries have a DIFRec after the name (see below)
]
manifest lenDRHeader = offset DR.pathName/16

//----------------------------------------------------------------------------
structure DIFRec:	// additional info in entries for DIFs
//----------------------------------------------------------------------------
[
createProt @Protection	// create protection
inhProps word lenInhProps = @InhProps
diskPageUsage↑0,1 word	// number of disk pages used
diskPageLimit↑0,1 word	// number of disk pages permitted
]
manifest lenDIFRec = size DIFRec/16

manifest
[
// types of directory entries
drTypeNormal = 1	// normal file
drTypeDIF = 2		// directory information file

// constants for DR header validity check.
// the following two must be the next higher power of 2 minus one.
// ***If this is changed, IfsDirKey.asm must be changed also.
maxDRType = 3		// maximum value of type field
maxDRLength = 127	// maximum value of length field
drHeaderMask = #171600	// mask of bits that should be zero in DR header
]

//----------------------------------------------------------------------------
structure Capabilities:	// user capabilities
//----------------------------------------------------------------------------
[
wheel bit		// allowed to do anything
mail bit		// allowed to receive mail
blank bit 14
]

//----------------------------------------------------------------------------
structure DIF:		// directory information file (page 1)
//----------------------------------------------------------------------------
[
// directory properties
@DIFRec			// truth copy of stuff in directory entry
connectProt @Protection	// connect protection
owner @DirName		// name of directory owner (if files-only)
miscDirAttributes word =
   [
   filesOnly bit	// files-only directory
   blank bit 13
   validGrapevineRName bit  // Grapevine knows about this name
   nonexistentDIF bit	// no local DIF exists.  By definition, this cannot
   			// be true in a DIF file, only in the cache.
   ]

// user properties
password word 9		// encrypted password (cached if using Grapevine)
userGroups @Protection	// user group membership (cached if using Grapevine)
capabilities @Capabilities
ownedGroups @Protection	// groups owned by this user
defaultPrinter @DirName	// name of default printing server
timeLastValid @TIME	// time of most recent Grapevine validity check
hintNotUserGroups @Protection  // groups user is believed not to be in
]
manifest lenDIF = size DIF/16
manifest minLenDIF = offset DIF.ownedGroups/16  // for old DIF

//----------------------------------------------------------------------------
structure UserInfo:	// Passed to file operations
//----------------------------------------------------------------------------
[
userName word		// -> login directory name
connName word		// -> connected directory name
capabilities @Capabilities
userGroups @Protection
defaultDir word		// -> default directory name (0 if none)
]
manifest lenUserInfo = size UserInfo/16

//----------------------------------------------------------------------------
structure Home:		// home block written as file IFS.Home on all packs
//----------------------------------------------------------------------------
[
type word		// what kind of IFS this is
numUnits word		// number of units in file system
thisUnit word		// logical unit number of this disk
created @TIME		// creation date and time of file system
id @DirName		// file system ID (for OpenFileSys)
name @STRING		// name of this file system
]
manifest lenHome = size Home/16

manifest
[
// IFS types
ifsTypePrimary = 1	// primary file system (swap area, etc.)
ifsTypeBackup = 2	// backup file system
ifsTypeAuxiliary = 3	// auxiliary (non-backup) file system
]