fs/hfsplus/xattr.c
Source file repositories/reference/linux-study-clean/fs/hfsplus/xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hfsplus/xattr.c- Extension
.c- Size
- 27804 bytes
- Lines
- 1037
- 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.
- 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
hfsplus_fs.hlinux/nls.hxattr.h
Detected Declarations
function strcmp_xattr_finder_infofunction strcmp_xattr_aclfunction is_known_namespacefunction hfsplus_init_header_nodefunction hfsplus_init_map_nodefunction hfsplus_write_attributes_file_nodefunction hfsplus_create_attributes_filefunction is_xattr_operation_supportedfunction __hfsplus_setxattrfunction name_lenfunction copy_namefunction hfsplus_setxattrfunction hfsplus_getxattr_finder_infofunction __hfsplus_getxattrfunction hfsplus_getxattrfunction can_listfunction hfsplus_listxattr_finder_infofunction hfsplus_listxattrfunction hfsplus_removexattrfunction hfsplus_osx_getxattrfunction hfsplus_osx_setxattr
Annotated Snippet
if (unlikely(err)) {
pr_err("failed to extend attributes file\n");
goto end_attr_file_creation;
}
hip->phys_size = attr_file->i_size =
(loff_t)hip->alloc_blocks << sbi->alloc_blksz_shift;
hip->fs_blocks = hip->alloc_blocks << sbi->fs_shift;
inode_set_bytes(attr_file, attr_file->i_size);
}
buf = kzalloc(node_size, GFP_NOFS);
if (!buf) {
err = -ENOMEM;
goto end_attr_file_creation;
}
map_nodes = hfsplus_init_header_node(attr_file, clump_size, buf, node_size);
desc = (struct hfs_bnode_desc *)buf;
next_node = be32_to_cpu(desc->next);
index = 0;
err = hfsplus_write_attributes_file_node(attr_file, buf,
node_size, &index);
if (unlikely(err))
goto failed_header_node_init;
for (map_node_idx = 0; map_node_idx < map_nodes; map_node_idx++) {
if (next_node >= map_nodes)
next_node = 0;
hfsplus_init_map_node(buf, node_size, next_node);
err = hfsplus_write_attributes_file_node(attr_file, buf,
node_size, &index);
if (unlikely(err))
goto failed_header_node_init;
next_node++;
}
hfsplus_mark_inode_dirty(attr_file, HFSPLUS_I_ATTR_DIRTY);
sbi->attr_tree = hfs_btree_open(sb, HFSPLUS_ATTR_CNID);
if (!sbi->attr_tree)
pr_err("failed to load attributes file\n");
failed_header_node_init:
kfree(buf);
end_attr_file_creation:
iput(attr_file);
if (!err)
atomic_set(&sbi->attr_tree_state, HFSPLUS_VALID_ATTR_TREE);
else if (err == -ENOSPC)
atomic_set(&sbi->attr_tree_state, HFSPLUS_EMPTY_ATTR_TREE);
else
atomic_set(&sbi->attr_tree_state, HFSPLUS_FAILED_ATTR_TREE);
return err;
}
static inline
bool is_xattr_operation_supported(struct inode *inode)
{
if (HFSPLUS_IS_RSRC(inode))
return false;
return true;
}
int __hfsplus_setxattr(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
int err;
struct hfs_find_data cat_fd;
hfsplus_cat_entry entry;
u16 cat_entry_flags, cat_entry_type;
u16 folder_finderinfo_len = sizeof(DInfo) + sizeof(DXInfo);
u16 file_finderinfo_len = sizeof(FInfo) + sizeof(FXInfo);
hfs_dbg("ino %llu, name %s, value %p, size %zu\n",
inode->i_ino, name ? name : NULL,
value, size);
if (!is_xattr_operation_supported(inode))
return -EOPNOTSUPP;
Annotation
- Immediate include surface: `hfsplus_fs.h`, `linux/nls.h`, `xattr.h`.
- Detected declarations: `function strcmp_xattr_finder_info`, `function strcmp_xattr_acl`, `function is_known_namespace`, `function hfsplus_init_header_node`, `function hfsplus_init_map_node`, `function hfsplus_write_attributes_file_node`, `function hfsplus_create_attributes_file`, `function is_xattr_operation_supported`, `function __hfsplus_setxattr`, `function name_len`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- 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.