Vision filesystem - How do I fix a corrupt file?



If the runtime receives a file status 98 on a Vision file it means the file has been corrupted.  How can the Vision file be fixed?


To recover a corrupt Vision file which is returning a file status 98, use the "-rebuild" option of the Acucobol file utility, vutil. Keep in mind that the Vision file system has redundancies built into it, so that different rebuild options (-k #) will use different algorithms to rebuild the file. If one fails, another may succeed.

At the end of a rebuild operation, you will be prompted with "Do you wish to replace the original file?" If N (NO) is chosen, the rebuilt file will be retained, such as it is, in the current working directory. It will be named VTMP####.

    * vutil -rebuild filename

    * vutil -rebuild -k 0 filename (rebuild on primary key)

    * vutil -rebuild -k 1 filename (rebuild on 1st alternate key)

    * vutil -rebuild -k 2 filename (rebuild on 2nd alternate key)

      ( ..... vutil -rebuild -k n filename rebuilds on nth alternate)

If the file is compressed, and none of the above options recover the entire file, try the same commands again but add the -c argument. This will undertake a rebuild while removing compression from the file. This will rebuild the file in a different binary configuration, which may resolve the problem.

Another option is to add the --slow switch which can avoid errors that a standard rebuild encounters.  (Note that it is not necessarily slower than a standard rebuild.)

If none of the above successfully rebuilds the file, then recovering as much data as possible is the next step. One possible strategy is to merge the most recent backup with all the VTMP#### files which you have accumulated by using the above rebuild commands.

Another option is to write a COBOL version of rebuild, which can easily be constructed.

This program would have the form:

  Open input Original-File

  Open output Master-File

  Start Original-File at Low Values

  Read Original-File Next Record

* Set Declaratives so that error 98's are trapped , and

* the response is to increment the current key by 1 in the

* least significant digit, and the start is re-tried.

* Code your Start with an Invalid Key phrase which does

* the same thing.

  Write Master-File.

the runtime configuration option, "ERRORS-OK" will need to be set to 1 in order to open the corrupt file.

Lastly, in some instances the file's header has become corrupt and the file is no longer recognized as a Vision file ("filename: Incorrect file type" on any vutil command). The pointer to the first record in a Vision file is always the same, so try replacing the first 512 bytes (the header) of a Vision file with the first 512 bytes of a Vision file created via open output using the same SELECT and FD as the broken file. Then use vutil -rebuild to rebuild the patched, broken file.

Old KB# 2686
Comment List