fs/hfsplus/inode.c
Source file repositories/reference/linux-study-clean/fs/hfsplus/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hfsplus/inode.c- Extension
.c- Size
- 23057 bytes
- Lines
- 835
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/mm.hlinux/fs.hlinux/pagemap.hlinux/mpage.hlinux/sched.hlinux/cred.hlinux/uio.hlinux/fileattr.hhfsplus_fs.hhfsplus_raw.hxattr.h
Detected Declarations
function Copyrightfunction hfsplus_write_failedfunction hfsplus_write_beginfunction hfsplus_bmapfunction hfsplus_release_foliofunction hfsplus_direct_IOfunction hfsplus_get_blockfunction hfsplus_writepagesfunction hfsplus_get_permsfunction hfsplus_file_openfunction hfsplus_file_releasefunction hfsplus_setattrfunction hfsplus_getattrfunction hfsplus_file_fsyncfunction S_ISFIFOfunction hfsplus_delete_inodefunction hfsplus_inode_read_forkfunction hfsplus_inode_write_forkfunction hfsplus_cat_read_inodefunction hfsplus_cat_write_inodefunction hfsplus_fileattr_getfunction hfsplus_fileattr_set
Annotated Snippet
static const struct file_operations hfsplus_file_operations = {
.llseek = generic_file_llseek,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,
.mmap_prepare = generic_file_mmap_prepare,
.splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.fsync = hfsplus_file_fsync,
.open = hfsplus_file_open,
.release = hfsplus_file_release,
.unlocked_ioctl = hfsplus_ioctl,
};
struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
umode_t mode)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
struct inode *inode = new_inode(sb);
struct hfsplus_inode_info *hip;
if (!inode)
return NULL;
inode->i_ino = sbi->next_cnid++;
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
set_nlink(inode, 1);
simple_inode_init_ts(inode);
hip = HFSPLUS_I(inode);
mutex_init(&hip->extents_lock);
atomic_set(&hip->opencnt, 0);
hip->extent_state = 0;
hip->flags = 0;
hip->userflags = 0;
hip->subfolders = 0;
memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
hip->alloc_blocks = 0;
hip->first_blocks = 0;
hip->cached_start = 0;
hip->cached_blocks = 0;
hip->phys_size = 0;
hip->fs_blocks = 0;
hip->rsrc_inode = NULL;
if (S_ISDIR(inode->i_mode)) {
inode->i_size = 2;
sbi->folder_count++;
inode->i_op = &hfsplus_dir_inode_operations;
inode->i_fop = &hfsplus_dir_operations;
} else if (S_ISREG(inode->i_mode)) {
sbi->file_count++;
inode->i_op = &hfsplus_file_inode_operations;
inode->i_fop = &hfsplus_file_operations;
inode->i_mapping->a_ops = &hfsplus_aops;
hip->clump_blocks = sbi->data_clump_blocks;
} else if (S_ISLNK(inode->i_mode)) {
sbi->file_count++;
inode->i_op = &hfsplus_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &hfsplus_aops;
hip->clump_blocks = 1;
} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
sbi->file_count++;
inode->i_op = &hfsplus_special_inode_operations;
} else
sbi->file_count++;
insert_inode_hash(inode);
mark_inode_dirty(inode);
hfsplus_mark_mdb_dirty(sb);
return inode;
}
void hfsplus_delete_inode(struct inode *inode)
{
struct super_block *sb = inode->i_sb;
if (S_ISDIR(inode->i_mode)) {
HFSPLUS_SB(sb)->folder_count--;
hfsplus_mark_mdb_dirty(sb);
return;
}
HFSPLUS_SB(sb)->file_count--;
if (S_ISREG(inode->i_mode)) {
if (!inode->i_nlink) {
inode->i_size = 0;
hfsplus_file_truncate(inode);
}
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/mm.h`, `linux/fs.h`, `linux/pagemap.h`, `linux/mpage.h`, `linux/sched.h`, `linux/cred.h`, `linux/uio.h`.
- Detected declarations: `function Copyright`, `function hfsplus_write_failed`, `function hfsplus_write_begin`, `function hfsplus_bmap`, `function hfsplus_release_folio`, `function hfsplus_direct_IO`, `function hfsplus_get_block`, `function hfsplus_writepages`, `function hfsplus_get_perms`, `function hfsplus_file_open`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.