History

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.

Al Viro committed 8 years ago

Commit a07b2001 parent 9e98c679 files · +159 −28Browse files

Showing the changes to include/uapi/linux (2 of 9 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/fcntl.h +2 −0
  2. include/uapi/linux/mount.h +6 −0
include/uapi/linux/fcntl.h+2−0
@@ -91,5 +91,7 @@ · 90 unmodified lines
91#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */91#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */
92#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */92#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */
93 93
94#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
95
94 96
95#endif /* _UAPI_LINUX_FCNTL_H */97#endif /* _UAPI_LINUX_FCNTL_H */
include/uapi/linux/mount.h+6−0
@@ -55,4 +55,10 @@ · 54 unmodified lines
55#define MS_MGC_VAL 0xC0ED000055#define MS_MGC_VAL 0xC0ED0000
56#define MS_MGC_MSK 0xffff000056#define MS_MGC_MSK 0xffff0000
57 57
58/*
59 * open_tree() flags.
60 */
61#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
62#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
63
58#endif /* _UAPI_LINUX_MOUNT_H */64#endif /* _UAPI_LINUX_MOUNT_H */