linux/include/uapi/linux/btrfs.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 * Copyright (C) 2007 Oracle.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License v2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 021110-1307, USA.
 */

#ifndef _UAPI_LINUX_BTRFS_H
#define _UAPI_LINUX_BTRFS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/fs.h>

#define BTRFS_IOCTL_MAGIC
#define BTRFS_VOL_NAME_MAX
#define BTRFS_LABEL_SIZE

/* this should be 4k */
#define BTRFS_PATH_NAME_MAX
struct btrfs_ioctl_vol_args {};

#define BTRFS_DEVICE_PATH_NAME_MAX
#define BTRFS_SUBVOL_NAME_MAX

#ifndef __KERNEL__
/* Deprecated since 5.7 */
#define BTRFS_SUBVOL_CREATE_ASYNC
#endif
#define BTRFS_SUBVOL_RDONLY
#define BTRFS_SUBVOL_QGROUP_INHERIT

#define BTRFS_DEVICE_SPEC_BY_ID

#define BTRFS_SUBVOL_SPEC_BY_ID

#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED

#define BTRFS_FSID_SIZE
#define BTRFS_UUID_SIZE
#define BTRFS_UUID_UNPARSED_SIZE

/*
 * flags definition for qgroup limits
 *
 * Used by:
 * struct btrfs_qgroup_limit.flags
 * struct btrfs_qgroup_limit_item.flags
 */
#define BTRFS_QGROUP_LIMIT_MAX_RFER
#define BTRFS_QGROUP_LIMIT_MAX_EXCL
#define BTRFS_QGROUP_LIMIT_RSV_RFER
#define BTRFS_QGROUP_LIMIT_RSV_EXCL
#define BTRFS_QGROUP_LIMIT_RFER_CMPR
#define BTRFS_QGROUP_LIMIT_EXCL_CMPR

struct btrfs_qgroup_limit {};

/*
 * flags definition for qgroup inheritance
 *
 * Used by:
 * struct btrfs_qgroup_inherit.flags
 */
#define BTRFS_QGROUP_INHERIT_SET_LIMITS
#define BTRFS_QGROUP_INHERIT_FLAGS_SUPP

struct btrfs_qgroup_inherit {};

struct btrfs_ioctl_qgroup_limit_args {};

/*
 * Arguments for specification of subvolumes or devices, supporting by-name or
 * by-id and flags
 *
 * The set of supported flags depends on the ioctl
 *
 * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
 * - BTRFS_IOC_SUBVOL_GETFLAGS
 * - BTRFS_IOC_SUBVOL_SETFLAGS
 */

/* Supported flags for BTRFS_IOC_RM_DEV_V2 */
#define BTRFS_DEVICE_REMOVE_ARGS_MASK

/* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */
#define BTRFS_SUBVOL_CREATE_ARGS_MASK

/* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
#define BTRFS_SUBVOL_DELETE_ARGS_MASK

struct btrfs_ioctl_vol_args_v2 {};

/*
 * structure to report errors and progress to userspace, either as a
 * result of a finished scrub, a canceled scrub or a progress inquiry
 */
struct btrfs_scrub_progress {};

#define BTRFS_SCRUB_READONLY
#define BTRFS_SCRUB_SUPPORTED_FLAGS
struct btrfs_ioctl_scrub_args {};

#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS
#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID
struct btrfs_ioctl_dev_replace_start_params {};

#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED
#define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED
#define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED
#define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED
#define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED
struct btrfs_ioctl_dev_replace_status_params {};

#define BTRFS_IOCTL_DEV_REPLACE_CMD_START
#define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS
#define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL
#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR
#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED
#define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED
#define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS
struct btrfs_ioctl_dev_replace_args {};

struct btrfs_ioctl_dev_info_args {};

/*
 * Retrieve information about the filesystem
 */

/* Request information about checksum type and size */
#define BTRFS_FS_INFO_FLAG_CSUM_INFO

/* Request information about filesystem generation */
#define BTRFS_FS_INFO_FLAG_GENERATION
/* Request information about filesystem metadata UUID */
#define BTRFS_FS_INFO_FLAG_METADATA_UUID

struct btrfs_ioctl_fs_info_args {};

/*
 * feature flags
 *
 * Used by:
 * struct btrfs_ioctl_feature_flags
 */
