aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount
diff options
context:
space:
mode:
authorSean Eric Fagan <sef@FreeBSD.org>2019-09-23 04:28:07 +0000
committerSean Eric Fagan <sef@FreeBSD.org>2019-09-23 04:28:07 +0000
commitba7a55d93465725fd860066d95d4e910c3c027c2 (patch)
treee46ac60f38cbac374d17571c2895139d8899b29b /sbin/mount
parent7505cffa56d7347436b32f8d3f192ad1c4383ad8 (diff)
downloadsrc-ba7a55d93465725fd860066d95d4e910c3c027c2.tar.gz
src-ba7a55d93465725fd860066d95d4e910c3c027c2.zip
Add two options to allow mount to avoid covering up existing mount points.
The two options are * nocover/cover: Prevent/allow mounting over an existing root mountpoint. E.g., "mount -t ufs -o nocover /dev/sd1a /usr/local" will fail if /usr/local is already a mountpoint. * emptydir/noemptydir: Prevent/allow mounting on a non-empty directory. E.g., "mount -t ufs -o emptydir /dev/sd1a /usr" will fail. Neither of these options is intended to be a default, for historical and compatibility reasons. Reviewed by: allanjude, kib Differential Revision: https://reviews.freebsd.org/D21458
Notes
Notes: svn path=/head/; revision=352614
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/mntopts.h7
-rw-r--r--sbin/mount/mount.87
-rw-r--r--sbin/mount/mount.c4
3 files changed, 15 insertions, 3 deletions
diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h
index 924ead253890..183d6d9e501d 100644
--- a/sbin/mount/mntopts.h
+++ b/sbin/mount/mntopts.h
@@ -65,7 +65,8 @@ struct mntopt {
#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
-
+#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 }
+#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 }
/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
#define MOPT_AUTO { "auto", 0, 0, 0 }
@@ -95,7 +96,9 @@ struct mntopt {
MOPT_ACLS, \
MOPT_NFS4ACLS, \
MOPT_AUTOMOUNTED, \
- MOPT_UNTRUSTED
+ MOPT_UNTRUSTED, \
+ MOPT_NOCOVER, \
+ MOPT_EMPTYDIR
void getmntopts(const char *, const struct mntopt *, int *, int *);
void rmslashes(char *, char *);
diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8
index 7ff94fb7c165..3aee1bb86151 100644
--- a/sbin/mount/mount.8
+++ b/sbin/mount/mount.8
@@ -28,7 +28,7 @@
.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
.\" $FreeBSD$
.\"
-.Dd March 22, 2017
+.Dd August 28, 2019
.Dt MOUNT 8
.Os
.Sh NAME
@@ -162,6 +162,8 @@ When used with the
.Fl u
flag, this is the same as specifying the options currently in effect for
the mounted file system.
+.It Cm emptydir
+Require that the mount point directory be empty.
.It Cm force
The same as
.Fl f ;
@@ -237,6 +239,9 @@ flag.
Disable read clustering.
.It Cm noclusterw
Disable write clustering.
+.It Cm nocover
+Do not mount if the requested mount point is already
+the root of a mount point.
.It Cm noexec
Do not allow execution of any binaries on the mounted file system.
This option is useful for a server that has file systems containing
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index 102e87009b0f..938a220b41c3 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -119,6 +119,8 @@ static struct opt {
{ MNT_AUTOMOUNTED, "automounted" },
{ MNT_VERIFIED, "verified" },
{ MNT_UNTRUSTED, "untrusted" },
+ { MNT_NOCOVER, "nocover" },
+ { MNT_EMPTYDIR, "emptydir" },
{ 0, NULL }
};
@@ -975,6 +977,8 @@ flags2opts(int flags)
if (flags & MNT_ACLS) res = catopt(res, "acls");
if (flags & MNT_NFS4ACLS) res = catopt(res, "nfsv4acls");
if (flags & MNT_UNTRUSTED) res = catopt(res, "untrusted");
+ if (flags & MNT_NOCOVER) res = catopt(res, "nocover");
+ if (flags & MNT_EMPTYDIR) res = catopt(res, "emptydir");
return (res);
}