aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/mdmfs
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2011-09-13 20:16:11 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2011-09-13 20:16:11 +0000
commite50e74d8aa3ad6ced00d692a25936c9e3ca2bc2d (patch)
treed0c40a05e3e675b5fdfc78ce66ddc4969b6beddf /sbin/mdmfs
parent31f301d021da952c89a15bc7193978f6bf73a049 (diff)
downloadsrc-e50e74d8aa3ad6ced00d692a25936c9e3ca2bc2d.tar.gz
src-e50e74d8aa3ad6ced00d692a25936c9e3ca2bc2d.zip
Do not try to change the mode or ownership of the root of the mountpoint
when newly established mdmfs mount is readonly. PR: bin/128427 Tested and reviewed by: jchandra MFC after: 1 week Approved by: re (bz)
Notes
Notes: svn path=/head/; revision=225534
Diffstat (limited to 'sbin/mdmfs')
-rw-r--r--sbin/mdmfs/mdmfs.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c
index ef45040ce648..e0932652be1e 100644
--- a/sbin/mdmfs/mdmfs.c
+++ b/sbin/mdmfs/mdmfs.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/mdioctl.h>
+#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -60,6 +61,7 @@ struct mtpt_info {
bool mi_have_gid;
mode_t mi_mode;
bool mi_have_mode;
+ bool mi_forced_pw;
};
static bool debug; /* Emit debugging information? */
@@ -204,6 +206,7 @@ main(int argc, char **argv)
usage();
mi.mi_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
mi.mi_have_mode = true;
+ mi.mi_forced_pw = true;
free(set);
break;
case 'S':
@@ -223,6 +226,7 @@ main(int argc, char **argv)
break;
case 'w':
extract_ugid(optarg, &mi);
+ mi.mi_forced_pw = true;
break;
case 'X':
debug = true;
@@ -443,6 +447,29 @@ do_mount(const char *args, const char *mtpoint)
static void
do_mtptsetup(const char *mtpoint, struct mtpt_info *mip)
{
+ struct statfs sfs;
+
+ if (!mip->mi_have_mode && !mip->mi_have_uid && !mip->mi_have_gid)
+ return;
+
+ if (!norun) {
+ if (statfs(mtpoint, &sfs) == -1) {
+ warn("statfs: %s", mtpoint);
+ return;
+ }
+ if ((sfs.f_flags & MNT_RDONLY) != 0) {
+ if (mip->mi_forced_pw) {
+ warnx(
+ "Not changing mode/owner of %s since it is read-only",
+ mtpoint);
+ } else {
+ debugprintf(
+ "Not changing mode/owner of %s since it is read-only",
+ mtpoint);
+ }
+ return;
+ }
+ }
if (mip->mi_have_mode) {
debugprintf("changing mode of %s to %o.", mtpoint,