#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE
/*
 * Older kernels (< 4.9) on big-endian systems produced broken free space tree
 * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
 * < 4.7.3).  If this bit is clear, then the free space tree cannot be trusted.
 * btrfs-progs can also intentionally clear this bit to ask the kernel to
 * rebuild the free space tree, however this might not work on older kernels
 * that do not know about this bit. If not sure, clear the cache manually on
 * first mount when booting older kernel versions.
 */
#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID
#define BTRFS_FEATURE_COMPAT_RO_VERITY

/*
 * Put all block group items into a dedicated block group tree, greatly
 * reducing mount time for large filesystem due to better locality.
 */
#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE

#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS
#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO
#define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD

/*
 * older kernels tried to do bigger metadata blocks, but the
 * code was pretty buggy.  Lets not let them try anymore.
 */
#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA

#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF
#define BTRFS_FEATURE_INCOMPAT_RAID56
#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA
#define BTRFS_FEATURE_INCOMPAT_NO_HOLES
#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID
#define BTRFS_FEATURE_INCOMPAT_RAID1C34
#define BTRFS_FEATURE_INCOMPAT_ZONED
#define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2
#define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE
#define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA

struct btrfs_ioctl_feature_flags {};

/* balance control ioctl modes */
#define BTRFS_BALANCE_CTL_PAUSE
#define BTRFS_BALANCE_CTL_CANCEL

/*
 * this is packed, because it should be exactly the same as its disk
 * byte order counterpart (struct btrfs_disk_balance_args)
 */
struct btrfs_balance_args {} __attribute__ ((packed));

/* report balance progress to userspace */
struct btrfs_balance_progress {};

/*
 * flags definition for balance
 *
 * Restriper's general type filter
 *
 * Used by:
 * btrfs_ioctl_balance_args.flags
 * btrfs_balance_control.flags (internal)
 */
#define BTRFS_BALANCE_DATA
#define BTRFS_BALANCE_SYSTEM
#define BTRFS_BALANCE_METADATA

#define BTRFS_BALANCE_TYPE_MASK

#define BTRFS_BALANCE_FORCE
#define BTRFS_BALANCE_RESUME

/*
 * flags definitions for per-type balance args
 *
 * Balance filters
 *
 * Used by:
 * struct btrfs_balance_args
 */
#define BTRFS_BALANCE_ARGS_PROFILES
#define BTRFS_BALANCE_ARGS_USAGE
#define BTRFS_BALANCE_ARGS_DEVID
#define BTRFS_BALANCE_ARGS_DRANGE
#define BTRFS_BALANCE_ARGS_VRANGE
#define BTRFS_BALANCE_ARGS_LIMIT
#define BTRFS_BALANCE_ARGS_LIMIT_RANGE
#define BTRFS_BALANCE_ARGS_STRIPES_RANGE
#define BTRFS_BALANCE_ARGS_USAGE_RANGE

#define BTRFS_BALANCE_ARGS_MASK

/*
 * Profile changing flags.  When SOFT is set we won't relocate chunk if
 * it already has the target profile (even though it may be
 * half-filled).
 */
#define BTRFS_BALANCE_ARGS_CONVERT
#define BTRFS_BALANCE_ARGS_SOFT


/*
 * flags definition for balance state
 *
 * Used by:
 * struct btrfs_ioctl_balance_args.state
 */
#define BTRFS_BALANCE_STATE_RUNNING
#define BTRFS_BALANCE_STATE_PAUSE_REQ
#define BTRFS_BALANCE_STATE_CANCEL_REQ

struct btrfs_ioctl_balance_args {};

#define BTRFS_INO_LOOKUP_PATH_MAX
struct btrfs_ioctl_ino_lookup_args {};

#define BTRFS_INO_LOOKUP_USER_PATH_MAX
struct btrfs_ioctl_ino_lookup_user_args {};

/* Search criteria for the btrfs SEARCH ioctl family. */
struct btrfs_ioctl_search_key {};

struct btrfs_ioctl_search_header {} __attribute__ ((__may_alias__));

#define BTRFS_SEARCH_ARGS_BUFSIZE
/*
 * the buf is an array of search headers where
 * each header is followed by the actual item
 * the type field is expanded to 32 bits for alignment
 */
struct btrfs_ioctl_search_args {};

/*
 * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes.
 * The allocated size of the buffer is set in buf_size.
 */
struct btrfs_ioctl_search_args_v2 {};

/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
struct btrfs_ioctl_clone_range_args {};

