xref: /freebsd/usr.sbin/fdread/fdread.1 (revision 8ccc0d235c226d84112561d453c49904398d085c)
1.\"
2.\" Copyright (c) 2001 Joerg Wunsch
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\"
27.Dd November 16, 2025
28.Dt FDREAD 1
29.Os
30.Sh NAME
31.Nm fdread
32.Nd read floppy disks
33.Sh SYNOPSIS
34.Nm
35.Op Fl qr
36.Op Fl d Ar device
37.Op Fl f Ar fillbyte
38.Op Fl o Ar file
39.Nm
40.Op Fl d Ar device
41.Fl I Ar numsects
42.Op Fl t Ar trackno
43.Sh DEPRECATION NOTICE
44.Nm
45is deprecated and may not be present in
46.Fx 16.0
47and later.
48.Sh DESCRIPTION
49The
50.Nm
51utility reads floppy disks.
52Effective read blocking based on the track
53size is performed, and floppy-specific error recovery of otherwise
54bad blocks can be enabled.
55.Pp
56The
57.Nm
58utility
59will always read an entire floppy medium, and write its contents to
60the respective output file.
61Unlike other tools like
62.Xr dd 1 ,
63.Nm
64automatically uses a read block size that is more efficient than
65reading single blocks (usually one track of data at a time), but
66falls back to reading single floppy sectors in case of an input/output
67error occurred, in order to obtain as much valid data as possible.
68While
69.Nm
70is working, kernel error reporting for floppy errors is turned off, so
71the console and/or syslog are not flooded with kernel error messages.
72.Pp
73The
74.Nm
75utility accepts the following options:
76.Bl -tag -width indent
77.It Fl q
78Turn on quiet mode.
79By default, the medium parameters of the device
80are being written to standard error output, progress will be indicated
81by the approximate number of kilobytes read so far, and errors will be
82printed out in detail, including the information about the location of
83recovered data in the output.
84In quiet mode, none of these messages
85will be generated.
86.It Fl r
87Enable error recovery.
88By default,
89.Nm
90stops after the first unrecovered read error, much like
91.Xr dd 1
92does.
93In recovery mode, however, one of two recovery actions will be
94taken:
95.Bl -bullet
96.It
97If the error was a CRC error in the data field, the
98kernel is told to ignore the error, and data are transferred to the
99output file anyway.
100.Bf -emphasis
101Note that this will cause the erroneous data
102to be included in the output file!
103.Ef
104Still, this is the best recovery action that can be taken at all.
105.It
106All other errors are really fatal (usually, the FDC did not find the
107sector ID fields), thus a dummy block with fill
108bytes will be included in the output file.
109.El
110.Pp
111Unless operating in quiet mode, the action taken and the location of
112the error in the output file will be displayed.
113.It Fl d Ar device
114Specify the input floppy device, defaulting to
115.Pa /dev/fd0 .
116The parameter
117.Ar device
118must be a valid floppy disk device.
119.It Fl f Ar fillbyte
120Value of the fill byte used for dummy blocks in the output file in
121recovery mode.
122Defaults to
123.Ql 0xf0 .
124(Mnemonic:
125.Dq foo . )
126The value can be specified using the usual C language notation of
127the number base.
128.It Fl o Ar file
129Specify the output file to be
130.Ar file .
131By default, the data will be written to standard output.
132.It Fl I Ar numsects
133Read
134.Ar numsects
135sector ID fields, and write out their contents to standard output.
136Each sector ID field contains recorded values for the cylinder number
137.Pq Ql C ,
138the head number
139.Pq Ql H ,
140the record number (sector number starting with 1)
141.Pq Ql R ,
142and the
143.Em sector shift value
144(0 = 128 bytes, 1 = 256 bytes, 2 = 512 bytes, 3 = 1024 bytes)
145.Pq Ql N .
146The
147.Fl I
148option is mutually exclusive with all other options except
149.Fl d Ar device
150and
151.Fl t Ar trackno .
152.It Fl t Ar trackno
153Specify the track number (cylinder number * number of heads + head
154number) to read the sector ID fields from; only allowed together with
155the
156.Fl I Ar numsects
157option.
158.El
159.Sh FILES
160.Bl -tag -width /dev/fd0
161.It Pa /dev/fd0
162Default device to read from.
163.El
164.Sh EXIT STATUS
165The
166.Nm
167utility sets the exit value according to
168.Xr sysexits 3 .
169In recovery mode, the exit value will be set to
170.Dv EX_IOERR
171if any error occurred during processing (even in quiet mode).
172.Sh DIAGNOSTICS
173Unless running in quiet mode, upon encountering an error, the status
174of the floppy disc controller (FDC) will be printed out, both in
175hexadecimal form, followed by a textual description that translates
176those values into a human-readable form for the most common error
177cases that can happen in a PC environment.
178.Pp
179The FDC error status includes the three FDC status registers
180.Ql ST0 ,
181.Ql ST1 ,
182and
183.Ql ST2 ,
184as well as the location of the error (physical cylinder, head, and sector
185number, plus the
186.Dq sector shift value ,
187respectively).
188See the manual for the NE765 or compatible for details
189about the status register contents.
190.Pp
191The FDC's status is then examined to determine whether the error is
192deemed to be recoverable.
193If error recovery was requested, the
194location of the bad block in the output file is indicated by its
195(hexadecimal) bounds.
196Also, a summary line indicating the total number
197of transfer errors will be printed before exiting.
198.Sh SEE ALSO
199.Xr dd 1 ,
200.Xr fdwrite 1 ,
201.Xr sysexits 3 ,
202.Xr fdc 4 ,
203.Xr fdcontrol 8
204.Sh HISTORY
205The
206.Nm
207utility was written mainly to provide a means of recovering at least some of
208the data on bad media, and to obviate the need to invoke
209.Xr dd 1
210with too many hard to memorize options that might be useful to handle
211a floppy.
212.Pp
213The command appeared in
214.Fx 5.0 .
215.Sh AUTHORS
216Program and man page by
217.An J\(:org Wunsch .
218.Sh BUGS
219Concurrent traffic on the second floppy drive located at the same FDC
220will make error recovery attempts pointless, since the FDC status
221obtained after a read error occurred cannot be guaranteed to actually
222belong to the erroneous transfer.
223Thus using option
224.Fl r
225is only reliable if
226.Ar device
227is the only active drive on that controller.
228.Pp
229No attempt beyond the floppy error retry mechanism of
230.Xr fdc 4
231is made in order to see whether bad sectors could still be read
232without errors by trying multiple times.
233.Pp
234Bits that are (no longer) available on the floppy medium cannot be
235guessed by
236.Nm .
237