Created
August 19, 2020 16:06
-
-
Save RomanHargrave/3313425e40716f32e9075ed04fee033d to your computer and use it in GitHub Desktop.
Files-11 is a fuck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //------------------------------------------------ | |
| //--- 010 Editor v10.0 Binary Template | |
| // | |
| // File: Files-11 INDEXF.SYS Template | |
| // Authors: Roman Hargrave | |
| // Version: 0.1 | |
| // Purpose: Inspecting Files-11 INDEXF data | |
| // Category: | |
| // File Mask: | |
| // ID Bytes: | |
| // History: | |
| //------------------------------------------------ | |
| // Always 512 according to VMS File System Internals (FSI). | |
| #define BLOCK_SIZE 512 | |
| // VMS Time Handling ------------------------------------------------------------------------ | |
| #define VTime_UNIX_EPOCH 35067168005400000 | |
| #define VTime_TO_SECONDS 10000000 | |
| typedef uint64 VTime <read=VTime_Read, write=VTime_Write>; | |
| typedef uint64 VDur <read=VDur_Read>; | |
| string VTime_Read(VTime t) | |
| { | |
| time_t nix_time = (time_t) ((t - VTime_UNIX_EPOCH) / VTime_TO_SECONDS); | |
| return TimeTToString(nix_time); | |
| } | |
| void VTime_Write(VTime &t, string rep) | |
| { | |
| time_t nix_time = 0; | |
| StringToTimeT(rep, nix_time); | |
| t = ((nix_time * VTime_TO_SECONDS) + VTime_UNIX_EPOCH); | |
| } | |
| string VDur_Read(VDur t) | |
| { | |
| uint16 years, months, weeks, days, hours, minutes, seconds; | |
| uint32 total_seconds = t / VTime_TO_SECONDS; | |
| years = Floor(total_seconds / 31557600); | |
| months = Floor(total_seconds / 2629800) % 12; | |
| weeks = Floor(total_seconds / 604800) % 4; | |
| days = Floor(total_seconds / 86400) % 7; | |
| hours = Floor(total_seconds / 3600) % 24; | |
| minutes = Floor(total_seconds / 60) % 60; | |
| seconds = total_seconds % 60; | |
| string rep; | |
| SPrintf(rep,"P%02dY%02dM%02dW%dDT%02dH%02dM%02dS", | |
| years, months, weeks, days, hours, minutes, seconds); | |
| return rep; | |
| } | |
| void VDur_Write(VDur &t, string rep) | |
| { | |
| uint16 years, months, weeks, days, hours, minutes, seconds; | |
| SScanf(rep, "P%dY%dM%dW%dDT%dH%dM%dS", | |
| years, months, weeks, days, hours, minutes, seconds); | |
| uint32 total_seconds = | |
| (years * 31557600) | |
| + (months * 2629800) | |
| + (weeks * 604800) | |
| + (days * 86400) | |
| + (hours * 3600) | |
| + (minutes * 60) | |
| + seconds; | |
| t = total_seconds * VTime_TO_SECONDS; | |
| } | |
| uint64 VBNOffset(uint32 vbn) | |
| { | |
| return (FTell() / BLOCK_SIZE) - (vbn * BLOCK_SIZE); | |
| } | |
| // INDEXF.SYS Types ------------------------------------------------------------------------- | |
| // void block | |
| struct Block { ubyte data[BLOCK_SIZE]; }; | |
| struct ODStrucLev { | |
| ubyte version; | |
| ubyte level; | |
| }; | |
| struct VolChar { | |
| ubyte HM2_V_READCHECK : 1 <name="HM2$V_READCHECK">; | |
| ubyte HM2_V_WRITCHECK : 1 <name="HM2$V_WRITCHECK">; | |
| ubyte HM2_V_ERASE : 1 <name="HM2$V_ERASE">; | |
| ubyte HM2_V_NOHIGHWATER : 1 <name="HM2$V_NOHIGHWATER">; | |
| ubyte __unused <hidden=true>; | |
| }; | |
| struct Protection { | |
| ubyte ReadProtect : 1 <name="Read Protect", comment="Prohibit reading">; | |
| ubyte WriteProtect : 1 <name="Write Protect", comment="Prohibit writing to extant files">; | |
| ubyte CreateProtect : 1 <name="Create Protect", comment="Prohibit file creation">; | |
| ubyte DeleteProtect : 1 <name="Delete Protect", comment="Prohibit file deletion">; | |
| ubyte __unused <hidden=true>; | |
| }; | |
| struct BootBlock { | |
| byte bootloader[BLOCK_SIZE]; | |
| }; | |
| // Exactly 512b | |
| struct HomeBlock { | |
| uint32 HM2_L_HOMELBN <comment="Home block LBN. Must be non-zero.",name="HM2$L_HOMELBN">; | |
| uint32 HM2_L_ALHOMELBN <comment="Alternate home block LBN.", name="HM2$L_ALHOMELBN">; | |
| uint32 HM2_L_ALTIDXLBN <comment="Backup index file header LBN", name="HM2$L_ALTIDXLBN">; | |
| struct ODStrucLev | |
| HM2_W_STRUCLEV <comment="Structure level and version", name="HM2$W_STRUCLEV">; | |
| uint16 HM2_W_CLUSTER <comment="Storage bitmap cluster factor", name="HM2$W_CLUSTER">; | |
| uint16 HM2_W_HOMEVBN <comment="Home block VBN. Must be non-zero.", name="HM2$W_HOMEVBN">; | |
| uint16 HM2_W_ALHOMEVBN <comment="Backup home block VBN", name="HM2$W_ALHOMEVBN">; | |
| uint16 HM2_W_ALTIDXVBN <comment="Backup index file header VBN.", name="HM2$W_ALTIDXVBN">; | |
| uint16 HM2_W_IBMAPVBN <comment="Index file bitmap VBN.", name="HM2$W_IBMAPVBN">; | |
| uint32 HM2_L_IBMAPLBN <comment="Index file bitmap LBN. Must be non-zero", name="HM2$L_IBMAPLBN">; | |
| uint32 HM2_L_MAXFILES <comment="Maximum number of files", name="HM2$L_MAXFILES">; | |
| uint16 HM2_W_IBMAPSIZE <comment="Index file bitmap size (number of blocks)", name="HM2$W_IBMAPSIZE">; | |
| uint16 HM2_W_RESFILES <comment="Number of reserved files. Must be at least 5.", name="HM2$W_RESFILES">; | |
| uint16 HM2_W_DEVTYPE <comment="Disk device type. Not used.", name="HM2$W_DEVTYPE">; | |
| uint16 HM2_W_RVN <comment="Relative volume number.", name="HM2$W_RVN">; | |
| uint16 HM2_W_SETCOUNT <comment="Number of volumes in the set (if this is volume 1).", name="HM2$W_SETCOUNT">; | |
| struct VolChar | |
| HM2_W_VOLCHAR <comment="Volume characteristics", name="HM2$W_VOLCHAR">; | |
| uint32 HM2_W_VOLOWNER <comment="Volume owner (binary UIC)", name="HM2$W_VOLOWNER">; | |
| uint32 __reserved_1 <hidden=true>; | |
| struct Protection | |
| HM2_W_PROTECT <comment="Volume protection code", name="HM2$W_PROTECT">; | |
| struct Protection | |
| HM2_W_FILEPROT <comment="Default file protection (unsupported)", name="HM2$W_FILEPROT">; | |
| uint16 __reserved_2 <hidden=true>; | |
| uint16 HM2_W_CHECKSUM1 <comment="Additive checksum of all preceding entries", name="HM2$W_CHECKSUM1">; | |
| VTime HM2_Q_CREDATE <comment="Volume creation date", name="HM2$Q_CREDATE">; | |
| ubyte HM2_B_WINDOW <comment="Default window size (number of retrieval pointers)", name="HM2$B_WINDOW">; | |
| ubyte HM2_B_LRU_LIM <comment="Directory process limit.", name="HM2$B_LRU_LIM">; | |
| uint16 HM2_W_EXTEND <comment="Default file extend", name="HM2$W_EXTEND">; | |
| VDur HM2_Q_RETAINMIN <comment="Minimum file retention period", name="HM2$Q_RETAINMIN">; | |
| VDur HM2_Q_RETAINMAX <comment="Maximum file retention period", name="HM2$Q_RETAINMAX">; | |
| VTime HM2_Q_REVDATE <comment="Volume revision date", name="HM2$Q_REVDATE">; | |
| ubyte HM2_R_MIN_CLASS[20] <comment="Minimum security class", name="HM2$R_MIN_CLASS">; | |
| ubyte HM2_R_MAX_CLASS[20] <comment="Maximum sexurity class", name="HM2$R_MAX_CLASS">; | |
| ubyte __reserved_3[320] <hidden=true>; | |
| uint32 HM2_L_SERIALNUM <comment="Media serial number", name="HM2$L_SERIALNUM">; | |
| char HM2_T_STRUCNAME[12] <comment="Structure (volume set) name", name="HM2$T_STRUCNAME">; | |
| char HM2_T_VOLNAME[12] <comment="Volume name", name="HM2$T_VOLNAME">; | |
| char HM2_T_OWNERNAME[12] <comment="Owner name", name="HM2$T_OWNERNAME">; | |
| char HM2_T_FORMAT[12] <comment="Format type", name="HM2$T_FORMAT">; | |
| uint16 __reserved_4 <hidden=true>; | |
| uint16 HM2_W_CHECKSUM2 <comment="Additive checksum of the prior 255 16-bit words", name="HM2$W_CHECKSUM2">; | |
| }; | |
| struct FileID { | |
| uint16 fileNumberLo <comment="Low-order file number", name="Low Order File Number">; | |
| uint16 sequenceNumber <comment="File sequence number", name="File Sequence Number">; | |
| ubyte relativeVolume <comment="Relative volume number", name="Relative Volume Number">; | |
| ubyte fileNumberHi <comment="High-order file number", name="High Order File Number">; | |
| }; | |
| struct FileChars { | |
| ubyte FCH_V_NOBACKUP : 1 <comment="Disable backup", name="FCH$V_NOBACKUP">; | |
| ubyte FCH_V_WRITEBACK : 1 <comment="Enable write-back cache", name="FCH$V_WRITEBACK">; | |
| ubyte FCH_V_READCHECK : 1 <comment="Enable read-checking", name="FCH$V_READCHECK">; | |
| ubyte FCH_V_WRITCHECK : 1 <comment="Enable write-checking", name="FCH$V_WRITCHECK">; | |
| ubyte FCH_V_CONTIGB : 1 <comment="Prefer contiguous allocation", name="FCH$V_CONTIGB">; | |
| ubyte FCH_V_LOCKED : 1 <comment="Was locked on deaccess", name="FCH$V_LOCKED">; | |
| ubyte FCH_V_CONTIG : 1 <comment="Is logically contiguous", name="FCH$V_CONTIG">; | |
| ubyte FCH_V_BADACL : 1 <comment="Has invalid ACL", name="FCH$V_BADACL">; | |
| ubyte FCH_V_SPOOL : 1 <comment="Is a spool file", name="FCH$V_SPOOL">; | |
| ubyte FCH_V_DIRECTORY : 1 <comment="Is a directory", name="FCH$V_DIRECTORY">; | |
| ubyte FCH_V_BADBLOCK : 1 <comment="Has bad data block(s)", name="FCH$V_BADBLOCK">; | |
| ubyte FCH_V_MARKDEL : 1 <comment="Is marked for deletion", name="FCH$V_MARKDEL">; | |
| ubyte FCH_V_NOCHARGE : 1 <comment="Is free for owner", name="FCH$V_NOCHARGE">; | |
| ubyte FCH_V_ERASE : 1 <comment="Is to be erased on deletion", name="FCH$_ERASE">; | |
| uint16 __unused <hidden=true>; | |
| }; | |
| struct MinimumAccessLevel { | |
| ubyte Read : 2 <comment="Lowest level required for read access", name="Read">; | |
| ubyte Write : 2 <comment="Lowest level required for write access", name="Write">; | |
| ubyte Execute : 2 <comment="Lowest level required for execute access", name="Execute">; | |
| ubyte Delete : 2 <comment="Lowest level required for delete access", name="Delete">; | |
| }; | |
| struct FileProtection { | |
| ubyte System : 4 <name="System">; | |
| ubyte Owner : 4 <name="Owner">; | |
| ubyte Group : 4 <name="Group">; | |
| ubyte World : 4 <name="World">; | |
| }; | |
| struct JournalFlags { | |
| ubyte FJN_V_ONLY_RU : 1 <comment="Only to be accessed in a recovery unit", name="FJN$V_ONLY_RU">; | |
| ubyte FJN_V_RUJNL : 1 <comment="Enable recovery-unit journaling", name="FJN$V_RUJNL">; | |
| ubyte FJN_V_BIJNL : 1 <comment="Enable before-image journaling", name="FJN$V_BIJNL">; | |
| ubyte FJN_V_AIJNL : 1 <comment="Enable after-image journaling", name="FJNL$V_AIJNL">; | |
| ubyte FJN_V_ATJNL : 1 <comment="Enable audit-trail journaling", name="FJNL$V_ATJNL">; | |
| ubyte FJN_V_NEVER_RU : 1 <comment="Never to be accessed in a recovery unit", name="FJN$V_NEVER_RU">; | |
| ubyte FJN_V_JOURNAL_FILE : 1 <comment="The file is an RMS journal file", name="FJN$V_JOURNAL_FILE">; | |
| }; | |
| struct SecurityClassification { | |
| uint16 __reserved <hidden=true>; | |
| ubyte CLS_B_SECUR_LEV <comment="Secrecy level", name="CLS$B_SECUR_LEV">; | |
| ubyte CLS_B_INTEG_LEV <comment="Integrety level", name="CLS$B_INTEG_LEV">; | |
| uint64 CLS_Q_SECUR_CAT <comment="Secrecy category mask", name="CLS$Q_SECUR_CAT">; | |
| uint64 CLS_Q_INTEG_CAT <comment="Integrity category mask", name="CLS$Q_INTEG_CAT">; | |
| }; | |
| struct FileIdent { | |
| char FI2_T_FILENAME[20] <comment="File name", name="FI2$T_FILENAME">; | |
| uint16 FI2_W_REVISION <comment="Revision number", name="FI2$W_REVISION">; | |
| VTime FI2_Q_CREDATE <comment="Creation date", name="FI2$Q_CREDATE">; | |
| VTime FI2_Q_REVDATE <comment="Revision date", name="FI2$Q_REVDATE">; | |
| VTime FI2_Q_EXPDATE <comment="Epiration date", name="FI2$Q_EXPDATE">; | |
| VTime FI2_Q_BAKDATE <comment="Backup date", name="FI2$Q_BAKDATE">; | |
| char FI2_T_FILENAMEEXT[66] <comment="Continued file name", name="FI2$T_FILENAMEEXT">; | |
| }; | |
| struct FileHeader { | |
| // Fixed Portion ------------------------------------------ | |
| ubyte FH2_B_IDOFFSET <comment="Ident area offset (16-bit words from start of header)", name="FH2$B_IDOFFSET">; | |
| ubyte FH2_B_MPOFFSET <comment="Map area offset (16-bit words from start of file header)", name="FH2$B_MPOFFSET">; | |
| ubyte FH2_B_ACOFFSET <comment="Access control list offset", name="FH2$B_ACOFFSET">; | |
| ubyte FH2_B_RSOFFSET <comment="Reserved area offset", name="FH2$B_RSOFFSET">; | |
| uint16 FH2_W_SEGNUM <comment="Extension segment number", name="FH2$W_SEGNUM">; | |
| struct ODStrucLev | |
| FH2_W_STRUCLEV <comment="On-disk-structure level", name="FH2$W_STRUCLEV">; | |
| struct FileID | |
| FH2_W_FID <comment="File ID number", name="FH2$W_FID">; | |
| struct FileID | |
| FH2_W_EXT_FID <comment="Extension file ID", name="FH2$W_EXT_FID">; | |
| ubyte FH2_W_RECATTR[32] <comment="Record Attributes", name="FH2$W_RECATTR">; | |
| struct FileChars | |
| FH2_L_FILECHAR <comment="File Characteristics", name="FH2$L_FILECHAR">; | |
| uint16 __reserved1 <hidden=true>; | |
| ubyte FH2_B_MAP_INUSE <comment="Map words in use", name="FH2$B_MAP_INUSE">; | |
| struct MinimumAccessLevel | |
| FH2_B_ACC_MODE <comment="Accessor privilege level", name="FH2$B_ACC_MODE">; | |
| uint32 FH2_L_FILEOWNER <comment="File owner identification", name="FH2$L_FILEOWNER">; | |
| struct FileProtection | |
| FH2_W_FILEPROT <comment="File protection code", name="FH2$W_FILEPROT">; | |
| struct FileID | |
| FH2_W_BACKLINK <comment="Back link file ID", name="FH2$W_BACKLINK">; | |
| struct JournalFlags | |
| FH2_B_JOURNAL <comment="Journal control flags", name="FH2$B_JOURNAL">; | |
| ubyte FH2_B_RU_ACTIVE <comment="Recoverable facility ID number", name="FH2$B_RU_ACTIVE">; | |
| uint16 __reserved2 <hidden=true>; // size = 76 bytes (38 words) after the end of this field | |
| // Optional Portion --------------------------------------- | |
| // If B_IDOFFSET is 40 or more words (80+ bytes), highwater mark field is present | |
| // this is because L_HIGHWATER will run up until word 40 | |
| if (FH2_B_IDOFFSET >= 40) { | |
| uint32 FH2_L_HIGHWATER <comment="File highwater mark", name="FH2$L_HIGHWATER">; | |
| } | |
| if (FH2_B_IDOFFSET >= 41) { | |
| uint16 __reserved3 <hidden=true>; | |
| } | |
| if (FH2_B_IDOFFSET >= 42) { | |
| uint16 __reserved4 <hidden=true>; | |
| } | |
| if (FH2_B_IDOFFSET >= 43) { | |
| uint16 __reserved5 <hidden=true>; | |
| } | |
| if (FH2_B_IDOFFSET >= 44) { | |
| uint16 __reserved6 <hidden=true>; | |
| } | |
| if (FH2_B_IDOFFSET >= 54) { | |
| struct SecurityClassification FH2_R_CLASS_PROT <comment="Security classification details", name="FH2$R_CLASS_PROT">; | |
| } | |
| struct FileIdent IDENT; | |
| }; | |
| struct { | |
| // Cluster 1 ---------------------------------------------- | |
| struct BootBlock boot; // VBN 1 | |
| struct HomeBlock home; // VBN 2 | |
| struct HomeBlock __c1HomeCopies[home.HM2_W_CLUSTER - 2] <hidden=true>; | |
| // Cluster 2 ---------------------------------------------- | |
| struct HomeBlock __c2HomeCopies[home.HM2_W_CLUSTER] <hidden=true>; | |
| // Cluster 3 ---------------------------------------------- | |
| struct HomeBlock backupHome; | |
| struct HomeBlock __c3HomeCopies[home.HM2_W_CLUSTER - 1] <hidden=true>; | |
| // Cluster 4 ---------------------------------------------- | |
| struct FileHeader alternateIndexHeader; | |
| } indexf; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment