fs/btrfs/verity.c
Source file repositories/reference/linux-study-clean/fs/btrfs/verity.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/verity.c- Extension
.c- Size
- 22761 bytes
- Lines
- 801
- 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.
- 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/init.hlinux/fs.hlinux/slab.hlinux/rwsem.hlinux/xattr.hlinux/security.hlinux/posix_acl_xattr.hlinux/iversion.hlinux/fsverity.hlinux/sched/mm.hmessages.hctree.hbtrfs_inode.htransaction.hlocking.hfs.haccessors.hioctl.hverity.horphan.h
Detected Declarations
function themfunction drop_verity_itemsfunction btrfs_drop_verity_itemsfunction keyfunction bufferfunction del_orphanfunction rollback_verityfunction finish_verityfunction btrfs_begin_enable_verityfunction btrfs_end_enable_verityfunction btrfs_get_verity_descriptorfunction btrfs_write_merkle_tree_block
Annotated Snippet
if (ret > 0) {
ret = 0;
/* No more keys of this type, we're done */
if (path->slots[0] == 0)
break;
path->slots[0]--;
} else if (ret < 0) {
btrfs_end_transaction(trans);
return ret;
}
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
/* No more keys of this type, we're done */
if (key.objectid != btrfs_ino(inode) || key.type != key_type)
break;
/*
* This shouldn't be a performance sensitive function because
* it's not used as part of truncate. If it ever becomes
* perf sensitive, change this to walk forward and bulk delete
* items
*/
ret = btrfs_del_items(trans, root, path, path->slots[0], 1);
if (ret) {
btrfs_end_transaction(trans);
return ret;
}
count++;
btrfs_release_path(path);
btrfs_end_transaction(trans);
}
btrfs_end_transaction(trans);
return count;
}
/*
* Drop all verity items
*
* @inode: inode to drop verity items for
*
* In most contexts where we are dropping verity items, we want to do it for all
* the types of verity items, not a particular one.
*
* Returns: 0 on success, negative error code on failure.
*/
int btrfs_drop_verity_items(struct btrfs_inode *inode)
{
int ret;
ret = drop_verity_items(inode, BTRFS_VERITY_DESC_ITEM_KEY);
if (ret < 0)
return ret;
ret = drop_verity_items(inode, BTRFS_VERITY_MERKLE_ITEM_KEY);
if (ret < 0)
return ret;
return 0;
}
/*
* Insert and write inode items with a given key type and offset.
*
* @inode: inode to insert for
* @key_type: key type to insert
* @offset: item offset to insert at
* @src: source data to write
* @len: length of source data to write
*
* Write len bytes from src into items of up to 2K length.
* The inserted items will have key (ino, key_type, offset + off) where off is
* consecutively increasing from 0 up to the last item ending at offset + len.
*
* Returns 0 on success and a negative error code on failure.
*/
static int write_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
const char *src, u64 len)
{
struct btrfs_trans_handle *trans;
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_root *root = inode->root;
struct extent_buffer *leaf;
struct btrfs_key key;
unsigned long copy_bytes;
unsigned long src_offset = 0;
void *data;
int ret = 0;
path = btrfs_alloc_path();
if (!path)
Annotation
- Immediate include surface: `linux/init.h`, `linux/fs.h`, `linux/slab.h`, `linux/rwsem.h`, `linux/xattr.h`, `linux/security.h`, `linux/posix_acl_xattr.h`, `linux/iversion.h`.
- Detected declarations: `function them`, `function drop_verity_items`, `function btrfs_drop_verity_items`, `function key`, `function buffer`, `function del_orphan`, `function rollback_verity`, `function finish_verity`, `function btrfs_begin_enable_verity`, `function btrfs_end_enable_verity`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.