qemu-e2k/linux-user
Filip Bozuta d6092e085d linux-user: Add support for a group of btrfs ioctls used for subvolumes
This patch implements functionality of following ioctls:

BTRFS_IOC_SUBVOL_CREATE - Creating a btrfs subvolume

    Create a btrfs subvolume. The subvolume is created using the ioctl's
    third argument which represents a pointer to a following structure
    type:

    struct btrfs_ioctl_vol_args {
	__s64 fd;
	char name[BTRFS_PATH_NAME_MAX + 1];
    };

    Before calling this ioctl, the fields of this structure should be filled
    with aproppriate values. The fd field represents the file descriptor
    value of the subvolume and the name field represents the subvolume
    path.

BTRFS_IOC_SUBVOL_GETFLAGS - Getting subvolume flags

    Read the flags of the btrfs subvolume. The flags are read using
    the ioctl's third argument that is a pointer of __u64 (unsigned long).
    The third argument represents a bit mask that can be composed of following
    values:
    BTRFS_SUBVOL_RDONLY           (1ULL << 1)
    BTRFS_SUBVOL_QGROUP_INHERIT   (1ULL << 2)
    BTRFS_DEVICE_SPEC_BY_ID       (1ULL << 3)
    BTRFS_SUBVOL_SPEC_BY_ID       (1ULL << 4)

BTRFS_IOC_SUBVOL_SETFLAGS - Setting subvolume flags

    Set the flags of the btrfs subvolume. The flags are set using the
    ioctl's third argument that is a pointer of __u64 (unsigned long).
    The third argument represents a bit mask that can be composed of same
    values as in the case of previous ioctl (BTRFS_IOC_SUBVOL_GETFLAGS).

BTRFS_IOC_SUBVOL_GETINFO - Getting subvolume information

    Read information about the subvolume. The subvolume information is
    returned in the ioctl's third argument which represents a pointer to
    a following structure type:

    struct btrfs_ioctl_get_subvol_info_args {
	/* Id of this subvolume */
	__u64 treeid;

	/* Name of this subvolume, used to get the real name at mount point */
	char name[BTRFS_VOL_NAME_MAX + 1];

	/*
	 * Id of the subvolume which contains this subvolume.
	 * Zero for top-level subvolume or a deleted subvolume.
	 */
	__u64 parent_id;

	/*
	 * Inode number of the directory which contains this subvolume.
	 * Zero for top-level subvolume or a deleted subvolume
	 */
	__u64 dirid;

	/* Latest transaction id of this subvolume */
	__u64 generation;

	/* Flags of this subvolume */
	__u64 flags;

	/* UUID of this subvolume */
	__u8 uuid[BTRFS_UUID_SIZE];

	/*
	 * UUID of the subvolume of which this subvolume is a snapshot.
	 * All zero for a non-snapshot subvolume.
	 */
	__u8 parent_uuid[BTRFS_UUID_SIZE];

	/*
	 * UUID of the subvolume from which this subvolume was received.
	 * All zero for non-received subvolume.
	 */
	__u8 received_uuid[BTRFS_UUID_SIZE];

	/* Transaction id indicating when change/create/send/receive happened */
	__u64 ctransid;
	__u64 otransid;
	__u64 stransid;
	__u64 rtransid;
	/* Time corresponding to c/o/s/rtransid */
	struct btrfs_ioctl_timespec ctime;
	struct btrfs_ioctl_timespec otime;
	struct btrfs_ioctl_timespec stime;
	struct btrfs_ioctl_timespec rtime;

	/* Must be zero */
	__u64 reserved[8];
     };

     All of the fields of this structure are filled after the ioctl call.

Implementation notes:

    Ioctls BTRFS_IOC_SUBVOL_CREATE and BTRFS_IOC_SUBVOL_GETINFO have structure
    types as third arguments. That is the reason why a corresponding definition
    are added in file 'linux-user/syscall_types.h'.

    The line '#include <linux/btrfs.h>' is added in file 'linux-user/syscall.c' to
    recognise preprocessor definitions for these ioctls. Since the file "linux/btrfs.h"
    was added in the kernel version 3.9, it is enwrapped in an #ifdef statement
    with parameter CONFIG_BTRFS which is defined in 'configure' if the
    header file is present.

Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Tested-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200823195014.116226-2-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-09-03 01:09:35 +02:00
..
aarch64 linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
alpha linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
arm linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
cris linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
generic linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
host linux-user: Add safe_syscall for riscv64 host 2018-12-26 06:40:02 +11:00
hppa linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
i386 linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
m68k linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
microblaze linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
mips linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
mips64 linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory 2020-08-27 12:29:50 +02:00
nios2 linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
openrisc linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
ppc linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
riscv linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
s390x linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
sh4 linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
sparc linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
sparc64 linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
tilegx linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
x86_64 linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00
xtensa linux-user: Add missing termbits types and values definitions 2020-08-27 12:29:50 +02:00
cpu_loop-common.h cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
elfload.c linux-user: detect mismatched ELF ABI in qemu-mips[n32][el] 2020-08-27 12:29:50 +02:00
errno_defs.h Supply missing header guards 2019-06-12 13:20:21 +02:00
exit.c build: move TARGET_GPROF to config-host.mak 2020-02-12 16:29:27 +01:00
fd-trans.c linux-user: add netlink RTM_SETLINK command 2020-07-13 21:26:33 +02:00
fd-trans.h linux-user: move TargetFdTrans functions to their own file 2018-09-25 22:36:47 +02:00
flat.h Supply missing header guards 2019-06-12 13:20:21 +02:00
flatload.c linux-user: completely re-write init_guest_space 2020-05-15 15:25:16 +01:00
ioctls.h linux-user: Add support for a group of btrfs ioctls used for subvolumes 2020-09-03 01:09:35 +02:00
linux_loop.h linux-user: Add loop control ioctls 2016-07-19 15:22:33 +03:00
linuxload.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
main.c linux-user: Ensure mmap_min_addr is non-zero 2020-07-27 22:02:40 +02:00
meson.build meson: linux-user 2020-08-21 06:30:38 -04:00
mmap.c linux-user: Adjust guest page protection for the host 2020-08-23 16:57:58 +02:00
qemu.h linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines 2020-08-27 12:29:50 +02:00
safe-syscall.S linux-user: Provide safe_syscall for fixing races between signals and syscalls 2016-05-27 14:49:51 +03:00
signal-common.h linux-user: Make sigaltstack stacks per-thread 2019-07-26 19:24:33 +02:00
signal.c linux-user: Use `qemu_log' for strace 2020-02-19 11:17:40 +01:00
socket.h Supply missing header guards 2019-06-12 13:20:21 +02:00
strace.c linux-user: Add strace support for printing OFD fcntl operations 2020-09-01 11:47:12 +02:00
strace.list linux-user: Add strace support for printing arguments of some clock and time functions 2020-08-27 12:29:50 +02:00
syscall.c linux-user: Add support for a group of btrfs ioctls used for subvolumes 2020-09-03 01:09:35 +02:00
syscall_defs.h linux-user: Add support for a group of btrfs ioctls used for subvolumes 2020-09-03 01:09:35 +02:00
syscall_types.h linux-user: Add support for a group of btrfs ioctls used for subvolumes 2020-09-03 01:09:35 +02:00
target_flat.h Supply missing header guards 2019-06-12 13:20:21 +02:00
trace-events linux-user: fix use of SIGRTMIN 2020-02-12 18:56:41 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
uaccess.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
uname.c cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
uname.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
vm86.c linux-user: Use `qemu_log' for non-strace logging 2020-02-19 11:17:40 +01:00