summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>1995-03-23 12:11:07 +0000
committermycroft <mycroft@NetBSD.org>1995-03-23 12:11:07 +0000
commit06d0a67a076bc65f8a973288cb89f2f29d01f0d9 (patch)
tree5fd683305d1c6fcec328fe1c13e0b57de24f0b8d /sys/dev
parentd21add8356e0d6506a294985465611a2d48b1209 (diff)
Check for read-only media in open(), not write().
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/wd.c19
-rw-r--r--sys/dev/isa/wd.c19
-rw-r--r--sys/dev/scsipi/cd.c15
-rw-r--r--sys/dev/scsipi/sd.c20
4 files changed, 37 insertions, 36 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index 9d2a4b6fb15..d65eaf30cb9 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wd.c,v 1.132 1995/03/23 11:33:32 mycroft Exp $ */
+/* $NetBSD: wd.c,v 1.133 1995/03/23 12:12:26 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@@ -396,14 +396,6 @@ wdstrategy(bp)
goto bad;
}
-#if 0
- /* "Soft" write protect check. */
- if ((wd->sc_flags & WDF_WRITEPROT) && (bp->b_flags & B_READ) == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-#endif
-
/* If it's a null transfer, return immediately. */
if (bp->b_bcount == 0)
goto done;
@@ -928,6 +920,15 @@ wdopen(dev, flag, fmt)
wdunlock(wd);
}
+#if 0
+ /* Check for read-only media. */
+ if ((flag & FWRITE) != 0 &&
+ (wd->sc_flags & WDF_WRITEPROT) != 0) {
+ error = EROFS;
+ goto bad;
+ }
+#endif
+
/* Check that the partition exists. */
if (part != RAW_PART &&
(part >= wd->sc_dk.dk_label.d_npartitions ||
diff --git a/sys/dev/isa/wd.c b/sys/dev/isa/wd.c
index 9d2a4b6fb15..d65eaf30cb9 100644
--- a/sys/dev/isa/wd.c
+++ b/sys/dev/isa/wd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wd.c,v 1.132 1995/03/23 11:33:32 mycroft Exp $ */
+/* $NetBSD: wd.c,v 1.133 1995/03/23 12:12:26 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@@ -396,14 +396,6 @@ wdstrategy(bp)
goto bad;
}
-#if 0
- /* "Soft" write protect check. */
- if ((wd->sc_flags & WDF_WRITEPROT) && (bp->b_flags & B_READ) == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-#endif
-
/* If it's a null transfer, return immediately. */
if (bp->b_bcount == 0)
goto done;
@@ -928,6 +920,15 @@ wdopen(dev, flag, fmt)
wdunlock(wd);
}
+#if 0
+ /* Check for read-only media. */
+ if ((flag & FWRITE) != 0 &&
+ (wd->sc_flags & WDF_WRITEPROT) != 0) {
+ error = EROFS;
+ goto bad;
+ }
+#endif
+
/* Check that the partition exists. */
if (part != RAW_PART &&
(part >= wd->sc_dk.dk_label.d_npartitions ||
diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c
index bb14fbf5e20..6f88c210789 100644
--- a/sys/dev/scsipi/cd.c
+++ b/sys/dev/scsipi/cd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.61 1995/03/23 11:51:22 mycroft Exp $ */
+/* $NetBSD: cd.c,v 1.62 1995/03/23 12:11:07 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@@ -288,6 +288,12 @@ cdopen(dev, flag, fmt)
cdunlock(cd);
}
+ /* Check for read-only media. */
+ if ((flag & FWRITE) != 0) {
+ error = EROFS;
+ goto bad;
+ }
+
/* Check that the partition exists. */
if (part != RAW_PART &&
(part >= cd->sc_dk.dk_label.d_npartitions ||
@@ -418,13 +424,6 @@ cdstrategy(bp)
goto bad;
}
/*
- * can't ever write to a CD
- */
- if ((bp->b_flags & B_READ) == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
- /*
* If it's a null transfer, return immediately
*/
if (bp->b_bcount == 0)
diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c
index 288d0bebf6b..1e2e8d8eee0 100644
--- a/sys/dev/scsipi/sd.c
+++ b/sys/dev/scsipi/sd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.62 1995/03/23 11:43:13 mycroft Exp $ */
+/* $NetBSD: sd.c,v 1.63 1995/03/23 12:11:12 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@@ -294,6 +294,15 @@ sdopen(dev, flag, fmt)
sdunlock(sd);
}
+#if 0
+ /* Check for read-only media. */
+ if ((flag & FWRITE) != 0 &&
+ (sd->flags & SDF_WRITEPROT) != 0) {
+ error = EROFS;
+ goto bad;
+ }
+#endif
+
/* Check that the partition exists. */
if (part != RAW_PART &&
(part >= sd->sc_dk.dk_label.d_npartitions ||
@@ -421,15 +430,6 @@ sdstrategy(bp)
bp->b_error = EIO;
goto bad;
}
-#if 0
- /*
- * "soft" write protect check
- */
- if ((sd->flags & SDF_WRITEPROT) && (bp->b_flags & B_READ) == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-#endif
/*
* If it's a null transfer, return immediatly
*/