Fullscreen patch utility (QNX)
spatch [-bp] file [offset] spatch -m pid selector offset
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, you'll see 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 type Enter.
The commands are as follows:
This pattern: | Matches: |
---|---|
61 62 63 d e | the 5 characters "abcde" |
a b c d e | the 5 characters "abcde" |
If you specify a directory in the file argument, the disk will be edited, but spatch will move 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 will be the first block of the named file). If the named file has extents, spatch won't thread through those extents, but will go to the next sequential block.
You can use spatch to recover lost files or directories. For more information, see the QNX Installation & Configuration manual.
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
You may not use the spatch utility on a disk when there are open files on the disk, unless the -b (browse) option is used.