History log of /freebsd-current/usr.sbin/fdformat/fdformat.c
Revision Date Author Comments
# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 960536b6 14-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL instead of 0 for pointers and memory allocation.
malloc and realloc will return NULL pointer if it can't alloc memory.

MFC after: 4 weeks


# bcaa6ebc 21-Feb-2011 Rebecca Cran <brucec@FreeBSD.org>

The FD_FORM ioctl used to ignore errors from the floppy controller; now when
it encounters an error it returns an error from the ioctl.
Ignore any errors when using the FD_FORM ioctl.

PR: kern/103862
MFC after: 3 days


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 81f5cd99 24-Jun-2009 Joerg Wunsch <joerg@FreeBSD.org>

Drop the defunct FDOPT_NOERRLOG option from all the floppy utilities.
The kernel does not log floppy media errors anymore.

In fdcontrol, do always open the file descriptor in read-only mode so
it can operate on read-only media, as there is no longer a separate
control device to operate on.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 1b67be7b 20-Aug-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Rewrite of the floppy driver to make it MPsafe & GEOM friendly:

Centralize the fdctl_wr() function by adding the offset in
the resource to the softc structure.

Bugfix: Read the drive-change signal from the correct place:
same place as the ctl register.

Remove the cdevsw{} related code and implement a GEOM class.

Ditch the state-engine and park a thread on each controller
to service the queue.

Make the interrupt FAST & MPSAFE since it is just a simple
wakeup(9) call.

Rely on a per controller mutex to protect the bioqueues.
Grab GEOMs topology lock when we have to and Giant when
ISADMA needs it. Since all access to the hardware is
isolated in the per controller thread, the rest of the
driver is lock & Giant free.

Create a per-drive queue where requests are parked while
the motor spins up. When the motor is running the requests
are purged to the per controller queue. This allows
requests to other drives to be serviced during spin-up.

Only setup the motor-off timeout when we finish the last
request on the queue and cancel it when a new request
arrives. This fixes the bug in the old code where the motor
turned off while we were still retrying a request.

Make the "drive-change" work reliably. Probe the drive on
first opens. Probe with a recal and a seek to cyl=1 to
reset the drive change line and check again to see if we
have a media.

When we see the media disappear we destroy the geom provider,
create a new one, and flag that autodetection should happen
next time we see a media (unless a specific format is configured).

Add sysctl tunables for a lot of drive related parameters.
If you spend a lot of time waiting for floppies you can
grab the i82078 pdf from Intels web-page and try tuning
these.

Add sysctl debug.fdc.debugflags which will enable various
kinds of debugging printfs.

Add central definitions of our well known floppy formats.

Simplify datastructures for autoselection of format and
call the code at the right times.

Bugfix: Remove at least one piece of code which would have
made 2.88M floppies not work.

Use implied seeks on enhanced controllers.

Use multisector transfers on all controllers. Increase
ISADMA bounce buffers accordingly.

Fall back to single sector when retrying. Reset retry count
on every successful transaction.

Sort functions in a more sensible order and generally tidy
up a fair bit here and there.

Assorted related fixes and adjustments in userland utilities.

WORKAROUNDS:
Do allow r/w opens of r/o media but refuse actual write
operations. This is necessary until the p4::phk_bufwork
branch gets integrated (This problem relates to remounting
not reopening devices, see sys/*/*/${fs}_vfsops.c for details).

Keep PC98's private copy of the old floppy driver compiling
and presumably working (see below).

TODO (planned)

Move probing of drives until after interrupts/timeouts work
(like for ATA/SCSI drives).

TODO (unplanned)

This driver should be made to work on PC98 as well.

Test on YE-DATA PCMCIA floppy drive.

Fix 2.88M media.

This is a MT5 candidate (depends on the bioq_takefirst() addition).


# 624a58b6 06-Jan-2004 Eric Anholt <anholt@FreeBSD.org>

From PR:
In fdformat.c a closing parenthesis is at the wrong place. Instead of
adding sizeof _PATH_DEV + 1 to the length of argv[optind], the length of the
string starting (sizeof _PATH_DEV + 1) characters after argv[optind]'s
beginning (accessing junk memory if we jump over the terminating null
character) is passed to malloc().

PR: bin/60026
Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>


# 467a0b06 01-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

Include <string.h> for some prototypes, rather than depending on
pollution from <strings.h>.


# 1a6bed68 15-Dec-2001 Joerg Wunsch <joerg@FreeBSD.org>

Long promised major enhancement set for the floppy disk driver:

. The main device node now supports automatic density selection for
commonly used media densities. So you can stuff your 1.44 MB and
720 KB media into your drive and just access /dev/fd0, no questions
asked. It's all that easy, isn't it? :)

. Device density handling has been completely overhauled. The old way
of hardwired kernel density knowledge is no longer there. Instead,
the kernel now implements 16 subdevices per drive. The first
subdevice uses automatic density selection, while the remaining 15
devices are freely programmable. They can be assigned an arbitrary
name of the form /dev/fd[:digit]+.[:digit:]{1,4}, where the second
number is meant to either implement device names that are mnemonic
for their raw capacity (as it used to be), or they can alternatively
be created as "anonymous" devices like fd0.1 through fd0.15,
depending on the taste of the administrator. After creating a
subdevice, it is initialized to the maximal native density of the
respective drive type, so it needs to be customized for other
densities by using fdcontrol(8). Pseudo-partition devices (fd0a
through fd0h) are still supported as symlinks.

