fs/btrfs/props.c
Source file repositories/reference/linux-study-clean/fs/btrfs/props.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/props.c- Extension
.c- Size
- 11453 bytes
- Lines
- 476
- 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/hashtable.hlinux/xattr.hmessages.hprops.hbtrfs_inode.htransaction.hctree.hxattr.hcompression.hspace-info.hfs.haccessors.hsuper.hdir-item.h
Detected Declarations
struct prop_handlerfunction find_prop_handlerfunction btrfs_validate_propfunction ignoredfunction btrfs_set_propfunction iterate_object_propsfunction inode_prop_iteratorfunction btrfs_load_inode_propsfunction prop_compression_validatefunction prop_compression_applyfunction prop_compression_ignorefunction btrfs_inode_inherit_propsfunction btrfs_props_init
Annotated Snippet
struct prop_handler {
struct hlist_node node;
const char *xattr_name;
int (*validate)(const struct btrfs_inode *inode, const char *value,
size_t len);
int (*apply)(struct btrfs_inode *inode, const char *value, size_t len);
const char *(*extract)(const struct btrfs_inode *inode);
bool (*ignore)(const struct btrfs_inode *inode);
int inheritable;
};
static const struct hlist_head *find_prop_handlers_by_hash(const u64 hash)
{
struct hlist_head *h;
h = &prop_handlers_ht[hash_min(hash, BTRFS_PROP_HANDLERS_HT_BITS)];
if (hlist_empty(h))
return NULL;
return h;
}
static const struct prop_handler *
find_prop_handler(const char *name,
const struct hlist_head *handlers)
{
struct prop_handler *h;
if (!handlers) {
u64 hash = btrfs_name_hash(name, strlen(name));
handlers = find_prop_handlers_by_hash(hash);
if (!handlers)
return NULL;
}
hlist_for_each_entry(h, handlers, node)
if (!strcmp(h->xattr_name, name))
return h;
return NULL;
}
int btrfs_validate_prop(const struct btrfs_inode *inode, const char *name,
const char *value, size_t value_len)
{
const struct prop_handler *handler;
if (strlen(name) <= XATTR_BTRFS_PREFIX_LEN)
return -EINVAL;
handler = find_prop_handler(name, NULL);
if (!handler)
return -EINVAL;
if (value_len == 0)
return 0;
return handler->validate(inode, value, value_len);
}
/*
* Check if a property should be ignored (not set) for an inode.
*
* @inode: The target inode.
* @name: The property's name.
*
* The caller must be sure the given property name is valid, for example by
* having previously called btrfs_validate_prop().
*
* Returns: true if the property should be ignored for the given inode
* false if the property must not be ignored for the given inode
*/
bool btrfs_ignore_prop(const struct btrfs_inode *inode, const char *name)
{
const struct prop_handler *handler;
handler = find_prop_handler(name, NULL);
ASSERT(handler != NULL);
return handler->ignore(inode);
}
int btrfs_set_prop(struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
const char *name, const char *value, size_t value_len,
int flags)
{
const struct prop_handler *handler;
int ret;
Annotation
- Immediate include surface: `linux/hashtable.h`, `linux/xattr.h`, `messages.h`, `props.h`, `btrfs_inode.h`, `transaction.h`, `ctree.h`, `xattr.h`.
- Detected declarations: `struct prop_handler`, `function find_prop_handler`, `function btrfs_validate_prop`, `function ignored`, `function btrfs_set_prop`, `function iterate_object_props`, `function inode_prop_iterator`, `function btrfs_load_inode_props`, `function prop_compression_validate`, `function prop_compression_apply`.
- 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.