Skip to content

Commit c2d8c8b

Browse files
committed
Add tool to examine ITS archive files.
So far, it only lists the contents.
1 parent 199eca9 commit c2d8c8b

File tree

4 files changed

+224
-1
lines changed

4 files changed

+224
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ bin2x
55
its2bin
66
its2x
77
its2rim
8+
itsarc
89
dis10

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OBJS = pdp10-opc.o info.o word.o bin-word.o its-word.o x-word.o \
55
sblk.o pdump.o dis.o timing.o timing_ka10.o timing_ki10.o memory.o
66
#file.o
77

8-
UTILS = bin2ascii bin2x its2x its2bin its2rim
8+
UTILS = bin2ascii bin2x its2x its2bin its2rim itsarc
99

1010
all: dis10 $(UTILS)
1111

@@ -33,6 +33,9 @@ its2bin: its2bin.o word.o bin-word.o its-word.o x-word.o
3333
its2rim: its2rim.o word.o bin-word.o its-word.o x-word.o
3434
$(CC) its2rim.o word.o bin-word.o its-word.o x-word.o -o its2rim
3535

36+
itsarc: itsarc.o $(OBJS)
37+
$(CC) $^ -o $@
38+
3639
#dependencies
3740
bin-word.o: bin-word.c dis.h
3841
bin2ascii.o: bin2ascii.c

arcdev.format

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Copyright (c) 1999 Massachusetts Institute of Technology
2+
See the COPYING file at the top-level directory of this project.
3+
------------------------------
4+
5+
;Archive device format:
6+
7+
;The first page of an archive device file is its directory.
8+
;The remaining pages are data.
9+
10+
;The directory may not even be looked at unless the archive is "locked".
11+
.SEE LOCK,UNLOCK ;Only one ARCDEV can lock a given archive at a time.
12+
;Shuffling the directory should not be done in place, even when it is locked.
13+
;Instead, use DIRGET to make a copy and DIRPUT to store the copy back in.
14+
;When a file is open, the address of its data area is remembered in FILADR.
15+
;The data area of a file never moves, and the file can be open only in one
16+
;direction at a time, so reading or writing the data area requires no interlocking.
17+
18+
;The format of the archive device directory is approximately that of
19+
;an I.T.S. UFD. The differences are:
20+
21+
;In the fixed header, word 0 (UDESCP) contains SIXBIT /ARC1!!/
22+
;Word 1 points to the beginning of the name area, as in UFDs.
23+
;Word 2 points to the end of the data area.
24+
;Word 3 is used to tell when the archive needs to be cleaned
25+
; because it is being touched for the first time since the system came up.
26+
;Word 4 contains what is supposed to be the creation date of the archive.
27+
; Since locking the archive device clobbers the creation date,
28+
; we store it here so we can restore it after clobbering it.
29+
;Word 5 similarly stores the dumped bit.
30+
31+
;There is nothing analogous to the "descriptors" in a disk UFD.
32+
33+
;Random info in UFD
34+
UDESCP==0 ;SIXBIT /ARC1!!/
35+
UDNAMP==1 ;Address in directory of first filename block.
36+
UDDATP==2 ;Address of first free word past data area of last file.
37+
UDINIT==3 ;Time of startup of last run of system during which this
38+
;archive was cleaned (ARCCLN). If not same as startup time
39+
;of this run of the system, we must do ARCCLN.
40+
UDCRDT==4 ;This word holds what ought to be the creation date
41+
;of the archive device file itself.
42+
;0 => this archive antedates the UDCRDT word, in which
43+
;case it gets set from today's date.
44+
UDDMPB==5 ;This is like UDCRDT but stores the dumped bit.
45+
46+
UDNMIN==10 ;If UDNAMP is less than this, there is no room for another filename block.
47+
48+
;In each filename block, the UNFN1, UNFN2, UNDATE and UNREF words are
49+
;just as in UFDs. The UNRNDM word is slightly different:
50+
51+
LUNBLK==5 ;Number of words in each filename block.
52+
UNFN1==0 ;First file name.
53+
UNFN2==1 ;Second file name.
54+
UNRNDM==2 ;All kinds of random info:
55+
;The RH is the address in the file of the start of the file's data area header.
56+
;The LH contains these bits:
57+
UNWRIT==4 ;Open for writing. Not actually maintained in the archive,
58+
;Just reflected to the user when he reads ARC:.FILE. (DIR).
59+
UNCDEL==20 ;Delete this file when it is closed.
60+
UNIGFL==24 ;Bits to ignore file
61+
UNWRDC==301200,, ;Word count of last block mod 2000.
62+
;This information really lives in UHWCNT, and is just reflected
63+
;here when the user reads the image directory.
64+
UNDATE==3 ;Date and time file last modified.
65+
UNTIM==2200,, ;Compacted time of creation
66+
UNYMD==222000,, ;Y,M,D of creation
67+
UNMON==270400,, ;Month
68+
UNDAY==220500,, ;Day
69+
UNYRB==330700,, ;Year
70+
UNREF==4 ;Reference date same as left half of undate
71+
UNREFD==222000,, ;Reference date byte pointer
72+
UNAUTH==111100,, ;MFD index of author, all 1=> no directory.
73+
UNBYTE==001100,, ;File byte size and length info.
74+
;LET S=BITS PER BYTE, C=COUNT OF UNUSED BYTES IN LAST WD
75+
;400+100xS+C S=1 TO 3 C=0 TO 35.
76+
;200+20xS+C S=4 TO 7 C=0 TO 8
77+
;44+4xS+C S=8 TO 18. C=0 TO 3
78+
;44-S S=19. TO 36. C=0
79+
;NOTE THAT OLD FILES HAVE UNBYTE=0 => S=36.
80+
81+
82+
;The data of a file starts with two words of header information:
83+
UHWCNT==0 ;Total length of the file's data, including header, in words.
84+
UHREFC==1 ;RH: Number of archives using the file, in either direction.
85+
;LH: -1 if file open for writing.
86+
UHNAMP==2 ;Unused
87+
UHBLEN==3 ;Length of this header; offset to 1st actual data word.
88+

