Reading OS9 Disks in Linux Bob van der Poel Johann E. Klasek I've got too many disks in OS9 format...and I want to read some of them on my Linux box. So, I wrote this utility. If it is useful to you, please let me know. Also, if you create additional lines for the reados9 script--send them to me and I'll include it on the master copy. How it works ------------ The disk routines on a linux box can not be used to read os9 disks. Not only are there no file managers for this, but the linux drivers do not like disks with sectors numbered as 0. However, these is a relatively easy way around the problem. Just use fdrawcmd. The latest version of fdrawcmd can be found at http://fdutils.ltnb.lu. This package was developed with version 5.2, and I suggest that you use at least this version. fdrawcmd bypasses the operating system and reads/writes raw sectors from the floppy. Using this technique it is possible to copy most os9 disks to a Linux hard drive. To read a OS9 disk we have to first know the format of the disk. For this we have developed the os9guess utility (see instructions below). Once we have the format, we can run the os9read script and make an image of the disk on our hard drive. Once we have an image file, we can then extract files, etc. with the os9disk program. For additional information of an image you can look at the details of this volume with the program sector0. About hardware -------------- Some OS-9 formats are using single density (FM instead MFM) for track 0 on side 0 only. The intention was that even "old", only FM capable disk controllers should be enable to recognise the disk even the data is not reachable. Nowadays this "backward compatibility" is a serious problem for modern PC-based hardware, because they are not FM-aware anymore ... To come around this problem one have to collect old enough hardware as a reader system, e.g. (in use May 2011) Pentium II ISA bus based PC hardware (mainboard/BIOS with disabled on-board floppy controller) Adaptec AHA-1542CF (ISA-card, only floppy controller is used, Linux recognises it as "post-1991 82077") 5 1/4" floppy disk drive (NEC, Epson or similar) ATAPI-CDROM (to start a CDROM-based Linux distribution like Knoppix 3.4 - systems of this kind may not boot from SCSI-CDROM or even USB stick) os9guess -------- This C program simply loops though a number of possible disk formats used by OS9 and sees if it can read LSN0 from the disk. If a valid LSN0 is found, the program prints out some data. The important information is the number of sides, tracks, sectors, track offset and sector offset. A special case are formats where track 0 side 0 are just FM formated (single density) with a different sector count, the remaining disk is MFM (double density) formated. This can be analysed in detail with the sector0 tool. Once you have this information, you can use os9read. Maybe you have to customize the given diskformats or add a new one of the script os9read. Note that os9guess uses fdrawcmd to read the disk. If os9guess finds a 256 sector read succeeds, it reads that sector and tries to analyze it. Under normal operation it first checks the 4 byte word at offset $60 in LSN0 for a integrity code. If this fails, the next format is attempted. Color Computer (and other) disks have this lacking, so you can start os9guess with the -c option which skips the test. In this case look at "remaining= 0" status, which indicates that a sector has been successfully read. The other option for os9guess is the drive number. By default, os9guess uses drive 0 (what you call A: under MS-DOS). It assumes that this is mapped to /dev/fd0 under linux. Calling os9guess with a -1, -2 or -3 uses drive 1, 2 or 3. Again, os9guess assumes /dev/fd1, /dev/fd2, and /dev/fd3. If this doesn't match your setup you'll have to modify the source. os9read ------- This is a bash shell script which creates a disk image. When you run the script you will be presented with a menu of known disk formats. If the format you need is not there, you'll have to add it. Hopefully the layout is clear enough to do this easily. If the format is listed, enter the number at the prompt. Next, enter the drive number. Finally, enter a name for the disk image. The disk will be copied to that named file. Any existing images file with the same name will be overwritten! While fdrawcmd is running you'll see its diagnostics. For formats with track 0 side 0 single density (FM) an extended procedure is used. The first track is read with the separate script tr0 which does it iterative because some hardware setups may need several tries to read the whole track errorfree. The important line is the one reading: remaining = 0 If you get anything other than 0 here you might as well hit ctrl-c and abort the read since it isn't working. Once you have a disk image, you can use os9disk to read it. The following format are supported at this time Name TrOffset ScOffset Sides Tracks Sectors Track0 sectors (FM) ------------------------------------------------------------------------- 0 COCO 40/18 0 1 2 40 18 1. MM/1 80/36 0 0 2 80 36 2. MM/1 80/33 0 0 2 80 33 3. Univ 80/16 1 1 2 79 16 4. Coco 35/18 0 1 1 35 18 5. Coco 80/18 0 1 2 80 18 6. DD 80/16 0 0 2 80 16 10 os9disk ------- This program, written in C, will list the directory and extract files from an image file. When the program starts it compares the size information in LSN0 of the image to the disk file size. If they do not match, an error message is printed and the program exits. This is probably not the most complete test, but it seems to work for now. To run os9disk, follow the program name with the name of the image file and your options. The following options are currently supported: -s Display a short directory for the image file. This is the default operation. -d DIR Set the destination directory to DIR. By default the files are extracted to the current working directory. If DIR does not exist, it will be created. At this time only one level of directory can be created. -l Display a long directory. This is similar to the information you get with a 'dir -e' command in OS9. -L Display a long directory with added information. The entries for "." and ".." will be included as well as the create dates and the logical sector numbers of each files file descriptor. This is really only useful for debugging. -x Extract all files in the image. Currently there is no option to extract only specified files. -v Print some debug information to stdout. sector0 ------- A utility to interpret the contents of sector0 (LSN0) of an OS-9 disk/volume. Orginally written by Andrzej Kotanski, 1996, e-mail kotanski AT desy de, for OS-9. Ported for Linux and slightly extented by Johann Klasek j AT klasek at. Usage: ./sector0 IMAGEFILE Other Help ---------- To unpack os9 archives you'll need some programs. The lha which comes with some linux distributions does not appear to work on mm/1 lha files (don't know about coco). The source for lha is on www.rtsi.com and complies cleanly on linux. Krieder's ar will not compile on linux, however, Carl recently uploaded binaries which do to www.rtsi.com. I suggest, to avoid confusion with standard linux programs, you rename these to os9lha and os9ar.