]> www.infradead.org Git - users/willy/linux.git/commit
vfs: syscall: Add open_tree(2) to reference or clone a mount
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 11 Sep 2018 21:20:53 +0000 (22:20 +0100)
committerDavid Howells <dhowells@redhat.com>
Tue, 11 Sep 2018 21:20:53 +0000 (22:20 +0100)
commit5caad78464aa92ab55df824d1f0e3336123f1b49
tree1d691a0f59443a9025063ed016a98aac8599407d
parent307c6e5241b4b44076c016bc64d1748b93d1792b
vfs: syscall: Add open_tree(2) to reference or clone a mount

open_tree(dfd, pathname, flags)

Returns an O_PATH-opened file descriptor or an error.
dfd and pathname specify the location to open, in usual
fashion (see e.g. fstatat(2)).  flags should be an OR of
some of the following:
* AT_PATH_EMPTY, AT_NO_AUTOMOUNT, AT_SYMLINK_NOFOLLOW -
same meanings as usual
* OPEN_TREE_CLOEXEC - make the resulting descriptor
close-on-exec
* OPEN_TREE_CLONE or OPEN_TREE_CLONE | AT_RECURSIVE -
instead of opening the location in question, create a detached
mount tree matching the subtree rooted at location specified by
dfd/pathname.  With AT_RECURSIVE the entire subtree is cloned,
without it - only the part within in the mount containing the
location in question.  In other words, the same as mount --rbind
or mount --bind would've taken.  The detached tree will be
dissolved on the final close of obtained file.  Creation of such
detached trees requires the same capabilities as doing mount --bind.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-api@vger.kernel.org
arch/x86/entry/syscalls/syscall_32.tbl
arch/x86/entry/syscalls/syscall_64.tbl
fs/file_table.c
fs/internal.h
fs/namespace.c
include/linux/fs.h
include/linux/syscalls.h
include/uapi/linux/fcntl.h
include/uapi/linux/mount.h [new file with mode: 0644]