/*
 * flags definition for the defrag range ioctl
 *
 * Used by:
 * struct btrfs_ioctl_defrag_range_args.flags
 */
#define BTRFS_DEFRAG_RANGE_COMPRESS
#define BTRFS_DEFRAG_RANGE_START_IO
#define BTRFS_DEFRAG_RANGE_FLAGS_SUPP

struct btrfs_ioctl_defrag_range_args {};


#define BTRFS_SAME_DATA_DIFFERS
/* For extent-same ioctl */
struct btrfs_ioctl_same_extent_info {};

struct btrfs_ioctl_same_args {};

struct btrfs_ioctl_space_info {};

struct btrfs_ioctl_space_args {};

struct btrfs_data_container {};

struct btrfs_ioctl_ino_path_args {};

struct btrfs_ioctl_logical_ino_args {};

/*
 * Return every ref to the extent, not just those containing logical block.
 * Requires logical == extent bytenr.
 */
#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET

enum btrfs_dev_stat_values {};

/* Reset statistics after reading; needs SYS_ADMIN capability */
#define BTRFS_DEV_STATS_RESET

struct btrfs_ioctl_get_dev_stats {};

#define BTRFS_QUOTA_CTL_ENABLE
#define BTRFS_QUOTA_CTL_DISABLE
#define BTRFS_QUOTA_CTL_RESCAN__NOTUSED
#define BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA
struct btrfs_ioctl_quota_ctl_args {};

struct btrfs_ioctl_quota_rescan_args {};

struct btrfs_ioctl_qgroup_assign_args {};

struct btrfs_ioctl_qgroup_create_args {};
struct btrfs_ioctl_timespec {};

struct btrfs_ioctl_received_subvol_args {};

/*
 * Caller doesn't want file data in the send stream, even if the
 * search of clone sources doesn't find an extent. UPDATE_EXTENT
 * commands will be sent instead of WRITE commands.
 */
#define BTRFS_SEND_FLAG_NO_FILE_DATA

/*
 * Do not add the leading stream header. Used when multiple snapshots
 * are sent back to back.
 */
#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER

/*
 * Omit the command at the end of the stream that indicated the end
 * of the stream. This option is used when multiple snapshots are
 * sent back to back.
 */
#define BTRFS_SEND_FLAG_OMIT_END_CMD

/*
 * Read the protocol version in the structure
 */
#define BTRFS_SEND_FLAG_VERSION

/*
 * Send compressed data using the ENCODED_WRITE command instead of decompressing
 * the data and sending it with the WRITE command. This requires protocol
 * version >= 2.
 */
#define BTRFS_SEND_FLAG_COMPRESSED

#define BTRFS_SEND_FLAG_MASK

struct btrfs_ioctl_send_args {};

/*
 * Information about a fs tree root.
 *
 * All items are filled by the ioctl
 */
struct btrfs_ioctl_get_subvol_info_args {};

#define BTRFS_MAX_ROOTREF_BUFFER_NUM
struct btrfs_ioctl_get_subvol_rootref_args {};

/*
 * Data and metadata for an encoded read or write.
 *
 * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g.,
 * compression). This can be used to read the compressed contents of a file or
 * write pre-compressed data directly to a file.
 *
 * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially
 * preadv/pwritev with additional metadata about how the data is encoded and the
 * size of the unencoded data.
 *
 * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills
 * the metadata fields, and returns the size of the encoded data. It reads one
 * extent per call. It can also read data which is not encoded.
 *
 * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data
 * from the iovecs, and returns the size of the encoded data. Note that the
 * encoded data is not validated when it is written; if it is not valid (e.g.,
 * it cannot be decompressed), then a subsequent read may return an error.
 *
 * Since the filesystem page cache contains decoded data, encoded I/O bypasses
 * the page cache. Encoded I/O requires CAP_SYS_ADMIN.
 */
struct btrfs_ioctl_encoded_io_args {};

/* Data is not compressed. */
#define BTRFS_ENCODED_IO_COMPRESSION_NONE
/* Data is compressed as a single zlib stream. */
#define BTRFS_ENCODED_IO_COMPRESSION_ZLIB
/*
 * Data is compressed as a single zstd frame with the windowLog compression
 * parameter set to no more than 17.
 */