. The old hack to use flags 0x1 to always assume drive 0 were there is
no longer supported; this is now supposed to be done by wiring the
devices down from the loader via device flags. On IA32
architectures, the first two drives are looked up in the CMOS
configuration records though. On PCMCIA (i. e., the Y-E Data
controller of the Toshiba Libretto), a single drive is always
assumed.

. Other specialities like disabling the FIFO and not probing the drive
at boot-time are selected by per-controller or per-drive flags, too.

. Unit attentions (media has been changed) are supposed to be detected
now; density autoselection only occurs after a unit attention. (Can
be turned off by a per-drive flag, this will cause each Fdopen() to
perform the autoselection.)

. FM floppies can be handled now (on controllers that actually support
it -- not all do these days).

. Fdopen() can be told to avoid density selection by setting
O_NONBLOCK; this leaves the descriptor in a half-opened state where
only a few ioctls are accepted. This is necessary to run fdformat
on a device that uses automatic density selection (since you cannot
autoselect on an unformatted medium, obviously).

. Just differentiate between a plain old NE765 and the enhanced chips,
but don't try more; the existing code was wrong and only misdetected
the chips anyway.

BUGS and TODOs:

. All documentation update still needs to be done.

. Formatting not-so-standard format yields unpredictable results; i
have yet to figure out why this happens. "Standard" formats like
720 and 1440 KB do work, however.

. rc scripts are needed to setup device nodes with nonstandard
densities (like the old /dev/fdN.MMM we used to have).

. Obtaining device flags from the kernel environment doesn't work yet,
thus currently only drives that are present in (IA32) CMOS are
really detected. Someone who knows the odds and ends about device
flags is needed here, i can't figure out what i'm doing wrong.

. 2.88 MB still needs to be done.


# 4f0b1b78 03-Jul-2001 Joerg Wunsch <joerg@FreeBSD.org>

Make fdformat WARN=2 ready.


# e42ad56f 02-Jul-2001 Joerg Wunsch <joerg@FreeBSD.org>

Use the printstatus() function from ${.CURDIR}/../fdread/fdutil.c to
give a bit more information about up to 10 errors encountered during
formatting (unless -q has been specified, of course).

While being here, removed a bitrotten comment in the Makefile, and
kill the old Emacs local variable stuff at the end of fdformat.c
that's no longer useful anway.


# a5cef3b4 26-Jun-2001 Joerg Wunsch <joerg@FreeBSD.org>

Now that we've got it, use FDOPT_NOERRLOG for fdformat and fdwrite to
avoid blasting the syslog with error messages from bad floppies. Both
tools have their own error reporting anyway (which could easily be
cluttered by the syslog output on your terminal).


# d137c337 06-Jun-2001 Joerg Wunsch <joerg@FreeBSD.org>

Part #2 of the <machine/ioctl_fd.h> => <sys/fdcio.h> move: handle the
tools in usr.sbin/fd*.


# ad70dcf3 23-May-2001 Poul-Henning Kamp <phk@FreeBSD.org>

fdformat prompts for user confirmation. it exits 0 if the user
doesn't confirm, which needlessly complicates scripts.

PR: 15339
Submitted by: richard winkel rich@math.missouri.edu
MFC after: 1 week


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# d2c1dda3 01-Jun-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Add -y option which doesn't ask for confimation, but still shows progress

PR: 9259
Submitted by: Clark Gaylord <cgaylord@vt.edu>


# 31245fb2 22-Jan-2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Fix fdformat to not use /dev/r* device nodes anymore, this usage
has been made obsolete by the block/char device merging.

Reflect this change in the manual page and fix the usage of a
backslash in ``e.g.''.

Reviewed by: bright, sheldonh, phk


# d0fd62ec 07-Jan-2000 KATO Takenori <kato@FreeBSD.org>

- Added 640KB and 1232KB formats support.
- Added $FreeBSD$.

Submitted by: nyan


# 6c9d5885 17-Sep-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Document options in man page, not in usage string.


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 9a89db44 25-Sep-1994 Joerg Wunsch <joerg@FreeBSD.org>

Transfer speed definitions are now also found in <machine/ioctl_fd.h>.
Remove the old include file, since it used to be in a non-public place.


# f38ec702 17-Sep-1994 David Greenman <dg@FreeBSD.org>

Fix include path.


# 538788f3 22-May-1994 Joerg Wunsch <joerg@FreeBSD.org>

Make use of the new FDOPT_NORETRY facility. It does not make sense to
verify formatted tracks with fully retryng. The head should not be moved
in either case.
Also some minor copyright cleanup.


# 6ae4c621 20-Feb-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

From: phk@login.dkuug.dk (Poul-Henning Kamp)
Message-Id: <9402201119.AA06430@login.dkuug.dk>
Subject: bug in fdformat.c

There is a bug in fdformat.c: the number of heads are hardcoded in two places.
This is quite inconsequencial at present, but a bug nontheless.


# d4ef5cfd 09-Feb-1994 Andrey A. Chernov <ache@FreeBSD.org>

Fix size of il (interleave) array.


# bef69b45 09-Feb-1994 Andrey A. Chernov <ache@FreeBSD.org>

Add interleave > 1 support by Poul-Henning Kamp.
Chack valid range of sectors per track.


# 4f81180d 26-Jan-1994 Andrey A. Chernov <ache@FreeBSD.org>

We got now floppy formatter