2024-01-17 21:03:09 -07:00
|
|
|
.\" Copyright (c) 2024 DTB <trinity@trinity.moe>
|
2024-03-26 18:26:51 -06:00
|
|
|
.\" Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
2024-01-17 21:03:09 -07:00
|
|
|
.\"
|
|
|
|
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
|
|
|
|
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-06-21 03:23:39 -06:00
|
|
|
.TH DJ 1 2024-06-17 "Bonsai Core Utilites 0.13.11"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH NAME
|
|
|
|
dj \(en disk jockey
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH SYNOPSIS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-01-09 23:43:45 -07:00
|
|
|
dj
|
|
|
|
.RB ( -AdHnq )
|
|
|
|
.RB ( -a
|
|
|
|
.RB [ byte ])
|
|
|
|
.RB ( -c
|
|
|
|
.RB [ count ])
|
|
|
|
|
|
|
|
.RB ( -i
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBinput file\fP])
|
2024-01-09 23:43:45 -07:00
|
|
|
.RB ( -b
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBinput block size\fP])
|
2024-01-09 23:43:45 -07:00
|
|
|
.RB ( -s
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBinput offset\fP])
|
2024-01-09 23:43:45 -07:00
|
|
|
|
|
|
|
.RB ( -o
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBoutput file\fP])
|
2024-01-09 23:43:45 -07:00
|
|
|
.RB ( -B
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBoutput block size\fP])
|
2024-01-09 23:43:45 -07:00
|
|
|
.RB ( -S
|
2024-06-06 00:14:55 -06:00
|
|
|
[\fBoutput offset\fP])
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-06-05 17:15:42 -06:00
|
|
|
.SH DESCRIPTION
|
|
|
|
|
|
|
|
Perform precise read and write operations on files. This utility is useful for
|
2024-06-17 23:36:52 -06:00
|
|
|
reading and writing binary data to and from disks.
|
2024-06-05 17:15:42 -06:00
|
|
|
|
|
|
|
This manual page uses the terms \(lqskip\(rq and \(lqseek\(rq to refer to moving
|
|
|
|
to a specified byte by index in the input and output of the program
|
|
|
|
respectively. This language is inherited from the
|
|
|
|
.BR dd (1p)
|
2024-06-17 23:36:52 -06:00
|
|
|
utility and used here to decrease ambiguity.
|
2024-06-05 17:18:21 -06:00
|
|
|
|
|
|
|
When seeking or skipping to a byte, writing or reading starts at the byte
|
|
|
|
immediately subsequent to the specified byte.
|
2024-06-05 17:15:42 -06:00
|
|
|
.\"
|
2024-03-26 23:58:00 -06:00
|
|
|
.SH OPTIONS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-i\fP
|
2024-05-24 10:03:52 -06:00
|
|
|
Takes a file path as an argument and opens it for use as an input.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-b\fP
|
2024-06-17 23:36:52 -06:00
|
|
|
Takes a numeric argument as the size in bytes of the input buffer, the default
|
|
|
|
being 1024.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-s\fP
|
2024-04-28 20:42:44 -06:00
|
|
|
Takes a numeric argument as the number of bytes to skip into the input
|
|
|
|
before starting to read. If the standard input is used, bytes read to this point
|
|
|
|
are discarded.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-o\fP
|
2024-05-24 10:06:15 -06:00
|
|
|
Takes a file path as an argument and opens it for use as an output.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-B\fP
|
2024-03-26 18:26:51 -06:00
|
|
|
Does the same as
|
|
|
|
.B -b
|
|
|
|
but for the output buffer.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-S\fP
|
2024-06-05 17:15:42 -06:00
|
|
|
Seeks a number of bytes through the output before starting to write from
|
2024-04-18 08:38:48 -06:00
|
|
|
the input. If the output is a stream, null characters are printed.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-a\fP
|
2024-06-17 23:36:52 -06:00
|
|
|
Accepts a single literal byte with which the input buffer is padded in the event
|
2024-04-18 08:40:29 -06:00
|
|
|
of an incomplete read from the input file.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-A\fP
|
2024-05-24 09:56:44 -06:00
|
|
|
Specifying this option pads the input buffer with null bytes in the event of an
|
2024-06-17 23:36:52 -06:00
|
|
|
incomplete read. This is equivalent to specifying
|
2024-04-28 20:42:44 -06:00
|
|
|
.B -a
|
2024-06-02 18:47:14 -06:00
|
|
|
with a null byte instead of a character.
|
|
|
|
.IP \fB-c\fP
|
2024-06-17 23:36:52 -06:00
|
|
|
Specifies a number of reads to make. The default is 0, in which case the
|
2024-05-24 10:13:59 -06:00
|
|
|
input is read until a partial or empty read is made.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-d\fP
|
2024-03-29 16:14:27 -06:00
|
|
|
Prints invocation information before program execution as described in the
|
2024-06-17 23:36:52 -06:00
|
|
|
DIAGNOSTICS section. Each invocation increments the debug level of the
|
2024-03-29 16:14:27 -06:00
|
|
|
program.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-H\fP
|
2024-04-28 20:42:44 -06:00
|
|
|
Prints diagnostics messages in a human-readable manner as described in the
|
2024-06-17 23:36:52 -06:00
|
|
|
DIAGNOSTICS section.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-n\fP
|
2024-06-17 23:36:52 -06:00
|
|
|
Retries failed reads once before exiting.
|
2024-06-02 18:47:14 -06:00
|
|
|
.IP \fB-q\fP
|
2024-03-26 18:26:51 -06:00
|
|
|
Suppresses error messages which print when a read or write is partial or
|
2024-03-27 00:08:43 -06:00
|
|
|
empty. Each invocation decrements the debug level of the program.
|
2024-06-05 17:15:42 -06:00
|
|
|
.\"
|
2024-03-27 00:08:43 -06:00
|
|
|
.SH STANDARD INPUT
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-05-24 10:14:53 -06:00
|
|
|
The standard input shall be used as an input if no inputs are specified or if
|
2024-06-02 18:47:14 -06:00
|
|
|
one or more of the input files is \(lq-\(rq.
|
|
|
|
.\"
|
2024-06-17 23:36:52 -06:00
|
|
|
.SH STANDARD OUTPUT
|
|
|
|
The standard output shall be used as an output if no inputs are specified or if
|
|
|
|
one or more of the input files is \(lq-\(rq.
|
|
|
|
.\"
|
2024-03-26 18:26:51 -06:00
|
|
|
.SH DIAGNOSTICS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-06-17 23:36:52 -06:00
|
|
|
On a partial or empty read, unless the
|
2024-01-09 23:43:45 -07:00
|
|
|
.B -q
|
2024-06-17 23:36:52 -06:00
|
|
|
option is specified, a diagnostic message is printed. Then, the program exits
|
|
|
|
unless the
|
2024-01-09 23:43:45 -07:00
|
|
|
.B -n
|
2024-06-17 23:36:52 -06:00
|
|
|
option is specified.
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-05-24 10:21:06 -06:00
|
|
|
By default, statistics are printed for input and output to the standard error in
|
2024-03-26 18:26:51 -06:00
|
|
|
the following format:
|
2024-01-09 23:43:45 -07:00
|
|
|
|
2024-03-26 18:26:51 -06:00
|
|
|
.RS
|
2024-06-06 00:14:55 -06:00
|
|
|
{records read} {ASCII unit separator} {partial records read}
|
|
|
|
{ASCII record separator} {records written} {ASCII unit separator}
|
|
|
|
{partial records written} {ASCII group separator} {bytes read}
|
|
|
|
{ASCII record separator} {bytes written} {ASCII file separator}
|
2024-03-26 18:26:51 -06:00
|
|
|
.RE
|
|
|
|
|
2024-04-18 08:44:44 -06:00
|
|
|
This format for diagnostic output is designed to be machine-parseable for
|
|
|
|
convenience. For a more human-readable format, the
|
2024-01-09 23:43:45 -07:00
|
|
|
.B -H
|
2024-04-18 08:44:44 -06:00
|
|
|
option may be specified. In this event, the following format is used instead:
|
2024-03-26 18:26:51 -06:00
|
|
|
|
|
|
|
.RS
|
2024-06-06 00:14:55 -06:00
|
|
|
{records read} '+' {partial records read} '>' {records written}
|
|
|
|
'+' {partial records written} ';' {bytes read} '>' {bytes written}
|
|
|
|
{ASCII line feed}
|
2024-03-26 18:26:51 -06:00
|
|
|
.RE
|
|
|
|
|
2024-03-29 16:14:27 -06:00
|
|
|
If the
|
|
|
|
.B -d
|
2024-06-17 23:36:52 -06:00
|
|
|
option is specified, debug information will be printed at the beginning of
|
|
|
|
execution. This output contains information regarding how the program was
|
|
|
|
invoked. The following example is the result of running the program with
|
2024-03-29 16:14:27 -06:00
|
|
|
.B -d
|
|
|
|
as the only argument:
|
|
|
|
|
|
|
|
.RS
|
2024-06-06 00:14:55 -06:00
|
|
|
argv0=dj
|
|
|
|
in=<stdin> ibs=1024 skip=0 align=ff count=0
|
|
|
|
out=<stdout> obs=1024 seek=0 debug= 3 noerror=0
|
2024-03-29 16:14:27 -06:00
|
|
|
.RE
|
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
In non-recoverable errors that don\(cqt pertain to the read-write cycle, a
|
2024-03-26 19:22:30 -06:00
|
|
|
diagnostic message is printed and the program exits with the appropriate
|
2024-06-05 20:39:37 -06:00
|
|
|
.BR sysexits.h (3)
|
|
|
|
status.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH BUGS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-01-09 23:43:45 -07:00
|
|
|
If
|
|
|
|
.B -n
|
2024-05-24 10:21:06 -06:00
|
|
|
is specified along with the
|
|
|
|
.B -c
|
2024-06-17 23:36:52 -06:00
|
|
|
option and a count, actual byte output is the product of the count and the input
|
|
|
|
block size and therefore may be lower than expected. If the
|
2024-01-09 23:43:45 -07:00
|
|
|
.B -a
|
|
|
|
or
|
|
|
|
.B -A
|
2024-06-17 23:36:52 -06:00
|
|
|
options are specified, this could make written data nonsensical.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-03-27 00:08:43 -06:00
|
|
|
.SH CAVEATS
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-03-27 00:14:02 -06:00
|
|
|
Existing files are not truncated on ouput and are instead overwritten.
|
2024-03-27 00:08:43 -06:00
|
|
|
|
2024-05-24 10:21:06 -06:00
|
|
|
Many lowercase options have capitalized variants and vice-versa which can be
|
|
|
|
confusing. Capitalized options tend to affect output or are more intense
|
|
|
|
versions of lowercase options.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH RATIONALE
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-06-03 23:21:00 -06:00
|
|
|
This program was based on the
|
|
|
|
.BR dd (1p)
|
|
|
|
utility as specified in POSIX. While character conversion may have been the
|
|
|
|
original intent of
|
|
|
|
.BR dd (1p),
|
|
|
|
it is irrelevant to its modern use. Because of this, this program eschews
|
|
|
|
character conversion and adds typical option formatting, allowing seeks to be
|
|
|
|
specified in bytes rather than in blocks, allowing arbitrary bytes as padding,
|
|
|
|
and printing in a format that\(cqs easy for machines to parse.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH COPYRIGHT
|
2024-06-03 23:07:19 -06:00
|
|
|
|
2024-06-02 18:47:14 -06:00
|
|
|
Copyright \(co 2023 DTB. License AGPLv3+: GNU AGPL version 3 or later
|
2024-01-09 23:43:45 -07:00
|
|
|
<https://gnu.org/licenses/agpl.html>.
|
2024-06-02 18:47:14 -06:00
|
|
|
.\"
|
2024-01-09 23:43:45 -07:00
|
|
|
.SH SEE ALSO
|
2024-06-02 18:47:14 -06:00
|
|
|
.BR dd (1p)
|