manipulating FLEX .dsk files - nealcrook/multicomp6809 GitHub Wiki

Resources

  • The PERL script flex_vfs in the bin/ area of this repository
  • Read this http://www.waveguide.se/?article=reading-flex-disk-images (you could download/compile the two programs that the author wrote, but my flex_vfs tool can now do all of that and much more)
  • The PERL script sd_image2flex_dsk in the bin/ area of this repository
  • The PERL script flex_disk_manip in the flex/ area of this repository

Introduction to flex_vfs

The script flex_vfs provides a command-line environment within which you can manipulate FLEX .dsk files of arbitrary geometries; it superceeds the functionality of the other tools mentioned here. More on this tool below.

If you have an SDcard image that contains the image of a FLEX disk, you can extract it using the sd_image2flex_dsk script. This script performs the reverse of the process that was used to insert the file into the SDcard image: first, it extracts an .img file then it processes the file with flex_disk_manip to bisect each 512-byte block into a 256-byte sector, creating a .dsk file.

Use flex_disk_manip -help to see what it can do. For example, use -dir -info to get a directory listing of a .dsk file.

Compile the cmd2bin.c and flextract.c programs. Use -h on each of them to get help. Refer to the author's article for more detailed examples.

Example flex_vfs session

From within flex_vfs, you can move files between disks of any geometry, copy, delete, etc. This means (eg) that you can copy files from any disk image to the 1474560-byte images expected by my 6809 multicomp FLEX port. Here is an example session. Note the extensive build-in help text.

./flex_vfs
flex_vfs: mount 1 sys.dsk
flex_vfs: mount 2 ADVENT.DSK dsk
flex_vfs: clone 1 new.dsk
flex_vfs: mount 3 new.dsk
flex_vfs: delete 3:*.*
flex_vfs: copy 2.*.CMD 3
flex_vfs: help

flex_vfs allows manipulation of up to 4 virtual drives, numbered 0 through 3.
Each drive can be associated with a file on the host filesystem. Files
can be copied between virtual drives or transferred between virtual drives
and the host filesystem. Virtual drives can be inspected and manipulated.

Usage:

    flex_vfs
    flex_vfs < script
    flex_vfs foo.bin
    flex_vfs *.bin

The first form starts an interactive session.
The second form runs a sequence of commands from a file (See 'help scripts').
The third form treats foo.bin as a disk image and does a mount/info/check/dir/exit.
The fourth form treats *.bin as a set of disk images and does a
mount/info/check/dir/exit on each image in turn.

Commands are:

    mount      - associate disk image with virtual drive number
    umount     - disconnect disk image from drive number
    info       - report virtual drives currently mounted
    clone      - make copy of virtual drive (optional format conversion)
    new        - create new empty disk image (optional geometry specification)
    copy       - copy file(s) from one virtual drive to another
    rename     - change name of file on virtual drive
    label      - change disk label/volume number/creation date
    type       - view file from virtual drive (optional format conversion)
    export     - copy file from virtual drive to local file system (optional format conversion)
    import     - copy file from local file system to virtual drive (optional format conversion)
    date       - set date
    dir        - directory of virtual drive
    hdir       - directory of local file system
    delete     - delete file(s) from virtual drive
    truncate   - delete sector(s) from file(s) from virtual drive
    create     - create file from sector(s) on the free list
    link       - patch boot sector on virtual drive
    fix        - perform low-level edit on virtual drive
    rdboot     - copy boot sector from virtual drive
    wrboot     - write boot sector to virtual drive
    rdbootfile - read boot sector from file on local file system
    check      - check integrity of virtual drive
    scrub      - null out deleted file names and unused sectors
    repair     - check and repair virtual drive
    uppercase  - treat all FLEX file specifiers as upper-case
    exit       - unmount all mounted drives and leave flex_vfs
    quit       - synonym for exit
    help       - this is it.

Other help topics: comments formats scripts conversions

Type help <command name> or help <topic> for more help.
flex_vfs: exit

Cookbook: use flex_vfs to create a new system disk

This recipe creates a new disk image named 'mydisk.dsk' and copies the minimum set of files from the multicomp09_flex.dsk image necessary to make the new disk into a bootable system disk.

