aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1994-11-08 05:42:10 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1994-11-08 05:42:10 +0000
commit6febd9aaf597f9e99b6f6461859866c486c37b3c (patch)
tree99356320cb9a1888ff408c86f4791414b7b57845
parent5755e2597a2c7377c7e29e67c650a59dd116ab48 (diff)
downloadsrc-6febd9aaf597f9e99b6f6461859866c486c37b3c.tar.gz
src-6febd9aaf597f9e99b6f6461859866c486c37b3c.zip
From: Lars Fredriksen <fredriks@mcs.com>
Here is a patch to fd.c that will check to make sure the floppy is not writeprotected when you try to open the device RW. Submitted by: lars
Notes
Notes: svn path=/head/; revision=4260
-rw-r--r--sys/dev/fdc/fdc.c22
-rw-r--r--sys/i386/isa/fd.c22
-rw-r--r--sys/isa/fd.c22
3 files changed, 63 insertions, 3 deletions
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 8315344457a3..f5abb9b8c6d9 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -40,7 +40,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $Id: fd.c,v 1.38 1994/10/27 20:44:46 jkh Exp $
+ * $Id: fd.c,v 1.40 1994/11/02 09:08:40 jkh Exp $
*
*/
@@ -700,6 +700,7 @@ Fdopen(dev, flags)
fdu_t fdu = FDUNIT(minor(dev));
int type = FDTYPE(minor(dev));
fdc_p fdc;
+ int st3;
#if NFT > 0
/* check for a tape open */
@@ -764,6 +765,25 @@ Fdopen(dev, flags)
}
}
}
+
+ /* select it */
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNON);
+
+ if (flags & FWRITE) {
+ /* Check to make sure the diskette */
+ /* is writable */
+ out_fdc(fdc->fdcu, NE7CMD_SENSED);
+ out_fdc(fdc->fdcu, fdu);
+ st3 = in_fdc(fdc->fdcu);
+ if(st3 & NE7_ST3_WP) {
+ printf("fd%d: Floppy not writable\n", fdu);
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+ return(EPERM);
+ }
+ }
+
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+
fd_data[fdu].ft = fd_types + type - 1;
fd_data[fdu].flags |= FD_OPEN;
diff --git a/sys/i386/isa/fd.c b/sys/i386/isa/fd.c
index 8315344457a3..f5abb9b8c6d9 100644
--- a/sys/i386/isa/fd.c
+++ b/sys/i386/isa/fd.c
@@ -40,7 +40,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $Id: fd.c,v 1.38 1994/10/27 20:44:46 jkh Exp $
+ * $Id: fd.c,v 1.40 1994/11/02 09:08:40 jkh Exp $
*
*/
@@ -700,6 +700,7 @@ Fdopen(dev, flags)
fdu_t fdu = FDUNIT(minor(dev));
int type = FDTYPE(minor(dev));
fdc_p fdc;
+ int st3;
#if NFT > 0
/* check for a tape open */
@@ -764,6 +765,25 @@ Fdopen(dev, flags)
}
}
}
+
+ /* select it */
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNON);
+
+ if (flags & FWRITE) {
+ /* Check to make sure the diskette */
+ /* is writable */
+ out_fdc(fdc->fdcu, NE7CMD_SENSED);
+ out_fdc(fdc->fdcu, fdu);
+ st3 = in_fdc(fdc->fdcu);
+ if(st3 & NE7_ST3_WP) {
+ printf("fd%d: Floppy not writable\n", fdu);
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+ return(EPERM);
+ }
+ }
+
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+
fd_data[fdu].ft = fd_types + type - 1;
fd_data[fdu].flags |= FD_OPEN;
diff --git a/sys/isa/fd.c b/sys/isa/fd.c
index 8315344457a3..f5abb9b8c6d9 100644
--- a/sys/isa/fd.c
+++ b/sys/isa/fd.c
@@ -40,7 +40,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $Id: fd.c,v 1.38 1994/10/27 20:44:46 jkh Exp $
+ * $Id: fd.c,v 1.40 1994/11/02 09:08:40 jkh Exp $
*
*/
@@ -700,6 +700,7 @@ Fdopen(dev, flags)
fdu_t fdu = FDUNIT(minor(dev));
int type = FDTYPE(minor(dev));
fdc_p fdc;
+ int st3;
#if NFT > 0
/* check for a tape open */
@@ -764,6 +765,25 @@ Fdopen(dev, flags)
}
}
}
+
+ /* select it */
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNON);
+
+ if (flags & FWRITE) {
+ /* Check to make sure the diskette */
+ /* is writable */
+ out_fdc(fdc->fdcu, NE7CMD_SENSED);
+ out_fdc(fdc->fdcu, fdu);
+ st3 = in_fdc(fdc->fdcu);
+ if(st3 & NE7_ST3_WP) {
+ printf("fd%d: Floppy not writable\n", fdu);
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+ return(EPERM);
+ }
+ }
+
+ set_motor(fdc->fdcu, fd_data[fdu].fdsu, TURNOFF);
+
fd_data[fdu].ft = fd_types + type - 1;
fd_data[fdu].flags |= FD_OPEN;