xref: /freebsd/usr.sbin/fdread/fdread.1 (revision 17d6c636720d00f77e5d098daf4c278f89d84f7b)
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.\" $FreeBSD$
27.\"
28.\"
29.Dd May 14, 2001
30.Os
31.Dt FDREAD 1
32.Sh NAME
33.Nm fdread
34.Nd read floppy disks
35.Sh SYNOPSIS
36.Nm
37.Op Fl qr
38.Op Fl d Ar device
39.Op Fl f Ar fillbyte
40.Op Fl o Ar file
41.Nm
42.Op Fl d Ar device
43.Fl I Ar numsects
44.Op Fl t Ar trackno
45.Sh DESCRIPTION
46The
47.Nm
48utility reads floppy disks.  Effective read blocking based on the track
49size is performed, and floppy-specific error recovery of otherwise
50bad blocks can be enabled.
51.Pp
52.Nm
53will always read an entire floppy medium, and write its contents to
54the respective output file.  Unlike other tools like
55.Xr dd 1 ,
56.Nm
57automatically uses a read block size that is more efficient than
58reading single blocks (usually one track of data at a time), but
59falls back to reading single floppy sectors in case of an input/output
60error occurred, in order to obtain as much valid data as possible.
61While
62.Nm
63is working, kernel error reporting for floppy errors is turned off, so
64the console and/or syslog are not flooded with kernel error messages.
65.Pp
66The
67.Nm
68utility accepts the following options:
69.Bl -tag -width indent
70.It Fl q
71Turn on quiet mode.  By default, the medium parameters of the device
72are being written to standard error output, progress will be indicated
73by the approximate number of kilobytes read so far, and errors will be
74printed out in detail, including the information about the location of
75recovered data in the output.  In quiet mode, none of these messages
76will be generated.
77.It Fl r
78Enable error recovery.  By default,
79.Nm
80stops after the first unrecovered read error, much like
81.Xr dd 1
82does.  In recovery mode, however, one of two recovery actions will be
83taken:
84.Bl -bullet
85.It
86If the error was a CRC error in the data field, the
87kernel is told to ignore the error, and data are transferred to the
88output file anyway.
89.Bf -emphasis
90Note that this will cause the erroneous data
91to be included in the output file!
92.Ef
93Still, this is the best recovery action that can be taken at all.
94.It
95All other errors are really fatal (usually, the FDC didn't find the
96sector ID fields), thus a dummy block with fill
97bytes will be included in the output file.
98.El
99.Pp
100Unless operating in quiet mode, the action taken and the location of
101the error in the output file will be displayed.
102.It Fl d Ar device
103Specify the input floppy device, defaulting to
104.Pa /dev/fd0 .
105The parameter
106.Ar device
107must be a valid floppy disk device.
108.It Fl f Ar fillbyte
109Value of the fill byte used for dummy blocks in the output file in
110recovery mode.  Defaults to
111.Ql 0xf0 .
112(Mnemonic:
113.Dq foo . )
114The value can be specified using the usual C language notation of
115the number base.
116.It Fl o Ar file
117Specify the output file to be
118.Ar file .
119By default, the data will be written to standard output.
120.It Fl I Ar numsects
121Read
122.Ar numsects
123sector ID fields, and write out their contents to standard output.
124Each sector ID field contains recorded values for the cylinder number
125.Pq Ql C ,
126the head number
127.Pq Ql H ,
128the record number (sector number starting with 1)
129.Pq Ql R ,
130and the
131.Em sector shift value
132(0 = 128 bytes, 1 = 256 bytes, 2 = 512 bytes, 3 = 1024 bytes)
133.Pq Ql N .
134The
135.Fl I
136option is mutually exclusive with all other options except
137.Fl d Ar device
138and
139.Fl t Ar trackno .
140.It Fl t Ar trackno
141Specify the track number (cylinder number * number of heads + head
142number) to read the sector ID fields from; only allowed together with
143the
144.Fl I Ar numsects
145option.
146.El
147.Sh FILES
148.Bl -tag -width /dev/fd0
149.It Pa /dev/fd0
150Default device to read from.
151.El
152.Sh DIAGNOSTICS
153.Nm
154sets the exit value according to
155.Xr sysexits 3 .
156In recovery mode, the exit value will be set to
157.Dv EX_IOERR
158if any error occurred during processing (even in quiet mode).
159.Pp
160Unless running in quiet mode, upon encountering an error, the status
161of the floppy disc controller (FDC) will be printed out, both in
162hexadecimal form, followed by a textual description that translates
163those values into a human-readable form for the most common error
164cases that can happen in a PC environment.
165.Pp
166The FDC error status includes the three FDC status registers
167.Ql ST0 ,
168.Ql ST1 ,
169and
170.Ql ST2 ,
171as well as the location of the error (physical cylinder, head, and sector
172number, plus the
173.Dq sector shift value ,
174respectively).  See the manual for the NE765 or compatible for details
175about the status register contents.
176.Pp
177The FDC's status is then examined to determine whether the error is
178deemed to be recoverable.  If error recovery was requested, the
179location of the bad block in the output file is indicated by its
180(hexadecimal) bounds.  Also, a summary line indicating the total number
181of transfer errors will be printed before exiting.
182.Sh SEE ALSO
183.Xr dd 1 ,
184.Xr fdwrite 1 ,
185.Xr sysexits 3 ,
186.Xr fdc 4 ,
187.Xr fdcontrol 8
188.Sh HISTORY
189The
190.Nm
191utility was written mainly to provide a means of recovering at least some of
192the data on bad media, and to obviate the need to invoke
193.Xr dd 1
194with too many hard to memorize options that might be useful to handle
195a floppy.
196.Pp
197The command appeared in
198.Fx 5.0 .
199.Sh AUTHORS
200Program and man page by
201.An J\(:org Wunsch .
202.Sh BUGS
203Concurrent traffic on the second floppy drive located at the same FDC
204will make error recovery attempts pointless, since the FDC status
205obtained after a read error occurred cannot be guaranteed to actually
206belong to the erroneous transfer.  Thus using option
207.Fl r
208is only reliable if
209.Ar device
210is the only active drive on that controller.
211.Pp
212No attempt beyond the floppy error retry mechanism of
213.Xr fdc 4
214is made in order to see whether bad sectors could still be read
215without errors by trying multiple times.
216.Pp
217Bits that are (no longer) available on the floppy medium cannot be
218guessed by
219.Nm .
220