mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
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
This commit is contained in:
parent
5755e2597a
commit
6febd9aaf5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4260
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
22
sys/isa/fd.c
22
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user