diff options
author | Suman Chakravartula <[email protected]> | 2012-01-11 16:48:02 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-01-12 15:49:38 -0800 |
commit | e18be9a637088911d2b618788cd45982986e63cb (patch) | |
tree | 611485fc0e3b37bea63a1e48ccff9f55be9b38a6 /lib | |
parent | 96b91ef0d6b289037c4d54357901e4b694e08f02 (diff) |
Add overlay(-O) mount option support
Linux supports mounting over non-empty directories by default.
In Solaris this is not the case and -O option is required for
zfs mount to mount a zfs filesystem over a non-empty directory.
For compatibility, I've added support for -O option to mount
zfs filesystems over non-empty directories if the user wants
to, just like in Solaris.
I've defined MS_OVERLAY to record it in the flags variable if
the -O option is supplied. The flags variable passes through
a few functions and its checked before performing the empty
directory check in zfs_mount function. If -O is given, the
check is not performed.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #473
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libspl/include/sys/mount.h | 7 | ||||
-rw-r--r-- | lib/libzfs/libzfs_mount.c | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/libspl/include/sys/mount.h b/lib/libspl/include/sys/mount.h index d4ac6a958..145e785e3 100644 --- a/lib/libspl/include/sys/mount.h +++ b/lib/libspl/include/sys/mount.h @@ -73,4 +73,11 @@ # define MS_DETACH 0x00000002 #endif /* MNT_DETACH */ +/* + * Overlay mount is default in Linux, but for solaris/zfs + * compatibility, MS_OVERLAY is defined to explicitly have the user + * provide a flag (-O) to mount over a non empty directory. + */ +#define MS_OVERLAY 0x00000004 + #endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 6758f6a09..0fe83e550 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -440,9 +440,11 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) /* * Determine if the mountpoint is empty. If so, refuse to perform the - * mount. We don't perform this check if 'remount' is specified. + * mount. We don't perform this check if 'remount' is + * specified or if overlay option(-O) is given */ - if (!remount && !dir_is_empty(mountpoint)) { + if ((flags & MS_OVERLAY) == 0 && !remount && + !dir_is_empty(mountpoint)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "directory is not empty")); return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, |