itsarc.c

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* Copyright (C) 2017 Lars Brinkhoff <lars@nocrew.org>
2+
3+
This program is free software: you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, either version 2 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
16+
#include <stdio.h>
17+
18+
#include "dis.h"
19+
20+
#define NEW_ARC ((word_t)(0416243210101LL)) /* Sixbit ARC1!! */
21+
22+
extern word_t get_its_word (FILE *f);
23+
24+
/* Just allocate a full moby to hold the file. */
25+
static word_t buffer[256 * 1024];
26+
27+
static int
28+
byte_size (int code, int *leftovers)
29+
{
30+
if (code <= 17)
31+
{
32+
*leftovers = 0;
33+
return 044 - code;
34+
}
35+
else if (code <= 111)
36+
{
37+
*leftovers = (code & 3);
38+
return (code - 044) >> 2;
39+
}
40+
else if (code <= 248)
41+
{
42+
*leftovers = (code & 013);
43+
return (code - 0200) >> 4;
44+
}
45+
else
46+
{
47+
*leftovers = (code & 077);
48+
return (code - 0400) >> 6;
49+
}
50+
}
51+
52+
int
53+
main (int argc, char **argv)
54+
{
55+
char string[7];
56+
word_t word;
57+
word_t *p;
58+
FILE *f;
59+
60+
if (argc != 2)
61+
{
62+
fprintf (stderr, "Usage: %s <file>\n", argv[0]);
63+
exit (1);
64+
}
65+
66+
f = fopen (argv[1], "rb");
67+
file_36bit_format = FORMAT_ITS;
68+
69+
p = buffer;
70+
while ((word = get_its_word (f)) != -1)
71+
{
72+
*p++ = word;
73+
}
74+
75+
/* word_t arc_size = p - buffer; */
76+
77+
if (buffer[0] != NEW_ARC)
78+
{
79+
sixbit_to_ascii(buffer[0], string);
80+
fprintf (stderr, "First word: %012llo \"%s\"\n", buffer[0], string);
81+
fprintf (stderr, "Old ARC format. Not supported.\n");
82+
exit (1);
83+
}
84+
85+
word_t name_beg = buffer[1];
86+
/* word_t data_end = buffer[2]; */
87+
88+
fprintf (stderr, "Last cleanup: ");
89+
print_datime (stderr, buffer[3]);
90+
fputc ('\n', stderr);
91+
92+
fprintf (stderr, "Created: ");
93+
print_datime (stderr, buffer[4]);
94+
fputc ('\n', stderr);
95+
96+
word_t dumped = buffer[5];
97+
fprintf (stderr, "Dumped: %llo\n", dumped);
98+
99+
fprintf (stderr, "\nFile name Words Modified Referenced Byte\n");
100+
101+
int i;
102+
for (i = name_beg; i < 02000; i += 5)
103+
{
104+
sixbit_to_ascii(buffer[i], string);
105+
fprintf (stderr, "%s ", string);
106+
sixbit_to_ascii(buffer[i+1], string);
107+
fprintf (stderr, "%s ", string);
108+
109+
/* word_t flags = buffer[i+2] >> 18; */
110+
word_t data = buffer[i+2] & 0777777;
111+
112+
word_t length = buffer[data];
113+
/* word_t header = buffer[data+3]; */
114+
fprintf (stderr, "%6lld ", length);
115+
116+
print_datime (stderr, buffer[i+3]);
117+
fprintf (stderr, " (");
118+
print_date (stderr, buffer[i+4]);
119+
fputc (')', stderr);
120+
121+
int author = (buffer[i+4] >> 9) & 0777;
122+
if (author != 0 && author != 0777)
123+
fprintf (stderr, " Author %03o", author);
124+
125+
int leftovers;
126+
fprintf (stderr, " %d\n",
127+
byte_size (buffer[i+4] & 0777, &leftovers));
128+
}
129+
130+
return 0;
131+
}

0 commit comments

Comments
 (0)