fs/btrfs/ioctl.c
Source file repositories/reference/linux-study-clean/fs/btrfs/ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/ioctl.c- Extension
.c- Size
- 145344 bytes
- Lines
- 5664
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/bio.hlinux/file.hlinux/fs.hlinux/fsnotify.hlinux/pagemap.hlinux/highmem.hlinux/time.hlinux/string.hlinux/backing-dev.hlinux/mount.hlinux/namei.hlinux/writeback.hlinux/compat.hlinux/security.hlinux/xattr.hlinux/mm.hlinux/slab.hlinux/blkdev.hlinux/uuid.hlinux/btrfs.hlinux/uaccess.hlinux/iversion.hlinux/fileattr.hlinux/fsverity.hlinux/sched/xacct.hlinux/io_uring/cmd.hctree.hdisk-io.hexport.htransaction.hbtrfs_inode.h
Detected Declarations
struct btrfs_ioctl_timespec_32struct btrfs_ioctl_received_subvol_args_32struct btrfs_ioctl_get_subvol_info_args_32struct btrfs_ioctl_send_args_32struct btrfs_ioctl_encoded_io_args_32struct btrfs_uring_encoded_datastruct btrfs_uring_privstruct io_btrfs_cmdfunction btrfs_mask_fsflags_for_typefunction btrfs_inode_flags_to_fsflagsfunction btrfs_sync_inode_flags_to_i_flagsfunction check_fsflagsfunction check_fsflags_compatiblefunction btrfs_check_ioctl_vol_args_pathfunction btrfs_check_ioctl_vol_args2_subvol_namefunction btrfs_fileattr_getfunction btrfs_fileattr_setfunction btrfs_ioctl_getversionfunction btrfs_ioctl_fitrimfunction create_subvol_num_itemsfunction create_subvolfunction create_snapshotfunction btrfs_mksubvolfunction btrfs_mksnapshotfunction exclop_start_or_cancel_relocfunction btrfs_ioctl_resizefunction __btrfs_ioctl_snap_createfunction btrfs_ioctl_snap_createfunction btrfs_ioctl_snap_create_v2function btrfs_ioctl_subvol_getflagsfunction btrfs_ioctl_subvol_setflagsfunction key_in_skfunction copy_to_skfunction search_ioctlfunction btrfs_ioctl_tree_searchfunction btrfs_ioctl_tree_search_v2function btrfs_search_path_in_treefunction btrfs_search_path_in_tree_userfunction btrfs_ioctl_ino_lookupfunction ioctlfunction _btrfs_ioctl_get_subvol_infofunction btrfs_header_nritemsfunction btrfs_ioctl_get_subvol_info_32function btrfs_ioctl_get_subvol_infofunction btrfs_ioctl_get_subvol_rootreffunction btrfs_header_nritemsfunction btrfs_ioctl_snap_destroyfunction btrfs_ioctl_defrag
Annotated Snippet
struct btrfs_ioctl_timespec_32 {
__u64 sec;
__u32 nsec;
} __attribute__ ((__packed__));
struct btrfs_ioctl_received_subvol_args_32 {
char uuid[BTRFS_UUID_SIZE]; /* in */
__u64 stransid; /* in */
__u64 rtransid; /* out */
struct btrfs_ioctl_timespec_32 stime; /* in */
struct btrfs_ioctl_timespec_32 rtime; /* out */
__u64 flags; /* in */
__u64 reserved[16]; /* in */
} __attribute__ ((__packed__));
#define BTRFS_IOC_SET_RECEIVED_SUBVOL_32 _IOWR(BTRFS_IOCTL_MAGIC, 37, \
struct btrfs_ioctl_received_subvol_args_32)
struct btrfs_ioctl_get_subvol_info_args_32 {
__u64 treeid;
char name[BTRFS_VOL_NAME_MAX + 1];
__u64 parent_id;
__u64 dirid;
__u64 generation;
__u64 flags;
__u8 uuid[BTRFS_UUID_SIZE];
__u8 parent_uuid[BTRFS_UUID_SIZE];
__u8 received_uuid[BTRFS_UUID_SIZE];
__u64 ctransid;
__u64 otransid;
__u64 stransid;
__u64 rtransid;
struct btrfs_ioctl_timespec_32 ctime;
struct btrfs_ioctl_timespec_32 otime;
struct btrfs_ioctl_timespec_32 stime;
struct btrfs_ioctl_timespec_32 rtime;
__u64 reserved[8];
} __attribute__ ((__packed__));
#define BTRFS_IOC_GET_SUBVOL_INFO_32 _IOR(BTRFS_IOCTL_MAGIC, 60, \
struct btrfs_ioctl_get_subvol_info_args_32)
#endif
#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
struct btrfs_ioctl_send_args_32 {
__s64 send_fd; /* in */
__u64 clone_sources_count; /* in */
compat_uptr_t clone_sources; /* in */
__u64 parent_root; /* in */
__u64 flags; /* in */
__u32 version; /* in */
__u8 reserved[28]; /* in */
} __attribute__ ((__packed__));
#define BTRFS_IOC_SEND_32 _IOW(BTRFS_IOCTL_MAGIC, 38, \
struct btrfs_ioctl_send_args_32)
struct btrfs_ioctl_encoded_io_args_32 {
compat_uptr_t iov;
compat_ulong_t iovcnt;
__s64 offset;
__u64 flags;
__u64 len;
__u64 unencoded_len;
__u64 unencoded_offset;
__u32 compression;
__u32 encryption;
__u8 reserved[64];
};
#define BTRFS_IOC_ENCODED_READ_32 _IOR(BTRFS_IOCTL_MAGIC, 64, \
struct btrfs_ioctl_encoded_io_args_32)
#define BTRFS_IOC_ENCODED_WRITE_32 _IOW(BTRFS_IOCTL_MAGIC, 64, \
struct btrfs_ioctl_encoded_io_args_32)
#endif
/* Mask out flags that are inappropriate for the given type of inode. */
static unsigned int btrfs_mask_fsflags_for_type(const struct inode *inode,
unsigned int flags)
{
if (S_ISDIR(inode->i_mode))
return flags;
else if (S_ISREG(inode->i_mode))
return flags & ~FS_DIRSYNC_FL;
else
return flags & (FS_NODUMP_FL | FS_NOATIME_FL);
}
/*
* Export internal inode flags to the format expected by the FS_IOC_GETFLAGS
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bio.h`, `linux/file.h`, `linux/fs.h`, `linux/fsnotify.h`, `linux/pagemap.h`, `linux/highmem.h`, `linux/time.h`.
- Detected declarations: `struct btrfs_ioctl_timespec_32`, `struct btrfs_ioctl_received_subvol_args_32`, `struct btrfs_ioctl_get_subvol_info_args_32`, `struct btrfs_ioctl_send_args_32`, `struct btrfs_ioctl_encoded_io_args_32`, `struct btrfs_uring_encoded_data`, `struct btrfs_uring_priv`, `struct io_btrfs_cmd`, `function btrfs_mask_fsflags_for_type`, `function btrfs_inode_flags_to_fsflags`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.