spatch

Fullscreen patch utility (QNX Neutrino)

Syntax:

spatch [-bp] file [offset]

Runs on:

QNX Neutrino

Options:

-b
Browse only; don't allow the Save command. The file or disk is accessed in read-only mode.
-p
Pause before starting.
file
The file or disk to be examined.
offset
The address—in RAM, in the file, or on the disk—where the spatch is to begin (specified in hex).

Description:

The spatch utility provides fullscreen editing of files or disk blocks. The screen displays a 16-by-16 (256) byte image of the data being examined, similar to that shown here:

 Edit Next Prev Lastblk Home Goto Find Continue Save Addr Quit                 
000000000: 2E 28 6E 65 77 29 20 53  50 41 54 43 48 20 22 46 .(new) SPATCH "F
000000010: 75 6C 6C 20 73 63 72 65  65 6E 20 70 61 74 63 68 ull screen patch
000000020: 20 75 74 69 6C 69 74 79  22 1E 2E 28 73 79 6E 74  utility"..(synt
000000030: 61 78 29 1E 09 11 73 70  61 74 63 68 10 20 20 11 ax)...spatch.  .

000000040: 66 69 6C 65 10 20 20 AE  66 69 6C 65 6E 61 6D 65 file.  .filename
000000050: AF 1E 09 11 73 70 61 74  63 68 10 20 20 11 64 69 ....spatch.  .di
000000060: 73 6B 10 20 20 AE 64 72  69 76 65 AF 20 20 AE 62 sk.  .drive.  .b
000000070: 6C 6F 63 6B AF 1E 09 11  73 70 61 74 63 68 10 20 lock....spatch.

000000080: 20 11 6D 65 6D 10 20 20  AE 73 65 67 6D 65 6E 74  .mem.  .segment
000000090: AF 20 20 AE 6F 66 66 73  65 74 AF 1E 2E 28 65 78 .  .offset...(ex
0000000a0: 61 6D 70 6C 65 73 29 1E  09 11 73 70 61 74 63 68 amples)...spatch
0000000b0: 20 20 66 69 6C 65 20 20  2F 63 6D 64 73 2F 6C 73   file   /bin/ls

0000000c0: 1E 09 73 70 61 74 63 68  20 20 64 69 73 6B 20 20 ..spatch  disk
0000000d0: 31 20 20 31 1E 09 73 70  61 74 63 68 20 20 6D 65 1  1..spatch  me
0000000e0: 6D 20 20 62 30 30 30 20  20 30 10 1E 2E 28 73 74 m  b000  0...(st
0000000f0: 61 72 74 29 1E 53 50 41  54 43 48 20 69 73 20 61 art).SPATCH is a

At the top of the screen, there's a list of commands. To select a command, either type its first letter or move the cursor to the command (with the arrow keys) and press Enter.

The commands are as follows:

Edit
Enter the data area. Pressing Tab switches between hex and ASCII data entry. Pressing Esc returns you to the menu. The changed data isn't updated on the disk or in memory.
Next
Move forward 256 bytes. You can also press Pg Dn.
Prev
Move backward 256 bytes. You can also press Pg Up.
Home
Go to the start of the file, disk, or memory. You can also press the Home key.
Lastblk
Go to the last block of the file or disk. You can also press End.
Goto
Move to a specified address. The type of address depends on the source of the data (file or disk) and the address type.
Find
Search for a specified pattern, which may consist of single characters or hex digit pairs separated by a space. For example, the patterns 61 62 63 d e and a b c d e both match the five characters abcde.

To stop the search, press any key.

Continue
Find the next occurrence of the last pattern found. You typically use this command after a Find when searching.
Save
Save the current screen back to the source. If you don't issue this command, all changes made using Edit are lost as soon as you leave the current screen of data. The Save option is disabled if you specify the -b (browse) option.
Addr
Toggle between address types:
  • Absolute (default for FILE)
  • Disk Block:Offset (default for DISK)
Quit
Leave the spatch utility.

If you specify a directory in the file argument, the disk is edited, but spatch moves only through the blocks that make up the directory. This is similar to “spatching” a file, but if you wish to make changes, the disk must be opened for exclusive use as would any block special file.

To run spatch on a directory or a block special file, you must either be root or have write permission for the disk's block special file.

The offset argument lets you specify the address where spatch is to begin. If file is a regular file, the offset is a byte offset. If file is a block special file, the offset is a block:byte offset. If file is a block special file with a QNX filesystem on it, the offset may be the name of a file or directory (the beginning address is the first block of the named file). If the named file has extents, spatch doesn't thread through those extents, but goes to the next sequential block.

You can use spatch to recover lost files or directories. For more information, see the Working with Filesystems and Backing Up and Recovering Data chapters of the QNX Neutrino User's Guide.

Examples:

Patch the contents of the file /bin/ls:

spatch /bin/ls

Patch the contents of the block-special raw disk volume /dev/hd0:

spatch /dev/hd0

Environment variables:

TERM
Interpreted as the name of the terminal type.

Exit status:

0
Success.
> 0
An error occurred.

Caveats:

You may not use the spatch utility on a disk when there are open files on the disk, unless you specify the -b (browse) option.