#define BTRFS_ENCODED_IO_COMPRESSION_ZSTD
/*
 * Data is compressed sector by sector (using the sector size indicated by the
 * name of the constant) with LZO1X and wrapped in the format documented in
 * fs/btrfs/lzo.c. For writes, the compression sector size must match the
 * filesystem sector size.
 */
#define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K
#define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K
#define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K
#define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K
#define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K
#define BTRFS_ENCODED_IO_COMPRESSION_TYPES

/* Data is not encrypted. */
#define BTRFS_ENCODED_IO_ENCRYPTION_NONE
#define BTRFS_ENCODED_IO_ENCRYPTION_TYPES

/* Error codes as returned by the kernel */
enum btrfs_err_code {};

#define BTRFS_IOC_SNAP_CREATE
#define BTRFS_IOC_DEFRAG
#define BTRFS_IOC_RESIZE
#define BTRFS_IOC_SCAN_DEV
#define BTRFS_IOC_FORGET_DEV
/* trans start and trans end are dangerous, and only for
 * use by applications that know how to avoid the
 * resulting deadlocks
 */
#define BTRFS_IOC_TRANS_START
#define BTRFS_IOC_TRANS_END
#define BTRFS_IOC_SYNC

#define BTRFS_IOC_CLONE
#define BTRFS_IOC_ADD_DEV
#define BTRFS_IOC_RM_DEV
#define BTRFS_IOC_BALANCE

#define BTRFS_IOC_CLONE_RANGE

#define BTRFS_IOC_SUBVOL_CREATE
#define BTRFS_IOC_SNAP_DESTROY
#define BTRFS_IOC_DEFRAG_RANGE
#define BTRFS_IOC_TREE_SEARCH
#define BTRFS_IOC_TREE_SEARCH_V2
#define BTRFS_IOC_INO_LOOKUP
#define BTRFS_IOC_DEFAULT_SUBVOL
#define BTRFS_IOC_SPACE_INFO
#define BTRFS_IOC_START_SYNC
#define BTRFS_IOC_WAIT_SYNC
#define BTRFS_IOC_SNAP_CREATE_V2
#define BTRFS_IOC_SUBVOL_CREATE_V2
#define BTRFS_IOC_SUBVOL_GETFLAGS
#define BTRFS_IOC_SUBVOL_SETFLAGS
#define BTRFS_IOC_SCRUB
#define BTRFS_IOC_SCRUB_CANCEL
#define BTRFS_IOC_SCRUB_PROGRESS
#define BTRFS_IOC_DEV_INFO
#define BTRFS_IOC_FS_INFO
#define BTRFS_IOC_BALANCE_V2
#define BTRFS_IOC_BALANCE_CTL
#define BTRFS_IOC_BALANCE_PROGRESS
#define BTRFS_IOC_INO_PATHS
#define BTRFS_IOC_LOGICAL_INO
#define BTRFS_IOC_SET_RECEIVED_SUBVOL
#define BTRFS_IOC_SEND
#define BTRFS_IOC_DEVICES_READY
#define BTRFS_IOC_QUOTA_CTL
#define BTRFS_IOC_QGROUP_ASSIGN
#define BTRFS_IOC_QGROUP_CREATE
#define BTRFS_IOC_QGROUP_LIMIT
#define BTRFS_IOC_QUOTA_RESCAN
#define BTRFS_IOC_QUOTA_RESCAN_STATUS
#define BTRFS_IOC_QUOTA_RESCAN_WAIT
#define BTRFS_IOC_GET_FSLABEL
#define BTRFS_IOC_SET_FSLABEL
#define BTRFS_IOC_GET_DEV_STATS
#define BTRFS_IOC_DEV_REPLACE
#define BTRFS_IOC_FILE_EXTENT_SAME
#define BTRFS_IOC_GET_FEATURES
#define BTRFS_IOC_SET_FEATURES
#define BTRFS_IOC_GET_SUPPORTED_FEATURES
#define BTRFS_IOC_RM_DEV_V2
#define BTRFS_IOC_LOGICAL_INO_V2
#define BTRFS_IOC_GET_SUBVOL_INFO
#define BTRFS_IOC_GET_SUBVOL_ROOTREF
#define BTRFS_IOC_INO_LOOKUP_USER
#define BTRFS_IOC_SNAP_DESTROY_V2
#define BTRFS_IOC_ENCODED_READ
#define BTRFS_IOC_ENCODED_WRITE

#ifdef __cplusplus
}
#endif

#endif /* _UAPI_LINUX_BTRFS_H */