.;- DK:DIRMV.RNO DATE: 31-MAY-83 TIME: 22:46:18 .ap;.ps 58,74;.lm 4;.uc .c;CREATION AND HANDLING OF MULTI-VOLUME .c;DIRECTORIES UNDER RT-11 WITH TECO .s 2 .c;Dr. M. van Swaay .c;Department of Computer Science .c;Kansas State University .c;Manhattan, KS 66506 .s 3;.lm 10;.rm 68 A set of TECO macro's has been designed to create, maintain, and search master directory files extending over 50 or more floppy volumes. A directory file may occupy all available space on a disk volume, but updating is possible only if space is available for both the current directory file and for the updated version. For practical reasons directory files should therefore be limited to not more than half the space available on one disk volume. Comments may be added to each entry in the directory file. The search routine supports wildcard search patterns similar to those available in DIR. .s 3;.lm 4;.rm 74 Users of small RT-11 systems with floppy disk storage may easily accumulate 100 or more volumes of data, programs, text, etc. With such a large collection, locating individual files can become a major chore, requiring lengthy scanning of displayed or printed directories. A master directory extending over many disk volumes will allow more efficient searching. Unfortunately there will rarely be enough space on the system volume to hold or create such a master directory. Therefore, the master will have to be constructed and maintained on the non-system spindle. The same spindle will also have to hold each input volume while its directory is read for construction or updating of the master directory file. Under the constraints described above, a package dealing with a master directory must include a tool that will allow swapping of disk volumes on the non-system spindle without risk of overwriting of output data onto an input volume. Major uses of a master directory directory file will be the searching for individual files or classes of files, and the recording of additional information beyond the file name. Both commenting and search operations point to the use of an editor. TECO not only handles these operations well, but also provides the flexibility to handle the creation and updating of master directory files. TECO can gain access to volume ID records by virtue of an undocumented but reliable feature built into DUP: during initialization of a volume, DUP writes the string DECRT11A at locations 760-767(8) of block 1 of the volume. The bytes immediately preceding this string (from 730-757(8)) receive the volume ID and owner's name. To retrieve the volume ID, TECO can open the volume as a non-file input device, after which a search for the string DECRT11A and backtrack over 32 bytes will position the text pointer in front of the volume ID record. To retrieve file information on a volume, a TECO program can use the NEXTFILE (EN$) command after an initial wildcard filespec of EN*.*$. Thus the command string .s;.c;EN*.*$<:EN$;G*13I$10I$> .s;will collect the names of all files on the volume into the text buffer. Both the access of the volume ID and the retrieval of all file names are performed by TECO without help from USR, which does not know about volume ID, and cannot handle wildcards. Because USR is not involved in the input activities for volume ID or file names, an output channel can be kept open without interference with the directory information cached by USR. Consequently it is possible to read multiple input volumes, and to write accumulated text periodically to a single output volume, all on the same spindle, without interference between the input and output operations. On the basis of the features described above, a set of TECO macro's has been developed to create, maintain, and search master directory files. Each function is started by execution of a TECO macro as a disk-resident command (EISY:file$$). The disk file installs various macro's in TECO registers X, Y, and Z for repetitive execution. The memory-resident macro's can be invoked by escape sequences that are recognized by a slightly enhanced version of the VT52 screen macro. The directory routines themselves are largely independent of terminal characteristics, but the VT52 screen macro is specific for the VT52 and its look-alikes. It should be possible to enhance screen macro's for other terminals to allow recognition of escape sequences that will invoke those directory routines that are called from the screen macro. The actual macro's do not lend themselves to printed media, but copies are available on RX01 media on request. Three major functions have been implemented; these will be described below. Each function is started by invocation of a disk-resident TECO macro of the same name with the EI command. .s;.c;==== MAKE ==== MAKE begins by opening an output file and recording the ID of the volume on which that file will be written. MAKE then installs a set of memory-resident routines for invocation from the screen macro. One of the routines collects volume ID and directory records from one input volume per command, and allows insertion of comments in the resulting list of files. When accumulated text exceeds 4096 characters the next read command is refused, and the user is prompted to mount the output volume, on which a directory file has been opened previously. MAKE will verify insertion of the appropriate volume by comparing its ID against the ID recorded by MAKE at the time the output file was opened. Text will be written only if the proper volume ID is found. After all accumulated text has been written, MAKE provides a choice between closing of the output file, or collection of more input. The size of the output file is limited only by the size of the output volume, although in practice it will be convenient to limit the size of the directory to less than half the volume size, to allow space for later updating. With an average record size of 50 characters per file entry (10 for file name and CRLF, plus 40 characters of comment), that establishes a capacity on RX01 disks of about 2000 file entries per directory file, or 50 volumes holding 40 files each. In addition to the automatic write sequences triggered by the growth of the accumulated text, write operations may be initiated by the user by means of a second escape sequence recognized by the enhanced screen macro. That will generally be necessary after the last input volume has been read. In either case, MAKE guards against output to the wrong volume by testing the volume ID. Because the volume ID of the volume holding the master directory performs such an important function, users should select an identification mark for that volume that differs decisively from all other ID marks used at the site. .s;.c;==== UPDATE ==== UPDATE is a set of routines that allow maintenance on a master directory. To perform an update, the volume holding the present master directory should be mounted first, and the directory file should be identified. The disk-resident UPDATE macro prompts the user for these actions. Enough free space should be available on the volume to receive the updated directory file. The presence of the directory file is verified, and the volume ID and file name are stored in memory by UPDATE for later use. Update volumes may next be submitted in random order; they may include volumes for which no entries exist in the present master directory. As each update volume is mounted, its ID and directory can be read by means of an escape sequence recognized by the screen macro. When the accumulated update text exceeds 4096 characters, or when the user explicitly requests a merge operation, the update routine directs the user to mount the output volume. As in MAKE, a test is made on the ID of the output volume. On approval of the volume, the directory file is opened in backup mode, and the file is read page by page. As each page is read, its volume ID is tested for presence in the update text. If the update text does not contain the volume ID of the current input page, that page is passed to output. If update information was collected on the volume described by the current input page, the two directory pages are merged. For all duplicate file entries, the entry in the update text is discarded, and the (commented) entry from the current master file is retained. Entries for which no duplicate is found in the update text are discarded, and new entries found only in the update text are appended to the text in the current directory page. All modified pages from the current directory file and all new pages representing volumes not previously known are retained in memory. After the entire input file has been processed, all modified and new pages are placed in the text buffer for commenting. After insertion of any desired comments the user must then close the new directory file with one of the standard TECO file-closing commands. The merge process is summarized by the code below. .S;.LIT OPEN/BACKUP MASTER DIRECTORY FILE WHILE NOT END-OF-FILE DO READ PAGE IF VOLUME ID NOT IN UPDATE LIST DO WRITE PAGE TO OUTPUT ELSE DO IF DUPLICATE ENTRY, RETAIN OLD ENTRY IF OLD ENTRY ONLY, DISCARD IT IF NEW ENTRY ONLY, APPEND TO CURRENT PAGE HOLD MODIFIED PAGE IN MEMORY END END IF MODIFIED PAGES AND/OR NEW PAGES DO PLACE ANY MODIFIED PAGES IN TEXT BUFFER APPEND ANY UN-PROCESSED UPDATE TEXT TO BUFFER INVITE COMMENTING ACCEPT CLOSE COMMAND FROM USER END CLOSE OUTPUT FILE .ELI .s;.c;==== FIND ==== FIND is the search routine. When invoked as a disk-resident macro, FIND accepts a file name for the directory file, and then installs memory-resident routines that will accept a search pattern and extract matching records from the directory file. The search pattern is explicitly taylored to search for files and groups of files by name: the name field is limited to six characters, and the type field, if present, cannot extend beyond three characters. A single <.> may be present in the pattern. The characters and <*> may be used as wildcards, with matching the group A-Z and 0-9, and * matching any single character, including . The name of the directory file is stored in memory by FIND, so that multiple searches may be performed. The search command itself is implemented as an escape sequence recognized by the enhanced screen macro. After each search, all matching records are presented for viewing and output to disk or printer, separated into groups according to the volume(s) on which the corresponding files reside. Although the package is primarily designed to handle master directories, it also provides a convenient tool to create and maintain README files on individual volumes. With a single volume serving both as output and as input, no volume swapping will be necessary, and comments may be added as needed. Whenever the content of the volume changes, an update pass on that volume, with the README file as input, will yield an up-to-date version without the need to re-enter comments on retained files. It was stated earlier that a practical limit for a master directory file is one half of the size of the storage volume. Some devious tricks make it possible to edit a file with TECO even if the file extends over more than half of a storage volume, or in general, to edit a file in-place. For in-place editing, the file should be opened with an ER command. Next an output file with the same name is opened with an EW command, after which that file is closed immediately with an EF command. Next an output file of appropriate length is reopened with an EW command. As long as no other running programs interfere and claim the briefly released space the new output file will be placed in the same position as the now deleted input file. During all these operations, however, the channel to the input text remains intact, so that read operations on that text will be handled normally. It then will be the responsibility of the user to guarantee that read operations always stay ahead of write operations, so that no unread input will be overwritten with new output. From the description it should be obvious that in-place editing carries substantial risks of data loss. For that reason no provisions have been made in the directory package for in-place editing, even though persons familiar with the TECO instruction set will find it quite possible to add that capability. That will increase the maximum size of the directory file to the full space available on one volume.