summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-07-08 14:31:00 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-07-08 14:31:00 +0000
commit887908b79c7ae681e8b2bb02279240af317262d5 (patch)
treeb7308c555d181eef75bcf31c0d747e006d2dd458
parentb87977228a6f6a5a391c69fdfb2dc717d206ece4 (diff)
Return EROFS when a read-write mount of a read-only sd(4) device
is attempted. This is instead of the current EACCES and is intended to result in better error messages from mount(8). Tweak default EROFS error text to mention fsck'ing in mount_ext2fs and mount_msdos since they both have fsck's like ffs. ok deraadt@ aja@ ian@ phessler@
-rw-r--r--sbin/mount_ext2fs/mount_ext2fs.c6
-rw-r--r--sbin/mount_msdos/mount_msdos.c6
-rw-r--r--sys/scsi/sd.c4
3 files changed, 12 insertions, 4 deletions
diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c
index 8797f2df9ac..a1cfd0d3f49 100644
--- a/sbin/mount_ext2fs/mount_ext2fs.c
+++ b/sbin/mount_ext2fs/mount_ext2fs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ext2fs.c,v 1.14 2009/10/27 23:59:33 deraadt Exp $ */
+/* $OpenBSD: mount_ext2fs.c,v 1.15 2012/07/08 14:30:58 krw Exp $ */
/* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */
/*-
@@ -97,6 +97,10 @@ main(int argc, char *argv[])
case EOPNOTSUPP:
errcause = "filesystem not supported by kernel";
break;
+ case EROFS:
+ errcause =
+ "filesystem must be mounted read-only; you may need to run fsck";
+ break;
default:
errcause = strerror(errno);
break;
diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c
index 8e2aa0f3ce5..a3c1aa913e4 100644
--- a/sbin/mount_msdos/mount_msdos.c
+++ b/sbin/mount_msdos/mount_msdos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_msdos.c,v 1.24 2011/04/04 13:49:48 tedu Exp $ */
+/* $OpenBSD: mount_msdos.c,v 1.25 2012/07/08 14:30:58 krw Exp $ */
/* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */
/*
@@ -140,6 +140,10 @@ main(int argc, char **argv)
case EMFILE:
errcause = "mount table full";
break;
+ case EROFS:
+ errcause =
+ "filesystem must be mounted read-only; you may need to run fsck";
+ break;
case EINVAL:
errcause =
"not an MSDOS filesystem";
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index e7171c16729..fe94b7b8a47 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.240 2012/06/10 21:29:04 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.241 2012/07/08 14:30:59 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -353,7 +353,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
}
if (ISSET(flag, FWRITE) && ISSET(sc_link->flags, SDEV_READONLY)) {
device_unref(&sc->sc_dev);
- return (EACCES);
+ return (EROFS);
}
SC_DEBUG(sc_link, SDEV_DB1,