aboutsummaryrefslogtreecommitdiff
path: root/sbin/mdconfig
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/mdconfig')
-rw-r--r--sbin/mdconfig/mdconfig.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index 02f128763c21..e3ca148d7fa9 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
@@ -233,6 +234,16 @@ main(int argc, char **argv)
if (cmdline == 2 && mdio.md_type == MD_VNODE)
if (mdio.md_file[0] == '\0')
errx(1, "must specify -f for -t vnode");
+ if (mdio.md_type == MD_VNODE &&
+ (mdio.md_options & MD_READONLY) == 0) {
+ if (access(mdio.md_file, W_OK) < 0 &&
+ (errno == EACCES || errno == EPERM || errno == EROFS)) {
+ fprintf(stderr,
+ "WARNING: opening backing store: %s readonly\n",
+ mdio.md_file);
+ mdio.md_options |= MD_READONLY;
+ }
+ }
if (action == LIST) {
if (mdio.md_options & MD_AUTOUNIT)
list(fd);