#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
-uid_t t_overflowuid = 65534;
-gid_t t_overflowgid = 65534;
+static char t_buf[PATH_MAX];
-/* path of the test device */
-const char *t_fstype;
-
-/* path of the test device */
-const char *t_device;
-
-/* path of the test scratch device */
-const char *t_device_scratch;
-
-/* mountpoint of the test device */
-const char *t_mountpoint;
-
-/* mountpoint of the test device */
-const char *t_mountpoint_scratch;
-
-/* fd for @t_mountpoint */
-int t_mnt_fd;
-
-/* fd for @t_mountpoint_scratch */
-int t_mnt_scratch_fd;
-
-/* fd for @T_DIR1 */
-int t_dir1_fd;
-
-/* temporary buffer */
-char t_buf[PATH_MAX];
-
-/* whether the underlying filesystem supports idmapped mounts */
-bool t_fs_allow_idmap;
-/* whether the system supports user namespaces */
-bool t_has_userns;
+static void init_vfstest_info(struct vfstest_info *info)
+{
+ info->t_overflowuid = 65534;
+ info->t_overflowgid = 65534;
+ info->t_fstype = NULL;
+ info->t_device = NULL;
+ info->t_device_scratch = NULL;
+ info->t_mountpoint = NULL;
+ info->t_mountpoint_scratch = NULL;
+ info->t_mnt_fd = -EBADF;
+ info->t_mnt_scratch_fd = -EBADF;
+ info->t_dir1_fd = -EBADF;
+ info->t_fs_allow_idmap = false;
+}
-static void stash_overflowuid(void)
+static void stash_overflowuid(struct vfstest_info *info)
{
int fd;
ssize_t ret;
if (ret < 0)
return;
- t_overflowuid = atoi(buf);
+ info->t_overflowuid = atoi(buf);
}
-static void stash_overflowgid(void)
+static void stash_overflowgid(struct vfstest_info *info)
{
int fd;
ssize_t ret;
if (ret < 0)
return;
- t_overflowgid = atoi(buf);
+ info->t_overflowgid = atoi(buf);
}
-static bool is_xfs(void)
+static bool is_xfs(const char *fstype)
{
static int enabled = -1;
if (enabled == -1)
- enabled = !strcmp(t_fstype, "xfs");
+ enabled = !strcmp(fstype, "xfs");
return enabled;
}
return enabled == 1;
}
-static bool xfs_irix_sgid_inherit_enabled(void)
+static bool xfs_irix_sgid_inherit_enabled(const char *fstype)
{
static int enabled = -1;
enabled = 0;
- if (is_xfs()) {
+ if (is_xfs(fstype)) {
fd = open("/proc/sys/fs/xfs/irix_sgid_inherit", O_RDONLY | O_CLOEXEC);
if (fd < 0)
return false;
fd = -EBADF; \
}
-static void test_setup(void)
+static void test_setup(struct vfstest_info *info)
{
- if (mkdirat(t_mnt_fd, T_DIR1, 0777))
+ if (mkdirat(info->t_mnt_fd, T_DIR1, 0777))
die("failure: mkdirat");
- t_dir1_fd = openat(t_mnt_fd, T_DIR1, O_CLOEXEC | O_DIRECTORY);
- if (t_dir1_fd < 0)
+ info->t_dir1_fd = openat(info->t_mnt_fd, T_DIR1, O_CLOEXEC | O_DIRECTORY);
+ if (info->t_dir1_fd < 0)
die("failure: openat");
- if (fchmod(t_dir1_fd, 0777))
+ if (fchmod(info->t_dir1_fd, 0777))
die("failure: fchmod");
}
-static void test_cleanup(void)
+static void test_cleanup(struct vfstest_info *info)
{
- safe_close(t_dir1_fd);
- if (rm_r(t_mnt_fd, T_DIR1))
+ safe_close(info->t_dir1_fd);
+ if (rm_r(info->t_mnt_fd, T_DIR1))
die("failure: rm_r");
}
/* Validate that basic file operations on idmapped mounts. */
-static int fsids_unmapped(void)
+static int fsids_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, hardlink_target_fd = -EBADF, open_tree_fd = -EBADF;
};
/* create hardlink target */
- hardlink_target_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ hardlink_target_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (hardlink_target_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* create directory for rename test */
- if (mkdirat(t_dir1_fd, DIR1, 0700)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0700)) {
log_stderr("failure: mkdirat");
goto out;
}
/* change ownership of all files to uid 0 */
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int fsids_mapped(void)
+static int fsids_mapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, hardlink_target_fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create hardlink target */
- hardlink_target_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ hardlink_target_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (hardlink_target_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* create directory for rename test */
- if (mkdirat(t_dir1_fd, DIR1, 0700)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0700)) {
log_stderr("failure: mkdirat");
goto out;
}
/* change ownership of all files to uid 0 */
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* Validate that basic file operations on idmapped mounts from a user namespace. */
-static int create_in_userns(void)
+static int create_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
pid_t pid;
/* change ownership of all files to uid 0 */
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int hardlink_crossing_mounts(void)
+static int hardlink_crossing_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* interested in making sure we're not introducing an accidental way to
* violate that restriction or that suddenly this becomes possible.
*/
- if (!linkat(open_tree_fd, FILE1, t_dir1_fd, HARDLINK1, 0)) {
+ if (!linkat(open_tree_fd, FILE1, info->t_dir1_fd, HARDLINK1, 0)) {
log_stderr("failure: linkat");
goto out;
}
return fret;
}
-static int hardlink_crossing_idmapped_mounts(void)
+static int hardlink_crossing_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd1 = -EBADF, open_tree_fd2 = -EBADF;
.attr_set = MOUNT_ATTR_IDMAP,
};
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd1 = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd1 = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 10000, 10000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 10000, 10000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
goto out;
}
- open_tree_fd2 = sys_open_tree(t_dir1_fd, DIR1,
+ open_tree_fd2 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
return fret;
}
-static int hardlink_from_idmapped_mount(void)
+static int hardlink_from_idmapped_mount(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
.attr_set = MOUNT_ATTR_IDMAP,
};
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 10000, 10000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 10000, 10000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
return fret;
}
-static int hardlink_from_idmapped_mount_in_userns(void)
+static int hardlink_from_idmapped_mount_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int rename_crossing_mounts(void)
+static int rename_crossing_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* interested in making sure we're not introducing an accidental way to
* violate that restriction or that suddenly this becomes possible.
*/
- if (!renameat(open_tree_fd, FILE1, t_dir1_fd, FILE1_RENAME)) {
+ if (!renameat(open_tree_fd, FILE1, info->t_dir1_fd, FILE1_RENAME)) {
log_stderr("failure: renameat");
goto out;
}
return fret;
}
-static int rename_crossing_idmapped_mounts(void)
+static int rename_crossing_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd1 = -EBADF, open_tree_fd2 = -EBADF;
.attr_set = MOUNT_ATTR_IDMAP,
};
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd1 = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd1 = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 10000, 10000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 10000, 10000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
goto out;
}
- open_tree_fd2 = sys_open_tree(t_dir1_fd, DIR1,
+ open_tree_fd2 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
return fret;
}
-static int rename_from_idmapped_mount(void)
+static int rename_from_idmapped_mount(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
.attr_set = MOUNT_ATTR_IDMAP,
};
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 10000, 10000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 10000, 10000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
return fret;
}
-static int rename_from_idmapped_mount_in_userns(void)
+static int rename_from_idmapped_mount_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
.attr_set = MOUNT_ATTR_IDMAP,
};
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int symlink_regular_mounts(void)
+static int symlink_regular_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
struct stat st;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- if (chown_r(t_mnt_fd, T_DIR1, 10000, 10000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 10000, 10000)) {
log_stderr("failure: chown_r");
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int symlink_idmapped_mounts(void)
+static int symlink_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
if (!caps_supported())
return 0;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int symlink_idmapped_mounts_in_userns(void)
+static int symlink_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (chown_r(t_mnt_fd, T_DIR1, 0, 0)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 0, 0)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (wait_for_pid(pid))
goto out;
- if (!expected_uid_gid(t_dir1_fd, FILE2, AT_SYMLINK_NOFOLLOW, 5000, 5000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, AT_SYMLINK_NOFOLLOW, 5000, 5000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
/* Validate that a caller whose fsids map into the idmapped mount within it's
* user namespace cannot create any device nodes.
*/
-static int device_node_in_userns(void)
+static int device_node_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
/* Validate that changing file ownership works correctly on idmapped mounts. */
-static int expected_uid_gid_idmapped_mounts(void)
+static int expected_uid_gid_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd1 = -EBADF, open_tree_fd2 = -EBADF;
}
/* create regular file via open() */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* create regular file via mknod */
- if (mknodat(t_dir1_fd, FILE2, S_IFREG | 0000, 0)) {
+ if (mknodat(info->t_dir1_fd, FILE2, S_IFREG | 0000, 0)) {
log_stderr("failure: mknodat");
goto out;
}
/* create character device */
- if (mknodat(t_dir1_fd, CHRDEV1, S_IFCHR | 0644, makedev(5, 1))) {
+ if (mknodat(info->t_dir1_fd, CHRDEV1, S_IFCHR | 0644, makedev(5, 1))) {
log_stderr("failure: mknodat");
goto out;
}
/* create hardlink */
- if (linkat(t_dir1_fd, FILE1, t_dir1_fd, HARDLINK1, 0)) {
+ if (linkat(info->t_dir1_fd, FILE1, info->t_dir1_fd, HARDLINK1, 0)) {
log_stderr("failure: linkat");
goto out;
}
/* create symlink */
- if (symlinkat(FILE2, t_dir1_fd, SYMLINK1)) {
+ if (symlinkat(FILE2, info->t_dir1_fd, SYMLINK1)) {
log_stderr("failure: symlinkat");
goto out;
}
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0700)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0700)) {
log_stderr("failure: mkdirat");
goto out;
}
goto out;
}
- open_tree_fd1 = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd1 = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
/* Validate that all files created through the image mountpoint are
* owned by the callers fsuid and fsgid.
*/
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
goto out;
}
- open_tree_fd2 = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd2 = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* Change ownership throught original image mountpoint. */
- if (fchownat(t_dir1_fd, FILE1, 2000, 2000, 0)) {
+ if (fchownat(info->t_dir1_fd, FILE1, 2000, 2000, 0)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, FILE2, 2000, 2000, 0)) {
+ if (fchownat(info->t_dir1_fd, FILE2, 2000, 2000, 0)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, HARDLINK1, 2000, 2000, 0)) {
+ if (fchownat(info->t_dir1_fd, HARDLINK1, 2000, 2000, 0)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, CHRDEV1, 2000, 2000, 0)) {
+ if (fchownat(info->t_dir1_fd, CHRDEV1, 2000, 2000, 0)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, SYMLINK1, 3000, 3000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW)) {
+ if (fchownat(info->t_dir1_fd, SYMLINK1, 3000, 3000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, SYMLINK1, 2000, 2000, AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, SYMLINK1, 2000, 2000, AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, DIR1, 2000, 2000, AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, DIR1, 2000, 2000, AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
/* Check ownership through original mount. */
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 3000, 3000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 3000, 3000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(open_tree_fd2, SYMLINK1, AT_SYMLINK_NOFOLLOW, t_overflowuid, t_overflowgid)) {
+ if (!expected_uid_gid(open_tree_fd2, SYMLINK1, AT_SYMLINK_NOFOLLOW, info->t_overflowuid, info->t_overflowgid)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
if (!switch_userns(attr1.userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!fchownat(t_dir1_fd, FILE1, 1000, 1000, 0))
+ if (!fchownat(info->t_dir1_fd, FILE1, 1000, 1000, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, FILE2, 1000, 1000, 0))
+ if (!fchownat(info->t_dir1_fd, FILE2, 1000, 1000, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, HARDLINK1, 1000, 1000, 0))
+ if (!fchownat(info->t_dir1_fd, HARDLINK1, 1000, 1000, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, CHRDEV1, 1000, 1000, 0))
+ if (!fchownat(info->t_dir1_fd, CHRDEV1, 1000, 1000, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, SYMLINK1, 2000, 2000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW))
+ if (!fchownat(info->t_dir1_fd, SYMLINK1, 2000, 2000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, SYMLINK1, 1000, 1000, AT_EMPTY_PATH))
+ if (!fchownat(info->t_dir1_fd, SYMLINK1, 1000, 1000, AT_EMPTY_PATH))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, DIR1, 1000, 1000, AT_EMPTY_PATH))
+ if (!fchownat(info->t_dir1_fd, DIR1, 1000, 1000, AT_EMPTY_PATH))
die("failure: fchownat");
if (!fchownat(open_tree_fd2, FILE1, 1000, 1000, 0))
if (fchownat(open_tree_fd1, DIR1, 1000, 1000, AT_EMPTY_PATH))
die("failure: fchownat");
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, FILE2, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, FILE2, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, HARDLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, HARDLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, CHRDEV1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, CHRDEV1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, SYMLINK1, AT_SYMLINK_NOFOLLOW, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, SYMLINK1, AT_SYMLINK_NOFOLLOW, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, SYMLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, SYMLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd2, DIR1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd2, DIR1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd1, FILE1, 0, 1000, 1000))
goto out;
/* Check ownership through original mount. */
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 1000, 1000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 1000, 1000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
if (!switch_userns(attr2.userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!fchownat(t_dir1_fd, FILE1, 0, 0, 0))
+ if (!fchownat(info->t_dir1_fd, FILE1, 0, 0, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, FILE2, 0, 0, 0))
+ if (!fchownat(info->t_dir1_fd, FILE2, 0, 0, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, HARDLINK1, 0, 0, 0))
+ if (!fchownat(info->t_dir1_fd, HARDLINK1, 0, 0, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, CHRDEV1, 0, 0, 0))
+ if (!fchownat(info->t_dir1_fd, CHRDEV1, 0, 0, 0))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, SYMLINK1, 3000, 3000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW))
+ if (!fchownat(info->t_dir1_fd, SYMLINK1, 3000, 3000, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, SYMLINK1, 0, 0, AT_EMPTY_PATH))
+ if (!fchownat(info->t_dir1_fd, SYMLINK1, 0, 0, AT_EMPTY_PATH))
die("failure: fchownat");
- if (!fchownat(t_dir1_fd, DIR1, 0, 0, AT_EMPTY_PATH))
+ if (!fchownat(info->t_dir1_fd, DIR1, 0, 0, AT_EMPTY_PATH))
die("failure: fchownat");
if (!fchownat(open_tree_fd1, FILE1, 0, 0, 0))
if (fchownat(open_tree_fd2, DIR1, 0, 0, AT_EMPTY_PATH))
die("failure: fchownat");
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, FILE2, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, FILE2, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, HARDLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, HARDLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, CHRDEV1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, CHRDEV1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, SYMLINK1, AT_SYMLINK_NOFOLLOW, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, SYMLINK1, AT_SYMLINK_NOFOLLOW, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, SYMLINK1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, SYMLINK1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
- if (!expected_uid_gid(open_tree_fd1, DIR1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd1, DIR1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd2, FILE1, 0, 0, 0))
goto out;
/* Check ownership through original mount. */
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, HARDLINK1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, HARDLINK1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 2000, 2000)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, AT_SYMLINK_NOFOLLOW, 2000, 2000)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, SYMLINK1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, SYMLINK1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
return fret;
}
-static int fscaps(void)
+static int fscaps(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, fd_userns = -EBADF;
pid_t pid;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
return fret;
}
-static int fscaps_idmapped_mounts(void)
+static int fscaps_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, file1_fd2 = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int fscaps_idmapped_mounts_in_userns(void)
+static int fscaps_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, file1_fd2 = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int fscaps_idmapped_mounts_in_userns_valid_in_ancestor_userns(void)
+static int fscaps_idmapped_mounts_in_userns_valid_in_ancestor_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, file1_fd2 = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int fscaps_idmapped_mounts_in_userns_separate_userns(void)
+static int fscaps_idmapped_mounts_in_userns_separate_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, file1_fd2 = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* change ownership of all files to uid 0 */
- if (chown_r(t_mnt_fd, T_DIR1, 20000, 20000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 20000, 20000)) {
log_stderr("failure: chown_r");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* Validate that setid transitions are handled correctly. */
-static int setid_binaries(void)
+static int setid_binaries(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, exec_fd = -EBADF;
pid_t pid;
/* create a file to be used as setuid binary */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
NULL,
};
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 5000, 5000))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 5000, 5000))
die("failure: expected_uid_gid");
- sys_execveat(t_dir1_fd, FILE1, argv, envp, 0);
+ sys_execveat(info->t_dir1_fd, FILE1, argv, envp, 0);
die("failure: sys_execveat");
exit(EXIT_FAILURE);
}
/* Validate that setid transitions are handled correctly on idmapped mounts. */
-static int setid_binaries_idmapped_mounts(void)
+static int setid_binaries_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, exec_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (mkdirat(t_mnt_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_mnt_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
/* create a file to be used as setuid binary */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* use this can't work. So attach the mount to the filesystem first
* before performing this check.
*/
- if (sys_move_mount(open_tree_fd, "", t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
+ if (sys_move_mount(open_tree_fd, "", info->t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
log_stderr("failure: sys_move_mount");
goto out;
}
safe_close(file1_fd);
safe_close(open_tree_fd);
- snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, t_mountpoint);
+ snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, info->t_mountpoint);
sys_umount2(t_buf, MNT_DETACH);
- rm_r(t_mnt_fd, DIR1);
+ rm_r(info->t_mnt_fd, DIR1);
return fret;
}
* running in a user namespace where the uid and gid of the setid binary have no
* mapping.
*/
-static int setid_binaries_idmapped_mounts_in_userns(void)
+static int setid_binaries_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, exec_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (mkdirat(t_mnt_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_mnt_fd, DIR1, 0777)) {
log_stderr("failure: ");
goto out;
}
/* create a file to be used as setuid binary */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* use this can't work. So attach the mount to the filesystem first
* before performing this check.
*/
- if (sys_move_mount(open_tree_fd, "", t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
+ if (sys_move_mount(open_tree_fd, "", info->t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
log_stderr("failure: sys_move_mount");
goto out;
}
goto out;
}
- file1_fd = openat(t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
goto out;
}
- file1_fd = openat(t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
snprintf(expected_egid, sizeof(expected_egid), "EXPECTED_EGID=%d", getegid());
envp[2] = expected_egid;
- if (!expected_uid_gid(open_tree_fd, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
sys_execveat(open_tree_fd, FILE1, argv, envp, 0);
safe_close(file1_fd);
safe_close(open_tree_fd);
- snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, t_mountpoint);
+ snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, info->t_mountpoint);
sys_umount2(t_buf, MNT_DETACH);
- rm_r(t_mnt_fd, DIR1);
+ rm_r(info->t_mnt_fd, DIR1);
return fret;
}
* running in a user namespace where the uid and gid of the setid binary have no
* mapping.
*/
-static int setid_binaries_idmapped_mounts_in_userns_separate_userns(void)
+static int setid_binaries_idmapped_mounts_in_userns_separate_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, exec_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (mkdirat(t_mnt_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_mnt_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
/* create a file to be used as setuid binary */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC | O_RDWR, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
safe_close(exec_fd);
/* change ownership of all files to uid 0 */
- if (chown_r(t_mnt_fd, T_DIR1, 20000, 20000)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, 20000, 20000)) {
log_stderr("failure: chown_r");
goto out;
}
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* use this can't work. So attach the mount to the filesystem first
* before performing this check.
*/
- if (sys_move_mount(open_tree_fd, "", t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
+ if (sys_move_mount(open_tree_fd, "", info->t_mnt_fd, DIR1, MOVE_MOUNT_F_EMPTY_PATH)) {
log_stderr("failure: sys_move_mount");
goto out;
}
goto out;
}
- file1_fd = openat(t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
goto out;
}
- file1_fd = openat(t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDWR | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* Verify that the sid bits got raised. */
- if (!is_setid(t_dir1_fd, FILE1, 0)) {
+ if (!is_setid(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: is_setid");
goto out;
}
snprintf(expected_egid, sizeof(expected_egid), "EXPECTED_EGID=%d", getegid());
envp[2] = expected_egid;
- if (!expected_uid_gid(open_tree_fd, FILE1, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(open_tree_fd, FILE1, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
sys_execveat(open_tree_fd, FILE1, argv, envp, 0);
safe_close(file1_fd);
safe_close(open_tree_fd);
- snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, t_mountpoint);
+ snprintf(t_buf, sizeof(t_buf), "%s/" DIR1, info->t_mountpoint);
sys_umount2(t_buf, MNT_DETACH);
- rm_r(t_mnt_fd, DIR1);
+ rm_r(info->t_mnt_fd, DIR1);
return fret;
}
-static int sticky_bit_unlink(void)
+static int sticky_bit_unlink(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
return fret;
}
-static int sticky_bit_unlink_idmapped_mounts(void)
+static int sticky_bit_unlink_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
/* Validate that the sticky bit behaves correctly on idmapped mounts for unlink
* operations in a user namespace.
*/
-static int sticky_bit_unlink_idmapped_mounts_in_userns(void)
+static int sticky_bit_unlink_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
return fret;
}
-static int sticky_bit_rename(void)
+static int sticky_bit_rename(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
return fret;
}
-static int sticky_bit_rename_idmapped_mounts(void)
+static int sticky_bit_rename_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
/* Validate that the sticky bit behaves correctly on idmapped mounts for unlink
* operations in a user namespace.
*/
-static int sticky_bit_rename_idmapped_mounts_in_userns(void)
+static int sticky_bit_rename_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
}
/* Validate that protected symlinks work correctly. */
-static int protected_symlinks(void)
+static int protected_symlinks(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
}
/* Validate that protected symlinks work correctly on idmapped mounts. */
-static int protected_symlinks_idmapped_mounts(void)
+static int protected_symlinks_idmapped_mounts(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
/* Validate that protected symlinks work correctly on idmapped mounts inside a
* user namespace.
*/
-static int protected_symlinks_idmapped_mounts_in_userns(void)
+static int protected_symlinks_idmapped_mounts_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int dir_fd = -EBADF, fd = -EBADF, open_tree_fd = -EBADF;
return 0;
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
/* validate sticky bit is set */
- if (!is_sticky(t_dir1_fd, DIR1, 0)) {
+ if (!is_sticky(info->t_dir1_fd, DIR1, 0)) {
log_stderr("failure: is_sticky");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int acls(void)
+static int acls(const struct vfstest_info *info)
{
int fret = -1;
int dir1_fd = -EBADF, open_tree_fd = -EBADF;
};
pid_t pid;
- if (mkdirat(t_dir1_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- if (fchmodat(t_dir1_fd, DIR1, 0777, 0)) {
+ if (fchmodat(info->t_dir1_fd, DIR1, 0777, 0)) {
log_stderr("failure: fchmodat");
goto out;
}
- if (mkdirat(t_dir1_fd, DIR2, 0777)) {
+ if (mkdirat(info->t_dir1_fd, DIR2, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- if (fchmodat(t_dir1_fd, DIR2, 0777, 0)) {
+ if (fchmodat(info->t_dir1_fd, DIR2, 0777, 0)) {
log_stderr("failure: fchmodat");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, DIR1,
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
goto out;
}
- if (sys_move_mount(open_tree_fd, "", t_dir1_fd, DIR2, MOVE_MOUNT_F_EMPTY_PATH)) {
+ if (sys_move_mount(open_tree_fd, "", info->t_dir1_fd, DIR2, MOVE_MOUNT_F_EMPTY_PATH)) {
log_stderr("failure: sys_move_mount");
goto out;
}
- dir1_fd = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ dir1_fd = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (dir1_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- snprintf(t_buf, sizeof(t_buf), "setfacl -m u:100010:rwx %s/%s/%s/%s", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "setfacl -m u:100010:rwx %s/%s/%s/%s", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (system(t_buf)) {
log_stderr("failure: system");
goto out;
}
- snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:100010:rwx", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:100010:rwx", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (system(t_buf)) {
log_stderr("failure: system");
goto out;
}
- snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:100020:rwx", t_mountpoint, T_DIR1, DIR2, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:100020:rwx", info->t_mountpoint, T_DIR1, DIR2, DIR3);
if (system(t_buf)) {
log_stderr("failure: system");
goto out;
die("failure: switch_userns");
snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:%lu:rwx",
- t_mountpoint, T_DIR1, DIR1, DIR3, 4294967295LU);
+ info->t_mountpoint, T_DIR1, DIR1, DIR3, 4294967295LU);
if (system(t_buf))
die("failure: system");
die("failure: switch_userns");
snprintf(t_buf, sizeof(t_buf), "getfacl -p %s/%s/%s/%s | grep -q user:%lu:rwx",
- t_mountpoint, T_DIR1, DIR2, DIR3, 100010LU);
+ info->t_mountpoint, T_DIR1, DIR2, DIR3, 100010LU);
if (system(t_buf))
die("failure: system");
}
/* if we delete the acls, the ls should fail because it's 700. */
- snprintf(t_buf, sizeof(t_buf), "%s/%s/%s/%s", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "%s/%s/%s/%s", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (removexattr(t_buf, "system.posix_acl_access")) {
log_stderr("failure: removexattr");
goto out;
goto out;
}
- snprintf(t_buf, sizeof(t_buf), "%s/" T_DIR1 "/" DIR2, t_mountpoint);
+ snprintf(t_buf, sizeof(t_buf), "%s/" T_DIR1 "/" DIR2, info->t_mountpoint);
sys_umount2(t_buf, MNT_DETACH);
fret = 0;
return ret;
}
-static int io_uring(void)
+static int io_uring(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
if (pid == 0) {
/* Verify we can open it with our current credentials. */
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, false, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
/* Verify we can't open it with our current credentials. */
ret_cqe = 0;
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, false, &ret_cqe);
if (file1_fd >= 0)
die("failure: io_uring_open_file");
die("failure: switch_ids");
/* Verify we can open it with the registered credentials. */
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
cred_id, false, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
/* Verify we can open it with the registered credentials and as
* a link.
*/
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
cred_id, true, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
return fret;
}
-static int io_uring_userns(void)
+static int io_uring_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, userns_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
if (pid == 0) {
/* Verify we can open it with our current credentials. */
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, false, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
/* Verify we can't open it with our current credentials. */
ret_cqe = 0;
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, false, &ret_cqe);
if (file1_fd >= 0)
die("failure: io_uring_open_file");
die("failure: switch_userns");
/* Verify we can open it with the registered credentials. */
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
cred_id, false, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
/* Verify we can open it with the registered credentials and as
* a link.
*/
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
cred_id, true, NULL);
if (file1_fd < 0)
die("failure: io_uring_open_file");
return fret;
}
-static int io_uring_idmapped(void)
+static int io_uring_idmapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
if (attr.userns_fd < 0)
return log_errno(-1, "failure: create user namespace");
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* In no circumstances, even with recorded credentials can it be allowed to
* open the file.
*/
-static int io_uring_idmapped_unmapped(void)
+static int io_uring_idmapped_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
if (attr.userns_fd < 0)
return log_errno(-1, "failure: create user namespace");
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int io_uring_idmapped_userns(void)
+static int io_uring_idmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
if (attr.userns_fd < 0)
return log_errno(-1, "failure: create user namespace");
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
die("failure: switch_userns");
ret_cqe = 0;
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, false, &ret_cqe);
if (file1_fd >= 0)
die("failure: io_uring_open_file");
die("failure: errno(%d)", abs(ret_cqe));
ret_cqe = 0;
- file1_fd = io_uring_openat_with_creds(ring, t_dir1_fd, FILE1,
+ file1_fd = io_uring_openat_with_creds(ring, info->t_dir1_fd, FILE1,
-1, true, &ret_cqe);
if (file1_fd >= 0)
die("failure: io_uring_open_file");
return fret;
}
-static int io_uring_idmapped_unmapped_userns(void)
+static int io_uring_idmapped_unmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
cred_id = ret;
/* create file only owner can open */
- file1_fd = openat(t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_RDONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
if (attr.userns_fd < 0)
return log_errno(-1, "failure: create user namespace");
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* created within a setgid directory and irix_sgid_inhiert is set then inherit
* the setgid bit if the caller is in the group of the directory.
*/
-static int setgid_create(void)
+static int setgid_create(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF;
if (!caps_supported())
return 0;
- if (fchmod(t_dir1_fd, S_IRUSR |
+ if (fchmod(info->t_dir1_fd, S_IRUSR |
S_IWUSR |
S_IRGRP |
S_IWGRP |
}
/* Verify that the setgid bit got raised. */
- if (!is_setgid(t_dir1_fd, "", AT_EMPTY_PATH)) {
+ if (!is_setgid(info->t_dir1_fd, "", AT_EMPTY_PATH)) {
log_stderr("failure: is_setgid");
goto out;
}
- supported = openat_tmpfile_supported(t_dir1_fd);
+ supported = openat_tmpfile_supported(info->t_dir1_fd);
pid = fork();
if (pid < 0) {
}
if (pid == 0) {
/* create regular file via open() */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, S_IXGRP | S_ISGID);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, S_IXGRP | S_ISGID);
if (file1_fd < 0)
die("failure: create");
/* We're capable_wrt_inode_uidgid() and also our fsgid matches
* the directories gid.
*/
- if (!is_setgid(t_dir1_fd, FILE1, 0))
+ if (!is_setgid(info->t_dir1_fd, FILE1, 0))
die("failure: is_setgid");
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000))
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000))
die("failure: create");
/* Directories always inherit the setgid bit. */
- if (!is_setgid(t_dir1_fd, DIR1, 0))
+ if (!is_setgid(info->t_dir1_fd, DIR1, 0))
die("failure: is_setgid");
/* create a special file via mknodat() vfs_create */
- if (mknodat(t_dir1_fd, FILE2, S_IFREG | S_ISGID | S_IXGRP, 0))
+ if (mknodat(info->t_dir1_fd, FILE2, S_IFREG | S_ISGID | S_IXGRP, 0))
die("failure: mknodat");
- if (!is_setgid(t_dir1_fd, FILE2, 0))
+ if (!is_setgid(info->t_dir1_fd, FILE2, 0))
die("failure: is_setgid");
/* create a character device via mknodat() vfs_mknod */
- if (mknodat(t_dir1_fd, CHRDEV1, S_IFCHR | S_ISGID | S_IXGRP, makedev(5, 1)))
+ if (mknodat(info->t_dir1_fd, CHRDEV1, S_IFCHR | S_ISGID | S_IXGRP, makedev(5, 1)))
die("failure: mknodat");
- if (!is_setgid(t_dir1_fd, CHRDEV1, 0))
+ if (!is_setgid(info->t_dir1_fd, CHRDEV1, 0))
die("failure: is_setgid");
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0))
die("failure: check ownership");
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0))
die("failure: check ownership");
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 0, 0))
die("failure: check ownership");
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 0, 0))
die("failure: check ownership");
- if (unlinkat(t_dir1_fd, FILE1, 0))
+ if (unlinkat(info->t_dir1_fd, FILE1, 0))
die("failure: delete");
- if (unlinkat(t_dir1_fd, DIR1, AT_REMOVEDIR))
+ if (unlinkat(info->t_dir1_fd, DIR1, AT_REMOVEDIR))
die("failure: delete");
- if (unlinkat(t_dir1_fd, FILE2, 0))
+ if (unlinkat(info->t_dir1_fd, FILE2, 0))
die("failure: delete");
- if (unlinkat(t_dir1_fd, CHRDEV1, 0))
+ if (unlinkat(info->t_dir1_fd, CHRDEV1, 0))
die("failure: delete");
/* create tmpfile via filesystem tmpfile api */
if (supported) {
- tmpfile_fd = openat(t_dir1_fd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
+ tmpfile_fd = openat(info->t_dir1_fd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
if (tmpfile_fd < 0)
die("failure: create");
/* link the temporary file into the filesystem, making it permanent */
- if (linkat(tmpfile_fd, "", t_dir1_fd, FILE3, AT_EMPTY_PATH))
+ if (linkat(tmpfile_fd, "", info->t_dir1_fd, FILE3, AT_EMPTY_PATH))
die("failure: linkat");
if (close(tmpfile_fd))
die("failure: close");
- if (!is_setgid(t_dir1_fd, FILE3, 0))
+ if (!is_setgid(info->t_dir1_fd, FILE3, 0))
die("failure: is_setgid");
- if (!expected_uid_gid(t_dir1_fd, FILE3, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE3, 0, 0, 0))
die("failure: check ownership");
- if (unlinkat(t_dir1_fd, FILE3, 0))
+ if (unlinkat(info->t_dir1_fd, FILE3, 0))
die("failure: delete");
}
die("failure: caps_down_fsetid");
/* create regular file via open() */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, S_IXGRP | S_ISGID);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_CLOEXEC, S_IXGRP | S_ISGID);
if (file1_fd < 0)
die("failure: create");
/* Neither in_group_p() nor capable_wrt_inode_uidgid() so setgid
* bit needs to be stripped.
*/
- if (is_setgid(t_dir1_fd, FILE1, 0))
+ if (is_setgid(info->t_dir1_fd, FILE1, 0))
die("failure: is_setgid");
/* create directory */
- if (mkdirat(t_dir1_fd, DIR1, 0000))
+ if (mkdirat(info->t_dir1_fd, DIR1, 0000))
die("failure: create");
- if (xfs_irix_sgid_inherit_enabled()) {
+ if (xfs_irix_sgid_inherit_enabled(info->t_fstype)) {
/* We're not in_group_p(). */
- if (is_setgid(t_dir1_fd, DIR1, 0))
+ if (is_setgid(info->t_dir1_fd, DIR1, 0))
die("failure: is_setgid");
} else {
/* Directories always inherit the setgid bit. */
- if (!is_setgid(t_dir1_fd, DIR1, 0))
+ if (!is_setgid(info->t_dir1_fd, DIR1, 0))
die("failure: is_setgid");
}
/* create a special file via mknodat() vfs_create */
- if (mknodat(t_dir1_fd, FILE2, S_IFREG | S_ISGID | S_IXGRP, 0))
+ if (mknodat(info->t_dir1_fd, FILE2, S_IFREG | S_ISGID | S_IXGRP, 0))
die("failure: mknodat");
- if (is_setgid(t_dir1_fd, FILE2, 0))
+ if (is_setgid(info->t_dir1_fd, FILE2, 0))
die("failure: is_setgid");
/* create a character device via mknodat() vfs_mknod */
- if (mknodat(t_dir1_fd, CHRDEV1, S_IFCHR | S_ISGID | S_IXGRP, makedev(5, 1)))
+ if (mknodat(info->t_dir1_fd, CHRDEV1, S_IFCHR | S_ISGID | S_IXGRP, makedev(5, 1)))
die("failure: mknodat");
- if (is_setgid(t_dir1_fd, CHRDEV1, 0))
+ if (is_setgid(info->t_dir1_fd, CHRDEV1, 0))
die("failure: is_setgid");
/*
* In setgid directories newly created files always inherit the
* gid from the parent directory. Verify that the file is owned
* by gid 0, not by gid 10000.
*/
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0))
die("failure: check ownership");
/*
* inherit the gid from the parent directory. Verify that the
* directory is owned by gid 0, not by gid 10000.
*/
- if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0))
die("failure: check ownership");
- if (!expected_uid_gid(t_dir1_fd, FILE2, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE2, 0, 0, 0))
die("failure: check ownership");
- if (!expected_uid_gid(t_dir1_fd, CHRDEV1, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, CHRDEV1, 0, 0, 0))
die("failure: check ownership");
- if (unlinkat(t_dir1_fd, FILE1, 0))
+ if (unlinkat(info->t_dir1_fd, FILE1, 0))
die("failure: delete");
- if (unlinkat(t_dir1_fd, DIR1, AT_REMOVEDIR))
+ if (unlinkat(info->t_dir1_fd, DIR1, AT_REMOVEDIR))
die("failure: delete");
- if (unlinkat(t_dir1_fd, FILE2, 0))
+ if (unlinkat(info->t_dir1_fd, FILE2, 0))
die("failure: delete");
- if (unlinkat(t_dir1_fd, CHRDEV1, 0))
+ if (unlinkat(info->t_dir1_fd, CHRDEV1, 0))
die("failure: delete");
/* create tmpfile via filesystem tmpfile api */
if (supported) {
- tmpfile_fd = openat(t_dir1_fd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
+ tmpfile_fd = openat(info->t_dir1_fd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
if (tmpfile_fd < 0)
die("failure: create");
/* link the temporary file into the filesystem, making it permanent */
- if (linkat(tmpfile_fd, "", t_dir1_fd, FILE3, AT_EMPTY_PATH))
+ if (linkat(tmpfile_fd, "", info->t_dir1_fd, FILE3, AT_EMPTY_PATH))
die("failure: linkat");
if (close(tmpfile_fd))
die("failure: close");
- if (is_setgid(t_dir1_fd, FILE3, 0))
+ if (is_setgid(info->t_dir1_fd, FILE3, 0))
die("failure: is_setgid");
- if (!expected_uid_gid(t_dir1_fd, FILE3, 0, 0, 0))
+ if (!expected_uid_gid(info->t_dir1_fd, FILE3, 0, 0, 0))
die("failure: check ownership");
- if (unlinkat(t_dir1_fd, FILE3, 0))
+ if (unlinkat(info->t_dir1_fd, FILE3, 0))
die("failure: delete");
}
return fret;
}
-static int setgid_create_idmapped(void)
+static int setgid_create_idmapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
if (!caps_supported())
return 0;
- if (fchmod(t_dir1_fd, S_IRUSR |
+ if (fchmod(info->t_dir1_fd, S_IRUSR |
S_IWUSR |
S_IRGRP |
S_IWGRP |
}
/* Verify that the sid bits got raised. */
- if (!is_setgid(t_dir1_fd, "", AT_EMPTY_PATH)) {
+ if (!is_setgid(info->t_dir1_fd, "", AT_EMPTY_PATH)) {
log_stderr("failure: is_setgid");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (mkdirat(open_tree_fd, DIR1, 0000))
die("failure: create");
- if (xfs_irix_sgid_inherit_enabled()) {
+ if (xfs_irix_sgid_inherit_enabled(info->t_fstype)) {
/* We're not in_group_p(). */
if (is_setgid(open_tree_fd, DIR1, 0))
die("failure: is_setgid");
return fret;
}
-static int setgid_create_idmapped_in_userns(void)
+static int setgid_create_idmapped_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
if (!caps_supported())
return 0;
- if (fchmod(t_dir1_fd, S_IRUSR |
+ if (fchmod(info->t_dir1_fd, S_IRUSR |
S_IWUSR |
S_IRGRP |
S_IWGRP |
}
/* Verify that the sid bits got raised. */
- if (!is_setgid(t_dir1_fd, "", AT_EMPTY_PATH)) {
+ if (!is_setgid(info->t_dir1_fd, "", AT_EMPTY_PATH)) {
log_stderr("failure: is_setgid");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
* and create a file with fs{g,u}id 0 and verify that the newly created
* file and directory inherit gid 1000, not 0.
*/
- if (fchownat(t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
if (mkdirat(open_tree_fd, DIR1, 0000))
die("failure: create");
- if (xfs_irix_sgid_inherit_enabled()) {
+ if (xfs_irix_sgid_inherit_enabled(info->t_fstype)) {
/* We're not in_group_p(). */
if (is_setgid(open_tree_fd, DIR1, 0))
die("failure: is_setgid");
if (wait_for_pid(pid))
goto out;
- if (fchownat(t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
die("failure: create");
/* Directories always inherit the setgid bit. */
- if (xfs_irix_sgid_inherit_enabled()) {
+ if (xfs_irix_sgid_inherit_enabled(info->t_fstype)) {
/* We're not in_group_p(). */
if (is_setgid(open_tree_fd, DIR1, 0))
die("failure: is_setgid");
#define PTR_TO_INT(p) ((int)((intptr_t)(p)))
#define INT_TO_PTR(u) ((void *)((intptr_t)(u)))
+struct threaded_args {
+ const struct vfstest_info *info;
+ int open_tree_fd;
+};
+
static void *idmapped_mount_create_cb(void *data)
{
- int fret = EXIT_FAILURE, open_tree_fd = PTR_TO_INT(data);
+ int fret = EXIT_FAILURE;
struct mount_attr attr = {
.attr_set = MOUNT_ATTR_IDMAP,
};
+ struct threaded_args *args = data;
/* Changing mount properties on a detached mount. */
attr.userns_fd = get_userns_fd(0, 10000, 10000);
goto out;
}
- if (sys_mount_setattr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr))) {
+ if (sys_mount_setattr(args->open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr))) {
log_stderr("failure: sys_mount_setattr");
goto out;
}
static void *idmapped_mount_operations_cb(void *data)
{
int file1_fd = -EBADF, file2_fd = -EBADF, dir1_fd = -EBADF,
- dir1_fd2 = -EBADF, fret = EXIT_FAILURE,
- open_tree_fd = PTR_TO_INT(data);
+ dir1_fd2 = -EBADF, fret = EXIT_FAILURE;
+ struct threaded_args *args = data;
+ const struct vfstest_info *info = args->info;
if (!switch_fsids(10000, 10000)) {
log_stderr("failure: switch fsids");
goto out;
}
- file1_fd = openat(open_tree_fd, FILE1,
+ file1_fd = openat(args->open_tree_fd, FILE1,
O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- file2_fd = openat(open_tree_fd, FILE2,
+ file2_fd = openat(args->open_tree_fd, FILE2,
O_CREAT | O_EXCL | O_CLOEXEC, 0644);
if (file2_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- if (mkdirat(open_tree_fd, DIR1, 0777)) {
+ if (mkdirat(args->open_tree_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- dir1_fd = openat(open_tree_fd, DIR1,
+ dir1_fd = openat(args->open_tree_fd, DIR1,
O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (dir1_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- if (!__expected_uid_gid(open_tree_fd, FILE1, 0, 0, 0, false) &&
- !__expected_uid_gid(open_tree_fd, FILE1, 0, 10000, 10000, false) &&
- !__expected_uid_gid(open_tree_fd, FILE1, 0, t_overflowuid, t_overflowgid, false)) {
+ if (!__expected_uid_gid(args->open_tree_fd, FILE1, 0, 0, 0, false) &&
+ !__expected_uid_gid(args->open_tree_fd, FILE1, 0, 10000, 10000, false) &&
+ !__expected_uid_gid(args->open_tree_fd, FILE1, 0, info->t_overflowuid, info->t_overflowgid, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!__expected_uid_gid(open_tree_fd, FILE2, 0, 0, 0, false) &&
- !__expected_uid_gid(open_tree_fd, FILE2, 0, 10000, 10000, false) &&
- !__expected_uid_gid(open_tree_fd, FILE2, 0, t_overflowuid, t_overflowgid, false)) {
+ if (!__expected_uid_gid(args->open_tree_fd, FILE2, 0, 0, 0, false) &&
+ !__expected_uid_gid(args->open_tree_fd, FILE2, 0, 10000, 10000, false) &&
+ !__expected_uid_gid(args->open_tree_fd, FILE2, 0, info->t_overflowuid, info->t_overflowgid, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!__expected_uid_gid(open_tree_fd, DIR1, 0, 0, 0, false) &&
- !__expected_uid_gid(open_tree_fd, DIR1, 0, 10000, 10000, false) &&
- !__expected_uid_gid(open_tree_fd, DIR1, 0, t_overflowuid, t_overflowgid, false)) {
+ if (!__expected_uid_gid(args->open_tree_fd, DIR1, 0, 0, 0, false) &&
+ !__expected_uid_gid(args->open_tree_fd, DIR1, 0, 10000, 10000, false) &&
+ !__expected_uid_gid(args->open_tree_fd, DIR1, 0, info->t_overflowuid, info->t_overflowgid, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
if (!__expected_uid_gid(dir1_fd, "", AT_EMPTY_PATH, 0, 0, false) &&
!__expected_uid_gid(dir1_fd, "", AT_EMPTY_PATH, 10000, 10000, false) &&
- !__expected_uid_gid(dir1_fd, "", AT_EMPTY_PATH, t_overflowuid, t_overflowgid, false)) {
+ !__expected_uid_gid(dir1_fd, "", AT_EMPTY_PATH, info->t_overflowuid, info->t_overflowgid, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- dir1_fd2 = openat(t_dir1_fd, DIR1,
+ dir1_fd2 = openat(info->t_dir1_fd, DIR1,
O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (dir1_fd2 < 0) {
log_stderr("failure: openat");
goto out;
}
- if (!__expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0, false) &&
- !__expected_uid_gid(t_dir1_fd, FILE1, 0, 10000, 10000, false)) {
+ if (!__expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0, false) &&
+ !__expected_uid_gid(info->t_dir1_fd, FILE1, 0, 10000, 10000, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!__expected_uid_gid(t_dir1_fd, FILE2, 0, 0, 0, false) &&
- !__expected_uid_gid(t_dir1_fd, FILE2, 0, 10000, 10000, false)) {
+ if (!__expected_uid_gid(info->t_dir1_fd, FILE2, 0, 0, 0, false) &&
+ !__expected_uid_gid(info->t_dir1_fd, FILE2, 0, 10000, 10000, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!__expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0, false) &&
- !__expected_uid_gid(t_dir1_fd, DIR1, 0, 10000, 10000, false)) {
+ if (!__expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0, false) &&
+ !__expected_uid_gid(info->t_dir1_fd, DIR1, 0, 10000, 10000, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
- if (!__expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0, false) &&
- !__expected_uid_gid(t_dir1_fd, DIR1, 0, 10000, 10000, false)) {
+ if (!__expected_uid_gid(info->t_dir1_fd, DIR1, 0, 0, 0, false) &&
+ !__expected_uid_gid(info->t_dir1_fd, DIR1, 0, 10000, 10000, false)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
pthread_exit(INT_TO_PTR(fret));
}
-static int threaded_idmapped_mount_interactions(void)
+static int threaded_idmapped_mount_interactions(const struct vfstest_info *info)
{
int i;
int fret = -1;
}
if (pid == 0) {
int open_tree_fd = -EBADF;
+ struct threaded_args args = {
+ .info = info,
+ .open_tree_fd = -EBADF,
+ };
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (open_tree_fd < 0)
die("failure: sys_open_tree");
+ args.open_tree_fd = open_tree_fd;
+
if (pthread_create(&threads[0], &thread_attr,
idmapped_mount_create_cb,
- INT_TO_PTR(open_tree_fd)))
+ &args))
die("failure: pthread_create");
if (pthread_create(&threads[1], &thread_attr,
idmapped_mount_operations_cb,
- INT_TO_PTR(open_tree_fd)))
+ &args))
die("failure: pthread_create");
ret1 = pthread_join(threads[0], INT_TO_PTR(tret1));
goto out;
}
- rm_r(t_dir1_fd, ".");
+ rm_r(info->t_dir1_fd, ".");
}
return fret;
}
-static int setattr_truncate(void)
+static int setattr_truncate(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF;
/* create regular file via open() */
- file1_fd = openat(t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, S_IXGRP | S_ISGID);
+ file1_fd = openat(info->t_dir1_fd, FILE1, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, S_IXGRP | S_ISGID);
if (file1_fd < 0) {
log_stderr("failure: create");
goto out;
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0)) {
log_stderr("failure: check ownership");
goto out;
}
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, FILE1, 0, 0, 0)) {
log_stderr("failure: check ownership");
goto out;
}
goto out;
}
- if (unlinkat(t_dir1_fd, FILE1, 0)) {
+ if (unlinkat(info->t_dir1_fd, FILE1, 0)) {
log_stderr("failure: remove");
goto out;
}
return fret;
}
-static int setattr_truncate_idmapped(void)
+static int setattr_truncate_idmapped(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int setattr_truncate_idmapped_in_userns(void)
+static int setattr_truncate_idmapped_in_userns(const struct vfstest_info *info)
{
int fret = -1;
int file1_fd = -EBADF, open_tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (wait_for_pid(pid))
goto out;
- if (fchownat(t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
if (wait_for_pid(pid))
goto out;
- if (fchownat(t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
- if (fchownat(t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
+ if (fchownat(info->t_dir1_fd, "", -1, 0, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
}
return fret;
}
-static int nested_userns(void)
+static int nested_userns(const struct vfstest_info *info)
{
int fret = -1;
int ret;
* Create one directory where we create files for each uid/gid within
* the first userns.
*/
- if (mkdirat(t_dir1_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- fd_dir1 = openat(t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
+ fd_dir1 = openat(info->t_dir1_fd, DIR1, O_DIRECTORY | O_CLOEXEC);
if (fd_dir1 < 0) {
log_stderr("failure: openat");
goto out;
snprintf(file, sizeof(file), DIR1 "/" FILE1 "_%u", id);
- if (mknodat(t_dir1_fd, file, S_IFREG | 0644, 0)) {
+ if (mknodat(info->t_dir1_fd, file, S_IFREG | 0644, 0)) {
log_stderr("failure: create %s", file);
goto out;
}
- if (fchownat(t_dir1_fd, file, id, id, AT_SYMLINK_NOFOLLOW)) {
+ if (fchownat(info->t_dir1_fd, file, id, id, AT_SYMLINK_NOFOLLOW)) {
log_stderr("failure: fchownat %s", file);
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, file, 0, id, id)) {
+ if (!expected_uid_gid(info->t_dir1_fd, file, 0, id, id)) {
log_stderr("failure: check ownership %s", file);
goto out;
}
}
/* Create detached mounts for all the user namespaces. */
- fd_open_tree_level1 = sys_open_tree(t_dir1_fd, DIR1,
+ fd_open_tree_level1 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
goto out;
}
- fd_open_tree_level2 = sys_open_tree(t_dir1_fd, DIR1,
+ fd_open_tree_level2 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
goto out;
}
- fd_open_tree_level3 = sys_open_tree(t_dir1_fd, DIR1,
+ fd_open_tree_level3 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
goto out;
}
- fd_open_tree_level4 = sys_open_tree(t_dir1_fd, DIR1,
+ fd_open_tree_level4 = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
if (id == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else if (id == 1000) {
id_level3 = id + 2000000; /* We punched a hole in the map at 1000. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
goto out;
}
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid)) {
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid)) {
log_stderr("failure: check ownership %s", file);
goto out;
}
if (id == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else if (id == 1000) {
id_level3 = id + 1000000; /* We punched a hole in the map at 1000. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
if (!bret)
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
}
snprintf(file, sizeof(file), FILE1 "_%u", id);
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
id_level2 = id;
if (id == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else if (id == 1000) {
id_level3 = id; /* We punched a hole in the map at 1000. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
if (!bret)
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
}
snprintf(file, sizeof(file), FILE1 "_%u", id);
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
if (id == 1000) {
id_level2 = id;
bret = expected_uid_gid(fd_open_tree_level2, file, 0, id_level2, id_level2);
} else {
- bret = expected_uid_gid(fd_open_tree_level2, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level2, file, 0, info->t_overflowuid, info->t_overflowgid);
}
if (!bret)
die("failure: check ownership %s", file);
if (id == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else {
id_level3 = id; /* Rest is business as usual. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
if (!bret)
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
}
snprintf(file, sizeof(file), FILE1 "_%u", id);
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level2, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level2, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
}
if (id_new == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else if (id_new == 1000) {
id_level3 = id_new + 1000000; /* We punched a hole in the map at 1000. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
if (!bret)
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
/* Revert ownership. */
if (fchownat(fd_open_tree_level2, file, id_new, id_new, AT_SYMLINK_NOFOLLOW))
die("failure: fchownat %s", file);
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
id_level2 = id_new;
if (id_new == 999) {
/* This id is unmapped. */
- bret = expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid);
+ bret = expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid);
} else if (id_new == 1000) {
id_level3 = id_new; /* We punched a hole in the map at 1000. */
bret = expected_uid_gid(fd_open_tree_level3, file, 0, id_level3, id_level3);
if (!bret)
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
/* Revert ownership. */
die("failure: fchownat %s", file);
}
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
/* There's no id 1000 anymore as we changed ownership for id 1000 to 1001 above. */
- if (!expected_uid_gid(fd_open_tree_level2, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level2, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
if (id_new == 999) {
* We did not change ownership as we can't
* chown from an unmapped id.
*/
- if (!expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
} else {
if (!expected_uid_gid(fd_open_tree_level3, file, 0, id_new, id_new))
die("failure: check ownership %s", file);
}
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
/* Revert ownership. */
if (!fchownat(fd_open_tree_level4, file, id_new, id_new, AT_SYMLINK_NOFOLLOW))
die("failure: fchownat %s", file);
- if (!expected_uid_gid(fd_open_tree_level1, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level1, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level2, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level2, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level3, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level3, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
- if (!expected_uid_gid(fd_open_tree_level4, file, 0, t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(fd_open_tree_level4, file, 0, info->t_overflowuid, info->t_overflowgid))
die("failure: check ownership %s", file);
}
#define BTRFS_SUBVOLUME1_RENAME "subvol1_rename"
#define BTRFS_SUBVOLUME2 "subvol2"
-static int btrfs_subvolumes_fsids_mapped(void)
+static int btrfs_subvolumes_fsids_mapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_fsids_mapped_userns(void)
+static int btrfs_subvolumes_fsids_mapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_fsids_unmapped(void)
+static int btrfs_subvolumes_fsids_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
};
/* create directory for rename test */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
/* change ownership of all files to uid 0 */
- if (fchownat(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (fchownat(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: fchownat");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_fsids_unmapped_userns(void)
+static int btrfs_subvolumes_fsids_unmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF, userns_fd = -EBADF;
pid_t pid;
/* create directory for rename test */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
/* change ownership of all files to uid 0 */
- if (fchownat(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (fchownat(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: fchownat");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (!switch_userns(userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0,
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
/*
return fret;
}
-static int btrfs_snapshots_fsids_mapped(void)
+static int btrfs_snapshots_fsids_mapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_fsids_mapped_userns(void)
+static int btrfs_snapshots_fsids_mapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_fsids_unmapped(void)
+static int btrfs_snapshots_fsids_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
return 0;
/* create directory for rename test */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
/* change ownership of all files to uid 0 */
- if (fchownat(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (fchownat(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: fchownat");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_fsids_unmapped_userns(void)
+static int btrfs_snapshots_fsids_unmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, subvolume_fd = -EBADF, tree_fd = -EBADF,
return 0;
/* create directory for rename test */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
/* change ownership of all files to uid 0 */
- if (fchownat(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (fchownat(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: fchownat");
goto out;
}
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
if (!switch_userns(userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0,
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
/*
return fret;
}
-static int btrfs_subvolumes_fsids_mapped_user_subvol_rm_allowed(void)
+static int btrfs_subvolumes_fsids_mapped_user_subvol_rm_allowed(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_mnt_scratch_fd, "",
+ open_tree_fd = sys_open_tree(info->t_mnt_scratch_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_fsids_mapped_userns_user_subvol_rm_allowed(void)
+static int btrfs_subvolumes_fsids_mapped_userns_user_subvol_rm_allowed(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_mnt_scratch_fd, "",
+ open_tree_fd = sys_open_tree(info->t_mnt_scratch_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_fsids_mapped_user_subvol_rm_allowed(void)
+static int btrfs_snapshots_fsids_mapped_user_subvol_rm_allowed(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_mnt_scratch_fd, "",
+ open_tree_fd = sys_open_tree(info->t_mnt_scratch_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_fsids_mapped_userns_user_subvol_rm_allowed(void)
+static int btrfs_snapshots_fsids_mapped_userns_user_subvol_rm_allowed(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_mnt_scratch_fd, "",
+ open_tree_fd = sys_open_tree(info->t_mnt_scratch_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_delete_by_spec_id(void)
+static int btrfs_delete_by_spec_id(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, subvolume_fd = -EBADF, tree_fd = -EBADF;
}
/* create subvolume */
- if (btrfs_create_subvolume(t_mnt_scratch_fd, "A")) {
+ if (btrfs_create_subvolume(info->t_mnt_scratch_fd, "A")) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
/* create subvolume */
- if (btrfs_create_subvolume(t_mnt_scratch_fd, "B")) {
+ if (btrfs_create_subvolume(info->t_mnt_scratch_fd, "B")) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- subvolume_fd = openat(t_mnt_scratch_fd, "B", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
+ subvolume_fd = openat(info->t_mnt_scratch_fd, "B", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subvolume_fd < 0) {
log_stderr("failure: openat");
goto out;
safe_close(subvolume_fd);
- subvolume_fd = openat(t_mnt_scratch_fd, "A", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
+ subvolume_fd = openat(info->t_mnt_scratch_fd, "A", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subvolume_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- subvolume_fd = openat(t_mnt_scratch_fd, "B/C", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
+ subvolume_fd = openat(info->t_mnt_scratch_fd, "B/C", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subvolume_fd < 0) {
log_stderr("failure: openat");
goto out;
goto out;
}
- if (sys_mount(t_device_scratch, t_mountpoint, "btrfs", 0, "subvol=B/C")) {
+ if (sys_mount(info->t_device_scratch, info->t_mountpoint, "btrfs", 0, "subvol=B/C")) {
log_stderr("failure: mount");
goto out;
}
- open_tree_fd = sys_open_tree(-EBADF, t_mountpoint,
+ open_tree_fd = sys_open_tree(-EBADF, info->t_mountpoint,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
if (errno != EOPNOTSUPP)
die("failure: errno");
- if (btrfs_delete_subvolume_id(t_mnt_scratch_fd, subvolume_id1))
+ if (btrfs_delete_subvolume_id(info->t_mnt_scratch_fd, subvolume_id1))
die("failure: btrfs_delete_subvolume_id");
exit(EXIT_SUCCESS);
safe_close(attr.userns_fd);
safe_close(open_tree_fd);
safe_close(tree_fd);
- sys_umount2(t_mountpoint, MNT_DETACH);
- btrfs_delete_subvolume_id(t_mnt_scratch_fd, subvolume_id2);
- btrfs_delete_subvolume(t_mnt_scratch_fd, "B");
+ sys_umount2(info->t_mountpoint, MNT_DETACH);
+ btrfs_delete_subvolume_id(info->t_mnt_scratch_fd, subvolume_id2);
+ btrfs_delete_subvolume(info->t_mnt_scratch_fd, "B");
return fret;
}
-static int btrfs_subvolumes_setflags_fsids_mapped(void)
+static int btrfs_subvolumes_setflags_fsids_mapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_setflags_fsids_mapped_userns(void)
+static int btrfs_subvolumes_setflags_fsids_mapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_subvolumes_setflags_fsids_unmapped(void)
+static int btrfs_subvolumes_setflags_fsids_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* create subvolume */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
return fret;
}
-static int btrfs_subvolumes_setflags_fsids_unmapped_userns(void)
+static int btrfs_subvolumes_setflags_fsids_unmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF, userns_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* create subvolume */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
if (!switch_userns(userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0,
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (btrfs_get_subvolume_ro(subvolume_fd, &read_only))
return fret;
}
-static int btrfs_snapshots_setflags_fsids_mapped(void)
+static int btrfs_snapshots_setflags_fsids_mapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_setflags_fsids_mapped_userns(void)
+static int btrfs_snapshots_setflags_fsids_mapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
return fret;
}
-static int btrfs_snapshots_setflags_fsids_unmapped(void)
+static int btrfs_snapshots_setflags_fsids_unmapped(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, subvolume_fd = -EBADF, tree_fd = -EBADF;
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* create subvolume */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
goto out;
}
- subvolume_fd = openat(t_dir1_fd, BTRFS_SUBVOLUME1,
+ subvolume_fd = openat(info->t_dir1_fd, BTRFS_SUBVOLUME1,
O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subvolume_fd < 0) {
log_stderr("failure: openat");
}
/* create read-write snapshot */
- if (btrfs_create_snapshot(subvolume_fd, t_dir1_fd,
+ if (btrfs_create_snapshot(subvolume_fd, info->t_dir1_fd,
BTRFS_SUBVOLUME1_SNAPSHOT1, 0)) {
log_stderr("failure: btrfs_create_snapshot");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1_SNAPSHOT1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1_SNAPSHOT1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
return fret;
}
-static int btrfs_snapshots_setflags_fsids_unmapped_userns(void)
+static int btrfs_snapshots_setflags_fsids_unmapped_userns(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF, subvolume_fd = -EBADF, tree_fd = -EBADF,
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, "",
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, "",
AT_EMPTY_PATH |
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
}
/* create subvolume */
- if (btrfs_create_subvolume(t_dir1_fd, BTRFS_SUBVOLUME1)) {
+ if (btrfs_create_subvolume(info->t_dir1_fd, BTRFS_SUBVOLUME1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
goto out;
}
- subvolume_fd = openat(t_dir1_fd, BTRFS_SUBVOLUME1,
+ subvolume_fd = openat(info->t_dir1_fd, BTRFS_SUBVOLUME1,
O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subvolume_fd < 0) {
log_stderr("failure: openat");
}
/* create read-write snapshot */
- if (btrfs_create_snapshot(subvolume_fd, t_dir1_fd,
+ if (btrfs_create_snapshot(subvolume_fd, info->t_dir1_fd,
BTRFS_SUBVOLUME1_SNAPSHOT1, 0)) {
log_stderr("failure: btrfs_create_snapshot");
goto out;
}
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1_SNAPSHOT1, 0, 0, 0)) {
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1_SNAPSHOT1, 0, 0, 0)) {
log_stderr("failure: expected_uid_gid");
goto out;
}
if (!switch_userns(userns_fd, 0, 0, false))
die("failure: switch_userns");
- if (!expected_uid_gid(t_dir1_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ if (!expected_uid_gid(info->t_dir1_fd, BTRFS_SUBVOLUME1, 0,
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
if (!expected_uid_gid(open_tree_fd, BTRFS_SUBVOLUME1, 0,
- t_overflowuid, t_overflowgid))
+ info->t_overflowuid, info->t_overflowgid))
die("failure: expected_uid_gid");
/*
* | |-/mnt/test/mnt1 /dev/loop1[/subvol1] btrfs rw,relatime,space_cache,user_subvol_rm_allowed,subvolid=268,subvol=/subvol1
* '-/mnt/scratch /dev/loop1 btrfs rw,relatime,space_cache,user_subvol_rm_allowed,subvolid=5,subvol=/
*/
-static int btrfs_subvolume_lookup_user(void)
+static int btrfs_subvolume_lookup_user(const struct vfstest_info *info)
{
int fret = -1, i;
int dir1_fd = -EBADF, dir2_fd = -EBADF, mnt_fd = -EBADF,
for (i = 0; i < ARRAY_SIZE(subvolume_ids); i++)
subvolume_ids[i] = -EINVAL;
- if (btrfs_create_subvolume(t_mnt_scratch_fd, BTRFS_SUBVOLUME_SUBVOL1)) {
+ if (btrfs_create_subvolume(info->t_mnt_scratch_fd, BTRFS_SUBVOLUME_SUBVOL1)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- if (btrfs_create_subvolume(t_mnt_scratch_fd, BTRFS_SUBVOLUME_SUBVOL2)) {
+ if (btrfs_create_subvolume(info->t_mnt_scratch_fd, BTRFS_SUBVOLUME_SUBVOL2)) {
log_stderr("failure: btrfs_create_subvolume");
goto out;
}
- subvolume_fds[BTRFS_SUBVOLUME_SUBVOL1_ID] = openat(t_mnt_scratch_fd,
+ subvolume_fds[BTRFS_SUBVOLUME_SUBVOL1_ID] = openat(info->t_mnt_scratch_fd,
BTRFS_SUBVOLUME_SUBVOL1,
O_CLOEXEC | O_DIRECTORY);
if (subvolume_fds[BTRFS_SUBVOLUME_SUBVOL1_ID] < 0) {
goto out;
}
- if (mkdirat(t_mnt_fd, BTRFS_SUBVOLUME_MNT, 0777)) {
+ if (mkdirat(info->t_mnt_fd, BTRFS_SUBVOLUME_MNT, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- snprintf(t_buf, sizeof(t_buf), "%s/%s", t_mountpoint, BTRFS_SUBVOLUME_MNT);
- if (sys_mount(t_device_scratch, t_buf, "btrfs", 0,
+ snprintf(t_buf, sizeof(t_buf), "%s/%s", info->t_mountpoint, BTRFS_SUBVOLUME_MNT);
+ if (sys_mount(info->t_device_scratch, t_buf, "btrfs", 0,
"subvol=" BTRFS_SUBVOLUME_SUBVOL1)) {
log_stderr("failure: mount");
goto out;
}
- mnt_fd = openat(t_mnt_fd, BTRFS_SUBVOLUME_MNT, O_CLOEXEC | O_DIRECTORY);
+ mnt_fd = openat(info->t_mnt_fd, BTRFS_SUBVOLUME_MNT, O_CLOEXEC | O_DIRECTORY);
if (mnt_fd < 0) {
log_stderr("failure: openat");
goto out;
}
- if (chown_r(t_mnt_scratch_fd, ".", 1000, 1000)) {
+ if (chown_r(info->t_mnt_scratch_fd, ".", 1000, 1000)) {
log_stderr("failure: chown_r");
goto out;
}
- subvolume_fds[BTRFS_SUBVOLUME_SUBVOL2_ID] = openat(t_mnt_scratch_fd,
+ subvolume_fds[BTRFS_SUBVOLUME_SUBVOL2_ID] = openat(info->t_mnt_scratch_fd,
BTRFS_SUBVOLUME_SUBVOL2,
O_CLOEXEC | O_DIRECTORY);
if (subvolume_fds[BTRFS_SUBVOLUME_SUBVOL2_ID] < 0) {
goto out;
}
- subvolume_fds[BTRFS_SUBVOLUME_SUBVOL3_ID] = openat(t_mnt_scratch_fd,
+ subvolume_fds[BTRFS_SUBVOLUME_SUBVOL3_ID] = openat(info->t_mnt_scratch_fd,
BTRFS_SUBVOLUME_SUBVOL1xSUBVOL3,
O_CLOEXEC | O_DIRECTORY);
if (subvolume_fds[BTRFS_SUBVOLUME_SUBVOL3_ID] < 0) {
goto out;
}
- subvolume_fds[BTRFS_SUBVOLUME_SUBVOL4_ID] = openat(t_mnt_scratch_fd,
+ subvolume_fds[BTRFS_SUBVOLUME_SUBVOL4_ID] = openat(info->t_mnt_scratch_fd,
BTRFS_SUBVOLUME_SUBVOL1xDIR1xDIR2xSUBVOL4,
O_CLOEXEC | O_DIRECTORY);
if (subvolume_fds[BTRFS_SUBVOLUME_SUBVOL4_ID] < 0) {
safe_close(userns_fd);
for (i = 0; i < ARRAY_SIZE(subvolume_fds); i++)
safe_close(subvolume_fds[i]);
- snprintf(t_buf, sizeof(t_buf), "%s/%s", t_mountpoint, BTRFS_SUBVOLUME_MNT);
+ snprintf(t_buf, sizeof(t_buf), "%s/%s", info->t_mountpoint, BTRFS_SUBVOLUME_MNT);
sys_umount2(t_buf, MNT_DETACH);
- unlinkat(t_mnt_fd, BTRFS_SUBVOLUME_MNT, AT_REMOVEDIR);
+ unlinkat(info->t_mnt_fd, BTRFS_SUBVOLUME_MNT, AT_REMOVEDIR);
return fret;
}
* Only {g,u}id 1000 and 1001 have a mapping in the idmapped mount. Other
* {g,u}id are unmapped.
*/
-static int setattr_fix_968219708108(void)
+static int setattr_fix_968219708108(const struct vfstest_info *info)
{
int fret = -1;
int open_tree_fd = -EBADF;
log_debug("Found " USER1 " with uid(%d) and gid(%d) and " USER2 " with uid(%d) and gid(%d)",
user1_uid, user1_gid, user2_uid, user2_gid);
- if (mkdirat(t_dir1_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- if (mknodat(t_dir1_fd, DIR1 "/" FILE1, S_IFREG | 0644, 0)) {
+ if (mknodat(info->t_dir1_fd, DIR1 "/" FILE1, S_IFREG | 0644, 0)) {
log_stderr("failure: mknodat");
goto out;
}
- if (chown_r(t_mnt_fd, T_DIR1, user1_uid, user1_gid)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, user1_uid, user1_gid)) {
log_stderr("failure: chown_r");
goto out;
}
- if (mknodat(t_dir1_fd, DIR1 "/" FILE2, S_IFREG | 0644, 0)) {
+ if (mknodat(info->t_dir1_fd, DIR1 "/" FILE2, S_IFREG | 0644, 0)) {
log_stderr("failure: mknodat");
goto out;
}
- if (fchownat(t_dir1_fd, DIR1 "/" FILE2, user2_uid, user2_gid, AT_SYMLINK_NOFOLLOW)) {
+ if (fchownat(info->t_dir1_fd, DIR1 "/" FILE2, user2_uid, user2_gid, AT_SYMLINK_NOFOLLOW)) {
log_stderr("failure: fchownat");
goto out;
}
- print_r(t_mnt_fd, T_DIR1);
+ print_r(info->t_mnt_fd, T_DIR1);
/* u:1000:1001:1 */
ret = add_map_entry(&idmap, user1_uid, user2_uid, 1, ID_TYPE_UID);
goto out;
}
- open_tree_fd = sys_open_tree(t_dir1_fd, DIR1,
+ open_tree_fd = sys_open_tree(info->t_dir1_fd, DIR1,
AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW |
OPEN_TREE_CLOEXEC |
/**
* setxattr_fix_705191b03d50 - test for commit 705191b03d50 ("fs: fix acl translation").
*/
-static int setxattr_fix_705191b03d50(void)
+static int setxattr_fix_705191b03d50(const struct vfstest_info *info)
{
int fret = -1;
int fd_userns = -EBADF;
log_debug("Found " USER1 " with uid(%d) and gid(%d)", user1_uid, user1_gid);
- if (mkdirat(t_dir1_fd, DIR1, 0777)) {
+ if (mkdirat(info->t_dir1_fd, DIR1, 0777)) {
log_stderr("failure: mkdirat");
goto out;
}
- if (chown_r(t_mnt_fd, T_DIR1, user1_uid, user1_gid)) {
+ if (chown_r(info->t_mnt_fd, T_DIR1, user1_uid, user1_gid)) {
log_stderr("failure: chown_r");
goto out;
}
- print_r(t_mnt_fd, T_DIR1);
+ print_r(info->t_mnt_fd, T_DIR1);
/* u:0:user1_uid:1 */
ret = add_map_entry(&idmap, user1_uid, 0, 1, ID_TYPE_UID);
if (sys_mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0))
die("failure: turn mount propagation off");
- snprintf(t_buf, sizeof(t_buf), "%s/%s/%s", t_mountpoint, T_DIR1, DIR1);
+ snprintf(t_buf, sizeof(t_buf), "%s/%s/%s", info->t_mountpoint, T_DIR1, DIR1);
if (sys_mount("none", t_buf, "tmpfs", 0, "mode=0755"))
die("failure: mount");
- snprintf(t_buf, sizeof(t_buf), "%s/%s/%s/%s", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "%s/%s/%s/%s", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (mkdir(t_buf, 0700))
die("failure: mkdir");
- snprintf(t_buf, sizeof(t_buf), "setfacl -m u:100:rwx %s/%s/%s/%s", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "setfacl -m u:100:rwx %s/%s/%s/%s", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (system(t_buf))
die("failure: system");
- snprintf(t_buf, sizeof(t_buf), "getfacl -n -p %s/%s/%s/%s | grep -q user:100:rwx", t_mountpoint, T_DIR1, DIR1, DIR3);
+ snprintf(t_buf, sizeof(t_buf), "getfacl -n -p %s/%s/%s/%s | grep -q user:100:rwx", info->t_mountpoint, T_DIR1, DIR1, DIR3);
if (system(t_buf))
die("failure: system");
{ setxattr_fix_705191b03d50, T_REQUIRE_USERNS, "test that setxattr works correctly for userns mountable filesystems", },
};
-static bool run_test(struct test_struct suite[], size_t suite_size)
+static bool run_test(struct vfstest_info *info, const struct test_struct suite[], size_t suite_size)
{
int i;
for (i = 0; i < suite_size; i++) {
- struct test_struct *t = &suite[i];
+ const struct test_struct *t = &suite[i];
int ret;
pid_t pid;
* mounts only run vfs generic tests.
*/
if ((t->support_flags & T_REQUIRE_IDMAPPED_MOUNTS &&
- !t_fs_allow_idmap) ||
- (t->support_flags & T_REQUIRE_USERNS && !t_has_userns)) {
+ !info->t_fs_allow_idmap) ||
+ (t->support_flags & T_REQUIRE_USERNS && !info->t_has_userns)) {
log_debug("Skipping test %s", t->description);
continue;
}
- test_setup();
+ test_setup(info);
pid = fork();
if (pid < 0)
return false;
if (pid == 0) {
- ret = t->test();
+ ret = t->test(info);
if (ret)
die("failure: %s", t->description);
}
ret = wait_for_pid(pid);
- test_cleanup();
+ test_cleanup(info);
if (ret)
return false;
return true;
}
-static bool fs_allow_idmap(void)
+static bool fs_allow_idmap(const struct vfstest_info *info)
{
int ret;
int open_tree_fd = -EBADF;
if (attr.userns_fd < 0)
return false;
- open_tree_fd = sys_open_tree(t_mnt_fd, "",
+ open_tree_fd = sys_open_tree(info->t_mnt_fd, "",
AT_EMPTY_PATH | AT_NO_AUTOMOUNT |
AT_SYMLINK_NOFOLLOW | OPEN_TREE_CLOEXEC |
OPEN_TREE_CLONE);
int main(int argc, char *argv[])
{
+ struct vfstest_info info;
int fret, ret;
int index = 0;
bool idmapped_mounts_supported = false, test_btrfs = false,
test_nested_userns = false, test_setattr_fix_968219708108 = false,
test_setxattr_fix_705191b03d50 = false;
+ init_vfstest_info(&info);
+
while ((ret = getopt_long_only(argc, argv, "", longopts, &index)) != -1) {
switch (ret) {
case 'd':
- t_device = optarg;
+ info.t_device = optarg;
break;
case 'f':
- t_fstype = optarg;
+ info.t_fstype = optarg;
break;
case 'm':
- t_mountpoint = optarg;
+ info.t_mountpoint = optarg;
break;
case 's':
idmapped_mounts_supported = true;
test_btrfs = true;
break;
case 'a':
- t_mountpoint_scratch = optarg;
+ info.t_mountpoint_scratch = optarg;
break;
case 'e':
- t_device_scratch = optarg;
+ info.t_device_scratch = optarg;
break;
case 'i':
test_setattr_fix_968219708108 = true;
}
}
- if (!t_device)
+ if (!info.t_device)
die_errno(EINVAL, "test device missing");
- if (!t_fstype)
+ if (!info.t_fstype)
die_errno(EINVAL, "test filesystem type missing");
- if (!t_mountpoint)
+ if (!info.t_mountpoint)
die_errno(EINVAL, "mountpoint of test device missing");
/* create separate mount namespace */
if (sys_mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0))
die("failure: turn mount propagation off");
- t_mnt_fd = openat(-EBADF, t_mountpoint, O_CLOEXEC | O_DIRECTORY);
- if (t_mnt_fd < 0)
- die("failed to open %s", t_mountpoint);
+ info.t_mnt_fd = openat(-EBADF, info.t_mountpoint, O_CLOEXEC | O_DIRECTORY);
+ if (info.t_mnt_fd < 0)
+ die("failed to open %s", info.t_mountpoint);
- t_mnt_scratch_fd = openat(-EBADF, t_mountpoint_scratch, O_CLOEXEC | O_DIRECTORY);
- if (t_mnt_fd < 0)
- die("failed to open %s", t_mountpoint_scratch);
+ info.t_mnt_scratch_fd = openat(-EBADF, info.t_mountpoint_scratch, O_CLOEXEC | O_DIRECTORY);
+ if (info.t_mnt_fd < 0)
+ die("failed to open %s", info.t_mountpoint_scratch);
- t_fs_allow_idmap = fs_allow_idmap();
+ info.t_fs_allow_idmap = fs_allow_idmap(&info);
if (idmapped_mounts_supported) {
/*
* Caller just wants to know whether the filesystem we're on
* supports idmapped mounts.
*/
- if (!t_fs_allow_idmap)
+ if (!info.t_fs_allow_idmap)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
}
- t_has_userns = sys_has_userns();
+ info.t_has_userns = sys_has_userns();
/* don't copy ENOSYS errno to child process on older kernel */
errno = 0;
- stash_overflowuid();
- stash_overflowgid();
+ stash_overflowuid(&info);
+ stash_overflowgid(&info);
fret = EXIT_FAILURE;
- if (test_core && !run_test(basic_suite, ARRAY_SIZE(basic_suite)))
+ if (test_core && !run_test(&info, basic_suite, ARRAY_SIZE(basic_suite)))
goto out;
if (test_fscaps_regression &&
- !run_test(fscaps_in_ancestor_userns,
+ !run_test(&info, fscaps_in_ancestor_userns,
ARRAY_SIZE(fscaps_in_ancestor_userns)))
goto out;
if (test_nested_userns &&
- !run_test(t_nested_userns, ARRAY_SIZE(t_nested_userns)))
+ !run_test(&info, t_nested_userns, ARRAY_SIZE(t_nested_userns)))
goto out;
- if (test_btrfs && !run_test(t_btrfs, ARRAY_SIZE(t_btrfs)))
+ if (test_btrfs && !run_test(&info, t_btrfs, ARRAY_SIZE(t_btrfs)))
goto out;
if (test_setattr_fix_968219708108 &&
- !run_test(t_setattr_fix_968219708108,
+ !run_test(&info, t_setattr_fix_968219708108,
ARRAY_SIZE(t_setattr_fix_968219708108)))
goto out;
if (test_setxattr_fix_705191b03d50 &&
- !run_test(t_setxattr_fix_705191b03d50,
+ !run_test(&info, t_setxattr_fix_705191b03d50,
ARRAY_SIZE(t_setxattr_fix_705191b03d50)))
goto out;