Place a write-protected floppy in the drive, and _read_ the
block device using "dd".
Invoke ioctl FDFLUSH. I've appended a program below to do that,
or you can use the "flushb" program, which seems to be
distributed with many Linux systems.
Place a NON-write-protected floppy in the drive, and _write_
the block device using "dd".
"dd" gets a write failure with errno set to EROFS.
Reading the disk, even one byte, causes the state of the switch to be tested
and the write will succeed after that.
Thanks
Bruce Perens
The Debian Linux Distribution
/*
* Floppy-disk buffer flush program.
* Copyright (C) 1995 Bruce Perens
* This program is free software under the GNU General Public License
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/fd.h>
static const char fd0[] = "/dev/fd0";
int
main(int argc, char * * argv)
{
const char * floppy = fd0;
int fd;
if ( argc > 1 )
floppy = argv[1];
fd = open(floppy, O_RDONLY);
if ( fd < 0 ) {
fprintf(stderr, "%s: %s.\n", floppy, strerror(errno));
return -1;
}
if ( ioctl(fd, FDFLUSH, 0) != 0 ) {
fprintf(stderr, "%s: fdflush: %s.\n", floppy, strerror(errno));
return -1;
}
return 0;
}
-- -- Attention Radio Amateurs: For information on "Linux for Hams", -- read the WWW page http://www.hams.com/LinuxForHams, -- or e-mail the word "help" to info@hams.com