CTSS: Files and directories
CTSS was not the first system to have a hard disk - that may have been the IBM RAMAC in 1956 - but as a time-sharing system it pioneered using the disk for online, multi-user, persistent random-access storage for user files and programs, as opposed to using the disk as a fast tape drive or a slow secondary memory.
Looking at its features, we can see how it evolved to match what users wanted. For example, the original filing system only allowed one person to read a particular file (or a directory) at a time, so there was no easy way for a group of people to work together on a file without taking copies of it. Features like common file directories and links were added to support this.
The IBM 1301 disk drive. Source: IBM manual
File names and types
As mentioned previously, each file name has two parts, with up to six characters for each part. (Six characters as a limit comes up a lot in CTSS, as 6 x 6 bit BCD characters would fit into a 36-bit machine word.) The two parts of the file name (called name1 and name2) are separated by a space when giving them to a command.
By convention, the second part of the name indicated the file type, eg
MAD for MAD source code or BSS for object files.
Metadata on the file directory included the record size and the number of records, so fixed record data files are supported.
Text files
Text files evolved over time. Initially card image or line-numbered files were used: these use 14 machine words (so 84 BCD characters) per line. This allows interchange with punched cards, with each card representing a line in the file. Especially at the start of CTSS, many users would have collections of cards for their programs and data, and would transfer from these to and from the disk. The line-numbered name refers to the convention for punched cards of having a sequence number in columns 73-80 so the order of cards could be recovered if you accidentally dropped the deck on the floor.
Although easy to access specific lines, the problem with this format is it is inefficient: a completely blank line would be represented by 14 words of space characters. Line-marked files offered a solution, where each line could have a variable length and the start of each line would have a marker and its length.
Later on - I think as a byproduct of doing Multics development on CTSS - ASCII format files were supported, with the familiar 8 bit encoding and variable line length. There was also support for 12-bit BCD files which packed 3 characters into a word and allowed lower case.
It is up to each program to decide what type of files it supports. The
MAD and FAP compilers accepted both card image and line-marked files,
but some other compilers only accepted one format. For editing files,
use EDC for card image and EDL for line-marked.
You can convert a card image file to a line-marked one with the
SQUASH command and go the other way with XPAND.
As an example, let's look at a two-line program stored as a card image
file HWC MAD and as a line-marked file HWL MAD. We use PRINT to
show how the two files look and PRBIN to show a binary dump.
Note that PRINT puts the line number at the start of the print out.
PRBIN will print in octal, with each two-digit number representing a
BCD character; for example, 60 is space and 00 is digit 0.
print hwc mad
W 1059.9
HWC MAD 01/11 1059.9
00010 PRINT COMMENT $HELLO, WORLD$
00020 END OF PROGRAM
R .016+.016
prbin hwc mad
W 1100.0
HWC MAD 01/11 1100.0
1 606060606060 606060606047 513145636023 464444254563 605330254343 467360664651
7 432453606060 606060606060 606060606060 606060606060 606060606060 606060606060
13 606060000000 010060606060 606060606060 606060606025 452460462660 475146275121
19 446060606060 606060606060 606060606060 606060606060 606060606060 606060606060
25 606060606060 606060606060 606060000000 020060606060
R .016+.016
print hwl mad
W 1101.7
HWL MAD 01/11 1101.7
PRINT COMMENT $HELLO, WORLD$
END OF PROGRAM
R .016+.016
prbin hwl mad
W 1101.8
HWL MAD 01/11 1101.8
1 777777000005 724751314563 602346444425 456360533025 434346736066 465143245357
7 777777000003 722545246046 266047514627 512144575757
R .000+.016
Directories and common files
Directories in CTSS are rooted in the single Master File Directory
(MFD) which contains pointers to several User File Directories
(UFD). Each user would have their own UFD named after their login
project number and name, eg M1416 GUEST. It is not possible to make
sub-directories under a UFD.
You can change to another user's directory with eg ATTACH M1416
ELIZA and return to your own directory with just ATTACH. But you
are only able to do this if the other user has given you access with
PERMIT.
Common files are UFDs intended for sharing. There are 5, numbered 1-5
and named CMFL01 to CMFL05. Although you could use ATTACH, the
simplest way to get to them is type COMFIL n where n is a number;
0 will return you to your own directory. On s709/ctss-kit, this is
how they are used
| COMFIL | Contents |
|---|---|
| 1 | Supervisor object code |
| 2 | System binaries and accounting files |
| 3 | Unused |
| 4 | System libraries |
| 5 | Unused |
You can also view other directories using LISTF without changing to
them by giving parameters. Foe example, the MAD compiler is stored as
MAD TSSDC. in common files 2. Here is two ways to see it.
listf (cfl2) MAD TSSDC.
W 1122.7
MAD TSSDC. 000 33 01/10/14
R .016+.033
comfil 2
W 1122.8
R .000+.000
listf MAD TSSDC.
W 1122.8
MAD TSSDC. 000 33 01/10/14
R .016+.000
COPY will allow you to take a copy of a file from common files to
your own UFD. Let's return home and grab that binary.
comfil 0
W 1123.9
R .016+.000
listf mad tssdc.
W 1124.1
NAMES NOT FOUND
MAD TSSDC.
R .016+.016
copy 2 mad tssdc.
W 1124.3
R .050+.016
listf mad tssdc.
W 1124.4
MAD TSSDC. 000 33 01/11/14
R .033+.016
UPDATE does the same in reverse, ie copies a file from your UFD to a
common file directory.
However there is no way in general to refer to a file in another
directory, so for example if you want to PRINT a file you would need
to change directory first rather than referring to a path to access
it.
File management
RENAME and DELETE work as expected. MOVE is used to copy a file
within the same UFD.
Links
CTSS also had a way to link a file name to another one. This is what we'd call a soft link today - there is a record pointing to a file name rather than multiple directory entries. This was often used to make files available to other users, for example having a common file entry point to the real file in a user's UFD. Links have a maximum depth of 2.
Permission to link must be granted via PERMIT, even to link to your
own files. So to make HELLO2 MAD point to HELLO MAD we could do:
permit hello mad 0 * *
W 1742.0
R .000+.016
link hello2 mad m1416 guest hello
W 1742.2
R .000+.016
listf
W 1742.3
10 FILES 14 RECORDS
NAME1 NAME2 MOD NOREC USED
PERMIT FILE 120 1 01/11/14
HELLO MAD 000 1
[...]
HELLO2 MAD 000 M1416 GUEST HELLO
R .016+.016
Note PERMIT saves permissions to PERMIT FILE rather than using
file metadata, and that the new link file is displayed at the end of
LISTF output in a special format.
UNLINK can be used to remove a link file.
Permissions
You can see the permissions field in the MOD column of the LISTF
output above. Like Unix there are three octal digits that can be
OR-ed together but the meaning is different
| Mode | Meaning |
|---|---|
--1 |
Temporary - file will be removed after next read |
--2 |
Secondary - file is being backed up and will be removed |
--4 |
Read-only |
-1- |
Write-only |
-2- |
Private - file can only be referenced by its owner |
1-- |
Protected - permissions can only be changed by its owner ted |
The effect of making a file both read- and write- only seems to be neither is permitted.
Permissions to delete a file come from whether it can be written to or not.
The command to change permissions is CHMODE which takes the file
names first and then the new mode at the end.
Further reading
The CTSS Programmer's Guide section AD discusses how the file system works, and sections AH.3 - 6 have further details on the commands mentioned in this post.
Questions, corrections, comments
I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com