flex_vfs: mount 0 multicomp09_flex.dsk
flex_vfs: new mydisk.dsk
flex_vfs: mount 1 mydisk.dsk
flex_vfs: copy 0.FLEX.SYS 1
flex_vfs: rdboot 0
flex_vfs: wrboot 1
flex_vfs: link 1.FLEX.SYS
flex_vfs: exit

If you want to do anything useful with the new disk you may want to copy files like DIR.CMD etc. to the new disk as well.

Cookbook: use flex_vfs to make an existing disk image bootable on Multicomp6809

This recipe makes an existing disk image (named 'mydisk.dsk') into a system disk that will boot on Multicomp6809.

flex_vfs: mount 0 multicomp09_flex.dsk
flex_vfs: mount 1 mydisk.dsk
flex_vfs: copy 0.FLEX.SYS 1
flex_vfs: rdboot 0
flex_vfs: wrboot 1
flex_vfs: link 1.FLEX.SYS
flex_vfs: exit

Caveats: I did not make the disk driver cope with different disk geometries so the only disks you can do this to are 80-track 72-sector disks. For any other geometry, use the next recipe

Cookbook: use flex_vfs to make a copy of an existing disk image and make it bootable on Multicomp6809

This recipe starts with an existing disk image (named 'existing.dsk') and makes a version of it that is bootable on Multicomp6809, even if the existing disk image uses a different geomety. The final image is named 'mydisk.dsk' and this recipe also uses the multicomp09_flex.dsk - as the source of the system/boot files.

(text that starts '--' is a comment - do not type it)

flex_vfs: mount 0 multicomp09_flex.dsk
flex_vfs: mount 1 DISK10.DSK
flex_vfs: new mydisk.dsk          -- defaults result in the correct geometry
flex_vfs: mount 2 mydisk.dsk      -- blank disk of the correct geometry
flex_vfs: copy 1.*.* 2            -- might include a "bad" FLEX.SYS so..
flex_vfs: copy 0.FLEX.SYS 2       -- ..the order is important. This is the Multicomp version
flex_vfs: rdboot 0
flex_vfs: wrboot 2                -- copy the boot sector
flex_vfs: link 2.FLEX.SYS         -- patch boot sector to reference FLEX.SYS start track/sector
flex_vfs: exit

Copying Random Access Files

Files that are shown in directory listings with the R attribute are Random Access Files. The most common example is ERRORS.SYS - an optional but useful file that turns FLEX error codes into textual messages.

The TSC "diagnostic utilities manual" explains that these files have 2 sectors at the start which contain a file sector map. This file sector map contains absolute track/sector references. Therefore, when a random access file is copied, the map becomes invalid (assuming the file occupies a different sequence of sectors on the destination disk). I'm not sure whether/how the FLEX COPY.CMD copes with this (I took a quick look at the code but could not see anything to handle it). flex_vfs does //not// cope with it - it copies the file sector map unchanged.

In order to make the random access file usable, you need to rebuild the file sector map. You can do this from within FLEX using the COPYR utility that is on the system disk. For example, if you need to fix up a copy of CLIB.LIB:

+++COPYR CLIB.LIB CLIB2.LIB
+++DELETE CLIB.LIB
+++RENAME CLIB2.LIB CLIB.LIB

This is rather annoying. The format of the file sector map is described in some detail but these files are not common enough for it to be worth coding up the rebuild algorithm within flex_vfs (if you disagree, feel free to send me the code!).

import/export commands

As well as transferring files between FLEX disk images, flex_vfs can also transfer files between the host filessystem and FLEX disk image, performing format conversions on the way. For example, it supports the FLEX text compression and binary record formats. These transfers are achieved using the 'import' and 'export' commands. For example:

flex_vfs: mount 0 test.dsk
flex_vfs: import 0 ../*.C xxx=compress

See "help conversions" for details.

Other flex_vfs delighters

  • If you invoke flex_vfs with a command-line argument it will treat it as the name of a FLEX disk and will mount it, check it and generate a directory listing.

  • flex_vfs will execute a command script piped to STDIN. This allows a fixed sequence of commands to be performed on a large number of disk images. For example, I wrote a script to extract the contents of a large set of disk images, with one directory for each image's extracted images. I then ran the tool "fdupes" to find files that were identical (or manybe more interesting, same-named files that had different content).

I //strongly// recommend that you take a backup of any .dsk file before you mess with it!! Let me know if you find any bugs in flex_vfs, or if you have requests for additional functionality.

⚠️ **GitHub.com Fallback** ⚠️