aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_mount.c
diff options
context:
space:
mode:
authorNed Bass <bass6@llnl.gov>2015-03-26 12:10:26 -0700
committerBrian Behlendorf <behlendorf1@llnl.gov>2015-03-27 14:46:58 -0700
commit9540be9b23fd6f8b5bf7d81853c251010d9b7205 (patch)
treee0391f316fad41e8d86180be53914db2f7be4cae /lib/libzfs/libzfs_mount.c
parent95a6990d9a77a56eb97b76f2880f95f0f42f4fe0 (diff)
zpool import should honor overlay property
Make the 'zpool import' command honor the overlay property to allow filesystems to be mounted on a non-empty directory. As it stands now this property is only checked by the 'zfs mount' command. Move the check into 'zfs_mount()` in libzpool so the property is honored for all callers. Signed-off-by: Ned Bass <bass6@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3227
Diffstat (limited to 'lib/libzfs/libzfs_mount.c')
-rw-r--r--lib/libzfs/libzfs_mount.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index ac3b68226..0e3332e0e 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -388,6 +388,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
struct stat buf;
char mountpoint[ZFS_MAXPROPLEN];
char mntopts[MNT_LINE_MAX];
+ char overlay[ZFS_MAXPROPLEN];
libzfs_handle_t *hdl = zhp->zfs_hdl;
int remount = 0, rc;
@@ -442,6 +443,19 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
}
/*
+ * Overlay mounts are disabled by default but may be enabled
+ * via the 'overlay' property or the 'zfs mount -O' option.
+ */
+ if (!(flags & MS_OVERLAY)) {
+ if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
+ sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {
+ if (strcmp(overlay, "on") == 0) {
+ flags |= MS_OVERLAY;
+ }
+ }
+ }
+
+ /*
* Determine if the mountpoint is empty. If so, refuse to perform the
* mount. We don't perform this check if 'remount' is
* specified or if overlay option(-O) is given